Commit 9beaf25c authored by yosin's avatar yosin Committed by Commit bot

Make ScriptCustomeElementDefinition class to hold ScriptState

This patch introduces |m_scriptState| member variable to
|ScriptCustomeElementDefinition| class to hold |ScriptState| pointer, to
return |ScriptValue| for JavaScript's constructor, prototype, callbacks,
etc, on the context where JavaScript values created.

This patch is a preparation of crrev.com/1994093002, introduce
|CustomElementRegistry#get()| method.

BUG=594918
TEST=n/a; no behavior changes

Review-Url: https://codereview.chromium.org/2030443003
Cr-Commit-Position: refs/heads/master@{#397069}
parent a4a128d5
......@@ -109,6 +109,7 @@ ScriptCustomElementDefinition::ScriptCustomElementDefinition(
const v8::Local<v8::Object>& constructor,
const v8::Local<v8::Object>& prototype)
: CustomElementDefinition(descriptor)
, m_scriptState(scriptState)
, m_constructor(scriptState->isolate(), constructor)
, m_prototype(scriptState->isolate(), prototype)
{
......@@ -119,18 +120,16 @@ ScriptCustomElementDefinition::ScriptCustomElementDefinition(
m_prototype.setPhantom();
}
v8::Local<v8::Object> ScriptCustomElementDefinition::constructor(
ScriptState* scriptState) const
v8::Local<v8::Object> ScriptCustomElementDefinition::constructor() const
{
DCHECK(!m_constructor.isEmpty());
return m_constructor.newLocal(scriptState->isolate());
return m_constructor.newLocal(m_scriptState->isolate());
}
v8::Local<v8::Object> ScriptCustomElementDefinition::prototype(
ScriptState* scriptState) const
v8::Local<v8::Object> ScriptCustomElementDefinition::prototype() const
{
DCHECK(!m_prototype.isEmpty());
return m_prototype.newLocal(scriptState->isolate());
return m_prototype.newLocal(m_scriptState->isolate());
}
} // namespace blink
......@@ -35,8 +35,8 @@ public:
virtual ~ScriptCustomElementDefinition() = default;
v8::Local<v8::Object> constructor(ScriptState*) const;
v8::Local<v8::Object> prototype(ScriptState*) const;
v8::Local<v8::Object> constructor() const;
v8::Local<v8::Object> prototype() const;
private:
ScriptCustomElementDefinition(
......@@ -45,6 +45,7 @@ private:
const v8::Local<v8::Object>& constructor,
const v8::Local<v8::Object>& prototype);
RefPtr<ScriptState> m_scriptState;
ScopedPersistent<v8::Object> m_constructor;
ScopedPersistent<v8::Object> m_prototype;
};
......
......@@ -67,7 +67,7 @@ void V8HTMLElement::constructorCustom(
if (!v8CallBoolean(wrapper->SetPrototype(
scriptState->context(),
def->prototype(scriptState)))) {
def->prototype()))) {
return;
}
}
......
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