Bug 638106 - CKEditor document should be editable, r=davidb, a=final+

This commit is contained in:
Alexander Surkov 2011-03-03 14:41:46 +08:00
parent ba863a631e
commit 34ae1fdc3e
8 changed files with 69 additions and 23 deletions

View File

@ -219,9 +219,8 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
#endif
mTreeConstructedState = eTreeConstructed;
mDocument->CacheChildrenInSubtree(mDocument);
mDocument->NotifyOfInitialUpdate();
NS_ASSERTION(mContentInsertions.Length() == 0,
"Pending content insertions while initial accessible tree isn't created!");
}

View File

@ -1503,6 +1503,15 @@ nsDocAccessible::CacheChildren()
void
nsDocAccessible::NotifyOfInitialUpdate()
{
// The content element may be changed before the initial update and then we
// miss the notification (since content tree change notifications are ignored
// prior to initial update). Make sure the content element is valid.
nsIContent* contentElm = nsCoreUtils::GetRoleContent(mDocument);
if (contentElm && mContent != contentElm)
mContent = contentElm;
// Build initial tree.
CacheChildrenInSubtree(this);
}
void

View File

@ -283,6 +283,8 @@ nsDocAccessibleWrap::GetNativeWindow() const
void
nsDocAccessibleWrap::NotifyOfInitialUpdate()
{
nsDocAccessible::NotifyOfInitialUpdate();
if (nsWinUtils::IsWindowEmulationEnabled()) {
// Create window for tab document.
if (nsWinUtils::IsTabDocument(mDocument)) {

View File

@ -59,13 +59,14 @@ const EXT_STATE_VERTICAL = nsIAccessibleStates.EXT_STATE_VERTICAL;
* @param aExtraState The extra state bits that are wanted.
* @param aAbsentState State bits that are not wanted.
* @param aAbsentExtraState Extra state bits that are not wanted.
* @param aTestName The test name.
*/
function testStates(aAccOrElmOrID, aState, aExtraState, aAbsentState,
aAbsentExtraState)
aAbsentExtraState, aTestName)
{
var [state, extraState] = getStates(aAccOrElmOrID);
var id = prettyName(aAccOrElmOrID);
var id = prettyName(aAccOrElmOrID) + (aTestName ? " [" + aTestName + "]": "");
// Primary test.
isState(state & aState, aState, false,

View File

@ -45,15 +45,13 @@ relativesrcdir = accessible/states
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
# temporarily disabled test (bug 562328)
# test_frames.html \
_TEST_FILES =\
test_aria.html \
test_aria_imgmap.html \
test_doc.html \
test_docarticle.html \
test_editablebody.html \
test_frames.html \
test_inputs.html \
test_inputs.xul \
test_link.html \
@ -63,6 +61,7 @@ _TEST_FILES =\
z_frames_article.html \
z_frames_checkbox.html \
z_frames_textbox.html \
z_frames_update.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -84,5 +84,6 @@
<div id="document" role="document">document</div>
<div id="editable_document" role="document" contentEditable="true">editable document</doc>
</body>
</html>

View File

@ -23,24 +23,31 @@
frameDocArticle = document.getElementById("frame_doc_article").contentDocument;
frameDocCheckbox = document.getElementById("frame_doc_checkbox").contentDocument;
frameDocTextbox = document.getElementById("frame_doc_textbox").contentDocument;
testStates(frameDoc, STATE_READONLY);
testStates(frameDocArticle, STATE_READONLY);
testStates(frameDocCheckbox, 0, 0, STATE_READONLY);
testStates(frameDocTextbox, 0, EXT_STATE_EDITABLE);
testStates(frameDoc, STATE_READONLY, 0, 0, 0, "test1: frameDoc");
testStates(frameDocArticle, STATE_READONLY, 0, 0, 0, "test1: frameDocArticle");
testStates(frameDocCheckbox, 0, 0, STATE_READONLY, 0, "test1: frameDocCheckbox");
testStates(frameDocTextbox, 0, EXT_STATE_EDITABLE, 0, 0, "test1: frameDocTextbox");
frameDoc.designMode = "on";
testStates(frameDoc, 0, EXT_STATE_EDITABLE);
testStates(frameDocArticle, STATE_READONLY);
testStates(frameDocCheckbox, 0, 0, STATE_READONLY);
testStates(frameDocTextbox, 0, EXT_STATE_EDITABLE);
testStates(frameDoc, 0, EXT_STATE_EDITABLE, 0, 0, "test2: frameDoc");
testStates(frameDocArticle, STATE_READONLY, 0, 0, 0, "test2: frameDocArticle");
testStates(frameDocCheckbox, 0, 0, STATE_READONLY, 0, "test2: frameDocCheckbox");
testStates(frameDocTextbox, 0, EXT_STATE_EDITABLE, 0, 0, "test2: frameDocTextbox");
frameDocArticle.designMode = "on";
testStates(frameDocArticle, 0, EXT_STATE_EDITABLE);
testStates(frameDocArticle, 0, EXT_STATE_EDITABLE, 0, 0, "test3: frameDocArticle");
frameDocCheckbox.designMode = "on";
testStates(frameDocCheckbox, 0, 0, STATE_READONLY);
testStates(frameDocCheckbox, 0, 0, STATE_READONLY, 0, "test4: frameDocCheckbox");
// Replace iframe document body before the document accessible tree is
// created. Check the states are updated for new body.
var frameUpdateDoc =
document.getElementById("frame_updatedoc").contentDocument;
testStates(frameUpdateDoc, 0, EXT_STATE_EDITABLE,
STATE_READONLY, EXT_STATE_STALE, "test5: frameUpdateDoc");
SimpleTest.finish();
}
@ -52,18 +59,24 @@
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=467387"
title="Expose non-editable documents as readonly, regardless of role">
Mozilla Bug 467387
href="https://bugzilla.mozilla.org/show_bug.cgi?id=467387"
title="Expose non-editable documents as readonly, regardless of role">
Mozilla Bug 467387
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=638106"
title="CKEditor document should be editable">
Mozilla Bug 638106
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<iframe id="frame_doc" src="z_frames.html"></iframe>
<iframe id="frame_doc_article" src="z_frames_article.html"></iframe>
<iframe id="frame_doc_checkbox" src="z_frames_checkbox.html"></iframe>
<iframe id="frame_doc_textbox" src="z_frames_textbox.html"></iframe>
<iframe id="frame_updatedoc" src="z_frames_update.html"></iframe>
</body>
</html>

View File

@ -0,0 +1,22 @@
<html>
<head>
<script>
function replaceBody()
{
var accRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
getService(Components.interfaces.nsIAccessibleRetrieval);
accRetrieval.getAccessibleFor(document);
var newBody = document.createElement("body");
newBody.setAttribute("contentEditable", "true");
newBody.textContent = "New Hello";
document.documentElement.replaceChild(newBody, document.body);
getComputedStyle(newBody, "").color;
}
</script>
</head>
<body onload="replaceBody();">
OLD hello
</body>
</html>