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

Delta Between Two Patch Sets: include.postload.js

Issue 5173617369284608: Issue 1868 - Handle <area> element properly when selected with "Block element" (Closed)
Left Patch Set: Created Jan. 28, 2015, 11:34 a.m.
Right Patch Set: Rebased and fixed grammar in comment Created Feb. 10, 2015, 10:12 a.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 | « no previous file | no next file » | 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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 // Turn on the choose element to create filter thing 328 // Turn on the choose element to create filter thing
329 function clickHide_activate() { 329 function clickHide_activate() {
330 if(document == null) 330 if(document == null)
331 return; 331 return;
332 332
333 // If we are already selecting, abort now 333 // If we are already selecting, abort now
334 if (clickHide_activated || clickHideFiltersDialog) 334 if (clickHide_activated || clickHideFiltersDialog)
335 clickHide_deactivate(); 335 clickHide_deactivate();
336 336
337 // Add overlays for blockable elements that don't emit mouse events that they can still be selected 337 // Add overlays for blockable elements that don't emit mouse events,
kzar 2015/02/09 17:24:41 Nitpick: Should read "...so that they can still be
Sebastian Noack 2015/02/10 10:19:27 Done.
338 // so that they can still be selected.
338 var elts = document.querySelectorAll('object,embed,iframe,frame'); 339 var elts = document.querySelectorAll('object,embed,iframe,frame');
339 for(var i=0; i<elts.length; i++) 340 for(var i=0; i<elts.length; i++)
340 { 341 {
341 var element = elts[i]; 342 var element = elts[i];
342 if (isBlockable(element)) 343 if (isBlockable(element))
343 addElementOverlay(element); 344 addElementOverlay(element);
344 } 345 }
345 346
346 clickHide_activated = true; 347 clickHide_activated = true;
347 document.addEventListener("mouseover", clickHide_mouseOver, true); 348 document.addEventListener("mouseover", clickHide_mouseOver, true);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 if (element instanceof HTMLElement && element.localName != "area") 415 if (element instanceof HTMLElement && element.localName != "area")
415 { 416 {
416 // Handle <area> and their <map> elements specially, 417 // Handle <area> and their <map> elements specially,
417 // blocking the image they are associated with 418 // blocking the image they are associated with
418 if (element.localName == "map") 419 if (element.localName == "map")
419 { 420 {
420 var images = document.querySelectorAll("img[usemap]"); 421 var images = document.querySelectorAll("img[usemap]");
421 for (var i = 0; i < images.length; i++) 422 for (var i = 0; i < images.length; i++)
422 { 423 {
423 var image = images[i]; 424 var image = images[i];
424 var usemap = image.getAttribute("usemap"); 425 var usemap = image.getAttribute("usemap");
kzar 2015/02/09 17:24:41 Don't we need to check that usemap isn't null befo
Sebastian Noack 2015/02/10 10:19:27 Mind the CSS selector above, excluding elements wi
kzar 2015/02/10 11:03:01 Ah OK
425 var index = usemap.indexOf("#"); 426 var index = usemap.indexOf("#");
426 427
427 if (index != -1 && usemap.substr(index + 1) == element.name) 428 if (index != -1 && usemap.substr(index + 1) == element.name)
428 return getBlockableElementOrAncestor(image); 429 return getBlockableElementOrAncestor(image);
429 } 430 }
430 431
431 return null; 432 return null;
432 } 433 }
433 434
434 if (isBlockable(element)) 435 if (isBlockable(element))
435 return element; 436 return element;
436 } 437 }
437 438
438 element = element.parentElement; 439 element = element.parentElement;
439 } 440 }
440 441
441 return null; 442 return null;
442 } 443 }
443
444 444
445 // Hovering over an element so highlight it 445 // Hovering over an element so highlight it
446 function clickHide_mouseOver(e) 446 function clickHide_mouseOver(e)
447 { 447 {
448 if (clickHide_activated == false) 448 if (clickHide_activated == false)
449 return; 449 return;
450 450
451 var target = getBlockableElementOrAncestor(e.target); 451 var target = getBlockableElementOrAncestor(e.target);
452 452
453 if (target) 453 if (target)
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 lastRightClickEventValid = false; 755 lastRightClickEventValid = false;
756 else 756 else
757 lastRightClickEvent = null; 757 lastRightClickEvent = null;
758 break; 758 break;
759 } 759 }
760 }); 760 });
761 761
762 if (window == window.top) 762 if (window == window.top)
763 ext.backgroundPage.sendMessage({type: "report-html-page"}); 763 ext.backgroundPage.sendMessage({type: "report-html-page"});
764 } 764 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld