Commit d1c616ac authored by Tatiana Meshkova's avatar Tatiana Meshkova

PushNoJS into all DOMUtils calls

parent 9d4b17a0
......@@ -101,6 +101,7 @@ EmbedChromeListener::HandleEvent(nsIDOMEvent* aEvent)
uint32_t winid;
mService->GetIDByWindow(window, &winid);
NS_ENSURE_TRUE(winid , NS_ERROR_FAILURE);
mService->EnterSecureJSContext();
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(window);
if (type.EqualsLiteral(MOZ_DOMMetaAdded)) {
......@@ -123,6 +124,7 @@ EmbedChromeListener::HandleEvent(nsIDOMEvent* aEvent)
bool disabled = true;
disabledIface->GetMozDisabled(&disabled);
if (!disabledIface || disabled) {
mService->LeaveSecureJSContext();
return NS_OK;
}
disabledIface->GetHref(href);
......@@ -132,8 +134,10 @@ EmbedChromeListener::HandleEvent(nsIDOMEvent* aEvent)
nsCOMPtr<nsIDOMDocument> ownDoc;
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(origTarget);
node->GetOwnerDocument(getter_AddRefs(ownDoc));
if (ownDoc != ctDoc)
if (ownDoc != ctDoc) {
mService->LeaveSecureJSContext();
return NS_OK;
}
nsString charset, title, rel, type;
ctDoc->GetCharacterSet(charset);
......@@ -184,6 +188,7 @@ EmbedChromeListener::HandleEvent(nsIDOMEvent* aEvent)
nsCOMPtr<nsIDOMWindow> targetWin;
ctDoc->GetDefaultView(getter_AddRefs(targetWin));
if (targetWin != docWin) {
mService->LeaveSecureJSContext();
return NS_OK;
}
nsCOMPtr<nsIDOMWindowUtils> tutils = do_GetInterface(targetWin);
......@@ -200,12 +205,14 @@ EmbedChromeListener::HandleEvent(nsIDOMEvent* aEvent)
messageName.Append(type);
root->SetPropertyAsBool(NS_LITERAL_STRING("persisted"), persisted);
} else {
mService->LeaveSecureJSContext();
return NS_OK;
}
nsString outStr;
json->CreateJSON(root, message);
mService->SendAsyncMessage(winid, messageName.get(), message.get());
mService->LeaveSecureJSContext();
return NS_OK;
}
......@@ -157,6 +157,7 @@ void EmbedTouchListener::HandleDoubleTap(const CSSPoint& aPoint, int32_t, const
void
EmbedTouchListener::AnyElementFromPoint(nsIDOMWindow* aWindow, double aX, double aY, nsIDOMElement* *aElem)
{
mService->EnterSecureJSContext();
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(aWindow);
nsCOMPtr<nsIDOMElement> elem;
NS_ENSURE_SUCCESS(utils->ElementFromPoint(aX, aY, true, true, getter_AddRefs(elem)), );
......@@ -190,6 +191,7 @@ EmbedTouchListener::AnyElementFromPoint(nsIDOMWindow* aWindow, double aX, double
if (elem) {
NS_ADDREF(*aElem = elem);
}
mService->LeaveSecureJSContext();
return;
}
......@@ -324,7 +326,7 @@ EmbedTouchListener::GetBoundingContentRect(nsIDOMElement* aElement)
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement);
NS_ENSURE_TRUE(node, retRect);
nsCOMPtr<nsIDOMDocument> origDocument;
nsCOMPtr<nsIDOMDocument> document;
NS_ENSURE_SUCCESS(node->GetOwnerDocument(getter_AddRefs(document)), retRect);
......@@ -343,6 +345,7 @@ EmbedTouchListener::GetBoundingContentRect(nsIDOMElement* aElement)
return retRect;
}
mService->EnterSecureJSContext();
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(newWin);
int32_t scrollX = 0, scrollY = 0;
NS_ENSURE_SUCCESS(utils->GetScrollXY(false, &scrollX, &scrollY), retRect);
......@@ -373,6 +376,7 @@ EmbedTouchListener::GetBoundingContentRect(nsIDOMElement* aElement)
r->GetTop(&rtop);
r->GetWidth(&rwidth);
r->GetHeight(&rheight);
mService->LeaveSecureJSContext();
return gfx::Rect(rleft + scrollX,
rtop + scrollY,
......
......@@ -183,7 +183,6 @@ NS_IMETHODIMP nsEmbedFilePicker::Show(int16_t* _retval)
nsresult rv;
mService->EnterSecureJSContext();
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(mWin);
NS_ENSURE_TRUE(utils, NS_ERROR_FAILURE);
......@@ -338,10 +337,13 @@ nsEmbedFilePicker::GetDomfile(nsIDOMFile * *aDomfile)
return NS_OK;
}
mService->EnterSecureJSContext();
nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(mWin);
nsCOMPtr<nsIDOMFile> file;
utils->WrapDOMFile(localFile, getter_AddRefs(file));
file.forget(aDomfile);
mService->LeaveSecureJSContext();
return NS_OK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment