Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1133)

Unified Diff: Source/core/layout/LayoutBlock.cpp

Issue 1295933003: Add overflow:auto scrollbars to child flex basis. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add all tests, even failing ones Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/layout/LayoutBlock.cpp
diff --git a/Source/core/layout/LayoutBlock.cpp b/Source/core/layout/LayoutBlock.cpp
index 116c979367c9b7c7fc0eb820d6eeff761531ee70..889152f3d79e307f7e1578f774b3e003849ffc48 100644
--- a/Source/core/layout/LayoutBlock.cpp
+++ b/Source/core/layout/LayoutBlock.cpp
@@ -93,9 +93,22 @@ static TrackedDescendantsMap* gPercentHeightDescendantsMap = nullptr;
static TrackedContainerMap* gPositionedContainerMap = nullptr;
static TrackedContainerMap* gPercentHeightContainerMap = nullptr;
-typedef WTF::HashSet<LayoutBlock*> DelayedUpdateScrollInfoSet;
+struct ScrollInfo {
+ DoubleSize scrollOffset;
+ bool autoHorizontalScrollBarChanged;
+ bool autoVerticalScrollBarChanged;
+ bool hasOffset() const { return scrollOffset.width() != 0 || scrollOffset.height() != 0; }
leviw_travelin_and_unemployed 2015/08/20 18:53:06 scollOffset == DoubleSize()?
szager1 2015/08/20 21:53:29 Done.
+ bool scrollBarsChanged() const { return autoHorizontalScrollBarChanged || autoVerticalScrollBarChanged; }
+ void merge(const ScrollInfo& other)
+ {
+ // We always keep the first scrollOffset we saw for this block, so don't copy that field.
+ autoHorizontalScrollBarChanged |= other.autoHorizontalScrollBarChanged;
+ autoVerticalScrollBarChanged |= other.autoVerticalScrollBarChanged;
+ }
+};
+typedef WTF::HashMap<LayoutBlock*, ScrollInfo> DelayedUpdateScrollInfoMap;
static int gDelayUpdateScrollInfo = 0;
-static DelayedUpdateScrollInfoSet* gDelayedUpdateScrollInfoSet = nullptr;
+static DelayedUpdateScrollInfoMap* gDelayedUpdateScrollInfoMap = nullptr;
LayoutBlock::LayoutBlock(ContainerNode* node)
: LayoutBox(node)
@@ -216,8 +229,8 @@ void LayoutBlock::willBeDestroyed()
m_lineBoxes.deleteLineBoxes();
- if (UNLIKELY(gDelayedUpdateScrollInfoSet != 0))
- gDelayedUpdateScrollInfoSet->remove(this);
+ if (UNLIKELY(gDelayedUpdateScrollInfoMap != 0))
+ gDelayedUpdateScrollInfoMap->remove(this);
if (TextAutosizer* textAutosizer = document().textAutosizer())
textAutosizer->destroy(this);
@@ -833,10 +846,10 @@ bool LayoutBlock::isSelfCollapsingBlock() const
void LayoutBlock::startDelayUpdateScrollInfo()
{
if (gDelayUpdateScrollInfo == 0) {
- ASSERT(!gDelayedUpdateScrollInfoSet);
- gDelayedUpdateScrollInfoSet = new DelayedUpdateScrollInfoSet;
+ ASSERT(!gDelayedUpdateScrollInfoMap);
+ gDelayedUpdateScrollInfoMap = new DelayedUpdateScrollInfoMap;
}
- ASSERT(gDelayedUpdateScrollInfoSet);
+ ASSERT(gDelayedUpdateScrollInfoMap);
++gDelayUpdateScrollInfo;
}
@@ -845,14 +858,16 @@ void LayoutBlock::finishDelayUpdateScrollInfo()
--gDelayUpdateScrollInfo;
ASSERT(gDelayUpdateScrollInfo >= 0);
if (gDelayUpdateScrollInfo == 0) {
- ASSERT(gDelayedUpdateScrollInfoSet);
+ ASSERT(gDelayedUpdateScrollInfoMap);
- OwnPtr<DelayedUpdateScrollInfoSet> infoSet(adoptPtr(gDelayedUpdateScrollInfoSet));
- gDelayedUpdateScrollInfoSet = nullptr;
+ OwnPtr<DelayedUpdateScrollInfoMap> infoSet(adoptPtr(gDelayedUpdateScrollInfoMap));
leviw_travelin_and_unemployed 2015/08/20 18:53:06 s/infoSet/infoMap/
szager1 2015/08/20 21:53:29 Done.
+ gDelayedUpdateScrollInfoMap = nullptr;
- for (auto* block : *infoSet) {
- if (block->hasOverflowClip()) {
- block->layer()->scrollableArea()->updateAfterLayout();
+ for (auto block : *infoSet) {
+ if (block.key->hasOverflowClip()) {
+ DeprecatedPaintLayerScrollableArea* scrollableArea = block.key->layer()->scrollableArea();
+ ScrollInfo& scrollInfo = block.value;
+ scrollableArea->finalizeScrollDimensions(scrollInfo.scrollOffset, scrollInfo.autoHorizontalScrollBarChanged, scrollInfo.autoVerticalScrollBarChanged);
}
}
}
@@ -870,10 +885,23 @@ void LayoutBlock::updateScrollInfoAfterLayout()
return;
}
- if (gDelayUpdateScrollInfo)
- gDelayedUpdateScrollInfoSet->add(this);
- else
+ if (gDelayUpdateScrollInfo) {
+ LayoutUnit logicalWidthExcludingScrollbar = logicalWidth() - scrollbarLogicalWidth();
+ LayoutUnit logicalHeightExcludingScrollbar = logicalHeight() - scrollbarLogicalHeight();
+ ScrollInfo scrollInfo;
+ layer()->scrollableArea()->updateScrollDimensions(scrollInfo.scrollOffset, scrollInfo.autoHorizontalScrollBarChanged, scrollInfo.autoVerticalScrollBarChanged);
+ if (scrollInfo.hasOffset() || scrollInfo.scrollBarsChanged()) {
+ DelayedUpdateScrollInfoMap::AddResult scrollInfoIterator = gDelayedUpdateScrollInfoMap->add(this, scrollInfo);
+ if (!scrollInfoIterator.isNewEntry)
+ scrollInfoIterator.storedValue->value.merge(scrollInfo);
+ }
+ if (scrollInfo.autoHorizontalScrollBarChanged)
+ setLogicalHeight(logicalHeightExcludingScrollbar + scrollbarLogicalHeight());
+ if (scrollInfo.autoVerticalScrollBarChanged)
+ setLogicalWidth(logicalWidthExcludingScrollbar + scrollbarLogicalWidth());
+ } else {
layer()->scrollableArea()->updateAfterLayout();
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698