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

Side by Side Diff: Source/core/rendering/RenderListItem.cpp

Issue 368733002: Split list marker updating into two steps (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address reviewer comments Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderListItem.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 260 }
261 261
262 static RenderObject* firstNonMarkerChild(RenderObject* parent) 262 static RenderObject* firstNonMarkerChild(RenderObject* parent)
263 { 263 {
264 RenderObject* result = parent->slowFirstChild(); 264 RenderObject* result = parent->slowFirstChild();
265 while (result && result->isListMarker()) 265 while (result && result->isListMarker())
266 result = result->nextSibling(); 266 result = result->nextSibling();
267 return result; 267 return result;
268 } 268 }
269 269
270 void RenderListItem::updateMarkerLocation() 270 void RenderListItem::updateMarkerLocationAndInvalidateWidth()
271 { 271 {
272 // Sanity check the location of our marker. 272 ASSERT(m_marker);
273 if (m_marker) {
274 RenderObject* markerParent = m_marker->parent();
275 RenderObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker);
276 if (!lineBoxParent) {
277 // If the marker is currently contained inside an anonymous box,
278 // then we are the only item in that anonymous box (since no line bo x
279 // parent was found). It's ok to just leave the marker where it is
280 // in this case.
281 if (markerParent && markerParent->isAnonymousBlock())
282 lineBoxParent = markerParent;
283 else
284 lineBoxParent = this;
285 }
286 273
287 if (markerParent != lineBoxParent || m_marker->preferredLogicalWidthsDir ty()) { 274 // FIXME: We should not modify the structure of the render tree
288 // FIXME: We should not modify the structure of the render tree 275 // during layout. crbug.com/370461
289 // during layout. crbug.com/370461 276 DeprecatedDisableModifyRenderTreeStructureAsserts disabler;
290 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; 277 // Removing and adding the marker can trigger repainting in
278 // containers other than ourselves, so we need to disable LayoutState.
279 ForceHorriblySlowRectMapping slowRectMapping(*this);
280 if (updateMarkerLocation()) {
281 // If the marker is inside we need to redo the preferred width calculati ons
282 // as the size of the item now includes the size of the list marker.
283 if (m_marker->isInside())
284 containingBlock()->updateLogicalWidth();
285 }
286 }
291 287
292 // Removing and adding the marker can trigger repainting in 288 bool RenderListItem::updateMarkerLocation()
293 // containers other than ourselves, so we need to disable LayoutStat e. 289 {
294 ForceHorriblySlowRectMapping slowRectMapping(*this); 290 ASSERT(m_marker);
295 updateFirstLetter(); 291 RenderObject* markerParent = m_marker->parent();
296 m_marker->remove(); 292 RenderObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker);
297 if (markerParent) 293 if (!lineBoxParent) {
298 markerParent->dirtyLinesFromChangedChild(m_marker); 294 // If the marker is currently contained inside an anonymous box, then we
299 if (!lineBoxParent) 295 // are the only item in that anonymous box (since no line box parent was
300 lineBoxParent = this; 296 // found). It's ok to just leave the marker where it is in this case.
301 lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent) ); 297 if (markerParent && markerParent->isAnonymousBlock())
302 m_marker->updateMarginsAndContent(); 298 lineBoxParent = markerParent;
303 // If markerParent is an anonymous block that has lost all its child ren, destroy it. 299 else
304 if (markerParent && markerParent->isAnonymousBlock() && !toRenderBlo ck(markerParent)->firstChild() && !toRenderBlock(markerParent)->continuation()) 300 lineBoxParent = this;
305 markerParent->destroy(); 301 }
306 302
307 // If the marker is inside we need to redo the preferred width calcu lations 303 if (markerParent != lineBoxParent) {
308 // as the size of the item now includes the size of the list marker. 304 updateFirstLetter();
309 if (m_marker->isInside()) 305 m_marker->remove();
310 containingBlock()->updateLogicalWidth(); 306 // FIXME(crbug.com/391009): Investigate whether this call is needed.
311 } 307 if (markerParent)
308 markerParent->dirtyLinesFromChangedChild(m_marker);
309 lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent));
310 m_marker->updateMarginsAndContent();
311 // If markerParent is an anonymous block with no children, destroy it.
312 if (markerParent && markerParent->isAnonymousBlock() && !toRenderBlock(m arkerParent)->firstChild() && !toRenderBlock(markerParent)->continuation())
313 markerParent->destroy();
314 return true;
312 } 315 }
316
317 return false;
313 } 318 }
314 319
315 void RenderListItem::layout() 320 void RenderListItem::layout()
316 { 321 {
317 ASSERT(needsLayout()); 322 ASSERT(needsLayout());
318 323
319 // The marker must be autosized before calling updateMarkerLocation.
320 // It cannot be done in the parent's beginLayout because it is not yet in th e render tree.
321 if (m_marker) { 324 if (m_marker) {
322 FastTextAutosizer* textAutosizer = document().fastTextAutosizer(); 325 // The marker must be autosized before calling
323 if (textAutosizer) 326 // updateMarkerLocationAndInvalidateWidth. It cannot be done in the
327 // parent's beginLayout because it is not yet in the render tree.
328 if (FastTextAutosizer* textAutosizer = document().fastTextAutosizer())
324 textAutosizer->inflateListItem(this, m_marker); 329 textAutosizer->inflateListItem(this, m_marker);
330
331 updateMarkerLocationAndInvalidateWidth();
325 } 332 }
326 333
327 updateMarkerLocation();
328 RenderBlockFlow::layout(); 334 RenderBlockFlow::layout();
329 } 335 }
330 336
331 void RenderListItem::addOverflowFromChildren() 337 void RenderListItem::addOverflowFromChildren()
332 { 338 {
333 RenderBlockFlow::addOverflowFromChildren(); 339 RenderBlockFlow::addOverflowFromChildren();
334 positionListMarker(); 340 positionListMarker();
335 } 341 }
336 342
337 void RenderListItem::positionListMarker() 343 void RenderListItem::positionListMarker()
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 { 474 {
469 ASSERT(node()); 475 ASSERT(node());
470 476
471 if (!m_hasExplicitValue) 477 if (!m_hasExplicitValue)
472 return; 478 return;
473 m_hasExplicitValue = false; 479 m_hasExplicitValue = false;
474 m_isValueUpToDate = false; 480 m_isValueUpToDate = false;
475 explicitValueChanged(); 481 explicitValueChanged();
476 } 482 }
477 483
484 void RenderListItem::setNotInList(bool notInList)
485 {
486 m_notInList = notInList;
487 if (m_marker)
488 updateMarkerLocation();
489 }
490
478 static RenderListItem* previousOrNextItem(bool isListReversed, Node* list, Rende rListItem* item) 491 static RenderListItem* previousOrNextItem(bool isListReversed, Node* list, Rende rListItem* item)
479 { 492 {
480 return isListReversed ? previousListItem(list, item) : nextListItem(list, it em); 493 return isListReversed ? previousListItem(list, item) : nextListItem(list, it em);
481 } 494 }
482 495
483 void RenderListItem::updateListMarkerNumbers() 496 void RenderListItem::updateListMarkerNumbers()
484 { 497 {
485 // If distribution recalc is needed, updateListMarkerNumber will be re-invok ed 498 // If distribution recalc is needed, updateListMarkerNumber will be re-invok ed
486 // after distribution is calculated. 499 // after distribution is calculated.
487 if (node()->document().childNeedsDistributionRecalc()) 500 if (node()->document().childNeedsDistributionRecalc())
(...skipping 22 matching lines...) Expand all
510 // assume that all the following ones have too. 523 // assume that all the following ones have too.
511 // This gives us the opportunity to stop here and avoid 524 // This gives us the opportunity to stop here and avoid
512 // marking the same nodes again. 525 // marking the same nodes again.
513 break; 526 break;
514 } 527 }
515 item->updateValue(); 528 item->updateValue();
516 } 529 }
517 } 530 }
518 531
519 } // namespace WebCore 532 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderListItem.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698