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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 }; | 86 }; |
87 | 87 |
88 static_assert(sizeof(LayoutBlock) == sizeof(SameSizeAsLayoutBlock), "LayoutBlock should stay small"); | 88 static_assert(sizeof(LayoutBlock) == sizeof(SameSizeAsLayoutBlock), "LayoutBlock should stay small"); |
89 | 89 |
90 static TrackedDescendantsMap* gPositionedDescendantsMap = nullptr; | 90 static TrackedDescendantsMap* gPositionedDescendantsMap = nullptr; |
91 static TrackedDescendantsMap* gPercentHeightDescendantsMap = nullptr; | 91 static TrackedDescendantsMap* gPercentHeightDescendantsMap = nullptr; |
92 | 92 |
93 static TrackedContainerMap* gPositionedContainerMap = nullptr; | 93 static TrackedContainerMap* gPositionedContainerMap = nullptr; |
94 static TrackedContainerMap* gPercentHeightContainerMap = nullptr; | 94 static TrackedContainerMap* gPercentHeightContainerMap = nullptr; |
95 | 95 |
96 typedef WTF::HashSet<LayoutBlock*> DelayedUpdateScrollInfoSet; | 96 struct ScrollInfo { |
97 DoubleSize scrollOffset; | |
98 bool autoHorizontalScrollBarChanged; | |
99 bool autoVerticalScrollBarChanged; | |
100 bool hasOffset() const { return scrollOffset.width() != 0 || scrollOffset.he ight() != 0; } | |
leviw_travelin_and_unemployed
2015/08/20 18:53:06
scollOffset == DoubleSize()?
szager1
2015/08/20 21:53:29
Done.
| |
101 bool scrollBarsChanged() const { return autoHorizontalScrollBarChanged || au toVerticalScrollBarChanged; } | |
102 void merge(const ScrollInfo& other) | |
103 { | |
104 // We always keep the first scrollOffset we saw for this block, so don't copy that field. | |
105 autoHorizontalScrollBarChanged |= other.autoHorizontalScrollBarChanged; | |
106 autoVerticalScrollBarChanged |= other.autoVerticalScrollBarChanged; | |
107 } | |
108 }; | |
109 typedef WTF::HashMap<LayoutBlock*, ScrollInfo> DelayedUpdateScrollInfoMap; | |
97 static int gDelayUpdateScrollInfo = 0; | 110 static int gDelayUpdateScrollInfo = 0; |
98 static DelayedUpdateScrollInfoSet* gDelayedUpdateScrollInfoSet = nullptr; | 111 static DelayedUpdateScrollInfoMap* gDelayedUpdateScrollInfoMap = nullptr; |
99 | 112 |
100 LayoutBlock::LayoutBlock(ContainerNode* node) | 113 LayoutBlock::LayoutBlock(ContainerNode* node) |
101 : LayoutBox(node) | 114 : LayoutBox(node) |
102 , m_hasMarginBeforeQuirk(false) | 115 , m_hasMarginBeforeQuirk(false) |
103 , m_hasMarginAfterQuirk(false) | 116 , m_hasMarginAfterQuirk(false) |
104 , m_beingDestroyed(false) | 117 , m_beingDestroyed(false) |
105 , m_hasMarkupTruncation(false) | 118 , m_hasMarkupTruncation(false) |
106 , m_widthAvailableToChildrenChanged(false) | 119 , m_widthAvailableToChildrenChanged(false) |
107 , m_hasOnlySelfCollapsingChildren(false) | 120 , m_hasOnlySelfCollapsingChildren(false) |
108 , m_descendantsWithFloatsMarkedForLayout(false) | 121 , m_descendantsWithFloatsMarkedForLayout(false) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 childBox->remove(); | 222 childBox->remove(); |
210 } | 223 } |
211 } | 224 } |
212 } else if (parent()) { | 225 } else if (parent()) { |
213 parent()->dirtyLinesFromChangedChild(this); | 226 parent()->dirtyLinesFromChangedChild(this); |
214 } | 227 } |
215 } | 228 } |
216 | 229 |
217 m_lineBoxes.deleteLineBoxes(); | 230 m_lineBoxes.deleteLineBoxes(); |
218 | 231 |
219 if (UNLIKELY(gDelayedUpdateScrollInfoSet != 0)) | 232 if (UNLIKELY(gDelayedUpdateScrollInfoMap != 0)) |
220 gDelayedUpdateScrollInfoSet->remove(this); | 233 gDelayedUpdateScrollInfoMap->remove(this); |
221 | 234 |
222 if (TextAutosizer* textAutosizer = document().textAutosizer()) | 235 if (TextAutosizer* textAutosizer = document().textAutosizer()) |
223 textAutosizer->destroy(this); | 236 textAutosizer->destroy(this); |
224 | 237 |
225 LayoutBox::willBeDestroyed(); | 238 LayoutBox::willBeDestroyed(); |
226 } | 239 } |
227 | 240 |
228 void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new Style) | 241 void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new Style) |
229 { | 242 { |
230 const ComputedStyle* oldStyle = style(); | 243 const ComputedStyle* oldStyle = style(); |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 return false; | 839 return false; |
827 } | 840 } |
828 return true; | 841 return true; |
829 } | 842 } |
830 return false; | 843 return false; |
831 } | 844 } |
832 | 845 |
833 void LayoutBlock::startDelayUpdateScrollInfo() | 846 void LayoutBlock::startDelayUpdateScrollInfo() |
834 { | 847 { |
835 if (gDelayUpdateScrollInfo == 0) { | 848 if (gDelayUpdateScrollInfo == 0) { |
836 ASSERT(!gDelayedUpdateScrollInfoSet); | 849 ASSERT(!gDelayedUpdateScrollInfoMap); |
837 gDelayedUpdateScrollInfoSet = new DelayedUpdateScrollInfoSet; | 850 gDelayedUpdateScrollInfoMap = new DelayedUpdateScrollInfoMap; |
838 } | 851 } |
839 ASSERT(gDelayedUpdateScrollInfoSet); | 852 ASSERT(gDelayedUpdateScrollInfoMap); |
840 ++gDelayUpdateScrollInfo; | 853 ++gDelayUpdateScrollInfo; |
841 } | 854 } |
842 | 855 |
843 void LayoutBlock::finishDelayUpdateScrollInfo() | 856 void LayoutBlock::finishDelayUpdateScrollInfo() |
844 { | 857 { |
845 --gDelayUpdateScrollInfo; | 858 --gDelayUpdateScrollInfo; |
846 ASSERT(gDelayUpdateScrollInfo >= 0); | 859 ASSERT(gDelayUpdateScrollInfo >= 0); |
847 if (gDelayUpdateScrollInfo == 0) { | 860 if (gDelayUpdateScrollInfo == 0) { |
848 ASSERT(gDelayedUpdateScrollInfoSet); | 861 ASSERT(gDelayedUpdateScrollInfoMap); |
849 | 862 |
850 OwnPtr<DelayedUpdateScrollInfoSet> infoSet(adoptPtr(gDelayedUpdateScroll InfoSet)); | 863 OwnPtr<DelayedUpdateScrollInfoMap> infoSet(adoptPtr(gDelayedUpdateScroll InfoMap)); |
leviw_travelin_and_unemployed
2015/08/20 18:53:06
s/infoSet/infoMap/
szager1
2015/08/20 21:53:29
Done.
| |
851 gDelayedUpdateScrollInfoSet = nullptr; | 864 gDelayedUpdateScrollInfoMap = nullptr; |
852 | 865 |
853 for (auto* block : *infoSet) { | 866 for (auto block : *infoSet) { |
854 if (block->hasOverflowClip()) { | 867 if (block.key->hasOverflowClip()) { |
855 block->layer()->scrollableArea()->updateAfterLayout(); | 868 DeprecatedPaintLayerScrollableArea* scrollableArea = block.key-> layer()->scrollableArea(); |
869 ScrollInfo& scrollInfo = block.value; | |
870 scrollableArea->finalizeScrollDimensions(scrollInfo.scrollOffset , scrollInfo.autoHorizontalScrollBarChanged, scrollInfo.autoVerticalScrollBarCha nged); | |
856 } | 871 } |
857 } | 872 } |
858 } | 873 } |
859 } | 874 } |
860 | 875 |
861 void LayoutBlock::updateScrollInfoAfterLayout() | 876 void LayoutBlock::updateScrollInfoAfterLayout() |
862 { | 877 { |
863 if (hasOverflowClip()) { | 878 if (hasOverflowClip()) { |
864 if (style()->isFlippedBlocksWritingMode()) { | 879 if (style()->isFlippedBlocksWritingMode()) { |
865 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=97937 | 880 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=97937 |
866 // Workaround for now. We cannot delay the scroll info for overflow | 881 // Workaround for now. We cannot delay the scroll info for overflow |
867 // for items with opposite writing directions, as the contents needs | 882 // for items with opposite writing directions, as the contents needs |
868 // to overflow in that direction | 883 // to overflow in that direction |
869 layer()->scrollableArea()->updateAfterLayout(); | 884 layer()->scrollableArea()->updateAfterLayout(); |
870 return; | 885 return; |
871 } | 886 } |
872 | 887 |
873 if (gDelayUpdateScrollInfo) | 888 if (gDelayUpdateScrollInfo) { |
874 gDelayedUpdateScrollInfoSet->add(this); | 889 LayoutUnit logicalWidthExcludingScrollbar = logicalWidth() - scrollb arLogicalWidth(); |
875 else | 890 LayoutUnit logicalHeightExcludingScrollbar = logicalHeight() - scrol lbarLogicalHeight(); |
891 ScrollInfo scrollInfo; | |
892 layer()->scrollableArea()->updateScrollDimensions(scrollInfo.scrollO ffset, scrollInfo.autoHorizontalScrollBarChanged, scrollInfo.autoVerticalScrollB arChanged); | |
893 if (scrollInfo.hasOffset() || scrollInfo.scrollBarsChanged()) { | |
894 DelayedUpdateScrollInfoMap::AddResult scrollInfoIterator = gDela yedUpdateScrollInfoMap->add(this, scrollInfo); | |
895 if (!scrollInfoIterator.isNewEntry) | |
896 scrollInfoIterator.storedValue->value.merge(scrollInfo); | |
897 } | |
898 if (scrollInfo.autoHorizontalScrollBarChanged) | |
899 setLogicalHeight(logicalHeightExcludingScrollbar + scrollbarLogi calHeight()); | |
900 if (scrollInfo.autoVerticalScrollBarChanged) | |
901 setLogicalWidth(logicalWidthExcludingScrollbar + scrollbarLogica lWidth()); | |
902 } else { | |
876 layer()->scrollableArea()->updateAfterLayout(); | 903 layer()->scrollableArea()->updateAfterLayout(); |
904 } | |
877 } | 905 } |
878 } | 906 } |
879 | 907 |
880 void LayoutBlock::layout() | 908 void LayoutBlock::layout() |
881 { | 909 { |
882 LayoutAnalyzer::Scope analyzer(*this); | 910 LayoutAnalyzer::Scope analyzer(*this); |
883 | 911 |
884 // Table cells call layoutBlock directly, so don't add any logic here. Put code into | 912 // Table cells call layoutBlock directly, so don't add any logic here. Put code into |
885 // layoutBlock(). | 913 // layoutBlock(). |
886 layoutBlock(false); | 914 layoutBlock(false); |
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2918 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const | 2946 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const |
2919 { | 2947 { |
2920 showLayoutObject(); | 2948 showLayoutObject(); |
2921 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) | 2949 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) |
2922 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); | 2950 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); |
2923 } | 2951 } |
2924 | 2952 |
2925 #endif | 2953 #endif |
2926 | 2954 |
2927 } // namespace blink | 2955 } // namespace blink |
OLD | NEW |