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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 | 65 |
66 using namespace HTMLNames; | 66 using namespace HTMLNames; |
67 | 67 |
68 // Used by flexible boxes when flexing this element and by table cells. | 68 // Used by flexible boxes when flexing this element and by table cells. |
69 typedef WTF::HashMap<const RenderBox*, LayoutUnit> OverrideSizeMap; | 69 typedef WTF::HashMap<const RenderBox*, LayoutUnit> OverrideSizeMap; |
70 | 70 |
71 // Used by grid elements to properly size their grid items. | 71 // Used by grid elements to properly size their grid items. |
72 // FIXME: Move these into RenderBoxRareData. | 72 // FIXME: Move these into RenderBoxRareData. |
73 static OverrideSizeMap* gOverrideContainingBlockLogicalHeightMap = 0; | 73 static OverrideSizeMap* gOverrideContainingBlockLogicalHeightMap = 0; |
74 static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = 0; | 74 static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = 0; |
75 static OverrideSizeMap* gOverrideInlineOffsetMap = 0; | |
76 static OverrideSizeMap* gOverrideBlockOffsetMap = 0; | |
75 | 77 |
76 | 78 |
77 // Size of border belt for autoscroll. When mouse pointer in border belt, | 79 // Size of border belt for autoscroll. When mouse pointer in border belt, |
78 // autoscroll is started. | 80 // autoscroll is started. |
79 static const int autoscrollBeltSize = 20; | 81 static const int autoscrollBeltSize = 20; |
80 static const unsigned backgroundObscurationTestMaxDepth = 4; | 82 static const unsigned backgroundObscurationTestMaxDepth = 4; |
81 | 83 |
82 static bool skipBodyBackground(const RenderBox* bodyElementRenderer) | 84 static bool skipBodyBackground(const RenderBox* bodyElementRenderer) |
83 { | 85 { |
84 ASSERT(bodyElementRenderer->isBody()); | 86 ASSERT(bodyElementRenderer->isBody()); |
(...skipping 11 matching lines...) Expand all Loading... | |
96 , m_minPreferredLogicalWidth(-1) | 98 , m_minPreferredLogicalWidth(-1) |
97 , m_maxPreferredLogicalWidth(-1) | 99 , m_maxPreferredLogicalWidth(-1) |
98 { | 100 { |
99 setIsBox(); | 101 setIsBox(); |
100 } | 102 } |
101 | 103 |
102 void RenderBox::willBeDestroyed() | 104 void RenderBox::willBeDestroyed() |
103 { | 105 { |
104 clearOverrideSize(); | 106 clearOverrideSize(); |
105 clearContainingBlockOverrideSize(); | 107 clearContainingBlockOverrideSize(); |
108 clearOverrideInlineAndBlockOffests(); | |
106 | 109 |
107 RenderBlock::removePercentHeightDescendantIfNeeded(this); | 110 RenderBlock::removePercentHeightDescendantIfNeeded(this); |
108 | 111 |
109 ShapeOutsideInfo::removeInfo(*this); | 112 ShapeOutsideInfo::removeInfo(*this); |
110 | 113 |
111 RenderBoxModelObject::willBeDestroyed(); | 114 RenderBoxModelObject::willBeDestroyed(); |
112 } | 115 } |
113 | 116 |
114 void RenderBox::removeFloatingOrPositionedChildFromBlockLists() | 117 void RenderBox::removeFloatingOrPositionedChildFromBlockLists() |
115 { | 118 { |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1004 gOverrideContainingBlockLogicalWidthMap->remove(this); | 1007 gOverrideContainingBlockLogicalWidthMap->remove(this); |
1005 clearOverrideContainingBlockContentLogicalHeight(); | 1008 clearOverrideContainingBlockContentLogicalHeight(); |
1006 } | 1009 } |
1007 | 1010 |
1008 void RenderBox::clearOverrideContainingBlockContentLogicalHeight() | 1011 void RenderBox::clearOverrideContainingBlockContentLogicalHeight() |
1009 { | 1012 { |
1010 if (gOverrideContainingBlockLogicalHeightMap) | 1013 if (gOverrideContainingBlockLogicalHeightMap) |
1011 gOverrideContainingBlockLogicalHeightMap->remove(this); | 1014 gOverrideContainingBlockLogicalHeightMap->remove(this); |
1012 } | 1015 } |
1013 | 1016 |
1017 LayoutUnit RenderBox::overrideInlineOffset() const | |
1018 { | |
1019 ASSERT(hasOverrideInlineOffset()); | |
1020 return gOverrideInlineOffsetMap->get(this); | |
1021 } | |
1022 | |
1023 LayoutUnit RenderBox::overrideBlockOffset() const | |
1024 { | |
1025 ASSERT(hasOverrideBlockOffset()); | |
1026 return gOverrideBlockOffsetMap->get(this); | |
1027 } | |
1028 | |
1029 bool RenderBox::hasOverrideInlineOffset() const | |
1030 { | |
1031 return gOverrideInlineOffsetMap && gOverrideInlineOffsetMap->contains(this); | |
1032 } | |
1033 | |
1034 bool RenderBox::hasOverrideBlockOffset() const | |
1035 { | |
1036 return gOverrideBlockOffsetMap && gOverrideBlockOffsetMap->contains(this); | |
1037 } | |
1038 | |
1039 void RenderBox::setOverrideInlineOffset(LayoutUnit inlineOffest) | |
1040 { | |
1041 if (!gOverrideInlineOffsetMap) | |
1042 gOverrideInlineOffsetMap = new OverrideSizeMap; | |
1043 gOverrideInlineOffsetMap->set(this, inlineOffest); | |
1044 } | |
1045 | |
1046 void RenderBox::setOverrideBlockOffset(LayoutUnit blockOffest) | |
1047 { | |
1048 if (!gOverrideBlockOffsetMap) | |
1049 gOverrideBlockOffsetMap = new OverrideSizeMap; | |
1050 gOverrideBlockOffsetMap->set(this, blockOffest); | |
1051 } | |
1052 | |
1053 void RenderBox::clearOverrideInlineAndBlockOffests() | |
1054 { | |
1055 if (gOverrideInlineOffsetMap) | |
1056 gOverrideInlineOffsetMap->remove(this); | |
1057 if (gOverrideBlockOffsetMap) | |
1058 gOverrideBlockOffsetMap->remove(this); | |
1059 } | |
1060 | |
1014 LayoutUnit RenderBox::adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width) const | 1061 LayoutUnit RenderBox::adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width) const |
1015 { | 1062 { |
1016 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); | 1063 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); |
1017 if (style()->boxSizing() == CONTENT_BOX) | 1064 if (style()->boxSizing() == CONTENT_BOX) |
1018 return width + bordersPlusPadding; | 1065 return width + bordersPlusPadding; |
1019 return std::max(width, bordersPlusPadding); | 1066 return std::max(width, bordersPlusPadding); |
1020 } | 1067 } |
1021 | 1068 |
1022 LayoutUnit RenderBox::adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height ) const | 1069 LayoutUnit RenderBox::adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height ) const |
1023 { | 1070 { |
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2610 | 2657 |
2611 // Use viewport as container for top-level fixed-position elements. | 2658 // Use viewport as container for top-level fixed-position elements. |
2612 if (style()->position() == FixedPosition && containingBlock->isRenderView()) { | 2659 if (style()->position() == FixedPosition && containingBlock->isRenderView()) { |
2613 const RenderView* view = toRenderView(containingBlock); | 2660 const RenderView* view = toRenderView(containingBlock); |
2614 if (FrameView* frameView = view->frameView()) { | 2661 if (FrameView* frameView = view->frameView()) { |
2615 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte ntRect(); | 2662 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte ntRect(); |
2616 return containingBlock->isHorizontalWritingMode() ? viewportRect.wid th() : viewportRect.height(); | 2663 return containingBlock->isHorizontalWritingMode() ? viewportRect.wid th() : viewportRect.height(); |
2617 } | 2664 } |
2618 } | 2665 } |
2619 | 2666 |
2667 if (hasOverrideContainingBlockLogicalWidth()) | |
2668 return overrideContainingBlockContentLogicalWidth(); | |
2669 | |
2620 if (containingBlock->isBox()) | 2670 if (containingBlock->isBox()) |
2621 return toRenderBox(containingBlock)->clientLogicalWidth(); | 2671 return toRenderBox(containingBlock)->clientLogicalWidth(); |
2622 | 2672 |
2623 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); | 2673 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); |
2624 | 2674 |
2625 const RenderInline* flow = toRenderInline(containingBlock); | 2675 const RenderInline* flow = toRenderInline(containingBlock); |
2626 InlineFlowBox* first = flow->firstLineBox(); | 2676 InlineFlowBox* first = flow->firstLineBox(); |
2627 InlineFlowBox* last = flow->lastLineBox(); | 2677 InlineFlowBox* last = flow->lastLineBox(); |
2628 | 2678 |
2629 // If the containing block is empty, return a width of 0. | 2679 // If the containing block is empty, return a width of 0. |
(...skipping 20 matching lines...) Expand all Loading... | |
2650 | 2700 |
2651 // Use viewport as container for top-level fixed-position elements. | 2701 // Use viewport as container for top-level fixed-position elements. |
2652 if (style()->position() == FixedPosition && containingBlock->isRenderView()) { | 2702 if (style()->position() == FixedPosition && containingBlock->isRenderView()) { |
2653 const RenderView* view = toRenderView(containingBlock); | 2703 const RenderView* view = toRenderView(containingBlock); |
2654 if (FrameView* frameView = view->frameView()) { | 2704 if (FrameView* frameView = view->frameView()) { |
2655 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte ntRect(); | 2705 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte ntRect(); |
2656 return containingBlock->isHorizontalWritingMode() ? viewportRect.hei ght() : viewportRect.width(); | 2706 return containingBlock->isHorizontalWritingMode() ? viewportRect.hei ght() : viewportRect.width(); |
2657 } | 2707 } |
2658 } | 2708 } |
2659 | 2709 |
2710 if (hasOverrideContainingBlockLogicalHeight()) | |
2711 return overrideContainingBlockContentLogicalHeight(); | |
2712 | |
2660 if (containingBlock->isBox()) { | 2713 if (containingBlock->isBox()) { |
2661 const RenderBlock* cb = containingBlock->isRenderBlock() ? | 2714 const RenderBlock* cb = containingBlock->isRenderBlock() ? |
2662 toRenderBlock(containingBlock) : containingBlock->containingBlock(); | 2715 toRenderBlock(containingBlock) : containingBlock->containingBlock(); |
2663 return cb->clientLogicalHeight(); | 2716 return cb->clientLogicalHeight(); |
2664 } | 2717 } |
2665 | 2718 |
2666 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); | 2719 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned ()); |
2667 | 2720 |
2668 const RenderInline* flow = toRenderInline(containingBlock); | 2721 const RenderInline* flow = toRenderInline(containingBlock); |
2669 InlineFlowBox* first = flow->firstLineBox(); | 2722 InlineFlowBox* first = flow->firstLineBox(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2836 minValues); | 2889 minValues); |
2837 | 2890 |
2838 if (computedValues.m_extent < minValues.m_extent) { | 2891 if (computedValues.m_extent < minValues.m_extent) { |
2839 computedValues.m_extent = minValues.m_extent; | 2892 computedValues.m_extent = minValues.m_extent; |
2840 computedValues.m_position = minValues.m_position; | 2893 computedValues.m_position = minValues.m_position; |
2841 computedValues.m_margins.m_start = minValues.m_margins.m_start; | 2894 computedValues.m_margins.m_start = minValues.m_margins.m_start; |
2842 computedValues.m_margins.m_end = minValues.m_margins.m_end; | 2895 computedValues.m_margins.m_end = minValues.m_margins.m_end; |
2843 } | 2896 } |
2844 } | 2897 } |
2845 | 2898 |
2899 if (hasOverrideInlineOffset() && !style()->hasStaticInlinePosition(isHorizon tal)) | |
Julien - ping for review
2014/12/02 20:46:05
This adds one hash lookup for every layout with po
Manuel Rego
2014/12/03 09:48:58
Nice catch. We can even minimize this more if we c
| |
2900 computedValues.m_position += overrideInlineOffset(); | |
2901 | |
2846 computedValues.m_extent += bordersPlusPadding; | 2902 computedValues.m_extent += bordersPlusPadding; |
2847 } | 2903 } |
2848 | 2904 |
2849 static void computeLogicalLeftPositionedOffset(LayoutUnit& logicalLeftPos, const RenderBox* child, LayoutUnit logicalWidthValue, const RenderBoxModelObject* con tainerBlock, LayoutUnit containerLogicalWidth) | 2905 static void computeLogicalLeftPositionedOffset(LayoutUnit& logicalLeftPos, const RenderBox* child, LayoutUnit logicalWidthValue, const RenderBoxModelObject* con tainerBlock, LayoutUnit containerLogicalWidth) |
2850 { | 2906 { |
2851 // Deal with differing writing modes here. Our offset needs to be in the co ntaining block's coordinate space. If the containing block is flipped | 2907 // Deal with differing writing modes here. Our offset needs to be in the co ntaining block's coordinate space. If the containing block is flipped |
2852 // along this axis, then we need to flip the coordinate. This can only happ en if the containing block is both a flipped mode and perpendicular to us. | 2908 // along this axis, then we need to flip the coordinate. This can only happ en if the containing block is both a flipped mode and perpendicular to us. |
2853 if (containerBlock->isHorizontalWritingMode() != child->isHorizontalWritingM ode() && containerBlock->style()->slowIsFlippedBlocksWritingMode()) { | 2909 if (containerBlock->isHorizontalWritingMode() != child->isHorizontalWritingM ode() && containerBlock->style()->slowIsFlippedBlocksWritingMode()) { |
2854 logicalLeftPos = containerLogicalWidth - logicalWidthValue - logicalLeft Pos; | 2910 logicalLeftPos = containerLogicalWidth - logicalWidthValue - logicalLeft Pos; |
2855 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo rderRight() : containerBlock->borderBottom()); | 2911 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo rderRight() : containerBlock->borderBottom()); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3146 minValues); | 3202 minValues); |
3147 | 3203 |
3148 if (computedValues.m_extent < minValues.m_extent) { | 3204 if (computedValues.m_extent < minValues.m_extent) { |
3149 computedValues.m_extent = minValues.m_extent; | 3205 computedValues.m_extent = minValues.m_extent; |
3150 computedValues.m_position = minValues.m_position; | 3206 computedValues.m_position = minValues.m_position; |
3151 computedValues.m_margins.m_before = minValues.m_margins.m_before; | 3207 computedValues.m_margins.m_before = minValues.m_margins.m_before; |
3152 computedValues.m_margins.m_after = minValues.m_margins.m_after; | 3208 computedValues.m_margins.m_after = minValues.m_margins.m_after; |
3153 } | 3209 } |
3154 } | 3210 } |
3155 | 3211 |
3212 if (hasOverrideBlockOffset() && !style()->hasStaticBlockPosition(isHorizonta lWritingMode())) | |
3213 computedValues.m_position += overrideBlockOffset(); | |
3214 | |
3156 // Set final height value. | 3215 // Set final height value. |
3157 computedValues.m_extent += bordersPlusPadding; | 3216 computedValues.m_extent += bordersPlusPadding; |
3158 } | 3217 } |
3159 | 3218 |
3160 static void computeLogicalTopPositionedOffset(LayoutUnit& logicalTopPos, const R enderBox* child, LayoutUnit logicalHeightValue, const RenderBoxModelObject* cont ainerBlock, LayoutUnit containerLogicalHeight) | 3219 static void computeLogicalTopPositionedOffset(LayoutUnit& logicalTopPos, const R enderBox* child, LayoutUnit logicalHeightValue, const RenderBoxModelObject* cont ainerBlock, LayoutUnit containerLogicalHeight) |
3161 { | 3220 { |
3162 // Deal with differing writing modes here. Our offset needs to be in the co ntaining block's coordinate space. If the containing block is flipped | 3221 // Deal with differing writing modes here. Our offset needs to be in the co ntaining block's coordinate space. If the containing block is flipped |
3163 // along this axis, then we need to flip the coordinate. This can only happ en if the containing block is both a flipped mode and perpendicular to us. | 3222 // along this axis, then we need to flip the coordinate. This can only happ en if the containing block is both a flipped mode and perpendicular to us. |
3164 if ((child->style()->slowIsFlippedBlocksWritingMode() && child->isHorizontal WritingMode() != containerBlock->isHorizontalWritingMode()) | 3223 if ((child->style()->slowIsFlippedBlocksWritingMode() && child->isHorizontal WritingMode() != containerBlock->isHorizontalWritingMode()) |
3165 || (child->style()->slowIsFlippedBlocksWritingMode() != containerBlock-> style()->slowIsFlippedBlocksWritingMode() && child->isHorizontalWritingMode() == containerBlock->isHorizontalWritingMode())) | 3224 || (child->style()->slowIsFlippedBlocksWritingMode() != containerBlock-> style()->slowIsFlippedBlocksWritingMode() && child->isHorizontalWritingMode() == containerBlock->isHorizontalWritingMode())) |
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4439 | 4498 |
4440 setLogicalTop(oldLogicalTop); | 4499 setLogicalTop(oldLogicalTop); |
4441 setLogicalWidth(oldLogicalWidth); | 4500 setLogicalWidth(oldLogicalWidth); |
4442 setMarginLeft(oldMarginLeft); | 4501 setMarginLeft(oldMarginLeft); |
4443 setMarginRight(oldMarginRight); | 4502 setMarginRight(oldMarginRight); |
4444 | 4503 |
4445 return borderBox; | 4504 return borderBox; |
4446 } | 4505 } |
4447 | 4506 |
4448 } // namespace blink | 4507 } // namespace blink |
OLD | NEW |