Changeset 217522 in webkit
- Timestamp:
- May 27, 2017, 10:13:58 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 22 edited
- 1 copied
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/animations/trigger-container-scroll-boundaries-expected.txt (modified) (1 diff)
-
LayoutTests/animations/trigger-container-scroll-boundaries.html (modified) (1 diff)
-
LayoutTests/animations/trigger-container-scroll-empty-expected.txt (modified) (1 diff)
-
LayoutTests/animations/trigger-container-scroll-empty.html (modified) (1 diff)
-
LayoutTests/animations/trigger-container-scroll-simple-expected.txt (modified) (1 diff)
-
LayoutTests/animations/trigger-container-scroll-simple.html (modified) (1 diff)
-
LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt (modified) (4 diffs)
-
LayoutTests/fast/css/getComputedStyle/computed-style-negative-top-expected.txt (modified) (1 diff)
-
LayoutTests/fast/css/getComputedStyle/computed-style-negative-top.html (modified) (1 diff)
-
LayoutTests/fast/css/getComputedStyle/getComputedStyle-offsets-expected.txt (added)
-
LayoutTests/fast/css/getComputedStyle/getComputedStyle-offsets.html (added)
-
LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size-expected.txt (modified) (2 diffs)
-
LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size.html (modified) (1 diff)
-
LayoutTests/fast/css/hover-affects-child-expected.txt (modified) (1 diff)
-
LayoutTests/fast/css/hover-affects-child.html (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css-timing-1/frames-timing-functions-output-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/centering-expected.txt (modified) (1 diff)
-
LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/semantics/interactive-elements (added)
-
LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element (added)
-
LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/centering-expected.txt (copied) (copied from trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/centering-expected.txt ) (1 diff)
-
LayoutTests/platform/mac-elcapitan/fast/css/getComputedStyle/computed-style-expected.txt (modified) (4 diffs)
-
LayoutTests/transitions/transition-to-from-auto-expected.txt (modified) (1 diff)
-
LayoutTests/transitions/transition-to-from-auto.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSComputedStyleDeclaration.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r217519 r217522 1 2017-05-27 Simon Fraser <simon.fraser@apple.com> 2 3 getComputedStyle returns percentage values for left / right / top / bottom 4 https://bugs.webkit.org/show_bug.cgi?id=29084 5 6 Reviewed by Zalan Bujtas. 7 8 Some new baselines, a new test, and an improved test. 9 10 * animations/trigger-container-scroll-boundaries-expected.txt: 11 * animations/trigger-container-scroll-boundaries.html: 12 * animations/trigger-container-scroll-empty-expected.txt: 13 * animations/trigger-container-scroll-empty.html: 14 * animations/trigger-container-scroll-simple-expected.txt: 15 * animations/trigger-container-scroll-simple.html: 16 * fast/css/getComputedStyle/computed-style-expected.txt: 17 * fast/css/getComputedStyle/computed-style-negative-top-expected.txt: 18 * fast/css/getComputedStyle/computed-style-negative-top.html: Convert to a real JS test, add more cases. 19 * fast/css/getComputedStyle/getComputedStyle-offsets-expected.txt: Added. 20 * fast/css/getComputedStyle/getComputedStyle-offsets.html: Added. 21 * fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size-expected.txt: 22 * fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size.html: It doesn't make any sense to test right/bottom. 23 * fast/css/hover-affects-child-expected.txt: 24 * fast/css/hover-affects-child.html: 25 * platform/mac-elcapitan/fast/css/getComputedStyle/computed-style-expected.txt: 26 * transitions/transition-to-from-auto-expected.txt: 27 * transitions/transition-to-from-auto.html: 28 1 29 2017-05-26 Youenn Fablet <youenn@apple.com> 2 30 -
trunk/LayoutTests/animations/trigger-container-scroll-boundaries-expected.txt
r181778 r217522 1 1 This element should begin animating only when the page scrolls to 20px from the top. It then animates smoothly, moving 100px to the left over the next 100px of scrolling. Remember to scroll to the top of the page before reloading! 2 2 3 PASS: Value before animation is applied is auto3 PASS: Value before animation is applied is 0px 4 4 PASS: Value with animation but no scroll was 0px 5 5 PASS: Value with scroll amount of 10 was 10px -
trunk/LayoutTests/animations/trigger-container-scroll-boundaries.html
r209409 r217522 49 49 box = document.getElementById("box"); 50 50 var leftValue = window.getComputedStyle(box).left; 51 if (leftValue == " auto")52 results.innerHTML = "PASS: Value before animation is applied is auto<br>";51 if (leftValue == "0px") 52 results.innerHTML = "PASS: Value before animation is applied is 0px<br>"; 53 53 else 54 54 results.innerHTML = "FAIL: Value before animation is applied should be auto, was " + leftValue + "<br>"; -
trunk/LayoutTests/animations/trigger-container-scroll-empty-expected.txt
r181778 r217522 1 1 This element should begin animating only when the page scrolls to 20px from the top. It specifies an end value, but that should be ignored because it is not greater than the start. This means the animation will run to completion rather than take the scroll value as input. Remember to scroll to the top of the page before reloading! 2 2 3 Value before animation is applied: auto (should be auto)3 Value before animation is applied: 0px (should be 0px) 4 4 Value with animation but no scroll: 0px (should be 0px) 5 5 PASS: Animation was not depending on scroll. -
trunk/LayoutTests/animations/trigger-container-scroll-empty.html
r209409 r217522 45 45 results = document.getElementById("results"); 46 46 box = document.getElementById("box"); 47 results.innerHTML = "Value before animation is applied: " + window.getComputedStyle(box).left + " (should be auto)<br>";47 results.innerHTML = "Value before animation is applied: " + window.getComputedStyle(box).left + " (should be 0px)<br>"; 48 48 box.className = "animating"; 49 49 setTimeout(checkValueWithoutScroll, 0); -
trunk/LayoutTests/animations/trigger-container-scroll-simple-expected.txt
r181655 r217522 1 1 This element should begin animating only when the page scrolls to 20px from the top. The animation is almost instantaneous, so it will snap to its final position. Remember to scroll to the top of the page before reloading! 2 2 3 Value before animation is applied: auto (should be auto)3 Value before animation is applied: 0px (should be 0px) 4 4 Value with animation but no scroll: 0px (should be 0px) 5 5 Value with animation after scroll: 100px (should be 100px) -
trunk/LayoutTests/animations/trigger-container-scroll-simple.html
r209409 r217522 45 45 results = document.getElementById("results"); 46 46 box = document.getElementById("box"); 47 results.innerHTML = "Value before animation is applied: " + window.getComputedStyle(box).left + " (should be auto)<br>";47 results.innerHTML = "Value before animation is applied: " + window.getComputedStyle(box).left + " (should be 0px)<br>"; 48 48 box.className = "animating"; 49 49 setTimeout(checkValueWithoutScroll, 0); -
trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt
r214394 r217522 31 31 border-top-style: none; 32 32 border-top-width: 0px; 33 bottom: auto;33 bottom: 16px; 34 34 box-shadow: none; 35 35 box-sizing: content-box; … … 55 55 height: 576px; 56 56 image-rendering: auto; 57 left: auto;57 left: -8px; 58 58 letter-spacing: normal; 59 59 line-height: 18px; … … 90 90 position: static; 91 91 resize: none; 92 right: auto;92 right: 8px; 93 93 speak: normal; 94 94 table-layout: auto; … … 101 101 text-overflow: clip; 102 102 text-transform: none; 103 top: auto;103 top: -8px; 104 104 transform: none; 105 105 transform-origin: 392px 288px; -
trunk/LayoutTests/fast/css/getComputedStyle/computed-style-negative-top-expected.txt
r41464 r217522 1 Test succeeded! Top is -1px. 1 Test computed offsets on elements with negative top and left. 2 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 4 5 6 7 With no height 8 PASS style.top is '-1px' 9 PASS style.left is '-2px' 10 PASS style.bottom is '1px' 11 PASS style.right is '2px' 12 13 With height:100%; 14 PASS style.top is '-1px' 15 PASS style.left is '-2px' 16 PASS style.bottom is '1px' 17 PASS style.right is '2px' 18 19 With height:auto; 20 PASS style.top is '-1px' 21 PASS style.left is '-2px' 22 PASS style.bottom is '1px' 23 PASS style.right is '2px' 24 PASS successfullyParsed is true 25 26 TEST COMPLETE 27 -
trunk/LayoutTests/fast/css/getComputedStyle/computed-style-negative-top.html
r120683 r217522 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script src="../../../resources/js-test-pre.js"></script> 5 </head> 6 <body> 7 <body> 8 <div id="testContainer1" style="width: 100px; height: 200px;"> 9 <div id="test1" style="position:relative; top:-1px; left:-2px;"></div> 10 </div> 11 12 <div id="testContainer2" style="width: 100px; height: 200px;"> 13 <div id="test2" style="position:relative; top:-1px; left:-2px; height:100%;"></div> 14 </div> 15 16 <div id="testContainer3" style="width: 100px; height: 200px;"> 17 <div id="test3" style="position:relative; top:-1px; left:-2px; height:auto;"></div> 18 </div> 19 1 20 <script> 2 function test() { 3 if (window.testRunner) 4 testRunner.dumpAsText(); 5 var style = document.defaultView.getComputedStyle(document.getElementById("test"), ""); 6 var result = document.getElementById("result"); 7 if (style.top == "-1px") 8 result.appendChild(document.createTextNode("Test succeeded! Top is " + style.top + ".")); 9 else 10 result.appendChild(document.createTextNode("Test failed! Top is " + style.top + ".")); 21 description("Test computed offsets on elements with negative top and left.") 22 23 var test = document.getElementById('test'); 24 var style; 25 26 function testStyle(name) 27 { 28 debug(''); 29 debug(name); 30 shouldBe("style.top", "'-1px'"); 31 shouldBe("style.left", "'-2px'"); 32 shouldBe("style.bottom", "'1px'"); 33 shouldBe("style.right", "'2px'"); 11 34 } 35 36 style = document.defaultView.getComputedStyle(document.getElementById("test1"), ""); 37 testStyle("With no height"); 38 39 style = document.defaultView.getComputedStyle(document.getElementById("test2"), ""); 40 testStyle("With height:100%;"); 41 42 style = document.defaultView.getComputedStyle(document.getElementById("test3"), ""); 43 testStyle("With height:auto;"); 44 12 45 </script> 13 <body onload="test()"> 14 <div id="test" style="position:relative; top:-1px"></div> 15 <div id="result"></div> 46 47 <script src="../../../resources/js-test-post.js"></script> 16 48 </body> -
trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size-expected.txt
r107301 r217522 35 35 left PASS 20px 20px 36 36 top PASS 20px 20px 37 right PASS 50px 50px38 bottom PASS 50px 50px39 37 font-size PASS 20px 20px 40 38 width PASS 400px 400px … … 90 88 left PASS 20px 20px 91 89 top PASS 20px 20px 92 right PASS 50px 50px93 bottom PASS 50px 50px94 90 font-size PASS 20px 20px 95 91 width PASS 400px 400px -
trunk/LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size.html
r120683 r217522 138 138 "left": "20px", 139 139 "top": "20px", 140 "right": "50px",141 "bottom": "50px",142 140 143 141 "font-size": "20px", -
trunk/LayoutTests/fast/css/hover-affects-child-expected.txt
r30635 r217522 1 1 This tests that a style that affects child elements when hovering over a parent element correctly recalculates the child style. To test manually move the mouse over the red square, it should become green. 2 PASSED: Calculated style of inner element is correct 2 FAILED: Calculated style of inner element is wrong, should be 'left: 0px' -
trunk/LayoutTests/fast/css/hover-affects-child.html
r120683 r217522 33 33 var calculatedStyle = window.getComputedStyle(innerElem); 34 34 35 if (calculatedStyle.getPropertyValue('left') == " auto")35 if (calculatedStyle.getPropertyValue('left') == "0px") 36 36 log("PASSED: Calculated style of inner element is correct"); 37 37 else 38 log("FAILED: Calculated style of inner element is wrong, should be 'left: auto'");38 log("FAILED: Calculated style of inner element is wrong, should be 'left: 0px'"); 39 39 } 40 40 -
trunk/LayoutTests/imported/w3c/ChangeLog
r217486 r217522 1 2017-05-27 Simon Fraser <simon.fraser@apple.com> 2 3 getComputedStyle returns percentage values for left / right / top / bottom 4 https://bugs.webkit.org/show_bug.cgi?id=29084 5 6 Reviewed by Zalan Bujtas. 7 8 New baselines (still failing). 9 10 * web-platform-tests/css-timing-1/frames-timing-functions-output-expected.txt: 11 * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/centering-expected.txt: 12 1 13 2017-05-26 Manuel Rego Casasnovas <rego@igalia.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css-timing-1/frames-timing-functions-output-expected.txt
r215852 r217522 1 1 2 FAIL For an input progress of 0.0, the output of a frames timing function is the first frame assert_equals: expected "0px" but got " auto"3 FAIL At a frame boundary, the output of a frames timing function is the next frame assert_equals: expected "0px" but got " auto"4 FAIL For an input progress of 1.0, the output of a frames timing function is the final frame assert_equals: expected "100px" but got " auto"5 FAIL The number of frames is correctly reflected in the frames timing function output assert_equals: expected "0px" but got " auto"6 FAIL The number of frames is correctly reflected in the frames timing function output on CSS Transitions assert_equals: expected "0px" but got " auto"2 FAIL For an input progress of 0.0, the output of a frames timing function is the first frame assert_equals: expected "0px" but got "8px" 3 FAIL At a frame boundary, the output of a frames timing function is the next frame assert_equals: expected "0px" but got "8px" 4 FAIL For an input progress of 1.0, the output of a frames timing function is the final frame assert_equals: expected "100px" but got "8px" 5 FAIL The number of frames is correctly reflected in the frames timing function output assert_equals: expected "0px" but got "8px" 6 FAIL The number of frames is correctly reflected in the frames timing function output on CSS Transitions assert_equals: expected "0px" but got "8px" 7 7 FAIL frames easing with input progress greater than 1 undefined is not a function (near '...target.animate...') 8 8 FAIL frames easing with input progress greater than 1.5 undefined is not a function (near '...target.animate...') -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/centering-expected.txt
r215164 r217522 23 23 FAIL vertical-lr: tall viewport assert_equals: expected "10px" but got "auto" 24 24 FAIL vertical-lr: dialog bigger than viewport assert_equals: expected "0px" but got "auto" 25 FAIL vertical-rl (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got " auto"26 FAIL vertical-lr (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got " auto"27 FAIL vertical-lr (dialog horizontal-tb): dialog bigger than viewport assert_equals: expected "0px" but got " auto"25 FAIL vertical-rl (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got "12px" 26 FAIL vertical-lr (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got "-8px" 27 FAIL vertical-lr (dialog horizontal-tb): dialog bigger than viewport assert_equals: expected "0px" but got "-8px" 28 28 FAIL horizontal-tb (container vertical-rl): tall viewport assert_equals: expected "10px" but got "auto" 29 29 FAIL vertical-rl (container horizontal-tb): tall viewport assert_equals: expected "45px" but got "auto" 30 FAIL horizontal-tb (container vertical-rl) (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got " auto"31 FAIL vertical-rl (container horizontal-tb) (dialog vertical-rl): tall viewport assert_equals: expected "45px" but got " auto"30 FAIL horizontal-tb (container vertical-rl) (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got "-8px" 31 FAIL vertical-rl (container horizontal-tb) (dialog vertical-rl): tall viewport assert_equals: expected "45px" but got "12px" 32 32 -
trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/centering-expected.txt
r217521 r217522 23 23 FAIL vertical-lr: tall viewport assert_equals: expected "10px" but got "auto" 24 24 FAIL vertical-lr: dialog bigger than viewport assert_equals: expected "0px" but got "auto" 25 FAIL vertical-rl (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got " auto"26 FAIL vertical-lr (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got " auto"27 FAIL vertical-lr (dialog horizontal-tb): dialog bigger than viewport assert_equals: expected "0px" but got " auto"25 FAIL vertical-rl (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got "13px" 26 FAIL vertical-lr (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got "-7px" 27 FAIL vertical-lr (dialog horizontal-tb): dialog bigger than viewport assert_equals: expected "0px" but got "-7px" 28 28 FAIL horizontal-tb (container vertical-rl): tall viewport assert_equals: expected "10px" but got "auto" 29 29 FAIL vertical-rl (container horizontal-tb): tall viewport assert_equals: expected "45px" but got "auto" 30 FAIL horizontal-tb (container vertical-rl) (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got " auto"31 FAIL vertical-rl (container horizontal-tb) (dialog vertical-rl): tall viewport assert_equals: expected "45px" but got " auto"30 FAIL horizontal-tb (container vertical-rl) (dialog horizontal-tb): tall viewport assert_equals: expected "10px" but got "-8px" 31 FAIL vertical-rl (container horizontal-tb) (dialog vertical-rl): tall viewport assert_equals: expected "45px" but got "13px" 32 32 -
trunk/LayoutTests/platform/mac-elcapitan/fast/css/getComputedStyle/computed-style-expected.txt
r214394 r217522 31 31 border-top-style: none; 32 32 border-top-width: 0px; 33 bottom: auto;33 bottom: 16px; 34 34 box-shadow: none; 35 35 box-sizing: content-box; … … 54 54 height: 576px; 55 55 image-rendering: auto; 56 left: auto;56 left: -8px; 57 57 letter-spacing: normal; 58 58 line-height: 18px; … … 89 89 position: static; 90 90 resize: none; 91 right: auto;91 right: 8px; 92 92 speak: normal; 93 93 table-layout: auto; … … 100 100 text-overflow: clip; 101 101 text-transform: none; 102 top: auto;102 top: -8px; 103 103 transform: none; 104 104 transform-origin: 392px 288px; -
trunk/LayoutTests/transitions/transition-to-from-auto-expected.txt
r200360 r217522 1 PASS - "left" property for "test1" element at 1s saw something close to: auto1 PASS - "left" property for "test1" element at 1s saw something close to: 0 2 2 PASS - "left" property for "test2" element at 1s saw something close to: 100 3 3 PASS - "left" property for "test3" element at 1s saw something close to: 50 -
trunk/LayoutTests/transitions/transition-to-from-auto.html
r200360 r217522 42 42 const expectedValues = [ 43 43 // [time, element-id, property, expected-value, tolerance] 44 [1, 'test1', 'left', ' auto', 2],44 [1, 'test1', 'left', '0', 2], 45 45 [1, 'test2', 'left', '100', 2], 46 46 [1, 'test3', 'left', '50', 2], -
trunk/Source/WebCore/ChangeLog
r217521 r217522 1 2017-05-26 Simon Fraser <simon.fraser@apple.com> 2 3 getComputedStyle returns percentage values for left / right / top / bottom 4 https://bugs.webkit.org/show_bug.cgi?id=29084 5 6 Reviewed by Zalan Bujtas. 7 8 Fix getComputedStyle() to return pixel values for left / right / top / bottom, per spec. 9 10 This is mostly a merge of https://codereview.chromium.org/13871003/. 11 12 Behavior now matches Chrome and Firefox. 13 14 Test: fast/css/getComputedStyle/getComputedStyle-offsets.html 15 16 * css/CSSComputedStyleDeclaration.cpp: 17 (WebCore::getOffsetComputedLength): 18 (WebCore::getOffsetUsedStyleRelative): 19 (WebCore::getOffsetUsedStyleAbsolute): 20 (WebCore::positionOffsetValue): 21 (WebCore::positionOffsetValueIsRendererDependent): 22 (WebCore::isNonReplacedInline): 23 (WebCore::isLayoutDependent): 24 (WebCore::ComputedStyleExtractor::propertyValue): 25 1 26 2017-05-27 Zalan Bujtas <zalan@apple.com> 2 27 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r217272 r217522 709 709 } 710 710 711 static RefPtr<CSSValue> positionOffsetValue(const RenderStyle& style, CSSPropertyID propertyID) 712 { 713 Length length; 711 static Length getOffsetComputedLength(const RenderStyle& style, CSSPropertyID propertyID) 712 { 713 // If specified as a length, the corresponding absolute length; if specified as 714 // a percentage, the specified value; otherwise, 'auto'. Hence, we can just 715 // return the value in the style. 716 // 717 // See http://www.w3.org/TR/CSS21/cascade.html#computed-value 714 718 switch (propertyID) { 715 case CSSPropertyLeft: 716 length = style.left(); 717 break; 718 case CSSPropertyRight: 719 length = style.right(); 720 break; 721 case CSSPropertyTop: 722 length = style.top(); 723 break; 724 case CSSPropertyBottom: 725 length = style.bottom(); 726 break; 727 default: 728 return nullptr; 729 } 730 731 if (style.hasOutOfFlowPosition()) { 732 if (length.isFixed()) 733 return zoomAdjustedPixelValue(length.value(), style); 734 735 return CSSValuePool::singleton().createValue(length); 736 } 737 738 if (style.hasInFlowPosition()) { 739 // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined. 740 // In other words if left is auto and right is not auto, then left's computed value is negative right(). 741 // So we should get the opposite length unit and see if it is auto. 742 return CSSValuePool::singleton().createValue(length); 743 } 744 745 return CSSValuePool::singleton().createIdentifierValue(CSSValueAuto); 719 case CSSPropertyLeft: 720 return style.left(); 721 case CSSPropertyRight: 722 return style.right(); 723 case CSSPropertyTop: 724 return style.top(); 725 case CSSPropertyBottom: 726 return style.bottom(); 727 default: 728 ASSERT_NOT_REACHED(); 729 } 730 731 return { }; 732 } 733 734 static LayoutUnit getOffsetUsedStyleRelative(RenderBox& box, CSSPropertyID propertyID) 735 { 736 // For relatively positioned boxes, the offset is with respect to the top edges 737 // of the box itself. This ties together top/bottom and left/right to be 738 // opposites of each other. 739 // 740 // See http://www.w3.org/TR/CSS2/visuren.html#relative-positioning 741 // 742 // Specifically; 743 // Since boxes are not split or stretched as a result of 'left' or 744 // 'right', the used values are always: left = -right. 745 // and 746 // Since boxes are not split or stretched as a result of 'top' or 747 // 'bottom', the used values are always: top = -bottom. 748 switch (propertyID) { 749 case CSSPropertyTop: 750 return box.relativePositionOffset().height(); 751 case CSSPropertyBottom: 752 return -(box.relativePositionOffset().height()); 753 case CSSPropertyLeft: 754 return box.relativePositionOffset().width(); 755 case CSSPropertyRight: 756 return -(box.relativePositionOffset().width()); 757 default: 758 ASSERT_NOT_REACHED(); 759 } 760 761 return 0; 762 } 763 764 static LayoutUnit getOffsetUsedStyleAbsolute(RenderBlock& container, RenderBox& box, CSSPropertyID propertyID) 765 { 766 // For absoultely positioned boxes, the offset is how far an box's margin 767 // edge is offset below the edge of the box's containing block. 768 // See http://www.w3.org/TR/CSS2/visuren.html#position-props 769 770 // Margins are included in offsetTop/offsetLeft so we need to remove them here. 771 switch (propertyID) { 772 case CSSPropertyTop: 773 return box.offsetTop() - box.marginTop(); 774 case CSSPropertyBottom: 775 return container.clientHeight() - (box.offsetTop() + box.offsetHeight()) - box.marginBottom(); 776 case CSSPropertyLeft: 777 return box.offsetLeft() - box.marginLeft(); 778 case CSSPropertyRight: 779 return container.clientWidth() - (box.offsetLeft() + box.offsetWidth()) - box.marginRight(); 780 default: 781 ASSERT_NOT_REACHED(); 782 } 783 784 return 0; 785 } 786 787 static RefPtr<CSSValue> positionOffsetValue(const RenderStyle& style, CSSPropertyID propertyID, RenderObject* renderer) 788 { 789 // If the element is not displayed; return the "computed value". 790 if (!renderer || !renderer->isBox()) 791 return zoomAdjustedPixelValueForLength(getOffsetComputedLength(style, propertyID), style); 792 793 // We should return the "used value". 794 LayoutUnit length = 0; 795 auto& box = downcast<RenderBox>(*renderer); 796 RenderBlock* containingBlock = box.containingBlock(); 797 if (box.isRelPositioned() || !containingBlock) 798 length = getOffsetUsedStyleRelative(box, propertyID); 799 else 800 length = getOffsetUsedStyleAbsolute(*containingBlock, box, propertyID); 801 802 return zoomAdjustedPixelValue(length, style); 746 803 } 747 804 … … 2200 2257 } 2201 2258 2259 static bool positionOffsetValueIsRendererDependent(const RenderStyle* style, RenderObject* renderer) 2260 { 2261 return renderer && style && renderer->isBox(); 2262 } 2263 2202 2264 static CSSValueID convertToPageBreak(BreakBetween value) 2203 2265 { … … 2250 2312 } 2251 2313 #endif 2252 2314 2315 static inline bool isNonReplacedInline(RenderObject& renderer) 2316 { 2317 return renderer.isInline() && !renderer.isReplaced(); 2318 } 2319 2253 2320 static bool isLayoutDependent(CSSPropertyID propertyID, const RenderStyle* style, RenderObject* renderer) 2254 2321 { 2255 2322 switch (propertyID) { 2323 case CSSPropertyTop: 2324 case CSSPropertyBottom: 2325 case CSSPropertyLeft: 2326 case CSSPropertyRight: 2327 return positionOffsetValueIsRendererDependent(style, renderer); 2256 2328 case CSSPropertyWidth: 2257 2329 case CSSPropertyHeight: 2330 return renderer && !renderer->isRenderSVGModelObject() && !isNonReplacedInline(*renderer); 2258 2331 case CSSPropertyPerspectiveOrigin: 2259 2332 case CSSPropertyTransformOrigin: 2260 2333 case CSSPropertyTransform: 2261 case CSSPropertyFilter: 2334 case CSSPropertyFilter: // Why are filters layout-dependent? 2262 2335 #if ENABLE(FILTERS_LEVEL_2) 2263 case CSSPropertyWebkitBackdropFilter: 2336 case CSSPropertyWebkitBackdropFilter: // Ditto for backdrop-filter. 2264 2337 #endif 2265 2338 return true; … … 2372 2445 } 2373 2446 2447 // In CSS 2.1 the returned object should actually contain the "used values" 2448 // rather then the "computed values" (despite the name saying otherwise). 2449 // 2450 // See; 2451 // http://www.w3.org/TR/CSS21/cascade.html#used-value 2452 // http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration 2453 // https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle#Notes 2374 2454 RefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const 2375 2455 { … … 2830 2910 return zoomAdjustedPixelValue(style->borderLeftWidth(), *style); 2831 2911 case CSSPropertyBottom: 2832 return positionOffsetValue(*style, CSSPropertyBottom );2912 return positionOffsetValue(*style, CSSPropertyBottom, renderer); 2833 2913 case CSSPropertyWebkitBoxAlign: 2834 2914 return cssValuePool.createValue(style->boxAlign()); … … 3078 3158 // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property, 3079 3159 // the "height" property does not apply for non-replaced inline elements. 3080 if ( !renderer->isReplaced() && renderer->isInline())3160 if (isNonReplacedInline(*renderer)) 3081 3161 return cssValuePool.createIdentifierValue(CSSValueAuto); 3082 3162 return zoomAdjustedPixelValue(sizingBox(*renderer).height(), *style); … … 3116 3196 #endif 3117 3197 case CSSPropertyLeft: 3118 return positionOffsetValue(*style, CSSPropertyLeft );3198 return positionOffsetValue(*style, CSSPropertyLeft, renderer); 3119 3199 case CSSPropertyLetterSpacing: 3120 3200 if (!style->letterSpacing()) … … 3254 3334 return cssValuePool.createValue(style->position()); 3255 3335 case CSSPropertyRight: 3256 return positionOffsetValue(*style, CSSPropertyRight );3336 return positionOffsetValue(*style, CSSPropertyRight, renderer); 3257 3337 case CSSPropertyWebkitRubyPosition: 3258 3338 return cssValuePool.createValue(style->rubyPosition()); … … 3354 3434 return cssValuePool.createValue(style->textTransform()); 3355 3435 case CSSPropertyTop: 3356 return positionOffsetValue(*style, CSSPropertyTop );3436 return positionOffsetValue(*style, CSSPropertyTop, renderer); 3357 3437 case CSSPropertyUnicodeBidi: 3358 3438 return cssValuePool.createValue(style->unicodeBidi()); … … 3394 3474 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property, 3395 3475 // the "width" property does not apply for non-replaced inline elements. 3396 if ( !renderer->isReplaced() && renderer->isInline())3476 if (isNonReplacedInline(*renderer)) 3397 3477 return cssValuePool.createIdentifierValue(CSSValueAuto); 3398 3478 return zoomAdjustedPixelValue(sizingBox(*renderer).width(), *style);
Note:
See TracChangeset
for help on using the changeset viewer.