--- /dev/null
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 6 of #text > DIV > BODY > HTML > #document to 6 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionDropped
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {TEXT} at (0,0) size 757x18
+ text run at (0,0) width 757: "This test does a drag and drop such that the selection around the dragged word is no longer in the document on the drop."
+ RenderBlock {DIV} at (0,34) size 784x18
+ RenderText {TEXT} at (0,0) size 37x18
+ text run at (0,0) width 37: "world"
+ RenderText {TEXT} at (37,0) size 4x18
+ text run at (37,0) width 4: " "
+ RenderInline {SPAN} at (0,0) size 31x18
+ RenderText {TEXT} at (41,0) size 31x18
+ text run at (41,0) width 31: "hello"
+caret: position 1 of child 1 {TEXT} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of #text > SPAN > LI > UL > BODY > HTML > #document to 2 of #text > SPAN > LI > UL > BODY > HTML > #document toDOMRange:range from 0 of #text > SPAN > LI > UL > BODY > HTML > #document to 5 of #text > SPAN > LI > UL > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of LI > UL > BODY > HTML > #document to 0 of LI > UL > BODY > HTML > #document givenAction:WebViewInsertActionDropped
-EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of #text > SPAN > LI > UL > BODY > HTML > #document to 6 of #text > SPAN > LI > UL > BODY > HTML > #document toDOMRange:range from 0 of #text > SPAN > LI > UL > BODY > HTML > #document to 6 of #text > SPAN > LI > UL > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of #text > SPAN > LI > UL > BODY > HTML > #document to 6 of #text > SPAN > LI > UL > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
layer at (0,0) size 800x600
RenderInline {SPAN} at (0,0) size 124x55
RenderText {TEXT} at (0,0) size 124x55
text run at (0,0) width 124: "world "
- RenderText {TEXT} at (124,0) size 107x55
- text run at (124,0) width 107: "hello "
- RenderInline {SPAN} at (0,0) size 112x55
- RenderText {TEXT} at (231,0) size 112x55
- text run at (231,0) width 112: "world"
+ RenderText {TEXT} at (124,0) size 95x55
+ text run at (124,0) width 95: "hello"
RenderBlock {P} at (0,73) size 784x72
RenderText {TEXT} at (0,0) size 764x72
text run at (0,0) width 562: "This is an automated test for elementAtPoint for points over position:outside list markers. "
using namespace HTMLNames;
-ReplacementFragment::ReplacementFragment(Document *document, DocumentFragment *fragment, bool matchStyle)
+ReplacementFragment::ReplacementFragment(Document *document, DocumentFragment *fragment, bool matchStyle, Element* editableRoot)
: m_document(document),
m_fragment(fragment),
m_matchStyle(matchStyle),
removeNode(newlineAtStartNode);
if (newlineAtEndNode)
removeNode(newlineAtEndNode);
-
- RefPtr<Node> holder = insertFragmentForTestRendering();
- Element* editableRoot = document->frame() ? document->frame()->selection().rootEditableElement() : 0;
ASSERT(editableRoot);
if (!editableRoot)
return;
+
+ RefPtr<Node> holder = insertFragmentForTestRendering();
RefPtr<Range> range = new Range(holder->document());
ExceptionCode ec = 0;
holder = insertFragmentForTestRendering();
}
- if (!editableRoot->isContentRichlyEditable())
- m_matchStyle = true;
-
saveRenderingInfo(holder.get());
removeUnrenderedNodes(holder.get());
m_hasMoreThanOneBlock = renderedBlocks(holder.get()) > 1;
}
ReplaceSelectionCommand::ReplaceSelectionCommand(Document *document, DocumentFragment *fragment, bool selectReplacement, bool smartReplace, bool matchStyle)
- : CompositeEditCommand(document),
- m_fragment(document, fragment, matchStyle),
+ : CompositeEditCommand(document),
m_selectReplacement(selectReplacement),
m_smartReplace(smartReplace),
- m_matchStyle(matchStyle)
+ m_matchStyle(matchStyle),
+ m_documentFragment(fragment)
{
}
if (!selection.isContentRichlyEditable())
m_matchStyle = true;
+ ReplacementFragment fragment(document(), m_documentFragment.get(), m_matchStyle, selection.rootEditableElement());
+
if (m_matchStyle)
m_insertionStyle = styleAtPosition(selection.start());
mergeStart = true;
} else {
// merge if current selection starts inside a paragraph, or there is only one block and no interchange newline to add
- mergeStart = !m_fragment.hasInterchangeNewlineAtStart() &&
- (!isStartOfParagraph(visibleStart) || (!m_fragment.hasInterchangeNewlineAtEnd() && !m_fragment.hasMoreThanOneBlock()));
+ mergeStart = !fragment.hasInterchangeNewlineAtStart() &&
+ (!isStartOfParagraph(visibleStart) || (!fragment.hasInterchangeNewlineAtEnd() && !fragment.hasMoreThanOneBlock()));
// This is a workaround for this bug:
// <rdar://problem/4013642> Copied quoted word does not paste as a quote if pasted at the start of a line
// We need more powerful logic in this whole mergeStart code for this case to come out right without
// breaking other cases.
- if (isStartOfParagraph(visibleStart) && isMailBlockquote(m_fragment.firstChild()))
+ if (isStartOfParagraph(visibleStart) && isMailBlockquote(fragment.firstChild()))
mergeStart = false;
// prevent first list item from getting merged into target, thereby pulled out of list
// assume that the mergeStartNode() contains the first visible content to paste.
// Any better ideas?
if (mergeStart) {
- for (Node *n = m_fragment.mergeStartNode(); n; n = n->parentNode()) {
+ for (Node *n = fragment.mergeStartNode(); n; n = n->parentNode()) {
if (isListElement(n)) {
mergeStart = false;
break;
// decide whether to later append nodes to the end
Node *beyondEndNode = 0;
- if (!isEndOfParagraph(visibleEnd) && !m_fragment.hasInterchangeNewlineAtEnd() &&
- (startBlock != endBlock || m_fragment.hasMoreThanOneBlock()))
+ if (!isEndOfParagraph(visibleEnd) && !fragment.hasInterchangeNewlineAtEnd() &&
+ (startBlock != endBlock || fragment.hasMoreThanOneBlock()))
beyondEndNode = selection.end().downstream().node();
Position startPos = selection.start();
// delete the current range selection, or insert paragraph for caret selection, as needed
if (selection.isRange()) {
- bool mergeBlocksAfterDelete = !(m_fragment.hasInterchangeNewlineAtStart() || m_fragment.hasInterchangeNewlineAtEnd() || m_fragment.hasMoreThanOneBlock());
+ bool mergeBlocksAfterDelete = !(fragment.hasInterchangeNewlineAtStart() || fragment.hasInterchangeNewlineAtEnd() || fragment.hasMoreThanOneBlock());
deleteSelection(false, mergeBlocksAfterDelete);
updateLayout();
visibleStart = VisiblePosition(endingSelection().start(), VP_DEFAULT_AFFINITY);
- if (m_fragment.hasInterchangeNewlineAtStart()) {
+ if (fragment.hasInterchangeNewlineAtStart()) {
if (isEndOfParagraph(visibleStart) && !isStartOfParagraph(visibleStart)) {
if (!isEndOfDocument(visibleStart))
setEndingSelection(visibleStart.next());
}
else {
ASSERT(selection.isCaret());
- if (m_fragment.hasInterchangeNewlineAtStart()) {
+ if (fragment.hasInterchangeNewlineAtStart()) {
if (isEndOfParagraph(visibleStart) && !isStartOfParagraph(visibleStart)) {
if (!isEndOfDocument(visibleStart))
setEndingSelection(visibleStart.next());
setEndingSelection(VisiblePosition(endingSelection().start(), VP_DEFAULT_AFFINITY));
}
}
- if (!m_fragment.hasInterchangeNewlineAtEnd() && m_fragment.hasMoreThanOneBlock() &&
+ if (!fragment.hasInterchangeNewlineAtEnd() && fragment.hasMoreThanOneBlock() &&
!startAtBlockBoundary && !isEndOfParagraph(visibleEnd)) {
// The start and the end need to wind up in separate blocks.
// Insert a paragraph separator to make that happen.
setTypingStyle(0);
// done if there is nothing to add
- if (!m_fragment.firstChild())
+ if (!fragment.firstChild())
return;
// check for a line placeholder, and store it away for possible removal later.
// now a "second deepest position"
downstream = positionAvoidingSpecialElementBoundary(downstream);
if (downstream.node()->hasTagName(brTag) && downstream.offset() == 0 &&
- m_fragment.hasInterchangeNewlineAtEnd() &&
+ fragment.hasInterchangeNewlineAtEnd() &&
isStartOfLine(VisiblePosition(downstream, VP_DEFAULT_AFFINITY)))
linePlaceholder = downstream.node();
}
// step 1: merge content into the start block
if (mergeStart) {
- Node *refNode = m_fragment.mergeStartNode();
+ Node *refNode = fragment.mergeStartNode();
if (refNode) {
Node *parent = refNode->parentNode();
Node *node = refNode->nextSibling();
insertNodeAtAndUpdateNodesInserted(refNode, startPos.node(), startPos.offset());
- while (node && !m_fragment.isBlockFlow(node)) {
+ while (node && !fragment.isBlockFlow(node)) {
Node *next = node->nextSibling();
insertNodeAfterAndUpdateNodesInserted(node, refNode);
refNode = node;
}
// step 2 : merge everything remaining in the fragment
- if (m_fragment.firstChild()) {
- Node *refNode = m_fragment.firstChild();
+ if (fragment.firstChild()) {
+ Node *refNode = fragment.firstChild();
Node *node = refNode ? refNode->nextSibling() : 0;
Node *insertionBlock = insertionPos.node()->enclosingBlockFlowElement();
bool insertionBlockIsRoot = insertionBlock == insertionBlock->rootEditableElement();
VisiblePosition visiblePos(insertionPos, DOWNSTREAM);
- if (!insertionBlockIsRoot && m_fragment.isBlockFlow(refNode) && isStartOfBlock(visiblePos))
+ if (!insertionBlockIsRoot && fragment.isBlockFlow(refNode) && isStartOfBlock(visiblePos))
insertNodeBeforeAndUpdateNodesInserted(refNode, insertionBlock);
- else if (!insertionBlockIsRoot && m_fragment.isBlockFlow(refNode) && isEndOfBlock(visiblePos)) {
+ else if (!insertionBlockIsRoot && fragment.isBlockFlow(refNode) && isEndOfBlock(visiblePos)) {
insertNodeAfterAndUpdateNodesInserted(refNode, insertionBlock);
- } else if (m_lastNodeInserted && !m_fragment.isBlockFlow(refNode)) {
+ } else if (m_lastNodeInserted && !fragment.isBlockFlow(refNode)) {
Position pos = visiblePos.next().deepEquivalent().downstream();
insertNodeAtAndUpdateNodesInserted(refNode, pos.node(), pos.offset());
} else {
Position lastPositionToSelect;
// step 4 : handle trailing newline
- if (m_fragment.hasInterchangeNewlineAtEnd()) {
+ if (fragment.hasInterchangeNewlineAtEnd()) {
removeLinePlaceholderIfNeeded(linePlaceholder);
if (!m_lastNodeInserted) {
bool insertParagraph = false;
VisiblePosition pos(insertionPos, VP_DEFAULT_AFFINITY);
- if (startBlock == endBlock && !m_fragment.isBlockFlow(m_lastTopNodeInserted.get())) {
+ if (startBlock == endBlock && !fragment.isBlockFlow(m_lastTopNodeInserted.get())) {
insertParagraph = true;
} else {
// Handle end-of-document case.
}
if (!m_matchStyle)
- fixupNodeStyles(m_fragment.nodes(), m_fragment.renderingInfo());
+ fixupNodeStyles(fragment.nodes(), fragment.renderingInfo());
completeHTMLReplacement(lastPositionToSelect);
// step 5 : mop up