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

Side by Side Diff: include.preload.js

Issue 29348869: Issue 4101 - Prevent runaway MutationObservers (Closed)
Patch Set: Created July 29, 2016, 9:06 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 type: "filters.collapse", 143 type: "filters.collapse",
144 urls: urls, 144 urls: urls,
145 mediatype: mediatype, 145 mediatype: mediatype,
146 baseURL: document.location.href 146 baseURL: document.location.href
147 }, 147 },
148 148
149 function(collapse) 149 function(collapse)
150 { 150 {
151 function collapseElement() 151 function collapseElement()
152 { 152 {
153 var propertyName = "display";
154 var propertyValue = "none";
153 if (element.localName == "frame") 155 if (element.localName == "frame")
154 element.style.setProperty("visibility", "hidden", "important"); 156 {
155 else 157 propertyName = "visibility";
156 element.style.setProperty("display", "none", "important"); 158 propertyValue = "hidden";
159 }
160
161 if (element.style.getPropertyValue(propertyName) !== propertyValue ||
Sebastian Noack 2016/08/10 12:55:57 Nit: AS per Mozilla's coding practices we perfer !
kzar 2016/08/11 13:53:30 Done.
162 element.style.getPropertyPriority(propertyName) !== "important")
163 element.style.setProperty(propertyName, propertyValue, "important");
157 } 164 }
158 165
159 if (collapse && !element._collapsed) 166 if (collapse && !element._collapsed)
Sebastian Noack 2016/08/10 12:55:57 With your changes to collapseElement(), the _colla
kzar 2016/08/11 13:53:30 Done.
160 { 167 {
161 collapseElement(); 168 collapseElement();
162 element._collapsed = true; 169 element._collapsed = true;
163 170
164 if (MutationObserver) 171 if (MutationObserver)
165 new MutationObserver(collapseElement).observe( 172 new MutationObserver(collapseElement).observe(
166 element, { 173 element, {
167 attributes: true, 174 attributes: true,
168 attributeFilter: ["style"] 175 attributeFilter: ["style"]
169 } 176 }
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 }, true); 571 }, true);
565 572
566 return updateStylesheet; 573 return updateStylesheet;
567 } 574 }
568 575
569 if (document instanceof HTMLDocument) 576 if (document instanceof HTMLDocument)
570 { 577 {
571 checkSitekey(); 578 checkSitekey();
572 window.updateStylesheet = init(document); 579 window.updateStylesheet = init(document);
573 } 580 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld