[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:29:41 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 9503e587abd820aceaac1673979976f552d40d37
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Mar 12 19:27:19 2004 +0000

    WebCore:
    
            Reviewed by Chris
    
            * khtml/khtml_part.cpp:
            (KHTMLPart::handleMouseMoveEventSelection): Clear the selection's
            "modify bias" since the user clicked, and is therefore no longer
            extending the selection with arrow keys.
            * khtml/khtml_selection.cpp:
            (KHTMLSelection::KHTMLSelection): Add new m_modifyBiasSet flag.
            (KHTMLSelection::init): Set the flag to false by default.
            (KHTMLSelection::operator=): Copy over the value of the new m_modifyBiasSet flag.
            (KHTMLSelection::modify): Set the flag if extending the selection and set the
            base and extent nodes based on the movement direction requested.
            * khtml/khtml_selection.h:
            * kwq/WebCoreBridge.h: See below.
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge rangeByAlteringCurrentSelection:direction:granularity:]): This
            method is used by the WebKit side in response to requests to change the selection
            using the arrow keys. It used to be called rangeByModifyingRange:alteration:direction:granularity:
            but I changed it to this new format since I explicitly want to use the current selection, and
            not some arbitrarily passed in selection. This helps to maintain the "modify bias" correctly.
            (-[WebCoreBridge alterCurrentSelection:direction:granularity:]): New method. A command to alter
            the current selection as given. Again, applying the command to the current selection, rather
            than just setting the selection to a new one, helps to maintain the "modify bias" correctly.
    
    WebKit:
    
            Reviewed by Chris
    
            * WebView.subproj/WebView.m:
            (-[WebView _alterCurrentSelection:direction:granularity:]): Changed name from
            _alterSelection:direction:granularity: to give a little extra clarity. Also, the
            body calls through to renamed rangeByAlteringCurrentSelection:direction:granularity:
            in WebCore.
            (-[WebView moveRight:]): Now calls renamed _alterCurrentSelection:direction:granularity:.
            (-[WebView moveRightAndModifySelection:]): Ditto.
            (-[WebView moveLeft:]): Ditto.
            (-[WebView moveLeftAndModifySelection:]): Ditto.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6219 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index ec63f4b..aa5a39a 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,29 @@
+2004-03-12  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Chris
+
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::handleMouseMoveEventSelection): Clear the selection's
+        "modify bias" since the user clicked, and is therefore no longer
+        extending the selection with arrow keys.
+        * khtml/khtml_selection.cpp:
+        (KHTMLSelection::KHTMLSelection): Add new m_modifyBiasSet flag.
+        (KHTMLSelection::init): Set the flag to false by default.
+        (KHTMLSelection::operator=): Copy over the value of the new m_modifyBiasSet flag.
+        (KHTMLSelection::modify): Set the flag if extending the selection and set the 
+        base and extent nodes based on the movement direction requested.
+        * khtml/khtml_selection.h:
+        * kwq/WebCoreBridge.h: See below.
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge rangeByAlteringCurrentSelection:direction:granularity:]): This
+        method is used by the WebKit side in response to requests to change the selection
+        using the arrow keys. It used to be called rangeByModifyingRange:alteration:direction:granularity:
+        but I changed it to this new format since I explicitly want to use the current selection, and
+        not some arbitrarily passed in selection. This helps to maintain the "modify bias" correctly.
+        (-[WebCoreBridge alterCurrentSelection:direction:granularity:]): New method. A command to alter
+        the current selection as given. Again, applying the command to the current selection, rather
+        than just setting the selection to a new one, helps to maintain the "modify bias" correctly.
+
 2004-03-11  Chris Blumenberg  <cblu at apple.com>
 
 	Added stubs for the HTML DOM API.
diff --git a/WebCore/khtml/editing/SelectionController.cpp b/WebCore/khtml/editing/SelectionController.cpp
index 8e82177..e5d20f5 100644
--- a/WebCore/khtml/editing/SelectionController.cpp
+++ b/WebCore/khtml/editing/SelectionController.cpp
@@ -128,7 +128,8 @@ KHTMLSelection::KHTMLSelection(const KHTMLSelection &o)
 
     m_baseIsStart = o.m_baseIsStart;
     m_needsCaretLayout = o.m_needsCaretLayout;
-
+    m_modifyBiasSet = o.m_modifyBiasSet;
+    
     // Only copy the coordinates over if the other object
     // has had a layout, otherwise keep the current
     // coordinates. This prevents drawing artifacts from
@@ -157,6 +158,7 @@ void KHTMLSelection::init()
     m_caretSize = 0;
     m_baseIsStart = true;
     m_needsCaretLayout = true;
+    m_modifyBiasSet = false;
 }
 
 KHTMLSelection::~KHTMLSelection()
@@ -187,6 +189,7 @@ KHTMLSelection &KHTMLSelection::operator=(const KHTMLSelection &o)
 
     m_baseIsStart = o.m_baseIsStart;
     m_needsCaretLayout = o.m_needsCaretLayout;
+    m_modifyBiasSet = o.m_modifyBiasSet;
     
     // Only copy the coordinates over if the other object
     // has had a layout, otherwise keep the current
@@ -242,10 +245,23 @@ bool KHTMLSelection::modify(EAlter alter, EDirection dir, ETextGranularity elem)
         case FORWARD:
             switch (elem) {
                 case CHARACTER:
-                    if (alter == EXTEND)
+                    if (alter == EXTEND) {
+                        if (!m_modifyBiasSet) {
+                            m_modifyBiasSet = true;
+                            setBaseNode(startNode());
+                            setBaseOffset(startOffset());
+                            setExtentNode(endNode());
+                            setExtentOffset(endOffset());
+                        }
                         pos = nextCharacterPosition(DOMPosition(extentNode(), extentOffset()));
-                    else
-                        pos = nextCharacterPosition();
+                    }
+                    else {
+                        m_modifyBiasSet = false;
+                        if (state() == RANGE)
+                            pos = DOMPosition(endNode(), endOffset());
+                        else
+                            pos = nextCharacterPosition();
+                    }
                     break;
                 case WORD:
                     // EDIT FIXME: implement
@@ -260,10 +276,23 @@ bool KHTMLSelection::modify(EAlter alter, EDirection dir, ETextGranularity elem)
         case BACKWARD:
             switch (elem) {
                 case CHARACTER:
-                    if (alter == EXTEND)
+                    if (alter == EXTEND) {
+                        if (!m_modifyBiasSet) {
+                            m_modifyBiasSet = true;
+                            setBaseNode(endNode());
+                            setBaseOffset(endOffset());
+                            setExtentNode(startNode());
+                            setExtentOffset(startOffset());
+                        }
                         pos = previousCharacterPosition(DOMPosition(extentNode(), extentOffset()));
-                    else
-                        pos = previousCharacterPosition();
+                    }
+                    else {
+                        m_modifyBiasSet = false;
+                        if (state() == RANGE)
+                            pos = DOMPosition(startNode(), startOffset());
+                        else
+                            pos = previousCharacterPosition();
+                    }
                     break;
                 case WORD:
                     // EDIT FIXME: implement
diff --git a/WebCore/khtml/editing/SelectionController.h b/WebCore/khtml/editing/SelectionController.h
index 2538221..2864eae 100644
--- a/WebCore/khtml/editing/SelectionController.h
+++ b/WebCore/khtml/editing/SelectionController.h
@@ -89,6 +89,7 @@ public:
     static DOM::DOMPosition nextCharacterPosition(const DOM::DOMPosition &from);
         
     void setNeedsLayout(bool flag=true);
+    void clearModifyBias() { m_modifyBiasSet = false; }
     
     bool isEmpty() const;
     DOM::Range toRange() const;
@@ -146,6 +147,7 @@ private:
 
 	bool m_baseIsStart : 1;       // true if base node is before the extent node
 	bool m_needsCaretLayout : 1;  // true if the caret position needs to be calculated
+	bool m_modifyBiasSet : 1;     // true if the selection has been modified with EAlter::EXTEND
 };
 
 
diff --git a/WebCore/khtml/editing/selection.cpp b/WebCore/khtml/editing/selection.cpp
index 8e82177..e5d20f5 100644
--- a/WebCore/khtml/editing/selection.cpp
+++ b/WebCore/khtml/editing/selection.cpp
@@ -128,7 +128,8 @@ KHTMLSelection::KHTMLSelection(const KHTMLSelection &o)
 
     m_baseIsStart = o.m_baseIsStart;
     m_needsCaretLayout = o.m_needsCaretLayout;
-
+    m_modifyBiasSet = o.m_modifyBiasSet;
+    
     // Only copy the coordinates over if the other object
     // has had a layout, otherwise keep the current
     // coordinates. This prevents drawing artifacts from
@@ -157,6 +158,7 @@ void KHTMLSelection::init()
     m_caretSize = 0;
     m_baseIsStart = true;
     m_needsCaretLayout = true;
+    m_modifyBiasSet = false;
 }
 
 KHTMLSelection::~KHTMLSelection()
@@ -187,6 +189,7 @@ KHTMLSelection &KHTMLSelection::operator=(const KHTMLSelection &o)
 
     m_baseIsStart = o.m_baseIsStart;
     m_needsCaretLayout = o.m_needsCaretLayout;
+    m_modifyBiasSet = o.m_modifyBiasSet;
     
     // Only copy the coordinates over if the other object
     // has had a layout, otherwise keep the current
@@ -242,10 +245,23 @@ bool KHTMLSelection::modify(EAlter alter, EDirection dir, ETextGranularity elem)
         case FORWARD:
             switch (elem) {
                 case CHARACTER:
-                    if (alter == EXTEND)
+                    if (alter == EXTEND) {
+                        if (!m_modifyBiasSet) {
+                            m_modifyBiasSet = true;
+                            setBaseNode(startNode());
+                            setBaseOffset(startOffset());
+                            setExtentNode(endNode());
+                            setExtentOffset(endOffset());
+                        }
                         pos = nextCharacterPosition(DOMPosition(extentNode(), extentOffset()));
-                    else
-                        pos = nextCharacterPosition();
+                    }
+                    else {
+                        m_modifyBiasSet = false;
+                        if (state() == RANGE)
+                            pos = DOMPosition(endNode(), endOffset());
+                        else
+                            pos = nextCharacterPosition();
+                    }
                     break;
                 case WORD:
                     // EDIT FIXME: implement
@@ -260,10 +276,23 @@ bool KHTMLSelection::modify(EAlter alter, EDirection dir, ETextGranularity elem)
         case BACKWARD:
             switch (elem) {
                 case CHARACTER:
-                    if (alter == EXTEND)
+                    if (alter == EXTEND) {
+                        if (!m_modifyBiasSet) {
+                            m_modifyBiasSet = true;
+                            setBaseNode(endNode());
+                            setBaseOffset(endOffset());
+                            setExtentNode(startNode());
+                            setExtentOffset(startOffset());
+                        }
                         pos = previousCharacterPosition(DOMPosition(extentNode(), extentOffset()));
-                    else
-                        pos = previousCharacterPosition();
+                    }
+                    else {
+                        m_modifyBiasSet = false;
+                        if (state() == RANGE)
+                            pos = DOMPosition(startNode(), startOffset());
+                        else
+                            pos = previousCharacterPosition();
+                    }
                     break;
                 case WORD:
                     // EDIT FIXME: implement
diff --git a/WebCore/khtml/editing/selection.h b/WebCore/khtml/editing/selection.h
index 2538221..2864eae 100644
--- a/WebCore/khtml/editing/selection.h
+++ b/WebCore/khtml/editing/selection.h
@@ -89,6 +89,7 @@ public:
     static DOM::DOMPosition nextCharacterPosition(const DOM::DOMPosition &from);
         
     void setNeedsLayout(bool flag=true);
+    void clearModifyBias() { m_modifyBiasSet = false; }
     
     bool isEmpty() const;
     DOM::Range toRange() const;
@@ -146,6 +147,7 @@ private:
 
 	bool m_baseIsStart : 1;       // true if base node is before the extent node
 	bool m_needsCaretLayout : 1;  // true if the caret position needs to be calculated
+	bool m_modifyBiasSet : 1;     // true if the selection has been modified with EAlter::EXTEND
 };
 
 
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 230d090..5515c34 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -4781,6 +4781,7 @@ void KHTMLPart::handleMouseMoveEventSelection(khtml::MouseMoveEvent *event)
 	// Restart the selection if this is the first mouse move. This work is usually
 	// done in khtmlMousePressEvent, but not if the mouse press was on an existing selection.
 	KHTMLSelection sel = selection();
+    sel.clearModifyBias();
     if (!d->m_mouseMovedSinceLastMousePress) {
 		d->m_mouseMovedSinceLastMousePress = true;
         sel.moveTo(node, offset);
diff --git a/WebCore/khtml/khtml_selection.cpp b/WebCore/khtml/khtml_selection.cpp
index 8e82177..e5d20f5 100644
--- a/WebCore/khtml/khtml_selection.cpp
+++ b/WebCore/khtml/khtml_selection.cpp
@@ -128,7 +128,8 @@ KHTMLSelection::KHTMLSelection(const KHTMLSelection &o)
 
     m_baseIsStart = o.m_baseIsStart;
     m_needsCaretLayout = o.m_needsCaretLayout;
-
+    m_modifyBiasSet = o.m_modifyBiasSet;
+    
     // Only copy the coordinates over if the other object
     // has had a layout, otherwise keep the current
     // coordinates. This prevents drawing artifacts from
@@ -157,6 +158,7 @@ void KHTMLSelection::init()
     m_caretSize = 0;
     m_baseIsStart = true;
     m_needsCaretLayout = true;
+    m_modifyBiasSet = false;
 }
 
 KHTMLSelection::~KHTMLSelection()
@@ -187,6 +189,7 @@ KHTMLSelection &KHTMLSelection::operator=(const KHTMLSelection &o)
 
     m_baseIsStart = o.m_baseIsStart;
     m_needsCaretLayout = o.m_needsCaretLayout;
+    m_modifyBiasSet = o.m_modifyBiasSet;
     
     // Only copy the coordinates over if the other object
     // has had a layout, otherwise keep the current
@@ -242,10 +245,23 @@ bool KHTMLSelection::modify(EAlter alter, EDirection dir, ETextGranularity elem)
         case FORWARD:
             switch (elem) {
                 case CHARACTER:
-                    if (alter == EXTEND)
+                    if (alter == EXTEND) {
+                        if (!m_modifyBiasSet) {
+                            m_modifyBiasSet = true;
+                            setBaseNode(startNode());
+                            setBaseOffset(startOffset());
+                            setExtentNode(endNode());
+                            setExtentOffset(endOffset());
+                        }
                         pos = nextCharacterPosition(DOMPosition(extentNode(), extentOffset()));
-                    else
-                        pos = nextCharacterPosition();
+                    }
+                    else {
+                        m_modifyBiasSet = false;
+                        if (state() == RANGE)
+                            pos = DOMPosition(endNode(), endOffset());
+                        else
+                            pos = nextCharacterPosition();
+                    }
                     break;
                 case WORD:
                     // EDIT FIXME: implement
@@ -260,10 +276,23 @@ bool KHTMLSelection::modify(EAlter alter, EDirection dir, ETextGranularity elem)
         case BACKWARD:
             switch (elem) {
                 case CHARACTER:
-                    if (alter == EXTEND)
+                    if (alter == EXTEND) {
+                        if (!m_modifyBiasSet) {
+                            m_modifyBiasSet = true;
+                            setBaseNode(endNode());
+                            setBaseOffset(endOffset());
+                            setExtentNode(startNode());
+                            setExtentOffset(startOffset());
+                        }
                         pos = previousCharacterPosition(DOMPosition(extentNode(), extentOffset()));
-                    else
-                        pos = previousCharacterPosition();
+                    }
+                    else {
+                        m_modifyBiasSet = false;
+                        if (state() == RANGE)
+                            pos = DOMPosition(startNode(), startOffset());
+                        else
+                            pos = previousCharacterPosition();
+                    }
                     break;
                 case WORD:
                     // EDIT FIXME: implement
diff --git a/WebCore/khtml/khtml_selection.h b/WebCore/khtml/khtml_selection.h
index 2538221..2864eae 100644
--- a/WebCore/khtml/khtml_selection.h
+++ b/WebCore/khtml/khtml_selection.h
@@ -89,6 +89,7 @@ public:
     static DOM::DOMPosition nextCharacterPosition(const DOM::DOMPosition &from);
         
     void setNeedsLayout(bool flag=true);
+    void clearModifyBias() { m_modifyBiasSet = false; }
     
     bool isEmpty() const;
     DOM::Range toRange() const;
@@ -146,6 +147,7 @@ private:
 
 	bool m_baseIsStart : 1;       // true if base node is before the extent node
 	bool m_needsCaretLayout : 1;  // true if the caret position needs to be calculated
+	bool m_modifyBiasSet : 1;     // true if the selection has been modified with EAlter::EXTEND
 };
 
 
diff --git a/WebCore/khtml/xml/dom_selection.cpp b/WebCore/khtml/xml/dom_selection.cpp
index 8e82177..e5d20f5 100644
--- a/WebCore/khtml/xml/dom_selection.cpp
+++ b/WebCore/khtml/xml/dom_selection.cpp
@@ -128,7 +128,8 @@ KHTMLSelection::KHTMLSelection(const KHTMLSelection &o)
 
     m_baseIsStart = o.m_baseIsStart;
     m_needsCaretLayout = o.m_needsCaretLayout;
-
+    m_modifyBiasSet = o.m_modifyBiasSet;
+    
     // Only copy the coordinates over if the other object
     // has had a layout, otherwise keep the current
     // coordinates. This prevents drawing artifacts from
@@ -157,6 +158,7 @@ void KHTMLSelection::init()
     m_caretSize = 0;
     m_baseIsStart = true;
     m_needsCaretLayout = true;
+    m_modifyBiasSet = false;
 }
 
 KHTMLSelection::~KHTMLSelection()
@@ -187,6 +189,7 @@ KHTMLSelection &KHTMLSelection::operator=(const KHTMLSelection &o)
 
     m_baseIsStart = o.m_baseIsStart;
     m_needsCaretLayout = o.m_needsCaretLayout;
+    m_modifyBiasSet = o.m_modifyBiasSet;
     
     // Only copy the coordinates over if the other object
     // has had a layout, otherwise keep the current
@@ -242,10 +245,23 @@ bool KHTMLSelection::modify(EAlter alter, EDirection dir, ETextGranularity elem)
         case FORWARD:
             switch (elem) {
                 case CHARACTER:
-                    if (alter == EXTEND)
+                    if (alter == EXTEND) {
+                        if (!m_modifyBiasSet) {
+                            m_modifyBiasSet = true;
+                            setBaseNode(startNode());
+                            setBaseOffset(startOffset());
+                            setExtentNode(endNode());
+                            setExtentOffset(endOffset());
+                        }
                         pos = nextCharacterPosition(DOMPosition(extentNode(), extentOffset()));
-                    else
-                        pos = nextCharacterPosition();
+                    }
+                    else {
+                        m_modifyBiasSet = false;
+                        if (state() == RANGE)
+                            pos = DOMPosition(endNode(), endOffset());
+                        else
+                            pos = nextCharacterPosition();
+                    }
                     break;
                 case WORD:
                     // EDIT FIXME: implement
@@ -260,10 +276,23 @@ bool KHTMLSelection::modify(EAlter alter, EDirection dir, ETextGranularity elem)
         case BACKWARD:
             switch (elem) {
                 case CHARACTER:
-                    if (alter == EXTEND)
+                    if (alter == EXTEND) {
+                        if (!m_modifyBiasSet) {
+                            m_modifyBiasSet = true;
+                            setBaseNode(endNode());
+                            setBaseOffset(endOffset());
+                            setExtentNode(startNode());
+                            setExtentOffset(startOffset());
+                        }
                         pos = previousCharacterPosition(DOMPosition(extentNode(), extentOffset()));
-                    else
-                        pos = previousCharacterPosition();
+                    }
+                    else {
+                        m_modifyBiasSet = false;
+                        if (state() == RANGE)
+                            pos = DOMPosition(startNode(), startOffset());
+                        else
+                            pos = previousCharacterPosition();
+                    }
                     break;
                 case WORD:
                     // EDIT FIXME: implement
diff --git a/WebCore/khtml/xml/dom_selection.h b/WebCore/khtml/xml/dom_selection.h
index 2538221..2864eae 100644
--- a/WebCore/khtml/xml/dom_selection.h
+++ b/WebCore/khtml/xml/dom_selection.h
@@ -89,6 +89,7 @@ public:
     static DOM::DOMPosition nextCharacterPosition(const DOM::DOMPosition &from);
         
     void setNeedsLayout(bool flag=true);
+    void clearModifyBias() { m_modifyBiasSet = false; }
     
     bool isEmpty() const;
     DOM::Range toRange() const;
@@ -146,6 +147,7 @@ private:
 
 	bool m_baseIsStart : 1;       // true if base node is before the extent node
 	bool m_needsCaretLayout : 1;  // true if the caret position needs to be calculated
+	bool m_modifyBiasSet : 1;     // true if the selection has been modified with EAlter::EXTEND
 };
 
 
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index f35834f..be6285a 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -274,7 +274,8 @@ typedef enum {
 
 - (void)undoEditing:(id)arg;
 - (void)redoEditing:(id)arg;
-- (DOMRange *)rangeByModifyingRange:(DOMRange *)range alteration:(WebSelectionAlteration)alteration direction:(WebSelectionDirection)direction granularity:(WebSelectionGranularity)granularity;
+- (DOMRange *)rangeByAlteringCurrentSelection:(WebSelectionAlteration)alteration direction:(WebSelectionDirection)direction granularity:(WebSelectionGranularity)granularity;
+- (void)alterCurrentSelection:(WebSelectionAlteration)alteration direction:(WebSelectionDirection)direction granularity:(WebSelectionGranularity)granularity;
 - (void)insertText:(NSString *)text;
 - (void)insertNewline;
 - (void)deleteKeyPressed;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index efe6122..f070b34 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -1276,18 +1276,32 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
     cmd.reapply();
 }
 
-- (DOMRange *)rangeByModifyingRange:(DOMRange *)range alteration:(WebSelectionAlteration)alteration direction:(WebSelectionDirection)direction granularity:(WebSelectionGranularity)granularity;
+- (DOMRange *)rangeByAlteringCurrentSelection:(WebSelectionAlteration)alteration direction:(WebSelectionDirection)direction granularity:(WebSelectionGranularity)granularity
 {
+    if (!_part)
+        return nil;
+        
     // NOTE: The enums *must* match the very similar ones declared in ktml_selection.h
-    NodeImpl *startContainer = [[range startContainer] _nodeImpl];
-    NodeImpl *endContainer = [[range endContainer] _nodeImpl];
-    KHTMLSelection selection(startContainer, [range startOffset], endContainer, [range endOffset]);
+    KHTMLSelection selection(_part->selection());
     selection.modify(static_cast<KHTMLSelection::EAlter>(alteration), 
                      static_cast<KHTMLSelection::EDirection>(direction), 
                      static_cast<KHTMLSelection::ETextGranularity>(granularity));
     return [DOMRange _rangeWithImpl:selection.toRange().handle()];
 }
 
+- (void)alterCurrentSelection:(WebSelectionAlteration)alteration direction:(WebSelectionDirection)direction granularity:(WebSelectionGranularity)granularity
+{
+    if (!_part)
+        return;
+        
+    // NOTE: The enums *must* match the very similar ones declared in ktml_selection.h
+    KHTMLSelection selection(_part->selection());
+    selection.modify(static_cast<KHTMLSelection::EAlter>(alteration), 
+                     static_cast<KHTMLSelection::EDirection>(direction), 
+                     static_cast<KHTMLSelection::ETextGranularity>(granularity));
+    _part->setSelection(selection);
+}
+
 - (void)setSelectedDOMRange:(DOMRange *)range
 {
     NodeImpl *startContainer = [[range startContainer] _nodeImpl];
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index a47ce78..137215c 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,17 @@
+2004-03-12  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Chris
+
+        * WebView.subproj/WebView.m:
+        (-[WebView _alterCurrentSelection:direction:granularity:]): Changed name from
+        _alterSelection:direction:granularity: to give a little extra clarity. Also, the
+        body calls through to renamed rangeByAlteringCurrentSelection:direction:granularity:
+        in WebCore.
+        (-[WebView moveRight:]): Now calls renamed _alterCurrentSelection:direction:granularity:.
+        (-[WebView moveRightAndModifySelection:]): Ditto.
+        (-[WebView moveLeft:]): Ditto.
+        (-[WebView moveLeftAndModifySelection:]): Ditto.
+
 2004-03-11  Richard Williamson   <rjw at apple.com>
 
 	Workaround for 3585644.  Force the window number of the
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index 6562ba0..90b5ad3 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -2046,15 +2046,12 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
     [self insertText:string replacingDOMRange:[self selectedDOMRange]];
 }
 
-- (void)_alterSelection:(WebSelectionAlteration)alteration direction:(WebSelectionDirection)direction granularity:(WebSelectionGranularity)granularity
+- (void)_alterCurrentSelection:(WebSelectionAlteration)alteration direction:(WebSelectionDirection)direction granularity:(WebSelectionGranularity)granularity
 {
-    DOMRange *currentRange = [self selectedDOMRange];
-    DOMRange *proposedRange = [[self _bridgeForCurrentSelection] rangeByModifyingRange:currentRange
-        alteration:alteration 
-        direction:direction 
-        granularity:granularity];
-    if ([[self _editingDelegateForwarder] webView:self shouldChangeSelectedDOMRange:currentRange toDOMRange:proposedRange]) {
-        [self setSelectedDOMRange:proposedRange];
+    WebBridge *bridge = [self _bridgeForCurrentSelection];
+    DOMRange *proposedRange = [bridge rangeByAlteringCurrentSelection:alteration direction:direction granularity:granularity];
+    if ([[self _editingDelegateForwarder] webView:self shouldChangeSelectedDOMRange:[self selectedDOMRange] toDOMRange:proposedRange]) {
+        [bridge alterCurrentSelection:alteration direction:direction granularity:granularity];
     }
 }
 
@@ -2064,22 +2061,22 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
 
 - (void)moveRight:(id)sender
 {
-    [self _alterSelection:WebSelectByMoving direction:WebSelectRight granularity:WebSelectByCharacter];
+    [self _alterCurrentSelection:WebSelectByMoving direction:WebSelectRight granularity:WebSelectByCharacter];
 }
 
 - (void)moveRightAndModifySelection:(id)sender
 {
-    [self _alterSelection:WebSelectByExtending direction:WebSelectRight granularity:WebSelectByCharacter];
+    [self _alterCurrentSelection:WebSelectByExtending direction:WebSelectRight granularity:WebSelectByCharacter];
 }
 
 - (void)moveLeft:(id)sender
 {
-    [self _alterSelection:WebSelectByMoving direction:WebSelectLeft granularity:WebSelectByCharacter];
+    [self _alterCurrentSelection:WebSelectByMoving direction:WebSelectLeft granularity:WebSelectByCharacter];
 }
 
 - (void)moveLeftAndModifySelection:(id)sender
 {
-    [self _alterSelection:WebSelectByExtending direction:WebSelectLeft granularity:WebSelectByCharacter];
+    [self _alterCurrentSelection:WebSelectByExtending direction:WebSelectLeft granularity:WebSelectByCharacter];
 }
 
 - (void)deleteBackward:(id)sender

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list