Backed out changeset f8cccf3de0a3 (bug 842495) for crashtest failures on a CLOSED TREE.

This commit is contained in:
Ryan VanderMeulen 2013-02-27 17:08:26 -05:00
parent 4e23be6c04
commit c190fb7316
5 changed files with 62 additions and 35 deletions

View File

@ -116,6 +116,33 @@ HTMLFrameElement::GetAttributeMappingFunction() const
return &MapAttributesIntoRule;
}
already_AddRefed<nsIDocument>
HTMLFrameElement::GetContentDocument(ErrorResult& aRv)
{
nsCOMPtr<nsIDOMDocument> doc;
nsresult rv = nsGenericHTMLFrameElement::GetContentDocument(getter_AddRefs(doc));
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
nsCOMPtr<nsIDocument> ret = do_QueryInterface(doc);
return ret.forget();
}
already_AddRefed<nsIDOMWindow>
HTMLFrameElement::GetContentWindow(ErrorResult& aRv)
{
nsCOMPtr<nsIDOMWindow> win;
nsresult rv = nsGenericHTMLFrameElement::GetContentWindow(getter_AddRefs(win));
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
return win.forget();
}
JSObject*
HTMLFrameElement::WrapNode(JSContext* aCx, JSObject* aScope,
bool* aTriedToWrap)

View File

@ -102,8 +102,9 @@ public:
SetAttrHelper(nsGkAtoms::src, aSrc);
}
using nsGenericHTMLFrameElement::GetContentDocument;
using nsGenericHTMLFrameElement::GetContentWindow;
already_AddRefed<nsIDocument> GetContentDocument(ErrorResult& aRv);
already_AddRefed<nsIDOMWindow> GetContentWindow(ErrorResult& aRv);
protected:
virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope,

View File

@ -51,71 +51,69 @@ nsresult
nsGenericHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
{
NS_PRECONDITION(aContentDocument, "Null out param");
nsIDocument* document = GetContentDocument();
nsIDOMDocument* domDocument =
static_cast<nsIDOMDocument*>(document->AsDOMNode());
NS_ADDREF(*aContentDocument = domDocument);
*aContentDocument = nullptr;
nsCOMPtr<nsIDOMWindow> win;
GetContentWindow(getter_AddRefs(win));
if (!win) {
return NS_OK;
}
nsIDocument*
nsGenericHTMLFrameElement::GetContentDocument()
{
nsCOMPtr<nsPIDOMWindow> win = GetContentWindow();
return win ? win->GetDoc() : nullptr;
return win->GetDocument(aContentDocument);
}
nsresult
nsGenericHTMLFrameElement::GetContentWindow(nsIDOMWindow** aContentWindow)
{
NS_PRECONDITION(aContentWindow, "Null out param");
nsCOMPtr<nsPIDOMWindow> window = GetContentWindow();
window.forget(aContentWindow);
return NS_OK;
}
*aContentWindow = nullptr;
already_AddRefed<nsPIDOMWindow>
nsGenericHTMLFrameElement::GetContentWindow()
{
EnsureFrameLoader();
nsresult rv = EnsureFrameLoader();
NS_ENSURE_SUCCESS(rv, rv);
if (!mFrameLoader) {
return nullptr;
return NS_OK;
}
bool depthTooGreat = false;
mFrameLoader->GetDepthTooGreat(&depthTooGreat);
if (depthTooGreat) {
// Claim to have no contentWindow
return nullptr;
return NS_OK;
}
nsCOMPtr<nsIDocShell> doc_shell;
mFrameLoader->GetDocShell(getter_AddRefs(doc_shell));
nsCOMPtr<nsPIDOMWindow> win = do_GetInterface(doc_shell);
nsCOMPtr<nsPIDOMWindow> win(do_GetInterface(doc_shell));
if (!win) {
return nullptr;
return NS_OK;
}
NS_ASSERTION(win->IsOuterWindow(),
"Uh, this window should always be an outer window!");
return win.forget();
return CallQueryInterface(win, aContentWindow);
}
void
nsresult
nsGenericHTMLFrameElement::EnsureFrameLoader()
{
if (!GetParent() || !IsInDoc() || mFrameLoader || mFrameLoaderCreationDisallowed) {
// If frame loader is there, we just keep it around, cached
return;
return NS_OK;
}
mFrameLoader = nsFrameLoader::Create(this, mNetworkCreated);
if (!mFrameLoader) {
// Strangely enough, this method doesn't actually ensure that the
// frameloader exists. It's more of a best-effort kind of thing.
mFrameLoader = nsFrameLoader::Create(this, mNetworkCreated);
return NS_OK;
}
return NS_OK;
}
nsresult
@ -152,13 +150,14 @@ nsGenericHTMLFrameElement::SwapFrameLoaders(nsIFrameLoaderOwner* aOtherOwner)
nsresult
nsGenericHTMLFrameElement::LoadSrc()
{
EnsureFrameLoader();
nsresult rv = EnsureFrameLoader();
NS_ENSURE_SUCCESS(rv, rv);
if (!mFrameLoader) {
return NS_OK;
}
nsresult rv = mFrameLoader->LoadFrame();
rv = mFrameLoader->LoadFrame();
#ifdef DEBUG
if (NS_FAILED(rv)) {
NS_WARNING("failed to load URL");

View File

@ -90,11 +90,9 @@ protected:
// This doesn't really ensure a frame loade in all cases, only when
// it makes sense.
void EnsureFrameLoader();
nsresult EnsureFrameLoader();
nsresult LoadSrc();
nsIDocument* GetContentDocument();
nsresult GetContentDocument(nsIDOMDocument** aContentDocument);
already_AddRefed<nsPIDOMWindow> GetContentWindow();
nsresult GetContentWindow(nsIDOMWindow** aContentWindow);
nsRefPtr<nsFrameLoader> mFrameLoader;

View File

@ -24,7 +24,9 @@ interface HTMLFrameElement : HTMLElement {
attribute DOMString longDesc;
[SetterThrows]
attribute boolean noResize;
[GetterThrows]
readonly attribute Document? contentDocument;
[GetterThrows]
readonly attribute WindowProxy? contentWindow;
[TreatNullAs=EmptyString, SetterThrows] attribute DOMString marginHeight;