Bug 21610. Add support to distinguish key binding overlay from normal overlay documents.
git-svn-id: svn://10.0.0.236/trunk@56060 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -127,6 +127,12 @@ public:
|
||||
* Load inline and attribute style sheets
|
||||
*/
|
||||
NS_IMETHOD PrepareStyleSheets(nsIURI* aURI) = 0;
|
||||
|
||||
/**
|
||||
* Indicate that this doc will be used only to load a key binding
|
||||
* document.
|
||||
*/
|
||||
NS_IMETHOD SetIsKeybindingDocument(PRBool aIsKeyBindingDoc) = 0;
|
||||
};
|
||||
|
||||
// factory functions
|
||||
|
||||
@@ -309,6 +309,7 @@ nsXULDocument::nsXULDocument(void)
|
||||
mNextSrcLoadWaiter(nsnull),
|
||||
mCharSetID("UTF-8"),
|
||||
mDisplaySelection(PR_FALSE),
|
||||
mIsKeyBindingDoc(PR_FALSE),
|
||||
mIsPopup(PR_FALSE),
|
||||
mResolutionPhase(nsForwardReference::eStart),
|
||||
mNextContentID(NS_CONTENT_ID_COUNTER_BASE),
|
||||
@@ -602,6 +603,13 @@ nsXULDocument::PrepareStyleSheets(nsIURI* anURL)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::SetIsKeybindingDocument(PRBool aIsKeyBindingDoc)
|
||||
{
|
||||
mIsKeyBindingDoc = aIsKeyBindingDoc;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::SetDocumentURL(nsIURI* anURL)
|
||||
{
|
||||
@@ -3175,18 +3183,20 @@ nsXULDocument::Init()
|
||||
getter_AddRefs(mNameSpaceManager));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Create our focus tracker and hook it up.
|
||||
rv = nsXULCommandDispatcher::Create(getter_AddRefs(mCommandDispatcher));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a focus tracker");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!mIsKeyBindingDoc) {
|
||||
// Create our focus tracker and hook it up.
|
||||
rv = nsXULCommandDispatcher::Create(getter_AddRefs(mCommandDispatcher));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a focus tracker");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMEventListener> CommandDispatcher =
|
||||
do_QueryInterface(mCommandDispatcher);
|
||||
nsCOMPtr<nsIDOMEventListener> CommandDispatcher =
|
||||
do_QueryInterface(mCommandDispatcher);
|
||||
|
||||
if (CommandDispatcher) {
|
||||
// Take the focus tracker and add it as an event listener for focus and blur events.
|
||||
AddEventListener("focus", CommandDispatcher, PR_TRUE);
|
||||
AddEventListener("blur", CommandDispatcher, PR_TRUE);
|
||||
if (CommandDispatcher) {
|
||||
// Take the focus tracker and add it as an event listener for focus and blur events.
|
||||
AddEventListener("focus", CommandDispatcher, PR_TRUE);
|
||||
AddEventListener("blur", CommandDispatcher, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the local store. Yeah, I know. I wish GetService() used a
|
||||
@@ -4934,7 +4944,8 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe
|
||||
|
||||
// We also need to pay special attention to the keyset tag to set up a listener
|
||||
if ((aPrototype->mNameSpaceID == kNameSpaceID_XUL) &&
|
||||
(aPrototype->mTag.get() == kKeysetAtom)) {
|
||||
(aPrototype->mTag.get() == kKeysetAtom) &&
|
||||
! mIsKeyBindingDoc) {
|
||||
// Create our nsXULKeyListener and hook it up.
|
||||
nsCOMPtr<nsIXULKeyListener> keyListener;
|
||||
rv = nsComponentManager::CreateInstance(kXULKeyListenerCID,
|
||||
|
||||
@@ -289,6 +289,7 @@ public:
|
||||
NS_IMETHOD SetCurrentPrototype(nsIXULPrototypeDocument* aDocument);
|
||||
NS_IMETHOD SetDocumentURL(nsIURI* anURL);
|
||||
NS_IMETHOD PrepareStyleSheets(nsIURI* anURL);
|
||||
NS_IMETHOD SetIsKeybindingDocument(PRBool aIsKeyBindingDoc);
|
||||
|
||||
// nsIStreamLoadableDocument interface
|
||||
NS_IMETHOD LoadFromStream(nsIInputStream& xulStream,
|
||||
@@ -507,6 +508,7 @@ protected:
|
||||
nsVoidArray mStyleSheets;
|
||||
nsCOMPtr<nsIDOMSelection> mSelection; // [OWNER]
|
||||
PRBool mDisplaySelection;
|
||||
PRBool mIsKeyBindingDoc;
|
||||
nsVoidArray mPresShells;
|
||||
nsCOMPtr<nsIEventListenerManager> mListenerManager; // [OWNER]
|
||||
nsCOMPtr<nsINameSpaceManager> mNameSpaceManager; // [OWNER]
|
||||
|
||||
@@ -127,6 +127,12 @@ public:
|
||||
* Load inline and attribute style sheets
|
||||
*/
|
||||
NS_IMETHOD PrepareStyleSheets(nsIURI* aURI) = 0;
|
||||
|
||||
/**
|
||||
* Indicate that this doc will be used only to load a key binding
|
||||
* document.
|
||||
*/
|
||||
NS_IMETHOD SetIsKeybindingDocument(PRBool aIsKeyBindingDoc) = 0;
|
||||
};
|
||||
|
||||
// factory functions
|
||||
|
||||
@@ -309,6 +309,7 @@ nsXULDocument::nsXULDocument(void)
|
||||
mNextSrcLoadWaiter(nsnull),
|
||||
mCharSetID("UTF-8"),
|
||||
mDisplaySelection(PR_FALSE),
|
||||
mIsKeyBindingDoc(PR_FALSE),
|
||||
mIsPopup(PR_FALSE),
|
||||
mResolutionPhase(nsForwardReference::eStart),
|
||||
mNextContentID(NS_CONTENT_ID_COUNTER_BASE),
|
||||
@@ -602,6 +603,13 @@ nsXULDocument::PrepareStyleSheets(nsIURI* anURL)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::SetIsKeybindingDocument(PRBool aIsKeyBindingDoc)
|
||||
{
|
||||
mIsKeyBindingDoc = aIsKeyBindingDoc;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::SetDocumentURL(nsIURI* anURL)
|
||||
{
|
||||
@@ -3175,18 +3183,20 @@ nsXULDocument::Init()
|
||||
getter_AddRefs(mNameSpaceManager));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Create our focus tracker and hook it up.
|
||||
rv = nsXULCommandDispatcher::Create(getter_AddRefs(mCommandDispatcher));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a focus tracker");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!mIsKeyBindingDoc) {
|
||||
// Create our focus tracker and hook it up.
|
||||
rv = nsXULCommandDispatcher::Create(getter_AddRefs(mCommandDispatcher));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a focus tracker");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMEventListener> CommandDispatcher =
|
||||
do_QueryInterface(mCommandDispatcher);
|
||||
nsCOMPtr<nsIDOMEventListener> CommandDispatcher =
|
||||
do_QueryInterface(mCommandDispatcher);
|
||||
|
||||
if (CommandDispatcher) {
|
||||
// Take the focus tracker and add it as an event listener for focus and blur events.
|
||||
AddEventListener("focus", CommandDispatcher, PR_TRUE);
|
||||
AddEventListener("blur", CommandDispatcher, PR_TRUE);
|
||||
if (CommandDispatcher) {
|
||||
// Take the focus tracker and add it as an event listener for focus and blur events.
|
||||
AddEventListener("focus", CommandDispatcher, PR_TRUE);
|
||||
AddEventListener("blur", CommandDispatcher, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the local store. Yeah, I know. I wish GetService() used a
|
||||
@@ -4934,7 +4944,8 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe
|
||||
|
||||
// We also need to pay special attention to the keyset tag to set up a listener
|
||||
if ((aPrototype->mNameSpaceID == kNameSpaceID_XUL) &&
|
||||
(aPrototype->mTag.get() == kKeysetAtom)) {
|
||||
(aPrototype->mTag.get() == kKeysetAtom) &&
|
||||
! mIsKeyBindingDoc) {
|
||||
// Create our nsXULKeyListener and hook it up.
|
||||
nsCOMPtr<nsIXULKeyListener> keyListener;
|
||||
rv = nsComponentManager::CreateInstance(kXULKeyListenerCID,
|
||||
|
||||
@@ -289,6 +289,7 @@ public:
|
||||
NS_IMETHOD SetCurrentPrototype(nsIXULPrototypeDocument* aDocument);
|
||||
NS_IMETHOD SetDocumentURL(nsIURI* anURL);
|
||||
NS_IMETHOD PrepareStyleSheets(nsIURI* anURL);
|
||||
NS_IMETHOD SetIsKeybindingDocument(PRBool aIsKeyBindingDoc);
|
||||
|
||||
// nsIStreamLoadableDocument interface
|
||||
NS_IMETHOD LoadFromStream(nsIInputStream& xulStream,
|
||||
@@ -507,6 +508,7 @@ protected:
|
||||
nsVoidArray mStyleSheets;
|
||||
nsCOMPtr<nsIDOMSelection> mSelection; // [OWNER]
|
||||
PRBool mDisplaySelection;
|
||||
PRBool mIsKeyBindingDoc;
|
||||
nsVoidArray mPresShells;
|
||||
nsCOMPtr<nsIEventListenerManager> mListenerManager; // [OWNER]
|
||||
nsCOMPtr<nsINameSpaceManager> mNameSpaceManager; // [OWNER]
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WA
|
||||
RRANTY OF ANY KIND, either express or
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
@@ -1085,7 +1084,7 @@ NS_IMETHODIMP nsXULKeyListenerImpl::GetKeyBindingDocument(nsCAutoString& aURLStr
|
||||
|
||||
// We've got a file. Check our key binding file cache.
|
||||
nsIURIKey key(uri);
|
||||
document = NS_STATIC_CAST(nsIDOMXULDocument*, mKeyBindingTable->Get(&key));
|
||||
document = dont_AddRef(NS_STATIC_CAST(nsIDOMXULDocument*, mKeyBindingTable->Get(&key)));
|
||||
|
||||
if (!document) {
|
||||
LoadKeyBindingDocument(uri, getter_AddRefs(document));
|
||||
@@ -1112,6 +1111,13 @@ NS_IMETHODIMP nsXULKeyListenerImpl::LoadKeyBindingDocument(nsIURI* aURI, nsIDOMX
|
||||
nsIDOMXULDocument::GetIID(),
|
||||
getter_AddRefs(doc));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIXULDocument> xulDoc = do_QueryInterface(doc, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
xulDoc->SetIsKeybindingDocument(PR_TRUE);
|
||||
|
||||
// Now we have to synchronously load the key binding file.
|
||||
// Create a XUL content sink, a parser, and kick off a load for
|
||||
// the overlay.
|
||||
@@ -1132,7 +1138,6 @@ NS_IMETHODIMP nsXULKeyListenerImpl::LoadKeyBindingDocument(nsIURI* aURI, nsIDOMX
|
||||
proto->SetDocumentPrincipal(principal);
|
||||
|
||||
// Set master and current prototype
|
||||
nsCOMPtr<nsIXULDocument> xulDoc = do_QueryInterface(doc);
|
||||
xulDoc->SetMasterPrototype(proto);
|
||||
xulDoc->SetCurrentPrototype(proto);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user