Changeset 205282 in webkit


Ignore:
Timestamp:
Sep 1, 2016 12:37:19 AM (8 years ago)
Author:
mmaxfield@apple.com
Message:

Clean up TextRun-related code
https://bugs.webkit.org/show_bug.cgi?id=161473

Reviewed by Simon Fraser.

Source/WebCore:

Some assorted cleanup, including:

  • Renaming "AllowTrailingExpansion | ForbidLeadingExpansion" to "DefaultExpansion"
  • Migrating from pointers to references
  • Migrating from ints to unsigneds
  • Using proper character names from CharacterNames.h
  • Simplifying CoreTextSPI.h

No new tests because there is no behavior change.

  • platform/graphics/TextRun.h:

(WebCore::TextRun::TextRun):

  • platform/graphics/mac/ComplexTextController.cpp:

(WebCore::TextLayout::isNeeded):
(WebCore::TextLayout::constructTextRun):

  • platform/spi/cocoa/CoreTextSPI.h:
  • platform/text/TextFlags.h:
  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::constructTextRun):

  • rendering/RenderBlock.h:
  • rendering/RenderListMarker.cpp:

(WebCore::RenderListMarker::computePreferredLogicalWidths):
(WebCore::RenderListMarker::getRelativeMarkerRect):

  • rendering/RenderMenuList.cpp:

(RenderMenuList::updateOptionsWidth):

  • rendering/RenderText.cpp:

(WebCore::RenderText::widthFromCache):
(WebCore::RenderText::trimmedPrefWidths):
(WebCore::hyphenWidth):
(WebCore::maxWordFragmentWidth):
(WebCore::RenderText::computePreferredLogicalWidths):
(WebCore::RenderText::width):

  • rendering/RenderText.h:
  • rendering/RenderThemeIOS.mm:
  • rendering/line/BreakingContext.h:

(WebCore::textWidth):
(WebCore::tryHyphenating):

  • rendering/svg/SVGInlineTextBox.cpp:

(WebCore::SVGInlineTextBox::offsetForPositionInFragment):
(WebCore::SVGInlineTextBox::selectionRectForTextFragment):
(WebCore::SVGInlineTextBox::localSelectionRect):
(WebCore::SVGInlineTextBox::paintSelectionBackground):
(WebCore::SVGInlineTextBox::paint):
(WebCore::SVGInlineTextBox::acquirePaintingResource):
(WebCore::SVGInlineTextBox::prepareGraphicsContextForTextPainting):
(WebCore::SVGInlineTextBox::constructTextRun):
(WebCore::SVGInlineTextBox::paintDecorationWithStyle):
(WebCore::SVGInlineTextBox::paintTextWithShadows):
(WebCore::SVGInlineTextBox::paintText):

  • rendering/svg/SVGInlineTextBox.h:

Source/WebKit/mac:

Remove unused #includes.

  • WebCoreSupport/WebDragClient.mm:
  • WebView/WebView.mm:
Location:
trunk/Source
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r205280 r205282  
     12016-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
    1582016-08-31  Carlos Garcia Campos  <cgarcia@igalia.com>
    259
  • trunk/Source/WebCore/platform/graphics/TextRun.h

    r198074 r205282  
    4646    WTF_MAKE_FAST_ALLOCATED;
    4747public:
    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)
    4949        : m_text(text)
    5050        , m_charactersLength(text.length())
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp

    r203042 r205282  
    5252    static bool isNeeded(RenderText& text, const FontCascade& font)
    5353    {
    54         TextRun run = RenderBlock::constructTextRun(&text, text.style());
     54        TextRun run = RenderBlock::constructTextRun(text, text.style());
    5555        return font.codePath(run) == FontCascade::Complex;
    5656    }
     
    7777    static TextRun constructTextRun(RenderText& text, float xPos)
    7878    {
    79         TextRun run = RenderBlock::constructTextRun(&text, text.style());
     79        TextRun run = RenderBlock::constructTextRun(text, text.style());
    8080        run.setCharactersLength(text.textLength());
    8181        ASSERT(run.charactersLength() >= run.length());
  • trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h

    r204858 r205282  
    4343};
    4444
     45typedef CF_OPTIONS(uint32_t, CTFontTransformOptions)
     46{
     47    kCTFontTransformApplyShaping = (1 << 0),
     48    kCTFontTransformApplyPositioning = (1 << 1)
     49};
     50
     51typedef CF_OPTIONS(uint32_t, CTFontDescriptorOptions)
     52{
     53    kCTFontDescriptorOptionSystemUIFont = 1 << 1,
     54    kCTFontDescriptorOptionPreferAppleSystemFont = kCTFontOptionsPreferSystemFont
     55};
     56
    4557#endif
    4658
     
    5365extern const CFStringRef kCTFontOpticalSizeAttribute;
    5466
    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 #endif
    6367bool CTFontTransformGlyphs(CTFontRef, CGGlyph glyphs[], CGSize advances[], CFIndex count, CTFontTransformOptions);
    64 #endif
    6568
    6669CGSize CTRunGetInitialAdvance(CTRunRef run);
     
    7477CFBitVectorRef CTFontCopyGlyphCoverageForFeature(CTFontRef, CFDictionaryRef feature);
    7578
    76 #if PLATFORM(COCOA)
    77 #if !USE(APPLE_INTERNAL_SDK)
    78 typedef CF_OPTIONS(uint32_t, CTFontDescriptorOptions)
    79 {
    80     kCTFontDescriptorOptionSystemUIFont = 1 << 1,
    81     kCTFontDescriptorOptionPreferAppleSystemFont = kCTFontOptionsPreferSystemFont
    82 };
    83 
    8479CTFontDescriptorRef CTFontDescriptorCreateWithAttributesAndOptions(CFDictionaryRef attributes, CTFontDescriptorOptions);
    8580
    8681extern const CFStringRef kCTFontDescriptorTextStyleAttribute;
    8782extern const CFStringRef kCTFontUIFontDesignTrait;
    88 #endif
    89 #endif
    9083
    9184bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
     
    9386CTFontRef CTFontCreateForCharactersWithLanguage(CTFontRef currentFont, const UTF16Char *characters, CFIndex length, CFStringRef language, CFIndex *coveredLength);
    9487
    95 #if PLATFORM(COCOA)
    9688extern const CFStringRef kCTUIFontTextStyleShortHeadline;
    9789extern const CFStringRef kCTUIFontTextStyleShortBody;
     
    119111extern const CGFloat kCTFontWeightHeavy;
    120112extern const CGFloat kCTFontWeightBlack;
    121 #endif
    122113
    123 #if PLATFORM(IOS)
    124114extern const CFStringRef kCTUIFontTextStyleTitle1;
    125115extern const CFStringRef kCTUIFontTextStyleTitle2;
    126116extern const CFStringRef kCTUIFontTextStyleTitle3;
    127117CTFontDescriptorRef CTFontCreatePhysicalFontDescriptorForCharactersWithLanguage(CTFontRef currentFont, const UTF16Char* characters, CFIndex length, CFStringRef language, CFIndex* coveredLength);
    128 #endif
    129118
    130119CTFontRef CTFontCreatePhysicalFontForCharactersWithLanguage(CTFontRef, const UTF16Char* characters, CFIndex length, CFStringRef language, CFIndex* coveredLength);
  • trunk/Source/WebCore/platform/text/TextFlags.h

    r196969 r205282  
    5353    ForceLeadingExpansion = 2 << 2,
    5454    LeadingExpansionMask = 3 << 2,
     55
     56    DefaultExpansion = AllowTrailingExpansion | ForbidLeadingExpansion,
    5557};
    5658typedef unsigned ExpansionBehavior;
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r204400 r205282  
    38023802}
    38033803
    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)
     3804TextRun RenderBlock::constructTextRun(const RenderText& text, const RenderStyle& style, ExpansionBehavior expansion)
     3805{
     3806    return constructTextRun(text.stringView(), style, expansion);
     3807}
     3808
     3809TextRun RenderBlock::constructTextRun(const RenderText& text, unsigned offset, unsigned length, const RenderStyle& style, ExpansionBehavior expansion)
    38103810{
    38113811    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, int length, const RenderStyle& style, ExpansionBehavior expansion)
     3812    ASSERT(stop <= text.textLength());
     3813    return constructTextRun(text.stringView(offset, stop), style, expansion);
     3814}
     3815
     3816TextRun RenderBlock::constructTextRun(const LChar* characters, unsigned length, const RenderStyle& style, ExpansionBehavior expansion)
    38173817{
    38183818    return constructTextRun(StringView(characters, length), style, expansion);
    38193819}
    38203820
    3821 TextRun RenderBlock::constructTextRun(const UChar* characters, int length, const RenderStyle& style, ExpansionBehavior expansion)
     3821TextRun RenderBlock::constructTextRun(const UChar* characters, unsigned length, const RenderStyle& style, ExpansionBehavior expansion)
    38223822{
    38233823    return constructTextRun(StringView(characters, length), style, expansion);
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r204908 r205282  
    205205
    206206    static TextRun constructTextRun(StringView, const RenderStyle&,
    207         ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextRunFlags = DefaultTextRunFlags);
     207        ExpansionBehavior = DefaultExpansion, TextRunFlags = DefaultTextRunFlags);
    208208    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, int length, const RenderStyle&,
    215         ExpansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion);
    216     static TextRun constructTextRun(const UChar* characters, int length, 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);
    218218   
    219219    LayoutUnit paginationStrut() const;
  • trunk/Source/WebCore/rendering/RenderListMarker.cpp

    r203250 r205282  
    15441544        case Asterisks:
    15451545        case Footnotes: {
    1546             TextRun run = RenderBlock::constructTextRun(m_text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
     1546            TextRun run = RenderBlock::constructTextRun(m_text, style());
    15471547            logicalWidth = font.width(run); // no suffix for these types
    15481548        }
     
    16311631                logicalWidth = 0;
    16321632            else {
    1633                 TextRun run = RenderBlock::constructTextRun(m_text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
     1633                TextRun run = RenderBlock::constructTextRun(m_text, style());
    16341634                LayoutUnit itemWidth = font.width(run);
    16351635                UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' };
     
    17641764        case Footnotes: {
    17651765            const FontCascade& font = style().fontCascade();
    1766             TextRun run = RenderBlock::constructTextRun(m_text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
     1766            TextRun run = RenderBlock::constructTextRun(m_text, style());
    17671767            relativeRect = FloatRect(0, 0, font.width(run), font.fontMetrics().height());
    17681768            break;
     
    18581858                return FloatRect();
    18591859            const FontCascade& font = style().fontCascade();
    1860             TextRun run = RenderBlock::constructTextRun(m_text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
     1860            TextRun run = RenderBlock::constructTextRun(m_text, style());
    18611861            float itemWidth = font.width(run);
    18621862            UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' };
  • trunk/Source/WebCore/rendering/RenderMenuList.cpp

    r203324 r205282  
    220220            if (!text.isEmpty()) {
    221221                const FontCascade& font = style().fontCascade();
    222                 TextRun run = RenderBlock::constructTextRun(text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
     222                TextRun run = RenderBlock::constructTextRun(text, style());
    223223                optionWidth += font.width(run);
    224224            }
     
    226226        } else if (!text.isEmpty()) {
    227227            const FontCascade& font = style().fontCascade();
    228             TextRun run = RenderBlock::constructTextRun(text, style(), AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
     228            TextRun run = RenderBlock::constructTextRun(text, style());
    229229            maxOptionWidth = std::max(maxOptionWidth, font.width(run));
    230230        }
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r205011 r205282  
    453453}
    454454
    455 ALWAYS_INLINE float RenderText::widthFromCache(const FontCascade& f, int start, int len, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow, const RenderStyle& style) const
     455ALWAYS_INLINE float RenderText::widthFromCache(const FontCascade& f, unsigned start, unsigned len, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow, const RenderStyle& style) const
    456456{
    457457    if (style.hasTextCombine() && is<RenderCombineText>(*this)) {
     
    467467        ASSERT(m_text);
    468468        StringImpl& text = *m_text.impl();
    469         for (int i = start; i < start + len; i++) {
     469        for (unsigned i = start; i < start + len; i++) {
    470470            char c = text[i];
    471471            if (c <= ' ') {
     
    493493    }
    494494
    495     TextRun run = RenderBlock::constructTextRun(this, start, len, style);
     495    TextRun run = RenderBlock::constructTextRun(*this, start, len, style);
    496496    run.setCharactersLength(textLength() - start);
    497497    ASSERT(run.charactersLength() >= run.length());
     
    609609    endWS = m_hasEndWS;
    610610
    611     int len = textLength();
     611    unsigned len = textLength();
    612612
    613613    if (!len || (stripFrontSpaces && text()->containsOnlyWhitespace())) {
     
    633633    ASSERT(m_text);
    634634    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') {
    636636        const FontCascade& font = style.fontCascade(); // FIXME: This ignores first-line.
    637637        if (stripFrontSpaces) {
    638             const UChar space = ' ';
    639638            float spaceWidth = font.width(RenderBlock::constructTextRun(&space, 1, style));
    640639            maxW -= spaceWidth;
     
    654653        beginMaxW = maxW;
    655654        endMaxW = maxW;
    656         for (int i = 0; i < len; i++) {
    657             int linelen = 0;
     655        for (unsigned i = 0; i < len; i++) {
     656            unsigned linelen = 0;
    658657            while (i + linelen < len && text[i + linelen] != '\n')
    659658                linelen++;
     
    727726}
    728727
    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)
     728static 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
     735static float maxWordFragmentWidth(RenderText& renderer, const RenderStyle& style, const FontCascade& font, StringView word, unsigned minimumPrefixLength, unsigned minimumSuffixLength, unsigned& suffixStart, HashSet<const Font*>& fallbackFonts, GlyphOverflow& glyphOverflow)
    736736{
    737737    suffixStart = 0;
     
    740740
    741741    Vector<int, 8> hyphenLocations;
    742     int hyphenLocation = word.length() - minimumSuffixLength;
     742    ASSERT(word.length() >= minimumSuffixLength);
     743    unsigned hyphenLocation = word.length() - minimumSuffixLength;
    743744    while ((hyphenLocation = lastHyphenLocation(word, hyphenLocation, style.locale())) >= minimumPrefixLength)
    744745        hyphenLocations.append(hyphenLocation);
     
    759760        TextRun run = RenderBlock::constructTextRun(fragmentWithHyphen.toString(), style);
    760761        run.setCharactersLength(fragmentWithHyphen.length());
    761         run.setCharacterScanForCodePath(!renderer->canUseSimpleFontCodePath());
     762        run.setCharacterScanForCodePath(!renderer.canUseSimpleFontCodePath());
    762763        float fragmentWidth = font.width(run, &fallbackFonts, &glyphOverflow);
    763764
     
    808809    // fragment) encountered so far, and only try hyphenating words that are wider.
    809810    float maxWordWidth = std::numeric_limits<float>::max();
    810     int minimumPrefixLength = 0;
    811     int minimumSuffixLength = 0;
     811    unsigned minimumPrefixLength = 0;
     812    unsigned minimumSuffixLength = 0;
    812813    if (style.hyphens() == HyphensAuto && canHyphenate(style.locale())) {
    813814        maxWordWidth = 0;
    814815
    815816        // 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;
    823822    }
    824823
     
    907906                w = widthFromCache(font, i, wordLen, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style);
    908907                if (c == softHyphen && style.hyphens() != HyphensNone)
    909                     currMinWidth = hyphenWidth(this, font);
     908                    currMinWidth = hyphenWidth(*this, font);
    910909            }
    911910
    912911            if (w > maxWordWidth) {
    913                 int suffixStart;
    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);
    915914
    916915                if (suffixStart) {
     
    986985                currMaxWidth = 0;
    987986            } else {
    988                 TextRun run = RenderBlock::constructTextRun(this, i, 1, style);
     987                TextRun run = RenderBlock::constructTextRun(*this, i, 1, style);
    989988                run.setCharactersLength(len - i);
    990989                ASSERT(run.charactersLength() >= run.length());
     
    13261325            w = widthFromCache(f, from, len, xPos, fallbackFonts, glyphOverflow, style);
    13271326    } else {
    1328         TextRun run = RenderBlock::constructTextRun(this, from, len, style);
     1327        TextRun run = RenderBlock::constructTextRun(*this, from, len, style);
    13291328        run.setCharactersLength(textLength() - from);
    13301329        ASSERT(run.charactersLength() >= run.length());
  • trunk/Source/WebCore/rendering/RenderText.h

    r204653 r205282  
    197197    bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, HitTestAction) final { ASSERT_NOT_REACHED(); return false; }
    198198
    199     float widthFromCache(const FontCascade&, int start, int len, 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;
    200200    bool isAllASCII() const { return m_isAllASCII; }
    201201    bool computeUseBackslashAsYenSymbol() const;
  • trunk/Source/WebCore/rendering/RenderThemeIOS.mm

    r204858 r205282  
    576576    float measureText(const String& string) const override
    577577    {
    578         TextRun run = RenderBlock::constructTextRun(string, m_style, AllowTrailingExpansion | ForbidLeadingExpansion, DefaultTextRunFlags);
     578        TextRun run = RenderBlock::constructTextRun(string, m_style);
    579579        return m_font.width(run);
    580580    }
  • trunk/Source/WebCore/rendering/line/BreakingContext.h

    r204654 r205282  
    645645        return FontCascade::width(*layout, from, len, &fallbackFonts);
    646646
    647     TextRun run = RenderBlock::constructTextRun(&text, from, len, style);
     647    TextRun run = RenderBlock::constructTextRun(text, from, len, style);
    648648    run.setCharactersLength(text.textLength() - from);
    649649    ASSERT(run.charactersLength() >= run.length());
     
    694694
    695695    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);
    697697    run.setCharactersLength(text.textLength() - lastSpace);
    698698    ASSERT(run.charactersLength() >= run.length());
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp

    r204400 r205282  
    8989    ASSERT(scalingFactor);
    9090
    91     TextRun textRun = constructTextRun(&renderer().style(), fragment);
     91    TextRun textRun = constructTextRun(renderer().style(), fragment);
    9292
    9393    // Eventually handle lengthAdjust="spacingAndGlyphs".
     
    108108}
    109109
    110 FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition, const RenderStyle* style) const
     110FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition, const RenderStyle& style) const
    111111{
    112112    ASSERT_WITH_SECURITY_IMPLICATION(startPosition < endPosition);
    113     ASSERT(style);
    114113
    115114    float scalingFactor = renderer().scalingFactor();
     
    158157            continue;
    159158
    160         FloatRect fragmentRect = selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, &style);
     159        FloatRect fragmentRect = selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, style);
    161160        fragment.buildFragmentTransform(fragmentTransform);
    162161        if (!fragmentTransform.isIdentity())
     
    226225
    227226        paintInfo.context().setFillColor(backgroundColor);
    228         paintInfo.context().fillRect(selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, &style), backgroundColor);
     227        paintInfo.context().fillRect(selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, style), backgroundColor);
    229228
    230229        m_paintingResourceMode = ApplyToDefaultMode;
     
    307306                    continue;
    308307                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);
    310310                break;
    311311            case PaintTypeStroke:
     
    313313                    continue;
    314314                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);
    316317                break;
    317318            case PaintTypeMarkers:
     
    334335}
    335336
    336 bool SVGInlineTextBox::acquirePaintingResource(GraphicsContext*& context, float scalingFactor, RenderBoxModelObject& renderer, const RenderStyle* style)
     337bool SVGInlineTextBox::acquirePaintingResource(GraphicsContext*& context, float scalingFactor, RenderBoxModelObject& renderer, const RenderStyle& style)
    337338{
    338339    ASSERT(scalingFactor);
    339     ASSERT(style);
    340340    ASSERT(m_paintingResourceMode != ApplyToDefaultMode);
    341341
    342342    Color fallbackColor;
    343343    if (m_paintingResourceMode & ApplyToFillMode)
    344         m_paintingResource = RenderSVGResource::fillPaintingResource(renderer, *style, fallbackColor);
     344        m_paintingResource = RenderSVGResource::fillPaintingResource(renderer, style, fallbackColor);
    345345    else if (m_paintingResourceMode & ApplyToStrokeMode)
    346         m_paintingResource = RenderSVGResource::strokePaintingResource(renderer, *style, fallbackColor);
     346        m_paintingResource = RenderSVGResource::strokePaintingResource(renderer, style, fallbackColor);
    347347    else {
    348348        // We're either called for stroking or filling.
     
    353353        return false;
    354354
    355     if (!m_paintingResource->applyResource(renderer, *style, context, m_paintingResourceMode)) {
     355    if (!m_paintingResource->applyResource(renderer, style, context, m_paintingResourceMode)) {
    356356        if (fallbackColor.isValid()) {
    357357            RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
     
    359359
    360360            m_paintingResource = fallbackResource;
    361             m_paintingResource->applyResource(renderer, *style, context, m_paintingResourceMode);
     361            m_paintingResource->applyResource(renderer, style, context, m_paintingResourceMode);
    362362        }
    363363    }
     
    377377}
    378378
    379 bool SVGInlineTextBox::prepareGraphicsContextForTextPainting(GraphicsContext*& context, float scalingFactor, const RenderStyle* style)
     379bool SVGInlineTextBox::prepareGraphicsContextForTextPainting(GraphicsContext*& context, float scalingFactor, const RenderStyle& style)
    380380{
    381381    return acquirePaintingResource(context, scalingFactor, parent()->renderer(), style);
     
    387387}
    388388
    389 TextRun SVGInlineTextBox::constructTextRun(const RenderStyle* style, const SVGTextFragment& fragment) const
    390 {
    391     ASSERT(style);
    392 
     389TextRun SVGInlineTextBox::constructTextRun(const RenderStyle& style, const SVGTextFragment& fragment) const
     390{
    393391    TextRun run(StringView(renderer().text()).substring(fragment.characterOffset, fragment.length)
    394392                , 0 /* xPos, only relevant with allowTabs=true */
     
    396394                , AllowTrailingExpansion
    397395                , direction()
    398                 , dirOverride() || style->rtlOrdering() == VisualOrder /* directionalOverride */);
     396                , dirOverride() || style.rtlOrdering() == VisualOrder /* directionalOverride */);
    399397
    400398    // We handle letter & word spacing ourselves.
     
    539537
    540538    GraphicsContext* contextPtr = &context;
    541     if (acquirePaintingResource(contextPtr, scalingFactor, decorationRenderer, &decorationStyle))
     539    if (acquirePaintingResource(contextPtr, scalingFactor, decorationRenderer, decorationStyle))
    542540        releasePaintingResource(contextPtr, &path);
    543541}
    544542
    545 void SVGInlineTextBox::paintTextWithShadows(GraphicsContext& context, const RenderStyle* style, TextRun& textRun, const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition)
     543void SVGInlineTextBox::paintTextWithShadows(GraphicsContext& context, const RenderStyle& style, TextRun& textRun, const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition)
    546544{
    547545    float scalingFactor = renderer().scalingFactor();
     
    549547
    550548    const FontCascade& scaledFont = renderer().scaledFont();
    551     const ShadowData* shadow = style->textShadow();
     549    const ShadowData* shadow = style.textShadow();
    552550
    553551    FloatPoint textOrigin(fragment.x, fragment.y);
     
    588586}
    589587
    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 
     588void SVGInlineTextBox::paintText(GraphicsContext& context, const RenderStyle& style, const RenderStyle& selectionStyle, const SVGTextFragment& fragment, bool hasSelection, bool paintSelectedTextOnly)
     589{
    595590    unsigned startPosition = 0;
    596591    unsigned endPosition = 0;
     
    613608    // Draw text using selection style from the start to the end position of the selection
    614609    if (style != selectionStyle)
    615         SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, *selectionStyle);
     610        SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, selectionStyle);
    616611
    617612    paintTextWithShadows(context, selectionStyle, textRun, fragment, startPosition, endPosition);
    618613
    619614    if (style != selectionStyle)
    620         SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, *style);
     615        SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, style);
    621616
    622617    // 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  
    6565
    6666    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;
    6868
    6969private:
    7070    bool isSVGInlineTextBox() const override { return true; }
    7171
    72     TextRun constructTextRun(const RenderStyle*, const SVGTextFragment&) const;
     72    TextRun constructTextRun(const RenderStyle&, const SVGTextFragment&) const;
    7373
    74     bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderBoxModelObject&, const RenderStyle*);
     74    bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderBoxModelObject&, const RenderStyle&);
    7575    void releasePaintingResource(GraphicsContext*&, const Path*);
    7676
    77     bool prepareGraphicsContextForTextPainting(GraphicsContext*&, float scalingFactor, const RenderStyle*);
     77    bool prepareGraphicsContextForTextPainting(GraphicsContext*&, float scalingFactor, const RenderStyle&);
    7878    void restoreGraphicsContextAfterTextPainting(GraphicsContext*&);
    7979
    8080    void paintDecoration(GraphicsContext&, TextDecoration, const SVGTextFragment&);
    8181    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);
    8484
    8585    bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction) override;
  • trunk/Source/WebKit/mac/ChangeLog

    r205275 r205282  
     12016-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
    1132016-08-31  Keith Rollin  <krollin@apple.com>
    214
  • trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm

    r181760 r205282  
    3939#import "WebNSPasteboardExtras.h"
    4040#import "WebNSURLExtras.h"
    41 #import "WebStringTruncator.h"
    4241#import "WebUIDelegate.h"
    4342#import "WebUIDelegatePrivate.h"
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r205275 r205282  
    262262#import <WebCore/SQLiteDatabaseTracker.h>
    263263#import <WebCore/SmartReplace.h>
    264 #import <WebCore/TextRun.h>
    265264#import <WebCore/TileControllerMemoryHandlerIOS.h>
    266265#import <WebCore/WAKWindow.h>
Note: See TracChangeset for help on using the changeset viewer.