uBlock-LLC / uBlock

uBlock: a fast, lightweight, and lean blocker for Chrome, Firefox, and Safari.
https://ublock.org/
GNU General Public License v3.0
8.18k stars 436 forks source link

Element picker appears misaligned on http://xkcd.com/ #210

Closed gorhill closed 10 years ago

gorhill commented 10 years ago

Reported as a comment in #190, it's a different issue than #190 though.

gorhill commented 10 years ago

The div main element has a margin of -390px, and a left position of 390px (position is relative). I suspect the problem is the browser's Element.getBoundingClientRect implementation.

s-fiebig commented 10 years ago

Quick fix: Replace both lines in highlightElements() 'M', r.left + offx, ' ', r.top + offy, with 'M', r.left - document.body.getBoundingClientRect().left + offx, ' ', r.top + offy, As long as the Element.getBoundingClientRect isn't working as expected, this works for me, at least, all tested websites looked alright with the picker.

gorhill commented 10 years ago

Thanks for the finding, I will try it.

gorhill commented 10 years ago

Ok, this works so long as the document is not scrolled. As soon as you scroll, the highlighted rectangle becomes sticky rather than scroll with the position of the highlighted element.

Need something more, will look into it.

gorhill commented 10 years ago

Ok, replacing offx entirely with -bodyRect.left seems to do the trick (also applies to offy).

pwstokes225 commented 10 years ago

This issue seems to be fixed on http://xkcd.com/. Unfortunately, now it seems to manifest in places where it hadn't before. Such as http://what-if.xkcd.com/ and http://oeis.org/.

pwstokes225 commented 10 years ago

It looks like the issue after scrolling has re-emerged. Otherwise, this fix works great.

gorhill commented 10 years ago

after scrolling

?

Mikey1993 commented 10 years ago

@gorhill Please look at my last comment on #275, there is a new issue regarding this fix I suppose. Thanks.

pwstokes225 commented 10 years ago

Perhaps this scrolling issue is unique to me, or to people with similar setups. I'm on µBlock 0.7.0.5 on Chrome 40.0.2182.3 dev-m (64-bit) on Windows 8.1. Picking an element without any scrolling works fine: No scrolling Picking the same element after scrolling slightly results in a misalignment by the amount scrolled: Scrolling

ialexsilva commented 10 years ago

@pwstokes225 I could not reproduce the glitch... µBlock 0.7.0.5 on Chrome 38.0.2125.101 m (64-bit) on Windows 8.1.

s-fiebig commented 10 years ago

@pwstokes225a as ialexsilva I couldn't reproduce this. µBlock 0.7.0.5 on Chrome 38.0.2125.101 m (32bit)

pwstokes225 commented 10 years ago

Okay, I have confirmed my issue resulted from a flag in chrome://flags/. I'm not certain which one, but the element picker works fine now that I've reset all the flags to their default.