2010-11-27 Benjamin Kalman <kalman@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Nov 2010 02:54:43 +0000 (02:54 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Nov 2010 02:54:43 +0000 (02:54 +0000)
        Reviewed by Darin Adler.

        Move Position::EditingBoundaryCrossingRule to a new header file
        https://bugs.webkit.org/show_bug.cgi?id=49630

        * GNUmakefile.am:
        * WebCore.exp.in:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * dom/Position.cpp:
        (WebCore::downstreamIgnoringEditingBoundaries):
        (WebCore::upstreamIgnoringEditingBoundaries):
        * dom/Position.h:
        * editing/DeleteSelectionCommand.cpp:
        (WebCore::DeleteSelectionCommand::doApply):
        * editing/EditingBoundary.h: Added.
        * editing/visible_units.cpp:
        (WebCore::startOfParagraph):
        (WebCore::endOfParagraph):
        (WebCore::isStartOfParagraph):
        (WebCore::isEndOfParagraph):
        * editing/visible_units.h:
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::createVisiblePosition):

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

14 files changed:
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.exp.in
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/dom/Position.cpp
WebCore/dom/Position.h
WebCore/editing/DeleteSelectionCommand.cpp
WebCore/editing/EditingBoundary.h [new file with mode: 0644]
WebCore/editing/visible_units.cpp
WebCore/editing/visible_units.h
WebCore/rendering/RenderObject.cpp

index 2cbef04..ef6d765 100644 (file)
@@ -1,3 +1,32 @@
+2010-11-27  Benjamin Kalman  <kalman@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Move Position::EditingBoundaryCrossingRule to a new header file
+        https://bugs.webkit.org/show_bug.cgi?id=49630
+
+        * GNUmakefile.am:
+        * WebCore.exp.in:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Position.cpp:
+        (WebCore::downstreamIgnoringEditingBoundaries):
+        (WebCore::upstreamIgnoringEditingBoundaries):
+        * dom/Position.h:
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::doApply):
+        * editing/EditingBoundary.h: Added.
+        * editing/visible_units.cpp:
+        (WebCore::startOfParagraph):
+        (WebCore::endOfParagraph):
+        (WebCore::isStartOfParagraph):
+        (WebCore::isEndOfParagraph):
+        * editing/visible_units.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::createVisiblePosition):
+
 2010-11-26  Rob Buis  <rwlbuis@gmail.com>
 
         Reviewed by Simon Fraser.
index fd8b5fc..fefd130 100644 (file)
@@ -1323,6 +1323,7 @@ webcore_sources += \
        WebCore/editing/EditCommand.h \
        WebCore/editing/EditingBehavior.h \
        WebCore/editing/EditingBehaviorTypes.h \
+       WebCore/editing/EditingBoundary.h \
        WebCore/editing/EditingStyle.cpp \
        WebCore/editing/EditingStyle.h \
        WebCore/editing/EditorCommand.cpp \
index 3246e0a..e097f7c 100644 (file)
@@ -420,7 +420,7 @@ __ZN7WebCore16createFullMarkupEPKNS_4NodeE
 __ZN7WebCore16createFullMarkupEPKNS_5RangeE
 __ZN7WebCore16enclosingIntRectERK7_NSRect
 __ZN7WebCore16enclosingIntRectERKNS_9FloatRectE
-__ZN7WebCore16isEndOfParagraphERKNS_15VisiblePositionENS_8Position27EditingBoundaryCrossingRuleE
+__ZN7WebCore16isEndOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
 __ZN7WebCore16jsStringSlowCaseEPN3JSC9ExecStateERNS0_9WeakGCMapIPN3WTF10StringImplEPNS0_8JSStringEEES6_
 __ZN7WebCore17CredentialStorage3getERKNS_15ProtectionSpaceE
 __ZN7WebCore17DOMImplementation13isXMLMIMETypeERKN3WTF6StringE
@@ -431,7 +431,7 @@ __ZN7WebCore17HistoryController26saveDocumentAndScrollStateEv
 __ZN7WebCore17nameForCursorTypeENS_6Cursor4TypeE
 __ZN7WebCore17openTemporaryFileEPKcRi
 __ZN7WebCore18SearchPopupMenuMacC1EPNS_15PopupMenuClientE
-__ZN7WebCore18isStartOfParagraphERKNS_15VisiblePositionENS_8Position27EditingBoundaryCrossingRuleE
+__ZN7WebCore18isStartOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
 __ZN7WebCore18pluginScriptObjectEPN3JSC9ExecStateEPNS_13JSHTMLElementE
 __ZN7WebCore18proxyServersForURLERKNS_4KURLEPKNS_17NetworkingContextE
 __ZN7WebCore19AnimationController16resumeAnimationsEv
@@ -1129,10 +1129,10 @@ __ZNK7WebCore8Document31displayStringModifiedByEncodingERKN3WTF6StringE
 __ZNK7WebCore8Document4bodyEv
 __ZNK7WebCore8Document6domainEv
 __ZNK7WebCore8IntPointcv8_NSPointEv
-__ZNK7WebCore8Position10downstreamENS0_27EditingBoundaryCrossingRuleE
+__ZNK7WebCore8Position10downstreamENS_27EditingBoundaryCrossingRuleE
 __ZNK7WebCore8Position25leadingWhitespacePositionENS_9EAffinityEb
 __ZNK7WebCore8Position26trailingWhitespacePositionENS_9EAffinityEb
-__ZNK7WebCore8Position8upstreamENS0_27EditingBoundaryCrossingRuleE
+__ZNK7WebCore8Position8upstreamENS_27EditingBoundaryCrossingRuleE
 __ZNK7WebCore9DOMWindow27pendingUnloadEventListenersEv
 __ZNK7WebCore9FloatRectcv7_NSRectEv
 __ZNK7WebCore9FrameTree12traverseNextEPKNS_5FrameE
index 4cc6792..5b4dd3b 100644 (file)
             'editing/EditCommand.h',
             'editing/EditingBehavior.h',
             'editing/EditingBehaviorTypes.h',
+            'editing/EditingBoundary.h',
             'editing/EditingStyle.cpp',
             'editing/EditingStyle.h',
             'editing/Editor.cpp',
index c1cd0c2..54207b7 100644 (file)
@@ -1710,6 +1710,7 @@ HEADERS += \
     editing/EditCommand.h \
     editing/EditingStyle.h \
     editing/EditingBehavior.h \
+    editing/EditingBoundary.h \
     editing/Editor.h \
     editing/FormatBlockCommand.h \
     editing/htmlediting.h \
index 19aaf5c..d01af3d 100755 (executable)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\editing\EditingBoundary.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\editing\DeleteButtonController.cpp"\r
                                >\r
                                <FileConfiguration\r
index e9b0f14..44bb997 100644 (file)
                37FD4298118368460093C029 /* TreeDepthLimit.h in Headers */ = {isa = PBXBuildFile; fileRef = 37FD4297118368460093C029 /* TreeDepthLimit.h */; };
                3888F6EE128C9889000CA8E0 /* InspectorFileSystemAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3888F6EC128C9889000CA8E0 /* InspectorFileSystemAgent.cpp */; };
                3888F6EF128C9889000CA8E0 /* InspectorFileSystemAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 3888F6ED128C9889000CA8E0 /* InspectorFileSystemAgent.h */; };
+               3AC648B2129E146500C3EB25 /* EditingBoundary.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AC648B1129E146500C3EB25 /* EditingBoundary.h */; settings = {ATTRIBUTES = (Private, ); }; };
                41002CCD0F66EDEF009E660D /* ScriptFunctionCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 41002CCB0F66EDEF009E660D /* ScriptFunctionCall.h */; };
                41002CCE0F66EDEF009E660D /* ScriptFunctionCall.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41002CCC0F66EDEF009E660D /* ScriptFunctionCall.cpp */; };
                410B7E721045FAB000D8224F /* JSMessageEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */; };
                37FD4297118368460093C029 /* TreeDepthLimit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeDepthLimit.h; sourceTree = "<group>"; };
                3888F6EC128C9889000CA8E0 /* InspectorFileSystemAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorFileSystemAgent.cpp; sourceTree = "<group>"; };
                3888F6ED128C9889000CA8E0 /* InspectorFileSystemAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFileSystemAgent.h; sourceTree = "<group>"; };
+               3AC648B1129E146500C3EB25 /* EditingBoundary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditingBoundary.h; sourceTree = "<group>"; };
                41002CCB0F66EDEF009E660D /* ScriptFunctionCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptFunctionCall.h; sourceTree = "<group>"; };
                41002CCC0F66EDEF009E660D /* ScriptFunctionCall.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptFunctionCall.cpp; sourceTree = "<group>"; };
                410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageEventCustom.cpp; sourceTree = "<group>"; };
                                93309D95099E64910056E581 /* EditCommand.h */,
                                4F1534DD11B532EC0021FD86 /* EditingBehavior.h */,
                                4F1534DF11B533020021FD86 /* EditingBehaviorTypes.h */,
+                               3AC648B1129E146500C3EB25 /* EditingBoundary.h */,
                                9BAB6C6B12550631001626D4 /* EditingStyle.cpp */,
                                9BAB6C6A12550631001626D4 /* EditingStyle.h */,
                                4B3043CA0AE0373B00A82647 /* Editor.cpp */,
                                93309DE4099E64920056E581 /* EditCommand.h in Headers */,
                                4F1534DE11B532EC0021FD86 /* EditingBehavior.h in Headers */,
                                4F1534E011B533020021FD86 /* EditingBehaviorTypes.h in Headers */,
+                               3AC648B2129E146500C3EB25 /* EditingBoundary.h in Headers */,
                                9BAB6C6C12550631001626D4 /* EditingStyle.h in Headers */,
                                6550B6A4099DF0270090D781 /* EditingText.h in Headers */,
                                4B3043CD0AE0373B00A82647 /* Editor.h in Headers */,
index d56613e..be175aa 100644 (file)
@@ -1006,7 +1006,7 @@ static Position downstreamIgnoringEditingBoundaries(Position position)
     Position lastPosition;
     while (position != lastPosition) {
         lastPosition = position;
-        position = position.downstream(Position::CanCrossEditingBoundary);
+        position = position.downstream(CanCrossEditingBoundary);
     }
     return position;
 }
@@ -1016,7 +1016,7 @@ static Position upstreamIgnoringEditingBoundaries(Position position)
     Position lastPosition;
     while (position != lastPosition) {
         lastPosition = position;
-        position = position.upstream(Position::CanCrossEditingBoundary);
+        position = position.upstream(CanCrossEditingBoundary);
     }
     return position;
 }
index 552d675..4d3b5fe 100644 (file)
@@ -27,6 +27,7 @@
 #define Position_h
 
 #include "ContainerNode.h"
+#include "EditingBoundary.h"
 #include "TextAffinity.h"
 #include "TextDirection.h"
 #include <wtf/Assertions.h>
@@ -56,11 +57,6 @@ public:
         PositionIsBeforeAnchor
     };
 
-    enum EditingBoundaryCrossingRule {
-        CanCrossEditingBoundary,
-        CannotCrossEditingBoundary
-    };
-    
     Position()
         : m_offset(0)
         , m_anchorType(PositionIsOffsetInAnchor)
index b617a27..594a94f 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "Document.h"
 #include "DocumentFragment.h"
+#include "EditingBoundary.h"
 #include "Editor.h"
 #include "EditorClient.h"
 #include "Element.h"
@@ -739,8 +740,8 @@ void DeleteSelectionCommand::doApply()
     EAffinity affinity = m_selectionToDelete.affinity();
     
     Position downstreamEnd = m_selectionToDelete.end().downstream();
-    m_needPlaceholder = isStartOfParagraph(m_selectionToDelete.visibleStart(), Position::CanCrossEditingBoundary)
-            && isEndOfParagraph(m_selectionToDelete.visibleEnd(), Position::CanCrossEditingBoundary)
+    m_needPlaceholder = isStartOfParagraph(m_selectionToDelete.visibleStart(), CanCrossEditingBoundary)
+            && isEndOfParagraph(m_selectionToDelete.visibleEnd(), CanCrossEditingBoundary)
             && !lineBreakExistsAtVisiblePosition(m_selectionToDelete.visibleEnd());
     if (m_needPlaceholder) {
         // Don't need a placeholder when deleting a selection that starts just before a table
diff --git a/WebCore/editing/EditingBoundary.h b/WebCore/editing/EditingBoundary.h
new file mode 100644 (file)
index 0000000..1cb0849
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2004, 2006, 2008 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+ */
+
+#ifndef EditingBoundary_h
+#define EditingBoundary_h
+
+namespace WebCore {
+
+enum EditingBoundaryCrossingRule {
+    CanCrossEditingBoundary,
+    CannotCrossEditingBoundary
+};
+
+}
+
+#endif // EditingBoundary_h
index 7d46374..91de663 100644 (file)
@@ -780,7 +780,7 @@ VisiblePosition nextSentencePosition(const VisiblePosition &c)
     return c.honorEditableBoundaryAtOrBefore(next);
 }
 
-VisiblePosition startOfParagraph(const VisiblePosition& c, Position::EditingBoundaryCrossingRule boundaryCrossingRule)
+VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossingRule boundaryCrossingRule)
 {
     Position p = c.deepEquivalent();
     Node *startNode = p.node();
@@ -798,7 +798,7 @@ VisiblePosition startOfParagraph(const VisiblePosition& c, Position::EditingBoun
 
     Node *n = startNode;
     while (n) {
-        if (boundaryCrossingRule == Position::CannotCrossEditingBoundary && n->isContentEditable() != startNode->isContentEditable())
+        if (boundaryCrossingRule == CannotCrossEditingBoundary && n->isContentEditable() != startNode->isContentEditable())
             break;
         RenderObject *r = n->renderer();
         if (!r) {
@@ -839,7 +839,7 @@ VisiblePosition startOfParagraph(const VisiblePosition& c, Position::EditingBoun
     return VisiblePosition(node, offset, DOWNSTREAM);
 }
 
-VisiblePosition endOfParagraph(const VisiblePosition &c, Position::EditingBoundaryCrossingRule boundaryCrossingRule)
+VisiblePosition endOfParagraph(const VisiblePosition &c, EditingBoundaryCrossingRule boundaryCrossingRule)
 {    
     if (c.isNull())
         return VisiblePosition();
@@ -858,7 +858,7 @@ VisiblePosition endOfParagraph(const VisiblePosition &c, Position::EditingBounda
 
     Node *n = startNode;
     while (n) {
-        if (boundaryCrossingRule == Position::CannotCrossEditingBoundary && n->isContentEditable() != startNode->isContentEditable())
+        if (boundaryCrossingRule == CannotCrossEditingBoundary && n->isContentEditable() != startNode->isContentEditable())
             break;
         RenderObject *r = n->renderer();
         if (!r) {
@@ -914,12 +914,12 @@ bool inSameParagraph(const VisiblePosition &a, const VisiblePosition &b)
     return a.isNotNull() && startOfParagraph(a) == startOfParagraph(b);
 }
 
-bool isStartOfParagraph(const VisiblePosition &pos, Position::EditingBoundaryCrossingRule boundaryCrossingRule)
+bool isStartOfParagraph(const VisiblePosition &pos, EditingBoundaryCrossingRule boundaryCrossingRule)
 {
     return pos.isNotNull() && pos == startOfParagraph(pos, boundaryCrossingRule);
 }
 
-bool isEndOfParagraph(const VisiblePosition &pos, Position::EditingBoundaryCrossingRule boundaryCrossingRule)
+bool isEndOfParagraph(const VisiblePosition &pos, EditingBoundaryCrossingRule boundaryCrossingRule)
 {
     return pos.isNotNull() && pos == endOfParagraph(pos, boundaryCrossingRule);
 }
index f78f9d1..98a5332 100644 (file)
@@ -27,6 +27,7 @@
 #define visible_units_h
 
 #include "Document.h"
+#include "EditingBoundary.h"
 #include "Position.h"
 #include "TextAffinity.h"
 
@@ -61,13 +62,13 @@ VisiblePosition logicalStartOfLine(const VisiblePosition &);
 VisiblePosition logicalEndOfLine(const VisiblePosition &);
 
 // paragraphs (perhaps a misnomer, can be divided by line break elements)
-VisiblePosition startOfParagraph(const VisiblePosition&, Position::EditingBoundaryCrossingRule = Position::CannotCrossEditingBoundary);
-VisiblePosition endOfParagraph(const VisiblePosition&, Position::EditingBoundaryCrossingRule = Position::CannotCrossEditingBoundary);
+VisiblePosition startOfParagraph(const VisiblePosition&, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
+VisiblePosition endOfParagraph(const VisiblePosition&, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
 VisiblePosition startOfNextParagraph(const VisiblePosition&);
 VisiblePosition previousParagraphPosition(const VisiblePosition &, int x);
 VisiblePosition nextParagraphPosition(const VisiblePosition &, int x);
-bool isStartOfParagraph(const VisiblePosition &, Position::EditingBoundaryCrossingRule = Position::CannotCrossEditingBoundary);
-bool isEndOfParagraph(const VisiblePosition &, Position::EditingBoundaryCrossingRule = Position::CannotCrossEditingBoundary);
+bool isStartOfParagraph(const VisiblePosition &, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
+bool isEndOfParagraph(const VisiblePosition &, EditingBoundaryCrossingRule = CannotCrossEditingBoundary);
 bool inSameParagraph(const VisiblePosition &, const VisiblePosition &);
 
 // blocks (true paragraphs; line break elements don't break blocks)
index e13b1f9..b0e74ae 100644 (file)
@@ -31,6 +31,7 @@
 #include "Chrome.h"
 #include "CSSStyleSelector.h"
 #include "DashArray.h"
+#include "EditingBoundary.h"
 #include "FloatQuad.h"
 #include "Frame.h"
 #include "FrameView.h"
@@ -2639,10 +2640,10 @@ VisiblePosition RenderObject::createVisiblePosition(int offset, EAffinity affini
         if (!node->isContentEditable()) {
             // If it can be found, we prefer a visually equivalent position that is editable. 
             Position position(node, offset);
-            Position candidate = position.downstream(Position::CanCrossEditingBoundary);
+            Position candidate = position.downstream(CanCrossEditingBoundary);
             if (candidate.node()->isContentEditable())
                 return VisiblePosition(candidate, affinity);
-            candidate = position.upstream(Position::CanCrossEditingBoundary);
+            candidate = position.upstream(CanCrossEditingBoundary);
             if (candidate.node()->isContentEditable())
                 return VisiblePosition(candidate, affinity);
         }