javascript div offsetHeight reports incorrect values on text resize




9 years ago
9 years ago


(Reporter: Steve, Unassigned)


Windows XP

Firefox Tracking Flags

(Not tracked)





9 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/2009011913 Firefox/3.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/2009011913 Firefox/3.0.6

When using Javascript to retrieve the offsetHeight value of a div element, the value returned is correct only if the page magnification is at default. When a user changes the magnification (with [Ctrl][+] or [Ctrl][-]), the reported offsetHeight value is incorrect; it decreases as text size increases or returns inconsistent values as the text size changes. Thus, Web applications relying on accurate reporting of this value will not function correctly in Firefox.

Reproducible: Always

Steps to Reproduce:
1. Set up a HTML page containing a div element with some text in it.
2. Use Javascript to read the offsetHeight value of this element (var divHeight = document.getElementById('divId').offsetHeight;)
3. Have the user change the page magnification by pressing [Ctrl][+] and [Ctrl][-], and read back the element's offsetHeight value again.
Actual Results:  
Using the demo page at to reproduce this error produces the following results:
Default page magnification: offsetHeight = 60px (correct value)
+1 page magnification: offsetHeight = 57px
+2 page magnification: offsetHeight = 56px
+3 page magnification: offsetHeight = 54px
-1 page magnification: offsetheight = 59px 
-2 page magnification: offsetheight = 59px 
-3 page magnification: offsetheight = 62px

Expected Results:  
As the text size increases with page magnification, so too the offsetHeight value of the containing element should increase to reflect the larger size of the element in accomodating the text. Similarly, the offsetHeight value should decrease with decreasing page magnification and text size. This value should show the actual pixel height of the element when read.


Build platform

Build tools
Compiler 	Version 	Compiler flags
cl 	14.00.50727.762 	-GL -wd4624 -wd4952 -TC -nologo -W3 -Gy -Fd$(PDBFILE)
cl 	14.00.50727.762 	-GR- -GL -wd4624 -wd4952 -TP -nologo -Zc:wchar_t- -W3 -Gy -Fd$(PDBFILE)

Configure arguments
--enable-application=browser --enable-update-channel=release --enable-optimize --disable-debug --disable-tests --enable-update-packaging --enable-official-branding --enable-jemalloc --with-crashreporter-enable-percent=10
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2a1pre) Gecko/20090303 Minefield/3.2a1pre  
Seems only to work correctly if I set View > Zoom > Zoom Text Only.
Component: General → Layout
Product: Firefox → Core
QA Contact: general → layout
Version: unspecified → Trunk
You need to log in before you can comment on or make changes to this bug.