From: zalan@apple.com Date: Wed, 18 Mar 2015 04:00:40 +0000 (+0000) Subject: Simple line layout: Use Vector<>::const_iterator instead of custom FlowContents:... X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=c6b9dfd93513ee9d29b13973b82724f8bef71166 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): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181683 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index f8c4213..1f622e4 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,5 +1,29 @@ 2015-03-17 Zalan Bujtas + 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 + Simple line layout: Change FlowContents::segmentForPosition() to segmentForRun(). https://bugs.webkit.org/show_bug.cgi?id=142785 diff --git a/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h b/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h index b78f296..6379721 100644 --- a/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h +++ b/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h @@ -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::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); diff --git a/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp b/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp index 0e7437a..2456216 100644 --- a/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp +++ b/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp @@ -157,8 +157,7 @@ unsigned TextFragmentIterator::skipToNextPosition(PositionType positionType, uns nextPosition = m_currentSegment->text.is8Bit() ? nextBreakablePosition(*m_currentSegment, currentPosition) : nextBreakablePosition(*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(*nextSegment, nextPosition) : nextBreakablePosition(*nextSegment, nextPosition)); } else if (nextPosition == currentPosition) {