Reviewed by harrison
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Jul 2006 22:29:02 +0000 (22:29 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Jul 2006 22:29:02 +0000 (22:29 +0000)
        <rdar://problem/4619260>
        9A213 + Safari 521.15.1 Crash with To Do's alarm icon (WebCore::maxDeepOffset(WebCore::Node const*) )
        <rdar://problem/4619841>
        REGRESSION: Dragging selection over input field results in a crash (WebCore::maxDeepOffset(WebCore::Node const*)

        * WebCore.xcodeproj/project.pbxproj:
        * editing/Selection.cpp:
        (WebCore::Selection::adjustForEditableContent): Iterate using next/previousVisuallyDistinctCandidate
        instead of traverseNext/Previous node because we were skipping positions.  Jump out of shadow trees.
        Migrate to isEditablePosition instead of isContentEditable.

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

WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/editing/Selection.cpp

index ebf4aa9930b44a5b7781e09099110411946dace1..28c4ecdf90bf4a0d7f593b9c92a49b7e0d7316cc 100644 (file)
@@ -1,3 +1,19 @@
+2006-07-10  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+        
+        <rdar://problem/4619260>
+        9A213 + Safari 521.15.1 Crash with To Do's alarm icon (WebCore::maxDeepOffset(WebCore::Node const*) )
+        <rdar://problem/4619841>
+        REGRESSION: Dragging selection over input field results in a crash (WebCore::maxDeepOffset(WebCore::Node const*)
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * editing/Selection.cpp:
+        (WebCore::Selection::adjustForEditableContent): Iterate using next/previousVisuallyDistinctCandidate 
+        instead of traverseNext/Previous node because we were skipping positions.  Jump out of shadow trees.  
+        Migrate to isEditablePosition instead of isContentEditable.
+        
+
 2006-07-10  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Adele.
index 35e71a50b1446daa22ea686bb24000663c528cc5..c9445b51c3e26c43ae701e786a156b566e4b61f7 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildStyle section */
+               D0DBCB790A6303EC007FA386 /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               D0DBCB7A0A6303EC007FA386 /* Deployment */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                       };
+                       name = Deployment;
+               };
+/* End PBXBuildStyle section */
+
 /* Begin PBXContainerItemProxy section */
                DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+                       buildSettings = {
+                       };
+                       buildStyles = (
+                               D0DBCB790A6303EC007FA386 /* Development */,
+                               D0DBCB7A0A6303EC007FA386 /* Deployment */,
+                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index a96545ec16badc026e7a1bedb7048629fafd4962..ea2debab5739f4f1f7de2be1ffd6821e30ebde1d 100644 (file)
@@ -334,12 +334,16 @@ void Selection::adjustForEditableContent()
         // move backward until non-editable content inside the same lowest editable ancestor is reached.
         Node* endEditableAncestor = lowestEditableAncestor(m_end.node());
         if (endRoot || endEditableAncestor != baseEditableAncestor) {
-            Node* node = m_end.node();
-            VisiblePosition previous(Position(node, maxDeepOffset(node)));
-            while (node && !(lowestEditableAncestor(node) == baseEditableAncestor && !node->isContentEditable() && previous.isNotNull())) {
-                node = node->traversePreviousNode();
-                previous = VisiblePosition(Position(node, node ? maxDeepOffset(node) : 0));
+            
+            Position p = previousVisuallyDistinctCandidate(m_end);
+            while (p.isNotNull() && !(lowestEditableAncestor(p.node()) == baseEditableAncestor && !isEditablePosition(p))) {
+                Node* root = editableRootForPosition(p);
+                Node* shadowParent = root && root->isShadowNode() ? root->shadowParentNode() : 0;
+                p = isAtomicNode(p.node()) ? positionBeforeNode(p.node()) : previousVisuallyDistinctCandidate(p);
+                if (p.isNull() && shadowParent)
+                    p = Position(shadowParent, maxDeepOffset(shadowParent));
             }
+            VisiblePosition previous(p);
             
             if (previous.isNull()) {
                 ASSERT_NOT_REACHED();
@@ -351,16 +355,19 @@ void Selection::adjustForEditableContent()
             m_end = previous.deepEquivalent();
         }
 
-        // The selection ends in editable content or non-editable content inside a different editable ancestor, 
-        // move backward until non-editable content inside the same lowest editable ancestor is reached.
+        // The selection starts in editable content or non-editable content inside a different editable ancestor, 
+        // move forward until non-editable content inside the same lowest editable ancestor is reached.
         Node* startEditableAncestor = lowestEditableAncestor(m_start.node());      
         if (startRoot || startEditableAncestor != baseEditableAncestor) {
-            Node* node = m_start.node();
-            VisiblePosition next(Position(node, 0));
-            while (node && !(lowestEditableAncestor(node) == baseEditableAncestor && !node->isContentEditable() && next.isNotNull())) {
-                node = node->traverseNextNode();
-                next = VisiblePosition(Position(node, 0));
+            Position p = nextVisuallyDistinctCandidate(m_start);
+            while (p.isNotNull() && !(lowestEditableAncestor(p.node()) == baseEditableAncestor && !isEditablePosition(p))) {
+                Node* root = editableRootForPosition(p);
+                Node* shadowParent = root && root->isShadowNode() ? root->shadowParentNode() : 0;
+                p = isAtomicNode(p.node()) ? positionAfterNode(p.node()) : nextVisuallyDistinctCandidate(p);
+                if (p.isNull() && shadowParent)
+                    p = Position(shadowParent, 0);
             }
+            VisiblePosition next(p);
             
             if (next.isNull()) {
                 ASSERT_NOT_REACHED();