OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 var style = null; | 286 var style = null; |
287 var observer = null; | 287 var observer = null; |
288 | 288 |
289 // Use Shadow DOM if available to don't mess with web pages that rely on | 289 // Use Shadow DOM if available to don't mess with web pages that rely on |
290 // the order of their own <style> tags (#309). | 290 // the order of their own <style> tags (#309). |
291 // | 291 // |
292 // However, creating a shadow root breaks running CSS transitions. So we | 292 // However, creating a shadow root breaks running CSS transitions. So we |
293 // have to create the shadow root before transistions might start (#452). | 293 // have to create the shadow root before transistions might start (#452). |
294 // | 294 // |
295 // Also, using shadow DOM causes issues on some Google websites, | 295 // Also, using shadow DOM causes issues on some Google websites, |
296 // including Goolgle Docs and Gmail (#1770, #2602). | 296 // including Google Docs and Gmail (#1770, #2602). |
297 if ("createShadowRoot" in document.documentElement && !/\.google\.com$/.test(d
ocument.domain)) | 297 if ("createShadowRoot" in document.documentElement && !/\.google\.com$/.test(d
ocument.domain)) |
298 { | 298 { |
299 shadow = document.documentElement.createShadowRoot(); | 299 shadow = document.documentElement.createShadowRoot(); |
300 shadow.appendChild(document.createElement("shadow")); | 300 shadow.appendChild(document.createElement("shadow")); |
301 } | 301 } |
302 | 302 |
303 var updateStylesheet = function(reinject) | 303 var updateStylesheet = function(reinject) |
304 { | 304 { |
305 ext.backgroundPage.sendMessage({type: "get-selectors"}, function(selectors) | 305 ext.backgroundPage.sendMessage({type: "get-selectors"}, function(selectors) |
306 { | 306 { |
(...skipping 13 matching lines...) Expand all Loading... |
320 { | 320 { |
321 // Create <style> element lazily, only if we add styles. Add it to | 321 // Create <style> element lazily, only if we add styles. Add it to |
322 // the shadow DOM if possible. Otherwise fallback to the <head> or | 322 // the shadow DOM if possible. Otherwise fallback to the <head> or |
323 // <html> element. If we have injected a style element before that | 323 // <html> element. If we have injected a style element before that |
324 // has been removed (the sheet property is null), create a new one. | 324 // has been removed (the sheet property is null), create a new one. |
325 style = document.createElement("style"); | 325 style = document.createElement("style"); |
326 (shadow || document.head || document.documentElement).appendChild(style)
; | 326 (shadow || document.head || document.documentElement).appendChild(style)
; |
327 | 327 |
328 // It can happen that the frame already navigated to a different | 328 // It can happen that the frame already navigated to a different |
329 // document while we were waiting for the background page to respond. | 329 // document while we were waiting for the background page to respond. |
330 // In that case the sheet property will stay null, after addind the | 330 // In that case the sheet property will stay null, after adding the |
331 // <style> element to the shadow DOM. | 331 // <style> element to the shadow DOM. |
332 if (style.sheet) | 332 if (style.sheet) |
333 { | 333 { |
334 // If using shadow DOM, we have to add the ::content pseudo-element | 334 // If using shadow DOM, we have to add the ::content pseudo-element |
335 // before each selector, in order to match elements within the | 335 // before each selector, in order to match elements within the |
336 // insertion point. | 336 // insertion point. |
337 if (shadow) | 337 if (shadow) |
338 selectors = convertSelectorsForShadowDOM(selectors); | 338 selectors = convertSelectorsForShadowDOM(selectors); |
339 | 339 |
340 // WebKit (and Blink?) apparently chokes when the selector list in a | 340 // WebKit (and Blink?) apparently chokes when the selector list in a |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 }, true); | 392 }, true); |
393 | 393 |
394 return updateStylesheet; | 394 return updateStylesheet; |
395 } | 395 } |
396 | 396 |
397 if (document instanceof HTMLDocument) | 397 if (document instanceof HTMLDocument) |
398 { | 398 { |
399 checkSitekey(); | 399 checkSitekey(); |
400 window.updateStylesheet = init(document); | 400 window.updateStylesheet = init(document); |
401 } | 401 } |
OLD | NEW |