haikuwebkit/LayoutTests/cssom/subpixel-offsetleft-top-wid...

46 lines
1.4 KiB
HTML
Raw Permalink Normal View History

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: Canonical link: https://commits.webkit.org/150985@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-05-14 23:13:52 +00:00
<!DOCTYPE html>
<html>
<head>
<title>This tests that offset* and client* can return fractional values.</title>
<style>
div {
position: fixed;
border-style: solid;
border-color: red;
}
</style>
</head>
<body>
<script>
if (window.testRunner)
testRunner.dumpAsText();
var container = document.body;
w = 0;
h = 0;
adjustment = 0.1;
for (i = 0; i < 20; ++i) {
adjustment+=0.1;
for (j = 0; j < 20; ++j) {
var e = document.createElement("div");
e.style.top = (w * i + j * adjustment) + "px";
e.style.left = (w * j + i * adjustment) + "px";
e.style.width = w + "px";
e.style.height = h + "px";
e.style.borderWidth = adjustment/4 + "px";
container.appendChild(e);
w+=0.1;
h+=0.1;
}
}
var result = "";
var divs = document.getElementsByTagName("div");
for (i = 0; i < divs.length; ++i) {
var element = divs[i];
result+="offsetTop:" + element.offsetTop.toFixed(2) + " offsetLeft:" + element.offsetLeft.toFixed(2) + " offsetWidth:" + element.offsetWidth.toFixed(2) + " offsetHeight:" + element.offsetHeight.toFixed(2) + "</br> clientTop:" + element.clientTop.toFixed(2) + " clientLeft:" + element.clientLeft.toFixed(2) + " clientWidth:" + element.clientWidth.toFixed(2) + " clientHeight:" + element.clientHeight.toFixed(2) + "</br>";
}
document.body.innerHTML = result;
</script>
</body>
</html>