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::updateMarkerLocation() { // 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; } if (markerParent != lineBoxParent || m_marker->preferredLogicalWidthsDirty()) { // Removing and adding the marker can trigger repainting in // containers other than ourselves, so we need to disable LayoutState. LayoutStateDisabler layoutStateDisabler(view()); 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() && !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(); } } }