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
+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)
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
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
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
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
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
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
--- /dev/null
+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
+
--- /dev/null
+
+<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
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
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
+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
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,
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.
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.
return VisiblePosition(p);
}
-// antidote for maxDeepOffset()
Position rangeCompliantEquivalent(const Position& pos)
{
if (pos.isNull())
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);
}
// 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);
}
if (!firstChild())
return VisiblePosition(element(), 0, DOWNSTREAM);
- if (isTable()) {
+ if (isTable() && element()) {
int absx, absy;
absolutePositionForContent(absx, absy);