| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/ListMarkerPainter.h" | 6 #include "core/paint/ListMarkerPainter.h" |
| 7 | 7 |
| 8 #include "core/layout/LayoutListItem.h" | 8 #include "core/layout/LayoutListItem.h" |
| 9 #include "core/layout/LayoutListMarker.h" | 9 #include "core/layout/LayoutListMarker.h" |
| 10 #include "core/layout/TextRunConstructor.h" | 10 #include "core/layout/TextRunConstructor.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 if (m_layoutListMarker.isImage()) { | 51 if (m_layoutListMarker.isImage()) { |
| 52 context->drawImage(m_layoutListMarker.image()->image(&m_layoutListMarker
, marker.size()).get(), marker); | 52 context->drawImage(m_layoutListMarker.image()->image(&m_layoutListMarker
, marker.size()).get(), marker); |
| 53 if (m_layoutListMarker.selectionState() != SelectionNone) { | 53 if (m_layoutListMarker.selectionState() != SelectionNone) { |
| 54 LayoutRect selRect = m_layoutListMarker.localSelectionRect(); | 54 LayoutRect selRect = m_layoutListMarker.localSelectionRect(); |
| 55 selRect.moveBy(boxOrigin); | 55 selRect.moveBy(boxOrigin); |
| 56 context->fillRect(pixelSnappedIntRect(selRect), m_layoutListMarker.l
istItem()->selectionBackgroundColor()); | 56 context->fillRect(pixelSnappedIntRect(selRect), m_layoutListMarker.l
istItem()->selectionBackgroundColor()); |
| 57 } | 57 } |
| 58 return; | 58 return; |
| 59 } | 59 } |
| 60 | 60 |
| 61 if (m_layoutListMarker.selectionState() != SelectionNone) { | 61 if (!RuntimeEnabledFeatures::selectionPaintingWithoutSelectionGapsEnabled() |
| 62 && m_layoutListMarker.selectionState() != SelectionNone) { |
| 62 LayoutRect selRect = m_layoutListMarker.localSelectionRect(); | 63 LayoutRect selRect = m_layoutListMarker.localSelectionRect(); |
| 63 selRect.moveBy(boxOrigin); | 64 selRect.moveBy(boxOrigin); |
| 64 context->fillRect(pixelSnappedIntRect(selRect), m_layoutListMarker.listI
tem()->selectionBackgroundColor()); | 65 context->fillRect(pixelSnappedIntRect(selRect), m_layoutListMarker.listI
tem()->selectionBackgroundColor()); |
| 65 } | 66 } |
| 66 | 67 |
| 68 // TODO(wkorman): Do we still need all of these if we use pure text? |
| 67 const Color color(m_layoutListMarker.resolveColor(CSSPropertyColor)); | 69 const Color color(m_layoutListMarker.resolveColor(CSSPropertyColor)); |
| 68 context->setStrokeColor(color); | 70 context->setStrokeColor(color); |
| 69 context->setStrokeStyle(SolidStroke); | 71 context->setStrokeStyle(SolidStroke); |
| 70 context->setStrokeThickness(1.0f); | 72 context->setStrokeThickness(1.0f); |
| 71 context->setFillColor(color); | 73 context->setFillColor(color); |
| 72 | 74 |
| 73 EListStyleType type = m_layoutListMarker.style()->listStyleType(); | 75 EListStyleType listStyle = m_layoutListMarker.style()->listStyleType(); |
| 74 switch (type) { | 76 if (listStyle == NoneListStyle) |
| 75 case Disc: | |
| 76 context->fillEllipse(marker); | |
| 77 return; | 77 return; |
| 78 case Circle: | |
| 79 context->strokeEllipse(marker); | |
| 80 return; | |
| 81 case Square: | |
| 82 context->fillRect(marker); | |
| 83 return; | |
| 84 case NoneListStyle: | |
| 85 return; | |
| 86 case ArabicIndic: | |
| 87 case Armenian: | |
| 88 case Bengali: | |
| 89 case Cambodian: | |
| 90 case CJKIdeographic: | |
| 91 case CjkEarthlyBranch: | |
| 92 case CjkHeavenlyStem: | |
| 93 case DecimalLeadingZero: | |
| 94 case DecimalListStyle: | |
| 95 case Devanagari: | |
| 96 case EthiopicHalehame: | |
| 97 case EthiopicHalehameAm: | |
| 98 case EthiopicHalehameTiEr: | |
| 99 case EthiopicHalehameTiEt: | |
| 100 case Georgian: | |
| 101 case Gujarati: | |
| 102 case Gurmukhi: | |
| 103 case Hebrew: | |
| 104 case Hangul: | |
| 105 case HangulConsonant: | |
| 106 case KoreanHangulFormal: | |
| 107 case KoreanHanjaFormal: | |
| 108 case KoreanHanjaInformal: | |
| 109 case Hiragana: | |
| 110 case HiraganaIroha: | |
| 111 case Kannada: | |
| 112 case Katakana: | |
| 113 case KatakanaIroha: | |
| 114 case Khmer: | |
| 115 case Lao: | |
| 116 case LowerAlpha: | |
| 117 case LowerArmenian: | |
| 118 case LowerGreek: | |
| 119 case LowerLatin: | |
| 120 case LowerRoman: | |
| 121 case Malayalam: | |
| 122 case Mongolian: | |
| 123 case Myanmar: | |
| 124 case Oriya: | |
| 125 case Persian: | |
| 126 case SimpChineseFormal: | |
| 127 case SimpChineseInformal: | |
| 128 case Telugu: | |
| 129 case Thai: | |
| 130 case Tibetan: | |
| 131 case TradChineseFormal: | |
| 132 case TradChineseInformal: | |
| 133 case UpperAlpha: | |
| 134 case UpperArmenian: | |
| 135 case UpperLatin: | |
| 136 case UpperRoman: | |
| 137 case Urdu: | |
| 138 break; | |
| 139 } | |
| 140 if (m_layoutListMarker.text().isEmpty()) | 78 if (m_layoutListMarker.text().isEmpty()) |
| 141 return; | 79 return; |
| 142 | 80 |
| 143 const Font& font = m_layoutListMarker.style()->font(); | 81 const Font& font = m_layoutListMarker.style()->font(); |
| 144 TextRun textRun = constructTextRun(font, m_layoutListMarker.text(), m_layout
ListMarker.styleRef()); | 82 TextRun textRun = constructTextRun(font, m_layoutListMarker.text(), m_layout
ListMarker.styleRef()); |
| 145 | 83 |
| 146 GraphicsContextStateSaver stateSaver(*context, false); | 84 GraphicsContextStateSaver stateSaver(*context, false); |
| 147 if (!m_layoutListMarker.style()->isHorizontalWritingMode()) { | 85 if (!m_layoutListMarker.style()->isHorizontalWritingMode()) { |
| 148 marker.moveBy(roundedIntPoint(-boxOrigin)); | 86 marker.moveBy(roundedIntPoint(-boxOrigin)); |
| 149 marker = marker.transposedRect(); | 87 marker = marker.transposedRect(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 164 StringBuilder reversedText; | 102 StringBuilder reversedText; |
| 165 if (textNeedsReversing) { | 103 if (textNeedsReversing) { |
| 166 unsigned length = m_layoutListMarker.text().length(); | 104 unsigned length = m_layoutListMarker.text().length(); |
| 167 reversedText.reserveCapacity(length); | 105 reversedText.reserveCapacity(length); |
| 168 for (int i = length - 1; i >= 0; --i) | 106 for (int i = length - 1; i >= 0; --i) |
| 169 reversedText.append(m_layoutListMarker.text()[i]); | 107 reversedText.append(m_layoutListMarker.text()[i]); |
| 170 ASSERT(reversedText.length() == length); | 108 ASSERT(reversedText.length() == length); |
| 171 textRun.setText(reversedText.toString()); | 109 textRun.setText(reversedText.toString()); |
| 172 } | 110 } |
| 173 | 111 |
| 174 const UChar suffix = m_layoutListMarker.listMarkerSuffix(type, m_layoutListM
arker.listItem()->value()); | 112 const UChar suffix = m_layoutListMarker.listMarkerSuffix(listStyle, m_layout
ListMarker.listItem()->value()); |
| 175 UChar suffixStr[2] = { suffix, static_cast<UChar>(' ') }; | 113 UChar suffixStr[2]; |
| 176 TextRun suffixRun = constructTextRun(font, suffixStr, 2, m_layoutListMarker.
styleRef(), m_layoutListMarker.style()->direction()); | 114 suffixStr[0] = suffix; |
| 115 int suffixLength = 1; |
| 116 // For lists with symbol style, the suffix is a space. For language styles,
the suffix is a |
| 117 // language-specific character which is then followed by an additional space
. |
| 118 // TODO(wkorman): Review everywhere we do this and see if we can consolidate
logic. |
| 119 if (m_layoutListMarker.simplifiedListStyle() == LayoutListMarker::LanguageSi
mpleStyle) { |
| 120 suffixStr[1] = static_cast<UChar>(' '); |
| 121 suffixLength = 2; |
| 122 } |
| 123 TextRun suffixRun = constructTextRun(font, suffixStr, suffixLength, m_layout
ListMarker.styleRef(), m_layoutListMarker.style()->direction()); |
| 177 TextRunPaintInfo suffixRunInfo(suffixRun); | 124 TextRunPaintInfo suffixRunInfo(suffixRun); |
| 178 suffixRunInfo.bounds = marker; | 125 suffixRunInfo.bounds = marker; |
| 179 | 126 |
| 180 if (m_layoutListMarker.style()->isLeftToRightDirection()) { | 127 if (m_layoutListMarker.style()->isLeftToRightDirection()) { |
| 181 context->drawText(font, textRunPaintInfo, textOrigin); | 128 context->drawText(font, textRunPaintInfo, textOrigin); |
| 182 context->drawText(font, suffixRunInfo, textOrigin + IntSize(font.width(t
extRun), 0)); | 129 context->drawText(font, suffixRunInfo, textOrigin + IntSize(font.width(t
extRun), 0)); |
| 183 } else { | 130 } else { |
| 184 context->drawText(font, suffixRunInfo, textOrigin); | 131 context->drawText(font, suffixRunInfo, textOrigin); |
| 185 context->drawText(font, textRunPaintInfo, textOrigin + IntSize(font.widt
h(suffixRun), 0)); | 132 context->drawText(font, textRunPaintInfo, textOrigin + IntSize(font.widt
h(suffixRun), 0)); |
| 186 } | 133 } |
| 187 } | 134 } |
| 188 | 135 |
| 189 } // namespace blink | 136 } // namespace blink |
| OLD | NEW |