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

Side by Side Diff: composer.postload.js

Issue 29350213: Issue 4364 - Drop support for Chrome 29-40 and remove legacy code (Closed)
Patch Set: Rebased, renamed function to runInPageContext(), fixed typo in comment Created Sept. 9, 2016, 2:38 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 } 478 }
479 unhighlightElements(); 479 unhighlightElements();
480 480
481 let overlays = document.getElementsByClassName("__adblockplus__overlay"); 481 let overlays = document.getElementsByClassName("__adblockplus__overlay");
482 while (overlays.length > 0) 482 while (overlays.length > 0)
483 overlays[0].parentNode.removeChild(overlays[0]); 483 overlays[0].parentNode.removeChild(overlays[0]);
484 484
485 ext.onExtensionUnloaded.removeListener(deactivateBlockElement); 485 ext.onExtensionUnloaded.removeListener(deactivateBlockElement);
486 } 486 }
487 487
488 // In Chrome 37-40, the document_end content script (this one) runs properly, 488 if (document instanceof HTMLDocument)
489 // while the document_start content scripts (that defines ext) might not. Check
490 // whether variable ext exists before continuing to avoid
491 // "Uncaught ReferenceError: ext is not defined". See https://crbug.com/416907
492 if ("ext" in window && document instanceof HTMLDocument)
493 { 489 {
494 // Use a contextmenu handler to save the last element the user right-clicked 490 // Use a contextmenu handler to save the last element the user right-clicked
495 // on. To make things easier, we actually save the DOM event. We have to do 491 // on. To make things easier, we actually save the DOM event. We have to do
496 // this because the contextMenu API only provides a URL, not the actual DOM 492 // this because the contextMenu API only provides a URL, not the actual DOM
497 // element. 493 // element.
498 // We also need to make sure that the previous right click event, 494 // We also need to make sure that the previous right click event,
499 // if there is one, is removed. We don't know which frame it is in so we must 495 // if there is one, is removed. We don't know which frame it is in so we must
500 // send a message to the other frames to clear their old right click events. 496 // send a message to the other frames to clear their old right click events.
501 document.addEventListener("contextmenu", event => 497 document.addEventListener("contextmenu", event =>
502 { 498 {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 if (currentElement && msg.remove) 542 if (currentElement && msg.remove)
547 { 543 {
548 // Hide the selected element itself if an added blocking 544 // Hide the selected element itself if an added blocking
549 // filter is causing it to collapse. Note that this 545 // filter is causing it to collapse. Note that this
550 // behavior is incomplete, but the best we can do here, 546 // behavior is incomplete, but the best we can do here,
551 // e.g. if an added blocking filter matches other elements, 547 // e.g. if an added blocking filter matches other elements,
552 // the effect won't be visible until the page is is reloaded. 548 // the effect won't be visible until the page is is reloaded.
553 checkCollapse(currentElement.prisoner || currentElement); 549 checkCollapse(currentElement.prisoner || currentElement);
554 550
555 // Apply added element hiding filters. 551 // Apply added element hiding filters.
556 updateStylesheet(); 552 elemhide.apply();
557 } 553 }
558 deactivateBlockElement(); 554 deactivateBlockElement();
559 break; 555 break;
560 case "composer.content.clearPreviousRightClickEvent": 556 case "composer.content.clearPreviousRightClickEvent":
561 if (!lastRightClickEventIsMostRecent) 557 if (!lastRightClickEventIsMostRecent)
562 lastRightClickEvent = null; 558 lastRightClickEvent = null;
563 lastRightClickEventIsMostRecent = false; 559 lastRightClickEventIsMostRecent = false;
564 break; 560 break;
565 case "composer.content.dialogOpened": 561 case "composer.content.dialogOpened":
566 if (window == window.top) 562 if (window == window.top)
(...skipping 13 matching lines...) Expand all
580 } 576 }
581 }); 577 });
582 } 578 }
583 break; 579 break;
584 } 580 }
585 }); 581 });
586 582
587 if (window == window.top) 583 if (window == window.top)
588 ext.backgroundPage.sendMessage({type: "composer.ready"}); 584 ext.backgroundPage.sendMessage({type: "composer.ready"});
589 } 585 }
OLDNEW
« chrome/ext/background.js ('K') | « chrome/ext/background.js ('k') | include.preload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld