Bug 761927, part 0: Add casting helpers and clean house a little. r=jlebar

This commit is contained in:
Chris Jones 2012-06-22 18:27:30 -07:00
parent 0cdf1d13a9
commit d17e510433
2 changed files with 35 additions and 10 deletions

View File

@ -523,6 +523,27 @@ TabParent::SendSelectionEvent(nsSelectionEvent& event)
return PBrowserParent::SendSelectionEvent(event);
}
/*static*/ TabParent*
TabParent::GetFrom(nsFrameLoader* aFrameLoader)
{
if (!aFrameLoader) {
return nsnull;
}
PBrowserParent* remoteBrowser = aFrameLoader->GetRemoteBrowser();
return static_cast<TabParent*>(remoteBrowser);
}
/*static*/ TabParent*
TabParent::GetFrom(nsIContent* aContent)
{
nsCOMPtr<nsIFrameLoaderOwner> loaderOwner = do_QueryInterface(aContent);
if (!loaderOwner) {
return nsnull;
}
nsRefPtr<nsFrameLoader> frameLoader = loaderOwner->GetFrameLoader();
return GetFrom(frameLoader);
}
bool
TabParent::RecvEndIMEComposition(const bool& aCancel,
nsString* aComposition)

View File

@ -7,26 +7,26 @@
#ifndef mozilla_tabs_TabParent_h
#define mozilla_tabs_TabParent_h
#include "base/basictypes.h"
#include "jsapi.h"
#include "mozilla/dom/PBrowserParent.h"
#include "mozilla/dom/PContentDialogParent.h"
#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "jsapi.h"
#include "nsCOMPtr.h"
#include "nsITabParent.h"
#include "nsIBrowserDOMWindow.h"
#include "nsWeakReference.h"
#include "nsIDialogParamBlock.h"
#include "nsIAuthPromptProvider.h"
#include "nsIBrowserDOMWindow.h"
#include "nsIDialogParamBlock.h"
#include "nsISecureBrowserUI.h"
#include "nsITabParent.h"
#include "nsWeakReference.h"
class nsFrameLoader;
class nsIURI;
class nsIDOMElement;
struct gfxMatrix;
struct JSContext;
struct JSObject;
class nsFrameLoader;
class nsIDOMElement;
class nsIURI;
namespace mozilla {
namespace dom {
@ -154,6 +154,10 @@ public:
bool SendCompositionEvent(nsCompositionEvent& event);
bool SendTextEvent(nsTextEvent& event);
bool SendSelectionEvent(nsSelectionEvent& event);
static TabParent* GetFrom(nsFrameLoader* aFrameLoader);
static TabParent* GetFrom(nsIContent* aContent);
protected:
bool ReceiveMessage(const nsString& aMessage,
bool aSync,