Title: [200744] trunk/Source/WebCore
Revision
200744
Author
rn...@webkit.org
Date
2016-05-11 23:47:34 -0700 (Wed, 11 May 2016)

Log Message

TextIteratorStopsOnFormControls is never used
https://bugs.webkit.org/show_bug.cgi?id=157609

Reviewed by Alex Christensen.

Removed SurroundingText.cpp and TextIteratorStopsOnFormControls from TextIterator as they're no longer used.

* editing/SurroundingText.cpp: Removed.
* editing/TextIterator.cpp:
(WebCore::TextIterator::advance):
(WebCore::TextIterator::exitNode):
(WebCore::SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator):
(WebCore::SimplifiedBackwardsTextIterator::advance):
(WebCore::characterSubrange):
(WebCore::BackwardsCharacterIterator::BackwardsCharacterIterator):
* editing/TextIterator.h:
(WebCore::SimplifiedBackwardsTextIterator::atEnd):
* editing/TextIteratorBehavior.h:

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (200743 => 200744)


--- trunk/Source/WebCore/ChangeLog	2016-05-12 06:34:41 UTC (rev 200743)
+++ trunk/Source/WebCore/ChangeLog	2016-05-12 06:47:34 UTC (rev 200744)
@@ -1,3 +1,24 @@
+2016-05-11  Ryosuke Niwa  <rn...@webkit.org>
+
+        TextIteratorStopsOnFormControls is never used
+        https://bugs.webkit.org/show_bug.cgi?id=157609
+
+        Reviewed by Alex Christensen.
+
+        Removed SurroundingText.cpp and TextIteratorStopsOnFormControls from TextIterator as they're no longer used.
+
+        * editing/SurroundingText.cpp: Removed.
+        * editing/TextIterator.cpp:
+        (WebCore::TextIterator::advance):
+        (WebCore::TextIterator::exitNode):
+        (WebCore::SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator):
+        (WebCore::SimplifiedBackwardsTextIterator::advance):
+        (WebCore::characterSubrange):
+        (WebCore::BackwardsCharacterIterator::BackwardsCharacterIterator):
+        * editing/TextIterator.h:
+        (WebCore::SimplifiedBackwardsTextIterator::atEnd):
+        * editing/TextIteratorBehavior.h:
+
 2016-05-11  Chris Dumez  <cdu...@apple.com>
 
         Kill Node::ancestorElement()

Deleted: trunk/Source/WebCore/editing/SurroundingText.cpp (200743 => 200744)


--- trunk/Source/WebCore/editing/SurroundingText.cpp	2016-05-12 06:34:41 UTC (rev 200743)
+++ trunk/Source/WebCore/editing/SurroundingText.cpp	2016-05-12 06:47:34 UTC (rev 200744)
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SurroundingText.h"
-
-#include "Document.h"
-#include "TextIterator.h"
-#include "VisibleSelection.h"
-#include "VisibleUnits.h"
-
-namespace WebCore {
-
-SurroundingText::SurroundingText(const VisiblePosition& visiblePosition, unsigned maxLength)
-    : m_positionOffsetInContent(0)
-{
-    if (visiblePosition.isNull())
-        return;
-
-    const unsigned halfMaxLength = maxLength / 2;
-    CharacterIterator forwardIterator(makeRange(visiblePosition, endOfDocument(visiblePosition)).get(), TextIteratorStopsOnFormControls);
-    if (!forwardIterator.atEnd())
-        forwardIterator.advance(maxLength - halfMaxLength);
-
-    Position position = visiblePosition.deepEquivalent().parentAnchoredEquivalent();
-    Document* document = position.document();
-    RefPtr<Range> forwardRange = forwardIterator.range();
-    if (!forwardRange || !Range::create(document, position, forwardRange->startPosition())->text().length()) {
-        ASSERT(forwardRange);
-        return;
-    }
-
-    BackwardsCharacterIterator backwardsIterator(makeRange(startOfDocument(visiblePosition), visiblePosition).get(), TextIteratorStopsOnFormControls);
-    if (!backwardsIterator.atEnd())
-        backwardsIterator.advance(halfMaxLength);
-
-    RefPtr<Range> backwardsRange = backwardsIterator.range();
-    if (!backwardsRange) {
-        ASSERT(backwardsRange);
-        return;
-    }
-
-    m_positionOffsetInContent = Range::create(document, backwardsRange->endPosition(), position)->text().length();
-    m_contentRange = Range::create(document, backwardsRange->endPosition(), forwardRange->startPosition());
-    ASSERT(m_contentRange);
-}
-
-PassRefPtr<Range> SurroundingText::rangeFromContentOffsets(unsigned startOffsetInContent, unsigned endOffsetInContent)
-{
-    if (startOffsetInContent >= endOffsetInContent || endOffsetInContent > content().length())
-        return 0;
-
-    CharacterIterator iterator(m_contentRange.get());
-
-    ASSERT(!iterator.atEnd());
-    iterator.advance(startOffsetInContent);
-
-    ASSERT(iterator.range());
-    Position start = iterator.range()->startPosition();
-
-    ASSERT(!iterator.atEnd());
-    iterator.advance(endOffsetInContent - startOffsetInContent);
-
-    ASSERT(iterator.range());
-    Position end = iterator.range()->startPosition();
-
-    return Range::create(start.document(), start, end);
-}
-
-String SurroundingText::content() const
-{
-    if (m_contentRange)
-        return m_contentRange->text();
-    return String();
-}
-
-unsigned SurroundingText::positionOffsetInContent() const
-{
-    return m_positionOffsetInContent;
-}
-
-} // namespace WebCore

Modified: trunk/Source/WebCore/editing/TextIterator.cpp (200743 => 200744)


--- trunk/Source/WebCore/editing/TextIterator.cpp	2016-05-12 06:34:41 UTC (rev 200743)
+++ trunk/Source/WebCore/editing/TextIterator.cpp	2016-05-12 06:47:34 UTC (rev 200744)
@@ -414,9 +414,6 @@
     }
 
     while (m_node && m_node != m_pastEndNode) {
-        if ((m_behavior & TextIteratorStopsOnFormControls) && HTMLFormControlElement::enclosingFormControlElement(m_node))
-            return;
-
         // if the range ends at offset 0 of an element, represent the
         // position, but not the content, of that element e.g. if the
         // node is a blockflow element, emit a newline that
@@ -1188,26 +1185,8 @@
 
 // --------
 
-SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator(const Range& range, TextIteratorBehavior behavior)
-    : m_behavior(behavior)
-    , m_node(nullptr)
-    , m_offset(0)
-    , m_handledNode(false)
-    , m_handledChildren(false)
-    , m_startContainer(nullptr)
-    , m_startOffset(0)
-    , m_endContainer(nullptr)
-    , m_endOffset(0)
-    , m_positionNode(nullptr)
-    , m_positionStartOffset(0)
-    , m_positionEndOffset(0)
-    , m_lastTextNode(nullptr)
-    , m_lastCharacter(0)
-    , m_havePassedStartContainer(false)
-    , m_shouldHandleFirstLetter(false)
+SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator(const Range& range)
 {
-    ASSERT(behavior == TextIteratorDefaultBehavior || behavior == TextIteratorStopsOnFormControls);
-
     range.ownerDocument().updateLayoutIgnorePendingStylesheets();
 
     Node* startNode = &range.startContainer();
@@ -1260,9 +1239,6 @@
     m_copyableText.reset();
     m_text = StringView();
 
-    if ((m_behavior & TextIteratorStopsOnFormControls) && HTMLFormControlElement::enclosingFormControlElement(m_node))
-        return;
-
     while (m_node && !m_havePassedStartContainer) {
         // Don't handle node if we start iterating at [node, 0].
         if (!m_handledNode && !(m_node == m_endContainer && !m_endOffset)) {
@@ -1554,7 +1530,7 @@
 }
 
 BackwardsCharacterIterator::BackwardsCharacterIterator(const Range& range)
-    : m_underlyingIterator(range, TextIteratorDefaultBehavior)
+    : m_underlyingIterator(range)
     , m_offset(0)
     , m_runOffset(0)
     , m_atBreak(true)

Modified: trunk/Source/WebCore/editing/TextIterator.h (200743 => 200744)


--- trunk/Source/WebCore/editing/TextIterator.h	2016-05-12 06:34:41 UTC (rev 200743)
+++ trunk/Source/WebCore/editing/TextIterator.h	2016-05-12 06:47:34 UTC (rev 200744)
@@ -188,7 +188,7 @@
 // chunks so as to optimize for performance of the iteration.
 class SimplifiedBackwardsTextIterator {
 public:
-    explicit SimplifiedBackwardsTextIterator(const Range&, TextIteratorBehavior = TextIteratorDefaultBehavior);
+    explicit SimplifiedBackwardsTextIterator(const Range&);
 
     bool atEnd() const { return !m_positionNode; }
     void advance();
@@ -206,37 +206,37 @@
     void emitCharacter(UChar, Node&, int startOffset, int endOffset);
     bool advanceRespectingRange(Node*);
 
-    const TextIteratorBehavior m_behavior;
+    const TextIteratorBehavior m_behavior { TextIteratorDefaultBehavior };
 
     // Current position, not necessarily of the text being returned, but position as we walk through the DOM tree.
-    Node* m_node;
-    int m_offset;
-    bool m_handledNode;
-    bool m_handledChildren;
+    Node* m_node { nullptr };
+    int m_offset { 0 };
+    bool m_handledNode { false };
+    bool m_handledChildren { false };
     BitStack m_fullyClippedStack;
 
     // The range.
-    Node* m_startContainer;
-    int m_startOffset;
-    Node* m_endContainer;
-    int m_endOffset;
+    Node* m_startContainer { nullptr };
+    int m_startOffset { 0 };
+    Node* m_endContainer { nullptr };
+    int m_endOffset { 0 };
     
     // The current text and its position, in the form to be returned from the iterator.
-    Node* m_positionNode;
-    int m_positionStartOffset;
-    int m_positionEndOffset;
+    Node* m_positionNode { nullptr };
+    int m_positionStartOffset { 0 };
+    int m_positionEndOffset { 0 };
     TextIteratorCopyableText m_copyableText;
     StringView m_text;
 
     // Used to do the whitespace logic.
-    Text* m_lastTextNode;
-    UChar m_lastCharacter;
+    Text* m_lastTextNode { nullptr };
+    UChar m_lastCharacter { 0 };
 
     // Whether m_node has advanced beyond the iteration range (i.e. m_startContainer).
-    bool m_havePassedStartContainer;
+    bool m_havePassedStartContainer { false };
 
     // Should handle first-letter renderer in the next call to handleTextNode.
-    bool m_shouldHandleFirstLetter;
+    bool m_shouldHandleFirstLetter { false };
 };
 
 // Builds on the text iterator, adding a character position so we can walk one

Modified: trunk/Source/WebCore/editing/TextIteratorBehavior.h (200743 => 200744)


--- trunk/Source/WebCore/editing/TextIteratorBehavior.h	2016-05-12 06:34:41 UTC (rev 200743)
+++ trunk/Source/WebCore/editing/TextIteratorBehavior.h	2016-05-12 06:47:34 UTC (rev 200744)
@@ -51,11 +51,9 @@
     // Used when pasting inside password field.
     TextIteratorEmitsOriginalText = 1 << 5,
 
-    TextIteratorStopsOnFormControls = 1 << 6,
+    TextIteratorEmitsImageAltText = 1 << 6,
 
-    TextIteratorEmitsImageAltText = 1 << 7,
-
-    TextIteratorBehavesAsIfNodesFollowing = 1 << 8,
+    TextIteratorBehavesAsIfNodesFollowing = 1 << 7,
 };
 
 typedef unsigned short TextIteratorBehavior;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to