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

Side by Side Diff: include.postload.js

Issue 5088751004942336: Issue 370 - Right-clicked element is removed independent of created filter (Closed)
Patch Set: Created Jan. 10, 2014, 10:27 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
« block.js ('K') | « block.js ('k') | 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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 case "get-clickhide-state": 504 case "get-clickhide-state":
505 sendResponse({active: clickHide_activated}); 505 sendResponse({active: clickHide_activated});
506 break; 506 break;
507 case "clickhide-activate": 507 case "clickhide-activate":
508 clickHide_activate(); 508 clickHide_activate();
509 break; 509 break;
510 case "clickhide-deactivate": 510 case "clickhide-deactivate":
511 clickHide_deactivate(); 511 clickHide_deactivate();
512 break; 512 break;
513 case "clickhide-new-filter": 513 case "clickhide-new-filter":
514 // The request is received by all frames, so ignore it if we're not the frame the 514 // The message is received by all frames, so ignore it if we're not the frame the
515 // user right-clicked in 515 // user right-clicked in
516 if(!lastRightClickEvent) 516 if(!lastRightClickEvent)
517 return; 517 return;
518 // We hope the URL we are given is the same as the one in the element re ferenced 518 // We hope the URL we are given is the same as the one in the element re ferenced
519 // by lastRightClickEvent.target. If not, we just discard 519 // by lastRightClickEvent.target. If not, we just discard
520 var target = lastRightClickEvent.target; 520 var target = lastRightClickEvent.target;
521 var url = target.src; 521 var url = target.src;
522 // If we don't have the element with a src URL same as the filter, look for it. 522 // If we don't have the element with a src URL same as the filter, look for it.
523 // Chrome's context menu API is terrible. Why can't it give us the frigg in' element 523 // Chrome's context menu API is terrible. Why can't it give us the frigg in' element
524 // to start with? 524 // to start with?
(...skipping 10 matching lines...) Expand all
535 // This is hopefully our element. In case of multiple elements 535 // This is hopefully our element. In case of multiple elements
536 // with the same src, only one will be highlighted. 536 // with the same src, only one will be highlighted.
537 target = elts[i]; 537 target = elts[i];
538 break; 538 break;
539 } 539 }
540 } 540 }
541 } 541 }
542 // Following test will be true if we found the element with the filter U RL 542 // Following test will be true if we found the element with the filter U RL
543 if(msg.filter === url) 543 if(msg.filter === url)
544 { 544 {
545 // This request would have come from the chrome.contextMenu handler, s o we 545 // This message would have come from the chrome.contextMenu handler, s o we
546 // simulate the user having chosen the element to get rid of via the u sual means. 546 // simulate the user having chosen the element to get rid of via the u sual means.
547 clickHide_activated = true; 547 clickHide_activated = true;
548 // FIXME: clickHideFilters is erased in clickHide_mouseClick anyway, s o why set it? 548 // FIXME: clickHideFilters is erased in clickHide_mouseClick anyway, s o why set it?
549 clickHideFilters = [msg.filter]; 549 clickHideFilters = [msg.filter];
550 // Coerce red highlighted overlay on top of element to remove. 550 // Coerce red highlighted overlay on top of element to remove.
551 // TODO: Wow, the design of the clickHide stuff is really dumb - gotta fix it sometime 551 // TODO: Wow, the design of the clickHide stuff is really dumb - gotta fix it sometime
552 currentElement = addElementOverlay(target); 552 currentElement = addElementOverlay(target);
553 currentElement_backgroundColor = target.style.backgroundColor; 553 currentElement_backgroundColor = target.style.backgroundColor;
554 // clickHide_mouseOver(lastRightClickEvent); 554 // clickHide_mouseOver(lastRightClickEvent);
555 clickHide_mouseClick(lastRightClickEvent); 555 clickHide_mouseClick(lastRightClickEvent);
556 } 556 }
557 else 557 else
558 console.log("clickhide-new-filter: URLs don't match. Couldn't find tha t element.", request.filter, url, lastRightClickEvent.target.src); 558 console.log("clickhide-new-filter: URLs don't match. Couldn't find tha t element.", msg.filter, url, lastRightClickEvent.target.src);
559 break; 559 break;
560 case "clickhide-init": 560 case "clickhide-init":
561 if (clickHideFiltersDialog) 561 if (clickHideFiltersDialog)
562 { 562 {
563 sendResponse({filters: clickHide_filters}); 563 sendResponse({filters: clickHide_filters});
564 564
565 clickHideFiltersDialog.style.width = (msg.width + 5) + "px"; 565 clickHideFiltersDialog.style.width = (msg.width + 5) + "px";
566 clickHideFiltersDialog.style.height = (msg.height + 5) + "px"; 566 clickHideFiltersDialog.style.height = (msg.height + 5) + "px";
567 clickHideFiltersDialog.style.visibility = "visible"; 567 clickHideFiltersDialog.style.visibility = "visible";
568 } 568 }
569 break; 569 break;
570 case "clickhide-move": 570 case "clickhide-move":
571 if (clickHideFiltersDialog) 571 if (clickHideFiltersDialog)
572 { 572 {
573 clickHideFiltersDialog.style.left = (parseInt(clickHideFiltersDialog.s tyle.left, 10) + request.x) + "px"; 573 clickHideFiltersDialog.style.left = (parseInt(clickHideFiltersDialog.s tyle.left, 10) + msg.x) + "px";
574 clickHideFiltersDialog.style.top = (parseInt(clickHideFiltersDialog.st yle.top, 10) + request.y) + "px"; 574 clickHideFiltersDialog.style.top = (parseInt(clickHideFiltersDialog.st yle.top, 10) + msg.y) + "px";
575 } 575 }
576 break; 576 break;
577 case "clickhide-close": 577 case "clickhide-close":
578 if (clickHideFiltersDialog) 578 if (clickHideFiltersDialog)
Wladimir Palant 2014/01/10 16:28:56 You should add |&& currentElement| check here whic
579 { 579 {
580 // Explicitly get rid of currentElement 580 // Explicitly get rid of currentElement
581 if (msg.remove && currentElement && currentElement.parentNode) 581 var element = currentElement;
582 currentElement.parentNode.removeChild(currentElement); 582 ext.backgroundPage.sendMessage({
583 type: "should-collapse",
584 url: element.src,
585 documentUrl: document.URL,
586 mediatype: typeMap[element.localName]
587 }, function(response)
588 {
589 if (response && element.parentNode)
590 element.parentNode.removeChild(element);
591 });
Wladimir Palant 2014/01/10 16:28:56 What if an element hiding filter was added? Not on
Sebastian Noack 2014/06/25 16:40:59 The problem is not (only) that the element is remo
Wladimir Palant 2014/06/25 18:49:34 We don't care, going through the entire document l
Sebastian Noack 2014/06/25 19:05:05 Actually we exactly do that already, when the matc
Thomas Greiner 2014/07/17 15:35:49 This issue only addresses the case when a filter d
Wladimir Palant 2014/07/17 15:55:10 That would be the best solution. If that's too com
583 592
584 clickHide_deactivate(); 593 clickHide_deactivate();
585 } 594 }
586 break; 595 break;
587 default: 596 default:
588 sendResponse({}); 597 sendResponse({});
589 break; 598 break;
590 } 599 }
591 }); 600 });
592 } 601 }
OLDNEW
« block.js ('K') | « block.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld