mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 440614 - text entry field unable to take focus; r=(bzbarsky + jst + peterv) sr=peterv
This commit is contained in:
parent
048708e0c1
commit
b51abf4b07
@ -3260,12 +3260,13 @@ void
|
||||
nsHTMLDocument::TearingDownEditor(nsIEditor *aEditor)
|
||||
{
|
||||
if (IsEditingOn()) {
|
||||
EditingState oldState = mEditingState;
|
||||
mEditingState = eTearingDown;
|
||||
|
||||
nsCOMPtr<nsIEditorStyleSheets> editorss = do_QueryInterface(aEditor);
|
||||
if (editorss) {
|
||||
editorss->RemoveOverrideStyleSheet(NS_LITERAL_STRING("resource://gre/res/contenteditable.css"));
|
||||
if (mEditingState == eDesignMode)
|
||||
if (oldState == eDesignMode)
|
||||
editorss->RemoveOverrideStyleSheet(NS_LITERAL_STRING("resource://gre/res/designmode.css"));
|
||||
}
|
||||
}
|
||||
@ -3297,6 +3298,15 @@ nsHTMLDocument::TurnEditingOff()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLDocument::ReinitEditor()
|
||||
{
|
||||
NS_ASSERTION(mEditingState != eOff, "Editor not inited.");
|
||||
|
||||
TurnEditingOff();
|
||||
return EditingStateChanged();
|
||||
}
|
||||
|
||||
static PRBool HasPresShell(nsPIDOMWindow *aWindow)
|
||||
{
|
||||
nsIDocShell *docShell = aWindow->GetDocShell();
|
||||
|
@ -231,6 +231,8 @@ public:
|
||||
mFragmentParser = aParser;
|
||||
}
|
||||
|
||||
virtual nsresult ReinitEditor();
|
||||
|
||||
virtual nsresult SetEditingState(EditingState aState);
|
||||
|
||||
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
||||
|
@ -171,6 +171,13 @@ public:
|
||||
* SetDesignMode().
|
||||
*/
|
||||
virtual nsresult SetEditingState(EditingState aState) = 0;
|
||||
|
||||
/**
|
||||
* Re-inits the editor. Editing must be on from contentEditable or designMode
|
||||
* when calling this.
|
||||
* Required because of the way the editor works. (bug 440614)
|
||||
*/
|
||||
virtual nsresult ReinitEditor() = 0;
|
||||
|
||||
/**
|
||||
* Returns the result of document.all[aID] which can either be a node
|
||||
|
@ -71,6 +71,7 @@ _TEST_FILES = test_bug1682.html \
|
||||
test_bug403868.html \
|
||||
test_bug403868.xhtml \
|
||||
test_bug404320.html \
|
||||
test_bug440614.html \
|
||||
test_form-parsing.html \
|
||||
test_viewport.html \
|
||||
test_documentAll.html \
|
||||
|
103
content/html/document/test/test_bug440614.html
Normal file
103
content/html/document/test/test_bug440614.html
Normal file
@ -0,0 +1,103 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=440614
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 440614</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=440614">Mozilla Bug 440614</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<iframe></iframe>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var styleSheets = null;
|
||||
|
||||
function checkStylesheets() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
// Evidently RemoveStyleSheet is the only method in nsIEditorStyleSheets
|
||||
// that would throw. RemoveOverrideStyleSheet returns NS_OK even if the
|
||||
// sheet is not there
|
||||
var removed = 0;
|
||||
try
|
||||
{
|
||||
styleSheets.removeStyleSheet("resource://gre/res/designmode.css");
|
||||
removed++;
|
||||
}
|
||||
catch (ex) { }
|
||||
|
||||
try {
|
||||
styleSheets.removeStyleSheet("resource://gre/res/contenteditable.css");
|
||||
removed++;
|
||||
}
|
||||
catch (ex) { }
|
||||
|
||||
is(removed, 0, "Should have thrown if stylesheet was not there");
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
|
||||
/** Not really bug 440614, just found while fixing 440614 **/
|
||||
var editframe = window.frames[0];
|
||||
var editdoc = editframe.document;
|
||||
var editor = null;
|
||||
editdoc.write('');
|
||||
editdoc.close();
|
||||
|
||||
editdoc.designMode='on';
|
||||
|
||||
// Hold the reference to the editor
|
||||
editor = editframe.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIEditingSession)
|
||||
.getEditorForWindow(editframe);
|
||||
|
||||
styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
|
||||
|
||||
editdoc.designMode='off';
|
||||
|
||||
checkStylesheets();
|
||||
|
||||
// Let go
|
||||
editor = null;
|
||||
styleSheets = null;
|
||||
|
||||
editdoc.body.contentEditable = true;
|
||||
|
||||
// Hold the reference to the editor
|
||||
editor = editframe.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIEditingSession)
|
||||
.getEditorForWindow(editframe);
|
||||
|
||||
styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets);
|
||||
|
||||
editdoc.body.contentEditable = false;
|
||||
|
||||
checkStylesheets();
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
//XXX I don't know if this is necessary, but we're dealing with iframes...
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(runTest);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -86,7 +86,7 @@
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIFrameFrame.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIDOMNSHTMLDocument.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIReflowCallback.h"
|
||||
@ -975,21 +975,15 @@ nsSubDocumentFrame::ShowDocShell()
|
||||
// Trigger editor re-initialization if midas is turned on in the
|
||||
// sub-document. This shouldn't be necessary, but given the way our
|
||||
// editor works, it is. See
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=284245
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=284245 && 440614
|
||||
docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIDOMNSHTMLDocument> doc =
|
||||
nsCOMPtr<nsIHTMLDocument> doc =
|
||||
do_QueryInterface(presShell->GetDocument());
|
||||
|
||||
if (doc) {
|
||||
nsAutoString designMode;
|
||||
doc->GetDesignMode(designMode);
|
||||
|
||||
if (designMode.EqualsLiteral("on")) {
|
||||
doc->SetDesignMode(NS_LITERAL_STRING("off"));
|
||||
doc->SetDesignMode(NS_LITERAL_STRING("on"));
|
||||
}
|
||||
}
|
||||
// Re-init the editor, if necessary
|
||||
if (doc && doc->IsEditingOn())
|
||||
doc->ReinitEditor();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user