Reviewed by Chris
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Dec 2004 19:05:07 +0000 (19:05 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Dec 2004 19:05:07 +0000 (19:05 +0000)
        Fix for this bug:

        <rdar://problem/3668157> REGRESSION (Mail): shift-click deselects when selection was created right-to-left

        * khtml/khtml_part.cpp:
        (KHTMLPart::handleMousePressEventSingleClick): Use RangeImpl::compareBoundaryPoints
        to figure out which end of the selection to extend.

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/khtml_part.cpp

index 0c9988212f5127a142b8ded8d17c6d895c3a33db..e102fe0c28eb4a7cbb30bd482fffd664f619be7b 100644 (file)
@@ -1,3 +1,15 @@
+2004-12-02  Ken Kocienda  <kocienda@apple.com>
+
+        Reviewed by Chris
+
+        Fix for this bug:
+        
+        <rdar://problem/3668157> REGRESSION (Mail): shift-click deselects when selection was created right-to-left
+
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::handleMousePressEventSingleClick): Use RangeImpl::compareBoundaryPoints
+        to figure out which end of the selection to extend.
+
 2004-12-02  David Harrison  <harrison@apple.com>
 
         Reviewed by Ken Kocienda.
index 4dbfedb8a873bfea185ca185b0a1de758055541c..ad28f1bdb4d4d62905a9446b4357f21227ce4e7a 100644 (file)
@@ -57,6 +57,7 @@
 #include "misc/htmlhashes.h"
 #include "misc/loader.h"
 #include "xml/dom2_eventsimpl.h"
+#include "xml/dom2_rangeimpl.h"
 #include "xml/xml_tokenizer.h"
 
 using namespace DOM;
@@ -4514,7 +4515,18 @@ void KHTMLPart::handleMousePressEventSingleClick(khtml::MousePressEvent *event)
             sel = selection();
             if (extendSelection && sel.isCaretOrRange()) {
                 sel.clearModifyBias();
-                sel.setExtent(pos);
+                
+                // See <rdar://problem/3668157> REGRESSION (Mail): shift-click deselects when selection 
+                // was created right-to-left
+                Position start = sel.start();
+                short before = RangeImpl::compareBoundaryPoints(pos.node(), pos.offset(), start.node(), start.offset());
+                if (before <= 0) {
+                    sel.setBaseAndExtent(pos, sel.end());
+                }
+                else {
+                    sel.setBaseAndExtent(start, pos);
+                }
+
                 if (d->m_selectionGranularity != CHARACTER) {
                     sel.expandUsingGranularity(d->m_selectionGranularity);
                 }