Simple line layout: Use Vector<>::const_iterator instead of custom FlowContents:...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Mar 2015 04:00:40 +0000 (04:00 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Mar 2015 04:00:40 +0000 (04:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142809

Reviewed by Antti Koivisto.

FlowContents::Iterator simply iterates on a vector<>. No need to custom implement it.

No change in functionality.

* rendering/SimpleLineLayoutFlowContents.h:
(WebCore::SimpleLineLayout::FlowContents::begin):
(WebCore::SimpleLineLayout::FlowContents::end):
(WebCore::SimpleLineLayout::FlowContents::Iterator::Iterator): Deleted.
(WebCore::SimpleLineLayout::FlowContents::Iterator::operator++): Deleted.
(WebCore::SimpleLineLayout::FlowContents::Iterator::operator--): Deleted.
(WebCore::SimpleLineLayout::FlowContents::Iterator::operator==): Deleted.
(WebCore::SimpleLineLayout::FlowContents::Iterator::operator!=): Deleted.
(WebCore::SimpleLineLayout::FlowContents::Iterator::operator*): Deleted.
(WebCore::SimpleLineLayout::FlowContents::Iterator::operator->): Deleted.
* rendering/SimpleLineLayoutTextFragmentIterator.cpp:
(WebCore::SimpleLineLayout::TextFragmentIterator::skipToNextPosition):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/SimpleLineLayoutFlowContents.h
Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp

index f8c4213..1f622e4 100644 (file)
@@ -1,5 +1,29 @@
 2015-03-17  Zalan Bujtas  <zalan@apple.com>
 
+        Simple line layout: Use Vector<>::const_iterator instead of custom FlowContents::Iterator.
+        https://bugs.webkit.org/show_bug.cgi?id=142809
+
+        Reviewed by Antti Koivisto.
+
+        FlowContents::Iterator simply iterates on a vector<>. No need to custom implement it.
+
+        No change in functionality.
+
+        * rendering/SimpleLineLayoutFlowContents.h:
+        (WebCore::SimpleLineLayout::FlowContents::begin):
+        (WebCore::SimpleLineLayout::FlowContents::end):
+        (WebCore::SimpleLineLayout::FlowContents::Iterator::Iterator): Deleted.
+        (WebCore::SimpleLineLayout::FlowContents::Iterator::operator++): Deleted.
+        (WebCore::SimpleLineLayout::FlowContents::Iterator::operator--): Deleted.
+        (WebCore::SimpleLineLayout::FlowContents::Iterator::operator==): Deleted.
+        (WebCore::SimpleLineLayout::FlowContents::Iterator::operator!=): Deleted.
+        (WebCore::SimpleLineLayout::FlowContents::Iterator::operator*): Deleted.
+        (WebCore::SimpleLineLayout::FlowContents::Iterator::operator->): Deleted.
+        * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
+        (WebCore::SimpleLineLayout::TextFragmentIterator::skipToNextPosition):
+
+2015-03-17  Zalan Bujtas  <zalan@apple.com>
+
         Simple line layout: Change FlowContents::segmentForPosition() to segmentForRun().
         https://bugs.webkit.org/show_bug.cgi?id=142785
 
index b78f296..6379721 100644 (file)
@@ -46,28 +46,9 @@ public:
     const Segment& segmentForRun(unsigned start, unsigned end) const;
     const Segment& segmentForRenderer(const RenderObject&) const;
 
-    class Iterator {
-    public:
-        Iterator(const FlowContents& flowContents, unsigned segmentIndex)
-            : m_flowContents(flowContents)
-            , m_segmentIndex(segmentIndex)
-        {
-        }
-
-        Iterator& operator++();
-        Iterator& operator--();
-        bool operator==(const Iterator& other) const;
-        bool operator!=(const Iterator& other) const;
-        const Segment& operator*() const;
-        const Segment* operator->() const;
-
-    private:
-        const FlowContents& m_flowContents;
-        unsigned m_segmentIndex;
-    };
-
-    Iterator begin() const { return Iterator(*this, 0); }
-    Iterator end() const { return Iterator(*this, m_segments.size()); }
+    typedef Vector<Segment, 8>::const_iterator Iterator;
+    Iterator begin() const { return m_segments.begin(); }
+    Iterator end() const { return m_segments.end(); }
 
 private:
     unsigned segmentIndexForRunSlow(unsigned start, unsigned end) const;
@@ -75,40 +56,6 @@ private:
     mutable unsigned m_lastSegmentIndex;
 };
 
-inline FlowContents::Iterator& FlowContents::Iterator::operator++()
-{
-    ++m_segmentIndex;
-    return *this;
-}
-
-inline FlowContents::Iterator& FlowContents::Iterator::operator--()
-{
-    --m_segmentIndex;
-    return *this;
-}
-
-inline bool FlowContents::Iterator::operator==(const FlowContents::Iterator& other) const
-{
-    return m_segmentIndex == other.m_segmentIndex;
-}
-
-inline bool FlowContents::Iterator::operator!=(const FlowContents::Iterator& other) const
-{
-    return !(*this == other);
-}
-
-inline const FlowContents::Segment& FlowContents::Iterator::operator*() const
-{
-    ASSERT(m_segmentIndex < m_flowContents.m_segments.size());
-    return m_flowContents.m_segments[m_segmentIndex];
-}
-
-inline const FlowContents::Segment* FlowContents::Iterator::operator->() const
-{
-    ASSERT(m_segmentIndex < m_flowContents.m_segments.size());
-    return &(m_flowContents.m_segments[m_segmentIndex]);
-}
-
 inline const FlowContents::Segment& FlowContents::segmentForRun(unsigned start, unsigned end) const
 {
     ASSERT(start < end);
index 0e7437a..2456216 100644 (file)
@@ -157,8 +157,7 @@ unsigned TextFragmentIterator::skipToNextPosition(PositionType positionType, uns
         nextPosition = m_currentSegment->text.is8Bit() ? nextBreakablePosition<LChar>(*m_currentSegment, currentPosition) : nextBreakablePosition<UChar>(*m_currentSegment, currentPosition);
         // We need to know whether the word actually finishes at the end of this renderer or not.
         if (nextPosition == m_currentSegment->end) {
-            auto nextSegment = m_currentSegment;
-            ++nextSegment;
+            const auto nextSegment = m_currentSegment + 1;
             if (nextSegment != m_flowContents.end())
                 overlappingFragment = nextPosition < (nextSegment->text.is8Bit() ? nextBreakablePosition<LChar>(*nextSegment, nextPosition) : nextBreakablePosition<UChar>(*nextSegment, nextPosition));
         } else if (nextPosition == currentPosition) {