void LayoutListMarker::computePreferredLogicalWidths() { ASSERT(preferredLogicalWidthsDirty()); updateContent(); if (isImage()) { LayoutSize imageSize(imageBulletSize()); m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = style()->isHorizontalWritingMode() ? imageSize.width() : imageSize.height(); clearPreferredLogicalWidthsDirty(); updateMargins(); return; } const Font& font = style()->font(); LayoutUnit logicalWidth; switch (listStyleCategory()) { case ListStyleCategory::None: break; case ListStyleCategory::Symbol: logicalWidth = LayoutUnit((font.fontMetrics().ascent() * 2 / 3 + 1) / 2 + 2); break; case ListStyleCategory::Language: logicalWidth = getWidthOfTextWithSuffix(); break; } m_minPreferredLogicalWidth = logicalWidth; m_maxPreferredLogicalWidth = logicalWidth; clearPreferredLogicalWidthsDirty(); updateMargins(); }
IntRect LayoutListMarker::getRelativeMarkerRect() const { if (isImage()) { IntSize imageSize = flooredIntSize(imageBulletSize()); return IntRect(0, 0, imageSize.width(), imageSize.height()); } IntRect relativeRect; switch (listStyleCategory()) { case ListStyleCategory::None: return IntRect(); case ListStyleCategory::Symbol: { // TODO(wkorman): Review and clean up/document the calculations below. // http://crbug.com/543193 const FontMetrics& fontMetrics = style()->fontMetrics(); int ascent = fontMetrics.ascent(); int bulletWidth = (ascent * 2 / 3 + 1) / 2; relativeRect = IntRect(1, 3 * (ascent - ascent * 2 / 3) / 2, bulletWidth, bulletWidth); } break; case ListStyleCategory::Language: relativeRect = IntRect(0, 0, getWidthOfTextWithSuffix(), style()->font().fontMetrics().height()); break; } if (!style()->isHorizontalWritingMode()) { relativeRect = relativeRect.transposedRect(); relativeRect.setX(size().width() - relativeRect.x() - relativeRect.width()); } return relativeRect; }
void LayoutListMarker::layout() { ASSERT(needsLayout()); LayoutAnalyzer::Scope analyzer(*this); if (isImage()) { updateMarginsAndContent(); LayoutSize imageSize(imageBulletSize()); setWidth(imageSize.width()); setHeight(imageSize.height()); } else { setLogicalWidth(minPreferredLogicalWidth()); setLogicalHeight(LayoutUnit(style()->fontMetrics().height())); } setMarginStart(LayoutUnit()); setMarginEnd(LayoutUnit()); Length startMargin = style()->marginStart(); Length endMargin = style()->marginEnd(); if (startMargin.isFixed()) setMarginStart(LayoutUnit(startMargin.value())); if (endMargin.isFixed()) setMarginEnd(LayoutUnit(endMargin.value())); clearNeedsLayout(); }
void LayoutListMarker::imageChanged(WrappedImagePtr o, const IntRect*) { // A list marker can't have a background or border image, so no need to call the base class method. if (o != m_image->data()) return; LayoutSize imageSize = isImage() ? imageBulletSize() : LayoutSize(); if (size() != imageSize || m_image->errorOccurred()) setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidationReason::ImageChanged); else setShouldDoFullPaintInvalidation(); }
void LayoutListMarker::layout() { ASSERT(needsLayout()); LayoutAnalyzer::Scope analyzer(*this); LayoutUnit blockOffset; for (LayoutBox* o = parentBox(); o && o != listItem(); o = o->parentBox()) { blockOffset += o->logicalTop(); } if (listItem()->style()->isLeftToRightDirection()) { m_lineOffset = listItem()->logicalLeftOffsetForLine( blockOffset, DoNotIndentText, LayoutUnit()); } else { m_lineOffset = listItem()->logicalRightOffsetForLine( blockOffset, DoNotIndentText, LayoutUnit()); } if (isImage()) { updateMarginsAndContent(); LayoutSize imageSize(imageBulletSize()); setWidth(imageSize.width()); setHeight(imageSize.height()); } else { const SimpleFontData* fontData = style()->font().primaryFont(); DCHECK(fontData); setLogicalWidth(minPreferredLogicalWidth()); setLogicalHeight( LayoutUnit(fontData ? fontData->getFontMetrics().height() : 0)); } setMarginStart(LayoutUnit()); setMarginEnd(LayoutUnit()); Length startMargin = style()->marginStart(); Length endMargin = style()->marginEnd(); if (startMargin.isFixed()) setMarginStart(LayoutUnit(startMargin.value())); if (endMargin.isFixed()) setMarginEnd(LayoutUnit(endMargin.value())); clearNeedsLayout(); }