Changeset 194710 in webkit


Ignore:
Timestamp:
Jan 7, 2016 12:01:23 PM (8 years ago)
Author:
Alan Bujtas
Message:

Incorrect position: fixed; rendering when child of position:relative/sticky.
https://bugs.webkit.org/show_bug.cgi?id=147284

Reviewed by Simon Fraser and David Hyatt.

Computing logical left for positioned objects should take the relative positioned ancestors' offset
into account.

Source/WebCore:

Tests: fast/block/positioning/fixed-container-with-relative-parent.html

fast/block/positioning/fixed-container-with-sticky-parent.html

  • rendering/RenderBox.cpp:

(WebCore::computeInlineStaticDistance):

LayoutTests:

  • fast/block/positioning/fixed-container-with-relative-parent-expected.html: Added.
  • fast/block/positioning/fixed-container-with-relative-parent.html: Added.
  • fast/block/positioning/fixed-container-with-sticky-parent-expected.html: Added.
  • fast/block/positioning/fixed-container-with-sticky-parent.html: Added.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r194706 r194710  
     12016-01-07  Zalan Bujtas  <zalan@apple.com>
     2
     3        Incorrect position: fixed; rendering when child of position:relative/sticky.
     4        https://bugs.webkit.org/show_bug.cgi?id=147284
     5
     6        Reviewed by Simon Fraser and David Hyatt.
     7
     8        Computing logical left for positioned objects should take the relative positioned ancestors' offset
     9        into account.
     10
     11        * fast/block/positioning/fixed-container-with-relative-parent-expected.html: Added.
     12        * fast/block/positioning/fixed-container-with-relative-parent.html: Added.
     13        * fast/block/positioning/fixed-container-with-sticky-parent-expected.html: Added.
     14        * fast/block/positioning/fixed-container-with-sticky-parent.html: Added.
     15
    1162016-01-07  Chris Dumez  <cdumez@apple.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r194708 r194710  
     12016-01-07  Zalan Bujtas  <zalan@apple.com>
     2
     3        Incorrect position: fixed; rendering when child of position:relative/sticky.
     4        https://bugs.webkit.org/show_bug.cgi?id=147284
     5
     6        Reviewed by Simon Fraser and David Hyatt.
     7
     8        Computing logical left for positioned objects should take the relative positioned ancestors' offset
     9        into account.
     10
     11        Tests: fast/block/positioning/fixed-container-with-relative-parent.html
     12               fast/block/positioning/fixed-container-with-sticky-parent.html
     13
     14        * rendering/RenderBox.cpp:
     15        (WebCore::computeInlineStaticDistance):
     16
    1172016-01-06  Simon Fraser  <simon.fraser@apple.com>
    218
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r194514 r194710  
    33323332        LayoutUnit staticPosition = child->layer()->staticInlinePosition() - containerBlock->borderLogicalLeft();
    33333333        for (auto* current = child->parent(); current && current != containerBlock; current = current->container()) {
    3334             if (is<RenderBox>(*current)) {
    3335                 staticPosition += downcast<RenderBox>(*current).logicalLeft();
    3336                 if (region && is<RenderBlock>(*current)) {
    3337                     const RenderBlock& currentBlock = downcast<RenderBlock>(*current);
    3338                     region = currentBlock.clampToStartAndEndRegions(region);
    3339                     RenderBoxRegionInfo* boxInfo = currentBlock.renderBoxRegionInfo(region);
    3340                     if (boxInfo)
    3341                         staticPosition += boxInfo->logicalLeft();
    3342                 }
     3334            if (!is<RenderBox>(*current))
     3335                continue;
     3336            const auto& renderBox = downcast<RenderBox>(*current);
     3337            staticPosition += renderBox.logicalLeft();
     3338            if (renderBox.isInFlowPositioned())
     3339                staticPosition += renderBox.isHorizontalWritingMode() ? renderBox.offsetForInFlowPosition().width() : renderBox.offsetForInFlowPosition().height();
     3340            if (region && is<RenderBlock>(*current)) {
     3341                const RenderBlock& currentBlock = downcast<RenderBlock>(*current);
     3342                region = currentBlock.clampToStartAndEndRegions(region);
     3343                RenderBoxRegionInfo* boxInfo = currentBlock.renderBoxRegionInfo(region);
     3344                if (boxInfo)
     3345                    staticPosition += boxInfo->logicalLeft();
    33433346            }
    33443347        }
    33453348        logicalLeft.setValue(Fixed, staticPosition);
    33463349    } else {
    3347         RenderBox& enclosingBox = child->parent()->enclosingBox();
     3350        const RenderBox& enclosingBox = child->parent()->enclosingBox();
    33483351        LayoutUnit staticPosition = child->layer()->staticInlinePosition() + containerLogicalWidth + containerBlock->borderLogicalLeft();
    3349         for (RenderElement* current = &enclosingBox; current; current = current->container()) {
     3352        for (const RenderElement* current = &enclosingBox; current; current = current->container()) {
    33503353            if (is<RenderBox>(*current)) {
    3351                 if (current != containerBlock)
    3352                     staticPosition -= downcast<RenderBox>(*current).logicalLeft();
     3354                if (current != containerBlock) {
     3355                    const auto& renderBox = downcast<RenderBox>(*current);
     3356                    staticPosition -= renderBox.logicalLeft();
     3357                    if (renderBox.isInFlowPositioned())
     3358                        staticPosition -= renderBox.isHorizontalWritingMode() ? renderBox.offsetForInFlowPosition().width() : renderBox.offsetForInFlowPosition().height();
     3359                }
    33533360                if (current == &enclosingBox)
    33543361                    staticPosition -= enclosingBox.logicalWidth();
     
    37143721    LayoutUnit staticLogicalTop = child->layer()->staticBlockPosition() - containerBlock->borderBefore();
    37153722    for (RenderElement* container = child->parent(); container && container != containerBlock; container = container->container()) {
    3716         if (is<RenderBox>(*container) && !is<RenderTableRow>(*container))
    3717             staticLogicalTop += downcast<RenderBox>(*container).logicalTop();
     3723        if (!is<RenderBox>(*container))
     3724            continue;
     3725        const auto& renderBox = downcast<RenderBox>(*container);
     3726        if (!is<RenderTableRow>(renderBox))
     3727            staticLogicalTop += renderBox.logicalTop();
     3728        if (renderBox.isInFlowPositioned())
     3729            staticLogicalTop += renderBox.isHorizontalWritingMode() ? renderBox.offsetForInFlowPosition().height() : renderBox.offsetForInFlowPosition().width();
    37183730    }
    37193731    logicalTop.setValue(Fixed, staticLogicalTop);
Note: See TracChangeset for help on using the changeset viewer.