📄 renderlistmarker.cpp
字号:
group[0] = static_cast<AbstractCJKChar>(digit0 + digitValue); if (digitValue) group[1] = fourthDigitMarker; } // Remove the tens digit, but leave the marker, for any group that has // a value of less than 20. if (groupValue < 20) { ASSERT(group[4] == noChar || group[4] == digit0 || group[4] == digit1); group[4] = noChar; } if (number == 0) break; } // Convert into characters, omitting consecutive runs of digit0 and // any trailing digit0. int length = 0; UChar characters[bufferLength]; AbstractCJKChar last = noChar; for (int i = 0; i < bufferLength; ++i) { AbstractCJKChar a = buffer[i]; if (a != noChar) { if (a != digit0 || last != digit0) characters[length++] = table[a - 1]; last = a; } } if (last == digit0) --length; return String(characters, length);}String listMarkerText(EListStyleType type, int value){ switch (type) { case LNONE: return ""; // We use the same characters for text security. // See RenderText::setInternalString. case CIRCLE: return String(&whiteBullet, 1); case DISC: return String(&bullet, 1); case SQUARE: // The CSS 2.1 test suite uses U+25EE BLACK MEDIUM SMALL SQUARE // instead, but I think this looks better. return String(&blackSquare, 1); case LDECIMAL: return String::number(value); case DECIMAL_LEADING_ZERO: if (value < -9 || value > 9) return String::number(value); if (value < 0) return "-0" + String::number(-value); // -01 to -09 return "0" + String::number(value); // 00 to 09 case LOWER_ALPHA: case LOWER_LATIN: { static const UChar lowerLatinAlphabet[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; return toAlphabetic(value, lowerLatinAlphabet, 26); } case UPPER_ALPHA: case UPPER_LATIN: { static const UChar upperLatinAlphabet[26] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; return toAlphabetic(value, upperLatinAlphabet, 26); } case LOWER_GREEK: { static const UChar lowerGreekAlphabet[24] = { 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9 }; return toAlphabetic(value, lowerGreekAlphabet, 24); } case HIRAGANA: { // FIXME: This table comes from the CSS3 draft, and is probably // incorrect, given the comments in that draft. static const UChar hiraganaAlphabet[48] = { 0x3042, 0x3044, 0x3046, 0x3048, 0x304A, 0x304B, 0x304D, 0x304F, 0x3051, 0x3053, 0x3055, 0x3057, 0x3059, 0x305B, 0x305D, 0x305F, 0x3061, 0x3064, 0x3066, 0x3068, 0x306A, 0x306B, 0x306C, 0x306D, 0x306E, 0x306F, 0x3072, 0x3075, 0x3078, 0x307B, 0x307E, 0x307F, 0x3080, 0x3081, 0x3082, 0x3084, 0x3086, 0x3088, 0x3089, 0x308A, 0x308B, 0x308C, 0x308D, 0x308F, 0x3090, 0x3091, 0x3092, 0x3093 }; return toAlphabetic(value, hiraganaAlphabet, 48); } case HIRAGANA_IROHA: { // FIXME: This table comes from the CSS3 draft, and is probably // incorrect, given the comments in that draft. static const UChar hiraganaIrohaAlphabet[47] = { 0x3044, 0x308D, 0x306F, 0x306B, 0x307B, 0x3078, 0x3068, 0x3061, 0x308A, 0x306C, 0x308B, 0x3092, 0x308F, 0x304B, 0x3088, 0x305F, 0x308C, 0x305D, 0x3064, 0x306D, 0x306A, 0x3089, 0x3080, 0x3046, 0x3090, 0x306E, 0x304A, 0x304F, 0x3084, 0x307E, 0x3051, 0x3075, 0x3053, 0x3048, 0x3066, 0x3042, 0x3055, 0x304D, 0x3086, 0x3081, 0x307F, 0x3057, 0x3091, 0x3072, 0x3082, 0x305B, 0x3059 }; return toAlphabetic(value, hiraganaIrohaAlphabet, 47); } case KATAKANA: { // FIXME: This table comes from the CSS3 draft, and is probably // incorrect, given the comments in that draft. static const UChar katakanaAlphabet[48] = { 0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, 0x30AB, 0x30AD, 0x30AF, 0x30B1, 0x30B3, 0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD, 0x30BF, 0x30C1, 0x30C4, 0x30C6, 0x30C8, 0x30CA, 0x30CB, 0x30CC, 0x30CD, 0x30CE, 0x30CF, 0x30D2, 0x30D5, 0x30D8, 0x30DB, 0x30DE, 0x30DF, 0x30E0, 0x30E1, 0x30E2, 0x30E4, 0x30E6, 0x30E8, 0x30E9, 0x30EA, 0x30EB, 0x30EC, 0x30ED, 0x30EF, 0x30F0, 0x30F1, 0x30F2, 0x30F3 }; return toAlphabetic(value, katakanaAlphabet, 48); } case KATAKANA_IROHA: { // FIXME: This table comes from the CSS3 draft, and is probably // incorrect, given the comments in that draft. static const UChar katakanaIrohaAlphabet[47] = { 0x30A4, 0x30ED, 0x30CF, 0x30CB, 0x30DB, 0x30D8, 0x30C8, 0x30C1, 0x30EA, 0x30CC, 0x30EB, 0x30F2, 0x30EF, 0x30AB, 0x30E8, 0x30BF, 0x30EC, 0x30BD, 0x30C4, 0x30CD, 0x30CA, 0x30E9, 0x30E0, 0x30A6, 0x30F0, 0x30CE, 0x30AA, 0x30AF, 0x30E4, 0x30DE, 0x30B1, 0x30D5, 0x30B3, 0x30A8, 0x30C6, 0x30A2, 0x30B5, 0x30AD, 0x30E6, 0x30E1, 0x30DF, 0x30B7, 0x30F1, 0x30D2, 0x30E2, 0x30BB, 0x30B9 }; return toAlphabetic(value, katakanaIrohaAlphabet, 47); } case CJK_IDEOGRAPHIC: { static const UChar traditionalChineseInformalTable[16] = { 0x842C, 0x5104, 0x5146, 0x5341, 0x767E, 0x5343, 0x96F6, 0x4E00, 0x4E8C, 0x4E09, 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D }; return toCJKIdeographic(value, traditionalChineseInformalTable); } case LOWER_ROMAN: return toRoman(value, false); case UPPER_ROMAN: return toRoman(value, true); case ARMENIAN: // CSS3 says "armenian" means "lower-armenian". // But the CSS2.1 test suite contains uppercase test results for "armenian", // so we'll match the test suite. return toArmenian(value, true); case GEORGIAN: return toGeorgian(value); case HEBREW: return toHebrew(value); } ASSERT_NOT_REACHED(); return "";}RenderListMarker::RenderListMarker(RenderListItem* item) : RenderBox(item->document()) , m_listItem(item){ // init RenderObject attributes setInline(true); // our object is Inline setReplaced(true); // pretend to be replaced}RenderListMarker::~RenderListMarker(){ if (m_image) m_image->removeClient(this);}void RenderListMarker::styleWillChange(StyleDifference diff, const RenderStyle* newStyle){ if (style() && (newStyle->listStylePosition() != style()->listStylePosition() || newStyle->listStyleType() != style()->listStyleType())) setNeedsLayoutAndPrefWidthsRecalc(); RenderBox::styleWillChange(diff, newStyle);}void RenderListMarker::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle){ RenderBox::styleDidChange(diff, oldStyle); if (m_image != style()->listStyleImage()) { if (m_image) m_image->removeClient(this); m_image = style()->listStyleImage(); if (m_image) m_image->addClient(this); }}InlineBox* RenderListMarker::createInlineBox(){ ListMarkerBox* box = new (renderArena()) ListMarkerBox(this); m_inlineBoxWrapper = box; return box;}bool RenderListMarker::isImage() const{ return m_image && !m_image->errorOccurred();}void RenderListMarker::paint(PaintInfo& paintInfo, int tx, int ty){ if (paintInfo.phase != PaintPhaseForeground) return; if (style()->visibility() != VISIBLE) return; IntRect marker = getRelativeMarkerRect(); marker.move(tx, ty); IntRect box(tx + x(), ty + y(), width(), height()); if (box.y() > paintInfo.rect.bottom() || box.y() + box.height() < paintInfo.rect.y()) return; if (hasBoxDecorations()) paintBoxDecorations(paintInfo, box.x(), box.y()); GraphicsContext* context = paintInfo.context; if (isImage()) {#if PLATFORM(MAC) if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled()) paintCustomHighlight(tx, ty, style()->highlight(), true);#endif context->drawImage(m_image->image(this, marker.size()), marker.location()); if (selectionState() != SelectionNone) { // FIXME: selectionRect() is in absolute, not painting coordinates. context->fillRect(selectionRect(), selectionBackgroundColor()); } return; }#if PLATFORM(MAC) // FIXME: paint gap between marker and list item proper if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled()) paintCustomHighlight(tx, ty, style()->highlight(), true);#endif if (selectionState() != SelectionNone) { // FIXME: selectionRect() is in absolute, not painting coordinates. context->fillRect(selectionRect(), selectionBackgroundColor()); } const Color color(style()->color()); context->setStrokeColor(color); context->setStrokeStyle(SolidStroke); context->setStrokeThickness(1.0f); context->setFillColor(color); switch (style()->listStyleType()) { case DISC: context->drawEllipse(marker); return; case CIRCLE: context->setFillColor(Color::transparent); context->drawEllipse(marker); return; case SQUARE: context->drawRect(marker); return; case LNONE: return; case ARMENIAN: case CJK_IDEOGRAPHIC: case DECIMAL_LEADING_ZERO: case GEORGIAN: case HEBREW: case HIRAGANA: case HIRAGANA_IROHA: case KATAKANA: case KATAKANA_IROHA: case LDECIMAL: case LOWER_ALPHA: case LOWER_GREEK: case LOWER_LATIN: case LOWER_ROMAN: case UPPER_ALPHA: case UPPER_LATIN: case UPPER_ROMAN: break; } if (m_text.isEmpty()) return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -