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. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. |
7 * All rights reserved. | 7 * All rights reserved. |
8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 if (style()->hasBlendMode()) | 1529 if (style()->hasBlendMode()) |
1530 return false; | 1530 return false; |
1531 return backgroundRect(BackgroundKnownOpaqueRect).contains(localRect); | 1531 return backgroundRect(BackgroundKnownOpaqueRect).contains(localRect); |
1532 } | 1532 } |
1533 | 1533 |
1534 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) { | 1534 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) { |
1535 const ComputedStyle& childStyle = childBox.styleRef(); | 1535 const ComputedStyle& childStyle = childBox.styleRef(); |
1536 if (childStyle.position() != StaticPosition && | 1536 if (childStyle.position() != StaticPosition && |
1537 childBox.containingBlock() != childBox.parent()) | 1537 childBox.containingBlock() != childBox.parent()) |
1538 return false; | 1538 return false; |
1539 if (childStyle.visibility() != EVisibility::Visible || | 1539 if (childStyle.visibility() != EVisibility::kVisible || |
1540 childStyle.shapeOutside()) | 1540 childStyle.shapeOutside()) |
1541 return false; | 1541 return false; |
1542 if (childBox.size().isZero()) | 1542 if (childBox.size().isZero()) |
1543 return false; | 1543 return false; |
1544 if (PaintLayer* childLayer = childBox.layer()) { | 1544 if (PaintLayer* childLayer = childBox.layer()) { |
1545 // FIXME: perhaps this could be less conservative? | 1545 // FIXME: perhaps this could be less conservative? |
1546 if (childLayer->compositingState() != NotComposited) | 1546 if (childLayer->compositingState() != NotComposited) |
1547 return false; | 1547 return false; |
1548 // FIXME: Deal with z-index. | 1548 // FIXME: Deal with z-index. |
1549 if (childStyle.isStackingContext()) | 1549 if (childStyle.isStackingContext()) |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2281 // may have some effect. For example, honoring the border-radius clip on | 2281 // may have some effect. For example, honoring the border-radius clip on |
2282 // a composited child paints into a mask for an otherwise non-painting | 2282 // a composited child paints into a mask for an otherwise non-painting |
2283 // element, because children of that element will require the mask. | 2283 // element, because children of that element will require the mask. |
2284 if (hasLayer() && layer()->compositingState() == PaintsIntoOwnBacking) | 2284 if (hasLayer() && layer()->compositingState() == PaintsIntoOwnBacking) |
2285 return false; | 2285 return false; |
2286 | 2286 |
2287 return true; | 2287 return true; |
2288 } | 2288 } |
2289 | 2289 |
2290 LayoutRect LayoutBox::localVisualRect() const { | 2290 LayoutRect LayoutBox::localVisualRect() const { |
2291 if (style()->visibility() != EVisibility::Visible) | 2291 if (style()->visibility() != EVisibility::kVisible) |
2292 return LayoutRect(); | 2292 return LayoutRect(); |
2293 | 2293 |
2294 if (hasMask() && !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 2294 if (hasMask() && !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
2295 return LayoutRect(layer()->boxForFilterOrMask()); | 2295 return LayoutRect(layer()->boxForFilterOrMask()); |
2296 return selfVisualOverflowRect(); | 2296 return selfVisualOverflowRect(); |
2297 } | 2297 } |
2298 | 2298 |
2299 void LayoutBox::inflateVisualRectForFilterUnderContainer( | 2299 void LayoutBox::inflateVisualRectForFilterUnderContainer( |
2300 LayoutRect& rect, | 2300 LayoutRect& rect, |
2301 const LayoutObject& container, | 2301 const LayoutObject& container, |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2850 ? marginStartWidth + marginEndWidth | 2850 ? marginStartWidth + marginEndWidth |
2851 : LayoutUnit()); | 2851 : LayoutUnit()); |
2852 | 2852 |
2853 if (marginBoxWidth < availableWidth) { | 2853 if (marginBoxWidth < availableWidth) { |
2854 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their used | 2854 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their used |
2855 // values are equal. This horizontally centers the element with respect to | 2855 // values are equal. This horizontally centers the element with respect to |
2856 // the edges of the containing block." | 2856 // the edges of the containing block." |
2857 const ComputedStyle& containingBlockStyle = containingBlock->styleRef(); | 2857 const ComputedStyle& containingBlockStyle = containingBlock->styleRef(); |
2858 if ((marginStartLength.isAuto() && marginEndLength.isAuto()) || | 2858 if ((marginStartLength.isAuto() && marginEndLength.isAuto()) || |
2859 (!marginStartLength.isAuto() && !marginEndLength.isAuto() && | 2859 (!marginStartLength.isAuto() && !marginEndLength.isAuto() && |
2860 containingBlockStyle.textAlign() == ETextAlign::WebkitCenter)) { | 2860 containingBlockStyle.textAlign() == ETextAlign::kWebkitCenter)) { |
2861 // Other browsers center the margin box for align=center elements so we | 2861 // Other browsers center the margin box for align=center elements so we |
2862 // match them here. | 2862 // match them here. |
2863 LayoutUnit centeredMarginBoxStart = std::max( | 2863 LayoutUnit centeredMarginBoxStart = std::max( |
2864 LayoutUnit(), | 2864 LayoutUnit(), |
2865 (availableWidth - childWidth - marginStartWidth - marginEndWidth) / | 2865 (availableWidth - childWidth - marginStartWidth - marginEndWidth) / |
2866 2); | 2866 2); |
2867 marginStart = centeredMarginBoxStart + marginStartWidth; | 2867 marginStart = centeredMarginBoxStart + marginStartWidth; |
2868 marginEnd = availableWidth - childWidth - marginStart + marginEndWidth; | 2868 marginEnd = availableWidth - childWidth - marginStart + marginEndWidth; |
2869 return; | 2869 return; |
2870 } | 2870 } |
2871 | 2871 |
2872 // Adjust margins for the align attribute | 2872 // Adjust margins for the align attribute |
2873 if ((!containingBlockStyle.isLeftToRightDirection() && | 2873 if ((!containingBlockStyle.isLeftToRightDirection() && |
2874 containingBlockStyle.textAlign() == ETextAlign::WebkitLeft) || | 2874 containingBlockStyle.textAlign() == ETextAlign::kWebkitLeft) || |
2875 (containingBlockStyle.isLeftToRightDirection() && | 2875 (containingBlockStyle.isLeftToRightDirection() && |
2876 containingBlockStyle.textAlign() == ETextAlign::WebkitRight)) { | 2876 containingBlockStyle.textAlign() == ETextAlign::kWebkitRight)) { |
2877 if (containingBlockStyle.isLeftToRightDirection() != | 2877 if (containingBlockStyle.isLeftToRightDirection() != |
2878 styleRef().isLeftToRightDirection()) { | 2878 styleRef().isLeftToRightDirection()) { |
2879 if (!marginStartLength.isAuto()) | 2879 if (!marginStartLength.isAuto()) |
2880 marginEndLength = Length(Auto); | 2880 marginEndLength = Length(Auto); |
2881 } else { | 2881 } else { |
2882 if (!marginEndLength.isAuto()) | 2882 if (!marginEndLength.isAuto()) |
2883 marginStartLength = Length(Auto); | 2883 marginStartLength = Length(Auto); |
2884 } | 2884 } |
2885 } | 2885 } |
2886 | 2886 |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3727 LayoutUnit containerLogicalWidth) { | 3727 LayoutUnit containerLogicalWidth) { |
3728 if (!logicalLeft.isAuto() || !logicalRight.isAuto()) | 3728 if (!logicalLeft.isAuto() || !logicalRight.isAuto()) |
3729 return; | 3729 return; |
3730 | 3730 |
3731 // For multicol we also need to keep track of the block position, since that | 3731 // For multicol we also need to keep track of the block position, since that |
3732 // determines which column we're in and thus affects the inline position. | 3732 // determines which column we're in and thus affects the inline position. |
3733 LayoutUnit staticBlockPosition = child->layer()->staticBlockPosition(); | 3733 LayoutUnit staticBlockPosition = child->layer()->staticBlockPosition(); |
3734 | 3734 |
3735 // FIXME: The static distance computation has not been patched for mixed | 3735 // FIXME: The static distance computation has not been patched for mixed |
3736 // writing modes yet. | 3736 // writing modes yet. |
3737 if (child->parent()->style()->direction() == TextDirection::Ltr) { | 3737 if (child->parent()->style()->direction() == TextDirection::kLtr) { |
3738 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - | 3738 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - |
3739 containerBlock->borderLogicalLeft(); | 3739 containerBlock->borderLogicalLeft(); |
3740 for (LayoutObject* curr = child->parent(); curr && curr != containerBlock; | 3740 for (LayoutObject* curr = child->parent(); curr && curr != containerBlock; |
3741 curr = curr->container()) { | 3741 curr = curr->container()) { |
3742 if (curr->isBox()) { | 3742 if (curr->isBox()) { |
3743 staticPosition += toLayoutBox(curr)->logicalLeft(); | 3743 staticPosition += toLayoutBox(curr)->logicalLeft(); |
3744 if (toLayoutBox(curr)->isInFlowPositioned()) | 3744 if (toLayoutBox(curr)->isInFlowPositioned()) |
3745 staticPosition += | 3745 staticPosition += |
3746 toLayoutBox(curr)->offsetForInFlowPosition().width(); | 3746 toLayoutBox(curr)->offsetForInFlowPosition().width(); |
3747 if (curr->isInsideFlowThread()) | 3747 if (curr->isInsideFlowThread()) |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4025 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { | 4025 if (marginLogicalLeft.isAuto() && marginLogicalRight.isAuto()) { |
4026 // Both margins auto, solve for equality | 4026 // Both margins auto, solve for equality |
4027 if (availableSpace >= 0) { | 4027 if (availableSpace >= 0) { |
4028 marginLogicalLeftValue = availableSpace / 2; // split the difference | 4028 marginLogicalLeftValue = availableSpace / 2; // split the difference |
4029 marginLogicalRightValue = | 4029 marginLogicalRightValue = |
4030 availableSpace - | 4030 availableSpace - |
4031 marginLogicalLeftValue; // account for odd valued differences | 4031 marginLogicalLeftValue; // account for odd valued differences |
4032 } else { | 4032 } else { |
4033 // Use the containing block's direction rather than the parent block's | 4033 // Use the containing block's direction rather than the parent block's |
4034 // per CSS 2.1 reference test abspos-non-replaced-width-margin-000. | 4034 // per CSS 2.1 reference test abspos-non-replaced-width-margin-000. |
4035 if (containerDirection == TextDirection::Ltr) { | 4035 if (containerDirection == TextDirection::kLtr) { |
4036 marginLogicalLeftValue = LayoutUnit(); | 4036 marginLogicalLeftValue = LayoutUnit(); |
4037 marginLogicalRightValue = availableSpace; // will be negative | 4037 marginLogicalRightValue = availableSpace; // will be negative |
4038 } else { | 4038 } else { |
4039 marginLogicalLeftValue = availableSpace; // will be negative | 4039 marginLogicalLeftValue = availableSpace; // will be negative |
4040 marginLogicalRightValue = LayoutUnit(); | 4040 marginLogicalRightValue = LayoutUnit(); |
4041 } | 4041 } |
4042 } | 4042 } |
4043 } else if (marginLogicalLeft.isAuto()) { | 4043 } else if (marginLogicalLeft.isAuto()) { |
4044 // Solve for left margin | 4044 // Solve for left margin |
4045 marginLogicalRightValue = | 4045 marginLogicalRightValue = |
4046 valueForLength(marginLogicalRight, containerRelativeLogicalWidth); | 4046 valueForLength(marginLogicalRight, containerRelativeLogicalWidth); |
4047 marginLogicalLeftValue = availableSpace - marginLogicalRightValue; | 4047 marginLogicalLeftValue = availableSpace - marginLogicalRightValue; |
4048 } else if (marginLogicalRight.isAuto()) { | 4048 } else if (marginLogicalRight.isAuto()) { |
4049 // Solve for right margin | 4049 // Solve for right margin |
4050 marginLogicalLeftValue = | 4050 marginLogicalLeftValue = |
4051 valueForLength(marginLogicalLeft, containerRelativeLogicalWidth); | 4051 valueForLength(marginLogicalLeft, containerRelativeLogicalWidth); |
4052 marginLogicalRightValue = availableSpace - marginLogicalLeftValue; | 4052 marginLogicalRightValue = availableSpace - marginLogicalLeftValue; |
4053 } else { | 4053 } else { |
4054 // Over-constrained, solve for left if direction is RTL | 4054 // Over-constrained, solve for left if direction is RTL |
4055 marginLogicalLeftValue = | 4055 marginLogicalLeftValue = |
4056 valueForLength(marginLogicalLeft, containerRelativeLogicalWidth); | 4056 valueForLength(marginLogicalLeft, containerRelativeLogicalWidth); |
4057 marginLogicalRightValue = | 4057 marginLogicalRightValue = |
4058 valueForLength(marginLogicalRight, containerRelativeLogicalWidth); | 4058 valueForLength(marginLogicalRight, containerRelativeLogicalWidth); |
4059 | 4059 |
4060 // Use the containing block's direction rather than the parent block's | 4060 // Use the containing block's direction rather than the parent block's |
4061 // per CSS 2.1 reference test abspos-non-replaced-width-margin-000. | 4061 // per CSS 2.1 reference test abspos-non-replaced-width-margin-000. |
4062 if (containerDirection == TextDirection::Rtl) | 4062 if (containerDirection == TextDirection::kRtl) |
4063 logicalLeftValue = (availableSpace + logicalLeftValue) - | 4063 logicalLeftValue = (availableSpace + logicalLeftValue) - |
4064 marginLogicalLeftValue - marginLogicalRightValue; | 4064 marginLogicalLeftValue - marginLogicalRightValue; |
4065 } | 4065 } |
4066 } else { | 4066 } else { |
4067 // ------------------------------------------------------------------------- | 4067 // ------------------------------------------------------------------------- |
4068 // Otherwise, set 'auto' values for 'margin-left' and 'margin-right' | 4068 // Otherwise, set 'auto' values for 'margin-left' and 'margin-right' |
4069 // to 0, and pick the one of the following six rules that applies. | 4069 // to 0, and pick the one of the following six rules that applies. |
4070 // | 4070 // |
4071 // 1. 'left' and 'width' are 'auto' and 'right' is not 'auto', then the | 4071 // 1. 'left' and 'width' are 'auto' and 'right' is not 'auto', then the |
4072 // width is shrink-to-fit. Then solve for 'left' | 4072 // width is shrink-to-fit. Then solve for 'left' |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4615 LayoutUnit minDist = LayoutUnit::max(); | 4615 LayoutUnit minDist = LayoutUnit::max(); |
4616 LayoutBox* closestLayoutObject = nullptr; | 4616 LayoutBox* closestLayoutObject = nullptr; |
4617 LayoutPoint adjustedPoint = point; | 4617 LayoutPoint adjustedPoint = point; |
4618 if (isTableRow()) | 4618 if (isTableRow()) |
4619 adjustedPoint.moveBy(location()); | 4619 adjustedPoint.moveBy(location()); |
4620 | 4620 |
4621 for (LayoutObject* layoutObject = firstChild; layoutObject; | 4621 for (LayoutObject* layoutObject = firstChild; layoutObject; |
4622 layoutObject = layoutObject->nextSibling()) { | 4622 layoutObject = layoutObject->nextSibling()) { |
4623 if ((!layoutObject->slowFirstChild() && !layoutObject->isInline() && | 4623 if ((!layoutObject->slowFirstChild() && !layoutObject->isInline() && |
4624 !layoutObject->isLayoutBlockFlow()) || | 4624 !layoutObject->isLayoutBlockFlow()) || |
4625 layoutObject->style()->visibility() != EVisibility::Visible) | 4625 layoutObject->style()->visibility() != EVisibility::kVisible) |
4626 continue; | 4626 continue; |
4627 | 4627 |
4628 if (!layoutObject->isBox()) | 4628 if (!layoutObject->isBox()) |
4629 continue; | 4629 continue; |
4630 | 4630 |
4631 LayoutBox* layoutBox = toLayoutBox(layoutObject); | 4631 LayoutBox* layoutBox = toLayoutBox(layoutObject); |
4632 | 4632 |
4633 LayoutUnit top = layoutBox->borderTop() + layoutBox->paddingTop() + | 4633 LayoutUnit top = layoutBox->borderTop() + layoutBox->paddingTop() + |
4634 (isTableRow() ? LayoutUnit() : layoutBox->location().y()); | 4634 (isTableRow() ? LayoutUnit() : layoutBox->location().y()); |
4635 LayoutUnit bottom = top + layoutBox->contentHeight(); | 4635 LayoutUnit bottom = top + layoutBox->contentHeight(); |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5696 block->adjustChildDebugRect(rect); | 5696 block->adjustChildDebugRect(rect); |
5697 | 5697 |
5698 return rect; | 5698 return rect; |
5699 } | 5699 } |
5700 | 5700 |
5701 bool LayoutBox::shouldClipOverflow() const { | 5701 bool LayoutBox::shouldClipOverflow() const { |
5702 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip(); | 5702 return hasOverflowClip() || styleRef().containsPaint() || hasControlClip(); |
5703 } | 5703 } |
5704 | 5704 |
5705 } // namespace blink | 5705 } // namespace blink |
OLD | NEW |