[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:52:17 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit d8689a098c400b452d4009290d9b2b826bf2d212
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jul 22 23:04:39 2004 +0000

            Reviewed by Hyatt
    
            Fix for this bug:
    
            <rdar://problem/3724344> Bolding and unbolding creates extraneous tags
    
            * khtml/editing/htmlediting_impl.cpp:
            (khtml::ApplyStyleCommandImpl::doApply): Move the start of the selection upstream
            before calling removeStyle. This makes sure we remove all styles that could apply to the
            selection, and not just ones in from the start position of the selection passed to us.
            This fixes the bug.
            * khtml/xml/dom_selection.cpp:
            (DOM::Selection::validate): Related fix to "constrain" the selection to be the
            smallest equivalent range of nodes, in effect making a "canonical" version of the
            selection. While this is not strictly necessary to fix the bug, it is a step I have been
            wanting to take this step for a long time, and some recent improvements made it
            possible for me to do now in just two lines of code.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@7104 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index b0fe459..737a00e 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -3,6 +3,26 @@
         Reviewed by Hyatt
 
         Fix for this bug:
+
+        <rdar://problem/3724344> Bolding and unbolding creates extraneous tags
+
+        * khtml/editing/htmlediting_impl.cpp:
+        (khtml::ApplyStyleCommandImpl::doApply): Move the start of the selection upstream
+        before calling removeStyle. This makes sure we remove all styles that could apply to the 
+        selection, and not just ones in from the start position of the selection passed to us. 
+        This fixes the bug.
+        * khtml/xml/dom_selection.cpp:
+        (DOM::Selection::validate): Related fix to "constrain" the selection to be the 
+        smallest equivalent range of nodes, in effect making a "canonical" version of the
+        selection. While this is not strictly necessary to fix the bug, it is a step I have been 
+        wanting to take this step for a long time, and some recent improvements made it 
+        possible for me to do now in just two lines of code.
+
+2004-07-22  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Hyatt
+
+        Fix for this bug:
         
         <rdar://problem/3711264> difficult (impossible?) to get cursor in an editable webview containing only tags
 
diff --git a/WebCore/khtml/editing/SelectionController.cpp b/WebCore/khtml/editing/SelectionController.cpp
index e66bc72..a5d186c 100644
--- a/WebCore/khtml/editing/SelectionController.cpp
+++ b/WebCore/khtml/editing/SelectionController.cpp
@@ -679,12 +679,23 @@ void Selection::validate(ETextGranularity granularity)
     }
 
     // adjust the state
-    if (start().isEmpty() && end().isEmpty())
+    if (start().isEmpty() && end().isEmpty()) {
         m_state = NONE;
-    else if (start() == end() || start().equivalentUpstreamPosition() == end().equivalentUpstreamPosition())
+    }
+    else if (start() == end() || start().equivalentUpstreamPosition() == end().equivalentUpstreamPosition()) {
         m_state = CARET;
-    else
+    }
+    else {
         m_state = RANGE;
+        // "Constrain" the selection to be the smallest equivalent range of nodes.
+        // This is a somewhat arbitrary choice, but experience shows that it is
+        // useful to make to make the selection "canonical" (if only for
+        // purposes of comparing selections). This is an ideal point of the code
+        // to do this operation, since all selection changes that result in a RANGE 
+        // come through here before anyone uses it.
+        assignStart(start().equivalentDownstreamPosition());
+        assignEnd(end().equivalentUpstreamPosition());
+    }
 
     m_needsCaretLayout = true;
     
diff --git a/WebCore/khtml/editing/htmlediting_impl.cpp b/WebCore/khtml/editing/htmlediting_impl.cpp
index 6f6d75b..6856c3a 100644
--- a/WebCore/khtml/editing/htmlediting_impl.cpp
+++ b/WebCore/khtml/editing/htmlediting_impl.cpp
@@ -628,8 +628,13 @@ void ApplyStyleCommandImpl::doApply()
     Position start(endingSelection().start().equivalentDownstreamPosition().equivalentRangeCompliantPosition());
     Position end(endingSelection().end().equivalentUpstreamPosition());
 
-    // remove style from the selection
-    removeStyle(start, end);
+    // Remove style from the selection.
+    // Use the upstream position of the start for removing style.
+    // This will ensure we remove all traces of the relevant styles from the selection
+    // and prevent us from adding redundant ones, as described in:
+    // <rdar://problem/3724344> Bolding and unbolding creates extraneous tags
+    removeStyle(start.equivalentUpstreamPosition(), end);
+    
     bool splitStart = splitTextAtStartIfNeeded(start, end); 
     if (splitStart) {
         start = endingSelection().start();
diff --git a/WebCore/khtml/editing/selection.cpp b/WebCore/khtml/editing/selection.cpp
index e66bc72..a5d186c 100644
--- a/WebCore/khtml/editing/selection.cpp
+++ b/WebCore/khtml/editing/selection.cpp
@@ -679,12 +679,23 @@ void Selection::validate(ETextGranularity granularity)
     }
 
     // adjust the state
-    if (start().isEmpty() && end().isEmpty())
+    if (start().isEmpty() && end().isEmpty()) {
         m_state = NONE;
-    else if (start() == end() || start().equivalentUpstreamPosition() == end().equivalentUpstreamPosition())
+    }
+    else if (start() == end() || start().equivalentUpstreamPosition() == end().equivalentUpstreamPosition()) {
         m_state = CARET;
-    else
+    }
+    else {
         m_state = RANGE;
+        // "Constrain" the selection to be the smallest equivalent range of nodes.
+        // This is a somewhat arbitrary choice, but experience shows that it is
+        // useful to make to make the selection "canonical" (if only for
+        // purposes of comparing selections). This is an ideal point of the code
+        // to do this operation, since all selection changes that result in a RANGE 
+        // come through here before anyone uses it.
+        assignStart(start().equivalentDownstreamPosition());
+        assignEnd(end().equivalentUpstreamPosition());
+    }
 
     m_needsCaretLayout = true;
     
diff --git a/WebCore/khtml/xml/dom_selection.cpp b/WebCore/khtml/xml/dom_selection.cpp
index e66bc72..a5d186c 100644
--- a/WebCore/khtml/xml/dom_selection.cpp
+++ b/WebCore/khtml/xml/dom_selection.cpp
@@ -679,12 +679,23 @@ void Selection::validate(ETextGranularity granularity)
     }
 
     // adjust the state
-    if (start().isEmpty() && end().isEmpty())
+    if (start().isEmpty() && end().isEmpty()) {
         m_state = NONE;
-    else if (start() == end() || start().equivalentUpstreamPosition() == end().equivalentUpstreamPosition())
+    }
+    else if (start() == end() || start().equivalentUpstreamPosition() == end().equivalentUpstreamPosition()) {
         m_state = CARET;
-    else
+    }
+    else {
         m_state = RANGE;
+        // "Constrain" the selection to be the smallest equivalent range of nodes.
+        // This is a somewhat arbitrary choice, but experience shows that it is
+        // useful to make to make the selection "canonical" (if only for
+        // purposes of comparing selections). This is an ideal point of the code
+        // to do this operation, since all selection changes that result in a RANGE 
+        // come through here before anyone uses it.
+        assignStart(start().equivalentDownstreamPosition());
+        assignEnd(end().equivalentUpstreamPosition());
+    }
 
     m_needsCaretLayout = true;
     

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list