Since MidpointState is a class, it should behave like a class
authorzoltan@webkit.org <zoltan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2014 21:33:22 +0000 (21:33 +0000)
committerzoltan@webkit.org <zoltan@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2014 21:33:22 +0000 (21:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127154

Reviewed by David Hyatt.

I modified MidpointState to behave like a class, updated the call sites also.

No new tests, no behavior change.

* platform/text/BidiResolver.h:
(WebCore::MidpointState::reset):
(WebCore::MidpointState::startIgnoringSpaces):
(WebCore::MidpointState::stopIgnoringSpaces):
(WebCore::MidpointState::midpoints):
(WebCore::MidpointState::numMidpoints):
(WebCore::MidpointState::currentMidpoint):
(WebCore::MidpointState::incrementCurrentMidpoint):
(WebCore::MidpointState::decreaseNumMidpoints):
(WebCore::MidpointState::betweenMidpoints):
(WebCore::MidpointState::setBetweenMidpoints):
(WebCore::MidpointState::addMidpoint): Renamed from deprecatedAddMidpoint, since now
its private, we no longer need to discourage callers from using it.
* rendering/InlineIterator.h:
(WebCore::IsolateTracker::addFakeRunIfNecessary):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::appendRunsForObject):
(WebCore::constructBidiRunsForLine):
* rendering/line/BreakingContextInlineHeaders.h:
(WebCore::checkMidpoints):
* rendering/line/TrailingObjects.cpp:
(WebCore::TrailingObjects::updateMidpointsForTrailingBoxes):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162472 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/text/BidiResolver.h
Source/WebCore/rendering/InlineIterator.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/line/BreakingContextInlineHeaders.h
Source/WebCore/rendering/line/TrailingObjects.cpp

index b0aabd326452806b55cd62df2ac927470bf595a5..1eaed0bd4e13ece26303c8c4bb22fc565f7130bd 100644 (file)
@@ -1,3 +1,37 @@
+2014-01-21  Zoltan Horvath  <zoltan@webkit.org>
+
+        Since MidpointState is a class, it should behave like a class
+        https://bugs.webkit.org/show_bug.cgi?id=127154
+
+        Reviewed by David Hyatt.
+
+        I modified MidpointState to behave like a class, updated the call sites also.
+
+        No new tests, no behavior change.
+
+        * platform/text/BidiResolver.h:
+        (WebCore::MidpointState::reset):
+        (WebCore::MidpointState::startIgnoringSpaces):
+        (WebCore::MidpointState::stopIgnoringSpaces):
+        (WebCore::MidpointState::midpoints):
+        (WebCore::MidpointState::numMidpoints):
+        (WebCore::MidpointState::currentMidpoint):
+        (WebCore::MidpointState::incrementCurrentMidpoint):
+        (WebCore::MidpointState::decreaseNumMidpoints):
+        (WebCore::MidpointState::betweenMidpoints):
+        (WebCore::MidpointState::setBetweenMidpoints):
+        (WebCore::MidpointState::addMidpoint): Renamed from deprecatedAddMidpoint, since now
+        its private, we no longer need to discourage callers from using it.
+        * rendering/InlineIterator.h:
+        (WebCore::IsolateTracker::addFakeRunIfNecessary):
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlockFlow::appendRunsForObject):
+        (WebCore::constructBidiRunsForLine):
+        * rendering/line/BreakingContextInlineHeaders.h:
+        (WebCore::checkMidpoints):
+        * rendering/line/TrailingObjects.cpp:
+        (WebCore::TrailingObjects::updateMidpointsForTrailingBoxes):
+
 2014-01-21  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r162452.
index bcd6221b2e4fbf3058df1e6d3acb54a6a3cec8a8..db8fd0a1dbf6e0d9b72e9dff9325d1a5115d2cf1 100644 (file)
@@ -42,29 +42,21 @@ public:
     
     void reset()
     {
-        numMidpoints = 0;
-        currentMidpoint = 0;
-        betweenMidpoints = false;
+        m_numMidpoints = 0;
+        m_currentMidpoint = 0;
+        m_betweenMidpoints = false;
     }
     
-    // The goal is to reuse the line state across multiple
-    // lines so we just keep an array around for midpoints and never clear it across multiple
-    // lines.  We track the number of items and position using the two other variables.
-    Vector<Iterator> midpoints;
-    unsigned numMidpoints;
-    unsigned currentMidpoint;
-    bool betweenMidpoints;
-
     void startIgnoringSpaces(const Iterator& midpoint)
     {
-        ASSERT(!(numMidpoints % 2));
-        deprecatedAddMidpoint(midpoint);
+        ASSERT(!(m_numMidpoints % 2));
+        addMidpoint(midpoint);
     }
 
     void stopIgnoringSpaces(const Iterator& midpoint)
     {
-        ASSERT(numMidpoints % 2);
-        deprecatedAddMidpoint(midpoint);
+        ASSERT(m_numMidpoints % 2);
+        addMidpoint(midpoint);
     }
 
     // When ignoring spaces, this needs to be called for objects that need line boxes such as RenderInlines or
@@ -75,14 +67,30 @@ public:
         stopIgnoringSpaces(midpoint);
         startIgnoringSpaces(midpoint);
     }
+
+    Vector<Iterator>& midpoints() { return m_midpoints; }
+    const unsigned& numMidpoints() const { return m_numMidpoints; }
+    const unsigned& currentMidpoint() const { return m_currentMidpoint; }
+    void incrementCurrentMidpoint() { ++m_currentMidpoint; }
+    void decreaseNumMidpoints() { --m_numMidpoints; }
+    const bool& betweenMidpoints() const { return m_betweenMidpoints; }
+    void setBetweenMidpoints(bool betweenMidpoint) { m_betweenMidpoints = betweenMidpoint; }
 private:
-    void deprecatedAddMidpoint(const Iterator& midpoint)
+    // The goal is to reuse the line state across multiple
+    // lines so we just keep an array around for midpoints and never clear it across multiple
+    // lines. We track the number of items and position using the two other variables.
+    Vector<Iterator> m_midpoints;
+    unsigned m_numMidpoints;
+    unsigned m_currentMidpoint;
+    bool m_betweenMidpoints;
+
+    void addMidpoint(const Iterator& midpoint)
     {
-        if (midpoints.size() <= numMidpoints)
-            midpoints.grow(numMidpoints + 10);
+        if (m_midpoints.size() <= m_numMidpoints)
+            m_midpoints.grow(m_numMidpoints + 10);
 
-        Iterator* midpointsIterator = midpoints.data();
-        midpointsIterator[numMidpoints++] = midpoint;
+        Iterator* midpointsIterator = m_midpoints.data();
+        midpointsIterator[m_numMidpoints++] = midpoint;
     }
 };
 
index b5f2a1e946f208e558c789322c88bee278d1291c..198cf5ce28bd12b0cb149e315c590085efdca9bd 100644 (file)
@@ -497,9 +497,9 @@ public:
         // For now, if we enter an isolate between midpoints, we increment our current midpoint or else
         // we'll leave the isolate and ignore the content that follows.
         MidpointState<InlineIterator>& midpointState = resolver.midpointState();
-        if (midpointState.betweenMidpoints && midpointState.midpoints[midpointState.currentMidpoint].renderer() == &obj) {
-            midpointState.betweenMidpoints = false;
-            ++midpointState.currentMidpoint;
+        if (midpointState.betweenMidpoints() && midpointState.midpoints()[midpointState.currentMidpoint()].renderer() == &obj) {
+            midpointState.setBetweenMidpoints(false);
+            midpointState.incrementCurrentMidpoint();
         }
     }
 
index dd78ef15647a83bf1102559a5057f369e086efa0..622624ced90c0d8db0d6b24738b561405400b89b 100644 (file)
@@ -83,18 +83,18 @@ void RenderBlockFlow::appendRunsForObject(BidiRunList<BidiRun>& runs, int start,
         return;
 
     LineMidpointState& lineMidpointState = resolver.midpointState();
-    bool haveNextMidpoint = (lineMidpointState.currentMidpoint < lineMidpointState.numMidpoints);
+    bool haveNextMidpoint = (lineMidpointState.currentMidpoint() < lineMidpointState.numMidpoints());
     InlineIterator nextMidpoint;
     if (haveNextMidpoint)
-        nextMidpoint = lineMidpointState.midpoints[lineMidpointState.currentMidpoint];
-    if (lineMidpointState.betweenMidpoints) {
+        nextMidpoint = lineMidpointState.midpoints()[lineMidpointState.currentMidpoint()];
+    if (lineMidpointState.betweenMidpoints()) {
         if (!(haveNextMidpoint && nextMidpoint.renderer() == obj))
             return;
         // This is a new start point. Stop ignoring objects and
         // adjust our start.
-        lineMidpointState.betweenMidpoints = false;
+        lineMidpointState.setBetweenMidpoints(false);
         start = nextMidpoint.offset();
-        lineMidpointState.currentMidpoint++;
+        lineMidpointState.incrementCurrentMidpoint();
         if (start < end)
             return appendRunsForObject(runs, start, end, obj, resolver);
     } else {
@@ -106,8 +106,8 @@ void RenderBlockFlow::appendRunsForObject(BidiRunList<BidiRun>& runs, int start,
         // An end midpoint has been encountered within our object.  We
         // need to go ahead and append a run with our endpoint.
         if (static_cast<int>(nextMidpoint.offset() + 1) <= end) {
-            lineMidpointState.betweenMidpoints = true;
-            lineMidpointState.currentMidpoint++;
+            lineMidpointState.setBetweenMidpoints(true);
+            lineMidpointState.incrementCurrentMidpoint();
             if (nextMidpoint.offset() != UINT_MAX) { // UINT_MAX means stop at the object and don't include any of it.
                 if (static_cast<int>(nextMidpoint.offset() + 1) > start)
                     runs.addRun(createRun(start, nextMidpoint.offset() + 1, obj, resolver));
@@ -964,7 +964,7 @@ static inline void constructBidiRunsForLine(const RenderBlockFlow* block, Inline
             segmentMarker->m_startsSegment = true;
             bidiRuns.addRun(segmentMarker);
             // Do not collapse midpoints between segments
-            topResolver.midpointState().betweenMidpoints = false;
+            topResolver.midpointState().setBetweenMidpoints(false);
         }
         if (segmentStart == segmentEnd)
             continue;
index e47d8c771bd7213ce7ea8342d5d8c311fb9ec984..33d296b280b5c2d345ca09ffb91e837413a4bc8f 100644 (file)
@@ -1068,16 +1068,16 @@ inline void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator&
     // Check to see if our last midpoint is a start point beyond the line break. If so,
     // shave it off the list, and shave off a trailing space if the previous end point doesn't
     // preserve whitespace.
-    if (lBreak.renderer() && lineMidpointState.numMidpoints && !(lineMidpointState.numMidpoints % 2)) {
-        InlineIterator* midpoints = lineMidpointState.midpoints.data();
-        InlineIterator& endpoint = midpoints[lineMidpointState.numMidpoints - 2];
-        const InlineIterator& startpoint = midpoints[lineMidpointState.numMidpoints - 1];
+    if (lBreak.renderer() && lineMidpointState.numMidpoints() && !(lineMidpointState.numMidpoints() % 2)) {
+        InlineIterator* midpoints = lineMidpointState.midpoints().data();
+        InlineIterator& endpoint = midpoints[lineMidpointState.numMidpoints() - 2];
+        const InlineIterator& startpoint = midpoints[lineMidpointState.numMidpoints() - 1];
         InlineIterator currpoint = endpoint;
         while (!currpoint.atEnd() && currpoint != startpoint && currpoint != lBreak)
             currpoint.increment();
         if (currpoint == lBreak) {
             // We hit the line break before the start point. Shave off the start point.
-            lineMidpointState.numMidpoints--;
+            lineMidpointState.decreaseNumMidpoints();
             if (endpoint.renderer()->style().collapseWhiteSpace() && endpoint.renderer()->isText())
                 endpoint.setOffset(endpoint.offset() - 1);
         }
index 67663922c36dd82a7dd99bc9a4e7a29297cc550f..96490cd5bd1ed7baed271554376b3f97ac5115a4 100644 (file)
@@ -36,24 +36,24 @@ void TrailingObjects::updateMidpointsForTrailingBoxes(LineMidpointState& lineMid
 
     // This object is either going to be part of the last midpoint, or it is going to be the actual endpoint.
     // In both cases we just decrease our pos by 1 level to exclude the space, allowing it to - in effect - collapse into the newline.
-    if (lineMidpointState.numMidpoints % 2) {
+    if (lineMidpointState.numMidpoints() % 2) {
         // Find the trailing space object's midpoint.
-        int trailingSpaceMidpoint = lineMidpointState.numMidpoints - 1;
-        for ( ; trailingSpaceMidpoint > 0 && lineMidpointState.midpoints[trailingSpaceMidpoint].renderer() != m_whitespace; --trailingSpaceMidpoint) { }
+        int trailingSpaceMidpoint = lineMidpointState.numMidpoints() - 1;
+        for ( ; trailingSpaceMidpoint > 0 && lineMidpointState.midpoints()[trailingSpaceMidpoint].renderer() != m_whitespace; --trailingSpaceMidpoint) { }
         ASSERT(trailingSpaceMidpoint >= 0);
         if (collapseFirstSpace == CollapseFirstSpace)
-            lineMidpointState.midpoints[trailingSpaceMidpoint].setOffset(lineMidpointState.midpoints[trailingSpaceMidpoint].offset() -1);
+            lineMidpointState.midpoints()[trailingSpaceMidpoint].setOffset(lineMidpointState.midpoints()[trailingSpaceMidpoint].offset() -1);
 
         // Now make sure every single trailingPositionedBox following the trailingSpaceMidpoint properly stops and starts
         // ignoring spaces.
         size_t currentMidpoint = trailingSpaceMidpoint + 1;
         for (size_t i = 0; i < m_boxes.size(); ++i) {
-            if (currentMidpoint >= lineMidpointState.numMidpoints) {
+            if (currentMidpoint >= lineMidpointState.numMidpoints()) {
                 // We don't have a midpoint for this box yet.
                 lineMidpointState.ensureLineBoxInsideIgnoredSpaces(m_boxes[i]);
             } else {
-                ASSERT(lineMidpointState.midpoints[currentMidpoint].renderer() == m_boxes[i]);
-                ASSERT(lineMidpointState.midpoints[currentMidpoint + 1].renderer() == m_boxes[i]);
+                ASSERT(lineMidpointState.midpoints()[currentMidpoint].renderer() == m_boxes[i]);
+                ASSERT(lineMidpointState.midpoints()[currentMidpoint + 1].renderer() == m_boxes[i]);
             }
             currentMidpoint += 2;
         }