Changeset 168868 in webkit
- Timestamp:
- May 14, 2014 4:13:52 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r168865 r168868 1 2014-05-14 Zalan Bujtas <zalan@apple.com> 2 3 Subpixel layout: Change Element.offset* client* scroll* return type to double. 4 https://bugs.webkit.org/show_bug.cgi?id=132895 5 6 Reviewed by Simon Fraser. 7 8 Some test cases expect integral values, so the test content is updated accordingly. 9 It mostly means adding Math.round() before comparing values in order to match pixelSnappedIntRect() 10 functionality. 11 12 * css3/calc/simple-calcs-prefixed.html: changed file format from Windows to Unix. 13 * css3/calc/simple-calcs.html: changed file format from Windows to Unix. 14 * cssom/subpixel-offsetleft-top-width-height-values-expected.txt: Added. 15 * cssom/subpixel-offsetleft-top-width-height-values.html: Added. 16 * editing/selection/drag-start-event-client-x-y.html: use floor as we compare the return value to a truncated integer. 17 * editing/selection/mixed-editability-10.html: 18 * fast/css/zoom-in-length-round-trip.html: 19 * fast/dom/non-numeric-values-numeric-parameters-expected.txt: 20 * fast/dom/script-tests/non-numeric-values-numeric-parameters.js: 21 * fast/forms/basic-buttons.html: 22 * js/dom/dom-static-property-for-in-iteration-expected.txt: 23 * platform/mac/fast/scrolling/scroll-div-latched-div.html: 24 * platform/mac/fast/scrolling/scroll-div-latched-mainframe.html: 25 * platform/mac/fast/scrolling/scroll-select-bottom-test.html: 26 * platform/mac/fast/scrolling/scroll-select-latched-mainframe.html: 27 * platform/mac/fast/scrolling/scroll-select-latched-select.html: 28 * resources/check-layout.js: 29 1 30 2014-05-14 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 31 -
trunk/LayoutTests/css3/calc/simple-calcs-prefixed.html
r168838 r168868 105 105 var zoom = zoomLevels[z]; 106 106 document.body.style.zoom = zoom; 107 var width = element.offsetWidth;107 var width = Math.round(element.offsetWidth); 108 108 if (width != 100) 109 109 error.push("@zoom=" + zoom + " expected width of 100, but was " + width); 110 var height = element.offsetHeight;110 var height = Math.round(element.offsetHeight); 111 111 if (height != 100) 112 112 error.push("@zoom=" + zoom + " expected height of 100, but was " + height); -
trunk/LayoutTests/css3/calc/simple-calcs.html
r168840 r168868 102 102 var zoom = zoomLevels[z]; 103 103 document.body.style.zoom = zoom; 104 var width = element.offsetWidth;104 var width = Math.round(element.offsetWidth); 105 105 if (width != 100) 106 106 error.push("@zoom=" + zoom + " expected width of 100, but was " + width); 107 var height = element.offsetHeight;107 var height = Math.round(element.offsetHeight); 108 108 if (height != 100) 109 109 error.push("@zoom=" + zoom + " expected height of 100, but was " + height); -
trunk/LayoutTests/editing/selection/drag-start-event-client-x-y.html
r168846 r168868 44 44 dragStartHandler: function(dragStart, dragDistance) { 45 45 var resultElement = document.getElementById("result"); 46 shouldBe(resultElement, "clientX", dragStart.x, event.clientX);47 shouldBe(resultElement, "clientY", dragStart.y, event.clientY);48 shouldBe(resultElement, "pageX", dragStart.x, event.pageX);49 shouldBe(resultElement, "pageY", dragStart.y, event.pageY);46 shouldBe(resultElement, "clientX", Math.floor(dragStart.x), event.clientX); 47 shouldBe(resultElement, "clientY", Math.floor(dragStart.y), event.clientY); 48 shouldBe(resultElement, "pageX", Math.floor(dragStart.x), event.pageX); 49 shouldBe(resultElement, "pageY", Math.floor(dragStart.y), event.pageY); 50 50 }, 51 51 … … 58 58 59 59 var element = document.getElementById("draggable"); 60 var dragStart = { x: element.offsetLeft + element.offsetWidth / 2, y: element.offsetTop+ 1.0 };60 var dragStart = { x: Math.round(element.offsetLeft) + Math.round(element.offsetWidth) / 2, y: Math.round(element.offsetTop) + 1.0 }; 61 61 var dragDistance = 10.0; 62 62 element.ondragstart = this.dragStartHandler.bind(this, dragStart, dragDistance); -
trunk/LayoutTests/editing/selection/mixed-editability-10.html
r120173 r168868 56 56 57 57 var coord = caretCoordinates(); 58 var anchorString = "Anchor (" + anchorNode + ", " + anchorOffset + " caret[" + coord.x + "," + coord.y + "] refpos=" + refpos+ ")";59 var anchorCorrect = anchorNode == elem && anchorOffset == offset && coord.x == refpos;58 var anchorString = "Anchor (" + anchorNode + ", " + anchorOffset + " caret[" + coord.x + "," + coord.y + "] refpos=" + Math.round(refpos) + ")"; 59 var anchorCorrect = anchorNode == elem && anchorOffset == offset && coord.x == Math.round(refpos); 60 60 if (anchorCorrect) 61 61 log(anchorString + " is correct."); -
trunk/LayoutTests/fast/css/zoom-in-length-round-trip.html
r120683 r168868 30 30 for (zoom = 100; zoom <= 200; zoom += 1) { 31 31 containerStyle.setProperty("zoom", zoom / 100); 32 if ( target.offsetWidth != 1 || target.offsetHeight!= 10) {33 if (hasSubpixelSupport && ( target.offsetWidth == 1 || target.offsetWidth == 2) && (target.offsetHeight == 10 || target.offsetHeight== 11))32 if (Math.round(target.offsetWidth) != 1 || Math.round(target.offsetHeight) != 10) { 33 if (hasSubpixelSupport && (Math.round(target.offsetWidth) == 1 || Math.round(target.offsetWidth) == 2) && (Math.round(target.offsetHeight) == 10 || Math.round(target.offsetHeight) == 11)) 34 34 continue; // With subpixel layout and pixel snapping we extend the box with one pixel at certain zoom levels. 35 35 failed = true; -
trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt
r154012 r168868 24 24 PASS nonNumericPolicy('document.body.scrollByLines(x)') is 'any type allowed' 25 25 PASS nonNumericPolicy('document.body.scrollByPages(x)') is 'any type allowed' 26 PASS nonNumericPolicy('document.body.scrollLeft = x') is ' any type allowed'27 PASS nonNumericPolicy('document.body.scrollTop = x') is ' any type allowed'26 PASS nonNumericPolicy('document.body.scrollLeft = x') is 'mixed' 27 PASS nonNumericPolicy('document.body.scrollTop = x') is 'mixed' 28 28 PASS nonNumericPolicy('document.images.item(x)') is 'any type allowed' 29 29 PASS nonNumericPolicy('document.createElement("input").setSelectionRange(x, 0)') is 'any type allowed' -
trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js
r154012 r168868 227 227 shouldBe("nonNumericPolicy('document.body.scrollByLines(x)')", "'any type allowed'"); 228 228 shouldBe("nonNumericPolicy('document.body.scrollByPages(x)')", "'any type allowed'"); 229 shouldBe("nonNumericPolicy('document.body.scrollLeft = x')", "' any type allowed'");230 shouldBe("nonNumericPolicy('document.body.scrollTop = x')", "' any type allowed'");229 shouldBe("nonNumericPolicy('document.body.scrollLeft = x')", "'mixed'"); 230 shouldBe("nonNumericPolicy('document.body.scrollTop = x')", "'mixed'"); 231 231 232 232 // History … … 393 393 ../../../../WebCore/html/HTMLAreaElement.idl: attribute long tabIndex; 394 394 ../../../../WebCore/html/HTMLBaseFontElement.idl: attribute long size; 395 ../../../../WebCore/html/HTMLBodyElement.idl: attribute longscrollLeft;396 ../../../../WebCore/html/HTMLBodyElement.idl: attribute longscrollTop;395 ../../../../WebCore/html/HTMLBodyElement.idl: attribute float scrollLeft; 396 ../../../../WebCore/html/HTMLBodyElement.idl: attribute float scrollTop; 397 397 ../../../../WebCore/html/HTMLButtonElement.idl: attribute long tabIndex; 398 398 ../../../../WebCore/html/HTMLCanvasElement.idl: attribute long width; -
trunk/LayoutTests/fast/forms/basic-buttons.html
r48690 r168868 44 44 45 45 button.parentNode.nextSibling.innerHTML = 46 "(" + button.offsetHeight + ", " + button.offsetWidth+ ") " +47 "(" + button.clientHeight + ", " + button.clientWidth+ ")";46 "(" + Math.round(button.offsetHeight) + ", " + Math.round(button.offsetWidth) + ") " + 47 "(" + Math.round(button.clientHeight) + ", " + Math.round(button.clientWidth) + ")"; 48 48 } 49 49 } -
trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt
r165603 r168868 53 53 PASS a["offsetWidth"] is 39 54 54 PASS a["offsetHeight"] is 18 55 PASS a["offsetParent"] is [object HTMLBodyElement]56 55 PASS a["clientLeft"] is 0 57 56 PASS a["clientTop"] is 0 … … 62 61 PASS a["scrollWidth"] is 0 63 62 PASS a["scrollHeight"] is 0 63 PASS a["offsetParent"] is [object HTMLBodyElement] 64 64 PASS a["className"] is 65 65 PASS a["classList"] is -
trunk/LayoutTests/platform/mac/fast/scrolling/scroll-div-latched-div.html
r166960 r168868 70 70 var startPosX = divTarget.offsetLeft + 20; 71 71 debug("div display height = " + divTarget.clientHeight); 72 var startPosY = divTarget.offsetTop + divTarget.clientHeight- 42; // One wheel turn before end.72 var startPosY = Math.round(divTarget.offsetTop) + Math.round(divTarget.clientHeight) - 42; // One wheel turn before end. 73 73 eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame 74 74 debug("Mouse moved to (" + startPosX + ", " + startPosY + ")"); -
trunk/LayoutTests/platform/mac/fast/scrolling/scroll-div-latched-mainframe.html
r166960 r168868 67 67 68 68 // Scroll the #source until we reach the #target. 69 var startPosX = divTarget.offsetLeft+ 20;70 var startPosY = divTarget.offsetTop- 42; // Slightly more than one wheel scroll away from the IFrame69 var startPosX = Math.round(divTarget.offsetLeft) + 20; 70 var startPosY = Math.round(divTarget.offsetTop) - 42; // Slightly more than one wheel scroll away from the IFrame 71 71 eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame 72 72 debug("Mouse moved to (" + startPosX + ", " + startPosY + ")"); -
trunk/LayoutTests/platform/mac/fast/scrolling/scroll-select-bottom-test.html
r167807 r168868 72 72 var startPosX = selectTarget.offsetLeft + 20; 73 73 debug("div display height = " + selectTarget.clientHeight); 74 var startPosY = selectTarget.offsetTop + selectTarget.clientHeight+ clientInset - 2; // Very near top (accounting for top content inset).74 var startPosY = Math.round(selectTarget.offsetTop) + Math.round(selectTarget.clientHeight) + clientInset - 2; // Very near top (accounting for top content inset). 75 75 eventSender.mouseMoveTo(startPosX, startPosY); 76 76 debug("Mouse moved to (" + startPosX + ", " + startPosY + ")"); -
trunk/LayoutTests/platform/mac/fast/scrolling/scroll-select-latched-mainframe.html
r166960 r168868 67 67 68 68 // Scroll the #source until we reach the #target. 69 var startPosX = selectTarget.offsetLeft+ 20;70 var startPosY = selectTarget.offsetTop- 42; // Slightly more than one wheel scroll away from the IFrame69 var startPosX = Math.round(selectTarget.offsetLeft) + 20; 70 var startPosY = Math.round(selectTarget.offsetTop) - 42; // Slightly more than one wheel scroll away from the IFrame 71 71 eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame 72 72 debug("Mouse moved to (" + startPosX + ", " + startPosY + ")"); -
trunk/LayoutTests/platform/mac/fast/scrolling/scroll-select-latched-select.html
r166960 r168868 68 68 69 69 // Scroll the #source until we reach the #target. 70 var startPosX = selectTarget.offsetLeft+ 20;70 var startPosX = Math.round(selectTarget.offsetLeft) + 20; 71 71 debug("div display height = " + selectTarget.clientHeight); 72 var startPosY = selectTarget.offsetTop + selectTarget.clientHeight- 42; // One wheel turn before end.72 var startPosY = Math.round(selectTarget.offsetTop) + Math.round(selectTarget.clientHeight) - 42; // One wheel turn before end. 73 73 eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the iFrame 74 74 debug("Mouse moved to (" + startPosX + ", " + startPosY + ")"); -
trunk/LayoutTests/resources/check-layout.js
r150067 r168868 38 38 var expectedWidth = checkAttribute(output, node, "data-expected-width"); 39 39 if (expectedWidth) { 40 if ( node.offsetWidth!= parseInt(expectedWidth))40 if (Math.round(node.offsetWidth) != parseInt(expectedWidth)) 41 41 failures.push("Expected " + expectedWidth + " for width, but got " + node.offsetWidth + ". "); 42 42 } … … 44 44 var expectedHeight = checkAttribute(output, node, "data-expected-height"); 45 45 if (expectedHeight) { 46 if ( node.offsetHeight!= parseInt(expectedHeight))46 if (Math.round(node.offsetHeight) != parseInt(expectedHeight)) 47 47 failures.push("Expected " + expectedHeight + " for height, but got " + node.offsetHeight + ". "); 48 48 } … … 50 50 var expectedOffset = checkAttribute(output, node, "data-offset-x"); 51 51 if (expectedOffset) { 52 if ( node.offsetLeft!= parseInt(expectedOffset))52 if (Math.round(node.offsetLeft) != parseInt(expectedOffset)) 53 53 failures.push("Expected " + expectedOffset + " for offsetLeft, but got " + node.offsetLeft + ". "); 54 54 } … … 56 56 var expectedOffset = checkAttribute(output, node, "data-offset-y"); 57 57 if (expectedOffset) { 58 if ( node.offsetTop!= parseInt(expectedOffset))58 if (Math.round(node.offsetTop) != parseInt(expectedOffset)) 59 59 failures.push("Expected " + expectedOffset + " for offsetTop, but got " + node.offsetTop + ". "); 60 60 } … … 62 62 var expectedWidth = checkAttribute(output, node, "data-expected-client-width"); 63 63 if (expectedWidth) { 64 if ( node.clientWidth!= parseInt(expectedWidth))64 if (Math.round(node.clientWidth) != parseInt(expectedWidth)) 65 65 failures.push("Expected " + expectedWidth + " for clientWidth, but got " + node.clientWidth + ". "); 66 66 } … … 68 68 var expectedHeight = checkAttribute(output, node, "data-expected-client-height"); 69 69 if (expectedHeight) { 70 if ( node.clientHeight!= parseInt(expectedHeight))70 if (Math.round(node.clientHeight) != parseInt(expectedHeight)) 71 71 failures.push("Expected " + expectedHeight + " for clientHeight, but got " + node.clientHeight + ". "); 72 72 } … … 74 74 var expectedWidth = checkAttribute(output, node, "data-expected-scroll-width"); 75 75 if (expectedWidth) { 76 if ( node.scrollWidth!= parseInt(expectedWidth))76 if (Math.round(node.scrollWidth) != parseInt(expectedWidth)) 77 77 failures.push("Expected " + expectedWidth + " for scrollWidth, but got " + node.scrollWidth + ". "); 78 78 } … … 80 80 var expectedHeight = checkAttribute(output, node, "data-expected-scroll-height"); 81 81 if (expectedHeight) { 82 if ( node.scrollHeight!= parseInt(expectedHeight))82 if (Math.round(node.scrollHeight) != parseInt(expectedHeight)) 83 83 failures.push("Expected " + expectedHeight + " for scrollHeight, but got " + node.scrollHeight + ". "); 84 84 } … … 87 87 if (expectedOffset) { 88 88 var totalLeft = node.clientLeft + node.offsetLeft; 89 if ( totalLeft!= parseInt(expectedOffset))89 if (Math.round(totalLeft) != parseInt(expectedOffset)) 90 90 failures.push("Expected " + expectedOffset + " for clientLeft+offsetLeft, but got " + totalLeft + ", clientLeft: " + node.clientLeft + ", offsetLeft: " + node.offsetLeft + ". "); 91 91 } … … 94 94 if (expectedOffset) { 95 95 var totalTop = node.clientTop + node.offsetTop; 96 if ( totalTop!= parseInt(expectedOffset))96 if (Math.round(totalTop) != parseInt(expectedOffset)) 97 97 failures.push("Expected " + expectedOffset + " for clientTop+offsetTop, but got " + totalTop + ", clientTop: " + node.clientTop + ", + offsetTop: " + node.offsetTop + ". "); 98 98 } -
trunk/Source/WebCore/ChangeLog
r168859 r168868 1 2014-05-14 Zalan Bujtas <zalan@apple.com> 2 3 Subpixel layout: Change Element.offset* client* scroll* return type to double. 4 https://bugs.webkit.org/show_bug.cgi?id=132895 5 6 Reviewed by Simon Fraser. 7 8 This patch changes Element.offset*, Element.client* and Element.scroll* APIs return 9 type from long to double to match the latest CSSOM View Module spec[1]. 10 Element.offset* and Element.client* do return subpixel values from now on. 11 Element.scroll* still return integral values as the scrolling code hasn't adopted to subpixel rendering yet. 12 13 subpixelCSSOMElementMetricsEnabled setting is added to be able to turn this feature on/off 14 from WK2 preferences. It toggles the return value from subpixel to floored integral. 15 It does not change layout/rendering behavior. 16 17 Reference list of what other browsers do: 18 IE: http://blogs.msdn.com/b/ie/archive/2012/02/17/sub-pixel-rendering-and-the-css-object-model.aspx 19 Blink: http://www.chromestatus.com/features/5497402177880064 20 Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=825607 21 22 [1] http://www.w3.org/TR/2013/WD-cssom-view-20131217/ 23 24 Test: cssom/subpixel-offsetleft-top-width-height-values.html 25 26 * dom/Element.cpp: 27 (WebCore::localZoomForRenderer): 28 (WebCore::adjustForLocalZoom): 29 (WebCore::convertToNonSubpixelValueIfNeeded): 30 (WebCore::Element::offsetLeft): 31 (WebCore::Element::offsetTop): 32 (WebCore::Element::offsetWidth): 33 (WebCore::Element::offsetHeight): 34 (WebCore::Element::clientLeft): 35 (WebCore::Element::clientTop): 36 (WebCore::Element::clientWidth): 37 (WebCore::Element::clientHeight): 38 (WebCore::Element::scrollLeft): 39 (WebCore::Element::scrollTop): 40 (WebCore::Element::setScrollLeft): 41 (WebCore::Element::setScrollTop): 42 (WebCore::Element::scrollWidth): 43 (WebCore::Element::scrollHeight): 44 * dom/Element.h: 45 * dom/Element.idl: 46 * html/HTMLBodyElement.cpp: 47 (WebCore::adjustForZoom): 48 (WebCore::HTMLBodyElement::scrollLeft): 49 (WebCore::HTMLBodyElement::setScrollLeft): 50 (WebCore::HTMLBodyElement::scrollTop): 51 (WebCore::HTMLBodyElement::setScrollTop): 52 (WebCore::HTMLBodyElement::scrollHeight): 53 (WebCore::HTMLBodyElement::scrollWidth): 54 * html/HTMLBodyElement.h: 55 * page/Settings.in: 56 1 57 2014-05-14 Brady Eidson <beidson@apple.com> 2 58 -
trunk/Source/WebCore/dom/Element.cpp
r168339 r168868 622 622 } 623 623 624 static float localZoomForRenderer(RenderElement*renderer)624 static double localZoomForRenderer(const RenderElement& renderer) 625 625 { 626 626 // FIXME: This does the wrong thing if two opposing zooms are in effect and canceled each 627 627 // other out, but the alternative is that we'd have to crawl up the whole render tree every 628 628 // time (or store an additional bit in the RenderStyle to indicate that a zoom was specified). 629 floatzoomFactor = 1;630 if (renderer ->style().effectiveZoom() != 1) {629 double zoomFactor = 1; 630 if (renderer.style().effectiveZoom() != 1) { 631 631 // Need to find the nearest enclosing RenderElement that set up 632 632 // a differing zoom, and then we divide our result by it to eliminate the zoom. 633 RenderElement* prev =renderer;633 const RenderElement* prev = &renderer; 634 634 for (RenderElement* curr = prev->parent(); curr; curr = curr->parent()) { 635 635 if (curr->style().effectiveZoom() != prev->style().effectiveZoom()) { … … 645 645 } 646 646 647 static int adjustForLocalZoom(LayoutUnit value, RenderElement*renderer)648 { 649 floatzoomFactor = localZoomForRenderer(renderer);647 static double adjustForLocalZoom(LayoutUnit value, const RenderElement& renderer) 648 { 649 double zoomFactor = localZoomForRenderer(renderer); 650 650 if (zoomFactor == 1) 651 return value ;651 return value.toDouble(); 652 652 #if ENABLE(SUBPIXEL_LAYOUT) 653 return lroundf(value / zoomFactor);653 return value.toDouble() / zoomFactor; 654 654 #else 655 655 // Needed because computeLengthInt truncates (rather than rounds) when scaling up. 656 656 if (zoomFactor > 1) 657 657 ++value; 658 return static_cast<int>(value / zoomFactor);658 return value.toDouble() / zoomFactor; 659 659 #endif 660 660 } 661 661 662 int Element::offsetLeft() 662 static double convertToNonSubpixelValueIfNeeded(double value, const Document& document) 663 { 664 return document.settings() && !document.settings()->subpixelCSSOMElementMetricsEnabled() ? floor(value) : value; 665 } 666 667 double Element::offsetLeft() 663 668 { 664 669 document().updateLayoutIgnorePendingStylesheets(); 665 670 if (RenderBoxModelObject* renderer = renderBoxModelObject()) 666 return adjustForLocalZoom(renderer->pixelSnappedOffsetLeft(), renderer);671 return convertToNonSubpixelValueIfNeeded(adjustForLocalZoom(renderer->offsetLeft(), *renderer), renderer->document()); 667 672 return 0; 668 673 } 669 674 670 intElement::offsetTop()675 double Element::offsetTop() 671 676 { 672 677 document().updateLayoutIgnorePendingStylesheets(); 673 678 if (RenderBoxModelObject* renderer = renderBoxModelObject()) 674 return adjustForLocalZoom(renderer->pixelSnappedOffsetTop(), renderer);679 return convertToNonSubpixelValueIfNeeded(adjustForLocalZoom(renderer->offsetTop(), *renderer), renderer->document()); 675 680 return 0; 676 681 } 677 682 678 int Element::offsetWidth() 683 double Element::offsetWidth() 684 { 685 document().updateLayoutIgnorePendingStylesheets(); 686 if (RenderBoxModelObject* renderer = renderBoxModelObject()) { 687 #if ENABLE(SUBPIXEL_LAYOUT) 688 return convertToNonSubpixelValueIfNeeded(adjustLayoutUnitForAbsoluteZoom(renderer->offsetWidth(), *renderer).toDouble(), renderer->document()); 689 #else 690 return adjustForAbsoluteZoom(renderer->offsetWidth(), *renderer); 691 #endif 692 } 693 return 0; 694 } 695 696 double Element::offsetHeight() 679 697 { 680 698 document().updateLayoutIgnorePendingStylesheets(); 681 699 if (RenderBoxModelObject* renderer = renderBoxModelObject()) 682 700 #if ENABLE(SUBPIXEL_LAYOUT) 683 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetWidth(), *renderer).round();701 return convertToNonSubpixelValueIfNeeded(adjustLayoutUnitForAbsoluteZoom(renderer->offsetHeight(), *renderer).toDouble(), renderer->document()); 684 702 #else 685 return adjustForAbsoluteZoom(renderer->pixelSnappedOffsetWidth(), *renderer); 686 #endif 687 return 0; 688 } 689 690 int Element::offsetHeight() 691 { 692 document().updateLayoutIgnorePendingStylesheets(); 693 if (RenderBoxModelObject* renderer = renderBoxModelObject()) 694 #if ENABLE(SUBPIXEL_LAYOUT) 695 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetHeight(), *renderer).round(); 696 #else 697 return adjustForAbsoluteZoom(renderer->pixelSnappedOffsetHeight(), *renderer); 703 return adjustForAbsoluteZoom(renderer->offsetHeight(), *renderer); 698 704 #endif 699 705 return 0; … … 720 726 } 721 727 722 intElement::clientLeft()728 double Element::clientLeft() 723 729 { 724 730 document().updateLayoutIgnorePendingStylesheets(); 725 731 726 732 if (RenderBox* renderer = renderBox()) 727 return adjustForAbsoluteZoom(roundToInt(renderer->clientLeft()), *renderer); 733 #if ENABLE(SUBPIXEL_LAYOUT) 734 return convertToNonSubpixelValueIfNeeded(adjustLayoutUnitForAbsoluteZoom(renderer->clientLeft(), *renderer).toDouble(), renderer->document()); 735 #else 736 return adjustForAbsoluteZoom(renderer->clientLeft(), *renderer); 737 #endif 728 738 return 0; 729 739 } 730 740 731 intElement::clientTop()741 double Element::clientTop() 732 742 { 733 743 document().updateLayoutIgnorePendingStylesheets(); 734 744 735 745 if (RenderBox* renderer = renderBox()) 736 return adjustForAbsoluteZoom(roundToInt(renderer->clientTop()), *renderer); 746 #if ENABLE(SUBPIXEL_LAYOUT) 747 return convertToNonSubpixelValueIfNeeded(adjustLayoutUnitForAbsoluteZoom(renderer->clientTop(), *renderer).toDouble(), renderer->document()); 748 #else 749 return adjustForAbsoluteZoom(renderer->clientTop(), *renderer); 750 #endif 737 751 return 0; 738 752 } 739 753 740 intElement::clientWidth()754 double Element::clientWidth() 741 755 { 742 756 document().updateLayoutIgnorePendingStylesheets(); … … 754 768 if (RenderBox* renderer = renderBox()) 755 769 #if ENABLE(SUBPIXEL_LAYOUT) 756 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientWidth(), *renderer).round();770 return convertToNonSubpixelValueIfNeeded(adjustLayoutUnitForAbsoluteZoom(renderer->clientWidth(), *renderer).toDouble(), renderer->document()); 757 771 #else 758 return adjustForAbsoluteZoom(renderer-> pixelSnappedClientWidth(), *renderer);772 return adjustForAbsoluteZoom(renderer->clientWidth(), *renderer); 759 773 #endif 760 774 return 0; 761 775 } 762 776 763 intElement::clientHeight()777 double Element::clientHeight() 764 778 { 765 779 document().updateLayoutIgnorePendingStylesheets(); … … 777 791 if (RenderBox* renderer = renderBox()) 778 792 #if ENABLE(SUBPIXEL_LAYOUT) 779 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientHeight(), *renderer).round();793 return convertToNonSubpixelValueIfNeeded(adjustLayoutUnitForAbsoluteZoom(renderer->clientHeight(), *renderer).toDouble(), renderer->document()); 780 794 #else 781 return adjustForAbsoluteZoom(renderer-> pixelSnappedClientHeight(), *renderer);795 return adjustForAbsoluteZoom(renderer->clientHeight(), *renderer); 782 796 #endif 783 797 return 0; 784 798 } 785 799 786 intElement::scrollLeft()800 double Element::scrollLeft() 787 801 { 788 802 document().updateLayoutIgnorePendingStylesheets(); … … 793 807 } 794 808 795 intElement::scrollTop()809 double Element::scrollTop() 796 810 { 797 811 document().updateLayoutIgnorePendingStylesheets(); … … 802 816 } 803 817 804 void Element::setScrollLeft( intnewLeft)818 void Element::setScrollLeft(double newLeft) 805 819 { 806 820 document().updateLayoutIgnorePendingStylesheets(); 807 821 808 822 if (RenderBox* renderer = renderBox()) { 809 renderer->setScrollLeft( static_cast<int>(newLeft * renderer->style().effectiveZoom()));823 renderer->setScrollLeft(round(newLeft * renderer->style().effectiveZoom())); 810 824 if (auto* scrollableArea = renderer->layer()) 811 825 scrollableArea->setScrolledProgrammatically(true); … … 813 827 } 814 828 815 void Element::setScrollTop( intnewTop)829 void Element::setScrollTop(double newTop) 816 830 { 817 831 document().updateLayoutIgnorePendingStylesheets(); 818 832 819 833 if (RenderBox* renderer = renderBox()) { 820 renderer->setScrollTop( static_cast<int>(newTop * renderer->style().effectiveZoom()));834 renderer->setScrollTop(round(newTop * renderer->style().effectiveZoom())); 821 835 if (auto* scrollableArea = renderer->layer()) 822 836 scrollableArea->setScrolledProgrammatically(true); … … 824 838 } 825 839 826 intElement::scrollWidth()840 double Element::scrollWidth() 827 841 { 828 842 document().updateLayoutIgnorePendingStylesheets(); … … 832 846 } 833 847 834 intElement::scrollHeight()848 double Element::scrollHeight() 835 849 { 836 850 document().updateLayoutIgnorePendingStylesheets(); -
trunk/Source/WebCore/dom/Element.h
r168339 r168868 207 207 void scrollByPages(int pages); 208 208 209 intoffsetLeft();210 intoffsetTop();211 intoffsetWidth();212 intoffsetHeight();209 double offsetLeft(); 210 double offsetTop(); 211 double offsetWidth(); 212 double offsetHeight(); 213 213 214 214 // FIXME: Replace uses of offsetParent in the platform with calls … … 217 217 218 218 Element* offsetParent(); 219 intclientLeft();220 intclientTop();221 intclientWidth();222 intclientHeight();223 virtual intscrollLeft();224 virtual intscrollTop();225 virtual void setScrollLeft( int);226 virtual void setScrollTop( int);227 virtual intscrollWidth();228 virtual intscrollHeight();219 double clientLeft(); 220 double clientTop(); 221 double clientWidth(); 222 double clientHeight(); 223 virtual double scrollLeft(); 224 virtual double scrollTop(); 225 virtual void setScrollLeft(double); 226 virtual void setScrollTop(double); 227 virtual double scrollWidth(); 228 virtual double scrollHeight(); 229 229 230 230 IntRect boundsInRootViewSpace(); -
trunk/Source/WebCore/dom/Element.idl
r167631 r168868 70 70 // Common extensions 71 71 72 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C 72 73 readonly attribute long offsetLeft; 73 74 readonly attribute long offsetTop; 74 75 readonly attribute long offsetWidth; 75 76 readonly attribute long offsetHeight; 76 [ImplementedAs=bindingsOffsetParent] readonly attribute Element offsetParent;77 77 readonly attribute long clientLeft; 78 78 readonly attribute long clientTop; … … 83 83 readonly attribute long scrollWidth; 84 84 readonly attribute long scrollHeight; 85 #else 86 readonly attribute double offsetLeft; 87 readonly attribute double offsetTop; 88 readonly attribute double offsetWidth; 89 readonly attribute double offsetHeight; 90 readonly attribute double clientLeft; 91 readonly attribute double clientTop; 92 readonly attribute double clientWidth; 93 readonly attribute double clientHeight; 94 attribute double scrollLeft; 95 attribute double scrollTop; 96 readonly attribute double scrollWidth; 97 readonly attribute double scrollHeight; 98 #endif 99 100 [ImplementedAs=bindingsOffsetParent] readonly attribute Element offsetParent; 85 101 86 102 void focus(); -
trunk/Source/WebCore/html/HTMLBodyElement.cpp
r167503 r168868 199 199 } 200 200 201 static int adjustForZoom(int value,Frame& frame)202 { 203 floatzoomFactor = frame.pageZoomFactor() * frame.frameScaleFactor();201 static double adjustForZoom(int value, const Frame& frame) 202 { 203 double zoomFactor = frame.pageZoomFactor() * frame.frameScaleFactor(); 204 204 if (zoomFactor == 1) 205 205 return value; … … 207 207 if (zoomFactor > 1) 208 208 value++; 209 return static_cast<int>(value / zoomFactor);210 } 211 212 intHTMLBodyElement::scrollLeft()213 { 214 document().updateLayoutIgnorePendingStylesheets(); 215 Frame* frame = document().frame(); 216 if (!frame) 217 return 0; 218 FrameView* view = frame->view(); 219 if (!view) 220 return 0; 221 return adjustForZoom(view->contentsScrollPosition().x(), *frame);222 } 223 224 void HTMLBodyElement::setScrollLeft( intscrollLeft)209 return value / zoomFactor; 210 } 211 212 double HTMLBodyElement::scrollLeft() 213 { 214 document().updateLayoutIgnorePendingStylesheets(); 215 Frame* frame = document().frame(); 216 if (!frame) 217 return 0; 218 FrameView* view = frame->view(); 219 if (!view) 220 return 0; 221 return floor(adjustForZoom(view->contentsScrollPosition().x(), *frame)); 222 } 223 224 void HTMLBodyElement::setScrollLeft(double scrollLeft) 225 225 { 226 226 document().updateLayoutIgnorePendingStylesheets(); … … 234 234 } 235 235 236 intHTMLBodyElement::scrollTop()237 { 238 document().updateLayoutIgnorePendingStylesheets(); 239 Frame* frame = document().frame(); 240 if (!frame) 241 return 0; 242 FrameView* view = frame->view(); 243 if (!view) 244 return 0; 245 return adjustForZoom(view->contentsScrollPosition().y(), *frame);246 } 247 248 void HTMLBodyElement::setScrollTop( intscrollTop)236 double HTMLBodyElement::scrollTop() 237 { 238 document().updateLayoutIgnorePendingStylesheets(); 239 Frame* frame = document().frame(); 240 if (!frame) 241 return 0; 242 FrameView* view = frame->view(); 243 if (!view) 244 return 0; 245 return floor(adjustForZoom(view->contentsScrollPosition().y(), *frame)); 246 } 247 248 void HTMLBodyElement::setScrollTop(double scrollTop) 249 249 { 250 250 document().updateLayoutIgnorePendingStylesheets(); … … 258 258 } 259 259 260 intHTMLBodyElement::scrollHeight()260 double HTMLBodyElement::scrollHeight() 261 261 { 262 262 // Update the document's layout. … … 268 268 if (!view) 269 269 return 0; 270 return adjustForZoom(view->contentsHeight(), *frame);271 } 272 273 intHTMLBodyElement::scrollWidth()270 return floor(adjustForZoom(view->contentsHeight(), *frame)); 271 } 272 273 double HTMLBodyElement::scrollWidth() 274 274 { 275 275 // Update the document's layout. … … 281 281 if (!view) 282 282 return 0; 283 return adjustForZoom(view->contentsWidth(), *frame);283 return floor(adjustForZoom(view->contentsWidth(), *frame)); 284 284 } 285 285 -
trunk/Source/WebCore/html/HTMLBodyElement.h
r162180 r168868 70 70 virtual bool supportsFocus() const override; 71 71 72 virtual intscrollLeft() override;73 virtual void setScrollLeft( int scrollLeft) override;72 virtual double scrollLeft() override; 73 virtual void setScrollLeft(double) override; 74 74 75 virtual intscrollTop() override;76 virtual void setScrollTop( int scrollTop) override;75 virtual double scrollTop() override; 76 virtual void setScrollTop(double) override; 77 77 78 virtual intscrollHeight() override;79 virtual intscrollWidth() override;78 virtual double scrollHeight() override; 79 virtual double scrollWidth() override; 80 80 81 81 virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const override; -
trunk/Source/WebCore/page/Settings.in
r168726 r168868 195 195 simpleLineLayoutDebugBordersEnabled initial=false, setNeedsStyleRecalcInAllFrames=1 196 196 197 subpixelCSSOMElementMetricsEnabled initial=true 198 197 199 mediaSourceEnabled initial=true, conditional=MEDIA_SOURCE 198 200 -
trunk/Source/WebKit2/ChangeLog
r168866 r168868 1 2014-05-14 Zalan Bujtas <zalan@apple.com> 2 3 Subpixel layout: Change Element.offset* client* scroll* return type to double. 4 https://bugs.webkit.org/show_bug.cgi?id=132895 5 6 Reviewed by Simon Fraser. 7 8 This patch changes Element.offset*, Element.client* and Element.scroll* APIs return 9 type from long to double to match the latest CSSOM View Module spec[1]. 10 Element.offset* and Element.client* do return subpixel values from now on. 11 Element.scroll* still return integral values as the scrolling code hasn't adopted to subpixel rendering yet. 12 13 subpixelCSSOMElementMetricsEnabled setting is added to be able to turn this feature on/off 14 from WK2 preferences. It toggles the return value from subpixel to floored integral. 15 It does not change layout/rendering behavior. 16 17 Reference list of what other browsers do: 18 IE: http://blogs.msdn.com/b/ie/archive/2012/02/17/sub-pixel-rendering-and-the-css-object-model.aspx 19 Blink: http://www.chromestatus.com/features/5497402177880064 20 Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=825607 21 22 [1] http://www.w3.org/TR/2013/WD-cssom-view-20131217/ 23 24 * Shared/WebPreferencesStore.h: 25 * UIProcess/API/C/WKPreferences.cpp: 26 (WKPreferencesSetSubpixelCSSOMElementMetricsEnabled): 27 (WKPreferencesGetSubpixelCSSOMElementMetricsEnabled): 28 * UIProcess/API/C/WKPreferencesRefPrivate.h: 29 * WebProcess/WebPage/WebPage.cpp: 30 (WebKit::WebPage::updatePreferences): 31 1 32 2014-05-14 Benjamin Poulain <bpoulain@apple.com> 2 33 -
trunk/Source/WebKit2/Shared/WebPreferencesStore.h
r168416 r168868 204 204 macro(SimpleLineLayoutEnabled, simpleLineLayoutEnabled, Bool, bool, true) \ 205 205 macro(SimpleLineLayoutDebugBordersEnabled, simpleLineLayoutDebugBordersEnabled, Bool, bool, false) \ 206 macro(SubpixelCSSOMElementMetricsEnabled, subpixelCSSOMElementMetricsEnabled, Bool, bool, true) \ 206 207 macro(BackgroundShouldExtendBeyondPage, backgroundShouldExtendBeyondPage, Bool, bool, false) \ 207 208 macro(MediaStreamEnabled, mediaStreamEnabled, Bool, bool, false) \ -
trunk/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
r168416 r168868 1187 1187 } 1188 1188 1189 void WKPreferencesSetSubpixelCSSOMElementMetricsEnabled(WKPreferencesRef preferencesRef, bool flag) 1190 { 1191 toImpl(preferencesRef)->setSubpixelCSSOMElementMetricsEnabled(flag); 1192 } 1193 1194 bool WKPreferencesGetSubpixelCSSOMElementMetricsEnabled(WKPreferencesRef preferencesRef) 1195 { 1196 return toImpl(preferencesRef)->subpixelCSSOMElementMetricsEnabled(); 1197 } 1198 1189 1199 void WKPreferencesSetMediaStreamEnabled(WKPreferencesRef preferencesRef, bool enabled) 1190 1200 { -
trunk/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h
r168541 r168868 297 297 WK_EXPORT bool WKPreferencesGetSimpleLineLayoutDebugBordersEnabled(WKPreferencesRef); 298 298 299 // Defaults to true. 300 WK_EXPORT void WKPreferencesSetSubpixelCSSOMElementMetricsEnabled(WKPreferencesRef, bool); 301 WK_EXPORT bool WKPreferencesGetSubpixelCSSOMElementMetricsEnabled(WKPreferencesRef); 302 299 303 WK_EXPORT void WKPreferencesResetTestRunnerOverrides(WKPreferencesRef preferencesRef); 300 304 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r168763 r168868 2689 2689 settings.setSimpleLineLayoutDebugBordersEnabled(store.getBoolValueForKey(WebPreferencesKey::simpleLineLayoutDebugBordersEnabledKey())); 2690 2690 2691 settings.setSubpixelCSSOMElementMetricsEnabled(store.getBoolValueForKey(WebPreferencesKey::subpixelCSSOMElementMetricsEnabledKey())); 2692 2691 2693 settings.setUseLegacyTextAlignPositionedElementBehavior(store.getBoolValueForKey(WebPreferencesKey::useLegacyTextAlignPositionedElementBehaviorKey())); 2692 2694
Note: See TracChangeset
for help on using the changeset viewer.