Changeset 205282 in webkit
- Timestamp:
- Sep 1, 2016 12:37:19 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r205280 r205282 1 2016-09-01 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Clean up TextRun-related code 4 https://bugs.webkit.org/show_bug.cgi?id=161473 5 6 Reviewed by Simon Fraser. 7 8 Some assorted cleanup, including: 9 - Renaming "AllowTrailingExpansion | ForbidLeadingExpansion" to "DefaultExpansion" 10 - Migrating from pointers to references 11 - Migrating from ints to unsigneds 12 - Using proper character names from CharacterNames.h 13 - Simplifying CoreTextSPI.h 14 15 No new tests because there is no behavior change. 16 17 * platform/graphics/TextRun.h: 18 (WebCore::TextRun::TextRun): 19 * platform/graphics/mac/ComplexTextController.cpp: 20 (WebCore::TextLayout::isNeeded): 21 (WebCore::TextLayout::constructTextRun): 22 * platform/spi/cocoa/CoreTextSPI.h: 23 * platform/text/TextFlags.h: 24 * rendering/RenderBlock.cpp: 25 (WebCore::RenderBlock::constructTextRun): 26 * rendering/RenderBlock.h: 27 * rendering/RenderListMarker.cpp: 28 (WebCore::RenderListMarker::computePreferredLogicalWidths): 29 (WebCore::RenderListMarker::getRelativeMarkerRect): 30 * rendering/RenderMenuList.cpp: 31 (RenderMenuList::updateOptionsWidth): 32 * rendering/RenderText.cpp: 33 (WebCore::RenderText::widthFromCache): 34 (WebCore::RenderText::trimmedPrefWidths): 35 (WebCore::hyphenWidth): 36 (WebCore::maxWordFragmentWidth): 37 (WebCore::RenderText::computePreferredLogicalWidths): 38 (WebCore::RenderText::width): 39 * rendering/RenderText.h: 40 * rendering/RenderThemeIOS.mm: 41 * rendering/line/BreakingContext.h: 42 (WebCore::textWidth): 43 (WebCore::tryHyphenating): 44 * rendering/svg/SVGInlineTextBox.cpp: 45 (WebCore::SVGInlineTextBox::offsetForPositionInFragment): 46 (WebCore::SVGInlineTextBox::selectionRectForTextFragment): 47 (WebCore::SVGInlineTextBox::localSelectionRect): 48 (WebCore::SVGInlineTextBox::paintSelectionBackground): 49 (WebCore::SVGInlineTextBox::paint): 50 (WebCore::SVGInlineTextBox::acquirePaintingResource): 51 (WebCore::SVGInlineTextBox::prepareGraphicsContextForTextPainting): 52 (WebCore::SVGInlineTextBox::constructTextRun): 53 (WebCore::SVGInlineTextBox::paintDecorationWithStyle): 54 (WebCore::SVGInlineTextBox::paintTextWithShadows): 55 (WebCore::SVGInlineTextBox::paintText): 56 * rendering/svg/SVGInlineTextBox.h: 57 1 58 2016-08-31 Carlos Garcia Campos <cgarcia@igalia.com> 2 59 -
trunk/Source/WebCore/platform/graphics/TextRun.h
r198074 r205282 46 46 WTF_MAKE_FAST_ALLOCATED; 47 47 public: 48 explicit TextRun(StringView text, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true)48 explicit TextRun(StringView text, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = DefaultExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true) 49 49 : m_text(text) 50 50 , m_charactersLength(text.length()) -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
r203042 r205282 52 52 static bool isNeeded(RenderText& text, const FontCascade& font) 53 53 { 54 TextRun run = RenderBlock::constructTextRun( &text, text.style());54 TextRun run = RenderBlock::constructTextRun(text, text.style()); 55 55 return font.codePath(run) == FontCascade::Complex; 56 56 } … … 77 77 static TextRun constructTextRun(RenderText& text, float xPos) 78 78 { 79 TextRun run = RenderBlock::constructTextRun( &text, text.style());79 TextRun run = RenderBlock::constructTextRun(text, text.style()); 80 80 run.setCharactersLength(text.textLength()); 81 81 ASSERT(run.charactersLength() >= run.length()); -
trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h
r204858 r205282 43 43 }; 44 44 45 typedef CF_OPTIONS(uint32_t, CTFontTransformOptions) 46 { 47 kCTFontTransformApplyShaping = (1 << 0), 48 kCTFontTransformApplyPositioning = (1 << 1) 49 }; 50 51 typedef CF_OPTIONS(uint32_t, CTFontDescriptorOptions) 52 { 53 kCTFontDescriptorOptionSystemUIFont = 1 << 1, 54 kCTFontDescriptorOptionPreferAppleSystemFont = kCTFontOptionsPreferSystemFont 55 }; 56 45 57 #endif 46 58 … … 53 65 extern const CFStringRef kCTFontOpticalSizeAttribute; 54 66 55 #if PLATFORM(COCOA)56 #if !USE(APPLE_INTERNAL_SDK)57 typedef CF_OPTIONS(uint32_t, CTFontTransformOptions)58 {59 kCTFontTransformApplyShaping = (1 << 0),60 kCTFontTransformApplyPositioning = (1 << 1)61 };62 #endif63 67 bool CTFontTransformGlyphs(CTFontRef, CGGlyph glyphs[], CGSize advances[], CFIndex count, CTFontTransformOptions); 64 #endif65 68 66 69 CGSize CTRunGetInitialAdvance(CTRunRef run); … … 74 77 CFBitVectorRef CTFontCopyGlyphCoverageForFeature(CTFontRef, CFDictionaryRef feature); 75 78 76 #if PLATFORM(COCOA)77 #if !USE(APPLE_INTERNAL_SDK)78 typedef CF_OPTIONS(uint32_t, CTFontDescriptorOptions)79 {80 kCTFontDescriptorOptionSystemUIFont = 1 << 1,81 kCTFontDescriptorOptionPreferAppleSystemFont = kCTFontOptionsPreferSystemFont82 };83 84 79 CTFontDescriptorRef CTFontDescriptorCreateWithAttributesAndOptions(CFDictionaryRef attributes, CTFontDescriptorOptions); 85 80 86 81 extern const CFStringRef kCTFontDescriptorTextStyleAttribute; 87 82 extern const CFStringRef kCTFontUIFontDesignTrait; 88 #endif89 #endif90 83 91 84 bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef); … … 93 86 CTFontRef CTFontCreateForCharactersWithLanguage(CTFontRef currentFont, const UTF16Char *characters, CFIndex length, CFStringRef language, CFIndex *coveredLength); 94 87 95 #if PLATFORM(COCOA)96 88 extern const CFStringRef kCTUIFontTextStyleShortHeadline; 97 89 extern const CFStringRef kCTUIFontTextStyleShortBody; … … 119 111 extern const CGFloat kCTFontWeightHeavy; 120 112 extern const CGFloat kCTFontWeightBlack; 121 #endif122 113 123 #if PLATFORM(IOS)124 114 extern const CFStringRef kCTUIFontTextStyleTitle1; 125 115 extern const CFStringRef kCTUIFontTextStyleTitle2; 126 116 extern const CFStringRef kCTUIFontTextStyleTitle3; 127 117 CTFontDescriptorRef CTFontCreatePhysicalFontDescriptorForCharactersWithLanguage(CTFontRef currentFont, const UTF16Char* characters, CFIndex length, CFStringRef language, CFIndex* coveredLength); 128 #endif129 118 130 119 CTFontRef CTFontCreatePhysicalFontForCharactersWithLanguage(CTFontRef, const UTF16Char* characters, CFIndex length, CFStringRef language, CFIndex* coveredLength); -
trunk/Source/WebCore/platform/text/TextFlags.h
r196969 r205282 53 53 ForceLeadingExpansion = 2 << 2, 54 54 LeadingExpansionMask = 3 << 2, 55 56 DefaultExpansion = AllowTrailingExpansion | ForbidLeadingExpansion, 55 57 }; 56 58 typedef unsigned ExpansionBehavior; -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r204400 r205282 3802 3802 } 3803 3803 3804 TextRun RenderBlock::constructTextRun(const RenderText *text, const RenderStyle& style, ExpansionBehavior expansion)3805 { 3806 return constructTextRun(text ->stringView(), style, expansion);3807 } 3808 3809 TextRun RenderBlock::constructTextRun(const RenderText *text, unsigned offset, unsigned length, const RenderStyle& style, ExpansionBehavior expansion)3804 TextRun RenderBlock::constructTextRun(const RenderText& text, const RenderStyle& style, ExpansionBehavior expansion) 3805 { 3806 return constructTextRun(text.stringView(), style, expansion); 3807 } 3808 3809 TextRun RenderBlock::constructTextRun(const RenderText& text, unsigned offset, unsigned length, const RenderStyle& style, ExpansionBehavior expansion) 3810 3810 { 3811 3811 unsigned stop = offset + length; 3812 ASSERT(stop <= text ->textLength());3813 return constructTextRun(text ->stringView(offset, stop), style, expansion);3814 } 3815 3816 TextRun RenderBlock::constructTextRun(const LChar* characters, intlength, const RenderStyle& style, ExpansionBehavior expansion)3812 ASSERT(stop <= text.textLength()); 3813 return constructTextRun(text.stringView(offset, stop), style, expansion); 3814 } 3815 3816 TextRun RenderBlock::constructTextRun(const LChar* characters, unsigned length, const RenderStyle& style, ExpansionBehavior expansion) 3817 3817 { 3818 3818 return constructTextRun(StringView(characters, length), style, expansion); 3819 3819 } 3820 3820 3821 TextRun RenderBlock::constructTextRun(const UChar* characters, intlength, const RenderStyle& style, ExpansionBehavior expansion)3821 TextRun RenderBlock::constructTextRun(const UChar* characters, unsigned length, const RenderStyle& style, ExpansionBehavior expansion) 3822 3822 { 3823 3823 return constructTextRun(StringView(characters, length), style, expansion); -
trunk/Source/WebCore/rendering/RenderBlock.h
r204908 r205282 205 205 206 206 static TextRun constructTextRun(StringView, const RenderStyle&, 207 ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextRunFlags = DefaultTextRunFlags);207 ExpansionBehavior = DefaultExpansion, TextRunFlags = DefaultTextRunFlags); 208 208 static TextRun constructTextRun(const String&, const RenderStyle&, 209 ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextRunFlags = DefaultTextRunFlags);210 static TextRun constructTextRun(const RenderText *, const RenderStyle&,211 ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion);212 static TextRun constructTextRun(const RenderText *, unsigned offset, unsigned length, const RenderStyle&,213 ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion);214 static TextRun constructTextRun(const LChar* characters, intlength, const RenderStyle&,215 ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion);216 static TextRun constructTextRun(const UChar* characters, intlength, const RenderStyle&,217 ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion);209 ExpansionBehavior = DefaultExpansion, TextRunFlags = DefaultTextRunFlags); 210 static TextRun constructTextRun(const RenderText&, const RenderStyle&, 211 ExpansionBehavior = DefaultExpansion); 212 static TextRun constructTextRun(const RenderText&, unsigned offset, unsigned length, const RenderStyle&, 213 ExpansionBehavior = DefaultExpansion); 214 static TextRun constructTextRun(const LChar* characters, unsigned length, const RenderStyle&, 215 ExpansionBehavior = DefaultExpansion); 216 static TextRun constructTextRun(const UChar* characters, unsigned length, const RenderStyle&, 217 ExpansionBehavior = DefaultExpansion); 218 218 219 219 LayoutUnit paginationStrut() const; -
trunk/Source/WebCore/rendering/RenderListMarker.cpp
r203250 r205282 1544 1544 case Asterisks: 1545 1545 case Footnotes: { 1546 TextRun run = RenderBlock::constructTextRun(m_text, style() , AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);1546 TextRun run = RenderBlock::constructTextRun(m_text, style()); 1547 1547 logicalWidth = font.width(run); // no suffix for these types 1548 1548 } … … 1631 1631 logicalWidth = 0; 1632 1632 else { 1633 TextRun run = RenderBlock::constructTextRun(m_text, style() , AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);1633 TextRun run = RenderBlock::constructTextRun(m_text, style()); 1634 1634 LayoutUnit itemWidth = font.width(run); 1635 1635 UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' }; … … 1764 1764 case Footnotes: { 1765 1765 const FontCascade& font = style().fontCascade(); 1766 TextRun run = RenderBlock::constructTextRun(m_text, style() , AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);1766 TextRun run = RenderBlock::constructTextRun(m_text, style()); 1767 1767 relativeRect = FloatRect(0, 0, font.width(run), font.fontMetrics().height()); 1768 1768 break; … … 1858 1858 return FloatRect(); 1859 1859 const FontCascade& font = style().fontCascade(); 1860 TextRun run = RenderBlock::constructTextRun(m_text, style() , AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);1860 TextRun run = RenderBlock::constructTextRun(m_text, style()); 1861 1861 float itemWidth = font.width(run); 1862 1862 UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' }; -
trunk/Source/WebCore/rendering/RenderMenuList.cpp
r203324 r205282 220 220 if (!text.isEmpty()) { 221 221 const FontCascade& font = style().fontCascade(); 222 TextRun run = RenderBlock::constructTextRun(text, style() , AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);222 TextRun run = RenderBlock::constructTextRun(text, style()); 223 223 optionWidth += font.width(run); 224 224 } … … 226 226 } else if (!text.isEmpty()) { 227 227 const FontCascade& font = style().fontCascade(); 228 TextRun run = RenderBlock::constructTextRun(text, style() , AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);228 TextRun run = RenderBlock::constructTextRun(text, style()); 229 229 maxOptionWidth = std::max(maxOptionWidth, font.width(run)); 230 230 } -
trunk/Source/WebCore/rendering/RenderText.cpp
r205011 r205282 453 453 } 454 454 455 ALWAYS_INLINE float RenderText::widthFromCache(const FontCascade& f, int start, intlen, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow, const RenderStyle& style) const455 ALWAYS_INLINE float RenderText::widthFromCache(const FontCascade& f, unsigned start, unsigned len, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow, const RenderStyle& style) const 456 456 { 457 457 if (style.hasTextCombine() && is<RenderCombineText>(*this)) { … … 467 467 ASSERT(m_text); 468 468 StringImpl& text = *m_text.impl(); 469 for ( inti = start; i < start + len; i++) {469 for (unsigned i = start; i < start + len; i++) { 470 470 char c = text[i]; 471 471 if (c <= ' ') { … … 493 493 } 494 494 495 TextRun run = RenderBlock::constructTextRun( this, start, len, style);495 TextRun run = RenderBlock::constructTextRun(*this, start, len, style); 496 496 run.setCharactersLength(textLength() - start); 497 497 ASSERT(run.charactersLength() >= run.length()); … … 609 609 endWS = m_hasEndWS; 610 610 611 intlen = textLength();611 unsigned len = textLength(); 612 612 613 613 if (!len || (stripFrontSpaces && text()->containsOnlyWhitespace())) { … … 633 633 ASSERT(m_text); 634 634 StringImpl& text = *m_text.impl(); 635 if (text[0] == ' ' || (text[0] == '\n'&& !style.preserveNewline()) || text[0] == '\t') {635 if (text[0] == space || (text[0] == newlineCharacter && !style.preserveNewline()) || text[0] == '\t') { 636 636 const FontCascade& font = style.fontCascade(); // FIXME: This ignores first-line. 637 637 if (stripFrontSpaces) { 638 const UChar space = ' ';639 638 float spaceWidth = font.width(RenderBlock::constructTextRun(&space, 1, style)); 640 639 maxW -= spaceWidth; … … 654 653 beginMaxW = maxW; 655 654 endMaxW = maxW; 656 for ( inti = 0; i < len; i++) {657 intlinelen = 0;655 for (unsigned i = 0; i < len; i++) { 656 unsigned linelen = 0; 658 657 while (i + linelen < len && text[i + linelen] != '\n') 659 658 linelen++; … … 727 726 } 728 727 729 static inline float hyphenWidth(RenderText* renderer, const FontCascade& font) 730 { 731 const RenderStyle& style = renderer->style(); 732 return font.width(RenderBlock::constructTextRun(style.hyphenString().string(), style)); 733 } 734 735 static float maxWordFragmentWidth(RenderText* renderer, const RenderStyle& style, const FontCascade& font, StringView word, int minimumPrefixLength, unsigned minimumSuffixLength, int& suffixStart, HashSet<const Font*>& fallbackFonts, GlyphOverflow& glyphOverflow) 728 static inline float hyphenWidth(RenderText& renderer, const FontCascade& font) 729 { 730 const RenderStyle& style = renderer.style(); 731 auto textRun = RenderBlock::constructTextRun(style.hyphenString().string(), style); 732 return font.width(textRun); 733 } 734 735 static float maxWordFragmentWidth(RenderText& renderer, const RenderStyle& style, const FontCascade& font, StringView word, unsigned minimumPrefixLength, unsigned minimumSuffixLength, unsigned& suffixStart, HashSet<const Font*>& fallbackFonts, GlyphOverflow& glyphOverflow) 736 736 { 737 737 suffixStart = 0; … … 740 740 741 741 Vector<int, 8> hyphenLocations; 742 int hyphenLocation = word.length() - minimumSuffixLength; 742 ASSERT(word.length() >= minimumSuffixLength); 743 unsigned hyphenLocation = word.length() - minimumSuffixLength; 743 744 while ((hyphenLocation = lastHyphenLocation(word, hyphenLocation, style.locale())) >= minimumPrefixLength) 744 745 hyphenLocations.append(hyphenLocation); … … 759 760 TextRun run = RenderBlock::constructTextRun(fragmentWithHyphen.toString(), style); 760 761 run.setCharactersLength(fragmentWithHyphen.length()); 761 run.setCharacterScanForCodePath(!renderer ->canUseSimpleFontCodePath());762 run.setCharacterScanForCodePath(!renderer.canUseSimpleFontCodePath()); 762 763 float fragmentWidth = font.width(run, &fallbackFonts, &glyphOverflow); 763 764 … … 808 809 // fragment) encountered so far, and only try hyphenating words that are wider. 809 810 float maxWordWidth = std::numeric_limits<float>::max(); 810 intminimumPrefixLength = 0;811 intminimumSuffixLength = 0;811 unsigned minimumPrefixLength = 0; 812 unsigned minimumSuffixLength = 0; 812 813 if (style.hyphens() == HyphensAuto && canHyphenate(style.locale())) { 813 814 maxWordWidth = 0; 814 815 815 816 // Map 'hyphenate-limit-{before,after}: auto;' to 2. 816 minimumPrefixLength = style.hyphenationLimitBefore(); 817 if (minimumPrefixLength < 0) 818 minimumPrefixLength = 2; 819 820 minimumSuffixLength = style.hyphenationLimitAfter(); 821 if (minimumSuffixLength < 0) 822 minimumSuffixLength = 2; 817 auto before = style.hyphenationLimitBefore(); 818 minimumPrefixLength = before < 0 ? 2 : before; 819 820 auto after = style.hyphenationLimitAfter(); 821 minimumSuffixLength = after < 0 ? 2 : after; 823 822 } 824 823 … … 907 906 w = widthFromCache(font, i, wordLen, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style); 908 907 if (c == softHyphen && style.hyphens() != HyphensNone) 909 currMinWidth = hyphenWidth( this, font);908 currMinWidth = hyphenWidth(*this, font); 910 909 } 911 910 912 911 if (w > maxWordWidth) { 913 intsuffixStart;914 float maxFragmentWidth = maxWordFragmentWidth( this, style, font, StringView(m_text).substring(i, wordLen), minimumPrefixLength, minimumSuffixLength, suffixStart, fallbackFonts, glyphOverflow);912 unsigned suffixStart; 913 float maxFragmentWidth = maxWordFragmentWidth(*this, style, font, StringView(m_text).substring(i, wordLen), minimumPrefixLength, minimumSuffixLength, suffixStart, fallbackFonts, glyphOverflow); 915 914 916 915 if (suffixStart) { … … 986 985 currMaxWidth = 0; 987 986 } else { 988 TextRun run = RenderBlock::constructTextRun( this, i, 1, style);987 TextRun run = RenderBlock::constructTextRun(*this, i, 1, style); 989 988 run.setCharactersLength(len - i); 990 989 ASSERT(run.charactersLength() >= run.length()); … … 1326 1325 w = widthFromCache(f, from, len, xPos, fallbackFonts, glyphOverflow, style); 1327 1326 } else { 1328 TextRun run = RenderBlock::constructTextRun( this, from, len, style);1327 TextRun run = RenderBlock::constructTextRun(*this, from, len, style); 1329 1328 run.setCharactersLength(textLength() - from); 1330 1329 ASSERT(run.charactersLength() >= run.length()); -
trunk/Source/WebCore/rendering/RenderText.h
r204653 r205282 197 197 bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, HitTestAction) final { ASSERT_NOT_REACHED(); return false; } 198 198 199 float widthFromCache(const FontCascade&, int start, intlen, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow*, const RenderStyle&) const;199 float widthFromCache(const FontCascade&, unsigned start, unsigned len, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow*, const RenderStyle&) const; 200 200 bool isAllASCII() const { return m_isAllASCII; } 201 201 bool computeUseBackslashAsYenSymbol() const; -
trunk/Source/WebCore/rendering/RenderThemeIOS.mm
r204858 r205282 576 576 float measureText(const String& string) const override 577 577 { 578 TextRun run = RenderBlock::constructTextRun(string, m_style , AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);578 TextRun run = RenderBlock::constructTextRun(string, m_style); 579 579 return m_font.width(run); 580 580 } -
trunk/Source/WebCore/rendering/line/BreakingContext.h
r204654 r205282 645 645 return FontCascade::width(*layout, from, len, &fallbackFonts); 646 646 647 TextRun run = RenderBlock::constructTextRun( &text, from, len, style);647 TextRun run = RenderBlock::constructTextRun(text, from, len, style); 648 648 run.setCharactersLength(text.textLength() - from); 649 649 ASSERT(run.charactersLength() >= run.length()); … … 694 694 695 695 const RenderStyle& style = text.style(); 696 TextRun run = RenderBlock::constructTextRun( &text, lastSpace, pos - lastSpace, style);696 TextRun run = RenderBlock::constructTextRun(text, lastSpace, pos - lastSpace, style); 697 697 run.setCharactersLength(text.textLength() - lastSpace); 698 698 ASSERT(run.charactersLength() >= run.length()); -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
r204400 r205282 89 89 ASSERT(scalingFactor); 90 90 91 TextRun textRun = constructTextRun( &renderer().style(), fragment);91 TextRun textRun = constructTextRun(renderer().style(), fragment); 92 92 93 93 // Eventually handle lengthAdjust="spacingAndGlyphs". … … 108 108 } 109 109 110 FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition, const RenderStyle *style) const110 FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition, const RenderStyle& style) const 111 111 { 112 112 ASSERT_WITH_SECURITY_IMPLICATION(startPosition < endPosition); 113 ASSERT(style);114 113 115 114 float scalingFactor = renderer().scalingFactor(); … … 158 157 continue; 159 158 160 FloatRect fragmentRect = selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, &style);159 FloatRect fragmentRect = selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, style); 161 160 fragment.buildFragmentTransform(fragmentTransform); 162 161 if (!fragmentTransform.isIdentity()) … … 226 225 227 226 paintInfo.context().setFillColor(backgroundColor); 228 paintInfo.context().fillRect(selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, &style), backgroundColor);227 paintInfo.context().fillRect(selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, style), backgroundColor); 229 228 230 229 m_paintingResourceMode = ApplyToDefaultMode; … … 307 306 continue; 308 307 m_paintingResourceMode = ApplyToFillMode | ApplyToTextMode; 309 paintText(paintInfo.context(), &style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly); 308 ASSERT(selectionStyle); 309 paintText(paintInfo.context(), style, *selectionStyle, fragment, hasSelection, paintSelectedTextOnly); 310 310 break; 311 311 case PaintTypeStroke: … … 313 313 continue; 314 314 m_paintingResourceMode = ApplyToStrokeMode | ApplyToTextMode; 315 paintText(paintInfo.context(), &style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly); 315 ASSERT(selectionStyle); 316 paintText(paintInfo.context(), style, *selectionStyle, fragment, hasSelection, paintSelectedTextOnly); 316 317 break; 317 318 case PaintTypeMarkers: … … 334 335 } 335 336 336 bool SVGInlineTextBox::acquirePaintingResource(GraphicsContext*& context, float scalingFactor, RenderBoxModelObject& renderer, const RenderStyle *style)337 bool SVGInlineTextBox::acquirePaintingResource(GraphicsContext*& context, float scalingFactor, RenderBoxModelObject& renderer, const RenderStyle& style) 337 338 { 338 339 ASSERT(scalingFactor); 339 ASSERT(style);340 340 ASSERT(m_paintingResourceMode != ApplyToDefaultMode); 341 341 342 342 Color fallbackColor; 343 343 if (m_paintingResourceMode & ApplyToFillMode) 344 m_paintingResource = RenderSVGResource::fillPaintingResource(renderer, *style, fallbackColor);344 m_paintingResource = RenderSVGResource::fillPaintingResource(renderer, style, fallbackColor); 345 345 else if (m_paintingResourceMode & ApplyToStrokeMode) 346 m_paintingResource = RenderSVGResource::strokePaintingResource(renderer, *style, fallbackColor);346 m_paintingResource = RenderSVGResource::strokePaintingResource(renderer, style, fallbackColor); 347 347 else { 348 348 // We're either called for stroking or filling. … … 353 353 return false; 354 354 355 if (!m_paintingResource->applyResource(renderer, *style, context, m_paintingResourceMode)) {355 if (!m_paintingResource->applyResource(renderer, style, context, m_paintingResourceMode)) { 356 356 if (fallbackColor.isValid()) { 357 357 RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource(); … … 359 359 360 360 m_paintingResource = fallbackResource; 361 m_paintingResource->applyResource(renderer, *style, context, m_paintingResourceMode);361 m_paintingResource->applyResource(renderer, style, context, m_paintingResourceMode); 362 362 } 363 363 } … … 377 377 } 378 378 379 bool SVGInlineTextBox::prepareGraphicsContextForTextPainting(GraphicsContext*& context, float scalingFactor, const RenderStyle *style)379 bool SVGInlineTextBox::prepareGraphicsContextForTextPainting(GraphicsContext*& context, float scalingFactor, const RenderStyle& style) 380 380 { 381 381 return acquirePaintingResource(context, scalingFactor, parent()->renderer(), style); … … 387 387 } 388 388 389 TextRun SVGInlineTextBox::constructTextRun(const RenderStyle* style, const SVGTextFragment& fragment) const 390 { 391 ASSERT(style); 392 389 TextRun SVGInlineTextBox::constructTextRun(const RenderStyle& style, const SVGTextFragment& fragment) const 390 { 393 391 TextRun run(StringView(renderer().text()).substring(fragment.characterOffset, fragment.length) 394 392 , 0 /* xPos, only relevant with allowTabs=true */ … … 396 394 , AllowTrailingExpansion 397 395 , direction() 398 , dirOverride() || style ->rtlOrdering() == VisualOrder /* directionalOverride */);396 , dirOverride() || style.rtlOrdering() == VisualOrder /* directionalOverride */); 399 397 400 398 // We handle letter & word spacing ourselves. … … 539 537 540 538 GraphicsContext* contextPtr = &context; 541 if (acquirePaintingResource(contextPtr, scalingFactor, decorationRenderer, &decorationStyle))539 if (acquirePaintingResource(contextPtr, scalingFactor, decorationRenderer, decorationStyle)) 542 540 releasePaintingResource(contextPtr, &path); 543 541 } 544 542 545 void SVGInlineTextBox::paintTextWithShadows(GraphicsContext& context, const RenderStyle *style, TextRun& textRun, const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition)543 void SVGInlineTextBox::paintTextWithShadows(GraphicsContext& context, const RenderStyle& style, TextRun& textRun, const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition) 546 544 { 547 545 float scalingFactor = renderer().scalingFactor(); … … 549 547 550 548 const FontCascade& scaledFont = renderer().scaledFont(); 551 const ShadowData* shadow = style ->textShadow();549 const ShadowData* shadow = style.textShadow(); 552 550 553 551 FloatPoint textOrigin(fragment.x, fragment.y); … … 588 586 } 589 587 590 void SVGInlineTextBox::paintText(GraphicsContext& context, const RenderStyle* style, const RenderStyle* selectionStyle, const SVGTextFragment& fragment, bool hasSelection, bool paintSelectedTextOnly) 591 { 592 ASSERT(style); 593 ASSERT(selectionStyle); 594 588 void SVGInlineTextBox::paintText(GraphicsContext& context, const RenderStyle& style, const RenderStyle& selectionStyle, const SVGTextFragment& fragment, bool hasSelection, bool paintSelectedTextOnly) 589 { 595 590 unsigned startPosition = 0; 596 591 unsigned endPosition = 0; … … 613 608 // Draw text using selection style from the start to the end position of the selection 614 609 if (style != selectionStyle) 615 SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, *selectionStyle);610 SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, selectionStyle); 616 611 617 612 paintTextWithShadows(context, selectionStyle, textRun, fragment, startPosition, endPosition); 618 613 619 614 if (style != selectionStyle) 620 SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, *style);615 SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, style); 621 616 622 617 // Eventually draw text using regular style from the end position of the selection to the end of the current chunk part -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h
r204400 r205282 65 65 66 66 int offsetForPositionInFragment(const SVGTextFragment&, float position, bool includePartialGlyphs) const; 67 FloatRect selectionRectForTextFragment(const SVGTextFragment&, unsigned fragmentStartPosition, unsigned fragmentEndPosition, const RenderStyle *) const;67 FloatRect selectionRectForTextFragment(const SVGTextFragment&, unsigned fragmentStartPosition, unsigned fragmentEndPosition, const RenderStyle&) const; 68 68 69 69 private: 70 70 bool isSVGInlineTextBox() const override { return true; } 71 71 72 TextRun constructTextRun(const RenderStyle *, const SVGTextFragment&) const;72 TextRun constructTextRun(const RenderStyle&, const SVGTextFragment&) const; 73 73 74 bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderBoxModelObject&, const RenderStyle *);74 bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderBoxModelObject&, const RenderStyle&); 75 75 void releasePaintingResource(GraphicsContext*&, const Path*); 76 76 77 bool prepareGraphicsContextForTextPainting(GraphicsContext*&, float scalingFactor, const RenderStyle *);77 bool prepareGraphicsContextForTextPainting(GraphicsContext*&, float scalingFactor, const RenderStyle&); 78 78 void restoreGraphicsContextAfterTextPainting(GraphicsContext*&); 79 79 80 80 void paintDecoration(GraphicsContext&, TextDecoration, const SVGTextFragment&); 81 81 void paintDecorationWithStyle(GraphicsContext&, TextDecoration, const SVGTextFragment&, RenderBoxModelObject& decorationRenderer); 82 void paintTextWithShadows(GraphicsContext&, const RenderStyle *, TextRun&, const SVGTextFragment&, unsigned startPosition, unsigned endPosition);83 void paintText(GraphicsContext&, const RenderStyle *, const RenderStyle*selectionStyle, const SVGTextFragment&, bool hasSelection, bool paintSelectedTextOnly);82 void paintTextWithShadows(GraphicsContext&, const RenderStyle&, TextRun&, const SVGTextFragment&, unsigned startPosition, unsigned endPosition); 83 void paintText(GraphicsContext&, const RenderStyle&, const RenderStyle& selectionStyle, const SVGTextFragment&, bool hasSelection, bool paintSelectedTextOnly); 84 84 85 85 bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction) override; -
trunk/Source/WebKit/mac/ChangeLog
r205275 r205282 1 2016-09-01 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Clean up TextRun-related code 4 https://bugs.webkit.org/show_bug.cgi?id=161473 5 6 Reviewed by Simon Fraser. 7 8 Remove unused #includes. 9 10 * WebCoreSupport/WebDragClient.mm: 11 * WebView/WebView.mm: 12 1 13 2016-08-31 Keith Rollin <krollin@apple.com> 2 14 -
trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm
r181760 r205282 39 39 #import "WebNSPasteboardExtras.h" 40 40 #import "WebNSURLExtras.h" 41 #import "WebStringTruncator.h"42 41 #import "WebUIDelegate.h" 43 42 #import "WebUIDelegatePrivate.h" -
trunk/Source/WebKit/mac/WebView/WebView.mm
r205275 r205282 262 262 #import <WebCore/SQLiteDatabaseTracker.h> 263 263 #import <WebCore/SmartReplace.h> 264 #import <WebCore/TextRun.h>265 264 #import <WebCore/TileControllerMemoryHandlerIOS.h> 266 265 #import <WebCore/WAKWindow.h>
Note: See TracChangeset
for help on using the changeset viewer.