Streamline use of TextIterator, cutting down includes and use of soon-to-be-deleted...
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Mar 2014 02:30:37 +0000 (02:30 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Mar 2014 02:30:37 +0000 (02:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129592

Reviewed by Sam Weinig.

Source/WebCore:

* WebCore.exp.in: Re-sorted this file. Not sure how it got unsorted.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::stringForVisiblePositionRange): Call TextIterator::text
instead of TextIterator::length. Also removed unneeded special case for empty string
and exception code.
(WebCore::AccessibilityObject::lengthForVisiblePositionRange): Ditto.

* accessibility/AccessibilityObject.h: Include TextIteratorBehavior.h instead of
TextIterator.h.

* accessibility/AccessibilityRenderObject.cpp: Include TextIterator.h.

* accessibility/mac/WebAccessibilityObjectWrapperBase.mm: Removed unneeded
TextIterator.h include.

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]): Call
TextIterator::text instead of TextIterator::length.

* dom/Element.cpp: Include TextIterator.h.

* dom/Node.cpp: Include Range.h.

* dom/Position.cpp:
(WebCore::Position::isCandidate): Cast to RenderBlockFlow since that's what the
type check above does. Use a return statement instead of an else for better flow.
(WebCore::Position::leadingWhitespacePosition): Call
deprecatedIsCollapsibleWhitespace by its new name (newly deprecated).
(WebCore::Position::trailingWhitespacePosition): Ditto.

* dom/Range.cpp:
(WebCore::Range::firstNode): Added a FIXME about code that clearly does not
belong. This is something we really need to fix.

* editing/AlternativeTextController.cpp: Include TextIterator.h.
* editing/ApplyStyleCommand.cpp: Ditto.

* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::prepareWhitespaceAtPositionForSplit): Call
deprecatedIsCollapsibleWhitespace by its new name (newly deprecated).

* editing/Editor.h: Include TextIteratorBehavior.h instead of TextIterator.h.

* editing/HTMLInterchange.cpp:
(WebCore::convertHTMLTextToInterchangeFormat): Call
deprecatedIsCollapsibleWhitespace by its new name (newly deprecated).

* editing/SpellingCorrectionCommand.cpp: Include TextIterator.h.

* editing/TextIterator.h: Moved isCollapsibleWhitespace from here into
htmlediting.h and renamed it deprecatedIsCollapsibleWhitespace.

* editing/TextIterator.cpp: Call
deprecatedIsCollapsibleWhitespace by its new name (newly deprecated).

* editing/TypingCommand.cpp: Include TextIterator.h.

* editing/VisibleUnits.cpp:
(WebCore::previousBoundary): Call TextIterator::text instead of
TextIterator::length.
(WebCore::nextBoundary): Ditto.

* editing/htmlediting.cpp: Include TextIterator.h.

* editing/htmlediting.h: Removed non-helpful section comments.
Added FIXME about isWhitespace. Added deprecatedIsCollapsibleWhitespace,
formerly not deprecated and in TextIterator.h.

* editing/markup.cpp: Include TextIterator.h.

* html/HTMLTextAreaElement.cpp: Include TextIterator.h.

* page/ContextMenuController.cpp:
(WebCore::selectionContainsPossibleWord): Call TextIterator::text
instead of TextIterator::length and TextIterator::characterAt.

* page/EventHandler.cpp: Sorted conditional includes alphabetically by condition.

* platform/mac/HTMLConverter.mm:
(+[WebHTMLConverter editingAttributedStringFromRange:]): Call TextIterator::text
instead of TextIterator::length.

Source/WebKit/win:

* WebCoreSupport/WebEditorClient.cpp: Added now-needed include.

Source/WebKit2:

* UIProcess/WebPageProxy.cpp: Added now-needed include.
* WebProcess/WebPage/WebPage.cpp: Ditto.

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

33 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Position.cpp
Source/WebCore/dom/Range.cpp
Source/WebCore/editing/AlternativeTextController.cpp
Source/WebCore/editing/ApplyStyleCommand.cpp
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/editing/HTMLInterchange.cpp
Source/WebCore/editing/SpellingCorrectionCommand.cpp
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/editing/TextIterator.h
Source/WebCore/editing/TypingCommand.cpp
Source/WebCore/editing/VisibleUnits.cpp
Source/WebCore/editing/htmlediting.cpp
Source/WebCore/editing/htmlediting.h
Source/WebCore/editing/markup.cpp
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/page/ContextMenuController.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebCore/platform/mac/HTMLConverter.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 2f00b10..ff25522 100644 (file)
@@ -1,3 +1,93 @@
+2014-03-02  Darin Adler  <darin@apple.com>
+
+        Streamline use of TextIterator, cutting down includes and use of soon-to-be-deleted functions
+        https://bugs.webkit.org/show_bug.cgi?id=129592
+
+        Reviewed by Sam Weinig.
+
+        * WebCore.exp.in: Re-sorted this file. Not sure how it got unsorted.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::stringForVisiblePositionRange): Call TextIterator::text
+        instead of TextIterator::length. Also removed unneeded special case for empty string
+        and exception code.
+        (WebCore::AccessibilityObject::lengthForVisiblePositionRange): Ditto.
+
+        * accessibility/AccessibilityObject.h: Include TextIteratorBehavior.h instead of
+        TextIterator.h.
+
+        * accessibility/AccessibilityRenderObject.cpp: Include TextIterator.h.
+
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm: Removed unneeded
+        TextIterator.h include.
+
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper doAXAttributedStringForTextMarkerRange:]): Call
+        TextIterator::text instead of TextIterator::length.
+
+        * dom/Element.cpp: Include TextIterator.h.
+
+        * dom/Node.cpp: Include Range.h.
+
+        * dom/Position.cpp:
+        (WebCore::Position::isCandidate): Cast to RenderBlockFlow since that's what the
+        type check above does. Use a return statement instead of an else for better flow.
+        (WebCore::Position::leadingWhitespacePosition): Call
+        deprecatedIsCollapsibleWhitespace by its new name (newly deprecated).
+        (WebCore::Position::trailingWhitespacePosition): Ditto.
+
+        * dom/Range.cpp:
+        (WebCore::Range::firstNode): Added a FIXME about code that clearly does not
+        belong. This is something we really need to fix.
+
+        * editing/AlternativeTextController.cpp: Include TextIterator.h.
+        * editing/ApplyStyleCommand.cpp: Ditto.
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::prepareWhitespaceAtPositionForSplit): Call
+        deprecatedIsCollapsibleWhitespace by its new name (newly deprecated).
+
+        * editing/Editor.h: Include TextIteratorBehavior.h instead of TextIterator.h.
+
+        * editing/HTMLInterchange.cpp:
+        (WebCore::convertHTMLTextToInterchangeFormat): Call
+        deprecatedIsCollapsibleWhitespace by its new name (newly deprecated).
+
+        * editing/SpellingCorrectionCommand.cpp: Include TextIterator.h.
+
+        * editing/TextIterator.h: Moved isCollapsibleWhitespace from here into
+        htmlediting.h and renamed it deprecatedIsCollapsibleWhitespace.
+
+        * editing/TextIterator.cpp: Call
+        deprecatedIsCollapsibleWhitespace by its new name (newly deprecated).
+
+        * editing/TypingCommand.cpp: Include TextIterator.h.
+
+        * editing/VisibleUnits.cpp:
+        (WebCore::previousBoundary): Call TextIterator::text instead of
+        TextIterator::length.
+        (WebCore::nextBoundary): Ditto.
+
+        * editing/htmlediting.cpp: Include TextIterator.h.
+
+        * editing/htmlediting.h: Removed non-helpful section comments.
+        Added FIXME about isWhitespace. Added deprecatedIsCollapsibleWhitespace,
+        formerly not deprecated and in TextIterator.h.
+
+        * editing/markup.cpp: Include TextIterator.h.
+
+        * html/HTMLTextAreaElement.cpp: Include TextIterator.h.
+
+        * page/ContextMenuController.cpp:
+        (WebCore::selectionContainsPossibleWord): Call TextIterator::text
+        instead of TextIterator::length and TextIterator::characterAt.
+
+        * page/EventHandler.cpp: Sorted conditional includes alphabetically by condition.
+
+        * platform/mac/HTMLConverter.mm:
+        (+[WebHTMLConverter editingAttributedStringFromRange:]): Call TextIterator::text
+        instead of TextIterator::length.
+
 2014-03-02  Benjamin Poulain  <benjamin@webkit.org>
 
         Add a fallback path for compiling the remaining attribute checkers
index bb1f60c..fd82b1c 100644 (file)
@@ -1339,8 +1339,8 @@ __ZN7WebCore9FrameView52disableLayerFlushThrottlingTemporarilyForInteractionEv
 __ZN7WebCore9FrameView6createERNS_5FrameE
 __ZN7WebCore9HTMLNames10actionAttrE
 __ZN7WebCore9HTMLNames10listingTagE
-__ZN7WebCore9HTMLNames11textareaTagE
 __ZN7WebCore9HTMLNames11optgroupTagE
+__ZN7WebCore9HTMLNames11textareaTagE
 __ZN7WebCore9HTMLNames12disabledAttrE
 __ZN7WebCore9HTMLNames12selectedAttrE
 __ZN7WebCore9HTMLNames13blockquoteTagE
index 9b7ee1f..acb6f2f 100644 (file)
@@ -59,6 +59,7 @@
 #include "Settings.h"
 #include "TextCheckerClient.h"
 #include "TextCheckingHelper.h"
+#include "TextIterator.h"
 #include "UserGestureIndicator.h"
 #include "VisibleUnits.h"
 #include "htmlediting.h"
@@ -1039,20 +1040,15 @@ String AccessibilityObject::stringForVisiblePositionRange(const VisiblePositionR
     RefPtr<Range> range = makeRange(visiblePositionRange.start, visiblePositionRange.end);
     for (TextIterator it(range.get()); !it.atEnd(); it.advance()) {
         // non-zero length means textual node, zero length means replaced node (AKA "attachments" in AX)
-        if (it.length()) {
-            // Add a textual representation for list marker text
-            String listMarkerText = listMarkerTextForNodeAndPosition(it.node(), visiblePositionRange.start);
-            if (!listMarkerText.isEmpty())
-                builder.append(listMarkerText);
-
+        if (it.text().length()) {
+            // Add a textual representation for list marker text.
+            builder.append(listMarkerTextForNodeAndPosition(it.node(), visiblePositionRange.start));
             it.appendTextToStringBuilder(builder);
         } else {
             // locate the node and starting offset for this replaced range
-            int exception = 0;
-            Node* node = it.range()->startContainer(exception);
-            ASSERT(node == it.range()->endContainer(exception));
-            int offset = it.range()->startOffset(exception);
-
+            Node* node = it.range()->startContainer();
+            ASSERT(node == it.range()->endContainer());
+            int offset = it.range()->startOffset();
             if (replacedNodeNeedsCharacter(node->childNode(offset)))
                 builder.append(objectReplacementCharacter);
         }
@@ -1071,8 +1067,8 @@ int AccessibilityObject::lengthForVisiblePositionRange(const VisiblePositionRang
     RefPtr<Range> range = makeRange(visiblePositionRange.start, visiblePositionRange.end);
     for (TextIterator it(range.get()); !it.atEnd(); it.advance()) {
         // non-zero length means textual node, zero length means replaced node (AKA "attachments" in AX)
-        if (it.length())
-            length += it.length();
+        if (it.text().length())
+            length += it.text().length();
         else {
             // locate the node and starting offset for this replaced range
             int exception = 0;
index b4f0fb5..6e1e93b 100644 (file)
@@ -33,7 +33,7 @@
 #include "FloatQuad.h"
 #include "LayoutRect.h"
 #include "Path.h"
-#include "TextIterator.h"
+#include "TextIteratorBehavior.h"
 #include "VisiblePosition.h"
 #include "VisibleSelection.h"
 #include <wtf/Forward.h>
index e1ac1e8..fc90767 100644 (file)
@@ -97,6 +97,7 @@
 #include "SVGSVGElement.h"
 #include "Text.h"
 #include "TextControlInnerElements.h"
+#include "TextIterator.h"
 #include "VisibleUnits.h"
 #include "htmlediting.h"
 #include <wtf/StdLibExtras.h>
index 817e953..e476d8f 100644 (file)
@@ -66,7 +66,6 @@
 #import "SimpleFontData.h"
 #import "TextCheckerClient.h"
 #import "TextCheckingHelper.h"
-#import "TextIterator.h"
 #import "VisibleUnits.h"
 #import "WebCoreFrameView.h"
 #import "WebCoreObjCExtras.h"
index d40290a..c8bb344 100644 (file)
@@ -1069,7 +1069,7 @@ static NSString* nsStringForReplacedNode(Node* replacedNode)
         int offset = it.range()->startOffset(exception);
         
         // non-zero length means textual node, zero length means replaced node (AKA "attachments" in AX)
-        if (it.length() != 0) {
+        if (it.text().length()) {
             // Add the text of the list marker item if necessary.
             String listMarkerText = m_object->listMarkerTextForNodeAndPosition(node, VisiblePosition(it.range()->startPosition()));
             if (!listMarkerText.isEmpty())
index 3408df5..897e7a0 100644 (file)
@@ -73,6 +73,7 @@
 #include "Settings.h"
 #include "StyleProperties.h"
 #include "StyleResolver.h"
+#include "TextIterator.h"
 #include "VoidCallback.h"
 #include "WheelEvent.h"
 #include "XMLNSNames.h"
index ceae536..a99aea4 100644 (file)
@@ -61,6 +61,7 @@
 #include "PlatformWheelEvent.h"
 #include "ProcessingInstruction.h"
 #include "ProgressEvent.h"
+#include "Range.h"
 #include "RenderBlock.h"
 #include "RenderBox.h"
 #include "RenderTextControl.h"
index 6f4c62a..9f08c62 100644 (file)
@@ -939,16 +939,16 @@ bool Position::isCandidate() const
         return !nodeIsUserSelectNone(deprecatedNode()) && atFirstEditingPositionForNode();
 
     if (renderer->isRenderBlockFlow()) {
-        RenderBlock& block = toRenderBlock(*renderer);
+        RenderBlockFlow& block = toRenderBlockFlow(*renderer);
         if (block.logicalHeight() || m_anchorNode->hasTagName(bodyTag)) {
             if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(block))
                 return atFirstEditingPositionForNode() && !Position::nodeIsUserSelectNone(deprecatedNode());
             return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSelectNone(deprecatedNode()) && atEditingBoundary();
         }
-    } else
-        return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSelectNone(deprecatedNode()) && atEditingBoundary();
+        return false;
+    }
 
-    return false;
+    return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSelectNone(deprecatedNode()) && atEditingBoundary();
 }
 
 bool Position::isRenderedCharacter() const
@@ -1068,7 +1068,7 @@ Position Position::leadingWhitespacePosition(EAffinity affinity, bool considerNo
     if (prev != *this && inSameEnclosingBlockFlowElement(deprecatedNode(), prev.deprecatedNode()) && prev.deprecatedNode()->isTextNode()) {
         String string = toText(prev.deprecatedNode())->data();
         UChar c = string[prev.deprecatedEditingOffset()];
-        if (considerNonCollapsibleWhitespace ? (isSpaceOrNewline(c) || c == noBreakSpace) : isCollapsibleWhitespace(c))
+        if (considerNonCollapsibleWhitespace ? (isSpaceOrNewline(c) || c == noBreakSpace) : deprecatedIsCollapsibleWhitespace(c))
             if (isEditablePosition(prev))
                 return prev;
     }
@@ -1087,7 +1087,7 @@ Position Position::trailingWhitespacePosition(EAffinity, bool considerNonCollaps
     UChar c = v.characterAfter();
     // The space must not be in another paragraph and it must be editable.
     if (!isEndOfParagraph(v) && v.next(CannotCrossEditingBoundary).isNotNull())
-        if (considerNonCollapsibleWhitespace ? (isSpaceOrNewline(c) || c == noBreakSpace) : isCollapsibleWhitespace(c))
+        if (considerNonCollapsibleWhitespace ? (isSpaceOrNewline(c) || c == noBreakSpace) : deprecatedIsCollapsibleWhitespace(c))
             return *this;
     
     return Position();
index c3e8a57..4fe719e 100644 (file)
@@ -1570,6 +1570,8 @@ Node* Range::firstNode() const
         return 0;
     if (m_start.container()->offsetInCharacters())
         return m_start.container();
+    // FIXME: A renderer-based rule is completely out of place here.
+    // For one thing, the renderer could be out of date if the DOM was recently changed.
     if (isRendererReplacedElement(m_start.container()->renderer()))
         return m_start.container();
     if (Node* child = m_start.container()->childNode(m_start.offset()))
index 2e7ec46..5021623 100644 (file)
@@ -41,6 +41,7 @@
 #include "TextCheckerClient.h"
 #include "TextCheckingHelper.h"
 #include "TextEvent.h"
+#include "TextIterator.h"
 #include "VisibleUnits.h"
 #include "htmlediting.h"
 #include "markup.h"
index 95310f5..aac90f7 100644 (file)
@@ -43,6 +43,7 @@
 #include "StyleProperties.h"
 #include "StyleResolver.h"
 #include "Text.h"
+#include "TextIterator.h"
 #include "TextNodeTraversal.h"
 #include "VisibleUnits.h"
 #include "htmlediting.h"
index 314283d..0021ec3 100644 (file)
@@ -773,9 +773,9 @@ void CompositeEditCommand::prepareWhitespaceAtPositionForSplit(Position& positio
     VisiblePosition previousVisiblePos(visiblePos.previous());
     Position previous(previousVisiblePos.deepEquivalent());
     
-    if (isCollapsibleWhitespace(previousVisiblePos.characterAfter()) && previous.deprecatedNode()->isTextNode() && !previous.deprecatedNode()->hasTagName(brTag))
+    if (deprecatedIsCollapsibleWhitespace(previousVisiblePos.characterAfter()) && previous.deprecatedNode()->isTextNode() && !previous.deprecatedNode()->hasTagName(brTag))
         replaceTextInNodePreservingMarkers(toText(previous.deprecatedNode()), previous.deprecatedEditingOffset(), 1, nonBreakingSpaceString());
-    if (isCollapsibleWhitespace(visiblePos.characterAfter()) && position.deprecatedNode()->isTextNode() && !position.deprecatedNode()->hasTagName(brTag))
+    if (deprecatedIsCollapsibleWhitespace(visiblePos.characterAfter()) && position.deprecatedNode()->isTextNode() && !position.deprecatedNode()->hasTagName(brTag))
         replaceTextInNodePreservingMarkers(toText(position.deprecatedNode()), position.deprecatedEditingOffset(), 1, nonBreakingSpaceString());
 }
 
index c567260..d115ee8 100644 (file)
@@ -37,7 +37,7 @@
 #include "FindOptions.h"
 #include "FrameSelection.h"
 #include "TextChecking.h"
-#include "TextIterator.h"
+#include "TextIteratorBehavior.h"
 #include "VisibleSelection.h"
 #include "WritingDirection.h"
 
index 2f72951..3bb0fe9 100644 (file)
@@ -30,6 +30,7 @@
 #include "RenderText.h"
 #include "Text.h"
 #include "TextIterator.h"
+#include "htmlediting.h"
 #include <wtf/text/StringBuilder.h>
 #include <wtf/unicode/CharacterNames.h>
 
@@ -50,10 +51,10 @@ String convertHTMLTextToInterchangeFormat(const String& in, const Text* node)
     unsigned consumed = 0;
     while (i < in.length()) {
         consumed = 1;
-        if (isCollapsibleWhitespace(in[i])) {
+        if (deprecatedIsCollapsibleWhitespace(in[i])) {
             // count number of adjoining spaces
             unsigned j = i + 1;
-            while (j < in.length() && isCollapsibleWhitespace(in[j]))
+            while (j < in.length() && deprecatedIsCollapsibleWhitespace(in[j]))
                 j++;
             unsigned count = j - i;
             consumed = count;
index 943e483..570c22e 100644 (file)
@@ -33,6 +33,7 @@
 #include "Frame.h"
 #include "ReplaceSelectionCommand.h"
 #include "SetSelectionCommand.h"
+#include "TextIterator.h"
 #include "markup.h"
 
 namespace WebCore {
index 0b8cab3..f5617bd 100644 (file)
@@ -540,15 +540,15 @@ bool TextIterator::handleTextNode()
         // This code aims to produce same results as handleTextBox() below so test results don't change. It does not make much logical sense.
         unsigned runEnd = m_offset;
         unsigned runStart = m_offset;
-        while (runEnd < str.length() && (isCollapsibleWhitespace(str[runEnd]) || str[runEnd] == '\t'))
+        while (runEnd < str.length() && (deprecatedIsCollapsibleWhitespace(str[runEnd]) || str[runEnd] == '\t'))
             ++runEnd;
-        bool addSpaceForPrevious = m_lastTextNodeEndedWithCollapsedSpace && m_lastCharacter && !isCollapsibleWhitespace(m_lastCharacter);
+        bool addSpaceForPrevious = m_lastTextNodeEndedWithCollapsedSpace && m_lastCharacter && !deprecatedIsCollapsibleWhitespace(m_lastCharacter);
         if (runEnd > runStart || addSpaceForPrevious) {
             if (runEnd == str.length()) {
                 m_lastTextNodeEndedWithCollapsedSpace = true;
                 return true;
             }
-            bool addSpaceForCurrent = runStart || (m_lastCharacter && !isCollapsibleWhitespace(m_lastCharacter));
+            bool addSpaceForCurrent = runStart || (m_lastCharacter && !deprecatedIsCollapsibleWhitespace(m_lastCharacter));
             if (addSpaceForCurrent || addSpaceForPrevious) {
                 emitCharacter(' ', m_node, 0, runStart, runEnd);
                 m_offset = runEnd;
@@ -556,7 +556,7 @@ bool TextIterator::handleTextNode()
             }
             runStart = runEnd;
         }
-        while (runEnd < str.length() && !isCollapsibleWhitespace(str[runEnd]))
+        while (runEnd < str.length() && !deprecatedIsCollapsibleWhitespace(str[runEnd]))
             ++runEnd;
         if (runStart < str.length())
             emitText(m_node, renderer, runStart, runEnd);
@@ -614,7 +614,7 @@ void TextIterator::handleTextBox()
         InlineTextBox* firstTextBox = renderer->containsReversedText() ? (m_sortedTextBoxes.isEmpty() ? 0 : m_sortedTextBoxes[0]) : renderer->firstTextBox();
         bool needSpace = m_lastTextNodeEndedWithCollapsedSpace
             || (m_textBox == firstTextBox && textBoxStart == runStart && runStart > 0);
-        if (needSpace && !isCollapsibleWhitespace(m_lastCharacter) && m_lastCharacter) {
+        if (needSpace && !deprecatedIsCollapsibleWhitespace(m_lastCharacter) && m_lastCharacter) {
             if (m_lastTextNode == m_node && runStart > 0 && str[runStart - 1] == ' ') {
                 unsigned spaceRunStart = runStart - 1;
                 while (spaceRunStart > 0 && str[spaceRunStart - 1] == ' ')
index b9402d6..749f127 100644 (file)
@@ -38,19 +38,6 @@ class InlineTextBox;
 class RenderText;
 class RenderTextFragment;
 
-// FIXME: Can't really answer this question correctly without knowing the white-space mode.
-// FIXME: Move this somewhere else in the editing directory. It doesn't belong here.
-inline bool isCollapsibleWhitespace(UChar c)
-{
-    switch (c) {
-        case ' ':
-        case '\n':
-            return true;
-        default:
-            return false;
-    }
-}
-
 String plainText(const Range*, TextIteratorBehavior = TextIteratorDefaultBehavior, bool isDisplayString = false);
 PassRefPtr<Range> findPlainText(const Range*, const String&, FindOptions);
 
index ce0e3b8..ba107c1 100644 (file)
@@ -37,6 +37,7 @@
 #include "InsertParagraphSeparatorCommand.h"
 #include "InsertTextCommand.h"
 #include "RenderElement.h"
+#include "TextIterator.h"
 #include "VisibleUnits.h"
 #include "htmlediting.h"
 
index 4b49541..b04247b 100644 (file)
@@ -531,7 +531,7 @@ static VisiblePosition previousBoundary(const VisiblePosition& c, BoundarySearch
             prepend(string, it.text());
         else {
             // Treat bullets used in the text security mode as regular characters when looking for boundaries
-            prependRepeatedCharacter(string, 'x', it.length());
+            prependRepeatedCharacter(string, 'x', it.text().length());
         }
         if (string.size() > suffixLength) {
             next = searchFunction(StringView(string.data(), string.size()), string.size() - suffixLength, MayHaveMoreContext, needMoreContext);
@@ -604,7 +604,7 @@ static VisiblePosition nextBoundary(const VisiblePosition& c, BoundarySearchFunc
             append(string, it.text());
         else {
             // Treat bullets used in the text security mode as regular characters when looking for boundaries
-            appendRepeatedCharacter(string, 'x', it.length());
+            appendRepeatedCharacter(string, 'x', it.text().length());
         }
         if (string.size() > prefixLength) {
             next = searchFunction(StringView(string.data(), string.size()), prefixLength, MayHaveMoreContext, needMoreContext);
index fedd8c7..050583d 100644 (file)
@@ -49,6 +49,7 @@
 #include "RenderElement.h"
 #include "ShadowRoot.h"
 #include "Text.h"
+#include "TextIterator.h"
 #include "VisibleUnits.h"
 #include <wtf/Assertions.h>
 #include <wtf/StdLibExtras.h>
index 317e969..363db8a 100644 (file)
@@ -44,7 +44,6 @@ class Range;
 class VisiblePosition;
 class VisibleSelection;
 
-
 // This file contains a set of helper functions used by the editing commands
 
 // -------------------------------------------------------------------------
@@ -214,9 +213,7 @@ Node* enclosingListChild(Node*);
 // -------------------------------------------------------------------------
 // Element
 // -------------------------------------------------------------------------
-    
-// Functions returning Element
-    
+
 PassRefPtr<Element> createTabSpanElement(Document&);
 PassRefPtr<Element> createTabSpanElement(Document&, PassRefPtr<Node> tabTextNode);
 PassRefPtr<Element> createTabSpanElement(Document&, const String& tabText);
@@ -225,26 +222,30 @@ PassRefPtr<Element> createBlockPlaceholderElement(Document&);
 Element* editableRootForPosition(const Position&, EditableType = ContentIsEditable);
 Element* unsplittableElementForPosition(const Position&);
 
-// Boolean functions on Element
-    
 bool canMergeLists(Element* firstList, Element* secondList);
     
 // -------------------------------------------------------------------------
 // VisibleSelection
 // -------------------------------------------------------------------------
 
-// Functions returning VisibleSelection
 VisibleSelection selectionForParagraphIteration(const VisibleSelection&);
 
 Position adjustedSelectionStartForStyleComputation(const VisibleSelection&);
     
+// -------------------------------------------------------------------------
 
-// Miscellaneous functions on Text
+// FIXME: This is only one of many definitions of whitespace, so the name is not specific enough.
 inline bool isWhitespace(UChar c)
 {
     return c == noBreakSpace || c == ' ' || c == '\n' || c == '\t';
 }
 
+// FIXME: Can't really answer this question correctly without knowing the white-space mode.
+inline bool deprecatedIsCollapsibleWhitespace(UChar c)
+{
+    return c == ' ' || c == '\n';
+}
+
 inline bool isAmbiguousBoundaryCharacter(UChar character)
 {
     // These are characters that can behave as word boundaries, but can appear within words.
index f4b34e3..d000e6b 100644 (file)
@@ -54,6 +54,7 @@
 #include "RenderBlock.h"
 #include "Settings.h"
 #include "StyleProperties.h"
+#include "TextIterator.h"
 #include "VisibleSelection.h"
 #include "VisibleUnits.h"
 #include "htmlediting.h"
index 6a2d60a..d0b6d06 100644 (file)
@@ -47,6 +47,7 @@
 #include "Text.h"
 #include "TextBreakIterator.h"
 #include "TextControlInnerElements.h"
+#include "TextIterator.h"
 #include "TextNodeTraversal.h"
 #include <wtf/Ref.h>
 #include <wtf/StdLibExtras.h>
index c61e8a9..70373aa 100644 (file)
@@ -718,9 +718,9 @@ static bool selectionContainsPossibleWord(Frame* frame)
 {
     // Current algorithm: look for a character that's not just a separator.
     for (TextIterator it(frame->selection().toNormalizedRange().get()); !it.atEnd(); it.advance()) {
-        int length = it.length();
+        int length = it.text().length();
         for (int i = 0; i < length; ++i) {
-            if (!(U_GET_GC_MASK(it.characterAt(i)) & U_GC_Z_MASK))
+            if (!(U_GET_GC_MASK(it.text()[i]) & U_GC_Z_MASK))
                 return true;
         }
     }
index 0f8a9cb..b63f9a9 100644 (file)
 #include <wtf/StdLibExtras.h>
 #include <wtf/TemporaryChange.h>
 
-#if ENABLE(TOUCH_EVENTS)
+#if ENABLE(CSS_IMAGE_SET)
+#include "StyleCachedImageSet.h"
+#endif
+
 #if ENABLE(IOS_TOUCH_EVENTS)
 #include "PlatformTouchEventIOS.h"
-#else
-#include "PlatformTouchEvent.h"
 #endif
+
+#if ENABLE(TOUCH_EVENTS)
 #include "TouchEvent.h"
 #include "TouchList.h"
 #endif
 
-#if ENABLE(CSS_IMAGE_SET)
-#include "StyleCachedImageSet.h"
+#if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
+#include "PlatformTouchEvent.h"
 #endif
 
 namespace WebCore {
index 84811a5..07648f2 100644 (file)
@@ -2499,7 +2499,7 @@ static NSInteger _colCompare(id block1, id block2, void *)
             }
         }
 
-        int currentTextLength = it.length();
+        int currentTextLength = it.text().length();
         if (!currentTextLength)
             continue;
 
index 4334e82..666c0b6 100644 (file)
@@ -1,3 +1,12 @@
+2014-03-02  Darin Adler  <darin@apple.com>
+
+        Streamline use of TextIterator, cutting down includes and use of soon-to-be-deleted functions
+        https://bugs.webkit.org/show_bug.cgi?id=129592
+
+        Reviewed by Sam Weinig.
+
+        * WebCoreSupport/WebEditorClient.cpp: Added now-needed include.
+
 2014-02-25  Anders Carlsson  <andersca@apple.com>
 
         Get rid of VisitedLinkStrategy
index 01b23c8..84f9afc 100644 (file)
@@ -47,6 +47,7 @@
 #include <WebCore/UndoStep.h>
 #include <WebCore/UserTypingGestureIndicator.h>
 #include <WebCore/VisibleSelection.h>
+#include <wtf/text/StringView.h>
 
 using namespace WebCore;
 using namespace HTMLNames;
index 0c2c3a6..53976ce 100644 (file)
@@ -1,3 +1,13 @@
+2014-03-02  Darin Adler  <darin@apple.com>
+
+        Streamline use of TextIterator, cutting down includes and use of soon-to-be-deleted functions
+        https://bugs.webkit.org/show_bug.cgi?id=129592
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/WebPageProxy.cpp: Added now-needed include.
+        * WebProcess/WebPage/WebPage.cpp: Ditto.
+
 2014-03-02  Enrica Casucci  <enrica@apple.com>
 
         [iOS WebKit2] Keyboard deadlock when accepting/dismissing autocorrection.
index 128dee2..ae44bb5 100644 (file)
@@ -98,6 +98,7 @@
 #include <WebCore/WindowFeatures.h>
 #include <stdio.h>
 #include <wtf/NeverDestroyed.h>
+#include <wtf/text/StringView.h>
 
 #if ENABLE(ASYNC_SCROLLING)
 #include "RemoteScrollingCoordinatorProxy.h"
index 245e6e0..2894cd4 100644 (file)
 #include <WebCore/SharedBuffer.h>
 #include <WebCore/SubframeLoader.h>
 #include <WebCore/SubstituteData.h>
+#include <WebCore/TextIterator.h>
 #include <WebCore/UserInputBridge.h>
 #include <WebCore/VisiblePosition.h>
 #include <WebCore/VisibleUnits.h>