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

Unified Diff: third_party/WebKit/Source/core/paint/ListMarkerPainter.cpp

Issue 1403643002: Rework list marker spacing for better web compatibility. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@472084_use_list_item_painter
Patch Set: Fix compile error with default switch case. 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
Index: third_party/WebKit/Source/core/paint/ListMarkerPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/ListMarkerPainter.cpp b/third_party/WebKit/Source/core/paint/ListMarkerPainter.cpp
index abc82dee2f29018b99e3da56fcc5dfa82b69e771..e05f7832d4f5128459ace432869976ce6e0b743a 100644
--- a/third_party/WebKit/Source/core/paint/ListMarkerPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/ListMarkerPainter.cpp
@@ -58,85 +58,23 @@ void ListMarkerPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& pai
return;
}
- if (m_layoutListMarker.selectionState() != SelectionNone) {
+ if (!RuntimeEnabledFeatures::selectionPaintingWithoutSelectionGapsEnabled()
+ && m_layoutListMarker.selectionState() != SelectionNone) {
LayoutRect selRect = m_layoutListMarker.localSelectionRect();
selRect.moveBy(boxOrigin);
context->fillRect(pixelSnappedIntRect(selRect), m_layoutListMarker.listItem()->selectionBackgroundColor());
}
+ // TODO(wkorman): Do we still need all of these if we use pure text?
const Color color(m_layoutListMarker.resolveColor(CSSPropertyColor));
context->setStrokeColor(color);
context->setStrokeStyle(SolidStroke);
context->setStrokeThickness(1.0f);
context->setFillColor(color);
- EListStyleType type = m_layoutListMarker.style()->listStyleType();
- switch (type) {
- case Disc:
- context->fillEllipse(marker);
+ EListStyleType listStyle = m_layoutListMarker.style()->listStyleType();
+ if (listStyle == NoneListStyle)
return;
- case Circle:
- context->strokeEllipse(marker);
- return;
- case Square:
- context->fillRect(marker);
- return;
- case NoneListStyle:
- return;
- case ArabicIndic:
- case Armenian:
- case Bengali:
- case Cambodian:
- case CJKIdeographic:
- case CjkEarthlyBranch:
- case CjkHeavenlyStem:
- case DecimalLeadingZero:
- case DecimalListStyle:
- case Devanagari:
- case EthiopicHalehame:
- case EthiopicHalehameAm:
- case EthiopicHalehameTiEr:
- case EthiopicHalehameTiEt:
- case Georgian:
- case Gujarati:
- case Gurmukhi:
- case Hebrew:
- case Hangul:
- case HangulConsonant:
- case KoreanHangulFormal:
- case KoreanHanjaFormal:
- case KoreanHanjaInformal:
- case Hiragana:
- case HiraganaIroha:
- case Kannada:
- case Katakana:
- case KatakanaIroha:
- case Khmer:
- case Lao:
- case LowerAlpha:
- case LowerArmenian:
- case LowerGreek:
- case LowerLatin:
- case LowerRoman:
- case Malayalam:
- case Mongolian:
- case Myanmar:
- case Oriya:
- case Persian:
- case SimpChineseFormal:
- case SimpChineseInformal:
- case Telugu:
- case Thai:
- case Tibetan:
- case TradChineseFormal:
- case TradChineseInformal:
- case UpperAlpha:
- case UpperArmenian:
- case UpperLatin:
- case UpperRoman:
- case Urdu:
- break;
- }
if (m_layoutListMarker.text().isEmpty())
return;
@@ -171,9 +109,18 @@ void ListMarkerPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& pai
textRun.setText(reversedText.toString());
}
- const UChar suffix = m_layoutListMarker.listMarkerSuffix(type, m_layoutListMarker.listItem()->value());
- UChar suffixStr[2] = { suffix, static_cast<UChar>(' ') };
- TextRun suffixRun = constructTextRun(font, suffixStr, 2, m_layoutListMarker.styleRef(), m_layoutListMarker.style()->direction());
+ const UChar suffix = m_layoutListMarker.listMarkerSuffix(listStyle, m_layoutListMarker.listItem()->value());
+ UChar suffixStr[2];
+ suffixStr[0] = suffix;
+ int suffixLength = 1;
+ // For lists with symbol style, the suffix is a space. For language styles, the suffix is a
+ // language-specific character which is then followed by an additional space.
+ // TODO(wkorman): Review everywhere we do this and see if we can consolidate logic.
+ if (m_layoutListMarker.simplifiedListStyle() == LayoutListMarker::LanguageSimpleStyle) {
+ suffixStr[1] = static_cast<UChar>(' ');
+ suffixLength = 2;
+ }
+ TextRun suffixRun = constructTextRun(font, suffixStr, suffixLength, m_layoutListMarker.styleRef(), m_layoutListMarker.style()->direction());
TextRunPaintInfo suffixRunInfo(suffixRun);
suffixRunInfo.bounds = marker;

Powered by Google App Engine
This is Rietveld 408576698