Reviewed by Dave Harrison.
Fix for <rdar://problem/
5428427> Wrong characters are re-converted after doing reconversion with Kotoeri
Revert change for<rdar://problem/
5279521> and add nil checks for the result of TextIterator::rangeFromLocationAndLength
TextIterator::exitNode shouldn't require the m_lastTextNode to be true, but we can't change that without making the logic in _web_attributedStringFromRange match.
We'll get that for free when we switch to use TextIterator in _web_attributedStringFromRange.
* editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::applyBlockStyle): Added nil checks.
* editing/IndentOutdentCommand.cpp: (WebCore::IndentOutdentCommand::indentRegion): ditto.
* editing/TextIterator.cpp: (WebCore::TextIterator::exitNode): Re-added check for m_lastTextNode before emitting newline.
LayoutTests:
Reviewed by Dave Harrison.
Tests for <rdar://problem/
5428427> Wrong characters are re-converted after doing reconversion with Kotoeri
* platform/mac/fast/text/attributed-substring-from-range-002-expected.txt: Added.
* platform/mac/fast/text/attributed-substring-from-range-002.html: Added.
* fast/forms/textarea-type-spaces-expected.txt: Revert back to old result.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25429
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-09-07 Adele Peterson <adele@apple.com>
+
+ Reviewed by Dave Harrison.
+
+ Tests for <rdar://problem/5428427> Wrong characters are re-converted after doing reconversion with Kotoeri
+
+ * platform/mac/fast/text/attributed-substring-from-range-002-expected.txt: Added.
+ * platform/mac/fast/text/attributed-substring-from-range-002.html: Added.
+ * fast/forms/textarea-type-spaces-expected.txt: Revert back to old result.
+
2007-09-07 Sam Weinig <sam@webkit.org>
* platform/win/Skipped: fix typo
--- /dev/null
+123456789
+-
+This tests a particular construction that screws up the text iterator.
+-
+actual text: \n123456789
+from innerText (TextIterator): 123456789
+from attributedSubstringFromRange: 123456789
+SUCCESS: Strings matched, although there is room for improvement because they were both wrong.
--- /dev/null
+<html>
+<body contenteditable><div><object></object></div>123456789</body>
+<script>
+ var console_messages = document.createElement("ol");
+ function log(message)
+ {
+ var item = document.createElement("li");
+ item.appendChild(document.createTextNode(message));
+ console_messages.appendChild(item);
+ }
+ function createConsole()
+ {
+ var console = document.createElement("pre");
+ console.appendChild(console_messages);
+ document.body.appendChild(console);
+ }
+
+ log("-");
+ log("This tests a particular construction that screws up the text iterator.");
+ log("-");
+
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+
+ // Set selection, because attributedSubstringFromRange only works on the run of text that's
+ // currently selected.
+ window.getSelection().setPosition(document.body, 0);
+
+ var stringFromInnerText = document.body.innerText;
+ var stringFromAttributedSubstring = textInputController.attributedSubstringFromRange(0, 100).string();
+
+ log("actual text: \\n123456789");
+ log("from innerText (TextIterator): " + stringFromInnerText.replace("\n", "\\n"));
+ log("from attributedSubstringFromRange: " + stringFromAttributedSubstring.replace("\n", "\\n"));
+
+ if (stringFromInnerText != stringFromAttributedSubstring)
+ log("FAILED: Strings must match to keep input methods working.");
+ else if (stringFromInnerText == "\n123456789")
+ log("SUCCESS: Strings were correct.");
+ else
+ log("SUCCESS: Strings matched, although there is room for improvement because they were both wrong.");
+ } else {
+ log("DID NOT TEST: This test cannot run interactively.");
+ }
+ createConsole();
+
+</script>
+</body>
+</html>
+2007-09-07 Adele Peterson <adele@apple.com>
+
+ Reviewed by Dave Harrison.
+
+ Fix for <rdar://problem/5428427> Wrong characters are re-converted after doing reconversion with Kotoeri
+
+ Revert change for<rdar://problem/5279521> and add nil checks for the result of TextIterator::rangeFromLocationAndLength
+ TextIterator::exitNode shouldn't require the m_lastTextNode to be true, but we can't change that without making the logic in _web_attributedStringFromRange match.
+ We'll get that for free when we switch to use TextIterator in _web_attributedStringFromRange.
+
+ * editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::applyBlockStyle): Added nil checks.
+ * editing/IndentOutdentCommand.cpp: (WebCore::IndentOutdentCommand::indentRegion): ditto.
+ * editing/TextIterator.cpp: (WebCore::TextIterator::exitNode): Re-added check for m_lastTextNode before emitting newline.
+
2007-09-07 Ada Chan <adachan@apple.com>
<rdar://problem/5395928> Need to be able to handle context menu item selection by index
nextParagraphStart = endOfParagraph(paragraphStart).next();
}
- updateStartEnd(TextIterator::rangeFromLocationAndLength(static_cast<Element*>(scope), startIndex, 0, true)->startPosition(),
- TextIterator::rangeFromLocationAndLength(static_cast<Element*>(scope), endIndex, 0, true)->startPosition());
+ startRange = TextIterator::rangeFromLocationAndLength(static_cast<Element*>(scope), startIndex, 0, true);
+ endRange = TextIterator::rangeFromLocationAndLength(static_cast<Element*>(scope), endIndex, 0, true);
+ if (startRange && endRange)
+ updateStartEnd(startRange->startPosition(), endRange->startPosition());
}
#define NoFontDelta (0.0f)
RefPtr<Range> startRange = TextIterator::rangeFromLocationAndLength(document()->documentElement(), 0, startIndex);
RefPtr<Range> endRange = TextIterator::rangeFromLocationAndLength(document()->documentElement(), 0, endIndex);
- setEndingSelection(Selection(startRange->endPosition(), endRange->endPosition(), DOWNSTREAM));
+ if (startRange && endRange)
+ setEndingSelection(Selection(startRange->endPosition(), endRange->endPosition(), DOWNSTREAM));
}
void IndentOutdentCommand::outdentParagraph()
// case it is a block, because the run should start where the
// emitted character is positioned visually.
Node* baseNode = m_node->lastChild() ? m_node->lastChild() : m_node;
- if (shouldEmitNewlineAfterNode(m_node)) {
+ // FIXME: This shouldn't require the m_lastTextNode to be true, but we can't change that without making
+ // the logic in _web_attributedStringFromRange match. We'll get that for free when we switch to use TextIterator in _web_attributedStringFromRange.
+ // See <rdar://problem/5428427> for an example of how this mismatch will cause problems.
+ if (m_lastTextNode && shouldEmitNewlineAfterNode(m_node)) {
// use extra newline to represent margin bottom, as needed
bool addNewline = shouldEmitExtraNewlineForNode(m_node);