Reviewed by Ken.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Sep 2004 16:10:01 +0000 (16:10 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Sep 2004 16:10:01 +0000 (16:10 +0000)
        - added new VisibleRange class; not used yet

        * WebCore.pbproj/project.pbxproj: Added visible_range.h and visible_range.cpp.
        * khtml/editing/visible_range.cpp: Added.
        * khtml/editing/visible_range.h: Added.

        - tweaks

        * kwq/WebCoreBridge.mm: (-[WebCoreBridge alterCurrentSelection:direction:granularity:]):
        Use switch statement instead of if statement so we get a warning if we ever add a new
        granularity.

        * khtml/editing/selection.h: khtml, not DOM, namespace
        * khtml/editing/visible_position.h: Ditto.

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

WebCore/ChangeLog-2005-08-23
WebCore/WebCore.pbproj/project.pbxproj
WebCore/khtml/editing/SelectionController.h
WebCore/khtml/editing/selection.h
WebCore/khtml/editing/visible_position.h
WebCore/khtml/editing/visible_range.cpp [new file with mode: 0644]
WebCore/khtml/editing/visible_range.h [new file with mode: 0644]
WebCore/kwq/WebCoreBridge.mm

index 8160145d8b350e39be2959ab3719a4a2702cb675..4bbbdd01ca1ca68c9e66d947f13b3073eef2edfc 100644 (file)
@@ -1,3 +1,22 @@
+2004-09-23  Darin Adler  <darin@apple.com>
+
+        Reviewed by Ken.
+
+        - added new VisibleRange class; not used yet
+
+        * WebCore.pbproj/project.pbxproj: Added visible_range.h and visible_range.cpp.
+        * khtml/editing/visible_range.cpp: Added.
+        * khtml/editing/visible_range.h: Added.
+
+        - tweaks
+
+        * kwq/WebCoreBridge.mm: (-[WebCoreBridge alterCurrentSelection:direction:granularity:]):
+        Use switch statement instead of if statement so we get a warning if we ever add a new
+        granularity.
+
+        * khtml/editing/selection.h: khtml, not DOM, namespace
+        * khtml/editing/visible_position.h: Ditto.
+
 2004-09-23  Darin Adler  <darin@apple.com>
 
         Reviewed by Ken.
index 8f8ecc7400ac1b7cd183a13e84099ffcdf44bb65..b6411f86ec30666310d9ea99f0bb1033b534c68f 100644 (file)
                                93ABE073070285F600BD91F9,
                                93ABE075070285F600BD91F9,
                                932B9835070297DC0032804F,
+                               939FF8EF0702B1B100979E5E,
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                                93ABE070070285F600BD91F9,
                                93ABE072070285F600BD91F9,
                                93ABE074070285F600BD91F9,
+                               939FF8EE0702B1B100979E5E,
                        );
                        isa = PBXSourcesBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                        settings = {
                        };
                };
+               939FF8EC0702B1B100979E5E = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
+                       name = visible_range.cpp;
+                       path = editing/visible_range.cpp;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               939FF8ED0702B1B100979E5E = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       name = visible_range.h;
+                       path = editing/visible_range.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               939FF8EE0702B1B100979E5E = {
+                       fileRef = 939FF8EC0702B1B100979E5E;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               939FF8EF0702B1B100979E5E = {
+                       fileRef = 939FF8ED0702B1B100979E5E;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
                93ABCE5D06E1A42E0085925B = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
                                932B9834070297DC0032804F,
                                93ABE069070285F600BD91F9,
                                93ABE068070285F600BD91F9,
+                               939FF8ED0702B1B100979E5E,
+                               939FF8EC0702B1B100979E5E,
                                93ABE06B070285F600BD91F9,
                                93ABE06A070285F600BD91F9,
                                93ABE06D070285F600BD91F9,
index 8cf6ea01fd20755300190c7543a34662c9087852..a1196473a900f7760e602d757cad97e6194712fa 100644 (file)
@@ -157,6 +157,6 @@ inline bool operator!=(const Selection &a, const Selection &b)
     return !(a == b);
 }
 
-} // namespace DOM
+} // namespace khtml
 
 #endif // KHTML_EDITING_SELECTION_H
index 8cf6ea01fd20755300190c7543a34662c9087852..a1196473a900f7760e602d757cad97e6194712fa 100644 (file)
@@ -157,6 +157,6 @@ inline bool operator!=(const Selection &a, const Selection &b)
     return !(a == b);
 }
 
-} // namespace DOM
+} // namespace khtml
 
 #endif // KHTML_EDITING_SELECTION_H
index 7e4743ec5f05d55fec8ee8af00d07f266f01c48d..a34df70a119e023ab990f1587a9b2856ba529a0c 100644 (file)
@@ -53,7 +53,7 @@ public:
     Position position() const { return rangeCompliantEquivalent(m_deepPosition); }
     Position deepEquivalent() const { return m_deepPosition; }
 
-    friend inline bool operator==(const VisiblePosition &a, const VisiblePosition &b);
+    friend bool operator==(const VisiblePosition &a, const VisiblePosition &b);
 
     VisiblePosition next() const;
     VisiblePosition previous() const;
@@ -109,6 +109,6 @@ VisiblePosition startVisiblePosition(const DOM::RangeImpl *);
 VisiblePosition endVisiblePosition(const DOM::Range &);
 VisiblePosition endVisiblePosition(const DOM::RangeImpl *);
 
-} // namespace DOM
+} // namespace khtml
 
 #endif // KHTML_EDITING_VISIBLE_POSITION_H
diff --git a/WebCore/khtml/editing/visible_range.cpp b/WebCore/khtml/editing/visible_range.cpp
new file mode 100644 (file)
index 0000000..9da6c06
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2004 Apple Computer, 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. 
+ */
+
+#include "visible_range.h"
+
diff --git a/WebCore/khtml/editing/visible_range.h b/WebCore/khtml/editing/visible_range.h
new file mode 100644 (file)
index 0000000..51dcd4a
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2004 Apple Computer, 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 KHTML_EDITING_VISIBLE_RANGE_H
+#define KHTML_EDITING_VISIBLE_RANGE_H
+
+#include "visible_position.h"
+
+namespace khtml {
+
+class VisibleRange
+{
+public:
+    typedef DOM::NodeImpl NodeImpl;
+    typedef DOM::Position Position;
+    typedef DOM::Range Range;
+
+    VisibleRange() { }
+    VisibleRange(NodeImpl *startContainer, long startOffset, NodeImpl *endContainer, long endOffset);
+    VisibleRange(const VisiblePosition &);
+    VisibleRange(const VisiblePosition &, const VisiblePosition &);
+    VisibleRange(const Range &);
+    VisibleRange(const Position &);
+    VisibleRange(const Position &, const Position &);
+
+    VisibleRange &operator=(const VisiblePosition &);
+    VisibleRange &operator=(const Range &);
+    VisibleRange &operator=(const Position &);
+
+    VisiblePosition start() const { return m_start; }
+    VisiblePosition end() const { return m_end; }
+
+    Range range() const;
+
+    void clear() { m_start.clear(); m_end.clear(); }
+
+    bool isNull() const { return m_start.isNull(); }
+    bool isCollapsed() const { return m_start == m_end; }
+
+    friend inline bool operator==(const VisiblePosition &a, const VisiblePosition &b);
+
+private:
+    VisiblePosition m_start;
+    VisiblePosition m_end;
+};
+
+inline bool operator==(const VisibleRange &a, const VisibleRange &b)
+{
+    return a.start() == b.start() && a.end() == b.end();
+}
+
+inline bool operator!=(const VisibleRange &a, const VisibleRange &b)
+{
+    return !(a == b);
+}
+
+} // namespace khtml
+
+#endif
index da2780b0050ac7e14b4c9b42c3c11c071f28f80d..9bbcac8173e41c51fbb9a28e1b6e139e2a5ca5ed 100644 (file)
@@ -1379,10 +1379,21 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
                      static_cast<Selection::EDirection>(direction), 
                      static_cast<ETextGranularity>(granularity));
 
-    // save vertical navigation x position if necessary
+    // save vertical navigation x position if necessary; many types of motion blow it away
     int xPos = KHTMLPart::NoXPosForVerticalArrowNavigation;
-    if (granularity == WebSelectByLine || granularity == WebSelectByParagraph)
-        xPos = _part->xPosForVerticalArrowNavigation();
+    switch (granularity) {
+        case WebSelectByLine:
+        case WebSelectByParagraph:
+            xPos = _part->xPosForVerticalArrowNavigation();
+            break;
+        case WebSelectByCharacter:
+        case WebSelectByWord:
+        case WebSelectToLineBoundary:
+        case WebSelectToParagraphBoundary:
+        case WebSelectToDocumentBoundary:
+            break;
+    }
+
     
     // setting the selection always clears saved vertical navigation x position
     _part->setSelection(selection);