Title: [265240] trunk/Source/WebCore
Revision
265240
Author
[email protected]
Date
2020-08-03 21:32:33 -0700 (Mon, 03 Aug 2020)

Log Message

Rename WidthIterator::m_currentCharacter to WidthIterator::m_currentCharacterIndex
https://bugs.webkit.org/show_bug.cgi?id=215056

Reviewed by Darin Adler.

It represents an index, not a character.

No new tests because there is no behavior change.

This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=214769
and https://bugs.webkit.org/show_bug.cgi?id=206208.

* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::offsetForPositionForSimpleText const):
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::advanceInternal):
(WebCore::WidthIterator::advance):
(WebCore::WidthIterator::advanceOneCharacter):
* platform/graphics/WidthIterator.h:
(WebCore::WidthIterator::currentCharacterIndex const):
(WebCore::WidthIterator::currentCharacter const): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (265239 => 265240)


--- trunk/Source/WebCore/ChangeLog	2020-08-04 04:02:01 UTC (rev 265239)
+++ trunk/Source/WebCore/ChangeLog	2020-08-04 04:32:33 UTC (rev 265240)
@@ -1,3 +1,27 @@
+2020-08-03  Myles C. Maxfield  <[email protected]>
+
+        Rename WidthIterator::m_currentCharacter to WidthIterator::m_currentCharacterIndex
+        https://bugs.webkit.org/show_bug.cgi?id=215056
+
+        Reviewed by Darin Adler.
+
+        It represents an index, not a character.
+
+        No new tests because there is no behavior change.
+
+        This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=214769
+        and https://bugs.webkit.org/show_bug.cgi?id=206208.
+
+        * platform/graphics/FontCascade.cpp:
+        (WebCore::FontCascade::offsetForPositionForSimpleText const):
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::advanceInternal):
+        (WebCore::WidthIterator::advance):
+        (WebCore::WidthIterator::advanceOneCharacter):
+        * platform/graphics/WidthIterator.h:
+        (WebCore::WidthIterator::currentCharacterIndex const):
+        (WebCore::WidthIterator::currentCharacter const): Deleted.
+
 2020-08-03  Youenn Fablet  <[email protected]>
 
         Move user gesture propagation over promise behind a feature flag

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (265239 => 265240)


--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2020-08-04 04:02:01 UTC (rev 265239)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2020-08-04 04:32:33 UTC (rev 265240)
@@ -1593,7 +1593,7 @@
     if (run.rtl()) {
         delta -= floatWidthForSimpleText(run);
         while (1) {
-            offset = it.currentCharacter();
+            offset = it.currentCharacterIndex();
             float w;
             if (!it.advanceOneCharacter(w, localGlyphBuffer))
                 break;
@@ -1608,7 +1608,7 @@
         }
     } else {
         while (1) {
-            offset = it.currentCharacter();
+            offset = it.currentCharacterIndex();
             float w;
             if (!it.advanceOneCharacter(w, localGlyphBuffer))
                 break;

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (265239 => 265240)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2020-08-04 04:02:01 UTC (rev 265239)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp	2020-08-04 04:32:33 UTC (rev 265240)
@@ -208,7 +208,7 @@
             continue;
         }
 #endif
-        int currentCharacter = textIterator.currentIndex();
+        int currentCharacterIndex = textIterator.currentIndex();
         const GlyphData& glyphData = m_font->glyphDataForCharacter(character, rtl);
         Glyph glyph = glyphData.glyph;
         if (!glyph && !characterMustDrawSomething) {
@@ -261,19 +261,19 @@
 
             static bool expandAroundIdeographs = FontCascade::canExpandAroundIdeographsInComplexText();
             bool treatAsSpace = FontCascade::treatAsSpace(character);
-            bool currentIsLastCharacter = currentCharacter + advanceLength == static_cast<size_t>(m_run.length());
+            bool currentIsLastCharacter = currentCharacterIndex + advanceLength == static_cast<size_t>(m_run.length());
             bool forceLeadingExpansion = false; // On the left, regardless of m_run.ltr()
             bool forceTrailingExpansion = false; // On the right, regardless of m_run.ltr()
             bool forbidLeadingExpansion = false;
             bool forbidTrailingExpansion = false;
             if (runForcesLeadingExpansion)
-                forceLeadingExpansion = m_run.ltr() ? !currentCharacter : currentIsLastCharacter;
+                forceLeadingExpansion = m_run.ltr() ? !currentCharacterIndex : currentIsLastCharacter;
             if (runForcesTrailingExpansion)
-                forceTrailingExpansion = m_run.ltr() ? currentIsLastCharacter : !currentCharacter;
+                forceTrailingExpansion = m_run.ltr() ? currentIsLastCharacter : !currentCharacterIndex;
             if (runForbidsLeadingExpansion)
-                forbidLeadingExpansion = m_run.ltr() ? !currentCharacter : currentIsLastCharacter;
+                forbidLeadingExpansion = m_run.ltr() ? !currentCharacterIndex : currentIsLastCharacter;
             if (runForbidsTrailingExpansion)
-                forbidTrailingExpansion = m_run.ltr() ? currentIsLastCharacter : !currentCharacter;
+                forbidTrailingExpansion = m_run.ltr() ? currentIsLastCharacter : !currentCharacterIndex;
             bool ideograph = (expandAroundIdeographs && FontCascade::isCJKIdeographOrSymbol(character));
             if (treatAsSpace || ideograph || forceLeadingExpansion || forceTrailingExpansion) {
                 // Distribute the run's total expansion evenly over all expansion opportunities in the run.
@@ -287,9 +287,9 @@
                             if (glyphBuffer) {
                                 if (glyphBuffer->isEmpty()) {
                                     if (m_forTextEmphasis)
-                                        glyphBuffer->add(font->zeroWidthSpaceGlyph(), font, m_expansionPerOpportunity, currentCharacter);
+                                        glyphBuffer->add(font->zeroWidthSpaceGlyph(), font, m_expansionPerOpportunity, currentCharacterIndex);
                                     else
-                                        glyphBuffer->add(font->spaceGlyph(), font, m_expansionPerOpportunity, currentCharacter);
+                                        glyphBuffer->add(font->spaceGlyph(), font, m_expansionPerOpportunity, currentCharacterIndex);
                                 } else
                                     glyphBuffer->expandLastAdvance(m_expansionPerOpportunity);
                             }
@@ -310,7 +310,7 @@
 
                 // Account for word spacing.
                 // We apply additional space between "words" by adding width to the space character.
-                if (treatAsSpace && (character != '\t' || !m_run.allowTabs()) && (currentCharacter || character == noBreakSpace) && m_font->wordSpacing())
+                if (treatAsSpace && (character != '\t' || !m_run.allowTabs()) && (currentCharacterIndex || character == noBreakSpace) && m_font->wordSpacing())
                     width += m_font->wordSpacing();
             } else
                 m_isAfterExpansion = false;
@@ -324,7 +324,7 @@
 
         if (m_accountForGlyphBounds) {
             bounds = font->boundsForGlyph(glyph);
-            if (!currentCharacter)
+            if (!currentCharacterIndex)
                 m_firstGlyphOverflow = std::max<float>(0, -bounds.x());
         }
 
@@ -339,7 +339,7 @@
         widthSinceLastRounding += width;
 
         if (glyphBuffer)
-            glyphBuffer->add(glyph, font, (rtl ? oldWidth + lastRoundingWidth : width), currentCharacter);
+            glyphBuffer->add(glyph, font, (rtl ? oldWidth + lastRoundingWidth : width), currentCharacterIndex);
 
         lastRoundingWidth = width - oldWidth;
 
@@ -365,7 +365,7 @@
             glyphBuffer->shrink(lastGlyphCount);
     }
 
-    m_currentCharacter = textIterator.currentIndex();
+    m_currentCharacterIndex = textIterator.currentIndex();
     m_runWidthSoFar += widthSinceLastRounding;
     m_finalRoundingWidth = lastRoundingWidth;
 }
@@ -377,16 +377,16 @@
     if (offset > length)
         offset = length;
 
-    if (m_currentCharacter >= offset)
+    if (m_currentCharacterIndex >= offset)
         return;
 
     if (m_run.is8Bit()) {
-        Latin1TextIterator textIterator(m_run.data8(m_currentCharacter), m_currentCharacter, offset, length);
+        Latin1TextIterator textIterator(m_run.data8(m_currentCharacterIndex), m_currentCharacterIndex, offset, length);
         advanceInternal(textIterator, glyphBuffer);
         return;
     }
 
-    SurrogatePairAwareTextIterator textIterator(m_run.data16(m_currentCharacter), m_currentCharacter, offset, length);
+    SurrogatePairAwareTextIterator textIterator(m_run.data16(m_currentCharacterIndex), m_currentCharacterIndex, offset, length);
     advanceInternal(textIterator, glyphBuffer);
 }
 
@@ -393,7 +393,7 @@
 bool WidthIterator::advanceOneCharacter(float& width, GlyphBuffer& glyphBuffer)
 {
     unsigned oldSize = glyphBuffer.size();
-    advance(m_currentCharacter + 1, &glyphBuffer);
+    advance(m_currentCharacterIndex + 1, &glyphBuffer);
     float w = 0;
     for (unsigned i = oldSize; i < glyphBuffer.size(); ++i)
         w += glyphBuffer.advanceAt(i).width();

Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.h (265239 => 265240)


--- trunk/Source/WebCore/platform/graphics/WidthIterator.h	2020-08-04 04:02:01 UTC (rev 265239)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.h	2020-08-04 04:32:33 UTC (rev 265240)
@@ -53,7 +53,7 @@
     const TextRun& run() const { return m_run; }
     float runWidthSoFar() const { return m_runWidthSoFar; }
     float finalRoundingWidth() const { return m_finalRoundingWidth; }
-    unsigned currentCharacter() const { return m_currentCharacter; }
+    unsigned currentCharacterIndex() const { return m_currentCharacterIndex; }
 
 private:
     GlyphData glyphDataForCharacter(UChar32, bool mirror);
@@ -68,7 +68,7 @@
     const TextRun& m_run;
     HashSet<const Font*>* m_fallbackFonts { nullptr };
 
-    unsigned m_currentCharacter { 0 };
+    unsigned m_currentCharacterIndex { 0 };
     float m_runWidthSoFar { 0 };
     float m_expansion { 0 };
     float m_expansionPerOpportunity { 0 };

Modified: trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp (265239 => 265240)


--- trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp	2020-08-04 04:02:01 UTC (rev 265239)
+++ trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp	2020-08-04 04:32:33 UTC (rev 265240)
@@ -58,9 +58,9 @@
 void SVGTextMetricsBuilder::advanceSimpleText()
 {
     GlyphBuffer glyphBuffer;
-    auto before = m_simpleWidthIterator->currentCharacter();
+    auto before = m_simpleWidthIterator->currentCharacterIndex();
     m_simpleWidthIterator->advance(m_textPosition + 1, &glyphBuffer);
-    auto after = m_simpleWidthIterator->currentCharacter();
+    auto after = m_simpleWidthIterator->currentCharacterIndex();
     if (before == after) {
         m_currentMetrics = SVGTextMetrics();
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to