| 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 Apple Inc. All rights reserved. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2010 Google Inc. All rights reserved. | 7 * Copyright (C) 2010 Google Inc. 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 LayoutSize offset = accumulateInFlowPositionOffsets(); | 738 LayoutSize offset = accumulateInFlowPositionOffsets(); |
| 739 | 739 |
| 740 LayoutBlock* containingBlock = this->containingBlock(); | 740 LayoutBlock* containingBlock = this->containingBlock(); |
| 741 | 741 |
| 742 // Objects that shrink to avoid floats normally use available line width when | 742 // Objects that shrink to avoid floats normally use available line width when |
| 743 // computing containing block width. However in the case of relative | 743 // computing containing block width. However in the case of relative |
| 744 // positioning using percentages, we can't do this. The offset should always | 744 // positioning using percentages, we can't do this. The offset should always |
| 745 // be resolved using the available width of the containing block. Therefore we | 745 // be resolved using the available width of the containing block. Therefore we |
| 746 // don't use containingBlockLogicalWidthForContent() here, but instead | 746 // don't use containingBlockLogicalWidthForContent() here, but instead |
| 747 // explicitly call availableWidth on our containing block. | 747 // explicitly call availableWidth on our containing block. |
| 748 if (!style()->left().isAuto()) { | 748 // https://drafts.csswg.org/css-position-3/#rel-pos |
| 749 if (!style()->right().isAuto() && | 749 Optional<LayoutUnit> left; |
| 750 !containingBlock->style()->isLeftToRightDirection()) | 750 Optional<LayoutUnit> right; |
| 751 offset.setWidth( | 751 if (!style()->left().isAuto()) |
| 752 -valueForLength(style()->right(), containingBlock->availableWidth())); | 752 left = valueForLength(style()->left(), containingBlock->availableWidth()); |
| 753 else | 753 if (!style()->right().isAuto()) |
| 754 offset.expand( | 754 right = valueForLength(style()->right(), containingBlock->availableWidth()); |
| 755 valueForLength(style()->left(), containingBlock->availableWidth()), | 755 if (!left && !right) { |
| 756 LayoutUnit()); | 756 left = LayoutUnit(); |
| 757 } else if (!style()->right().isAuto()) { | 757 right = LayoutUnit(); |
| 758 offset.expand( | 758 } |
| 759 -valueForLength(style()->right(), containingBlock->availableWidth()), | 759 if (!left) |
| 760 LayoutUnit()); | 760 left = -right.value(); |
| 761 if (!right) |
| 762 right = -left.value(); |
| 763 bool isLtr = containingBlock->style()->isLeftToRightDirection(); |
| 764 WritingMode writingMode = containingBlock->style()->getWritingMode(); |
| 765 switch (writingMode) { |
| 766 case WritingMode::kHorizontalTb: |
| 767 if (isLtr) |
| 768 offset.expand(left.value(), LayoutUnit()); |
| 769 else |
| 770 offset.setWidth(-right.value()); |
| 771 break; |
| 772 case WritingMode::kVerticalRl: |
| 773 offset.setWidth(-right.value()); |
| 774 break; |
| 775 case WritingMode::kVerticalLr: |
| 776 offset.expand(left.value(), LayoutUnit()); |
| 777 break; |
| 761 } | 778 } |
| 762 | 779 |
| 763 // If the containing block of a relatively positioned element does not specify | 780 // If the containing block of a relatively positioned element does not specify |
| 764 // a height, a percentage top or bottom offset should be resolved as auto. | 781 // a height, a percentage top or bottom offset should be resolved as auto. |
| 765 // An exception to this is if the containing block has the WinIE quirk where | 782 // An exception to this is if the containing block has the WinIE quirk where |
| 766 // <html> and <body> assume the size of the viewport. In this case, calculate | 783 // <html> and <body> assume the size of the viewport. In this case, calculate |
| 767 // the percent offset based on this height. | 784 // the percent offset based on this height. |
| 768 // See <https://bugs.webkit.org/show_bug.cgi?id=26396>. | 785 // See <https://bugs.webkit.org/show_bug.cgi?id=26396>. |
| 786 |
| 787 Optional<LayoutUnit> top; |
| 788 Optional<LayoutUnit> bottom; |
| 769 if (!style()->top().isAuto() && | 789 if (!style()->top().isAuto() && |
| 770 (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() || | 790 (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() || |
| 771 !style()->top().isPercentOrCalc() || | 791 !style()->top().isPercentOrCalc() || |
| 772 containingBlock->stretchesToViewport())) | 792 containingBlock->stretchesToViewport())) { |
| 773 offset.expand( | 793 top = valueForLength(style()->top(), containingBlock->availableHeight()); |
| 774 LayoutUnit(), | 794 } |
| 775 valueForLength(style()->top(), containingBlock->availableHeight())); | 795 if (!style()->bottom().isAuto() && |
| 776 | 796 (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() || |
| 777 else if (!style()->bottom().isAuto() && | 797 !style()->bottom().isPercentOrCalc() || |
| 778 (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() || | 798 containingBlock->stretchesToViewport())) { |
| 779 !style()->bottom().isPercentOrCalc() || | 799 bottom = |
| 780 containingBlock->stretchesToViewport())) | 800 valueForLength(style()->bottom(), containingBlock->availableHeight()); |
| 781 offset.expand( | 801 } |
| 782 LayoutUnit(), | 802 if (!top && !bottom) { |
| 783 -valueForLength(style()->bottom(), containingBlock->availableHeight())); | 803 top = LayoutUnit(); |
| 784 | 804 bottom = LayoutUnit(); |
| 805 } |
| 806 if (!top) |
| 807 top = -bottom.value(); |
| 808 if (!bottom) |
| 809 bottom = -top.value(); |
| 810 switch (writingMode) { |
| 811 case WritingMode::kHorizontalTb: |
| 812 offset.expand(LayoutUnit(), top.value()); |
| 813 break; |
| 814 case WritingMode::kVerticalRl: |
| 815 if (isLtr) |
| 816 offset.expand(LayoutUnit(), top.value()); |
| 817 else |
| 818 offset.setHeight(-bottom.value()); |
| 819 break; |
| 820 case WritingMode::kVerticalLr: |
| 821 if (isLtr) |
| 822 offset.expand(LayoutUnit(), top.value()); |
| 823 else |
| 824 offset.setHeight(-bottom.value()); |
| 825 break; |
| 826 } |
| 785 return offset; | 827 return offset; |
| 786 } | 828 } |
| 787 | 829 |
| 788 void LayoutBoxModelObject::updateStickyPositionConstraints() const { | 830 void LayoutBoxModelObject::updateStickyPositionConstraints() const { |
| 789 const FloatSize constrainingSize = computeStickyConstrainingRect().size(); | 831 const FloatSize constrainingSize = computeStickyConstrainingRect().size(); |
| 790 | 832 |
| 791 PaintLayerScrollableArea* scrollableArea = | 833 PaintLayerScrollableArea* scrollableArea = |
| 792 layer()->ancestorOverflowLayer()->getScrollableArea(); | 834 layer()->ancestorOverflowLayer()->getScrollableArea(); |
| 793 StickyPositionScrollingConstraints constraints; | 835 StickyPositionScrollingConstraints constraints; |
| 794 FloatSize skippedContainersOffset; | 836 FloatSize skippedContainersOffset; |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 if (rootElementStyle->hasBackground()) | 1410 if (rootElementStyle->hasBackground()) |
| 1369 return false; | 1411 return false; |
| 1370 | 1412 |
| 1371 if (node() != document().firstBodyElement()) | 1413 if (node() != document().firstBodyElement()) |
| 1372 return false; | 1414 return false; |
| 1373 | 1415 |
| 1374 return true; | 1416 return true; |
| 1375 } | 1417 } |
| 1376 | 1418 |
| 1377 } // namespace blink | 1419 } // namespace blink |
| OLD | NEW |