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

Unified Diff: include.postload.js

Issue 5088751004942336: Issue 370 - Right-clicked element is removed independent of created filter (Closed)
Patch Set: Created July 18, 2014, 9:13 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« block.js ('K') | « block.js ('k') | include.preload.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.postload.js
===================================================================
--- a/include.postload.js
+++ b/include.postload.js
@@ -487,7 +487,7 @@
clickHide_deactivate();
break;
case "clickhide-new-filter":
- // The request is received by all frames, so ignore it if we're not the frame the
+ // The message is received by all frames, so ignore it if we're not the frame the
// user right-clicked in
if(!lastRightClickEvent)
return;
@@ -518,7 +518,7 @@
// Following test will be true if we found the element with the filter URL
if(msg.filter === url)
{
- // This request would have come from the chrome.contextMenu handler, so we
+ // This message would have come from the chrome.contextMenu handler, so we
// simulate the user having chosen the element to get rid of via the usual means.
clickHide_activated = true;
// FIXME: clickHideFilters is erased in clickHide_mouseClick anyway, so why set it?
@@ -531,7 +531,7 @@
clickHide_mouseClick(lastRightClickEvent);
}
else
- console.log("clickhide-new-filter: URLs don't match. Couldn't find that element.", request.filter, url, lastRightClickEvent.target.src);
+ console.log("clickhide-new-filter: URLs don't match. Couldn't find that element.", msg.filter, url, lastRightClickEvent.target.src);
break;
case "clickhide-init":
if (clickHideFiltersDialog)
@@ -546,16 +546,48 @@
case "clickhide-move":
if (clickHideFiltersDialog)
{
- clickHideFiltersDialog.style.left = (parseInt(clickHideFiltersDialog.style.left, 10) + request.x) + "px";
- clickHideFiltersDialog.style.top = (parseInt(clickHideFiltersDialog.style.top, 10) + request.y) + "px";
+ clickHideFiltersDialog.style.left = (parseInt(clickHideFiltersDialog.style.left, 10) + msg.x) + "px";
+ clickHideFiltersDialog.style.top = (parseInt(clickHideFiltersDialog.style.top, 10) + msg.y) + "px";
}
break;
case "clickhide-close":
if (clickHideFiltersDialog)
{
// Explicitly get rid of currentElement
- if (msg.remove && currentElement && currentElement.parentNode)
- currentElement.parentNode.removeChild(currentElement);
+ var filters = msg.filters;
+ if (filters)
+ {
+ var isHidden = false;
+ var selectors = [];
+ for (var i = 0; i < filters.length; i++)
+ {
+ var selector = filters[i].match(/##(.*)$/);
+ if (selector)
+ {
+ if (currentElement.matches(selector[1]))
+ isHidden = true;
+
+ selectors.push(selector[1]);
+ }
+ }
+ if (setElemhideCSSRules)
+ setElemhideCSSRules(selectors);
Wladimir Palant 2014/11/17 19:53:57 The code above has multiple issues: * It doesn't
Thomas Greiner 2014/11/27 14:46:07 What we could do is instead of just forwarding the
+
+ if (!isHidden)
+ {
+ var element = currentElement;
+ ext.backgroundPage.sendMessage({
+ type: "should-collapse",
+ url: element.src,
+ documentUrl: document.URL,
+ mediatype: typeMap[element.localName]
+ }, function(response)
+ {
+ if (response && element.parentNode)
+ element.style.setProperty("display", "none", "important");
Wladimir Palant 2014/11/17 19:53:57 We don't need to check the element's parent node i
Sebastian Noack 2014/11/27 12:43:40 What is if element collapsing is disabled in the o
Thomas Greiner 2014/11/27 14:46:07 That's a valid comment and it doesn't seem like we
Sebastian Noack 2014/11/27 15:15:48 If that is sufficient, fine for me.
+ });
+ }
+ }
clickHide_deactivate();
}
« block.js ('K') | « block.js ('k') | include.preload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld