+2004-09-22 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Ken and John.
+
+ <rdar://problem/3759228> REGRESSION (Mail): stray characters when entering text via input method right after newline
+
+ * khtml/editing/htmlediting_impl.cpp:
+ (khtml::CompositeEditCommandImpl::inputText): Add an optional
+ selectInsertedText parameter.
+ (khtml::ReplaceSelectionCommandImpl::doApply): Let the inputText operation
+ select the text when inserting plain text, because it already knows all the right
+ information to do so, and this function doesn't (sometimes text is inserted
+ before the start of the old selection, not after!)
+ * khtml/editing/htmlediting_impl.h:
+
2004-09-22 Richard Williamson <rjw@apple.com>
More tweaks to dashboard regions.
applyCommandToComposite(cmd);
}
-void CompositeEditCommandImpl::inputText(const DOMString &text)
+void CompositeEditCommandImpl::inputText(const DOMString &text, bool selectInsertedText)
{
InputTextCommand cmd(document());
applyCommandToComposite(cmd);
- cmd.input(text);
+ cmd.input(text, selectInsertedText);
}
void CompositeEditCommandImpl::insertText(TextImpl *node, long offset, const DOMString &text)
LOG(Editing, "prepareForTextInsertion case 1");
appendNode(nodeToInsert, pos.node());
}
- else if (pos.node()->id() == ID_BR && pos.offset() == 1) {
- LOG(Editing, "prepareForTextInsertion case 2");
- insertNodeAfter(nodeToInsert, pos.node());
- }
else if (pos.node()->caretMinOffset() == pos.offset()) {
- LOG(Editing, "prepareForTextInsertion case 3");
+ LOG(Editing, "prepareForTextInsertion case 2");
insertNodeBefore(nodeToInsert, pos.node());
}
else if (pos.node()->caretMaxOffset() == pos.offset()) {
- LOG(Editing, "prepareForTextInsertion case 4");
+ LOG(Editing, "prepareForTextInsertion case 3");
insertNodeAfter(nodeToInsert, pos.node());
}
else
if (addTrailingSpace) {
text += " ";
}
- inputText(text);
- if (m_selectReplacement) {
- // Select what was inserted.
- setEndingSelection(Selection(selection.base(), endingSelection().extent()));
- }
- else {
+ inputText(text, m_selectReplacement);
+ if (!m_selectReplacement) {
// Mark misspellings in the inserted content.
markMisspellingsInSelection(Selection(upstreamStart, endingSelection().extent()));
}
void deleteSelection();
void deleteSelection(const DOM::Selection &selection);
void deleteText(DOM::TextImpl *node, long offset, long count);
- void inputText(const DOM::DOMString &text);
+ void inputText(const DOM::DOMString &text, bool selectInsertedText = false);
void insertNodeAfter(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);
void insertNodeAt(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild, long offset);
void insertNodeBefore(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);