Chromium Code Reviews| Index: Source/core/rendering/RenderListItem.cpp |
| diff --git a/Source/core/rendering/RenderListItem.cpp b/Source/core/rendering/RenderListItem.cpp |
| index 840eb7ef002622ce29102e53fb4a95f87d00c4f3..25a008835beb3b890de2f5a9ae69d9f58b867376 100644 |
| --- a/Source/core/rendering/RenderListItem.cpp |
| +++ b/Source/core/rendering/RenderListItem.cpp |
| @@ -267,64 +267,67 @@ static RenderObject* firstNonMarkerChild(RenderObject* parent) |
| return result; |
| } |
| -void RenderListItem::updateMarkerLocation() |
| +void RenderListItem::updateMarkerAndInvalidateWidth() |
| { |
| - // 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 (updateMarker()) { |
| + // 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); |
|
leviw_travelin_and_unemployed
2014/07/02 18:07:14
I'm suspicious of this line being removed entirely
pdr.
2014/07/02 18:39:30
I agree, lets do this as a followup. Added a fixme
|
| - 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::updateMarker() |
| +{ |
| + 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(); |
| + 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 |
| + // updateMarkerAndInvalidateWidth. 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); |
| + |
| + updateMarkerAndInvalidateWidth(); |
| } |
| - updateMarkerLocation(); |
| RenderBlockFlow::layout(); |
| } |
| @@ -475,6 +478,13 @@ void RenderListItem::clearExplicitValue() |
| explicitValueChanged(); |
| } |
| +void RenderListItem::setNotInList(bool notInList) |
| +{ |
| + m_notInList = notInList; |
| + if (m_marker) |
| + updateMarker(); |
| +} |
| + |
| static RenderListItem* previousOrNextItem(bool isListReversed, Node* list, RenderListItem* item) |
| { |
| return isListReversed ? previousListItem(list, item) : nextListItem(list, item); |