mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 709492 - Part 1: Add an observer that allows us to determine when a new page is shown. r=bz
This commit is contained in:
parent
b583d4c969
commit
22f3a217cb
@ -194,6 +194,8 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset
|
||||
//switch to page layout
|
||||
#include "nsGfxCIID.h"
|
||||
|
||||
#include "nsObserverService.h"
|
||||
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@ -509,6 +511,18 @@ public:
|
||||
nsCOMPtr<nsIDocument> mTop;
|
||||
};
|
||||
|
||||
class nsDocumentShownDispatcher : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsDocumentShownDispatcher(nsIDocument *aDocument)
|
||||
: mDocument(aDocument) {}
|
||||
|
||||
NS_IMETHOD Run();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// DocumentViewerImpl
|
||||
@ -2039,6 +2053,10 @@ DocumentViewerImpl::Show(void)
|
||||
}
|
||||
}
|
||||
|
||||
// Notify observers that a new page has been shown. (But not right now;
|
||||
// running JS at this time is not safe.)
|
||||
NS_DispatchToMainThread(new nsDocumentShownDispatcher(mDocument));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -4371,3 +4389,17 @@ DocumentViewerImpl::SetPrintPreviewPresentation(nsIViewManager* aViewManager,
|
||||
mPresContext = aPresContext;
|
||||
mPresShell = aPresShell;
|
||||
}
|
||||
|
||||
// Fires the "document-shown" event so that interested parties (right now, the
|
||||
// mobile browser) are aware of it.
|
||||
NS_IMETHODIMP
|
||||
nsDocumentShownDispatcher::Run()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
observerService->NotifyObservers(mDocument, "document-shown", NULL);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user