Index: Source/core/rendering/RenderListItem.cpp |
diff --git a/Source/core/rendering/RenderListItem.cpp b/Source/core/rendering/RenderListItem.cpp |
index 840eb7ef002622ce29102e53fb4a95f87d00c4f3..4809c11781c947d34c03fb028c948dd564128a20 100644 |
--- a/Source/core/rendering/RenderListItem.cpp |
+++ b/Source/core/rendering/RenderListItem.cpp |
@@ -267,64 +267,70 @@ static RenderObject* firstNonMarkerChild(RenderObject* parent) |
return result; |
} |
-void RenderListItem::updateMarkerLocation() |
+void RenderListItem::updateMarkerLocationAndInvalidateWidth() |
{ |
- // Sanity check the location of our marker. |
- if (m_marker) { |
- RenderObject* markerParent = m_marker->parent(); |
- RenderObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker); |
- if (!lineBoxParent) { |
- // If the marker is currently contained inside an anonymous box, |
- // then we are the only item in that anonymous box (since no line box |
- // parent was found). It's ok to just leave the marker where it is |
- // in this case. |
- if (markerParent && markerParent->isAnonymousBlock()) |
- lineBoxParent = markerParent; |
- else |
- lineBoxParent = this; |
- } |
+ ASSERT(m_marker); |
+ |
+ // FIXME: We should not modify the structure of the render tree |
+ // during layout. crbug.com/370461 |
+ DeprecatedDisableModifyRenderTreeStructureAsserts disabler; |
+ // Removing and adding the marker can trigger repainting in |
+ // containers other than ourselves, so we need to disable LayoutState. |
+ ForceHorriblySlowRectMapping slowRectMapping(*this); |
+ if (updateMarkerLocation()) { |
+ // If the marker is inside we need to redo the preferred width calculations |
+ // as the size of the item now includes the size of the list marker. |
+ if (m_marker->isInside()) |
+ containingBlock()->updateLogicalWidth(); |
+ } |
+} |
- if (markerParent != lineBoxParent || m_marker->preferredLogicalWidthsDirty()) { |
- // FIXME: We should not modify the structure of the render tree |
- // during layout. crbug.com/370461 |
- DeprecatedDisableModifyRenderTreeStructureAsserts disabler; |
- |
- // Removing and adding the marker can trigger repainting in |
- // containers other than ourselves, so we need to disable LayoutState. |
- ForceHorriblySlowRectMapping slowRectMapping(*this); |
- updateFirstLetter(); |
- m_marker->remove(); |
- if (markerParent) |
- markerParent->dirtyLinesFromChangedChild(m_marker); |
- if (!lineBoxParent) |
- lineBoxParent = this; |
- lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent)); |
- m_marker->updateMarginsAndContent(); |
- // If markerParent is an anonymous block that has lost all its children, destroy it. |
- if (markerParent && markerParent->isAnonymousBlock() && !toRenderBlock(markerParent)->firstChild() && !toRenderBlock(markerParent)->continuation()) |
- markerParent->destroy(); |
- |
- // If the marker is inside we need to redo the preferred width calculations |
- // as the size of the item now includes the size of the list marker. |
- if (m_marker->isInside()) |
- containingBlock()->updateLogicalWidth(); |
- } |
+bool RenderListItem::updateMarkerLocation() |
+{ |
+ ASSERT(m_marker); |
+ RenderObject* markerParent = m_marker->parent(); |
+ RenderObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker); |
+ if (!lineBoxParent) { |
+ // If the marker is currently contained inside an anonymous box, then we |
+ // are the only item in that anonymous box (since no line box parent was |
+ // found). It's ok to just leave the marker where it is in this case. |
+ if (markerParent && markerParent->isAnonymousBlock()) |
+ lineBoxParent = markerParent; |
+ else |
+ lineBoxParent = this; |
+ } |
+ |
+ if (markerParent != lineBoxParent) { |
+ updateFirstLetter(); |
+ m_marker->remove(); |
+ // FIXME(crbug.com/391009): Investigate whether this call is needed. |
+ if (markerParent) |
+ markerParent->dirtyLinesFromChangedChild(m_marker); |
+ lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent)); |
+ m_marker->updateMarginsAndContent(); |
+ // If markerParent is an anonymous block with no children, destroy it. |
+ if (markerParent && markerParent->isAnonymousBlock() && !toRenderBlock(markerParent)->firstChild() && !toRenderBlock(markerParent)->continuation()) |
+ markerParent->destroy(); |
+ return true; |
} |
+ |
+ return false; |
} |
void RenderListItem::layout() |
{ |
ASSERT(needsLayout()); |
- // The marker must be autosized before calling updateMarkerLocation. |
- // It cannot be done in the parent's beginLayout because it is not yet in the render tree. |
if (m_marker) { |
- FastTextAutosizer* textAutosizer = document().fastTextAutosizer(); |
- if (textAutosizer) |
+ // The marker must be autosized before calling |
+ // updateMarkerLocationAndInvalidateWidth. It cannot be done in the |
+ // parent's beginLayout because it is not yet in the render tree. |
+ if (FastTextAutosizer* textAutosizer = document().fastTextAutosizer()) |
textAutosizer->inflateListItem(this, m_marker); |
+ |
+ updateMarkerLocationAndInvalidateWidth(); |
} |
- updateMarkerLocation(); |
RenderBlockFlow::layout(); |
} |
@@ -475,6 +481,13 @@ void RenderListItem::clearExplicitValue() |
explicitValueChanged(); |
} |
+void RenderListItem::setNotInList(bool notInList) |
+{ |
+ m_notInList = notInList; |
+ if (m_marker) |
+ updateMarkerLocation(); |
+} |
+ |
static RenderListItem* previousOrNextItem(bool isListReversed, Node* list, RenderListItem* item) |
{ |
return isListReversed ? previousListItem(list, item) : nextListItem(list, item); |