Subpixel layout: Change Element.offset* client* scroll* return type to double.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2014 23:13:52 +0000 (23:13 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2014 23:13:52 +0000 (23:13 +0000)
commitb6bd39690992cbde406189723f430ceebe87743a
treeb01ba4c608a46dd482ab653892b3e96b6fc811de
parenta81389f4dbf7641195105c71b3f2f7cc5ca7a77c
Subpixel layout: Change Element.offset* client* scroll* return type to double.
https://bugs.webkit.org/show_bug.cgi?id=132895

Reviewed by Simon Fraser.

Source/WebCore:
This patch changes Element.offset*, Element.client* and Element.scroll* APIs return
type from long to double to match the latest CSSOM View Module spec[1].
Element.offset* and Element.client* do return subpixel values from now on.
Element.scroll* still return integral values as the scrolling code hasn't adopted to subpixel rendering yet.

subpixelCSSOMElementMetricsEnabled setting is added to be able to turn this feature on/off
from WK2 preferences. It toggles the return value from subpixel to floored integral.
It does not change layout/rendering behavior.

Reference list of what other browsers do:
IE: http://blogs.msdn.com/b/ie/archive/2012/02/17/sub-pixel-rendering-and-the-css-object-model.aspx
Blink: http://www.chromestatus.com/features/5497402177880064
Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=825607

[1] http://www.w3.org/TR/2013/WD-cssom-view-20131217/

Test: cssom/subpixel-offsetleft-top-width-height-values.html

* dom/Element.cpp:
(WebCore::localZoomForRenderer):
(WebCore::adjustForLocalZoom):
(WebCore::convertToNonSubpixelValueIfNeeded):
(WebCore::Element::offsetLeft):
(WebCore::Element::offsetTop):
(WebCore::Element::offsetWidth):
(WebCore::Element::offsetHeight):
(WebCore::Element::clientLeft):
(WebCore::Element::clientTop):
(WebCore::Element::clientWidth):
(WebCore::Element::clientHeight):
(WebCore::Element::scrollLeft):
(WebCore::Element::scrollTop):
(WebCore::Element::setScrollLeft):
(WebCore::Element::setScrollTop):
(WebCore::Element::scrollWidth):
(WebCore::Element::scrollHeight):
* dom/Element.h:
* dom/Element.idl:
* html/HTMLBodyElement.cpp:
(WebCore::adjustForZoom):
(WebCore::HTMLBodyElement::scrollLeft):
(WebCore::HTMLBodyElement::setScrollLeft):
(WebCore::HTMLBodyElement::scrollTop):
(WebCore::HTMLBodyElement::setScrollTop):
(WebCore::HTMLBodyElement::scrollHeight):
(WebCore::HTMLBodyElement::scrollWidth):
* html/HTMLBodyElement.h:
* page/Settings.in:

Source/WebKit2:
This patch changes Element.offset*, Element.client* and Element.scroll* APIs return
type from long to double to match the latest CSSOM View Module spec[1].
Element.offset* and Element.client* do return subpixel values from now on.
Element.scroll* still return integral values as the scrolling code hasn't adopted to subpixel rendering yet.

subpixelCSSOMElementMetricsEnabled setting is added to be able to turn this feature on/off
from WK2 preferences. It toggles the return value from subpixel to floored integral.
It does not change layout/rendering behavior.

Reference list of what other browsers do:
IE: http://blogs.msdn.com/b/ie/archive/2012/02/17/sub-pixel-rendering-and-the-css-object-model.aspx
Blink: http://www.chromestatus.com/features/5497402177880064
Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=825607

[1] http://www.w3.org/TR/2013/WD-cssom-view-20131217/

* Shared/WebPreferencesStore.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetSubpixelCSSOMElementMetricsEnabled):
(WKPreferencesGetSubpixelCSSOMElementMetricsEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

LayoutTests:
Some test cases expect integral values, so the test content is updated accordingly.
It mostly means adding Math.round() before comparing values in order to match pixelSnappedIntRect()
functionality.

* css3/calc/simple-calcs-prefixed.html: changed file format from Windows to Unix.
* css3/calc/simple-calcs.html: changed file format from Windows to Unix.
* cssom/subpixel-offsetleft-top-width-height-values-expected.txt: Added.
* cssom/subpixel-offsetleft-top-width-height-values.html: Added.
* editing/selection/drag-start-event-client-x-y.html: use floor as we compare the return value to a truncated integer.
* editing/selection/mixed-editability-10.html:
* fast/css/zoom-in-length-round-trip.html:
* fast/dom/non-numeric-values-numeric-parameters-expected.txt:
* fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
* fast/forms/basic-buttons.html:
* js/dom/dom-static-property-for-in-iteration-expected.txt:
* platform/mac/fast/scrolling/scroll-div-latched-div.html:
* platform/mac/fast/scrolling/scroll-div-latched-mainframe.html:
* platform/mac/fast/scrolling/scroll-select-bottom-test.html:
* platform/mac/fast/scrolling/scroll-select-latched-mainframe.html:
* platform/mac/fast/scrolling/scroll-select-latched-select.html:
* resources/check-layout.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/calc/simple-calcs-prefixed.html
LayoutTests/css3/calc/simple-calcs.html
LayoutTests/cssom/subpixel-offsetleft-top-width-height-values-expected.txt [new file with mode: 0644]
LayoutTests/cssom/subpixel-offsetleft-top-width-height-values.html [new file with mode: 0644]
LayoutTests/editing/selection/drag-start-event-client-x-y.html
LayoutTests/editing/selection/mixed-editability-10.html
LayoutTests/fast/css/zoom-in-length-round-trip.html
LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt
LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js
LayoutTests/fast/forms/basic-buttons.html
LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt
LayoutTests/platform/mac/fast/scrolling/scroll-div-latched-div.html
LayoutTests/platform/mac/fast/scrolling/scroll-div-latched-mainframe.html
LayoutTests/platform/mac/fast/scrolling/scroll-select-bottom-test.html
LayoutTests/platform/mac/fast/scrolling/scroll-select-latched-mainframe.html
LayoutTests/platform/mac/fast/scrolling/scroll-select-latched-select.html
LayoutTests/resources/check-layout.js
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Element.idl
Source/WebCore/html/HTMLBodyElement.cpp
Source/WebCore/html/HTMLBodyElement.h
Source/WebCore/page/Settings.in
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp