Title: [139891] trunk/Source/WebCore
- Revision
- 139891
- Author
- [email protected]
- Date
- 2013-01-16 10:02:46 -0800 (Wed, 16 Jan 2013)
Log Message
RenderListMarker::computePreferredLogicalWidth should not be public
https://bugs.webkit.org/show_bug.cgi?id=106956
Reviewed by Tony Chang.
RenderListItem was calling computePreferredLogicalWidths for the side
effects of updating the marker content and margins. Instead, call
updateMarginsAndContent directly.
* rendering/RenderListItem.cpp:
(WebCore::RenderListItem::updateMarkerLocation):
* rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::layout):
The isImage() codepath never calls computePreferredLogicalWidths, so we need to make
sure the content and margins are updated.
(WebCore::RenderListMarker::updateContent):
(WebCore::RenderListMarker::computePreferredLogicalWidths):
(WebCore::RenderListMarker::updateMarginsAndContent):
* rendering/RenderListMarker.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (139890 => 139891)
--- trunk/Source/WebCore/ChangeLog 2013-01-16 18:00:17 UTC (rev 139890)
+++ trunk/Source/WebCore/ChangeLog 2013-01-16 18:02:46 UTC (rev 139891)
@@ -1,3 +1,26 @@
+2013-01-16 Ojan Vafai <[email protected]>
+
+ RenderListMarker::computePreferredLogicalWidth should not be public
+ https://bugs.webkit.org/show_bug.cgi?id=106956
+
+ Reviewed by Tony Chang.
+
+ RenderListItem was calling computePreferredLogicalWidths for the side
+ effects of updating the marker content and margins. Instead, call
+ updateMarginsAndContent directly.
+
+ * rendering/RenderListItem.cpp:
+ (WebCore::RenderListItem::updateMarkerLocation):
+ * rendering/RenderListMarker.cpp:
+ (WebCore::RenderListMarker::layout):
+ The isImage() codepath never calls computePreferredLogicalWidths, so we need to make
+ sure the content and margins are updated.
+
+ (WebCore::RenderListMarker::updateContent):
+ (WebCore::RenderListMarker::computePreferredLogicalWidths):
+ (WebCore::RenderListMarker::updateMarginsAndContent):
+ * rendering/RenderListMarker.h:
+
2013-01-16 Claudio Saavedra <[email protected]>
[GTK] Safeguard against possible NULL-dereference
Modified: trunk/Source/WebCore/rendering/RenderListItem.cpp (139890 => 139891)
--- trunk/Source/WebCore/rendering/RenderListItem.cpp 2013-01-16 18:00:17 UTC (rev 139890)
+++ trunk/Source/WebCore/rendering/RenderListItem.cpp 2013-01-16 18:02:46 UTC (rev 139891)
@@ -265,8 +265,7 @@
if (!lineBoxParent)
lineBoxParent = this;
lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent));
- if (m_marker->preferredLogicalWidthsDirty())
- m_marker->computePreferredLogicalWidths();
+ m_marker->updateMarginsAndContent();
// If markerPar is an anonymous block that has lost all its children, destroy it.
if (markerPar && markerPar->isAnonymousBlock() && !markerPar->firstChild() && !toRenderBlock(markerPar)->continuation())
markerPar->destroy();
Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (139890 => 139891)
--- trunk/Source/WebCore/rendering/RenderListMarker.cpp 2013-01-16 18:00:17 UTC (rev 139890)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp 2013-01-16 18:02:46 UTC (rev 139891)
@@ -1318,6 +1318,7 @@
ASSERT(needsLayout());
if (isImage()) {
+ updateMarginsAndContent();
setWidth(m_image->imageSize(this, style()->effectiveZoom()).width());
setHeight(m_image->imageSize(this, style()->effectiveZoom()).height());
} else {
@@ -1350,20 +1351,126 @@
repaint();
}
-void RenderListMarker::computePreferredLogicalWidths()
+void RenderListMarker::updateMarginsAndContent()
{
- ASSERT(preferredLogicalWidthsDirty());
+ updateContent();
+ updateMargins();
+}
+void RenderListMarker::updateContent()
+{
+ // FIXME: This if-statement is just a performance optimization, but it's messy to use the preferredLogicalWidths dirty bit for this.
+ // It's unclear if this is a premature optimization.
+ if (!preferredLogicalWidthsDirty())
+ return;
+
m_text = "";
- const Font& font = style()->font();
- const FontMetrics& fontMetrics = font.fontMetrics();
-
if (isImage()) {
// FIXME: This is a somewhat arbitrary width. Generated images for markers really won't become particularly useful
// until we support the CSS3 marker pseudoclass to allow control over the width and height of the marker box.
- int bulletWidth = fontMetrics.ascent() / 2;
+ int bulletWidth = style()->fontMetrics().ascent() / 2;
m_image->setContainerSizeForRenderer(this, IntSize(bulletWidth, bulletWidth), style()->effectiveZoom());
+ return;
+ }
+
+ EListStyleType type = style()->listStyleType();
+ switch (type) {
+ case NoneListStyle:
+ break;
+ case Circle:
+ case Disc:
+ case Square:
+ m_text = listMarkerText(type, 0); // value is ignored for these types
+ break;
+ case Asterisks:
+ case Footnotes:
+ case Afar:
+ case Amharic:
+ case AmharicAbegede:
+ case ArabicIndic:
+ case Armenian:
+ case BinaryListStyle:
+ case Bengali:
+ case Cambodian:
+ case CJKIdeographic:
+ case CjkEarthlyBranch:
+ case CjkHeavenlyStem:
+ case DecimalLeadingZero:
+ case DecimalListStyle:
+ case Devanagari:
+ case Ethiopic:
+ case EthiopicAbegede:
+ case EthiopicAbegedeAmEt:
+ case EthiopicAbegedeGez:
+ case EthiopicAbegedeTiEr:
+ case EthiopicAbegedeTiEt:
+ case EthiopicHalehameAaEr:
+ case EthiopicHalehameAaEt:
+ case EthiopicHalehameAmEt:
+ case EthiopicHalehameGez:
+ case EthiopicHalehameOmEt:
+ case EthiopicHalehameSidEt:
+ case EthiopicHalehameSoEt:
+ case EthiopicHalehameTiEr:
+ case EthiopicHalehameTiEt:
+ case EthiopicHalehameTig:
+ case Georgian:
+ case Gujarati:
+ case Gurmukhi:
+ case Hangul:
+ case HangulConsonant:
+ case Hebrew:
+ case Hiragana:
+ case HiraganaIroha:
+ case Kannada:
+ case Katakana:
+ case KatakanaIroha:
+ case Khmer:
+ case Lao:
+ case LowerAlpha:
+ case LowerArmenian:
+ case LowerGreek:
+ case LowerHexadecimal:
+ case LowerLatin:
+ case LowerNorwegian:
+ case LowerRoman:
+ case Malayalam:
+ case Mongolian:
+ case Myanmar:
+ case Octal:
+ case Oriya:
+ case Oromo:
+ case Persian:
+ case Sidama:
+ case Somali:
+ case Telugu:
+ case Thai:
+ case Tibetan:
+ case Tigre:
+ case TigrinyaEr:
+ case TigrinyaErAbegede:
+ case TigrinyaEt:
+ case TigrinyaEtAbegede:
+ case UpperAlpha:
+ case UpperArmenian:
+ case UpperGreek:
+ case UpperHexadecimal:
+ case UpperLatin:
+ case UpperNorwegian:
+ case UpperRoman:
+ case Urdu:
+ m_text = listMarkerText(type, m_listItem->value());
+ break;
+ }
+}
+
+void RenderListMarker::computePreferredLogicalWidths()
+{
+ ASSERT(preferredLogicalWidthsDirty());
+ updateContent();
+
+ if (isImage()) {
LayoutSize imageSize = m_image->imageSize(this, style()->effectiveZoom());
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = style()->isHorizontalWritingMode() ? imageSize.width() : imageSize.height();
setPreferredLogicalWidthsDirty(false);
@@ -1371,6 +1478,8 @@
return;
}
+ const Font& font = style()->font();
+
LayoutUnit logicalWidth = 0;
EListStyleType type = style()->listStyleType();
switch (type) {
@@ -1378,14 +1487,12 @@
break;
case Asterisks:
case Footnotes:
- m_text = listMarkerText(type, m_listItem->value());
logicalWidth = font.width(m_text); // no suffix for these types
break;
case Circle:
case Disc:
case Square:
- m_text = listMarkerText(type, 0); // value is ignored for these types
- logicalWidth = (fontMetrics.ascent() * 2 / 3 + 1) / 2 + 2;
+ logicalWidth = (font.fontMetrics().ascent() * 2 / 3 + 1) / 2 + 2;
break;
case Afar:
case Amharic:
@@ -1462,7 +1569,6 @@
case UpperNorwegian:
case UpperRoman:
case Urdu:
- m_text = listMarkerText(type, m_listItem->value());
if (m_text.isEmpty())
logicalWidth = 0;
else {
Modified: trunk/Source/WebCore/rendering/RenderListMarker.h (139890 => 139891)
--- trunk/Source/WebCore/rendering/RenderListMarker.h 2013-01-16 18:00:17 UTC (rev 139890)
+++ trunk/Source/WebCore/rendering/RenderListMarker.h 2013-01-16 18:02:46 UTC (rev 139891)
@@ -38,8 +38,6 @@
RenderListMarker(RenderListItem*);
virtual ~RenderListMarker();
- virtual void computePreferredLogicalWidths();
-
const String& text() const { return m_text; }
String suffix() const;
@@ -47,8 +45,11 @@
virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+ void updateMarginsAndContent();
+
private:
virtual const char* renderName() const { return "RenderListMarker"; }
+ virtual void computePreferredLogicalWidths() OVERRIDE;
virtual bool isListMarker() const { return true; }
@@ -71,6 +72,7 @@
virtual bool canBeSelectionLeaf() const { return true; }
void updateMargins();
+ void updateContent();
virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes