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

Delta Between Two Patch Sets: include.preload.js

Issue 29436567: Issue 3200 - Delay initialization for prerendered documents (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Address comments to Patch Set 2 Created May 19, 2017, 11:57 p.m.
Right Patch Set: Move common logic into separate function Created Aug. 24, 2017, 2:06 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 | « composer.postload.js ('k') | safari/ext/background.js » ('j') | 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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-present 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 }); 572 });
573 573
574 this.propertyFilters.load(function() 574 this.propertyFilters.load(function()
575 { 575 {
576 propertyFiltersLoaded = true; 576 propertyFiltersLoaded = true;
577 checkLoaded(); 577 checkLoaded();
578 }); 578 });
579 } 579 }
580 }; 580 };
581 581
582 if (document instanceof HTMLDocument) 582 function whenDocumentVisible(callback)
583 { 583 {
584 checkSitekey();
585 wrapWebSocket();
586
587 var elemhide = new ElemHide();
588
589 if (document.visibilityState == "prerender") 584 if (document.visibilityState == "prerender")
590 { 585 {
591 // For prerendered documents, wait until the document is made visible. We 586 // For prerendered documents, wait until the document is made visible. We
592 // do not have access to the page property of the SafariBrowserTab object 587 // do not have access to the page property of the SafariBrowserTab object
593 // associated with this document until it is visible. Without the page 588 // associated with this document until it is visible. Without the page
594 // property, we cannot get a response from the background page. 589 // property, we cannot get a response from the background page.
595 let onVisibilitychange = function() 590 let onVisibilitychange = function()
596 { 591 {
597 document.removeEventListener("visibilitychange", onVisibilitychange); 592 document.removeEventListener("visibilitychange", onVisibilitychange);
598 593 callback();
599 elemhide.apply();
600 }; 594 };
601 595
602 document.addEventListener("visibilitychange", onVisibilitychange); 596 document.addEventListener("visibilitychange", onVisibilitychange);
603 } 597 }
604 else 598 else
605 { 599 {
606 elemhide.apply(); 600 callback();
607 } 601 }
602 }
603
604 if (document instanceof HTMLDocument)
605 {
606 checkSitekey();
607 wrapWebSocket();
608
609 var elemhide = new ElemHide();
610
611 whenDocumentVisible(elemhide.apply.bind(elemhide));
608 612
609 document.addEventListener("error", function(event) 613 document.addEventListener("error", function(event)
610 { 614 {
611 checkCollapse(event.target); 615 checkCollapse(event.target);
612 }, true); 616 }, true);
613 617
614 document.addEventListener("load", function(event) 618 document.addEventListener("load", function(event)
615 { 619 {
616 var element = event.target; 620 var element = event.target;
617 if (/^i?frame$/.test(element.localName)) 621 if (/^i?frame$/.test(element.localName))
618 checkCollapse(element); 622 checkCollapse(element);
619 }, true); 623 }, true);
620 } 624 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld