author | Ehsan Akhgari <ehsan@mozilla.com> |
Thu, 02 Sep 2010 20:36:42 -0400 | |
changeset 52121 | 1499c617241b3654d96d01f2ef07c71b68fca147 |
parent 52120 | c63f70603dd4252db3df308e41be247ea0f03662 |
child 52122 | 729be7ad43cf76b5dfa88cbd572dc91a3494c800 |
push id | 15551 |
push user | eakhgari@mozilla.com |
push date | Tue, 07 Sep 2010 22:09:01 +0000 |
treeherder | mozilla-central@7b4ebf471dd0 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | roc |
bugs | 592592 |
milestone | 2.0b6pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/content/html/content/test/test_bug408231.html +++ b/content/html/content/test/test_bug408231.html @@ -177,16 +177,17 @@ https://bugzilla.mozilla.org/show_bug.cg var expectedResult = expectedResults[i][1]; var result = fun(commandName); ok(result == expectedResult, funName + '('+commandName+') result=' +result+ ' expected=' + expectedResult); } } function runTests() { document.designMode='on'; + window.getSelection().collapse(document.body, 0); testQueryCommand(commandEnabledResults, callQueryCommandEnabled, "queryCommandEnabled"); testQueryCommand(commandStateResults, callQueryCommandState, "queryCommandState"); testQueryCommand(commandValueResults, callQueryCommandValue, "queryCommandValue"); document.designMode='off'; SimpleTest.finish(); } window.onload = runTests;
--- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -3852,18 +3852,22 @@ nsEditor::IsPreformatted(nsIDOMNode *aNo { nsCOMPtr<nsIContent> content = do_QueryInterface(aNode); NS_ENSURE_TRUE(aResult && content, NS_ERROR_NULL_POINTER); nsCOMPtr<nsIPresShell> 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<nsStyleContext> elementStyle; - if (content->IsElement()) { + if (!content->IsElement()) { + content = content->GetParent(); + } + if (content && content->IsElement()) { elementStyle = nsComputedDOMStyle::GetStyleContextForElement(content->AsElement(), nsnull, ps); } if (!elementStyle) { // Consider nodes without a style context to be NOT preformatted:
--- a/editor/libeditor/html/tests/Makefile.in +++ b/editor/libeditor/html/tests/Makefile.in @@ -54,16 +54,17 @@ include $(topsrcdir)/config/rules.mk test_bug478725.html \ test_bug480972.html \ test_bug484181.html \ test_bug487524.html \ test_bug520189.html \ 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 \ test_htmleditor_keyevent_handling.html \ test_select_all_without_body.html \ file_select_all_without_body.html \ test_root_element_replacement.html \ $(NULL)
new file mode 100644 --- /dev/null +++ b/editor/libeditor/html/tests/test_bug592592.html @@ -0,0 +1,60 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=592592 +--> +<head> + <title>Test for Bug 592592</title> + <script type="application/javascript" src="/MochiKit/packed.js"></script> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=592592">Mozilla Bug 592592</a> +<p id="display"></p> +<div id="content"> + <div id="editor" contenteditable="true" style="white-space:pre-wrap">a b</div> +</div> +<pre id="test"> +<script type="application/javascript"> + +/** Test for Bug 592592 **/ + +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(function() { + var ed = document.getElementById("editor"); + + // Put the selection right after "a" + ed.focus(); + window.getSelection().collapse(ed.firstChild, 1); + + // Press space + synthesizeKey(" ", {}); + + // Make sure we haven't added an nbsp + is(ed.innerHTML, "a b", "We should not be adding an for preformatted text"); + + // Remove the preformatted style + ed.removeAttribute("style"); + + // Reset the DOM + ed.innerHTML = "a b"; + + // Reset the selection + ed.focus(); + window.getSelection().collapse(ed.firstChild, 1); + + // Press space + synthesizeKey(" ", {}); + + // Make sure that we have added an nbsp + is(ed.innerHTML, "a b", "We should add an for non-preformatted text"); + + SimpleTest.finish(); +}); + +</script> +</pre> +</body> +</html>