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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
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 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 Length marginLeft = child.style()->marginStartUsing(style()); 1163 Length marginLeft = child.style()->marginStartUsing(style());
1164 Length marginRight = child.style()->marginEndUsing(style()); 1164 Length marginRight = child.style()->marginEndUsing(style());
1165 LayoutUnit margin; 1165 LayoutUnit margin;
1166 if (marginLeft.isFixed()) 1166 if (marginLeft.isFixed())
1167 margin += marginLeft.value(); 1167 margin += marginLeft.value();
1168 if (marginRight.isFixed()) 1168 if (marginRight.isFixed())
1169 margin += marginRight.value(); 1169 margin += marginRight.value();
1170 return margin; 1170 return margin;
1171 } 1171 }
1172 1172
1173 static bool needsLayoutDueToStaticPosition(LayoutBox* child) 1173 static bool needsLayoutDueToMovement(LayoutBox* child, LayoutBox* containingBloc k)
1174 { 1174 {
1175 // When a non-positioned block element moves, it may have positioned childre n that are 1175 // When a non-positioned block element moves, it may have positioned childre n that are
1176 // implicitly positioned relative to the non-positioned block. 1176 // implicitly positioned relative to the non-positioned block.
1177 const ComputedStyle* style = child->style(); 1177 const ComputedStyle* style = child->style();
1178 bool isHorizontal = style->isHorizontalWritingMode(); 1178 bool isHorizontal = style->isHorizontalWritingMode();
1179 if (style->hasStaticBlockPosition(isHorizontal)) { 1179 // A change in the containing block's block-direction borders will affect th e child's height and position.
1180 bool checkForChangeInAvailableHeight = containingBlock->needsLayout() && con tainingBlock->style()->logicalHeight().isAuto() && (containingBlock->borderBefor e() || containingBlock->borderAfter());
1181 if (style->hasStaticBlockPosition(isHorizontal) || checkForChangeInAvailable Height) {
mstensho (USE GERRIT) 2016/02/09 09:08:51 I was wondering why we don't need to do the same f
rhogan 2016/02/09 18:38:30 If we can come up with additional use cases, defin
mstensho (USE GERRIT) 2016/02/10 10:39:10 <!DOCTYPE html> <p>There should be a blue <em>squa
1180 LayoutBox::LogicalExtentComputedValues computedValues; 1182 LayoutBox::LogicalExtentComputedValues computedValues;
1181 LayoutUnit currentLogicalTop = child->logicalTop(); 1183 LayoutUnit currentLogicalTop = child->logicalTop();
1182 LayoutUnit currentLogicalHeight = child->logicalHeight(); 1184 LayoutUnit currentLogicalHeight = child->logicalHeight();
1183 child->computeLogicalHeight(currentLogicalHeight, currentLogicalTop, com putedValues); 1185 child->computeLogicalHeight(currentLogicalHeight, currentLogicalTop, com putedValues);
1184 if (computedValues.m_position != currentLogicalTop || computedValues.m_e xtent != currentLogicalHeight) 1186 if (computedValues.m_position != currentLogicalTop || computedValues.m_e xtent != currentLogicalHeight)
1185 return true; 1187 return true;
1186 } 1188 }
1187 if (style->hasStaticInlinePosition(isHorizontal)) { 1189 if (style->hasStaticInlinePosition(isHorizontal)) {
1188 LayoutBox::LogicalExtentComputedValues computedValues; 1190 LayoutBox::LogicalExtentComputedValues computedValues;
1189 LayoutUnit currentLogicalLeft = child->logicalLeft(); 1191 LayoutUnit currentLogicalLeft = child->logicalLeft();
(...skipping 19 matching lines...) Expand all
1209 SubtreeLayoutScope layoutScope(*positionedObject); 1211 SubtreeLayoutScope layoutScope(*positionedObject);
1210 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So 1212 // A fixed position element with an absolute positioned ancestor has no way of knowing if the latter has changed position. So
1211 // if this is a fixed position element, mark it for layout if it has an abspos ancestor and needs to move with that ancestor, i.e. 1213 // if this is a fixed position element, mark it for layout if it has an abspos ancestor and needs to move with that ancestor, i.e.
1212 // it has static position. 1214 // it has static position.
1213 markFixedPositionObjectForLayoutIfNeeded(positionedObject, layoutScope); 1215 markFixedPositionObjectForLayoutIfNeeded(positionedObject, layoutScope);
1214 if (info == LayoutOnlyFixedPositionedObjects) { 1216 if (info == LayoutOnlyFixedPositionedObjects) {
1215 positionedObject->layoutIfNeeded(); 1217 positionedObject->layoutIfNeeded();
1216 continue; 1218 continue;
1217 } 1219 }
1218 1220
1219 if (!positionedObject->normalChildNeedsLayout() && (relayoutChildren || needsLayoutDueToStaticPosition(positionedObject))) 1221 if (!positionedObject->normalChildNeedsLayout() && (relayoutChildren || needsLayoutDueToMovement(positionedObject, this)))
1220 layoutScope.setChildNeedsLayout(positionedObject); 1222 layoutScope.setChildNeedsLayout(positionedObject);
1221 1223
1222 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths. 1224 // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.
1223 if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculat ion()) 1225 if (relayoutChildren && positionedObject->needsPreferredWidthsRecalculat ion())
1224 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis); 1226 positionedObject->setPreferredLogicalWidthsDirty(MarkOnlyThis);
1225 1227
1226 LayoutUnit logicalTopEstimate; 1228 LayoutUnit logicalTopEstimate;
1227 bool needsBlockDirectionLocationSetBeforeLayout = isPaginated && positio nedObject->paginationBreakability() != ForbidBreaks; 1229 bool needsBlockDirectionLocationSetBeforeLayout = isPaginated && positio nedObject->paginationBreakability() != ForbidBreaks;
1228 if (needsBlockDirectionLocationSetBeforeLayout) { 1230 if (needsBlockDirectionLocationSetBeforeLayout) {
1229 // Out-of-flow objects are normally positioned after layout (while i n-flow objects are 1231 // Out-of-flow objects are normally positioned after layout (while i n-flow objects are
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2860 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2859 { 2861 {
2860 showLayoutObject(); 2862 showLayoutObject();
2861 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2863 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2862 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2864 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2863 } 2865 }
2864 2866
2865 #endif 2867 #endif
2866 2868
2867 } // namespace blink 2869 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698