Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: include.preload.js

Issue 5978149049335808: Issue 1290 - Added support for un-prefixedcreateShadowRoot (Closed)
Left Patch Set: Created Aug. 29, 2014, 8:24 p.m.
Right Patch Set: Addressed comment Created Aug. 29, 2014, 10:18 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // prior to Chrome 37, content scripts don't run on about:blank 117 // prior to Chrome 37, content scripts don't run on about:blank
118 // and about:srcdoc. So we have to apply element hiding and collapsing 118 // and about:srcdoc. So we have to apply element hiding and collapsing
119 // from the parent frame, when inline frames are loaded. 119 // from the parent frame, when inline frames are loaded.
120 var match = navigator.userAgent.match(/\bChrome\/(\d+)/); 120 var match = navigator.userAgent.match(/\bChrome\/(\d+)/);
121 var fixInlineFrames = match && parseInt(match[1]) < 37); 121 var fixInlineFrames = match && parseInt(match[1]) < 37);
122 122
123 // use Shadow DOM if available to don't mess with web pages that 123 // use Shadow DOM if available to don't mess with web pages that
124 // rely on the order of their own <style> tags (#309). However we 124 // rely on the order of their own <style> tags (#309). However we
125 // must not create the shadow root in the response callback passed 125 // must not create the shadow root in the response callback passed
126 // to sendMessage(), otherwise Chrome breaks some websites (#450). 126 // to sendMessage(), otherwise Chrome breaks some websites (#450).
127 var canUseShadow = "createShadowRoot" in document.documentElement; 127 var shadow = null;
128 if (canUseShadow) 128 if ("createShadowRoot" in document.documentElement)
129 { 129 {
130 var shadow = document.documentElement.createShadowRoot(); 130 shadow = document.documentElement.createShadowRoot();
Wladimir Palant 2014/08/29 20:49:51 I apparently missed that in the previous review -
Sebastian Noack 2014/08/29 22:19:29 Done.
131 shadow.appendChild(document.createElement("shadow")); 131 shadow.appendChild(document.createElement("shadow"));
132 } 132 }
133 133
134 // Sets the currently used CSS rules for elemhide filters 134 // Sets the currently used CSS rules for elemhide filters
135 var setElemhideCSSRules = function(selectors) 135 var setElemhideCSSRules = function(selectors)
136 { 136 {
137 if (selectors.length == 0) 137 if (selectors.length == 0)
138 return; 138 return;
139 139
140 var style = document.createElement("style"); 140 var style = document.createElement("style");
141 style.setAttribute("type", "text/css"); 141 style.setAttribute("type", "text/css");
142 142
143 if (canUseShadow) 143 if (shadow)
144 { 144 {
145 shadow.appendChild(style); 145 shadow.appendChild(style);
146 146
147 for (var i = 0; i < selectors.length; i++) 147 for (var i = 0; i < selectors.length; i++)
148 selectors[i] = "::content " + selectors[i]; 148 selectors[i] = "::content " + selectors[i];
149 } 149 }
150 else 150 else
151 { 151 {
152 // Try to insert the style into the <head> tag, inserting directly under t he 152 // Try to insert the style into the <head> tag, inserting directly under t he
153 // document root breaks dev tools functionality: 153 // document root breaks dev tools functionality:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 }, true); 199 }, true);
200 200
201 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); 201 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules);
202 } 202 }
203 203
204 if (document instanceof HTMLDocument) 204 if (document instanceof HTMLDocument)
205 { 205 {
206 checkExceptionKey(); 206 checkExceptionKey();
207 init(document); 207 init(document);
208 } 208 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld