Bug 1014553 - Part 3: Replace AutoPushJSContext in nsContentUtils::IsPatternMatching. r=bholley

This commit is contained in:
Bob Owen 2014-05-27 16:44:01 +01:00
Родитель 3d30abba7d
Коммит 6a00348c08
1 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -39,6 +39,7 @@
#include "mozilla/dom/HTMLMediaElement.h"
#include "mozilla/dom/HTMLTemplateElement.h"
#include "mozilla/dom/HTMLContentElement.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/TextDecoder.h"
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/dom/ShadowRoot.h"
@ -6112,11 +6113,15 @@ nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern,
nsIDocument* aDocument)
{
NS_ASSERTION(aDocument, "aDocument should be a valid pointer (not null)");
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aDocument->GetWindow());
NS_ENSURE_TRUE(sgo, true);
nsCOMPtr<nsIGlobalObject> globalObject =
do_QueryInterface(aDocument->GetWindow());
if (NS_WARN_IF(!globalObject)) {
return true;
}
AutoPushJSContext cx(sgo->GetContext()->GetNativeContext());
NS_ENSURE_TRUE(cx, true);
AutoJSAPI jsapi;
JSContext* cx = jsapi.cx();
JSAutoCompartment ac(cx, globalObject->GetGlobalJSObject());
// The pattern has to match the entire value.
aPattern.Insert(NS_LITERAL_STRING("^(?:"), 0);