Bug 454997 - <body contenteditable=true> exposed incorrectly, r=marcoz, aaronlev

This commit is contained in:
Alexander Surkov 2008-10-08 20:50:36 +08:00
Родитель 9e493c337a
Коммит 5b38a55cdc
6 изменённых файлов: 125 добавлений и 5 удалений

Просмотреть файл

@ -52,6 +52,8 @@
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentView.h"
#include "nsIDOMDocumentXBL.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMRange.h"
#include "nsIDOMXULContainerElement.h"
@ -387,13 +389,25 @@ already_AddRefed<nsIDOMElement>
nsAccUtils::GetDOMElementFor(nsIDOMNode *aNode)
{
nsCOMPtr<nsINode> node(do_QueryInterface(aNode));
nsIDOMElement *element = nsnull;
if (node->IsNodeOfType(nsINode::eELEMENT))
CallQueryInterface(node, &element);
else if (node->IsNodeOfType(nsINode::eTEXT))
CallQueryInterface(node->GetNodeParent(), &element);
else if (node->IsNodeOfType(nsINode::eDOCUMENT)) {
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(node));
if (htmlDoc) {
nsCOMPtr<nsIDOMHTMLElement> bodyElement;
htmlDoc->GetBody(getter_AddRefs(bodyElement));
if (bodyElement) {
CallQueryInterface(bodyElement, &element);
return element;
}
}
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(node));
domDoc->GetDocumentElement(&element);
}

Просмотреть файл

@ -153,7 +153,8 @@ public:
* Return DOM element related with the given node, i.e.
* a) itself if it is DOM element
* b) parent element if it is text node
* c) document element if it is document node.
* c) body element if it is HTML document node
* d) document element if it is document node.
*
* @param aNode [in] the given DOM node
*/

Просмотреть файл

@ -495,12 +495,21 @@ NS_IMETHODIMP nsDocAccessible::GetDocument(nsIDOMDocument **aDOMDoc)
NS_IMETHODIMP nsDocAccessible::GetAssociatedEditor(nsIEditor **aEditor)
{
NS_ENSURE_ARG_POINTER(aEditor);
*aEditor = nsnull;
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
if (!mDocument)
return NS_ERROR_FAILURE;
// Check if document is editable (designMode="on" case). Otherwise check if
// the html:body (for HTML document case) or document element is editable.
if (!mDocument->HasFlag(NODE_IS_EDITABLE)) {
return NS_OK; // Document not editable
nsCOMPtr<nsIDOMNode> DOMDocument(do_QueryInterface(mDocument));
nsCOMPtr<nsIDOMElement> DOMElement =
nsAccUtils::GetDOMElementFor(DOMDocument);
nsCOMPtr<nsIContent> content(do_QueryInterface(DOMElement));
if (!content->HasFlag(NODE_IS_EDITABLE))
return NS_OK;
}
nsCOMPtr<nsISupports> container = mDocument->GetContainer();

Просмотреть файл

@ -66,6 +66,8 @@ _TEST_FILES =\
$(warning test_table_indexes.html temporarily disabled) \
test_nsIAccessible_actions.html \
test_nsIAccessible_actions.xul \
test_nsIAccessible_editablebody.html \
test_nsIAccessible_editabledoc.html \
test_nsIAccessible_name.html \
test_nsIAccessible_name.xul \
test_nsIAccessible_selects.html \

Просмотреть файл

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=454997
-->
<head>
<title>nsIAccessible states tests of contenteditable body</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_states.js"></script>
<script type="application/javascript">
function doTest()
{
testStates(document, 0, EXT_STATE_EDITABLE);
testStates("p", 0, EXT_STATE_EDITABLE);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body contentEditable="true">
<a target="_blank"
title="nsIAccessible states tests of contenteditable body"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=454997">Mozilla Bug 454997</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<p id="p">hello</p>
</body>
</html>

Просмотреть файл

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=454997
-->
<head>
<title>nsIAccessible states tests of editable document</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/nsIAccessible_states.js"></script>
<script type="application/javascript">
function doTest()
{
document.designMode = "on";
testStates(document, 0, EXT_STATE_EDITABLE);
testStates("p", 0, EXT_STATE_EDITABLE);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body id="body">
<a target="_blank"
title="nsIAccessible states tests of editable document"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=454997">Mozilla Bug 454997</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<p id="p">hello</p>
</body>
</html>