Bug 106107

Summary: REGRESSION(SUBPIXEL_LAYOUT): el.offsetWidth < el.clientWidth for elements of a certain size
Product: WebKit Reporter: Brad Vogel <bradavogel>
Component: Layout and RenderingAssignee: Emil A Eklund <eae>
Status: RESOLVED FIXED    
Severity: Normal CC: bradavogel, eae, eric, leviw, me, ojan.autocc, rniwa, simon.fraser, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Original repro case
none
Patch none

Description Brad Vogel 2013-01-04 10:39:31 PST
Repro:
1) Run the attached file in Chrome 21 or later, or Webkit Nightly.

Actual Result:
You will see the alert "BUG: offsetWidth is smaller than clientWidth".

Expected Result:
You will see the alert "NO BUG: unable to repro"

Tested in:
Firefox 17.0.1: PASS
Chrome 20: PASS
Safari 6.0.2 (7536.26.17): PASS
Chrome 21: FAIL
Chrome Canary 26.0.1374.1: FAIL
Webkit Nightly Version 6.0.2 (7536.26.17, 537+): FAIL

Notes:
Per the W3C spec, offsetWidth should never be smaller than clientWidth.

If you change the attached repro case to use "margin: 1.2em" instead of "margin: 1.1em", it will not repro the bug.

Impact:
This breaks scripts that use the following code to check if an element is scrollable:
    var isScrollable = el.offsetWidth < el.scrollWidth;
because if the bug is reproducing, offsetWidth will be smaller than clientWidth, but scrollWidth will equal clientWidth.
Comment 1 Brad Vogel 2013-01-04 10:40:17 PST
Created attachment 181330 [details]
Original repro case
Comment 2 Alexey Proskuryakov 2013-01-07 10:13:55 PST
Regressed in <http://trac.webkit.org/changeset/133351>.
Comment 3 Emil A Eklund 2013-01-07 13:25:49 PST
Looking into this now.
Comment 4 Emil A Eklund 2013-01-07 15:33:46 PST
Created attachment 181577 [details]
Patch
Comment 5 Levi Weintraub 2013-01-07 15:39:36 PST
Comment on attachment 181577 [details]
Patch

LGTM.
Comment 6 Brad Vogel 2013-01-07 15:51:56 PST
LGTM!
Comment 7 Levi Weintraub 2013-01-07 15:56:53 PST
You may want to merge this into m25 given it's super low risk and high return.
Comment 8 WebKit Review Bot 2013-01-07 16:44:18 PST
Comment on attachment 181577 [details]
Patch

Clearing flags on attachment: 181577

Committed r139013: <http://trac.webkit.org/changeset/139013>
Comment 9 WebKit Review Bot 2013-01-07 16:44:22 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Ryosuke Niwa 2013-01-07 16:50:31 PST
This patch caused a build failure on Windows:
http://build.webkit.org/builders/Apple%20Win%20Debug%20%28Build%29/builds/60388/steps/compile-webkit/logs/stdio

7>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
7>WebCore.lib(RenderRegionSet.obj) : error LNK2005: "public: virtual int __thiscall WebCore::RenderBox::pixelSnappedOffsetWidth(void)const " (?pixelSnappedOffsetWidth@RenderBox@WebCore@@UBEHXZ) already defined in WebCore.lib(RenderingAllInOne.obj)
7>WebCore.lib(RenderRegionSet.obj) : error LNK2005: "public: virtual int __thiscall WebCore::RenderBox::pixelSnappedOffsetHeight(void)const " (?pixelSnappedOffsetHeight@RenderBox@WebCore@@UBEHXZ) already defined in WebCore.lib(RenderingAllInOne.obj)
7>WebCore.lib(MathMLInlineContainerElement.obj) : error LNK2005: "public: virtual int __thiscall WebCore::RenderBox::pixelSnappedOffsetWidth(void)const " (?pixelSnappedOffsetWidth@RenderBox@WebCore@@UBEHXZ) already defined in WebCore.lib(RenderingAllInOne.obj)
7>WebCore.lib(MathMLInlineContainerElement.obj) : error LNK2005: "public: virtual int __thiscall WebCore::RenderBox::pixelSnappedOffsetHeight(void)const " (?pixelSnappedOffsetHeight@RenderBox@WebCore@@UBEHXZ) already defined in WebCore.lib(RenderingAllInOne.obj)
7>   Creating library C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\lib\WebKit.lib and object C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\lib\WebKit.exp
7>C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\bin\WebKit.dll : fatal error LNK1169: one or more multiply defined symbols found
7>Build log was saved at "file://C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\obj\WebKitLib\BuildLog.htm"

It's probably a dependency problem though because I don't see RenderBox.cpp being recompiled.