LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jul 2006 02:31:39 +0000 (02:31 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jul 2006 02:31:39 +0000 (02:31 +0000)
        Reviewed by levi

        <rdar://problem/4509393>
        selected DOM range starts with <object>, 0 offset but selection should include the <object>

        * editing/selection/legal-positions-expected.txt: Added.
        * editing/selection/legal-positions.html: Added.

        * editing/deleting/delete-3608430-fix-expected.txt:
        * editing/deleting/delete-image-001-expected.txt:
        * editing/deleting/delete-image-002-expected.txt:
        * editing/deleting/delete-image-003-expected.txt:
        * editing/deleting/delete-image-004-expected.txt:
        * editing/selection/drag-to-contenteditable-iframe-expected.txt:
        * editing/selection/replaced-boundaries-3-expected.txt:
        * editing/selection/select-box-expected.txt:

WebCore:

        Reviewed by levi

        <rdar://problem/4509393>
        selected DOM range starts with <object>, 0 offset but selection should include the <object>

        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::shouldMergeStart):
        Don't pull content out of a table cell.
        * editing/htmlediting.cpp:
        (WebCore::editingIgnoresContent): Added <select> nodes.
        (WebCore::rangeCompliantEquivalent): Convert [node, 0] positions to positionBeforeNode(node)
        for more types of nodes.
        * rendering/RenderContainer.cpp:
        (WebCore::RenderContainer::positionForCoordinates):
        Fix a crasher when right clicking on an anonymous table.

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/deleting/delete-3608430-fix-expected.txt
LayoutTests/editing/deleting/delete-image-001-expected.txt
LayoutTests/editing/deleting/delete-image-002-expected.txt
LayoutTests/editing/deleting/delete-image-003-expected.txt
LayoutTests/editing/deleting/delete-image-004-expected.txt
LayoutTests/editing/selection/drag-to-contenteditable-iframe-expected.txt
LayoutTests/editing/selection/legal-positions-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/legal-positions.html [new file with mode: 0644]
LayoutTests/editing/selection/replaced-boundaries-3-expected.txt
LayoutTests/editing/selection/select-box-expected.txt
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/editing/htmlediting.cpp
WebCore/rendering/RenderContainer.cpp

index 2e5fdaa95c23c6783307910faee66b1ef586b350..1876213495197ce1bb40771ff3555f81df7cdeac 100644 (file)
@@ -1,3 +1,22 @@
+2006-07-12  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+        
+        <rdar://problem/4509393>
+        selected DOM range starts with <object>, 0 offset but selection should include the <object>
+
+        * editing/selection/legal-positions-expected.txt: Added.
+        * editing/selection/legal-positions.html: Added.
+
+        * editing/deleting/delete-3608430-fix-expected.txt:
+        * editing/deleting/delete-image-001-expected.txt:
+        * editing/deleting/delete-image-002-expected.txt:
+        * editing/deleting/delete-image-003-expected.txt:
+        * editing/deleting/delete-image-004-expected.txt:
+        * editing/selection/drag-to-contenteditable-iframe-expected.txt:
+        * editing/selection/replaced-boundaries-3-expected.txt:
+        * editing/selection/select-box-expected.txt:
+
 2006-07-12  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Brady Eidson (and written by Justin Garcia)
index 9513aa2d5934d707c615a759363064f87240394b..d320b42a78c29fc7b1caae7899c33f151427096d 100644 (file)
@@ -101,7 +101,7 @@ EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > SPAN > DIV > BODY
 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document toDOMRange:range from 6 of SPAN > DIV > BODY > HTML > #document to 6 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
-EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of IMG > SPAN > DIV > BODY > HTML > #document to 6 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldDeleteDOMRange:range from 5 of SPAN > DIV > BODY > HTML > #document to 6 of SPAN > DIV > BODY > HTML > #document
 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 4 of #text > SPAN > DIV > BODY > HTML > #document to 4 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
index a4fa93997fe6ae2eb9d63ac124dc3621022c07bd..29bc776034eb75eeaa0a8e389fba62fcab4c4ee0 100644 (file)
@@ -5,7 +5,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of IMG > SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldDeleteDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
index 64b012a0f3a2bfbaeff9fc75bf2933cf6f259fa4..e82c9109d7833717d5a290bf9b032458932a939d 100644 (file)
@@ -3,7 +3,7 @@ EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of IMG > SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document
 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
index fa47e0b841e9f7494bbaedb95ee9ce373636c31a..701b06e3263969ebddb409b1f4ff370f2d3bf63d 100644 (file)
@@ -4,7 +4,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of IMG > SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > SPAN > DIV > BODY > HTML > #document to 1 of #text > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
index 880af34739ff5da24d8ed95dc8693ae95e1af0b6..dabc8e7adb467a9b2d2a3ad7f6fe47a86199bf7e 100644 (file)
@@ -4,7 +4,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of IMG > SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
+EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of SPAN > DIV > BODY > HTML > #document to 4 of SPAN > DIV > BODY > HTML > #document
 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
index af8990a5bf1e2c1a1082309306728b11d5411d94..e198bacb2b09e39135bd3e26149a3ac560c44a3e 100644 (file)
@@ -9,7 +9,7 @@ EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of IFRAME > BODY > H
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of BODY > HTML > #document to 0 of BODY > HTML > #document givenAction:WebViewInsertActionDropped
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of BODY > HTML > #document to 0 of BODY > HTML > #document toDOMRange:range from 0 of IMG > BODY > HTML > #document to 1 of BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of BODY > HTML > #document to 0 of BODY > HTML > #document toDOMRange:range from 0 of BODY > HTML > #document to 1 of BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
diff --git a/LayoutTests/editing/selection/legal-positions-expected.txt b/LayoutTests/editing/selection/legal-positions-expected.txt
new file mode 100644 (file)
index 0000000..9eb4534
--- /dev/null
@@ -0,0 +1,25 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+This tests the endpoints of a DOM Range object made from a selection around certain types elements. These endpoints shouldn't be at offsets inside nodes that aren't containers or text nodes.
+
+Hello world!
+Hello World!
+Success
+Success
+Success
+Success
+Success
+Success
+Success
+Success
+Success
+Success
+Success
+Success
+Success
+Success
+Success
+Success
+
diff --git a/LayoutTests/editing/selection/legal-positions.html b/LayoutTests/editing/selection/legal-positions.html
new file mode 100644 (file)
index 0000000..4a623e3
--- /dev/null
@@ -0,0 +1,61 @@
+
+<script>
+function log(str) {
+    var li = document.createElement("li");
+    li.appendChild(document.createTextNode(str));
+    var console = document.getElementById("console");
+    console.appendChild(li);
+}
+
+function assert(bool) {
+    if (!bool)
+        log("Failure");
+    else
+        log("Success");
+}
+</script>
+<p>This tests the endpoints of a DOM Range object made from a selection around certain types elements.  These endpoints shouldn't be at offsets inside nodes that aren't containers or text nodes.</p>
+<div id="test">Hello <img src="../resources/abe.jpg"><object width="100"></object>world!<br>Hello World!</div>
+<ul id="console"></ul>
+
+<script>
+var s = window.getSelection();
+var e = document.getElementById("test");
+var r;
+
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+
+// The textnode
+s.setBaseAndExtent(e, 0, e, 1);
+r = s.getRangeAt(0);
+assert(r.startContainer == e.childNodes[0]);
+assert(r.startOffset == 0);
+assert(r.endContainer == e.childNodes[0]);
+assert(r.endOffset == r.endContainer.length);
+
+// The image
+s.setBaseAndExtent(e, 1, e, 2);
+r = s.getRangeAt(0);
+assert(r.startContainer == e);
+assert(r.startOffset == 1);
+assert(r.endContainer == e);
+assert(r.endOffset == 2);
+
+// The <object>
+s.setBaseAndExtent(e, 2, e, 3);
+r = s.getRangeAt(0);
+assert(r.startContainer == e);
+assert(r.startOffset == 2);
+assert(r.endContainer == e);
+assert(r.endOffset == 3);
+
+// The <br>
+s.setBaseAndExtent(e, 4, e, 5);
+r = s.getRangeAt(0);
+assert(r.startContainer == e);
+assert(r.startOffset == 4);
+assert(r.endContainer == e);
+assert(r.endOffset == 5);
+
+</script>
\ No newline at end of file
index 33417438b5b1b27194a0aecd56d297d4cf52c652..a018eeab672d3cde59c3c2b23fa2dd0a288d1097 100644 (file)
@@ -1,7 +1,7 @@
 EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 5 of DIV > BODY > HTML > #document
 EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 0 of SELECT > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 2 of SELECT > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
index 9c388e2714ec180087372f91649b7197abf89416..26273b78d88cb4fb5427ecbb828db7a929b2be4d 100644 (file)
@@ -53,6 +53,8 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x600
index 12a17627ca1b402e4049a829bd7a1063ccdb92e2..77e5118b7d0854cbf86b3ec28855e76e2974cd3e 100644 (file)
@@ -1,3 +1,21 @@
+2006-07-12  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+        
+        <rdar://problem/4509393>
+        selected DOM range starts with <object>, 0 offset but selection should include the <object>
+
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::shouldMergeStart): 
+        Don't pull content out of a table cell.
+        * editing/htmlediting.cpp:
+        (WebCore::editingIgnoresContent): Added <select> nodes.
+        (WebCore::rangeCompliantEquivalent): Convert [node, 0] positions to positionBeforeNode(node)
+        for more types of nodes.
+        * rendering/RenderContainer.cpp:
+        (WebCore::RenderContainer::positionForCoordinates): 
+        Fix a crasher when right clicking on an anonymous table.
+
 2006-07-12  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Brady Eidson
index 2e82e1a11d6dcbe13cf1369dd910b79d0393d3ba..0ee439bce98c81c572bc239fa4441cf5b7e20059 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildStyle section */
+               D098D47C0A65E2F400D1917D /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               D098D47D0A65E2F400D1917D /* Deployment */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                       };
+                       name = Deployment;
+               };
+/* End PBXBuildStyle section */
+
+/* Begin PBXBuildStyle section */
+               D098D45B0A65D5A600D1917D /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               D098D45C0A65D5A600D1917D /* 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 = (
+                               D098D47C0A65E2F400D1917D /* Development */,
+                               D098D47D0A65E2F400D1917D /* Deployment */,
+                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index c689d3b8b340a0e02fccf2c0975957470bcc075f..40241f0c2a16b507899ac88a69ac4dd9960eacfb 100644 (file)
@@ -489,8 +489,9 @@ bool ReplaceSelectionCommand::shouldMergeStart(const ReplacementFragment& incomi
         return false;
     
     // Don't pull content out of a list item.
-    // FIXMEs: Don't pull content out of a table cell either.
-    if (enclosingList(incomingFragment.mergeStartNode()))
+    // FIXMEs: Use an enclosing element getter that uses the render tree once this function is called after the fragment
+    // that's been placed into the document.
+    if (enclosingList(incomingFragment.mergeStartNode()) || enclosingNodeWithTag(incomingFragment.mergeStartNode(), tdTag))
         return false;
     
     // Merge if this is an empty editable subtree, to prevent an extra level of block nesting.
index c6854280d6b7abd4abdafdf0768021100e5190cf..661b77f7dd7876793e9683bf91a089851ebd9652 100644 (file)
@@ -55,26 +55,18 @@ bool editingIgnoresContent(const Node *node)
     if (!node || !node->isHTMLElement())
         return false;
     
-    if (node->renderer()) {
-        if (node->renderer()->isWidget() || node->renderer()->isImage())
-            return true;
-    } else {
-        // widgets
-        if (static_cast<const HTMLElement *>(node)->isGenericFormElement())
-            return true;
-        if (node->hasTagName(appletTag))
-            return true;
-        if (node->hasTagName(embedTag))
-            return true;
-        if (node->hasTagName(iframeTag))
-            return true;
-
-        // images
-        if (node->hasTagName(imgTag))
-            return true;
-    }
+    // There doesn't seem to be a way to find out if a a node is a pop up box by looking at its renderer.
+    if (node->hasTagName(selectTag))
+        return true;
     
-    return false;
+    if (node->renderer())
+        return node->renderer()->isWidget() || node->renderer()->isImage() || node->renderer()->isFormElement();
+
+    return node->hasTagName(appletTag) ||
+           node->hasTagName(embedTag) ||
+           node->hasTagName(iframeTag) ||
+           node->hasTagName(imgTag) ||
+           static_cast<const HTMLElement *>(node)->isGenericFormElement();
 }
 
 // Some nodes, like brs, will technically accept children, but we don't want that to happen while editing. 
@@ -265,7 +257,6 @@ VisiblePosition lastEditablePositionBeforePositionInRoot(const Position& positio
     return VisiblePosition(p);
 }
 
-// antidote for maxDeepOffset()
 Position rangeCompliantEquivalent(const Position& pos)
 {
     if (pos.isNull())
@@ -274,10 +265,7 @@ Position rangeCompliantEquivalent(const Position& pos)
     Node *node = pos.node();
     
     if (pos.offset() <= 0) {
-        // FIXME: createMarkup has a problem with BR 0 as the starting position
-        // so workaround until I can come back and fix createMarkup.  The problem
-        // is that createMarkup fails to include the initial BR in the markup.
-        if (node->parentNode() && node->hasTagName(brTag))
+        if (node->parentNode() && (node->hasTagName(brTag) || editingIgnoresContent(node)))
             return positionBeforeNode(node);
         return Position(node, 0);
     }
@@ -294,12 +282,9 @@ Position rangeCompliantEquivalent(const Position& pos)
         // use the highest allowed position in the node
         return Position(node, maxCompliantOffset);
     } 
-    
-    // "select" nodes, e.g., are ignored by editing but can have children.
-    // For us, a range inside of that node is tough to deal with, so use
-    // a more generic position.
+
+    // Editing should never generate positions like this.
     if ((pos.offset() < maxCompliantOffset) && editingIgnoresContent(node)) {
-        // ... but we should not have generated any such positions
         ASSERT_NOT_REACHED();
         return node->parentNode() ? positionBeforeNode(node) : Position(node, 0);
     }
index 13b720f3f31095de84338e53371954f050a85999..69cae5d48b0934695c4d9f2d047ea38eff1816e0 100644 (file)
@@ -495,7 +495,7 @@ VisiblePosition RenderContainer::positionForCoordinates(int x, int y)
     if (!firstChild())
         return VisiblePosition(element(), 0, DOWNSTREAM);
         
-    if (isTable()) {
+    if (isTable() && element()) {
         int absx, absy;
         absolutePositionForContent(absx, absy);