[webkit-changes] cvs commit: WebCore/khtml/editing
composite_edit_command.cpp composite_edit_command.h
htmlediting.cpp htmlediting.h insert_line_break_command.cpp
insert_text_command.cpp replace_selection_command.cpp
David
harrison at opensource.apple.com
Wed Nov 9 11:56:51 PST 2005
harrison 05/11/09 11:56:50
Modified: . ChangeLog
khtml/editing composite_edit_command.cpp
composite_edit_command.h htmlediting.cpp
htmlediting.h insert_line_break_command.cpp
insert_text_command.cpp
replace_selection_command.cpp
Log:
Reviewed by Justin.
<rdar://problem/4313925> Denver Regression: Mail: "TAB+paste+insert before" actually inserts after the pasted text
- added tab span editing functions in composite_edit_command.cpp
- called them from insertText, insertLineBreak, and replaceSelection commands
- also exposed some handy tab span funcs from htmlediting.cpp
Tests added in editing/insertion and editing/pasteboard.
* khtml/editing/composite_edit_command.cpp:
(khtml::CompositeEditCommand::positionOutsideTabSpan):
(khtml::CompositeEditCommand::insertNodeAtTabSpanPosition):
* khtml/editing/composite_edit_command.h:
* khtml/editing/htmlediting.cpp:
(khtml::positionBeforeNode):
(khtml::positionAfterNode):
(khtml::tabSpanNode):
(khtml::positionBeforeTabSpan):
* khtml/editing/htmlediting.h:
* khtml/editing/insert_line_break_command.cpp:
(khtml::InsertLineBreakCommand::doApply):
* khtml/editing/insert_text_command.cpp:
(khtml::InsertTextCommand::prepareForTextInsertion):
* khtml/editing/replace_selection_command.cpp:
(khtml::ReplaceSelectionCommand::doApply):
Revision Changes Path
1.349 +29 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.348
retrieving revision 1.349
diff -u -r1.348 -r1.349
--- ChangeLog 9 Nov 2005 02:46:21 -0000 1.348
+++ ChangeLog 9 Nov 2005 19:56:44 -0000 1.349
@@ -1,3 +1,32 @@
+2005-11-09 David Harrison <harrison at apple.com>
+
+ Reviewed by Justin.
+
+ <rdar://problem/4313925> Denver Regression: Mail: "TAB+paste+insert before" actually inserts after the pasted text
+
+ - added tab span editing functions in composite_edit_command.cpp
+ - called them from insertText, insertLineBreak, and replaceSelection commands
+ - also exposed some handy tab span funcs from htmlediting.cpp
+
+ Tests added in editing/insertion and editing/pasteboard.
+
+ * khtml/editing/composite_edit_command.cpp:
+ (khtml::CompositeEditCommand::positionOutsideTabSpan):
+ (khtml::CompositeEditCommand::insertNodeAtTabSpanPosition):
+ * khtml/editing/composite_edit_command.h:
+ * khtml/editing/htmlediting.cpp:
+ (khtml::positionBeforeNode):
+ (khtml::positionAfterNode):
+ (khtml::tabSpanNode):
+ (khtml::positionBeforeTabSpan):
+ * khtml/editing/htmlediting.h:
+ * khtml/editing/insert_line_break_command.cpp:
+ (khtml::InsertLineBreakCommand::doApply):
+ * khtml/editing/insert_text_command.cpp:
+ (khtml::InsertTextCommand::prepareForTextInsertion):
+ * khtml/editing/replace_selection_command.cpp:
+ (khtml::ReplaceSelectionCommand::doApply):
+
2005-11-08 Tim Omernick <timo at apple.com>
<http://bugzilla.opendarwin.org/show_bug.cgi?id=5665> (REGRESSION: Crash in deleteTimer)
1.17 +23 -0 WebCore/khtml/editing/composite_edit_command.cpp
Index: composite_edit_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/composite_edit_command.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- composite_edit_command.cpp 7 Nov 2005 19:59:22 -0000 1.16
+++ composite_edit_command.cpp 9 Nov 2005 19:56:47 -0000 1.17
@@ -280,6 +280,29 @@
applyCommandToComposite(insertCommand);
}
+Position CompositeEditCommand::positionOutsideTabSpan(const Position& pos)
+{
+ ASSERT(isTabSpanTextNode(pos.node()));
+
+ NodeImpl *tabSpan = tabSpanNode(pos.node());
+
+ if (pos.offset() <= pos.node()->caretMinOffset())
+ return positionBeforeNode(tabSpan);
+
+ if (pos.offset() >= pos.node()->caretMaxOffset())
+ return positionAfterNode(tabSpan);
+
+ splitTextNodeContainingElement(static_cast<TextImpl *>(pos.node()), pos.offset());
+ return positionBeforeNode(tabSpan);
+}
+
+void CompositeEditCommand::insertNodeAtTabSpanPosition(NodeImpl *node, const Position& pos)
+{
+ // insert node before, after, or at split of tab span
+ Position insertPos = positionOutsideTabSpan(pos);
+ insertNodeAt(node, insertPos.node(), insertPos.offset());
+}
+
void CompositeEditCommand::deleteSelection(bool smartDelete, bool mergeBlocksAfterDelete)
{
if (endingSelection().isRange()) {
1.6 +2 -0 WebCore/khtml/editing/composite_edit_command.h
Index: composite_edit_command.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/composite_edit_command.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- composite_edit_command.h 29 Sep 2005 07:47:06 -0000 1.5
+++ composite_edit_command.h 9 Nov 2005 19:56:47 -0000 1.6
@@ -73,6 +73,8 @@
void removeNode(DOM::NodeImpl *removeChild);
void removeNodePreservingChildren(DOM::NodeImpl *node);
void replaceTextInNode(DOM::TextImpl *node, int offset, int count, const DOM::DOMString &replacementText);
+ DOM::Position positionOutsideTabSpan(const DOM::Position& pos);
+ void insertNodeAtTabSpanPosition(DOM::NodeImpl *node, const DOM::Position& pos);
void setNodeAttribute(DOM::ElementImpl *, const DOM::QualifiedName& attribute, const DOM::DOMString &);
void splitTextNode(DOM::TextImpl *text, int offset);
void splitElement(DOM::ElementImpl *element, DOM::NodeImpl *atChild);
1.261 +8 -3 WebCore/khtml/editing/htmlediting.cpp
Index: htmlediting.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/htmlediting.cpp,v
retrieving revision 1.260
retrieving revision 1.261
diff -u -r1.260 -r1.261
--- htmlediting.cpp 3 Oct 2005 21:12:19 -0000 1.260
+++ htmlediting.cpp 9 Nov 2005 19:56:47 -0000 1.261
@@ -213,7 +213,7 @@
return false;
}
-static Position positionBeforeNode(NodeImpl *node)
+Position positionBeforeNode(const NodeImpl *node)
{
return Position(node->parentNode(), node->nodeIndex());
}
@@ -263,7 +263,7 @@
return false;
}
-static Position positionAfterNode(NodeImpl *node)
+Position positionAfterNode(const NodeImpl *node)
{
return Position(node->parentNode(), node->nodeIndex() + 1);
}
@@ -336,11 +336,16 @@
return (node && node->parentNode() && isTabSpanNode(node->parentNode()));
}
+NodeImpl *tabSpanNode(const NodeImpl *node)
+{
+ return isTabSpanTextNode(node) ? node->parentNode() : 0;
+}
+
Position positionBeforeTabSpan(const Position& pos)
{
NodeImpl *node = pos.node();
if (isTabSpanTextNode(node))
- node = node->parent();
+ node = tabSpanNode(node);
else if (!isTabSpanNode(node))
return pos;
1.113 +8 -4 WebCore/khtml/editing/htmlediting.h
Index: htmlediting.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/htmlediting.h,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -r1.112 -r1.113
--- htmlediting.h 29 Sep 2005 07:47:06 -0000 1.112
+++ htmlediting.h 9 Nov 2005 19:56:48 -0000 1.113
@@ -60,20 +60,24 @@
//------------------------------------------------------------------------------------------
-bool isSpecialElement(const DOM::NodeImpl *n);
+DOM::Position positionBeforeNode(const DOM::NodeImpl *node);
+DOM::Position positionAfterNode(const DOM::NodeImpl *node);
+
+bool isSpecialElement(const DOM::NodeImpl *node);
DOM::ElementImpl *createDefaultParagraphElement(DOM::DocumentImpl *document);
DOM::ElementImpl *createBreakElement(DOM::DocumentImpl *document);
bool isTabSpanNode(const DOM::NodeImpl *node);
bool isTabSpanTextNode(const DOM::NodeImpl *node);
+DOM::NodeImpl *tabSpanNode(const DOM::NodeImpl *node);
DOM::Position positionBeforeTabSpan(const DOM::Position& pos);
DOM::ElementImpl *createTabSpanElement(DOM::DocumentImpl *document, DOM::NodeImpl *tabTextNode=0);
DOM::ElementImpl *createTabSpanElement(DOM::DocumentImpl *document, QString *tabText);
-bool isNodeRendered(const DOM::NodeImpl *);
-bool isMailBlockquote(const DOM::NodeImpl *);
-DOM::NodeImpl *nearestMailBlockquote(const DOM::NodeImpl *);
+bool isNodeRendered(const DOM::NodeImpl *node);
+bool isMailBlockquote(const DOM::NodeImpl *node);
+DOM::NodeImpl *nearestMailBlockquote(const DOM::NodeImpl *node);
//------------------------------------------------------------------------------------------
1.9 +9 -14 WebCore/khtml/editing/insert_line_break_command.cpp
Index: insert_line_break_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/insert_line_break_command.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- insert_line_break_command.cpp 3 Oct 2005 21:12:19 -0000 1.8
+++ insert_line_break_command.cpp 9 Nov 2005 19:56:48 -0000 1.9
@@ -104,11 +104,10 @@
pos = positionOutsideContainingSpecialElement(pos);
- bool atStart = pos.offset() <= pos.node()->caretMinOffset();
- bool atEnd = pos.offset() >= pos.node()->caretMaxOffset();
- bool atEndOfBlock = isEndOfBlock(VisiblePosition(pos, selection.startAffinity()));
-
- if (atEndOfBlock) {
+ if (isTabSpanTextNode(pos.node())) {
+ insertNodeAtTabSpanPosition(nodeToInsert, pos);
+ setEndingSelection(Position(nodeToInsert->traverseNextNode(), 0), DOWNSTREAM);
+ } else if (isEndOfBlock(VisiblePosition(pos, selection.startAffinity()))) {
LOG(Editing, "input newline case 1");
// Check for a trailing BR. If there isn't one, we'll need to insert an "extra" one.
// This makes the "real" BR we want to insert appear in the rendering without any
@@ -117,14 +116,12 @@
if (pos.node()->hasTagName(brTag) && pos.offset() == 0) {
// Already placed in a trailing BR. Insert "real" BR before it and leave the selection alone.
insertNodeBefore(nodeToInsert, pos.node());
- }
- else {
+ } else {
NodeImpl *next = pos.node()->traverseNextNode();
bool hasTrailingBR = next && next->hasTagName(brTag) && pos.node()->enclosingBlockFlowElement() == next->enclosingBlockFlowElement();
insertNodeAfterPosition(nodeToInsert, pos);
- if (hasTrailingBR) {
+ if (hasTrailingBR)
setEndingSelection(SelectionController(Position(next, 0), DOWNSTREAM));
- }
else if (!document()->inStrictMode()) {
// Insert an "extra" BR at the end of the block.
ElementImpl *extraBreakNode = createBreakElement(document());
@@ -133,22 +130,20 @@
}
}
}
- else if (atStart) {
+ else if (pos.offset() <= pos.node()->caretMinOffset()) {
LOG(Editing, "input newline case 2");
// Insert node before downstream position, and place caret there as well.
Position endingPosition = pos.downstream();
insertNodeBeforePosition(nodeToInsert, endingPosition);
setEndingSelection(endingPosition, DOWNSTREAM);
- }
- else if (atEnd) {
+ } else if (pos.offset() >= pos.node()->caretMaxOffset()) {
LOG(Editing, "input newline case 3");
// Insert BR after this node. Place caret in the position that is downstream
// of the current position, reckoned before inserting the BR in between.
Position endingPosition = pos.downstream();
insertNodeAfterPosition(nodeToInsert, pos);
setEndingSelection(endingPosition, DOWNSTREAM);
- }
- else {
+ } else {
// Split a text node
LOG(Editing, "input newline case 4");
ASSERT(pos.node()->isTextNode());
1.13 +1 -10 WebCore/khtml/editing/insert_text_command.cpp
Index: insert_text_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/insert_text_command.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- insert_text_command.cpp 31 Oct 2005 19:04:43 -0000 1.12
+++ insert_text_command.cpp 9 Nov 2005 19:56:48 -0000 1.13
@@ -90,17 +90,8 @@
}
if (isTabSpanTextNode(pos.node())) {
- Position tempPos = pos;
NodeImpl *textNode = document()->createEditingTextNode("");
- NodeImpl *originalTabSpan = tempPos.node()->parent();
- if (tempPos.offset() <= tempPos.node()->caretMinOffset()) {
- insertNodeBefore(textNode, originalTabSpan);
- } else if (tempPos.offset() >= tempPos.node()->caretMaxOffset()) {
- insertNodeAfter(textNode, originalTabSpan);
- } else {
- splitTextNodeContainingElement(static_cast<TextImpl *>(tempPos.node()), tempPos.offset());
- insertNodeBefore(textNode, originalTabSpan);
- }
+ insertNodeAtTabSpanPosition(textNode, pos);
return Position(textNode, 0);
}
1.18 +4 -1 WebCore/khtml/editing/replace_selection_command.cpp
Index: replace_selection_command.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/replace_selection_command.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- replace_selection_command.cpp 3 Oct 2005 21:12:20 -0000 1.17
+++ replace_selection_command.cpp 9 Nov 2005 19:56:48 -0000 1.18
@@ -719,7 +719,10 @@
if (startAtStartOfBlock && startBlock->inDocument())
startPos = Position(startBlock, 0);
- startPos = positionOutsideContainingSpecialElement(startPos);
+ if (isTabSpanTextNode(startPos.node()))
+ startPos = positionOutsideTabSpan(startPos);
+ else
+ startPos = positionOutsideContainingSpecialElement(startPos);
KHTMLPart *part = document()->part();
More information about the webkit-changes
mailing list