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) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 static TrackedDescendantsMap* gPositionedDescendantsMap = nullptr; | 101 static TrackedDescendantsMap* gPositionedDescendantsMap = nullptr; |
102 | 102 |
103 // This map keeps track of the descendants whose 'height' is percentage associat ed | 103 // This map keeps track of the descendants whose 'height' is percentage associat ed |
104 // with a containing block. Like |gPositionedDescendantsMap|, it is also recompu ted | 104 // with a containing block. Like |gPositionedDescendantsMap|, it is also recompu ted |
105 // for every layout (see the comment above about why). | 105 // for every layout (see the comment above about why). |
106 static TrackedDescendantsMap* gPercentHeightDescendantsMap = nullptr; | 106 static TrackedDescendantsMap* gPercentHeightDescendantsMap = nullptr; |
107 | 107 |
108 static TrackedContainerMap* gPositionedContainerMap = nullptr; | 108 static TrackedContainerMap* gPositionedContainerMap = nullptr; |
109 static TrackedContainerMap* gPercentHeightContainerMap = nullptr; | 109 static TrackedContainerMap* gPercentHeightContainerMap = nullptr; |
110 | 110 |
111 typedef WTF::HashSet<LayoutBlock*> DelayedUpdateScrollInfoSet; | 111 struct ScrollInfo { |
112 DoubleSize scrollOffset; | |
113 bool autoHorizontalScrollBarChanged; | |
114 bool autoVerticalScrollBarChanged; | |
115 bool hasOffset() const { return scrollOffset != DoubleSize(); } | |
116 bool scrollBarsChanged() const { return autoHorizontalScrollBarChanged || au toVerticalScrollBarChanged; } | |
117 void merge(const ScrollInfo& other) | |
118 { | |
119 // We always keep the first scrollOffset we saw for this block, so don't copy that field. | |
120 autoHorizontalScrollBarChanged |= other.autoHorizontalScrollBarChanged; | |
121 autoVerticalScrollBarChanged |= other.autoVerticalScrollBarChanged; | |
122 } | |
123 }; | |
124 typedef WTF::HashMap<LayoutBlock*, ScrollInfo> DelayedUpdateScrollInfoMap; | |
112 static int gDelayUpdateScrollInfo = 0; | 125 static int gDelayUpdateScrollInfo = 0; |
113 static DelayedUpdateScrollInfoSet* gDelayedUpdateScrollInfoSet = nullptr; | 126 static DelayedUpdateScrollInfoMap* gDelayedUpdateScrollInfoMap = nullptr; |
114 | 127 |
115 LayoutBlock::LayoutBlock(ContainerNode* node) | 128 LayoutBlock::LayoutBlock(ContainerNode* node) |
116 : LayoutBox(node) | 129 : LayoutBox(node) |
117 , m_hasMarginBeforeQuirk(false) | 130 , m_hasMarginBeforeQuirk(false) |
118 , m_hasMarginAfterQuirk(false) | 131 , m_hasMarginAfterQuirk(false) |
119 , m_beingDestroyed(false) | 132 , m_beingDestroyed(false) |
120 , m_hasMarkupTruncation(false) | 133 , m_hasMarkupTruncation(false) |
121 , m_widthAvailableToChildrenChanged(false) | 134 , m_widthAvailableToChildrenChanged(false) |
122 , m_hasOnlySelfCollapsingChildren(false) | 135 , m_hasOnlySelfCollapsingChildren(false) |
123 , m_descendantsWithFloatsMarkedForLayout(false) | 136 , m_descendantsWithFloatsMarkedForLayout(false) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 childBox->remove(); | 238 childBox->remove(); |
226 } | 239 } |
227 } | 240 } |
228 } else if (parent()) { | 241 } else if (parent()) { |
229 parent()->dirtyLinesFromChangedChild(this); | 242 parent()->dirtyLinesFromChangedChild(this); |
230 } | 243 } |
231 } | 244 } |
232 | 245 |
233 m_lineBoxes.deleteLineBoxes(); | 246 m_lineBoxes.deleteLineBoxes(); |
234 | 247 |
235 if (UNLIKELY(gDelayedUpdateScrollInfoSet != 0)) | 248 if (UNLIKELY(gDelayedUpdateScrollInfoMap != 0)) |
236 gDelayedUpdateScrollInfoSet->remove(this); | 249 gDelayedUpdateScrollInfoMap->remove(this); |
237 | 250 |
238 if (TextAutosizer* textAutosizer = document().textAutosizer()) | 251 if (TextAutosizer* textAutosizer = document().textAutosizer()) |
239 textAutosizer->destroy(this); | 252 textAutosizer->destroy(this); |
240 | 253 |
241 LayoutBox::willBeDestroyed(); | 254 LayoutBox::willBeDestroyed(); |
242 } | 255 } |
243 | 256 |
244 void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new Style) | 257 void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new Style) |
245 { | 258 { |
246 const ComputedStyle* oldStyle = style(); | 259 const ComputedStyle* oldStyle = style(); |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 return false; | 834 return false; |
822 } | 835 } |
823 return true; | 836 return true; |
824 } | 837 } |
825 return false; | 838 return false; |
826 } | 839 } |
827 | 840 |
828 void LayoutBlock::startDelayUpdateScrollInfo() | 841 void LayoutBlock::startDelayUpdateScrollInfo() |
829 { | 842 { |
830 if (gDelayUpdateScrollInfo == 0) { | 843 if (gDelayUpdateScrollInfo == 0) { |
831 ASSERT(!gDelayedUpdateScrollInfoSet); | 844 ASSERT(!gDelayedUpdateScrollInfoMap); |
832 gDelayedUpdateScrollInfoSet = new DelayedUpdateScrollInfoSet; | 845 gDelayedUpdateScrollInfoMap = new DelayedUpdateScrollInfoMap; |
833 } | 846 } |
834 ASSERT(gDelayedUpdateScrollInfoSet); | 847 ASSERT(gDelayedUpdateScrollInfoMap); |
835 ++gDelayUpdateScrollInfo; | 848 ++gDelayUpdateScrollInfo; |
836 } | 849 } |
837 | 850 |
838 void LayoutBlock::finishDelayUpdateScrollInfo() | 851 void LayoutBlock::finishDelayUpdateScrollInfo() |
839 { | 852 { |
840 --gDelayUpdateScrollInfo; | 853 --gDelayUpdateScrollInfo; |
841 ASSERT(gDelayUpdateScrollInfo >= 0); | 854 ASSERT(gDelayUpdateScrollInfo >= 0); |
842 if (gDelayUpdateScrollInfo == 0) { | 855 if (gDelayUpdateScrollInfo == 0) { |
843 ASSERT(gDelayedUpdateScrollInfoSet); | 856 ASSERT(gDelayedUpdateScrollInfoMap); |
844 | 857 |
845 OwnPtr<DelayedUpdateScrollInfoSet> infoSet(adoptPtr(gDelayedUpdateScroll InfoSet)); | 858 OwnPtr<DelayedUpdateScrollInfoMap> infoMap(adoptPtr(gDelayedUpdateScroll InfoMap)); |
846 gDelayedUpdateScrollInfoSet = nullptr; | 859 gDelayedUpdateScrollInfoMap = nullptr; |
847 | 860 |
848 for (auto* block : *infoSet) { | 861 for (auto block : *infoMap) { |
849 if (block->hasOverflowClip()) { | 862 if (block.key->hasOverflowClip()) { |
850 block->layer()->scrollableArea()->updateAfterLayout(); | 863 DeprecatedPaintLayerScrollableArea* scrollableArea = block.key-> layer()->scrollableArea(); |
864 ScrollInfo& scrollInfo = block.value; | |
865 scrollableArea->finalizeScrollDimensions(scrollInfo.scrollOffset , scrollInfo.autoHorizontalScrollBarChanged, scrollInfo.autoVerticalScrollBarCha nged); | |
851 } | 866 } |
852 } | 867 } |
853 } | 868 } |
854 } | 869 } |
855 | 870 |
856 void LayoutBlock::updateScrollInfoAfterLayout() | 871 void LayoutBlock::updateScrollInfoAfterLayout() |
857 { | 872 { |
858 if (hasOverflowClip()) { | 873 if (hasOverflowClip()) { |
859 if (style()->isFlippedBlocksWritingMode()) { | 874 if (style()->isFlippedBlocksWritingMode()) { |
860 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=97937 | 875 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=97937 |
861 // Workaround for now. We cannot delay the scroll info for overflow | 876 // Workaround for now. We cannot delay the scroll info for overflow |
862 // for items with opposite writing directions, as the contents needs | 877 // for items with opposite writing directions, as the contents needs |
863 // to overflow in that direction | 878 // to overflow in that direction |
864 layer()->scrollableArea()->updateAfterLayout(); | 879 layer()->scrollableArea()->updateAfterLayout(); |
865 return; | 880 return; |
866 } | 881 } |
867 | 882 |
868 if (gDelayUpdateScrollInfo) | 883 if (gDelayUpdateScrollInfo) { |
869 gDelayedUpdateScrollInfoSet->add(this); | 884 LayoutUnit logicalWidthExcludingScrollbar = logicalWidth() - scrollb arLogicalWidth(); |
870 else | 885 LayoutUnit logicalHeightExcludingScrollbar = logicalHeight() - scrol lbarLogicalHeight(); |
886 ScrollInfo scrollInfo; | |
887 layer()->scrollableArea()->updateScrollDimensions(scrollInfo.scrollO ffset, scrollInfo.autoHorizontalScrollBarChanged, scrollInfo.autoVerticalScrollB arChanged); | |
888 DelayedUpdateScrollInfoMap::AddResult scrollInfoIterator = gDelayedU pdateScrollInfoMap->add(this, scrollInfo); | |
889 if (!scrollInfoIterator.isNewEntry) | |
890 scrollInfoIterator.storedValue->value.merge(scrollInfo); | |
891 if (scrollInfo.autoHorizontalScrollBarChanged) | |
892 setLogicalHeight(logicalHeightExcludingScrollbar + scrollbarLogi calHeight()); | |
893 if (scrollInfo.autoVerticalScrollBarChanged) | |
894 setLogicalWidth(logicalWidthExcludingScrollbar + scrollbarLogica lWidth()); | |
cbiesinger
2015/11/18 18:41:35
I thought more about this block and I am no longer
| |
895 } else { | |
871 layer()->scrollableArea()->updateAfterLayout(); | 896 layer()->scrollableArea()->updateAfterLayout(); |
897 } | |
872 } | 898 } |
873 } | 899 } |
874 | 900 |
875 void LayoutBlock::layout() | 901 void LayoutBlock::layout() |
876 { | 902 { |
877 LayoutAnalyzer::Scope analyzer(*this); | 903 LayoutAnalyzer::Scope analyzer(*this); |
878 | 904 |
879 // Table cells call layoutBlock directly, so don't add any logic here. Put code into | 905 // Table cells call layoutBlock directly, so don't add any logic here. Put code into |
880 // layoutBlock(). | 906 // layoutBlock(). |
881 layoutBlock(false); | 907 layoutBlock(false); |
(...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2882 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const | 2908 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const |
2883 { | 2909 { |
2884 showLayoutObject(); | 2910 showLayoutObject(); |
2885 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) | 2911 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) |
2886 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); | 2912 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); |
2887 } | 2913 } |
2888 | 2914 |
2889 #endif | 2915 #endif |
2890 | 2916 |
2891 } // namespace blink | 2917 } // namespace blink |
OLD | NEW |