+2004-12-10 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by Chris
+
+ * khtml/editing/htmlediting.cpp:
+ (khtml::InsertParagraphSeparatorCommand::doApply): There is a starting block which is supposed to
+ act as the root node for this operation. However, a loop was incorrectly coded, and a parent node
+ search could escape this node. Also, one other piece to code to move nodes to the new <p> element
+ should do nothing if the starting point for the selection is itself the starting block.
+ (khtml::InsertParagraphSeparatorInQuotedContentCommand::doApply): Similar changes, in spirit, to the above
+ function, though the names and concepts are slightly different.
+
2004-12-10 Maciej Stachowiak <mjs@apple.com>
Reviewed by Ken.
return;
// Build up list of ancestors in between the start node and the start block.
- for (NodeImpl *n = startNode->parentNode(); n && n != startBlock; n = n->parentNode())
- ancestors.prepend(n);
+ if (startNode != startBlock) {
+ for (NodeImpl *n = startNode->parentNode(); n && n != startBlock; n = n->parentNode())
+ ancestors.prepend(n);
+ }
// Make new block to represent the newline.
// If the start block is the body, just make a P tag, otherwise, make a shallow clone
}
// Move the start node and the siblings of the start node.
- NodeImpl *n = startNode;
- if (n->id() == ID_BR)
- n = n->nextSibling();
- while (n && n != addedBlock) {
- NodeImpl *next = n->nextSibling();
- removeNode(n);
- appendNode(n, parent);
- n = next;
- }
-
+ if (startNode != startBlock) {
+ NodeImpl *n = startNode;
+ if (n->id() == ID_BR)
+ n = n->nextSibling();
+ while (n && n != addedBlock) {
+ NodeImpl *next = n->nextSibling();
+ removeNode(n);
+ appendNode(n, parent);
+ n = next;
+ }
+ }
+
// Move everything after the start node.
NodeImpl *leftParent = ancestors.last();
while (leftParent && leftParent != startBlock) {
return;
// Build up list of ancestors in between the start node and the top blockquote.
- for (NodeImpl *n = startNode->parentNode(); n && n != topBlockquote; n = n->parentNode())
- ancestors.prepend(n);
+ if (startNode != topBlockquote) {
+ for (NodeImpl *n = startNode->parentNode(); n && n != topBlockquote; n = n->parentNode())
+ ancestors.prepend(n);
+ }
// Insert a break after the top blockquote.
int exceptionCode = 0;
}
// Move the start node and the siblings of the start node.
- NodeImpl *n = startNode;
- bool startIsBR = n->id() == ID_BR;
- if (startIsBR)
- n = n->nextSibling();
- while (n) {
- NodeImpl *next = n->nextSibling();
- removeNode(n);
- appendNode(n, parent);
- n = next;
+ bool startIsBR = false;
+ if (startNode != topBlockquote) {
+ NodeImpl *n = startNode;
+ bool startIsBR = n->id() == ID_BR;
+ if (startIsBR)
+ n = n->nextSibling();
+ while (n) {
+ NodeImpl *next = n->nextSibling();
+ removeNode(n);
+ appendNode(n, parent);
+ n = next;
+ }
}
// Move everything after the start node.