Title: [160074] trunk/Source/WebCore
Revision
160074
Author
zol...@webkit.org
Date
2013-12-04 00:29:45 -0800 (Wed, 04 Dec 2013)

Log Message

Move space-ignoring inline functions into MidpointState
<https://webkit.org/b/124957>

Reviewed by David Hyatt.

Since:
 - The following inline functions were used only with a mandatory LineMidpointState argument:
   startIgnoringSpaces, stopIgnoringSpaces, ensureLineBoxInsideIgnoredSpaces, deprecatedAddMidpoint.
 - TrailingObjects class uses these functions. Since they're inline in BreakingContextInlineHeaders.h,
   it's hard to separate TrailingObjects into it's own file. (blocks bug #124956)
 I made these functions as a member of LineMidpointState, and I also updated the call sites.

No new tests, no behavior change.

* platform/text/BidiResolver.h:
(WebCore::MidpointState::startIgnoringSpaces):
(WebCore::MidpointState::stopIgnoringSpaces):
(WebCore::MidpointState::ensureLineBoxInsideIgnoredSpaces):
(WebCore::MidpointState::deprecatedAddMidpoint):
* rendering/RenderBlock.h:
* rendering/line/BreakingContextInlineHeaders.h:
(WebCore::TrailingObjects::updateMidpointsForTrailingBoxes):
(WebCore::BreakingContext::handleBR):
(WebCore::BreakingContext::handleOutOfFlowPositioned):
(WebCore::shouldSkipWhitespaceAfterStartObject):
(WebCore::BreakingContext::handleEmptyInline):
(WebCore::BreakingContext::handleReplaced):
(WebCore::ensureCharacterGetsLineBox):
(WebCore::BreakingContext::handleText):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (160073 => 160074)


--- trunk/Source/WebCore/ChangeLog	2013-12-04 07:56:26 UTC (rev 160073)
+++ trunk/Source/WebCore/ChangeLog	2013-12-04 08:29:45 UTC (rev 160074)
@@ -1,3 +1,35 @@
+2013-12-04  Zoltan Horvath  <zol...@webkit.org>
+
+        Move space-ignoring inline functions into MidpointState
+        <https://webkit.org/b/124957>
+
+        Reviewed by David Hyatt.
+
+        Since:
+         - The following inline functions were used only with a mandatory LineMidpointState argument:
+           startIgnoringSpaces, stopIgnoringSpaces, ensureLineBoxInsideIgnoredSpaces, deprecatedAddMidpoint.
+         - TrailingObjects class uses these functions. Since they're inline in BreakingContextInlineHeaders.h,
+           it's hard to separate TrailingObjects into it's own file. (blocks bug #124956)
+         I made these functions as a member of LineMidpointState, and I also updated the call sites.
+
+        No new tests, no behavior change.
+
+        * platform/text/BidiResolver.h:
+        (WebCore::MidpointState::startIgnoringSpaces):
+        (WebCore::MidpointState::stopIgnoringSpaces):
+        (WebCore::MidpointState::ensureLineBoxInsideIgnoredSpaces):
+        (WebCore::MidpointState::deprecatedAddMidpoint):
+        * rendering/RenderBlock.h:
+        * rendering/line/BreakingContextInlineHeaders.h:
+        (WebCore::TrailingObjects::updateMidpointsForTrailingBoxes):
+        (WebCore::BreakingContext::handleBR):
+        (WebCore::BreakingContext::handleOutOfFlowPositioned):
+        (WebCore::shouldSkipWhitespaceAfterStartObject):
+        (WebCore::BreakingContext::handleEmptyInline):
+        (WebCore::BreakingContext::handleReplaced):
+        (WebCore::ensureCharacterGetsLineBox):
+        (WebCore::BreakingContext::handleText):
+
 2013-12-03  Zoltan Horvath  <zol...@webkit.org>
 
         Remove BreakingContext's friendship from RenderBlockFlow

Modified: trunk/Source/WebCore/platform/text/BidiResolver.h (160073 => 160074)


--- trunk/Source/WebCore/platform/text/BidiResolver.h	2013-12-04 07:56:26 UTC (rev 160073)
+++ trunk/Source/WebCore/platform/text/BidiResolver.h	2013-12-04 08:29:45 UTC (rev 160074)
@@ -31,7 +31,10 @@
 
 namespace WebCore {
 
-template <class Iterator> struct MidpointState {
+class RenderObject;
+
+template <class Iterator> class MidpointState {
+public:
     MidpointState()
     {
         reset();
@@ -51,6 +54,36 @@
     unsigned numMidpoints;
     unsigned currentMidpoint;
     bool betweenMidpoints;
+
+    void startIgnoringSpaces(const Iterator& midpoint)
+    {
+        ASSERT(!(numMidpoints % 2));
+        deprecatedAddMidpoint(midpoint);
+    }
+
+    void stopIgnoringSpaces(const Iterator& midpoint)
+    {
+        ASSERT(lineMidpointState.numMidpoints % 2);
+        deprecatedAddMidpoint(midpoint);
+    }
+
+    // When ignoring spaces, this needs to be called for objects that need line boxes such as RenderInlines or
+    // hard line breaks to ensure that they're not ignored.
+    void ensureLineBoxInsideIgnoredSpaces(RenderObject* renderer)
+    {
+        Iterator midpoint(0, renderer, 0);
+        stopIgnoringSpaces(midpoint);
+        startIgnoringSpaces(midpoint);
+    }
+private:
+    void deprecatedAddMidpoint(const Iterator& midpoint)
+    {
+        if (midpoints.size() <= numMidpoints)
+            midpoints.grow(numMidpoints + 10);
+
+        Iterator* midpointsIterator = midpoints.data();
+        midpointsIterator[numMidpoints++] = midpoint;
+    }
 };
 
 // The BidiStatus at a given position (typically the end of a line) can

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (160073 => 160074)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2013-12-04 07:56:26 UTC (rev 160073)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2013-12-04 08:29:45 UTC (rev 160074)
@@ -61,7 +61,7 @@
 
 template <class Iterator, class Run> class BidiResolver;
 template <class Run> class BidiRunList;
-template <class Iterator> struct MidpointState;
+template <class Iterator> class MidpointState;
 typedef BidiResolver<InlineIterator, BidiRun> InlineBidiResolver;
 typedef MidpointState<InlineIterator> LineMidpointState;
 typedef WTF::ListHashSet<RenderBox*, 16> TrackedRendererListHashSet;

Modified: trunk/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h (160073 => 160074)


--- trunk/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h	2013-12-04 07:56:26 UTC (rev 160073)
+++ trunk/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h	2013-12-04 08:29:45 UTC (rev 160074)
@@ -106,37 +106,6 @@
         m_boxes.append(box);
 }
 
-// Don't call this directly. Use one of the descriptive helper functions below.
-inline void deprecatedAddMidpoint(LineMidpointState& lineMidpointState, const InlineIterator& midpoint)
-{
-    if (lineMidpointState.midpoints.size() <= lineMidpointState.numMidpoints)
-        lineMidpointState.midpoints.grow(lineMidpointState.numMidpoints + 10);
-
-    InlineIterator* midpoints = lineMidpointState.midpoints.data();
-    midpoints[lineMidpointState.numMidpoints++] = midpoint;
-}
-
-inline void startIgnoringSpaces(LineMidpointState& lineMidpointState, const InlineIterator& midpoint)
-{
-    ASSERT(!(lineMidpointState.numMidpoints % 2));
-    deprecatedAddMidpoint(lineMidpointState, midpoint);
-}
-
-inline void stopIgnoringSpaces(LineMidpointState& lineMidpointState, const InlineIterator& midpoint)
-{
-    ASSERT(lineMidpointState.numMidpoints % 2);
-    deprecatedAddMidpoint(lineMidpointState, midpoint);
-}
-
-// When ignoring spaces, this needs to be called for objects that need line boxes such as RenderInlines or
-// hard line breaks to ensure that they're not ignored.
-inline void ensureLineBoxInsideIgnoredSpaces(LineMidpointState& lineMidpointState, RenderObject* renderer)
-{
-    InlineIterator midpoint(0, renderer, 0);
-    stopIgnoringSpaces(lineMidpointState, midpoint);
-    startIgnoringSpaces(lineMidpointState, midpoint);
-}
-
 void TrailingObjects::updateMidpointsForTrailingBoxes(LineMidpointState& lineMidpointState, const InlineIterator& lBreak, CollapseFirstSpaceOrNot collapseFirstSpace)
 {
     if (!m_whitespace)
@@ -158,7 +127,7 @@
         for (size_t i = 0; i < m_boxes.size(); ++i) {
             if (currentMidpoint >= lineMidpointState.numMidpoints) {
                 // We don't have a midpoint for this box yet.
-                ensureLineBoxInsideIgnoredSpaces(lineMidpointState, m_boxes[i]);
+                lineMidpointState.ensureLineBoxInsideIgnoredSpaces(m_boxes[i]);
             } else {
                 ASSERT(lineMidpointState.midpoints[currentMidpoint].renderer() == m_boxes[i]);
                 ASSERT(lineMidpointState.midpoints[currentMidpoint + 1].renderer() == m_boxes[i]);
@@ -172,9 +141,9 @@
         unsigned length = m_whitespace->textLength();
         unsigned pos = length >= 2 ? length - 2 : UINT_MAX;
         InlineIterator endMid(0, m_whitespace, pos);
-        startIgnoringSpaces(lineMidpointState, endMid);
+        lineMidpointState.startIgnoringSpaces(endMid);
         for (size_t i = 0; i < m_boxes.size(); ++i)
-            ensureLineBoxInsideIgnoredSpaces(lineMidpointState, m_boxes[i]);
+            lineMidpointState.ensureLineBoxInsideIgnoredSpaces(m_boxes[i]);
     }
 }
 
@@ -365,12 +334,12 @@
         // need to check for floats to clear - so if we're ignoring spaces, stop ignoring them and add a
         // run for this object.
         if (m_ignoringSpaces && m_currentStyle->clear() != CNONE)
-            ensureLineBoxInsideIgnoredSpaces(m_lineMidpointState, br);
+            m_lineMidpointState.ensureLineBoxInsideIgnoredSpaces(br);
         // If we were preceded by collapsing space and are in a right-aligned container we need to ensure the space gets
         // collapsed away so that it doesn't push the text out from the container's right-hand edge.
         // FIXME: Do this regardless of the container's alignment - will require rebaselining a lot of test results.
         else if (m_ignoringSpaces && (m_blockStyle.textAlign() == RIGHT || m_blockStyle.textAlign() == WEBKIT_RIGHT))
-            stopIgnoringSpaces(m_lineMidpointState, InlineIterator(0, m_current.renderer(), m_current.m_pos));
+            m_lineMidpointState.stopIgnoringSpaces(InlineIterator(0, m_current.renderer(), m_current.m_pos));
 
         if (!m_lineInfo.isEmpty())
             clear = m_currentStyle->clear();
@@ -443,7 +412,7 @@
     // then start ignoring spaces again.
     if (isInlineType || box->container()->isRenderInline()) {
         if (m_ignoringSpaces)
-            ensureLineBoxInsideIgnoredSpaces(m_lineMidpointState, box);
+            m_lineMidpointState.ensureLineBoxInsideIgnoredSpaces(box);
         m_trailingObjects.appendBoxIfNeeded(box);
     } else
         positionedObjects.append(box);
@@ -485,7 +454,7 @@
         RenderText* nextText = toRenderText(next);
         UChar nextChar = nextText->characterAt(0);
         if (nextText->style().isCollapsibleWhiteSpace(nextChar)) {
-            startIgnoringSpaces(lineMidpointState, InlineIterator(0, o, 0));
+            lineMidpointState.startIgnoringSpaces(InlineIterator(0, o, 0));
             return true;
         }
     }
@@ -512,7 +481,7 @@
             m_lineInfo.setEmpty(false, &m_block, &m_width);
         if (m_ignoringSpaces) {
             m_trailingObjects.clear();
-            ensureLineBoxInsideIgnoredSpaces(m_lineMidpointState, m_current.renderer());
+            m_lineMidpointState.ensureLineBoxInsideIgnoredSpaces(m_current.renderer());
         } else if (m_blockStyle.collapseWhiteSpace() && m_resolver.position().renderer() == m_current.renderer()
             && shouldSkipWhitespaceAfterStartObject(m_block, m_current.renderer(), m_lineMidpointState)) {
             // Like with list markers, we start ignoring spaces to make sure that any
@@ -541,7 +510,7 @@
     }
 
     if (m_ignoringSpaces)
-        stopIgnoringSpaces(m_lineMidpointState, InlineIterator(0, m_current.renderer(), 0));
+        m_lineMidpointState.stopIgnoringSpaces(InlineIterator(0, m_current.renderer(), 0));
 
     m_lineInfo.setEmpty(false, &m_block, &m_width);
     m_ignoringSpaces = false;
@@ -673,8 +642,8 @@
 inline void ensureCharacterGetsLineBox(LineMidpointState& lineMidpointState, InlineIterator& textParagraphSeparator)
 {
     InlineIterator midpoint(0, textParagraphSeparator.renderer(), textParagraphSeparator.m_pos);
-    startIgnoringSpaces(lineMidpointState, InlineIterator(0, textParagraphSeparator.renderer(), textParagraphSeparator.m_pos - 1));
-    stopIgnoringSpaces(lineMidpointState, InlineIterator(0, textParagraphSeparator.renderer(), textParagraphSeparator.m_pos));
+    lineMidpointState.startIgnoringSpaces(InlineIterator(0, textParagraphSeparator.renderer(), textParagraphSeparator.m_pos - 1));
+    lineMidpointState.stopIgnoringSpaces(InlineIterator(0, textParagraphSeparator.renderer(), textParagraphSeparator.m_pos));
 }
 
 inline void tryHyphenating(RenderText* text, const Font& font, const AtomicString& localeIdentifier, unsigned consecutiveHyphenatedLines, int consecutiveHyphenatedLinesLimit, int minimumPrefixLimit, int minimumSuffixLimit, unsigned lastSpace, unsigned pos, float xPos, int availableWidth, bool isFixedPitch, bool collapseWhiteSpace, int lastSpaceWordSpacing, InlineIterator& lineBreak, int nextBreakable, bool& hyphenated)
@@ -856,7 +825,7 @@
                     m_ignoringSpaces = false;
                     wordSpacingForWordMeasurement = 0;
                     lastSpace = m_current.m_pos; // e.g., "Foo    goo", don't add in any of the ignored spaces.
-                    stopIgnoringSpaces(m_lineMidpointState, InlineIterator(0, m_current.renderer(), m_current.m_pos));
+                    m_lineMidpointState.stopIgnoringSpaces(InlineIterator(0, m_current.renderer(), m_current.m_pos));
                     stoppedIgnoringSpaces = true;
                 } else {
                     // Just keep ignoring these spaces.
@@ -1000,7 +969,7 @@
                     // We just entered a mode where we are ignoring
                     // spaces. Create a midpoint to terminate the run
                     // before the second space.
-                    startIgnoringSpaces(m_lineMidpointState, m_startOfIgnoredSpaces);
+                    m_lineMidpointState.startIgnoringSpaces(m_startOfIgnoredSpaces);
                     m_trailingObjects.updateMidpointsForTrailingBoxes(m_lineMidpointState, InlineIterator(), TrailingObjects::DoNotCollapseFirstSpace);
                 }
             }
@@ -1011,7 +980,7 @@
             lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0;
             wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasurements.last().width) ? wordSpacing : 0;
             lastSpace = m_current.m_pos; // e.g., "Foo    goo", don't add in any of the ignored spaces.
-            stopIgnoringSpaces(m_lineMidpointState, InlineIterator(0, m_current.renderer(), m_current.m_pos));
+            m_lineMidpointState.stopIgnoringSpaces(InlineIterator(0, m_current.renderer(), m_current.m_pos));
         }
 #if ENABLE(SVG)
         if (isSVGText && m_current.m_pos > 0) {
@@ -1031,7 +1000,7 @@
                 m_startOfIgnoredSpaces.m_pos--;
                 // If there's just a single trailing space start ignoring it now so it collapses away.
                 if (m_current.m_pos == renderText->textLength() - 1)
-                    startIgnoringSpaces(m_lineMidpointState, m_startOfIgnoredSpaces);
+                    m_lineMidpointState.startIgnoringSpaces(m_startOfIgnoredSpaces);
             }
         }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to