mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-19 09:30:44 +00:00
Fix assorted issues with fastback, including adding progress listener notifications and introducing the PageHide and PageShow events. See bug 292971 for all of the details. r=darin, sr=bzbarsky, a=shaver.
This commit is contained in:
parent
f00b4902e7
commit
e4a343f08f
@ -278,12 +278,11 @@ nsresult nsRootAccessible::AddEventListeners()
|
||||
|
||||
GetChromeEventHandler(getter_AddRefs(target));
|
||||
NS_ASSERTION(target, "No chrome event handler for document");
|
||||
if (target) {
|
||||
// onunload doesn't fire unless we use chrome event handler for target
|
||||
target->AddEventListener(NS_LITERAL_STRING("unload"),
|
||||
if (target) {
|
||||
target->AddEventListener(NS_LITERAL_STRING("PageHide"),
|
||||
NS_STATIC_CAST(nsIDOMXULListener*, this),
|
||||
PR_TRUE);
|
||||
target->AddEventListener(NS_LITERAL_STRING("load"),
|
||||
target->AddEventListener(NS_LITERAL_STRING("PageShow"),
|
||||
NS_STATIC_CAST(nsIDOMXULListener*, this),
|
||||
PR_TRUE);
|
||||
}
|
||||
@ -323,10 +322,10 @@ nsresult nsRootAccessible::RemoveEventListeners()
|
||||
|
||||
GetChromeEventHandler(getter_AddRefs(target));
|
||||
if (target) {
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("unload"),
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("PageHide"),
|
||||
NS_STATIC_CAST(nsIDOMXULListener*, this),
|
||||
PR_TRUE);
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("load"),
|
||||
target->RemoveEventListener(NS_LITERAL_STRING("PageShow"),
|
||||
NS_STATIC_CAST(nsIDOMXULListener*, this),
|
||||
PR_TRUE);
|
||||
}
|
||||
@ -482,8 +481,8 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (eventType.LowerCaseEqualsLiteral("unload")) {
|
||||
// Only get cached accessible for unload -- so that we don't create it
|
||||
if (eventType.LowerCaseEqualsLiteral("PageHide")) {
|
||||
// Only get cached accessible for pagehide -- so that we don't create it
|
||||
// just to destroy it.
|
||||
nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(eventShell));
|
||||
nsCOMPtr<nsIAccessibleDocument> accessibleDoc =
|
||||
@ -668,7 +667,7 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
|
||||
}
|
||||
#else
|
||||
AtkStateChange stateData;
|
||||
if (eventType.EqualsIgnoreCase("load")) {
|
||||
if (eventType.EqualsIgnoreCase("PageShow")) {
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(targetNode));
|
||||
if (htmlDoc) {
|
||||
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_REORDER,
|
||||
|
@ -112,7 +112,7 @@ var gAutoHideTabbarPrefListener = null;
|
||||
* one listener that calls all real handlers.
|
||||
*/
|
||||
|
||||
function loadEventHandlers(event)
|
||||
function pageShowEventHandlers(event)
|
||||
{
|
||||
// Filter out events that are not about the document load we are interested in
|
||||
if (event.originalTarget == content.document) {
|
||||
@ -727,7 +727,7 @@ function delayedStartup()
|
||||
// loads the services
|
||||
initServices();
|
||||
initBMService();
|
||||
gBrowser.addEventListener("load", function(evt) { setTimeout(loadEventHandlers, 0, evt); }, true);
|
||||
gBrowser.addEventListener("PageShow", function(evt) { setTimeout(pageShowEventHandlers, 0, evt); }, true);
|
||||
|
||||
window.addEventListener("keypress", ctrlNumberTabSelection, false);
|
||||
|
||||
|
@ -90,8 +90,8 @@ class nsILayoutHistoryState;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x97e4f20e, 0x73de, 0x41fd, \
|
||||
{ 0x85, 0x20, 0x41, 0x45, 0xc8, 0x74, 0xf5, 0x85 } }
|
||||
{ 0x9339ff1e, 0xdab0, 0x4264, \
|
||||
{ 0x8a, 0x8c, 0xcb, 0x84, 0xeb, 0x4e, 0x6b, 0x92 } }
|
||||
|
||||
// The base value for the content ID counter.
|
||||
// This counter is used by the document to
|
||||
@ -731,6 +731,26 @@ public:
|
||||
virtual void BlockOnload() = 0;
|
||||
virtual void UnblockOnload() = 0;
|
||||
|
||||
/**
|
||||
* Notification that the page has been shown, for documents which are loaded
|
||||
* into a DOM window. This corresponds to the completion of document load,
|
||||
* or to the page's presentation being restored into an existing DOM window.
|
||||
* This notification fires applicable DOM events to the content window. See
|
||||
* nsIDOMPageTransitionEvent.idl for a description of the |aPersisted|
|
||||
* parameter.
|
||||
*/
|
||||
virtual void OnPageShow(PRBool aPersisted) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the page has been hidden, for documents which are loaded
|
||||
* into a DOM window. This corresponds to the unloading of the document, or
|
||||
* to the document's presentation being saved but removed from an existing
|
||||
* DOM window. This notification fires applicable DOM events to the content
|
||||
* window. See nsIDOMPageTransitionEvent.idl for a description of the
|
||||
* |aPersisted| parameter.
|
||||
*/
|
||||
virtual void OnPageHide(PRBool aPersisted) = 0;
|
||||
|
||||
protected:
|
||||
~nsIDocument()
|
||||
{
|
||||
|
@ -128,6 +128,7 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
|
||||
#include "nsBindingManager.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsILink.h"
|
||||
|
||||
#include "nsICharsetAlias.h"
|
||||
static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
|
||||
@ -4909,3 +4910,73 @@ nsDocument::UnblockOnload()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::OnPageShow(PRBool aPersisted)
|
||||
{
|
||||
if (aPersisted) {
|
||||
// Send out notifications that our <link> elements are attached.
|
||||
nsRefPtr<nsContentList> links = NS_GetContentList(this,
|
||||
nsHTMLAtoms::link,
|
||||
kNameSpaceID_Unknown,
|
||||
mRootContent);
|
||||
|
||||
if (links) {
|
||||
PRUint32 linkCount = links->Length(PR_TRUE);
|
||||
for (PRUint32 i = 0; i < linkCount; ++i) {
|
||||
nsCOMPtr<nsILink> link = do_QueryInterface(links->Item(i, PR_FALSE));
|
||||
if (link) {
|
||||
link->LinkAdded();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsIPresShell *shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[0]);
|
||||
if (shell && mScriptGlobalObject) {
|
||||
nsPresContext *pc = shell->GetPresContext();
|
||||
if (pc) {
|
||||
nsPageTransitionEvent event(PR_TRUE, NS_PAGE_SHOW, aPersisted);
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
||||
mScriptGlobalObject->HandleDOMEvent(pc, &event, nsnull,
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::OnPageHide(PRBool aPersisted)
|
||||
{
|
||||
// Send out notifications that our <link> elements are detached,
|
||||
// but only if this is not a full unload.
|
||||
if (aPersisted) {
|
||||
nsRefPtr<nsContentList> links = NS_GetContentList(this,
|
||||
nsHTMLAtoms::link,
|
||||
kNameSpaceID_Unknown,
|
||||
mRootContent);
|
||||
|
||||
if (links) {
|
||||
PRUint32 linkCount = links->Length(PR_TRUE);
|
||||
for (PRUint32 i = 0; i < linkCount; ++i) {
|
||||
nsCOMPtr<nsILink> link = do_QueryInterface(links->Item(i, PR_FALSE));
|
||||
if (link) {
|
||||
link->LinkRemoved();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now send out a PageHide event.
|
||||
nsIPresShell *shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[0]);
|
||||
if (shell && mScriptGlobalObject) {
|
||||
nsPresContext *pc = shell->GetPresContext();
|
||||
if (pc) {
|
||||
nsPageTransitionEvent event(PR_TRUE, NS_PAGE_HIDE, aPersisted);
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
||||
mScriptGlobalObject->HandleDOMEvent(pc, &event, nsnull,
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -440,6 +440,9 @@ public:
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
|
||||
virtual void OnPageShow(PRBool aPersisted);
|
||||
virtual void OnPageHide(PRBool aPersisted);
|
||||
|
||||
// nsIRadioGroupContainer
|
||||
NS_IMETHOD WalkRadioGroup(const nsAString& aName,
|
||||
nsIRadioVisitor* aVisitor);
|
||||
|
@ -120,7 +120,6 @@ public:
|
||||
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
|
||||
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
|
||||
@ -162,7 +161,6 @@ public:
|
||||
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
|
||||
|
||||
protected:
|
||||
nsWeakPtr mParent;
|
||||
@ -251,18 +249,6 @@ txLoadListenerProxy::Error(nsIDOMEvent* aEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
txLoadListenerProxy::PageRestore(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMLoadListener> listener = do_QueryReferent(mParent);
|
||||
|
||||
if (listener) {
|
||||
return listener->PageRestore(aEvent);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class nsForceXMLListener : public nsIStreamListener
|
||||
{
|
||||
public:
|
||||
@ -526,12 +512,6 @@ nsSyncLoader::Error(nsIDOMEvent* aEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSyncLoader::PageRestore(nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSyncLoader::OnChannelRedirect(nsIChannel *aOldChannel,
|
||||
nsIChannel *aNewChannel,
|
||||
|
@ -85,5 +85,7 @@ nsresult
|
||||
NS_NewDOMTextEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsTextEvent* aEvent);
|
||||
nsresult
|
||||
NS_NewDOMBeforeUnloadEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsBeforePageUnloadEvent* aEvent);
|
||||
nsresult
|
||||
NS_NewDOMPageTransitionEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsPageTransitionEvent* aEvent);
|
||||
|
||||
#endif // nsIPrivateDOMEvent_h__
|
||||
|
@ -75,6 +75,7 @@ CPPSRCS = \
|
||||
nsDOMMutationEvent.cpp \
|
||||
nsDOMPopupBlockedEvent.cpp \
|
||||
nsDOMBeforeUnloadEvent.cpp \
|
||||
nsDOMPageTransitionEvent.cpp \
|
||||
nsPrivateTextRange.cpp \
|
||||
nsDOMEventGroup.cpp \
|
||||
nsXMLEventsManager.cpp \
|
||||
|
@ -58,15 +58,16 @@ static const char* const sEventNames[] = {
|
||||
"mousedown", "mouseup", "click", "dblclick", "mouseover",
|
||||
"mouseout", "mousemove", "contextmenu", "keydown", "keyup", "keypress",
|
||||
"focus", "blur", "load", "beforeunload", "unload", "abort", "error",
|
||||
"DOMPageRestore", "submit", "reset", "change", "select", "input", "paint",
|
||||
"text", "compositionstart", "compositionend", "popupshowing", "popupshown",
|
||||
"submit", "reset", "change", "select", "input", "paint" ,"text",
|
||||
"compositionstart", "compositionend", "popupshowing", "popupshown",
|
||||
"popuphiding", "popuphidden", "close", "command", "broadcast", "commandupdate",
|
||||
"dragenter", "dragover", "dragexit", "dragdrop", "draggesture", "resize",
|
||||
"scroll","overflow", "underflow", "overflowchanged",
|
||||
"DOMSubtreeModified", "DOMNodeInserted", "DOMNodeRemoved",
|
||||
"DOMNodeRemovedFromDocument", "DOMNodeInsertedIntoDocument",
|
||||
"DOMAttrModified", "DOMCharacterDataModified",
|
||||
"popupBlocked", "DOMActivate", "DOMFocusIn", "DOMFocusOut"
|
||||
"popupBlocked", "DOMActivate", "DOMFocusIn", "DOMFocusOut",
|
||||
"PageShow", "PageHide"
|
||||
};
|
||||
|
||||
static char *sPopupAllowedEvents;
|
||||
@ -434,8 +435,6 @@ nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
|
||||
mEvent->message = NS_IMAGE_ABORT;
|
||||
else if (atom == nsLayoutAtoms::onerror)
|
||||
mEvent->message = NS_IMAGE_ERROR;
|
||||
else if (atom == nsLayoutAtoms::onDOMPageRestore)
|
||||
mEvent->message = NS_PAGE_RESTORE;
|
||||
} else if (mEvent->eventStructType == NS_MUTATION_EVENT) {
|
||||
if (atom == nsLayoutAtoms::onDOMAttrModified)
|
||||
mEvent->message = NS_MUTATION_ATTRMODIFIED;
|
||||
@ -458,6 +457,11 @@ nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
|
||||
mEvent->message = NS_UI_FOCUSIN;
|
||||
else if (atom == nsLayoutAtoms::onDOMFocusOut)
|
||||
mEvent->message = NS_UI_FOCUSOUT;
|
||||
} else if (mEvent->eventStructType == NS_PAGETRANSITION_EVENT) {
|
||||
if (atom == nsLayoutAtoms::onPageShow)
|
||||
mEvent->message = NS_PAGE_SHOW;
|
||||
else if (atom == nsLayoutAtoms::onPageHide)
|
||||
mEvent->message = NS_PAGE_HIDE;
|
||||
}
|
||||
|
||||
if (mEvent->message == NS_USER_DEFINED_EVENT)
|
||||
@ -796,8 +800,6 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
||||
case NS_IMAGE_ERROR:
|
||||
case NS_SCRIPT_ERROR:
|
||||
return sEventNames[eDOMEvents_error];
|
||||
case NS_PAGE_RESTORE:
|
||||
return sEventNames[eDOMEvents_DOMPageRestore];
|
||||
case NS_FORM_SUBMIT:
|
||||
return sEventNames[eDOMEvents_submit];
|
||||
case NS_FORM_RESET:
|
||||
@ -869,6 +871,10 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
||||
return sEventNames[eDOMEvents_DOMFocusIn];
|
||||
case NS_UI_FOCUSOUT:
|
||||
return sEventNames[eDOMEvents_DOMFocusOut];
|
||||
case NS_PAGE_SHOW:
|
||||
return sEventNames[eDOMEvents_PageShow];
|
||||
case NS_PAGE_HIDE:
|
||||
return sEventNames[eDOMEvents_PageHide];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -85,7 +85,6 @@ public:
|
||||
eDOMEvents_unload,
|
||||
eDOMEvents_abort,
|
||||
eDOMEvents_error,
|
||||
eDOMEvents_DOMPageRestore,
|
||||
eDOMEvents_submit,
|
||||
eDOMEvents_reset,
|
||||
eDOMEvents_change,
|
||||
@ -123,7 +122,9 @@ public:
|
||||
eDOMEvents_popupBlocked,
|
||||
eDOMEvents_DOMActivate,
|
||||
eDOMEvents_DOMFocusIn,
|
||||
eDOMEvents_DOMFocusOut
|
||||
eDOMEvents_DOMFocusOut,
|
||||
eDOMEvents_PageShow,
|
||||
eDOMEvents_PageHide
|
||||
};
|
||||
|
||||
nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent);
|
||||
|
96
content/events/src/nsDOMPageTransitionEvent.cpp
Executable file
96
content/events/src/nsDOMPageTransitionEvent.cpp
Executable file
@ -0,0 +1,96 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS 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.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDOMPageTransitionEvent.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
nsDOMPageTransitionEvent::nsDOMPageTransitionEvent(nsPresContext* aPresContext,
|
||||
nsPageTransitionEvent* aEvent)
|
||||
: nsDOMEvent(aPresContext, aEvent ? aEvent :
|
||||
new nsPageTransitionEvent(PR_FALSE, 0, PR_FALSE))
|
||||
{
|
||||
if ( aEvent ) {
|
||||
mEventIsInternal = PR_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mEventIsInternal = PR_TRUE;
|
||||
mEvent->time = PR_Now();
|
||||
}
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMPageTransitionEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMPageTransitionEvent)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(PageTransitionEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDOMPageTransitionEvent, nsDOMEvent)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDOMPageTransitionEvent, nsDOMEvent)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMPageTransitionEvent::GetPersisted(PRBool* aPersisted)
|
||||
{
|
||||
*aPersisted = NS_STATIC_CAST(nsPageTransitionEvent*, mEvent)->persisted;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMPageTransitionEvent::InitPageTransitionEvent(const nsAString &aTypeArg,
|
||||
PRBool aCanBubbleArg,
|
||||
PRBool aCancelableArg,
|
||||
PRBool aPersisted)
|
||||
{
|
||||
nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_STATIC_CAST(nsPageTransitionEvent*, mEvent)->persisted = aPersisted;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_NewDOMPageTransitionEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
nsPresContext* aPresContext,
|
||||
nsPageTransitionEvent *aEvent)
|
||||
{
|
||||
nsDOMPageTransitionEvent* it =
|
||||
new nsDOMPageTransitionEvent(aPresContext, aEvent);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return CallQueryInterface(it, aInstancePtrResult);
|
||||
}
|
60
content/events/src/nsDOMPageTransitionEvent.h
Executable file
60
content/events/src/nsDOMPageTransitionEvent.h
Executable file
@ -0,0 +1,60 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS 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.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsDOMPageTransitionEvent_h__
|
||||
#define nsDOMPageTransitionEvent_h__
|
||||
|
||||
#include "nsIDOMPageTransitionEvent.h"
|
||||
#include "nsDOMEvent.h"
|
||||
|
||||
class nsDOMPageTransitionEvent : public nsIDOMPageTransitionEvent,
|
||||
public nsDOMEvent
|
||||
{
|
||||
public:
|
||||
nsDOMPageTransitionEvent(nsPresContext* aPresContext,
|
||||
nsPageTransitionEvent* aEvent);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_DECL_NSIDOMPAGETRANSITIONEVENT
|
||||
|
||||
// Forward to base class
|
||||
NS_FORWARD_TO_NSDOMEVENT
|
||||
};
|
||||
|
||||
#endif // nsDOMPageTransitionEvent_h__
|
@ -56,6 +56,7 @@
|
||||
#include "nsIDOMScrollListener.h"
|
||||
#include "nsIDOMMutationListener.h"
|
||||
#include "nsIDOMUIListener.h"
|
||||
#include "nsIDOMPageTransitionListener.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
@ -242,7 +243,6 @@ static const EventDispatchData sLoadEvents[] = {
|
||||
{NS_IMAGE_ERROR, HANDLER(&nsIDOMLoadListener::Error), NS_EVENT_BITS_LOAD_ERROR},
|
||||
{NS_SCRIPT_ERROR,HANDLER(&nsIDOMLoadListener::Error), NS_EVENT_BITS_LOAD_ERROR},
|
||||
{NS_BEFORE_PAGE_UNLOAD,HANDLER(&nsIDOMLoadListener::BeforeUnload), NS_EVENT_BITS_LOAD_BEFORE_UNLOAD},
|
||||
{NS_PAGE_RESTORE,HANDLER(&nsIDOMLoadListener::PageRestore), NS_EVENT_BITS_LOAD_PAGE_RESTORE}
|
||||
};
|
||||
|
||||
static const EventDispatchData sPaintEvents[] = {
|
||||
@ -320,6 +320,13 @@ static const EventDispatchData sUIEvents[] = {
|
||||
NS_EVENT_BITS_UI_FOCUSOUT }
|
||||
};
|
||||
|
||||
static const EventDispatchData sPageTransitionEvents[] = {
|
||||
{ NS_PAGE_SHOW, HANDLER(&nsIDOMPageTransitionListener::PageShow),
|
||||
NS_EVENT_BITS_PAGETRANSITION_SHOW },
|
||||
{ NS_PAGE_HIDE, HANDLER(&nsIDOMPageTransitionListener::PageHide),
|
||||
NS_EVENT_BITS_PAGETRANSITION_HIDE }
|
||||
};
|
||||
|
||||
#define IMPL_EVENTTYPEDATA(type) \
|
||||
{ \
|
||||
s##type##Events, \
|
||||
@ -344,7 +351,8 @@ static const EventTypeData sEventTypes[] = {
|
||||
IMPL_EVENTTYPEDATA(XUL),
|
||||
IMPL_EVENTTYPEDATA(Scroll),
|
||||
IMPL_EVENTTYPEDATA(Mutation),
|
||||
IMPL_EVENTTYPEDATA(UI)
|
||||
IMPL_EVENTTYPEDATA(UI),
|
||||
IMPL_EVENTTYPEDATA(PageTransition)
|
||||
};
|
||||
|
||||
// Strong references to event groups
|
||||
@ -892,10 +900,6 @@ nsEventListenerManager::GetIdentifiersForType(nsIAtom* aType,
|
||||
*aArrayType = eEventArrayType_Load;
|
||||
*aFlags = NS_EVENT_BITS_LOAD_ERROR;
|
||||
}
|
||||
else if (aType == nsLayoutAtoms::onDOMPageRestore) {
|
||||
*aArrayType = eEventArrayType_Load;
|
||||
*aFlags = NS_EVENT_BITS_LOAD_PAGE_RESTORE;
|
||||
}
|
||||
else if (aType == nsLayoutAtoms::onpaint) {
|
||||
*aArrayType = eEventArrayType_Paint;
|
||||
*aFlags = NS_EVENT_BITS_PAINT_PAINT;
|
||||
@ -1020,6 +1024,14 @@ nsEventListenerManager::GetIdentifiersForType(nsIAtom* aType,
|
||||
*aArrayType = eEventArrayType_Composition;
|
||||
*aFlags = NS_EVENT_BITS_COMPOSITION_END;
|
||||
}
|
||||
else if (aType == nsLayoutAtoms::onPageShow) {
|
||||
*aArrayType = eEventArrayType_PageTransition;
|
||||
*aFlags = NS_EVENT_BITS_PAGETRANSITION_SHOW;
|
||||
}
|
||||
else if (aType == nsLayoutAtoms::onPageHide) {
|
||||
*aArrayType = eEventArrayType_PageTransition;
|
||||
*aFlags = NS_EVENT_BITS_PAGETRANSITION_HIDE;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1723,6 +1735,10 @@ nsEventListenerManager::CreateEvent(nsPresContext* aPresContext,
|
||||
NS_NewDOMBeforeUnloadEvent(aDOMEvent, aPresContext,
|
||||
NS_STATIC_CAST(nsBeforePageUnloadEvent*,
|
||||
aEvent));
|
||||
case NS_PAGETRANSITION_EVENT:
|
||||
return NS_NewDOMPageTransitionEvent(aDOMEvent, aPresContext,
|
||||
NS_STATIC_CAST(nsPageTransitionEvent*,
|
||||
aEvent));
|
||||
}
|
||||
|
||||
// For all other types of events, create a vanilla event object.
|
||||
|
@ -84,6 +84,7 @@ enum EventArrayType {
|
||||
eEventArrayType_Scroll = 12,
|
||||
eEventArrayType_Mutation = 13,
|
||||
eEventArrayType_DOMUI = 14,
|
||||
eEventArrayType_PageTransition = 15,
|
||||
eEventArrayType_Hash,
|
||||
eEventArrayType_None
|
||||
};
|
||||
@ -303,7 +304,6 @@ protected:
|
||||
#define NS_EVENT_BITS_LOAD_ABORT 0x04
|
||||
#define NS_EVENT_BITS_LOAD_ERROR 0x08
|
||||
#define NS_EVENT_BITS_LOAD_BEFORE_UNLOAD 0x10
|
||||
#define NS_EVENT_BITS_LOAD_PAGE_RESTORE 0x20
|
||||
|
||||
//nsIDOMXULListener
|
||||
#define NS_EVENT_BITS_XUL_NONE 0x00
|
||||
@ -349,4 +349,9 @@ protected:
|
||||
#define NS_EVENT_BITS_UI_FOCUSIN 0x02
|
||||
#define NS_EVENT_BITS_UI_FOCUSOUT 0x04
|
||||
|
||||
// nsIDOMPageTransitionListener
|
||||
#define NS_EVENT_BITS_PAGETRANSITION_NONE 0x00
|
||||
#define NS_EVENT_BITS_PAGETRANSITION_SHOW 0x01
|
||||
#define NS_EVENT_BITS_PAGETRANSITION_HIDE 0x02
|
||||
|
||||
#endif // nsEventListenerManager_h__
|
||||
|
@ -45,8 +45,8 @@ class nsIURI;
|
||||
|
||||
// IID for the nsILink interface
|
||||
#define NS_ILINK_IID \
|
||||
{ 0xa904ac22, 0x28fa, 0x4812, \
|
||||
{ 0xbe, 0xf3, 0x2, 0x2f, 0xf3, 0x3b, 0x8e, 0xf5 } }
|
||||
{ 0x0c212bc4, 0xfcd7, 0x479d, \
|
||||
{ 0x8c, 0x3f, 0x3b, 0xe8, 0xe6, 0x78, 0x74, 0x50 } }
|
||||
|
||||
/**
|
||||
* This interface allows SelectorMatches to get the canonical
|
||||
@ -86,6 +86,20 @@ public:
|
||||
*/
|
||||
NS_IMETHOD GetHrefURI(nsIURI** aURI) = 0;
|
||||
|
||||
/**
|
||||
* Dispatch a LinkAdded event to the nsIChromeEventHandler for this document.
|
||||
* This is used to notify the chrome listeners when restoring a page
|
||||
* presentation. Currently, this only applies to HTML <link> elements.
|
||||
*/
|
||||
NS_IMETHOD LinkAdded() = 0;
|
||||
|
||||
/**
|
||||
* Dispatch a LinkRemoved event to the nsIChromeEventHandler for this
|
||||
* document. This is used to notify the chrome listeners when saving a page
|
||||
* presentation (since the document is not torn down). Currently, this only
|
||||
* applies to HTML <link> elements.
|
||||
*/
|
||||
NS_IMETHOD LinkRemoved() = 0;
|
||||
};
|
||||
|
||||
#endif /* nsILink_h___ */
|
||||
|
@ -97,6 +97,8 @@ public:
|
||||
NS_IMETHOD GetLinkState(nsLinkState &aState);
|
||||
NS_IMETHOD SetLinkState(nsLinkState aState);
|
||||
NS_IMETHOD GetHrefURI(nsIURI** aURI);
|
||||
NS_IMETHOD LinkAdded() { return NS_OK; }
|
||||
NS_IMETHOD LinkRemoved() { return NS_OK; }
|
||||
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
|
@ -81,6 +81,8 @@ public:
|
||||
NS_IMETHOD GetLinkState(nsLinkState &aState);
|
||||
NS_IMETHOD SetLinkState(nsLinkState aState);
|
||||
NS_IMETHOD GetHrefURI(nsIURI** aURI);
|
||||
NS_IMETHOD LinkAdded() { return NS_OK; }
|
||||
NS_IMETHOD LinkRemoved() { return NS_OK; }
|
||||
|
||||
virtual nsresult HandleDOMEvent(nsPresContext* aPresContext,
|
||||
nsEvent* aEvent, nsIDOMEvent** aDOMEvent,
|
||||
|
@ -56,6 +56,8 @@
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
class nsHTMLLinkElement : public nsGenericHTMLElement,
|
||||
public nsIDOMHTMLLinkElement,
|
||||
@ -85,6 +87,8 @@ public:
|
||||
NS_IMETHOD GetLinkState(nsLinkState &aState);
|
||||
NS_IMETHOD SetLinkState(nsLinkState aState);
|
||||
NS_IMETHOD GetHrefURI(nsIURI** aURI);
|
||||
NS_IMETHOD LinkAdded();
|
||||
NS_IMETHOD LinkRemoved();
|
||||
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
@ -211,6 +215,20 @@ nsHTMLLinkElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLLinkElement::LinkAdded()
|
||||
{
|
||||
CreateAndDispatchEvent(GetOwnerDoc(), NS_LITERAL_STRING("DOMLinkAdded"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLLinkElement::LinkRemoved()
|
||||
{
|
||||
CreateAndDispatchEvent(GetOwnerDoc(), NS_LITERAL_STRING("DOMLinkRemoved"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLLinkElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
|
||||
{
|
||||
|
@ -234,7 +234,6 @@ public:
|
||||
NS_IMETHOD Unload(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD PageRestore(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
|
@ -171,7 +171,6 @@ static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
|
||||
|
||||
#include "plevent.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
|
||||
// Number of documents currently loading
|
||||
@ -862,18 +861,18 @@ nsDocShell::PrepareForNewContentModel()
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::FireUnloadNotification()
|
||||
nsDocShell::FirePageHideNotification(PRBool aIsUnload)
|
||||
{
|
||||
if (mContentViewer && !mFiredUnloadEvent) {
|
||||
mFiredUnloadEvent = PR_TRUE;
|
||||
|
||||
mContentViewer->Unload();
|
||||
mContentViewer->PageHide(aIsUnload);
|
||||
|
||||
PRInt32 i, n = mChildList.Count();
|
||||
for (i = 0; i < n; i++) {
|
||||
nsCOMPtr<nsIDocShell> shell(do_QueryInterface(ChildAt(i)));
|
||||
if (shell) {
|
||||
shell->FireUnloadNotification();
|
||||
shell->FirePageHideNotification(aIsUnload);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3145,6 +3144,13 @@ NS_IMETHODIMP
|
||||
nsDocShell::Stop(PRUint32 aStopFlags)
|
||||
{
|
||||
if (nsIWebNavigation::STOP_CONTENT & aStopFlags) {
|
||||
// Revoke any pending plevents related to content viewer restoration
|
||||
nsCOMPtr<nsIEventQueue> uiThreadQueue;
|
||||
NS_GetMainEventQ(getter_AddRefs(uiThreadQueue));
|
||||
if (uiThreadQueue)
|
||||
uiThreadQueue->RevokeEvents(this);
|
||||
|
||||
// Stop the document loading
|
||||
if (mContentViewer)
|
||||
mContentViewer->Stop();
|
||||
}
|
||||
@ -3375,7 +3381,7 @@ nsDocShell::Destroy()
|
||||
mIsBeingDestroyed = PR_TRUE;
|
||||
|
||||
//Fire unload event before we blow anything away.
|
||||
(void) FireUnloadNotification();
|
||||
(void) FirePageHideNotification(PR_TRUE);
|
||||
|
||||
// Stop any URLs that are currently being loaded...
|
||||
Stop(nsIWebNavigation::STOP_ALL);
|
||||
@ -4622,7 +4628,7 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
|
||||
// This will cause any OnLoad(...) handlers to fire, if it is a HTML
|
||||
// document...
|
||||
//
|
||||
if (!mEODForCurrentDocument && mContentViewer) {
|
||||
if ((mIsRestoringDocument || !mEODForCurrentDocument) && mContentViewer) {
|
||||
mIsExecutingOnLoadHandler = PR_TRUE;
|
||||
mContentViewer->LoadComplete(aStatus);
|
||||
mIsExecutingOnLoadHandler = PR_FALSE;
|
||||
@ -4747,7 +4753,7 @@ nsDocShell::CreateAboutBlankContentViewer()
|
||||
// is changed within the DocShell - otherwise, javascript will get the
|
||||
// wrong information :-(
|
||||
//
|
||||
(void) FireUnloadNotification();
|
||||
(void) FirePageHideNotification(PR_TRUE);
|
||||
}
|
||||
|
||||
// one helper factory, please
|
||||
@ -4889,93 +4895,138 @@ nsDocShell::CaptureState()
|
||||
mOSHE->AddChildShell(childShell);
|
||||
}
|
||||
|
||||
// Capture the security state.
|
||||
nsCOMPtr<nsISupports> securityState;
|
||||
if (mSecurityUI)
|
||||
mSecurityUI->CaptureState(getter_AddRefs(securityState));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mOSHE->SetSecurityState(securityState);
|
||||
class RestorePresentationEvent : public PLEvent
|
||||
{
|
||||
public:
|
||||
RestorePresentationEvent(nsDocShell *aShell);
|
||||
|
||||
nsRefPtr<nsDocShell> mDocShell;
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(void*)
|
||||
HandleRestorePresentationEvent(PLEvent *aEvent)
|
||||
{
|
||||
NS_STATIC_CAST(RestorePresentationEvent*, aEvent)->mDocShell->FinishRestore();
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
DestroyRestorePresentationEvent(PLEvent *aEvent)
|
||||
{
|
||||
delete NS_STATIC_CAST(RestorePresentationEvent*, aEvent);
|
||||
}
|
||||
|
||||
RestorePresentationEvent::RestorePresentationEvent(nsDocShell *aShell)
|
||||
: mDocShell(aShell)
|
||||
{
|
||||
PL_InitEvent(this, mDocShell, ::HandleRestorePresentationEvent,
|
||||
::DestroyRestorePresentationEvent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::FireRestoreEvents()
|
||||
nsDocShell::BeginRestore(PRBool aTop)
|
||||
{
|
||||
// These events fire bottom-up, so call this on our children first.
|
||||
PRInt32 n = mChildList.Count();
|
||||
for (PRInt32 i = 0; i < n; ++i) {
|
||||
nsCOMPtr<nsIDocShell> child = do_QueryInterface(ChildAt(i));
|
||||
if (child) {
|
||||
child->FireRestoreEvents();
|
||||
}
|
||||
}
|
||||
|
||||
// Dispatch events. This is a little messy. We need to avoid firing
|
||||
// onload so that it is visible from the content DOM window, but we _do_
|
||||
// want the chrome to see it for chrome/extensions that look for page load.
|
||||
// In addition, we need to fire DOMPageRestore on the content window.
|
||||
// Dispatch events for restoring the presentation. We try to simulate
|
||||
// the progress notifications loading the document would cause, so we add
|
||||
// the document's channel to the loadgroup to initiate stateChange
|
||||
// notifications.
|
||||
|
||||
nsresult rv = EnsureContentViewer();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> docViewer = do_QueryInterface(mContentViewer);
|
||||
NS_ENSURE_TRUE(docViewer, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
docViewer->GetPresShell(getter_AddRefs(shell));
|
||||
NS_ENSURE_TRUE(shell, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsEvent event(PR_TRUE, NS_PAGE_LOAD);
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> privWin = do_QueryInterface(mScriptGlobal);
|
||||
NS_ENSURE_TRUE(privWin, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIChromeEventHandler> handler = privWin->GetChromeEventHandler();
|
||||
|
||||
PRUint32 flags = NS_EVENT_FLAG_INIT;
|
||||
event.flags |= flags;
|
||||
flags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
flags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE;
|
||||
|
||||
nsIDOMEvent *domEvt = nsnull;
|
||||
nsPresContext *pc = shell->GetPresContext();
|
||||
|
||||
rv = handler->HandleChromeEvent(pc, &event, &domEvt,
|
||||
flags & NS_EVENT_CAPTURE_MASK, &status);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (domEvt) {
|
||||
nsrefcnt rc;
|
||||
NS_RELEASE2(domEvt, rc);
|
||||
if (0 != rc) {
|
||||
// Okay, so someone in the DOM loop (a listener, JS object)
|
||||
// still has a ref to the DOM Event but the internal data
|
||||
// hasn't been malloc'd. Force a copy of the data here so the
|
||||
// DOM Event is still valid.
|
||||
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent =
|
||||
do_QueryInterface(domEvt);
|
||||
|
||||
if (privateEvent) {
|
||||
privateEvent->DuplicatePrivateData();
|
||||
}
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
mContentViewer->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
|
||||
if (doc) {
|
||||
nsIChannel *channel = doc->GetChannel();
|
||||
if (channel) {
|
||||
mIsRestoringDocument = PR_TRUE;
|
||||
mLoadGroup->AddRequest(channel, nsnull);
|
||||
mIsRestoringDocument = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
status = nsEventStatus_eIgnore;
|
||||
nsEvent restoreEvent(PR_TRUE, NS_PAGE_RESTORE);
|
||||
// These events start from the top-down and finish from the bottom-up.
|
||||
// So, next we tell all of our children to call AddRequest, then post
|
||||
// a PLEvent, which will cause us to call finishRestore() on our children.
|
||||
|
||||
return mScriptGlobal->HandleDOMEvent(pc, &restoreEvent, nsnull,
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
PRInt32 n = mChildList.Count();
|
||||
for (PRInt32 i = 0; i < n; ++i) {
|
||||
nsCOMPtr<nsIDocShell> child = do_QueryInterface(ChildAt(i));
|
||||
if (child) {
|
||||
rv = child->BeginRestore(PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
if (aTop) {
|
||||
// We finish up the restore processing on a PLEvent to mimic the way
|
||||
// RemoveRequest is called by nsIChannel implementations.
|
||||
|
||||
nsCOMPtr<nsIEventQueue> uiThreadQueue;
|
||||
NS_GetMainEventQ(getter_AddRefs(uiThreadQueue));
|
||||
NS_ENSURE_TRUE(uiThreadQueue, NS_ERROR_UNEXPECTED);
|
||||
|
||||
PLEvent *evt = new RestorePresentationEvent(this);
|
||||
NS_ENSURE_TRUE(evt, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = uiThreadQueue->PostEvent(evt);
|
||||
if (NS_FAILED(rv)) {
|
||||
PL_DestroyEvent(evt);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::FinishRestore()
|
||||
{
|
||||
// First we call finishRestore() on our children. In the simulated load,
|
||||
// all of the child frames finish loading before the main document.
|
||||
|
||||
PRInt32 n = mChildList.Count();
|
||||
for (PRInt32 i = 0; i < n; ++i) {
|
||||
nsCOMPtr<nsIDocShell> child = do_QueryInterface(ChildAt(i));
|
||||
if (child) {
|
||||
child->FinishRestore();
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
mContentViewer->GetDOMDocument(getter_AddRefs(domDoc));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
|
||||
if (doc) {
|
||||
// Finally, we remove the request from the loadgroup. This will cause
|
||||
// onStateChange(STATE_STOP) to fire, which will fire the PageShow
|
||||
// event to the chrome.
|
||||
|
||||
nsIChannel *channel = doc->GetChannel();
|
||||
if (channel) {
|
||||
mIsRestoringDocument = PR_TRUE;
|
||||
mLoadGroup->RemoveRequest(channel, nsnull, NS_OK);
|
||||
mIsRestoringDocument = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetRestoringDocument(PRBool *aRestoring)
|
||||
{
|
||||
*aRestoring = mIsRestoringDocument;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class ContentViewerDestroyEvent : public PLEvent
|
||||
{
|
||||
public:
|
||||
ContentViewerDestroyEvent(nsIContentViewer *aViewer)
|
||||
: mViewer(aViewer)
|
||||
{
|
||||
}
|
||||
ContentViewerDestroyEvent(nsIContentViewer *aViewer, nsDocShell *aShell);
|
||||
|
||||
nsCOMPtr<nsIContentViewer> mViewer;
|
||||
};
|
||||
@ -4993,6 +5044,14 @@ DestroyContentViewerDestroyEvent(PLEvent *aEvent)
|
||||
delete NS_STATIC_CAST(ContentViewerDestroyEvent*, aEvent);
|
||||
}
|
||||
|
||||
ContentViewerDestroyEvent::ContentViewerDestroyEvent(nsIContentViewer *aViewer,
|
||||
nsDocShell *aShell)
|
||||
: mViewer(aViewer)
|
||||
{
|
||||
PL_InitEvent(this, aShell, ::HandleContentViewerDestroyEvent,
|
||||
::DestroyContentViewerDestroyEvent);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocShell::RestorePresentation(nsISHEntry *aSHEntry, PRBool aSavePresentation,
|
||||
PRBool *aRestored)
|
||||
@ -5043,6 +5102,10 @@ nsDocShell::RestorePresentation(nsISHEntry *aSHEntry, PRBool aSavePresentation,
|
||||
printf("restoring presentation from session history: %s\n", spec.get());
|
||||
#endif
|
||||
|
||||
// Notify the old content viewer that it's being hidden.
|
||||
FirePageHideNotification(!aSavePresentation);
|
||||
mFiredUnloadEvent = PR_FALSE;
|
||||
|
||||
// Save off the root view's parent and sibling so that we can insert the
|
||||
// new content viewer's root view at the same position. Also save the
|
||||
// bounds of the root view's widget.
|
||||
@ -5075,13 +5138,17 @@ nsDocShell::RestorePresentation(nsISHEntry *aSHEntry, PRBool aSavePresentation,
|
||||
// content viewer, we prevent the viewer from being torn down after
|
||||
// Destroy() is called.
|
||||
|
||||
if (!aSavePresentation)
|
||||
FireUnloadNotification();
|
||||
|
||||
mFiredUnloadEvent = PR_FALSE;
|
||||
nsresult rv;
|
||||
|
||||
if (mContentViewer) {
|
||||
if (aSavePresentation) {
|
||||
rv = CaptureState();
|
||||
if (NS_FAILED(rv) && mOSHE) {
|
||||
mOSHE->SyncPresentationState();
|
||||
aSavePresentation = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
mContentViewer->Close(aSavePresentation ? mOSHE.get() : nsnull);
|
||||
|
||||
// It's unsafe to actually destroy the content viewer here.
|
||||
@ -5093,12 +5160,9 @@ nsDocShell::RestorePresentation(nsISHEntry *aSHEntry, PRBool aSavePresentation,
|
||||
NS_GetMainEventQ(getter_AddRefs(uiThreadQueue));
|
||||
NS_ENSURE_TRUE(uiThreadQueue, NS_ERROR_UNEXPECTED);
|
||||
|
||||
PLEvent *evt = new ContentViewerDestroyEvent(mContentViewer);
|
||||
PLEvent *evt = new ContentViewerDestroyEvent(mContentViewer, this);
|
||||
NS_ENSURE_TRUE(evt, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
PL_InitEvent(evt, this, ::HandleContentViewerDestroyEvent,
|
||||
::DestroyContentViewerDestroyEvent);
|
||||
|
||||
rv = uiThreadQueue->PostEvent(evt);
|
||||
if (NS_FAILED(rv)) {
|
||||
PL_DestroyEvent(evt);
|
||||
@ -5191,15 +5255,6 @@ nsDocShell::RestorePresentation(nsISHEntry *aSHEntry, PRBool aSavePresentation,
|
||||
// aSHEntry is now our currently-loaded document.
|
||||
mOSHE = aSHEntry;
|
||||
|
||||
// Clear the mLSHE reference to indicate document loading is done one
|
||||
// way or another.
|
||||
mLSHE = nsnull;
|
||||
|
||||
// mEODForCurrentDocument is true here, so EndPageLoad will not fire
|
||||
// onload (we fire that below, in a special way so that the content window
|
||||
// does not see it).
|
||||
EndPageLoad(nsnull, nsnull, NS_OK);
|
||||
|
||||
// Meta-refresh timers have been restarted for this shell, but not
|
||||
// for our children. Walk the child shells and restart their timers.
|
||||
PRInt32 n = mChildList.Count();
|
||||
@ -5242,18 +5297,10 @@ nsDocShell::RestorePresentation(nsISHEntry *aSHEntry, PRBool aSavePresentation,
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the security state
|
||||
if (mSecurityUI) {
|
||||
nsCOMPtr<nsISupports> securityState;
|
||||
aSHEntry->GetSecurityState(getter_AddRefs(securityState));
|
||||
if (securityState)
|
||||
mSecurityUI->TransitionToState(securityState);
|
||||
}
|
||||
|
||||
SetCurrentURI(uri);
|
||||
|
||||
// Dispatch onload and DOMPageRestore.
|
||||
rv = FireRestoreEvents();
|
||||
rv = BeginRestore(PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mContentViewer->Show();
|
||||
@ -5304,8 +5351,7 @@ nsDocShell::CreateContentViewer(const char *aContentType,
|
||||
//
|
||||
|
||||
PRBool savePresentation = CanSavePresentation(request);
|
||||
if (!savePresentation)
|
||||
FireUnloadNotification();
|
||||
FirePageHideNotification(!savePresentation);
|
||||
|
||||
// Set mFiredUnloadEvent = PR_FALSE so that the unload handler for the
|
||||
// *new* document will fire.
|
||||
@ -5320,17 +5366,7 @@ nsDocShell::CreateContentViewer(const char *aContentType,
|
||||
|
||||
PRBool onLocationChangeNeeded = OnLoadingSite(aOpenedChannel, PR_FALSE);
|
||||
|
||||
if (savePresentation) {
|
||||
// The old content viewer will be saved during the call to Embed().
|
||||
rv = CaptureState();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mSavingOldViewer = PR_TRUE;
|
||||
} else {
|
||||
if (mOSHE) {
|
||||
mOSHE->SyncPresentationState();
|
||||
}
|
||||
}
|
||||
}
|
||||
mSavingOldViewer = savePresentation;
|
||||
|
||||
// let's try resetting the load group if we need to...
|
||||
nsCOMPtr<nsILoadGroup> currentLoadGroup;
|
||||
@ -5623,7 +5659,16 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
|
||||
|
||||
// Tell the old content viewer to hibernate in session history when
|
||||
// it is destroyed.
|
||||
mContentViewer->Close(mSavingOldViewer ? mOSHE.get() : nsnull);
|
||||
|
||||
PRBool savePresentation = mSavingOldViewer;
|
||||
if (savePresentation && NS_FAILED(CaptureState())) {
|
||||
if (mOSHE) {
|
||||
mOSHE->SyncPresentationState();
|
||||
}
|
||||
savePresentation = PR_FALSE;
|
||||
}
|
||||
|
||||
mContentViewer->Close(savePresentation ? mOSHE.get() : nsnull);
|
||||
aNewViewer->SetPreviousViewer(mContentViewer);
|
||||
|
||||
mContentViewer = nsnull;
|
||||
@ -6229,12 +6274,6 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
|
||||
// If we have a saved content viewer in history, restore and show it now.
|
||||
if (aSHEntry) {
|
||||
if (savePresentation) {
|
||||
rv = CaptureState();
|
||||
if (NS_FAILED(rv) && mOSHE)
|
||||
mOSHE->SyncPresentationState();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISHEntry> oldEntry = mOSHE;
|
||||
PRBool restored;
|
||||
rv = RestorePresentation(aSHEntry, savePresentation &&
|
||||
|
@ -14,7 +14,7 @@ struct nsRect;
|
||||
[ptr] native nsIDeviceContextPtr(nsIDeviceContext);
|
||||
[ref] native nsRectRef(nsRect);
|
||||
|
||||
[scriptable, uuid(456651af-14ca-4f8d-91a3-c7cdd7e7eef6)]
|
||||
[scriptable, uuid(62d0e866-e608-4b1a-9ab0-467142b3e3bd)]
|
||||
interface nsIContentViewer : nsISupports
|
||||
{
|
||||
|
||||
@ -27,7 +27,7 @@ interface nsIContentViewer : nsISupports
|
||||
void loadStart(in nsISupports aDoc);
|
||||
void loadComplete(in unsigned long aStatus);
|
||||
boolean permitUnload();
|
||||
void unload();
|
||||
void pageHide(in boolean isUnload);
|
||||
|
||||
/**
|
||||
* All users of a content viewer are responsible for calling both
|
||||
|
@ -66,7 +66,7 @@ interface nsISHEntry;
|
||||
interface nsILayoutHistoryState;
|
||||
interface nsISecureBrowserUI;
|
||||
|
||||
[scriptable, uuid(b0228925-9242-467b-842f-dc739a6e478f)]
|
||||
[scriptable, uuid(5d1529b3-f825-45af-a2ee-1ae4bc2b2b2a)]
|
||||
interface nsIDocShell : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -175,9 +175,10 @@ interface nsIDocShell : nsISupports
|
||||
|
||||
/**
|
||||
* Notify the associated content viewer and all child docshells that they are
|
||||
* about to be unloaded.
|
||||
* about to be hidden. If |isUnload| is true, then the document is being
|
||||
* unloaded as well.
|
||||
*/
|
||||
[noscript] void fireUnloadNotification();
|
||||
[noscript] void firePageHideNotification(in boolean isUnload);
|
||||
|
||||
/**
|
||||
* Presentation context for the currently loaded document. This may be null.
|
||||
@ -364,12 +365,22 @@ interface nsIDocShell : nsISupports
|
||||
void resumeRefreshURIs();
|
||||
|
||||
/**
|
||||
* Fire the onload and DOMPageRestore events as part of restoring a
|
||||
* presentation from sessino history. The onload event is fired starting
|
||||
* at the chrome event handler; the DOMPageRestore event is fired starting
|
||||
* at the window object. This first recurses into child docshells so that
|
||||
* events fire in a bottom-up order.
|
||||
* Begin firing WebProgressListener notifications and DOM events for
|
||||
* restoring a page presentation. |top| should be true for the toplevel
|
||||
* docshell that is being restored; it will be set to false when this method
|
||||
* is called for child docshells. This method will post an event to call
|
||||
* finishRestore() after returning to the event loop.
|
||||
*/
|
||||
void fireRestoreEvents();
|
||||
void beginRestore(in boolean top);
|
||||
|
||||
/**
|
||||
* Finish firing WebProgressListener notifications and DOM events for
|
||||
* restoring a page presentation. This should only be called via
|
||||
* beginRestore().
|
||||
*/
|
||||
void finishRestore();
|
||||
|
||||
/* Track whether we're currently restoring a document presentation. */
|
||||
readonly attribute boolean restoringDocument;
|
||||
};
|
||||
|
||||
|
@ -61,6 +61,7 @@ EXPORTS = \
|
||||
nsIDOMScrollListener.h \
|
||||
nsIDOMContextMenuListener.h \
|
||||
nsIDOMUIListener.h \
|
||||
nsIDOMPageTransitionListener.h \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -47,8 +47,9 @@
|
||||
*
|
||||
*/
|
||||
#define NS_IDOMLOADLISTENER_IID \
|
||||
{0x0f7fa587, 0xaac5, 0x11d9, \
|
||||
{0xba, 0x4e, 0x00, 0x11, 0x24, 0x78, 0xd6, 0x26} }
|
||||
{ /* d1810238-14f8-4cab-9b96-96bedb9de7be */ \
|
||||
0xd1810238, 0x14f8, 0x4cab, \
|
||||
{0x9b, 0x96, 0x96, 0xbe, 0xdb, 0x9d, 0xe7, 0xbe} }
|
||||
|
||||
class nsIDOMLoadListener : public nsIDOMEventListener {
|
||||
|
||||
@ -90,13 +91,6 @@ public:
|
||||
*/
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent) = 0;
|
||||
|
||||
/**
|
||||
* Processes a DOMPageRestore event. This is dispatched when a page's
|
||||
* presentation is restored from session history (onload does not fire
|
||||
* in this case).
|
||||
* @param aEvent The event object
|
||||
*/
|
||||
NS_IMETHOD PageRestore(nsIDOMEvent* aEvent) = 0;
|
||||
};
|
||||
|
||||
#endif // nsIDOMLoadListener_h__
|
||||
|
58
dom/public/coreEvents/nsIDOMPageTransitionListener.h
Executable file
58
dom/public/coreEvents/nsIDOMPageTransitionListener.h
Executable file
@ -0,0 +1,58 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS 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.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIDOMPageTransitionListener_h__
|
||||
#define nsIDOMPageTransitionListener_h__
|
||||
|
||||
#include "nsIDOMEventListener.h"
|
||||
|
||||
class nsIDOMEvent;
|
||||
|
||||
/*
|
||||
* Page transition event listener interface.
|
||||
*/
|
||||
#define NS_IDOMPAGETRANSITIONLISTENER_IID \
|
||||
{ 0x24f4d69f, 0x6b0c, 0x48a8, { 0xba, 0xb7, 0x12, 0x50, 0xcb, 0x5e, 0x48, 0x79 } }
|
||||
|
||||
class nsIDOMPageTransitionListener : public nsIDOMEventListener {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOMPAGETRANSITIONLISTENER_IID)
|
||||
|
||||
NS_IMETHOD PageShow(nsIDOMEvent* aEvent) = 0;
|
||||
NS_IMETHOD PageHide(nsIDOMEvent* aEvent) = 0;
|
||||
};
|
||||
#endif // nsIDOMPageTransitionListener_h__
|
@ -68,6 +68,7 @@ XPIDLSRCS = \
|
||||
nsIDOMBeforeUnloadEvent.idl \
|
||||
nsIDOMNSEventTarget.idl \
|
||||
nsIDOMSmartCardEvent.idl \
|
||||
nsIDOMPageTransitionEvent.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
62
dom/public/idl/events/nsIDOMPageTransitionEvent.idl
Executable file
62
dom/public/idl/events/nsIDOMPageTransitionEvent.idl
Executable file
@ -0,0 +1,62 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS 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.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIDOMEvent.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMPageTransitionEvent interface is used for the PageShow and
|
||||
* PageHide events, which are generic events that apply to both page
|
||||
* load/unload and saving/restoring a document from session history.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(b712418b-376f-4f75-b156-5d9ad99fe51f)]
|
||||
interface nsIDOMPageTransitionEvent : nsIDOMEvent
|
||||
{
|
||||
/**
|
||||
* Set to true if the document has been or will be persisted across
|
||||
* firing of the event. For example, if a document is being cached in
|
||||
* session history, |persisted| is true for the PageHide event.
|
||||
*/
|
||||
readonly attribute boolean persisted;
|
||||
|
||||
/* Initialize a new PageShow or PageHide event. */
|
||||
void initPageTransitionEvent(in DOMString typeArg,
|
||||
in boolean canBubbleArg,
|
||||
in boolean canCancelArg,
|
||||
in boolean persisted);
|
||||
};
|
@ -335,6 +335,9 @@ enum nsDOMClassInfoID {
|
||||
// SmartCard Events
|
||||
eDOMClassInfo_SmartCardEvent_id,
|
||||
|
||||
// PageTransition Events
|
||||
eDOMClassInfo_PageTransitionEvent_id,
|
||||
|
||||
// This one better be the last one in this list
|
||||
eDOMClassInfoIDCount
|
||||
};
|
||||
|
@ -208,6 +208,7 @@
|
||||
#include "nsIDOMBeforeUnloadEvent.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "nsIDOMSmartCardEvent.h"
|
||||
#include "nsIDOMPageTransitionEvent.h"
|
||||
#include "nsIDOMNSDocumentStyle.h"
|
||||
#include "nsIDOMDocumentRange.h"
|
||||
#include "nsIDOMDocumentTraversal.h"
|
||||
@ -1005,6 +1006,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(SmartCardEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(PageTransitionEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
};
|
||||
|
||||
nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
|
||||
@ -1736,6 +1739,11 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSmartCardEvent)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(PageTransitionEvent, nsIDOMPageTransitionEvent)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMPageTransitionEvent)
|
||||
DOM_CLASSINFO_EVENT_MAP_ENTRIES
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MutationEvent, nsIDOMMutationEvent)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMutationEvent)
|
||||
DOM_CLASSINFO_EVENT_MAP_ENTRIES
|
||||
|
@ -5815,6 +5815,9 @@ public:
|
||||
// Get the listener manager, which holds all event handlers for the window.
|
||||
nsIEventListenerManager* GetListenerManager() { return mListenerManager; }
|
||||
|
||||
// Get the saved value of the mMutationBits field.
|
||||
PRUint32 GetMutationBits() { return mMutationBits; }
|
||||
|
||||
// Get the contents of focus memory when the state was saved
|
||||
// (if the focus was inside of this window).
|
||||
nsIDOMElement* GetFocusedElement() { return mFocusedElement; }
|
||||
@ -5835,6 +5838,7 @@ private:
|
||||
nsCOMPtr<nsIDOMWindowInternal> mFocusedWindow;
|
||||
nsTimeout *mSavedTimeouts;
|
||||
nsTimeout **mTimeoutInsertionPoint;
|
||||
PRUint32 mMutationBits;
|
||||
};
|
||||
|
||||
WindowStateHolder::WindowStateHolder(JSContext *cx, JSObject *aObject,
|
||||
@ -5844,6 +5848,11 @@ WindowStateHolder::WindowStateHolder(JSContext *cx, JSObject *aObject,
|
||||
NS_ASSERTION(aWindow, "null window");
|
||||
|
||||
aWindow->GetListenerManager(getter_AddRefs(mListenerManager));
|
||||
mMutationBits = aWindow->mMutationBits;
|
||||
|
||||
// Clear the window's EventListenerManager pointer so that it can't have
|
||||
// listeners removed from it later.
|
||||
aWindow->mListenerManager = nsnull;
|
||||
|
||||
nsIFocusController *fc = aWindow->GetRootFocusController();
|
||||
NS_ASSERTION(fc, "null focus controller");
|
||||
@ -6042,6 +6051,7 @@ nsGlobalWindow::RestoreWindowState(nsISupports *aState)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mListenerManager = holder->GetListenerManager();
|
||||
mMutationBits = holder->GetMutationBits();
|
||||
|
||||
nsIDOMElement *focusedElement = holder->GetFocusedElement();
|
||||
nsIDOMWindowInternal *focusedWindow = holder->GetFocusedWindow();
|
||||
|
@ -110,7 +110,7 @@ InspectorApp.prototype =
|
||||
//this.initSearch();
|
||||
|
||||
var el = document.getElementById("bxBrowser");
|
||||
el.addEventListener("load", BrowserLoadListener, true);
|
||||
el.addEventListener("PageShow", BrowserPageShowListener, true);
|
||||
|
||||
this.setBrowser(false, true);
|
||||
//this.setSearch(false, true);
|
||||
@ -576,9 +576,9 @@ InspectorApp.prototype =
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// event listeners
|
||||
|
||||
function BrowserLoadListener(aEvent)
|
||||
function BrowserPageShowListener(aEvent)
|
||||
{
|
||||
// since we will also get load events for frame documents,
|
||||
// since we will also get PageShow events for frame documents,
|
||||
// make sure we respond to the top-level document load
|
||||
if (aEvent.target.defaultView == _content)
|
||||
inspector.documentLoaded();
|
||||
|
@ -68,7 +68,7 @@ function inSearchService()
|
||||
// the xmlextras facility for loading xml, but it's broken, so
|
||||
// we use a browser for onw
|
||||
var browser = document.getElementById("inSearchServiceLoader");
|
||||
browser.addEventListener("load", inSearchService_LoadListener, true);
|
||||
browser.addEventListener("PageShow", inSearchService_LoadListener, true);
|
||||
this.mWebNav = browser.webNavigation;
|
||||
}
|
||||
|
||||
|
@ -333,12 +333,6 @@ nsDOMParser::Error(nsIDOMEvent* aEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMParser::PageRestore(nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDOMParser::nsDOMParser()
|
||||
: mLoopingForSyncLoad(PR_FALSE)
|
||||
{
|
||||
|
@ -67,7 +67,6 @@ public:
|
||||
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
|
@ -121,15 +121,3 @@ nsLoadListenerProxy::Error(nsIDOMEvent* aEvent)
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadListenerProxy::PageRestore(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMLoadListener> listener(do_QueryReferent(mParent));
|
||||
|
||||
if (listener) {
|
||||
return listener->PageRestore(aEvent);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -69,7 +69,6 @@ public:
|
||||
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
|
||||
|
||||
protected:
|
||||
nsWeakPtr mParent;
|
||||
|
@ -1747,12 +1747,6 @@ nsXMLHttpRequest::Error(nsIDOMEvent* aEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::PageRestore(nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLHttpRequest::ChangeState(PRUint32 aState, PRBool aBroadcast,
|
||||
PRBool aClearEventListeners)
|
||||
|
@ -97,7 +97,6 @@ public:
|
||||
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
|
||||
|
||||
// nsIStreamListener
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
@ -78,7 +78,6 @@ public:
|
||||
virtual nsresult Unload(nsIDOMEvent* aEvent) {printf("Unload\n"); return NS_OK;}
|
||||
virtual nsresult Abort(nsIDOMEvent* aEvent) {printf("Abort\n"); return NS_OK;}
|
||||
virtual nsresult Error(nsIDOMEvent* aEvent) {printf("Error\n"); return NS_OK;}
|
||||
NS_IMETHOD PageRestore(nsIDOMEvent* aEvent) {printf("PageRestore\n"); return NS_OK;}
|
||||
};
|
||||
|
||||
NS_IMPL_ADDREF(nsMyListener)
|
||||
|
@ -986,17 +986,26 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus)
|
||||
nsCOMPtr<nsIDocumentViewer> kungFuDeathGrip(this);
|
||||
|
||||
// Now, fire either an OnLoad or OnError event to the document...
|
||||
PRBool restoring = PR_FALSE;
|
||||
if(NS_SUCCEEDED(aStatus)) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event(PR_TRUE, NS_PAGE_LOAD);
|
||||
|
||||
rv = global->HandleDOMEvent(mPresContext, &event, nsnull,
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
#ifdef MOZ_TIMELINE
|
||||
// if navigator.xul's load is complete, the main nav window is visible
|
||||
// mark that point.
|
||||
// If the document presentation is being restored, we don't want to fire
|
||||
// onload to the document content since that would likely confuse scripts
|
||||
// on the page.
|
||||
|
||||
nsIDocShell *docShell = global->GetDocShell();
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_UNEXPECTED);
|
||||
|
||||
docShell->GetRestoringDocument(&restoring);
|
||||
if (!restoring) {
|
||||
rv = global->HandleDOMEvent(mPresContext, &event, nsnull,
|
||||
NS_EVENT_FLAG_INIT, &status);
|
||||
#ifdef MOZ_TIMELINE
|
||||
// if navigator.xul's load is complete, the main nav window is visible
|
||||
// mark that point.
|
||||
|
||||
if (mDocument) {
|
||||
//printf("DEBUG: getting uri from document (%p)\n", mDocument.get());
|
||||
|
||||
nsIURI *uri = mDocument->GetDocumentURI();
|
||||
@ -1009,12 +1018,16 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus)
|
||||
NS_TIMELINE_MARK("Navigator Window visible now");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* MOZ_TIMELINE */
|
||||
}
|
||||
} else {
|
||||
// XXX: Should fire error event to the document...
|
||||
}
|
||||
|
||||
// Notify the document that it has been shown (regardless of whether
|
||||
// it was just loaded).
|
||||
mDocument->OnPageShow(restoring);
|
||||
|
||||
// Now that the document has loaded, we can tell the presshell
|
||||
// to unsuppress painting.
|
||||
if (mPresShell && !mStopped) {
|
||||
@ -1148,7 +1161,7 @@ DocumentViewerImpl::PermitUnload(PRBool *aPermitUnload)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentViewerImpl::Unload()
|
||||
DocumentViewerImpl::PageHide(PRBool aIsUnload)
|
||||
{
|
||||
mEnableRendering = PR_FALSE;
|
||||
|
||||
@ -1156,6 +1169,10 @@ DocumentViewerImpl::Unload()
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
mDocument->OnPageHide(!aIsUnload);
|
||||
if (!aIsUnload)
|
||||
return NS_OK;
|
||||
|
||||
// First, get the script global object from the document...
|
||||
nsIScriptGlobalObject *global = mDocument->GetScriptGlobalObject();
|
||||
|
||||
@ -1202,6 +1219,7 @@ DocumentViewerImpl::Open()
|
||||
|
||||
// XXX re-enable image animations once that works correctly
|
||||
|
||||
mEnableRendering = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class nsIPresShell;
|
||||
class nsIStyleSheet;
|
||||
|
||||
#define NS_IDOCUMENT_VIEWER_IID \
|
||||
{ 0x7e7a579e, 0xfa46, 0x4daf,{0xb7, 0xc6, 0x45, 0x69, 0xd3, 0xb5, 0x30, 0x05}}
|
||||
{ 0xbd4fde0c, 0x71fd, 0x4d77,{0xab, 0x66, 0x26, 0xce, 0x43, 0x93, 0x2e, 0x4e}}
|
||||
|
||||
/**
|
||||
* A document viewer is a kind of content viewer that uses NGLayout
|
||||
|
@ -165,7 +165,6 @@ LAYOUT_ATOM(oncontextmenu, "oncontextmenu")
|
||||
LAYOUT_ATOM(onDOMActivate, "onDOMActivate")
|
||||
LAYOUT_ATOM(onDOMFocusIn, "onDOMFocusIn")
|
||||
LAYOUT_ATOM(onDOMFocusOut, "onDOMFocusOut")
|
||||
LAYOUT_ATOM(onDOMPageRestore, "onDOMPageRestore")
|
||||
LAYOUT_ATOM(ondblclick, "ondblclick")
|
||||
LAYOUT_ATOM(ondragdrop, "ondragdrop")
|
||||
LAYOUT_ATOM(ondragenter, "ondragenter")
|
||||
@ -212,6 +211,10 @@ LAYOUT_ATOM(onDOMNodeInsertedIntoDocument, "onDOMNodeInsertedIntoDocument")
|
||||
LAYOUT_ATOM(onDOMAttrModified, "onDOMAttrModified")
|
||||
LAYOUT_ATOM(onDOMCharacterDataModified, "onDOMCharacterDataModified")
|
||||
|
||||
// pagetransition events
|
||||
LAYOUT_ATOM(onPageShow, "onPageShow")
|
||||
LAYOUT_ATOM(onPageHide, "onPageHide")
|
||||
|
||||
// Alphabetical list of languages for lang-specific transforms
|
||||
LAYOUT_ATOM(Japanese, "ja")
|
||||
LAYOUT_ATOM(Chinese, "zh-CN")
|
||||
|
@ -41,23 +41,15 @@
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMWindow;
|
||||
interface nsIDOMElement;
|
||||
|
||||
[scriptable, uuid(c5ca429c-b5c2-11d9-8547-00112478d626)]
|
||||
[scriptable, uuid(081e31e0-a144-11d3-8c7c-00609792278c)]
|
||||
interface nsISecureBrowserUI : nsISupports
|
||||
{
|
||||
void init(in nsIDOMWindow window);
|
||||
|
||||
readonly attribute unsigned long state;
|
||||
readonly attribute AString tooltipText;
|
||||
|
||||
/* Returns an object that encapsulates the current security state. */
|
||||
nsISupports captureState();
|
||||
|
||||
/**
|
||||
* Restore the state captured by captureState(), firing transition
|
||||
* notifications as necessary.
|
||||
*/
|
||||
void transitionToState(in nsISupports state);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
@ -990,19 +990,12 @@ nsresult nsSecureBrowserUIImpl::UpdateSecurityState(nsIRequest* aRequest)
|
||||
newSecurityState = lis_no_security;
|
||||
}
|
||||
|
||||
return UpdateSecurityState(newSecurityState, aRequest);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSecureBrowserUIImpl::UpdateSecurityState(lockIconState aNewState,
|
||||
nsIRequest *aRequest)
|
||||
{
|
||||
PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
|
||||
("SecureUI:%p: UpdateSecurityState: old-new %d - %d\n", this,
|
||||
mPreviousSecurityState, aNewState
|
||||
mPreviousSecurityState, newSecurityState
|
||||
));
|
||||
|
||||
if (mPreviousSecurityState != aNewState)
|
||||
if (mPreviousSecurityState != newSecurityState)
|
||||
{
|
||||
// must show alert
|
||||
|
||||
@ -1047,7 +1040,7 @@ nsSecureBrowserUIImpl::UpdateSecurityState(lockIconState aNewState,
|
||||
{
|
||||
case lis_no_security:
|
||||
case lis_broken_security:
|
||||
switch (aNewState)
|
||||
switch (newSecurityState)
|
||||
{
|
||||
case lis_no_security:
|
||||
case lis_broken_security:
|
||||
@ -1064,7 +1057,7 @@ nsSecureBrowserUIImpl::UpdateSecurityState(lockIconState aNewState,
|
||||
|
||||
if (showWarning)
|
||||
{
|
||||
switch (aNewState)
|
||||
switch (newSecurityState)
|
||||
{
|
||||
case lis_no_security:
|
||||
case lis_broken_security:
|
||||
@ -1085,9 +1078,9 @@ nsSecureBrowserUIImpl::UpdateSecurityState(lockIconState aNewState,
|
||||
}
|
||||
}
|
||||
|
||||
mPreviousSecurityState = aNewState;
|
||||
mPreviousSecurityState = newSecurityState;
|
||||
|
||||
if (lis_no_security == aNewState)
|
||||
if (lis_no_security == newSecurityState)
|
||||
{
|
||||
mSSLStatus = nsnull;
|
||||
mInfoTooltip.Truncate();
|
||||
@ -1098,7 +1091,7 @@ nsSecureBrowserUIImpl::UpdateSecurityState(lockIconState aNewState,
|
||||
{
|
||||
PRUint32 newState = STATE_IS_INSECURE;
|
||||
|
||||
switch (aNewState)
|
||||
switch (newSecurityState)
|
||||
{
|
||||
case lis_broken_security:
|
||||
newState = STATE_IS_BROKEN;
|
||||
@ -1498,50 +1491,3 @@ ConfirmPostToInsecureFromSecure()
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define NS_SECUREBROWSERUISTATE_IID \
|
||||
{0x086c5daf, 0xbb0a, 0x45cb, {0x98, 0x2b, 0xf1, 0x62, 0x49, 0xd5, 0x0e, 0x28}}
|
||||
|
||||
class nsSecureBrowserUIImpl::State : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_SECUREBROWSERUISTATE_IID)
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
State(lockIconState aState, nsISupports *aSSLStatus);
|
||||
|
||||
lockIconState GetState() const { return mState; }
|
||||
nsISupports* GetSSLStatus() { return mSSLStatus; }
|
||||
|
||||
private:
|
||||
lockIconState mState;
|
||||
nsCOMPtr<nsISupports> mSSLStatus;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSecureBrowserUIImpl::State, nsSecureBrowserUIImpl::State)
|
||||
|
||||
nsSecureBrowserUIImpl::State::State(lockIconState aState,
|
||||
nsISupports *aSSLStatus)
|
||||
: mState(aState), mSSLStatus(aSSLStatus)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSecureBrowserUIImpl::CaptureState(nsISupports **aState)
|
||||
{
|
||||
*aState = new State(mPreviousSecurityState, mSSLStatus);
|
||||
NS_ENSURE_TRUE(aState, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*aState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSecureBrowserUIImpl::TransitionToState(nsISupports *aState)
|
||||
{
|
||||
nsCOMPtr<nsSecureBrowserUIImpl::State> state = do_QueryInterface(aState);
|
||||
NS_ENSURE_TRUE(state, NS_ERROR_NULL_POINTER);
|
||||
|
||||
mSSLStatus = state->GetSSLStatus();
|
||||
return UpdateSecurityState(state->GetState(), nsnull);
|
||||
}
|
||||
|
@ -121,7 +121,6 @@ protected:
|
||||
PRInt32 mSubRequestsNoSecurity;
|
||||
|
||||
nsresult UpdateSecurityState(nsIRequest* aRequest);
|
||||
nsresult UpdateSecurityState(lockIconState aNewState, nsIRequest *aRequest);
|
||||
nsresult EvaluateAndUpdateSecurityState(nsIRequest *aRequest);
|
||||
void UpdateSubrequestMembers(nsIRequest *aRequest);
|
||||
|
||||
@ -145,7 +144,6 @@ protected:
|
||||
nsresult GetNSSDialogs(nsISecurityWarningDialogs **);
|
||||
|
||||
PLDHashTable mTransferringRequests;
|
||||
class State;
|
||||
};
|
||||
|
||||
|
||||
|
@ -71,9 +71,6 @@
|
||||
#include "nsIAutoCompleteResult.h"
|
||||
#include "nsIPK11TokenDB.h"
|
||||
#include "nsIPK11Token.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIDOMNSEvent.h"
|
||||
|
||||
static const char kPMPropertiesURL[] = "chrome://passwordmgr/locale/passwordmgr.properties";
|
||||
static PRBool sRememberPasswords = PR_FALSE;
|
||||
@ -266,37 +263,6 @@ nsPasswordManager::Init()
|
||||
|
||||
progress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_DOCUMENT);
|
||||
|
||||
// Listen for "domwindowopened", this will let us attach our DOMPageRestore
|
||||
// event listener.
|
||||
|
||||
obsService->AddObserver(this, "domwindowopened", PR_FALSE);
|
||||
obsService->AddObserver(this, "domwindowclosed", PR_FALSE);
|
||||
|
||||
// Also register on any open windows that already exist, since we don't
|
||||
// get notifications for those.
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> watcher =
|
||||
do_GetService(NS_WINDOWWATCHER_CONTRACTID);
|
||||
if (watcher) {
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
watcher->GetWindowEnumerator(getter_AddRefs(enumerator));
|
||||
if (enumerator) {
|
||||
PRBool hasMore;
|
||||
|
||||
while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsISupports> item;
|
||||
enumerator->GetNext(getter_AddRefs(item));
|
||||
|
||||
nsCOMPtr<nsIDOMEventTarget> targ = do_QueryInterface(item);
|
||||
if (targ) {
|
||||
targ->AddEventListener(NS_LITERAL_STRING("DOMPageRestore"),
|
||||
NS_STATIC_CAST(nsIDOMLoadListener*, this),
|
||||
PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now read in the signon file
|
||||
nsXPIDLCString signonFile;
|
||||
mPrefBranch->GetCharPref("SignonFileName", getter_Copies(signonFile));
|
||||
@ -781,20 +747,6 @@ nsPasswordManager::Observe(nsISupports* aSubject,
|
||||
NS_ASSERTION(branch == mPrefBranch, "unexpected pref change notification");
|
||||
|
||||
branch->GetBoolPref("rememberSignons", &sRememberPasswords);
|
||||
} else if (!strcmp(aTopic, "domwindowopened")) {
|
||||
nsCOMPtr<nsIDOMEventTarget> targ = do_QueryInterface(aSubject);
|
||||
if (targ) {
|
||||
targ->AddEventListener(NS_LITERAL_STRING("DOMPageRestore"),
|
||||
NS_STATIC_CAST(nsIDOMLoadListener*, this),
|
||||
PR_FALSE);
|
||||
}
|
||||
} else if (!strcmp(aTopic, "domwindowclosed")) {
|
||||
nsCOMPtr<nsIDOMEventTarget> targ = do_QueryInterface(aSubject);
|
||||
if (targ) {
|
||||
targ->RemoveEventListener(NS_LITERAL_STRING("DOMPageRestore"),
|
||||
NS_STATIC_CAST(nsIDOMLoadListener*, this),
|
||||
PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -813,22 +765,16 @@ nsPasswordManager::OnStateChange(nsIWebProgress* aWebProgress,
|
||||
!(aStateFlags & nsIWebProgressListener::STATE_STOP))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWin;
|
||||
nsresult rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWin));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return DoPrefill(domWin);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPasswordManager::DoPrefill(nsIDOMWindow *aDOMWindow)
|
||||
{
|
||||
// Don't do anything if the global signon pref is disabled
|
||||
if (!SingleSignonEnabled())
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWin;
|
||||
nsresult rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWin));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aDOMWindow->GetDocument(getter_AddRefs(domDoc));
|
||||
domWin->GetDocument(getter_AddRefs(domDoc));
|
||||
NS_ASSERTION(domDoc, "DOM window should always have a document!");
|
||||
|
||||
// For now, only prefill forms in HTML documents.
|
||||
@ -1622,32 +1568,6 @@ nsPasswordManager::Error(nsIDOMEvent* aEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPasswordManager::PageRestore(nsIDOMEvent* aEvent)
|
||||
{
|
||||
// Only autofill for trusted events.
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(aEvent);
|
||||
PRBool trusted = PR_FALSE;
|
||||
if (nsevent)
|
||||
nsevent->GetIsTrusted(&trusted);
|
||||
if (!trusted)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMEventTarget> target;
|
||||
aEvent->GetTarget(getter_AddRefs(target));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(target);
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIDOMWindow> win =
|
||||
do_QueryInterface(doc->GetScriptGlobalObject());
|
||||
if (win) {
|
||||
return DoPrefill(win);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// internal methods
|
||||
|
||||
|
@ -136,7 +136,6 @@ public:
|
||||
NS_IMETHOD BeforeUnload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
|
||||
|
||||
// Autocomplete
|
||||
PRBool AutoCompleteSearch(const nsAString& aSearchString,
|
||||
@ -158,7 +157,6 @@ protected:
|
||||
nsresult FillPassword(nsIDOMEvent* aEvent);
|
||||
void AttachToInput(nsIDOMHTMLInputElement* aElement);
|
||||
PRBool GetPasswordRealm(nsIURI* aURI, nsACString& aRealm);
|
||||
nsresult DoPrefill(nsIDOMWindow *aDOMWindw);
|
||||
|
||||
static PLDHashOperator PR_CALLBACK FindEntryEnumerator(const nsACString& aKey,
|
||||
SignonHashEntry* aEntry,
|
||||
|
@ -880,12 +880,6 @@ nsFormFillController::Error(nsIDOMEvent *aLoadEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormFillController::PageRestore(nsIDOMEvent *aLoadEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//// nsFormFillController
|
||||
|
||||
|
@ -112,7 +112,6 @@ public:
|
||||
NS_IMETHOD Unload(nsIDOMEvent *aLoadEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent *aLoadEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent *aLoadEvent);
|
||||
NS_IMETHOD PageRestore(nsIDOMEvent* aLoadEvent);
|
||||
|
||||
nsFormFillController();
|
||||
virtual ~nsFormFillController();
|
||||
|
@ -260,7 +260,7 @@ if (window && (wintype == "navigator:browser"))
|
||||
{
|
||||
var contentArea = window.document.getElementById("appcontent");
|
||||
if (contentArea)
|
||||
contentArea.addEventListener("load", charsetLoadListener, true);
|
||||
contentArea.addEventListener("PageShow", charsetLoadListener, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -269,14 +269,14 @@ else
|
||||
{
|
||||
var messageContent = window.document.getElementById("messagepane");
|
||||
if (messageContent)
|
||||
messageContent.addEventListener("load", mailCharsetLoadListener, true);
|
||||
messageContent.addEventListener("PageShow", mailCharsetLoadListener, true);
|
||||
}
|
||||
else
|
||||
if (window && arrayOfStrings[0] == "composer")
|
||||
{
|
||||
contentArea = window.document.getElementById("appcontent");
|
||||
if (contentArea)
|
||||
contentArea.addEventListener("load", composercharsetLoadListener, true);
|
||||
contentArea.addEventListener("PageShow", composercharsetLoadListener, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -410,7 +410,7 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="onLoad">
|
||||
<method name="onPageShow">
|
||||
<parameter name="aEvent"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
@ -433,7 +433,7 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="onUnload">
|
||||
<method name="onPageHide">
|
||||
<parameter name="aEvent"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
@ -566,8 +566,8 @@
|
||||
}
|
||||
|
||||
// Listen for first load for lazy attachment to form fill controller
|
||||
this.addEventListener("load", this.onLoad, true);
|
||||
this.addEventListener("unload", this.onUnload, true);
|
||||
this.addEventListener("PageShow", this.onPageShow, true);
|
||||
this.addEventListener("PageHide", this.onPageHide, true);
|
||||
this.addEventListener("DOMPopupBlocked", this.onPopupBlocked, false);
|
||||
]]>
|
||||
</constructor>
|
||||
@ -606,8 +606,8 @@
|
||||
this._fastFind = null;
|
||||
this._webBrowserFind = null;
|
||||
|
||||
this.removeEventListener("load", this.onLoad, true);
|
||||
this.removeEventListener("unload", this.onUnload, true);
|
||||
this.removeEventListener("PageShow", this.onPageShow, true);
|
||||
this.removeEventListener("PageHide", this.onPageHide, true);
|
||||
this.removeEventListener("DOMPopupBlocked", this.onPopupBlocked, true);
|
||||
]]>
|
||||
</body>
|
||||
|
@ -142,6 +142,7 @@ nsDocLoader::nsDocLoader()
|
||||
mParent = nsnull;
|
||||
|
||||
mIsLoadingDocument = PR_FALSE;
|
||||
mIsRestoringDocument = PR_FALSE;
|
||||
|
||||
static PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
@ -1155,6 +1156,10 @@ void nsDocLoader::FireOnStateChange(nsIWebProgress *aProgress,
|
||||
aStateFlags &= ~nsIWebProgressListener::STATE_IS_NETWORK;
|
||||
}
|
||||
|
||||
// Add the STATE_RESTORING bit if necessary.
|
||||
if (mIsRestoringDocument)
|
||||
aStateFlags |= nsIWebProgressListener::STATE_RESTORING;
|
||||
|
||||
#if defined(DEBUG)
|
||||
nsCAutoString buffer;
|
||||
|
||||
|
@ -210,6 +210,9 @@ protected:
|
||||
|
||||
PLDHashTable mRequestInfoHash;
|
||||
|
||||
/* Flag to indicate that we're in the process of restoring a document. */
|
||||
PRBool mIsRestoringDocument;
|
||||
|
||||
private:
|
||||
nsListenerInfo *GetListenerInfo(nsIWebProgressListener* aListener);
|
||||
|
||||
|
@ -165,6 +165,22 @@ interface nsIWebProgressListener : nsISupports
|
||||
const unsigned long STATE_IS_WINDOW = 0x00080000;
|
||||
|
||||
|
||||
/**
|
||||
* State Modifier Flags
|
||||
*
|
||||
* These flags further describe the transition which is occuring. These
|
||||
* flags are NOT mutually exclusive (i.e., an onStateChange event may
|
||||
* indicate some combination of these flags).
|
||||
*
|
||||
* STATE_RESTORING
|
||||
* This flag indicates that the state transition corresponds to the start
|
||||
* or stop of activity for restoring a previously-rendered presentation.
|
||||
* As such, there is no actual network activity associated with this
|
||||
* request, and any modifications made to the document or presentation
|
||||
* when it was originally loaded will still be present.
|
||||
*/
|
||||
const unsigned long STATE_RESTORING = 0x01000000;
|
||||
|
||||
/**
|
||||
* State Security Flags
|
||||
*
|
||||
|
@ -92,6 +92,7 @@ class nsIURI;
|
||||
#define NS_BEFORE_PAGE_UNLOAD_EVENT 26
|
||||
#define NS_UI_EVENT 27
|
||||
#define NS_QUERYCARETRECT_EVENT 28
|
||||
#define NS_PAGETRANSITION_EVENT 29
|
||||
|
||||
#define NS_EVENT_FLAG_NONE 0x0000
|
||||
#define NS_EVENT_FLAG_INIT 0x0001
|
||||
@ -324,6 +325,11 @@ class nsIURI;
|
||||
#define NS_QUERYCARETRECT_START 2600
|
||||
#define NS_QUERYCARETRECT (NS_QUERYCARETRECT_START)
|
||||
|
||||
// pagetransition events
|
||||
#define NS_PAGETRANSITION_START 2700
|
||||
#define NS_PAGE_SHOW (NS_PAGETRANSITION_START + 1)
|
||||
#define NS_PAGE_HIDE (NS_PAGETRANSITION_START + 2)
|
||||
|
||||
/**
|
||||
* Return status for event processors, nsEventStatus, is defined in
|
||||
* nsEvent.h.
|
||||
@ -884,6 +890,21 @@ public:
|
||||
PRInt32 detail;
|
||||
};
|
||||
|
||||
/**
|
||||
* PageTransition event
|
||||
*/
|
||||
class nsPageTransitionEvent : public nsEvent
|
||||
{
|
||||
public:
|
||||
nsPageTransitionEvent(PRBool isTrusted, PRUint32 msg, PRBool p)
|
||||
: nsEvent(isTrusted, msg, NS_PAGETRANSITION_EVENT),
|
||||
persisted(p)
|
||||
{
|
||||
}
|
||||
|
||||
PRBool persisted;
|
||||
};
|
||||
|
||||
/**
|
||||
* Event status for D&D Event
|
||||
*/
|
||||
|
@ -131,8 +131,8 @@ function()
|
||||
linkToolbarUI.toolbarActive = true;
|
||||
document.getElementById("linktoolbar").setAttribute("hasitems", "true");
|
||||
var contentArea = document.getElementById("appcontent");
|
||||
contentArea.addEventListener("unload", linkToolbarUI.clear, true);
|
||||
contentArea.addEventListener("load", linkToolbarUI.deactivate, true);
|
||||
contentArea.addEventListener("PageHide", linkToolbarUI.clear, true);
|
||||
contentArea.addEventListener("PageShow", linkToolbarUI.deactivate, true);
|
||||
contentArea.addEventListener("DOMHeadLoaded", linkToolbarUI.deactivate,
|
||||
true);
|
||||
}
|
||||
@ -150,8 +150,8 @@ function()
|
||||
linkToolbarUI.toolbarActive = false;
|
||||
document.getElementById("linktoolbar").setAttribute("hasitems", "false");
|
||||
var contentArea = document.getElementById("appcontent");
|
||||
contentArea.removeEventListener("unload", linkToolbarUI.clear, true);
|
||||
contentArea.removeEventListener("load", linkToolbarUI.deactivate, true);
|
||||
contentArea.removeEventListener("PageHide", linkToolbarUI.clear, true);
|
||||
contentArea.removeEventListener("PageShow", linkToolbarUI.deactivate, true);
|
||||
contentArea.removeEventListener("DOMHeadLoaded", linkToolbarUI.deactivate,
|
||||
true);
|
||||
}
|
||||
@ -249,7 +249,7 @@ function()
|
||||
if (!linkToolbarUI.initialized)
|
||||
{
|
||||
linkToolbarUI.initialized = true;
|
||||
document.removeEventListener("load", linkToolbarUI.initHandlers, true);
|
||||
document.removeEventListener("PageShow", linkToolbarUI.initHandlers, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
||||
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
document.addEventListener("load", linkToolbarUI.initHandlers, true);
|
||||
document.addEventListener("PageShow", linkToolbarUI.initHandlers, true);
|
||||
]]>
|
||||
</script>
|
||||
|
||||
|
@ -248,7 +248,7 @@ function removePopupPermListener(observer)
|
||||
* one listener that calls all real handlers.
|
||||
*/
|
||||
|
||||
function loadEventHandlers(event)
|
||||
function pageShowEventHandlers(event)
|
||||
{
|
||||
// Filter out events that are not about the document load we are interested in
|
||||
if (event.originalTarget == content.document) {
|
||||
@ -554,7 +554,7 @@ function Startup()
|
||||
// (rjc note: not the entire window, otherwise we'll get sidebar pane loads too!)
|
||||
// so we'll be notified when onloads complete.
|
||||
var contentArea = document.getElementById("appcontent");
|
||||
contentArea.addEventListener("load", loadEventHandlers, true);
|
||||
contentArea.addEventListener("PageShow", pageShowEventHandlers, true);
|
||||
contentArea.addEventListener("focus", contentAreaFrameFocus, true);
|
||||
|
||||
var turboMode = false;
|
||||
|
@ -55,7 +55,7 @@ struct nsRect;
|
||||
%}
|
||||
[ref] native nsRect(nsRect);
|
||||
|
||||
[scriptable, uuid(e47bf412-3bc2-4306-a82f-ea2bdf950432)]
|
||||
[scriptable, uuid(a19c4489-4a71-42e1-b150-61366547030d)]
|
||||
interface nsISHEntry : nsIHistoryEntry
|
||||
{
|
||||
/** URI for the document */
|
||||
@ -102,9 +102,6 @@ interface nsISHEntry : nsIHistoryEntry
|
||||
*/
|
||||
void clearChildShells();
|
||||
|
||||
/** Saved security state for the content viewer */
|
||||
attribute nsISupports securityState;
|
||||
|
||||
/** Saved refresh URI list for the content viewer */
|
||||
attribute nsISupportsArray refreshURIList;
|
||||
|
||||
|
@ -500,20 +500,6 @@ nsSHEntry::ClearChildShells()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::GetSecurityState(nsISupports **aState)
|
||||
{
|
||||
NS_IF_ADDREF(*aState = mSecurityState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::SetSecurityState(nsISupports *aState)
|
||||
{
|
||||
mSecurityState = aState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::GetRefreshURIList(nsISupportsArray **aList)
|
||||
{
|
||||
@ -545,7 +531,6 @@ nsSHEntry::SyncPresentationState()
|
||||
mWindowState = nsnull;
|
||||
mViewerBounds.SetRect(0, 0, 0, 0);
|
||||
mChildShells.Clear();
|
||||
mSecurityState = nsnull;
|
||||
mRefreshURIList = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -95,7 +95,6 @@ private:
|
||||
nsCOMPtr<nsISupports> mWindowState;
|
||||
nsRect mViewerBounds;
|
||||
nsVoidArray mChildShells;
|
||||
nsCOMPtr<nsISupports> mSecurityState;
|
||||
nsCOMPtr<nsISupportsArray> mRefreshURIList;
|
||||
};
|
||||
|
||||
|
@ -283,7 +283,7 @@ if (window && (wintype == "navigator:browser"))
|
||||
{
|
||||
var contentArea = window.document.getElementById("appcontent");
|
||||
if (contentArea)
|
||||
contentArea.addEventListener("load", charsetLoadListener, true);
|
||||
contentArea.addEventListener("PageShow", charsetLoadListener, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -292,14 +292,14 @@ else
|
||||
{
|
||||
var messageContent = window.document.getElementById("messagepane");
|
||||
if (messageContent)
|
||||
messageContent.addEventListener("load", mailCharsetLoadListener, true);
|
||||
messageContent.addEventListener("PageShow", mailCharsetLoadListener, true);
|
||||
}
|
||||
else
|
||||
if (window && arrayOfStrings[0] == "composer")
|
||||
{
|
||||
contentArea = window.document.getElementById("appcontent");
|
||||
if (contentArea)
|
||||
contentArea.addEventListener("load", composercharsetLoadListener, true);
|
||||
contentArea.addEventListener("PageShow", composercharsetLoadListener, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user