Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutListMarker.cpp

Issue 1407003005: Lists: Render marker text closer to list items. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated test expectations, again. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutListMarker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutListMarker.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutListMarker.cpp b/third_party/WebKit/Source/core/layout/LayoutListMarker.cpp
index 0906005d2896a486acfb015a8bc47b1eb5d939f4..91cdd4640f7d4384502f53e8a3d76fd7281b8f5b 100644
--- a/third_party/WebKit/Source/core/layout/LayoutListMarker.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutListMarker.cpp
@@ -1121,6 +1121,20 @@ void LayoutListMarker::updateContent()
}
}
+LayoutUnit LayoutListMarker::getWidthOfTextWithSuffix() const
+{
+ if (m_text.isEmpty())
+ return 0;
+ const Font& font = style()->font();
+ LayoutUnit itemWidth = font.width(m_text);
+ // TODO(wkorman): Look into constructing a text run for both text and suffix
+ // and painting them together.
+ UChar suffix[2] = { listMarkerSuffix(style()->listStyleType(), m_listItem->value()), ' ' };
+ TextRun run = constructTextRun(font, suffix, 2, styleRef(), style()->direction());
+ LayoutUnit suffixSpaceWidth = font.width(run);
+ return itemWidth + suffixSpaceWidth;
+}
+
void LayoutListMarker::computePreferredLogicalWidths()
{
ASSERT(preferredLogicalWidthsDirty());
@@ -1144,14 +1158,7 @@ void LayoutListMarker::computePreferredLogicalWidths()
logicalWidth = (font.fontMetrics().ascent() * 2 / 3 + 1) / 2 + 2;
break;
case ListStyleCategory::Language:
- if (m_text.isEmpty()) {
- logicalWidth = 0;
- } else {
- LayoutUnit itemWidth = font.width(m_text);
- UChar suffixSpace[2] = { listMarkerSuffix(style()->listStyleType(), m_listItem->value()), ' ' };
- LayoutUnit suffixSpaceWidth = font.width(constructTextRun(font, suffixSpace, 2, styleRef(), style()->direction()));
- logicalWidth = itemWidth + suffixSpaceWidth;
- }
+ logicalWidth = getWidthOfTextWithSuffix();
break;
}
@@ -1190,13 +1197,13 @@ void LayoutListMarker::updateMargins()
} else {
int offset = fontMetrics.ascent() * 2 / 3;
switch (listStyleCategory()) {
+ case ListStyleCategory::None:
+ break;
case ListStyleCategory::Symbol:
marginStart = -offset - cMarkerPadding - 1;
break;
- case ListStyleCategory::None:
- break;
default:
- marginStart = m_text.isEmpty() ? LayoutUnit() : -minPreferredLogicalWidth() - offset / 2;
+ marginStart = m_text.isEmpty() ? LayoutUnit() : -minPreferredLogicalWidth();
}
}
marginEnd = -marginStart - minPreferredLogicalWidth();
@@ -1206,13 +1213,13 @@ void LayoutListMarker::updateMargins()
} else {
int offset = fontMetrics.ascent() * 2 / 3;
switch (listStyleCategory()) {
+ case ListStyleCategory::None:
+ break;
case ListStyleCategory::Symbol:
marginEnd = offset + cMarkerPadding + 1 - minPreferredLogicalWidth();
break;
- case ListStyleCategory::None:
- break;
default:
- marginEnd = m_text.isEmpty() ? 0 : offset / 2;
+ marginEnd = 0;
}
}
marginStart = -marginEnd - minPreferredLogicalWidth();
@@ -1328,16 +1335,11 @@ IntRect LayoutListMarker::getRelativeMarkerRect() const
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:
- if (m_text.isEmpty())
- return IntRect();
- const Font& font = style()->font();
- int itemWidth = font.width(m_text);
- UChar suffixSpace[2] = { listMarkerSuffix(style()->listStyleType(), m_listItem->value()), ' ' };
- int suffixSpaceWidth = font.width(constructTextRun(font, suffixSpace, 2, styleRef(), style()->direction()));
- relativeRect = IntRect(0, 0, itemWidth + suffixSpaceWidth, font.fontMetrics().height());
+ relativeRect = IntRect(0, 0, getWidthOfTextWithSuffix(), style()->font().fontMetrics().height());
+ break;
}
if (!style()->isHorizontalWritingMode()) {
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutListMarker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698