From 103480ab0bc5cdf436dbd41fc0d012a2d319466f Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 2 Sep 2010 20:36:42 -0400 Subject: [PATCH] Bug 592592 - Non-breaking spaces inserted when multiple spaces are typed, even in pre-wrap-styled text r,a=roc --- content/html/content/test/test_bug408231.html | 1 + editor/libeditor/base/nsEditor.cpp | 6 +- editor/libeditor/html/tests/Makefile.in | 1 + .../libeditor/html/tests/test_bug592592.html | 60 +++++++++++++++++++ 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 editor/libeditor/html/tests/test_bug592592.html diff --git a/content/html/content/test/test_bug408231.html b/content/html/content/test/test_bug408231.html index 89e47ab3afb..4d2d86f0119 100644 --- a/content/html/content/test/test_bug408231.html +++ b/content/html/content/test/test_bug408231.html @@ -182,6 +182,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231 function runTests() { document.designMode='on'; + window.getSelection().collapse(document.body, 0); testQueryCommand(commandEnabledResults, callQueryCommandEnabled, "queryCommandEnabled"); testQueryCommand(commandStateResults, callQueryCommandState, "queryCommandState"); testQueryCommand(commandValueResults, callQueryCommandValue, "queryCommandValue"); diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index 5adc2f26d48..fa6e76892fa 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -3857,8 +3857,12 @@ nsEditor::IsPreformatted(nsIDOMNode *aNode, PRBool *aResult) nsCOMPtr ps = do_QueryReferent(mPresShellWeak); NS_ENSURE_TRUE(ps, NS_ERROR_NOT_INITIALIZED); + // Look at the node (and its parent if it's not an element), and grab its style context nsRefPtr elementStyle; - if (content->IsElement()) { + if (!content->IsElement()) { + content = content->GetParent(); + } + if (content && content->IsElement()) { elementStyle = nsComputedDOMStyle::GetStyleContextForElement(content->AsElement(), nsnull, ps); diff --git a/editor/libeditor/html/tests/Makefile.in b/editor/libeditor/html/tests/Makefile.in index 92063744ac3..4ff4a5a1463 100644 --- a/editor/libeditor/html/tests/Makefile.in +++ b/editor/libeditor/html/tests/Makefile.in @@ -59,6 +59,7 @@ _TEST_FILES = \ test_bug525389.html \ test_bug537046.html \ test_bug550434.html \ + test_bug592592.html \ test_CF_HTML_clipboard.html \ test_contenteditable_focus.html \ test_contenteditable_text_input_handling.html \ diff --git a/editor/libeditor/html/tests/test_bug592592.html b/editor/libeditor/html/tests/test_bug592592.html new file mode 100644 index 00000000000..3dc86b1b872 --- /dev/null +++ b/editor/libeditor/html/tests/test_bug592592.html @@ -0,0 +1,60 @@ + + + + + Test for Bug 592592 + + + + + + +Mozilla Bug 592592 +

+
+
a b
+
+
+
+
+ +