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

Side by Side Diff: sky/engine/core/rendering/RenderBlockFlow.cpp

Issue 697713002: Remove line breaking to avoid window. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 RenderBlockFlow* renderer = new RenderBlockFlow(0); 154 RenderBlockFlow* renderer = new RenderBlockFlow(0);
155 renderer->setDocumentForAnonymous(document); 155 renderer->setDocumentForAnonymous(document);
156 return renderer; 156 return renderer;
157 } 157 }
158 158
159 bool RenderBlockFlow::updateLogicalWidthAndColumnWidth() 159 bool RenderBlockFlow::updateLogicalWidthAndColumnWidth()
160 { 160 {
161 return RenderBlock::updateLogicalWidthAndColumnWidth(); 161 return RenderBlock::updateLogicalWidthAndColumnWidth();
162 } 162 }
163 163
164 void RenderBlockFlow::setBreakAtLineToAvoidWidow(int lineToBreak)
165 {
166 ASSERT(lineToBreak >= 0);
167 ensureRareData();
168 ASSERT(!m_rareData->m_didBreakAtLineToAvoidWidow);
169 m_rareData->m_lineBreakToAvoidWidow = lineToBreak;
170 }
171
172 void RenderBlockFlow::setDidBreakAtLineToAvoidWidow()
173 {
174 ASSERT(!shouldBreakAtLineToAvoidWidow());
175
176 // This function should be called only after a break was applied to avoid wi dows
177 // so assert |m_rareData| exists.
178 ASSERT(m_rareData);
179
180 m_rareData->m_didBreakAtLineToAvoidWidow = true;
181 }
182
183 void RenderBlockFlow::clearDidBreakAtLineToAvoidWidow()
184 {
185 if (!m_rareData)
186 return;
187
188 m_rareData->m_didBreakAtLineToAvoidWidow = false;
189 }
190
191 void RenderBlockFlow::clearShouldBreakAtLineToAvoidWidow() const
192 {
193 ASSERT(shouldBreakAtLineToAvoidWidow());
194 if (!m_rareData)
195 return;
196
197 m_rareData->m_lineBreakToAvoidWidow = -1;
198 }
199
200 bool RenderBlockFlow::isSelfCollapsingBlock() const 164 bool RenderBlockFlow::isSelfCollapsingBlock() const
201 { 165 {
202 m_hasOnlySelfCollapsingChildren = RenderBlock::isSelfCollapsingBlock(); 166 m_hasOnlySelfCollapsingChildren = RenderBlock::isSelfCollapsingBlock();
203 return m_hasOnlySelfCollapsingChildren; 167 return m_hasOnlySelfCollapsingChildren;
204 } 168 }
205 169
206 void RenderBlockFlow::layoutBlock(bool relayoutChildren) 170 void RenderBlockFlow::layoutBlock(bool relayoutChildren)
207 { 171 {
208 ASSERT(needsLayout()); 172 ASSERT(needsLayout());
209 ASSERT(isInlineBlock() || !isInline()); 173 ASSERT(isInlineBlock() || !isInline());
210 174
211 // If we are self-collapsing with self-collapsing descendants this will get set to save us burrowing through our 175 // If we are self-collapsing with self-collapsing descendants this will get set to save us burrowing through our
212 // descendants every time in |isSelfCollapsingBlock|. We reset it here so th at |isSelfCollapsingBlock| attempts to burrow 176 // descendants every time in |isSelfCollapsingBlock|. We reset it here so th at |isSelfCollapsingBlock| attempts to burrow
213 // at least once and so that it always gives a reliable result reflecting th e latest layout. 177 // at least once and so that it always gives a reliable result reflecting th e latest layout.
214 m_hasOnlySelfCollapsingChildren = false; 178 m_hasOnlySelfCollapsingChildren = false;
215 179
216 if (!relayoutChildren && simplifiedLayout()) 180 if (!relayoutChildren && simplifiedLayout())
217 return; 181 return;
218 182
219 SubtreeLayoutScope layoutScope(*this); 183 SubtreeLayoutScope layoutScope(*this);
220 184
221 // Multiple passes might be required for column and pagination based layout 185 layoutBlockFlow(relayoutChildren, layoutScope);
222 // In the case of the old column code the number of passes will only be two
223 // however, in the newer column code the number of passes could equal the
224 // number of columns.
225 bool done = false;
226 while (!done)
227 done = layoutBlockFlow(relayoutChildren, layoutScope);
228 186
229 updateLayerTransformAfterLayout(); 187 updateLayerTransformAfterLayout();
230 188
231 // Update our scroll information if we're overflow:auto/scroll/hidden now th at we know if 189 // Update our scroll information if we're overflow:auto/scroll/hidden now th at we know if
232 // we overflow or not. 190 // we overflow or not.
233 updateScrollInfoAfterLayout(); 191 updateScrollInfoAfterLayout();
234 192
235 if (m_paintInvalidationLogicalTop != m_paintInvalidationLogicalBottom) 193 if (m_paintInvalidationLogicalTop != m_paintInvalidationLogicalBottom)
236 setShouldInvalidateOverflowForPaint(true); 194 setShouldInvalidateOverflowForPaint(true);
237 195
238 clearNeedsLayout(); 196 clearNeedsLayout();
239 } 197 }
240 198
241 inline bool RenderBlockFlow::layoutBlockFlow(bool relayoutChildren, SubtreeLayou tScope& layoutScope) 199 inline void RenderBlockFlow::layoutBlockFlow(bool relayoutChildren, SubtreeLayou tScope& layoutScope)
242 { 200 {
243 LayoutUnit oldLeft = logicalLeft(); 201 LayoutUnit oldLeft = logicalLeft();
244 bool logicalWidthChanged = updateLogicalWidthAndColumnWidth(); 202 bool logicalWidthChanged = updateLogicalWidthAndColumnWidth();
245 relayoutChildren |= logicalWidthChanged; 203 relayoutChildren |= logicalWidthChanged;
246 204
247 rebuildFloatsFromIntruding(); 205 rebuildFloatsFromIntruding();
248 206
249 LayoutState state(*this, locationOffset(), logicalWidthChanged); 207 LayoutState state(*this, locationOffset(), logicalWidthChanged);
250 208
251 // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track 209 // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track
(...skipping 19 matching lines...) Expand all
271 229
272 if (childrenInline()) 230 if (childrenInline())
273 layoutInlineChildren(relayoutChildren, m_paintInvalidationLogicalTop, m_ paintInvalidationLogicalBottom, afterEdge); 231 layoutInlineChildren(relayoutChildren, m_paintInvalidationLogicalTop, m_ paintInvalidationLogicalBottom, afterEdge);
274 else 232 else
275 layoutBlockChildren(relayoutChildren, layoutScope, beforeEdge, afterEdge ); 233 layoutBlockChildren(relayoutChildren, layoutScope, beforeEdge, afterEdge );
276 234
277 // Expand our intrinsic height to encompass floats. 235 // Expand our intrinsic height to encompass floats.
278 if (lowestFloatLogicalBottom() > (logicalHeight() - afterEdge) && createsBlo ckFormattingContext()) 236 if (lowestFloatLogicalBottom() > (logicalHeight() - afterEdge) && createsBlo ckFormattingContext())
279 setLogicalHeight(lowestFloatLogicalBottom() + afterEdge); 237 setLogicalHeight(lowestFloatLogicalBottom() + afterEdge);
280 238
281 if (shouldBreakAtLineToAvoidWidow()) {
282 setEverHadLayout(true);
283 return false;
284 }
285
286 // Calculate our new height. 239 // Calculate our new height.
287 LayoutUnit oldHeight = logicalHeight(); 240 LayoutUnit oldHeight = logicalHeight();
288 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); 241 LayoutUnit oldClientAfterEdge = clientLogicalBottom();
289 242
290 updateLogicalHeight(); 243 updateLogicalHeight();
291 LayoutUnit newHeight = logicalHeight(); 244 LayoutUnit newHeight = logicalHeight();
292 if (oldHeight > newHeight && !childrenInline()) { 245 if (oldHeight > newHeight && !childrenInline()) {
293 // One of our children's floats may have become an overhanging float for us. 246 // One of our children's floats may have become an overhanging float for us.
294 for (RenderObject* child = lastChild(); child; child = child->previousSi bling()) { 247 for (RenderObject* child = lastChild(); child; child = child->previousSi bling()) {
295 if (child->isRenderBlockFlow() && !child->isFloatingOrOutOfFlowPosit ioned()) { 248 if (child->isRenderBlockFlow() && !child->isFloatingOrOutOfFlowPosit ioned()) {
296 RenderBlockFlow* block = toRenderBlockFlow(child); 249 RenderBlockFlow* block = toRenderBlockFlow(child);
297 if (block->lowestFloatLogicalBottom() + block->logicalTop() <= n ewHeight) 250 if (block->lowestFloatLogicalBottom() + block->logicalTop() <= n ewHeight)
298 break; 251 break;
299 addOverhangingFloats(block, false); 252 addOverhangingFloats(block, false);
300 } 253 }
301 } 254 }
302 } 255 }
303 256
304 bool heightChanged = (previousHeight != newHeight); 257 bool heightChanged = (previousHeight != newHeight);
305 if (heightChanged) 258 if (heightChanged)
306 relayoutChildren = true; 259 relayoutChildren = true;
307 260
308 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout); 261 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout);
309 262
310 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway). 263 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway).
311 computeOverflow(oldClientAfterEdge); 264 computeOverflow(oldClientAfterEdge);
312 265
313 m_descendantsWithFloatsMarkedForLayout = false; 266 m_descendantsWithFloatsMarkedForLayout = false;
314 return true;
315 } 267 }
316 268
317 void RenderBlockFlow::determineLogicalLeftPositionForChild(RenderBox* child) 269 void RenderBlockFlow::determineLogicalLeftPositionForChild(RenderBox* child)
318 { 270 {
319 LayoutUnit startPosition = borderStart() + paddingStart(); 271 LayoutUnit startPosition = borderStart() + paddingStart();
320 LayoutUnit initialStartPosition = startPosition; 272 LayoutUnit initialStartPosition = startPosition;
321 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) 273 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
322 startPosition -= verticalScrollbarWidth(); 274 startPosition -= verticalScrollbarWidth();
323 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth(); 275 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth();
324 276
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() 1332 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData()
1381 { 1333 {
1382 if (m_rareData) 1334 if (m_rareData)
1383 return *m_rareData; 1335 return *m_rareData;
1384 1336
1385 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); 1337 m_rareData = adoptPtr(new RenderBlockFlowRareData(this));
1386 return *m_rareData; 1338 return *m_rareData;
1387 } 1339 }
1388 1340
1389 } // namespace blink 1341 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBlockFlow.h ('k') | sky/engine/core/rendering/RenderBlockLineLayout.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698