Changeset 236979 in webkit


Ignore:
Timestamp:
Oct 9, 2018 1:11:04 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Resolve inset properties to computed style when there is overconstraintment
https://bugs.webkit.org/show_bug.cgi?id=188711

Patch by Oriol Brufau <Oriol Brufau> on 2018-10-09
Reviewed by Manuel Rego Casasnovas.

This patch makes WebKit behave closer to Blink. Specifically,

  • In overconstrained relative or absolute positioning, inset properties resolve to the computed value (absolutizing percentages) instead of to the used value.
  • In fixed positioning, the resolved value of non-'auto' values is no longer increased by the border of the containg block.

LayoutTests/imported/w3c:

Some tests still have failures due to

This patch can slighlty alter the resolved value if it's a long decimal number,
that's why test expectations for the timing functions test changed.

  • web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output-expected.txt:
  • web-platform-tests/css/cssom/getComputedStyle-insets-absolute-expected.txt: Added.
  • web-platform-tests/css/cssom/getComputedStyle-insets-absolute.html: Added.
  • web-platform-tests/css/cssom/getComputedStyle-insets-fixed-expected.txt: Added.
  • web-platform-tests/css/cssom/getComputedStyle-insets-fixed.html: Added.
  • web-platform-tests/css/cssom/getComputedStyle-insets-nobox-expected.txt: Added.
  • web-platform-tests/css/cssom/getComputedStyle-insets-nobox.html: Added.
  • web-platform-tests/css/cssom/getComputedStyle-insets-relative-expected.txt: Added.
  • web-platform-tests/css/cssom/getComputedStyle-insets-relative.html: Added.
  • web-platform-tests/css/cssom/getComputedStyle-insets-static-expected.txt: Added.
  • web-platform-tests/css/cssom/getComputedStyle-insets-static.html: Added.
  • web-platform-tests/css/cssom/getComputedStyle-insets-sticky-expected.txt: Added.
  • web-platform-tests/css/cssom/getComputedStyle-insets-sticky.html: Added.
  • web-platform-tests/css/cssom/support/getComputedStyle-insets.js: Added.

(serialize):
(wmName):
(checkStyle):
(runTestsWithWM):
(export.runTests):

Source/WebCore:

This patch can slighlty alter the resolved value if it's a long decimal number.

Tests: imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-absolute.html

imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-fixed.html
imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-nobox.html
imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-relative.html
imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-static.html
imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-sticky.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::positionOffsetValue):

  • rendering/RenderBox.h:
Location:
trunk
Files:
13 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r236932 r236979  
     12018-10-09  Oriol Brufau  <obrufau@igalia.com>
     2
     3        Resolve inset properties to computed style when there is overconstraintment
     4        https://bugs.webkit.org/show_bug.cgi?id=188711
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        This patch makes WebKit behave closer to Blink. Specifically,
     9         - In overconstrained relative or absolute positioning, inset properties resolve
     10           to the computed value (absolutizing percentages) instead of to the used value.
     11         - In fixed positioning, the resolved value of non-'auto' values is no longer
     12           increased by the border of the containg block.
     13
     14        Some tests still have failures due to
     15         - https://bugs.webkit.org/show_bug.cgi?id=189513
     16         - https://bugs.webkit.org/show_bug.cgi?id=189518
     17         - https://bugs.webkit.org/show_bug.cgi?id=189549
     18
     19        This patch can slighlty alter the resolved value if it's a long decimal number,
     20        that's why test expectations for the timing functions test changed.
     21
     22        * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output-expected.txt:
     23        * web-platform-tests/css/cssom/getComputedStyle-insets-absolute-expected.txt: Added.
     24        * web-platform-tests/css/cssom/getComputedStyle-insets-absolute.html: Added.
     25        * web-platform-tests/css/cssom/getComputedStyle-insets-fixed-expected.txt: Added.
     26        * web-platform-tests/css/cssom/getComputedStyle-insets-fixed.html: Added.
     27        * web-platform-tests/css/cssom/getComputedStyle-insets-nobox-expected.txt: Added.
     28        * web-platform-tests/css/cssom/getComputedStyle-insets-nobox.html: Added.
     29        * web-platform-tests/css/cssom/getComputedStyle-insets-relative-expected.txt: Added.
     30        * web-platform-tests/css/cssom/getComputedStyle-insets-relative.html: Added.
     31        * web-platform-tests/css/cssom/getComputedStyle-insets-static-expected.txt: Added.
     32        * web-platform-tests/css/cssom/getComputedStyle-insets-static.html: Added.
     33        * web-platform-tests/css/cssom/getComputedStyle-insets-sticky-expected.txt: Added.
     34        * web-platform-tests/css/cssom/getComputedStyle-insets-sticky.html: Added.
     35        * web-platform-tests/css/cssom/support/getComputedStyle-insets.js: Added.
     36        (serialize):
     37        (wmName):
     38        (checkStyle):
     39        (runTestsWithWM):
     40        (export.runTests):
     41
    1422018-10-08  Truitt Savell  <tsavell@apple.com>
    243
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output-expected.txt

    r228537 r236979  
    11
    2 FAIL cubic-bezier easing with input progress greater than 1 assert_approx_equals: The left of the animation should be approximately 98.8706654939602 at 230ms expected 98.8706654939602 +/- 0.01 but got 98.890625
    3 FAIL cubic-bezier easing with input progress greater than 1 and where the tangent on the upper boundary is infinity assert_approx_equals: The left of the animation should be approximately 106.31755608768113 at 230ms expected 106.31755608768113 +/- 0.01 but got 106.359375
    4 FAIL cubic-bezier easing with input progress less than 0 assert_approx_equals: The left of the animation should be approximately -16.589193103032184 at 10ms expected -16.589193103032184 +/- 0.01 but got -17.5
    5 FAIL cubic-bezier easing with input progress less than 0 and where the tangent on the lower boundary is infinity assert_approx_equals: The left of the animation should be approximately 0 at 300ms expected 0 +/- 0.01 but got 512.0625
     2FAIL cubic-bezier easing with input progress greater than 1 assert_approx_equals: The left of the animation should be approximately 98.8706654939602 at 230ms expected 98.8706654939602 +/- 0.01 but got 98.89859008789062
     3FAIL cubic-bezier easing with input progress greater than 1 and where the tangent on the upper boundary is infinity assert_approx_equals: The left of the animation should be approximately 106.31755608768113 at 230ms expected 106.31755608768113 +/- 0.01 but got 106.3595962524414
     4FAIL cubic-bezier easing with input progress less than 0 assert_approx_equals: The left of the animation should be approximately -16.589193103032184 at 10ms expected -16.589193103032184 +/- 0.01 but got -17.50836753845215
     5FAIL cubic-bezier easing with input progress less than 0 and where the tangent on the lower boundary is infinity assert_approx_equals: The left of the animation should be approximately 0 at 300ms expected 0 +/- 0.01 but got 512.0774536132812
    66
  • trunk/Source/WebCore/ChangeLog

    r236976 r236979  
     12018-10-09  Oriol Brufau  <obrufau@igalia.com>
     2
     3        Resolve inset properties to computed style when there is overconstraintment
     4        https://bugs.webkit.org/show_bug.cgi?id=188711
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        This patch makes WebKit behave closer to Blink. Specifically,
     9         - In overconstrained relative or absolute positioning, inset properties resolve
     10           to the computed value (absolutizing percentages) instead of to the used value.
     11         - In fixed positioning, the resolved value of non-'auto' values is no longer
     12           increased by the border of the containg block.
     13
     14        This patch can slighlty alter the resolved value if it's a long decimal number.
     15
     16        Tests: imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-absolute.html
     17               imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-fixed.html
     18               imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-nobox.html
     19               imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-relative.html
     20               imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-static.html
     21               imported/w3c/web-platform-tests/css/cssom/getComputedStyle-insets-sticky.html
     22
     23        * css/CSSComputedStyleDeclaration.cpp:
     24        (WebCore::positionOffsetValue):
     25        * rendering/RenderBox.h:
     26
    1272018-10-09  Jiewen Tan  <jiewen_tan@apple.com>
    228
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r236828 r236979  
    765765static RefPtr<CSSValue> positionOffsetValue(const RenderStyle& style, CSSPropertyID propertyID, RenderObject* renderer)
    766766{
     767    auto offset = getOffsetComputedLength(style, propertyID);
     768
    767769    // If the element is not displayed; return the "computed value".
    768770    if (!renderer || !renderer->isBox())
    769         return zoomAdjustedPixelValueForLength(getOffsetComputedLength(style, propertyID), style);
    770 
    771     // We should return the "used value".
     771        return zoomAdjustedPixelValueForLength(offset, style);
     772
    772773    auto& box = downcast<RenderBox>(*renderer);
    773774    auto* containingBlock = box.containingBlock();
    774     if (box.isRelativelyPositioned() || !containingBlock)
     775
     776    // Resolve a "computed value" percentage if the element is positioned.
     777    // TODO: percentages for sticky positioning should be handled here (bug 189549).
     778    if (containingBlock && offset.isPercentOrCalculated() && box.isPositioned() && !box.isStickilyPositioned()) {
     779        bool isVerticalProperty;
     780        if (propertyID == CSSPropertyTop || propertyID == CSSPropertyBottom)
     781            isVerticalProperty = true;
     782        else {
     783            ASSERT(propertyID == CSSPropertyLeft || propertyID == CSSPropertyRight);
     784            isVerticalProperty = false;
     785        }
     786        LayoutUnit containingBlockSize;
     787        if (isVerticalProperty == containingBlock->isHorizontalWritingMode()) {
     788            containingBlockSize = box.isOutOfFlowPositioned()
     789                ? box.containingBlockLogicalHeightForPositioned(*containingBlock, false)
     790                : box.containingBlockLogicalHeightForContent(ExcludeMarginBorderPadding);
     791        } else {
     792            containingBlockSize = box.isOutOfFlowPositioned()
     793                ? box.containingBlockLogicalWidthForPositioned(*containingBlock, nullptr, false)
     794                : box.containingBlockLogicalWidthForContent();
     795        }
     796        return zoomAdjustedPixelValue(floatValueForLength(offset, containingBlockSize), style);
     797    }
     798
     799    // Return a "computed value" length.
     800    if (!offset.isAuto())
     801        return zoomAdjustedPixelValueForLength(offset, style);
     802
     803    // The property won't be overconstrained if its computed value is "auto", so the "used value" can be returned.
     804    if (box.isRelativelyPositioned())
    775805        return zoomAdjustedPixelValue(getOffsetUsedStyleRelative(box, propertyID), style);
    776     if (renderer->isOutOfFlowPositioned())
     806
     807    if (containingBlock && box.isOutOfFlowPositioned())
    777808        return zoomAdjustedPixelValue(getOffsetUsedStyleOutOfFlowPositioned(*containingBlock, box, propertyID), style);
    778     // In-flow element.
    779     auto offset = getOffsetComputedLength(style, propertyID);
    780     if (offset.isAuto())
    781         return CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
    782     return zoomAdjustedPixelValueForLength(offset, style);
     809
     810    return CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
    783811}
    784812
  • trunk/Source/WebCore/rendering/RenderBox.h

    r236501 r236979  
    378378    LayoutUnit containingBlockLogicalWidthForContent() const override;
    379379    LayoutUnit containingBlockLogicalHeightForContent(AvailableLogicalHeightType) const;
    380 
     380    LayoutUnit containingBlockLogicalWidthForPositioned(const RenderBoxModelObject& containingBlock, RenderFragmentContainer* = nullptr, bool checkForPerpendicularWritingMode = true) const;
     381    LayoutUnit containingBlockLogicalHeightForPositioned(const RenderBoxModelObject& containingBlock, bool checkForPerpendicularWritingMode = true) const;
    381382    LayoutUnit containingBlockLogicalWidthForContentInFragment(RenderFragmentContainer*) const;
    382383    LayoutUnit containingBlockAvailableLineWidthInFragment(RenderFragmentContainer*) const;
     
    689690    bool repaintLayerRectsForImage(WrappedImagePtr, const FillLayer& layers, bool drawingBackground);
    690691
    691     LayoutUnit containingBlockLogicalWidthForPositioned(const RenderBoxModelObject& containingBlock, RenderFragmentContainer* = nullptr, bool checkForPerpendicularWritingMode = true) const;
    692     LayoutUnit containingBlockLogicalHeightForPositioned(const RenderBoxModelObject& containingBlock, bool checkForPerpendicularWritingMode = true) const;
    693 
    694692    void computePositionedLogicalHeight(LogicalExtentComputedValues&) const;
    695693    void computePositionedLogicalWidthUsing(SizeType, Length logicalWidth, const RenderBoxModelObject& containerBlock, TextDirection containerDirection,
Note: See TracChangeset for help on using the changeset viewer.