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

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

Issue 1674323002: Detect a change in border that affects a positioned object's height or position (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 4 years, 10 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: third_party/WebKit/Source/core/layout/LayoutBlock.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
index 6774606bbe87f2d44541a216072c22e94fcafb04..2e3cbb8a905bf0aee585a20bd25c250f9fe841b7 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -134,6 +134,7 @@ LayoutBlock::LayoutBlock(ContainerNode* node)
, m_descendantsWithFloatsMarkedForLayout(false)
, m_hasPositionedObjects(false)
, m_hasPercentHeightDescendants(false)
+ , m_heightAvailableToChildrenChanged(false)
{
// LayoutBlockFlow calls setChildrenInline(true).
// By default, subclasses do not have inline children.
@@ -248,9 +249,10 @@ void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new
LayoutBox::styleWillChange(diff, newStyle);
}
-static bool borderOrPaddingLogicalWidthChanged(const ComputedStyle& oldStyle, const ComputedStyle& newStyle)
+enum LogicalExtent { LogicalWidth, LogicalHeight };
+static bool borderOrPaddingLogicalDimensionChanged(const ComputedStyle& oldStyle, const ComputedStyle& newStyle, LogicalExtent logicalExtent)
{
- if (newStyle.isHorizontalWritingMode()) {
+ if (newStyle.isHorizontalWritingMode() && logicalExtent == LogicalWidth) {
mstensho (USE GERRIT) 2016/02/17 10:19:42 I think "if (newStyle.isHorizontalWritingMode() ==
return oldStyle.borderLeftWidth() != newStyle.borderLeftWidth()
|| oldStyle.borderRightWidth() != newStyle.borderRightWidth()
|| oldStyle.paddingLeft() != newStyle.paddingLeft()
@@ -295,7 +297,8 @@ void LayoutBlock::styleDidChange(StyleDifference diff, const ComputedStyle* oldS
// It's possible for our border/padding to change, but for the overall logical width of the block to
// end up being the same. We keep track of this change so in layoutBlock, we can know to set relayoutChildren=true.
mstensho (USE GERRIT) 2016/02/17 10:19:42 Should probably update this comment.
- m_widthAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && needsLayout() && borderOrPaddingLogicalWidthChanged(*oldStyle, newStyle);
+ m_widthAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && needsLayout() && borderOrPaddingLogicalDimensionChanged(*oldStyle, newStyle, LogicalWidth);
+ m_heightAvailableToChildrenChanged |= oldStyle && diff.needsFullLayout() && needsLayout() && borderOrPaddingLogicalDimensionChanged(*oldStyle, newStyle, LogicalHeight);
}
void LayoutBlock::invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& childPaintInvalidationState)
@@ -1017,6 +1020,13 @@ bool LayoutBlock::createsNewFormattingContext() const
|| isDocumentElement() || isColumnSpanAll() || isGridItem() || style()->containsPaint();
}
+bool static changeInAvailableLogicalHeightAffectsChild(LayoutBlock* parent, LayoutBox& child)
+{
+ if (parent->style()->boxSizing() != BORDER_BOX)
+ return false;
+ return parent->style()->isHorizontalWritingMode() && !child.style()->isHorizontalWritingMode();
+}
+
void LayoutBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, LayoutBox& child)
{
if (child.isOutOfFlowPositioned()) {
@@ -1031,7 +1041,8 @@ void LayoutBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, L
bool hasRelativeLogicalHeight = child.hasRelativeLogicalHeight()
|| (child.isAnonymous() && this->hasRelativeLogicalHeight())
|| child.stretchesToViewport();
- if (relayoutChildren || (hasRelativeLogicalHeight && !isLayoutView())) {
+ if (relayoutChildren || (hasRelativeLogicalHeight && !isLayoutView())
+ || (m_heightAvailableToChildrenChanged && changeInAvailableLogicalHeightAffectsChild(this, child))) {
child.setChildNeedsLayout(MarkOnlyThis);
// If the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.
@@ -1223,7 +1234,7 @@ void LayoutBlock::layoutPositionedObjects(bool relayoutChildren, PositionedLayou
continue;
}
- if (!positionedObject->normalChildNeedsLayout() && (relayoutChildren || needsLayoutDueToStaticPosition(positionedObject)))
+ if (!positionedObject->normalChildNeedsLayout() && (relayoutChildren || m_heightAvailableToChildrenChanged || needsLayoutDueToStaticPosition(positionedObject)))
layoutScope.setChildNeedsLayout(positionedObject);
// If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.

Powered by Google App Engine
This is Rietveld 408576698