OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. |
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 2651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2662 | 2662 |
2663 // Use viewport as container for top-level fixed-position elements. | 2663 // Use viewport as container for top-level fixed-position elements. |
2664 if (style()->position() == FixedPosition && containingBlock->isRenderView()) { | 2664 if (style()->position() == FixedPosition && containingBlock->isRenderView()) { |
2665 const RenderView* view = toRenderView(containingBlock); | 2665 const RenderView* view = toRenderView(containingBlock); |
2666 if (FrameView* frameView = view->frameView()) { | 2666 if (FrameView* frameView = view->frameView()) { |
2667 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte ntRect(); | 2667 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte ntRect(); |
2668 return containingBlock->isHorizontalWritingMode() ? viewportRect.wid th() : viewportRect.height(); | 2668 return containingBlock->isHorizontalWritingMode() ? viewportRect.wid th() : viewportRect.height(); |
2669 } | 2669 } |
2670 } | 2670 } |
2671 | 2671 |
2672 if (hasOverrideContainingBlockLogicalWidth()) | |
2673 return overrideContainingBlockContentLogicalWidth(); | |
2674 | |
2672 if (containingBlock->isBox()) | 2675 if (containingBlock->isBox()) |
2673 return toRenderBox(containingBlock)->clientLogicalWidth(); | 2676 return toRenderBox(containingBlock)->clientLogicalWidth(); |
2674 | 2677 |
2675 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); | 2678 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); |
2676 | 2679 |
2677 const RenderInline* flow = toRenderInline(containingBlock); | 2680 const RenderInline* flow = toRenderInline(containingBlock); |
2678 InlineFlowBox* first = flow->firstLineBox(); | 2681 InlineFlowBox* first = flow->firstLineBox(); |
2679 InlineFlowBox* last = flow->lastLineBox(); | 2682 InlineFlowBox* last = flow->lastLineBox(); |
2680 | 2683 |
2681 // If the containing block is empty, return a width of 0. | 2684 // If the containing block is empty, return a width of 0. |
(...skipping 20 matching lines...) Expand all Loading... | |
2702 | 2705 |
2703 // Use viewport as container for top-level fixed-position elements. | 2706 // Use viewport as container for top-level fixed-position elements. |
2704 if (style()->position() == FixedPosition && containingBlock->isRenderView()) { | 2707 if (style()->position() == FixedPosition && containingBlock->isRenderView()) { |
2705 const RenderView* view = toRenderView(containingBlock); | 2708 const RenderView* view = toRenderView(containingBlock); |
2706 if (FrameView* frameView = view->frameView()) { | 2709 if (FrameView* frameView = view->frameView()) { |
2707 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte ntRect(); | 2710 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte ntRect(); |
2708 return containingBlock->isHorizontalWritingMode() ? viewportRect.hei ght() : viewportRect.width(); | 2711 return containingBlock->isHorizontalWritingMode() ? viewportRect.hei ght() : viewportRect.width(); |
2709 } | 2712 } |
2710 } | 2713 } |
2711 | 2714 |
2715 if (hasOverrideContainingBlockLogicalHeight()) | |
2716 return overrideContainingBlockContentLogicalHeight(); | |
2717 | |
2712 if (containingBlock->isBox()) { | 2718 if (containingBlock->isBox()) { |
2713 const RenderBlock* cb = containingBlock->isRenderBlock() ? | 2719 const RenderBlock* cb = containingBlock->isRenderBlock() ? |
2714 toRenderBlock(containingBlock) : containingBlock->containingBlock(); | 2720 toRenderBlock(containingBlock) : containingBlock->containingBlock(); |
2715 return cb->clientLogicalHeight(); | 2721 return cb->clientLogicalHeight(); |
2716 } | 2722 } |
2717 | 2723 |
2718 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); | 2724 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); |
2719 | 2725 |
2720 const RenderInline* flow = toRenderInline(containingBlock); | 2726 const RenderInline* flow = toRenderInline(containingBlock); |
2721 InlineFlowBox* first = flow->firstLineBox(); | 2727 InlineFlowBox* first = flow->firstLineBox(); |
2722 InlineFlowBox* last = flow->lastLineBox(); | 2728 InlineFlowBox* last = flow->lastLineBox(); |
2723 | 2729 |
2724 // If the containing block is empty, return a height of 0. | 2730 // If the containing block is empty, return a height of 0. |
2725 if (!first || !last) | 2731 if (!first || !last) |
2726 return 0; | 2732 return 0; |
2727 | 2733 |
2728 LayoutUnit heightResult; | 2734 LayoutUnit heightResult; |
2729 LayoutRect boundingBox = flow->linesBoundingBox(); | 2735 LayoutRect boundingBox = flow->linesBoundingBox(); |
2730 if (containingBlock->isHorizontalWritingMode()) | 2736 if (containingBlock->isHorizontalWritingMode()) |
2731 heightResult = boundingBox.height(); | 2737 heightResult = boundingBox.height(); |
2732 else | 2738 else |
2733 heightResult = boundingBox.width(); | 2739 heightResult = boundingBox.width(); |
2734 heightResult -= (containingBlock->borderBefore() + containingBlock->borderAf ter()); | 2740 heightResult -= (containingBlock->borderBefore() + containingBlock->borderAf ter()); |
2735 return heightResult; | 2741 return heightResult; |
2736 } | 2742 } |
2737 | 2743 |
2738 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh t, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUni t containerLogicalWidth) | 2744 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh t, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUni t containerLogicalWidth) |
2739 { | 2745 { |
2740 if (!logicalLeft.isAuto() || !logicalRight.isAuto()) | 2746 if ((!logicalLeft.isAuto() || !logicalRight.isAuto()) && !child->parent()->i sRenderGrid()) |
2741 return; | 2747 return; |
2742 | 2748 |
2743 // FIXME: The static distance computation has not been patched for mixed wri ting modes yet. | 2749 // FIXME: The static distance computation has not been patched for mixed wri ting modes yet. |
2744 if (child->parent()->style()->direction() == LTR) { | 2750 if (child->parent()->style()->direction() == LTR) { |
2745 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - con tainerBlock->borderLogicalLeft(); | 2751 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - con tainerBlock->borderLogicalLeft(); |
2746 for (RenderObject* curr = child->parent(); curr && curr != containerBloc k; curr = curr->container()) { | 2752 for (RenderObject* curr = child->parent(); curr && curr != containerBloc k; curr = curr->container()) { |
2747 if (curr->isBox()) { | 2753 if (curr->isBox()) { |
2748 staticPosition += toRenderBox(curr)->logicalLeft(); | 2754 staticPosition += toRenderBox(curr)->logicalLeft(); |
2749 if (toRenderBox(curr)->isRelPositioned()) | 2755 if (toRenderBox(curr)->isRelPositioned()) |
2750 staticPosition += toRenderBox(curr)->relativePositionOffset( ).width(); | 2756 staticPosition += toRenderBox(curr)->relativePositionOffset( ).width(); |
2751 } else if (curr->isInline()) { | 2757 } else if (curr->isInline()) { |
2752 if (curr->isRelPositioned()) { | 2758 if (curr->isRelPositioned()) { |
2753 if (!curr->style()->logicalLeft().isAuto()) | 2759 if (!curr->style()->logicalLeft().isAuto()) |
2754 staticPosition += curr->style()->logicalLeft().value(); | 2760 staticPosition += curr->style()->logicalLeft().value(); |
2755 else | 2761 else |
2756 staticPosition -= curr->style()->logicalRight().value(); | 2762 staticPosition -= curr->style()->logicalRight().value(); |
2757 } | 2763 } |
2758 } | 2764 } |
2759 } | 2765 } |
2766 if (!logicalLeft.isAuto()) | |
2767 staticPosition += valueForLength(logicalLeft, containerLogicalWidth) ; | |
2768 else if (!logicalRight.isAuto()) | |
2769 staticPosition -= valueForLength(logicalRight, containerLogicalWidth ); | |
Julien - ping for review
2014/10/20 19:34:43
It's unclear to me why this doesn't impact regular
Manuel Rego
2014/10/23 12:48:38
Basically it doesn't affect regular blocks, becaus
| |
2760 logicalLeft.setValue(Fixed, staticPosition); | 2770 logicalLeft.setValue(Fixed, staticPosition); |
2761 } else { | 2771 } else { |
2762 RenderBox* enclosingBox = child->parent()->enclosingBox(); | 2772 RenderBox* enclosingBox = child->parent()->enclosingBox(); |
2763 LayoutUnit staticPosition = child->layer()->staticInlinePosition() + con tainerLogicalWidth + containerBlock->borderLogicalLeft(); | 2773 LayoutUnit staticPosition = child->layer()->staticInlinePosition() + con tainerLogicalWidth + containerBlock->borderLogicalLeft(); |
2764 for (RenderObject* curr = child->parent(); curr; curr = curr->container( )) { | 2774 for (RenderObject* curr = child->parent(); curr; curr = curr->container( )) { |
2765 if (curr->isBox()) { | 2775 if (curr->isBox()) { |
2766 if (curr != containerBlock) { | 2776 if (curr != containerBlock) { |
2767 staticPosition -= toRenderBox(curr)->logicalLeft(); | 2777 staticPosition -= toRenderBox(curr)->logicalLeft(); |
2768 if (toRenderBox(curr)->isRelPositioned()) | 2778 if (toRenderBox(curr)->isRelPositioned()) |
2769 staticPosition -= toRenderBox(curr)->relativePositionOff set().width(); | 2779 staticPosition -= toRenderBox(curr)->relativePositionOff set().width(); |
2770 } | 2780 } |
2771 if (curr == enclosingBox) | 2781 if (curr == enclosingBox) |
2772 staticPosition -= enclosingBox->logicalWidth(); | 2782 staticPosition -= enclosingBox->logicalWidth(); |
2773 } else if (curr->isInline()) { | 2783 } else if (curr->isInline()) { |
2774 if (curr->isRelPositioned()) { | 2784 if (curr->isRelPositioned()) { |
2775 if (!curr->style()->logicalLeft().isAuto()) | 2785 if (!curr->style()->logicalLeft().isAuto()) |
2776 staticPosition -= curr->style()->logicalLeft().value(); | 2786 staticPosition -= curr->style()->logicalLeft().value(); |
Julien - ping for review
2014/10/20 19:34:43
O_o
That looks like a bug to me. It will happily
Manuel Rego
2014/10/22 14:06:20
Though this is unrelated to my patch, I've been ch
| |
2777 else | 2787 else |
2778 staticPosition += curr->style()->logicalRight().value(); | 2788 staticPosition += curr->style()->logicalRight().value(); |
2779 } | 2789 } |
2780 } | 2790 } |
2781 if (curr == containerBlock) | 2791 if (curr == containerBlock) |
2782 break; | 2792 break; |
2783 } | 2793 } |
2794 if (!logicalRight.isAuto()) | |
2795 staticPosition += valueForLength(logicalRight, containerLogicalWidth ); | |
2796 else if (!logicalLeft.isAuto()) | |
2797 staticPosition -= valueForLength(logicalLeft, containerLogicalWidth) ; | |
Manuel Rego
2014/10/23 12:48:38
Like in the previous method, I've done something s
| |
2784 logicalRight.setValue(Fixed, staticPosition); | 2798 logicalRight.setValue(Fixed, staticPosition); |
2785 } | 2799 } |
2786 } | 2800 } |
2787 | 2801 |
2788 void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu tedValues) const | 2802 void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu tedValues) const |
2789 { | 2803 { |
2790 if (isReplaced()) { | 2804 if (isReplaced()) { |
2791 computePositionedLogicalWidthReplaced(computedValues); | 2805 computePositionedLogicalWidthReplaced(computedValues); |
2792 return; | 2806 return; |
2793 } | 2807 } |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3096 } | 3110 } |
3097 | 3111 |
3098 if (containerBlock->isBox() && toRenderBox(containerBlock)->scrollsOverflowY () && containerBlock->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ) { | 3112 if (containerBlock->isBox() && toRenderBox(containerBlock)->scrollsOverflowY () && containerBlock->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ) { |
3099 logicalLeftValue = logicalLeftValue + toRenderBox(containerBlock)->verti calScrollbarWidth(); | 3113 logicalLeftValue = logicalLeftValue + toRenderBox(containerBlock)->verti calScrollbarWidth(); |
3100 } | 3114 } |
3101 | 3115 |
3102 computedValues.m_position = logicalLeftValue + marginLogicalLeftValue; | 3116 computedValues.m_position = logicalLeftValue + marginLogicalLeftValue; |
3103 computeLogicalLeftPositionedOffset(computedValues.m_position, this, computed Values.m_extent, containerBlock, containerLogicalWidth); | 3117 computeLogicalLeftPositionedOffset(computedValues.m_position, this, computed Values.m_extent, containerBlock, containerLogicalWidth); |
3104 } | 3118 } |
3105 | 3119 |
3106 static void computeBlockStaticDistance(Length& logicalTop, Length& logicalBottom , const RenderBox* child, const RenderBoxModelObject* containerBlock) | 3120 static void computeBlockStaticDistance(Length& logicalTop, Length& logicalBottom , const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUnit containerLogicalHeight) |
3107 { | 3121 { |
3108 if (!logicalTop.isAuto() || !logicalBottom.isAuto()) | 3122 if ((!logicalTop.isAuto() || !logicalBottom.isAuto()) && !child->parent()->i sRenderGrid()) |
3109 return; | 3123 return; |
3110 | 3124 |
3111 // FIXME: The static distance computation has not been patched for mixed wri ting modes. | 3125 // FIXME: The static distance computation has not been patched for mixed wri ting modes. |
3112 LayoutUnit staticLogicalTop = child->layer()->staticBlockPosition() - contai nerBlock->borderBefore(); | 3126 LayoutUnit staticLogicalTop = child->layer()->staticBlockPosition() - contai nerBlock->borderBefore(); |
3113 for (RenderObject* curr = child->parent(); curr && curr != containerBlock; c urr = curr->container()) { | 3127 for (RenderObject* curr = child->parent(); curr && curr != containerBlock; c urr = curr->container()) { |
3114 if (curr->isBox() && !curr->isTableRow()) | 3128 if (curr->isBox() && !curr->isTableRow()) |
3115 staticLogicalTop += toRenderBox(curr)->logicalTop(); | 3129 staticLogicalTop += toRenderBox(curr)->logicalTop(); |
3116 } | 3130 } |
3131 if (!logicalTop.isAuto()) | |
3132 staticLogicalTop += valueForLength(logicalTop, containerLogicalHeight); | |
3133 else if (!logicalBottom.isAuto()) | |
3134 staticLogicalTop -= valueForLength(logicalBottom, containerLogicalHeight ); | |
3117 logicalTop.setValue(Fixed, staticLogicalTop); | 3135 logicalTop.setValue(Fixed, staticLogicalTop); |
3118 } | 3136 } |
3119 | 3137 |
3120 void RenderBox::computePositionedLogicalHeight(LogicalExtentComputedValues& comp utedValues) const | 3138 void RenderBox::computePositionedLogicalHeight(LogicalExtentComputedValues& comp utedValues) const |
3121 { | 3139 { |
3122 if (isReplaced()) { | 3140 if (isReplaced()) { |
3123 computePositionedLogicalHeightReplaced(computedValues); | 3141 computePositionedLogicalHeightReplaced(computedValues); |
3124 return; | 3142 return; |
3125 } | 3143 } |
3126 | 3144 |
(...skipping 28 matching lines...) Expand all Loading... | |
3155 * But rather than actually calculating the dimensions of that hypothetical | 3173 * But rather than actually calculating the dimensions of that hypothetical |
3156 * box, user agents are free to make a guess at its probable position. | 3174 * box, user agents are free to make a guess at its probable position. |
3157 * | 3175 * |
3158 * For the purposes of calculating the static position, the containing block | 3176 * For the purposes of calculating the static position, the containing block |
3159 * of fixed positioned elements is the initial containing block instead of | 3177 * of fixed positioned elements is the initial containing block instead of |
3160 * the viewport. | 3178 * the viewport. |
3161 \*-------------------------------------------------------------------------- -*/ | 3179 \*-------------------------------------------------------------------------- -*/ |
3162 | 3180 |
3163 // see FIXME 1 | 3181 // see FIXME 1 |
3164 // Calculate the static distance if needed. | 3182 // Calculate the static distance if needed. |
3165 computeBlockStaticDistance(logicalTopLength, logicalBottomLength, this, cont ainerBlock); | 3183 computeBlockStaticDistance(logicalTopLength, logicalBottomLength, this, cont ainerBlock, containerLogicalHeight); |
3166 | 3184 |
3167 // Calculate constraint equation values for 'height' case. | 3185 // Calculate constraint equation values for 'height' case. |
3168 LayoutUnit logicalHeight = computedValues.m_extent; | 3186 LayoutUnit logicalHeight = computedValues.m_extent; |
3169 computePositionedLogicalHeightUsing(styleToUse->logicalHeight(), containerBl ock, containerLogicalHeight, bordersPlusPadding, logicalHeight, | 3187 computePositionedLogicalHeightUsing(styleToUse->logicalHeight(), containerBl ock, containerLogicalHeight, bordersPlusPadding, logicalHeight, |
3170 logicalTopLength, logicalBottomLength, m arginBefore, marginAfter, | 3188 logicalTopLength, logicalBottomLength, m arginBefore, marginAfter, |
3171 computedValues); | 3189 computedValues); |
3172 | 3190 |
3173 // Avoid doing any work in the common case (where the values of min-height a nd max-height are their defaults). | 3191 // Avoid doing any work in the common case (where the values of min-height a nd max-height are their defaults). |
3174 // see FIXME 2 | 3192 // see FIXME 2 |
3175 | 3193 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3561 // are dealt with in computeReplacedHeight(). This means that the steps to produce | 3579 // are dealt with in computeReplacedHeight(). This means that the steps to produce |
3562 // correct max/min in the non-replaced version, are not necessary. | 3580 // correct max/min in the non-replaced version, are not necessary. |
3563 computedValues.m_extent = computeReplacedLogicalHeight() + borderAndPaddingL ogicalHeight(); | 3581 computedValues.m_extent = computeReplacedLogicalHeight() + borderAndPaddingL ogicalHeight(); |
3564 const LayoutUnit availableSpace = containerLogicalHeight - computedValues.m_ extent; | 3582 const LayoutUnit availableSpace = containerLogicalHeight - computedValues.m_ extent; |
3565 | 3583 |
3566 /*-----------------------------------------------------------------------*\ | 3584 /*-----------------------------------------------------------------------*\ |
3567 * 2. If both 'top' and 'bottom' have the value 'auto', replace 'top' | 3585 * 2. If both 'top' and 'bottom' have the value 'auto', replace 'top' |
3568 * with the element's static position. | 3586 * with the element's static position. |
3569 \*-----------------------------------------------------------------------*/ | 3587 \*-----------------------------------------------------------------------*/ |
3570 // see FIXME 1 | 3588 // see FIXME 1 |
3571 computeBlockStaticDistance(logicalTop, logicalBottom, this, containerBlock); | 3589 computeBlockStaticDistance(logicalTop, logicalBottom, this, containerBlock, containerLogicalHeight); |
3572 | 3590 |
3573 /*-----------------------------------------------------------------------*\ | 3591 /*-----------------------------------------------------------------------*\ |
3574 * 3. If 'bottom' is 'auto', replace any 'auto' on 'margin-top' or | 3592 * 3. If 'bottom' is 'auto', replace any 'auto' on 'margin-top' or |
3575 * 'margin-bottom' with '0'. | 3593 * 'margin-bottom' with '0'. |
3576 \*-----------------------------------------------------------------------*/ | 3594 \*-----------------------------------------------------------------------*/ |
3577 // FIXME: The spec. says that this step should only be taken when bottom is | 3595 // FIXME: The spec. says that this step should only be taken when bottom is |
3578 // auto, but if only top is auto, this makes step 4 impossible. | 3596 // auto, but if only top is auto, this makes step 4 impossible. |
3579 if (logicalTop.isAuto() || logicalBottom.isAuto()) { | 3597 if (logicalTop.isAuto() || logicalBottom.isAuto()) { |
3580 if (marginBefore.isAuto()) | 3598 if (marginBefore.isAuto()) |
3581 marginBefore.setValue(Fixed, 0); | 3599 marginBefore.setValue(Fixed, 0); |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4509 ASSERT(style()->hasBackground() || style()->hasBoxDecorations()); | 4527 ASSERT(style()->hasBackground() || style()->hasBoxDecorations()); |
4510 | 4528 |
4511 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) | 4529 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) |
4512 return m_rareData->m_previousBorderBoxSize; | 4530 return m_rareData->m_previousBorderBoxSize; |
4513 | 4531 |
4514 // We didn't save the old border box size because it was the same as the siz e of oldBounds. | 4532 // We didn't save the old border box size because it was the same as the siz e of oldBounds. |
4515 return previousBoundsSize; | 4533 return previousBoundsSize; |
4516 } | 4534 } |
4517 | 4535 |
4518 } // namespace blink | 4536 } // namespace blink |
OLD | NEW |