Difference in offsetTop value between Chrome and Firefox

681 views
Skip to first unread message

PeterFacey

unread,
Jun 26, 2010, 2:44:13 PM6/26/10
to Chromium-extensions
I have a content script that examines the offsetTop values of various
<DIV> elements of the DOM in order to calculate a distance to scroll
the page. It works in Firefox at all VIEW/ZOOM levels, and in Chrome
provided the zoom level is normal (CTRL+0). At larger zoom levels (CTRL
++) in Chrome it gets an amount that is too small.

I examined the offsetTop values of two <DIV> elements in Developer
Tools. These <DIV>s render one above the other in the browser window.

At normal zoom, the two offsetTop values are 221 and 411. Difference
is 190. Vertical separation on screen is 48 mm (measured with a
ruler).

At higher zoom, the two offsetTop values are 260 and 449. Difference
is 189. Vertical separation is 57 mm.

Thus, although the vertical separation on screen has increased due to
the higher zoom level, as one would expect it to, the figures returned
from the DOM do not reflect that.

Is this a bug or a feature of Chrome? If it is a feature, I suppose I
have to multiply all vertical pixel positions by a factor dependent
upon the zoom level?

PhistucK

unread,
Jul 30, 2010, 5:32:46 AM7/30/10
to PeterFacey, Chromium-extensions
The zoom feature is internal to Chrome. The website should not know that it is being zoomed and that is why these values do not change.

☆PhistucK



--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


PeterFacey

unread,
Jul 30, 2010, 5:53:46 AM7/30/10
to Chromium-extensions


Ok, that is perfectly logical. However, my program having examined the
offsetTop values calculates an amount to scroll the window by, and
does so using window.scrollBy(0, amount). This does not move the
window content by the correct amount, unless the zoom level is
"normal".

Thus it seems that the window.scrollBy() amount is not being scaled
internally by Chrome proportionate to the zoom level. Once you take
the view that the zoom is internal to Chrome, then I think everything
should be scaled appropriately surely?

PhistucK

unread,
Jul 30, 2010, 6:34:01 AM7/30/10
to PeterFacey, Chromium-extensions
Search crbug.com for an existing issue and star it. If you cannot find one, file a new issue at new.crbug.com.

Thank you.

☆PhistucK



--
Reply all
Reply to author
Forward
0 new messages