Title: [280102] trunk/Source/WebCore
Revision
280102
Author
[email protected]
Date
2021-07-20 13:40:10 -0700 (Tue, 20 Jul 2021)

Log Message

Use references instead of pointers in WidthIterator::advanceInternal()
https://bugs.webkit.org/show_bug.cgi?id=228099

Reviewed by Fujii Hironori.

We assert that font is non-null, so we should be able to use a reference for it instead of a pointer.

No new tests because there is no behavior change.

* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::advanceInternal):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (280101 => 280102)


--- trunk/Source/WebCore/ChangeLog	2021-07-20 20:39:35 UTC (rev 280101)
+++ trunk/Source/WebCore/ChangeLog	2021-07-20 20:40:10 UTC (rev 280102)
@@ -1,3 +1,17 @@
+2021-07-20  Myles C. Maxfield  <[email protected]>
+
+        Use references instead of pointers in WidthIterator::advanceInternal()
+        https://bugs.webkit.org/show_bug.cgi?id=228099
+
+        Reviewed by Fujii Hironori.
+
+        We assert that font is non-null, so we should be able to use a reference for it instead of a pointer.
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::advanceInternal):
+
 2021-07-20  Fujii Hironori  <[email protected]>
 
         Use WeakHashSet for Page::m_activityStateChangeObservers

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (280101 => 280102)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2021-07-20 20:39:35 UTC (rev 280101)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2021-07-20 20:40:10 UTC (rev 280102)
@@ -233,16 +233,15 @@
             currentCharacterIndex = textIterator.currentIndex();
             continue;
         }
-        const Font* font = glyphData.font ? glyphData.font : &m_font.primaryFont();
-        ASSERT(font);
+        const Font& font = glyphData.font ? *glyphData.font : primaryFont;
 
         previousWidth = width;
-        width = font->widthForGlyph(glyph);
+        width = font.widthForGlyph(glyph);
 
-        if (font != lastFontData) {
+        if (&font != lastFontData) {
             commitCurrentFontRange(glyphBuffer, lastGlyphCount, currentCharacterIndex, *lastFontData, primaryFont, character, widthOfCurrentFontRange, charactersTreatedAsSpace);
             lastGlyphCount = glyphBuffer.size();
-            lastFontData = font;
+            lastFontData = &font;
             widthOfCurrentFontRange = width;
         } else
             widthOfCurrentFontRange += width;
@@ -257,7 +256,7 @@
         }
 
         if (m_accountForGlyphBounds) {
-            bounds = font->boundsForGlyph(glyph);
+            bounds = font.boundsForGlyph(glyph);
             if (!currentCharacterIndex)
                 m_firstGlyphOverflow = std::max<float>(0, -bounds.x());
         }
@@ -265,7 +264,7 @@
         if (m_forTextEmphasis && !FontCascade::canReceiveTextEmphasis(character))
             glyph = 0;
 
-        glyphBuffer.add(glyph, *font, width, currentCharacterIndex);
+        glyphBuffer.add(glyph, font, width, currentCharacterIndex);
 #if USE(CTFONTSHAPEGLYPHS)
         // These 0 glyphs are needed by shapers if the source text has surrogate pairs.
         // However, CTFontTransformGlyphs() can't delete these 0 glyphs from the shaped text,
@@ -272,7 +271,7 @@
         // so we shouldn't add them in the first place if we're using that shaping routine.
         // Any other shaping routine should delete these glyphs from the shaped text.
         if (!U_IS_BMP(character))
-            glyphBuffer.add(0, *font, 0, currentCharacterIndex + 1);
+            glyphBuffer.add(0, font, 0, currentCharacterIndex + 1);
 #endif
 
         // Advance past the character we just dealt with.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to