Commit 7c0d6aae authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Add a note/caution about ExecutionContext details

There are two ExecutionContexts; one of the creation realm, and the
other of the document tree.  Explains the difference in a document.

Change-Id: I9aa90c1d57fa4cb8528629f69e4209d1554a2109
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2307389Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789931}
parent 4977ba83
...@@ -650,6 +650,28 @@ Each value changes the signature of the Blink methods by adding an additional pa ...@@ -650,6 +650,28 @@ Each value changes the signature of the Blink methods by adding an additional pa
`[GetterCallWith]` and `[SetterCallWith]` apply to attributes, and only affects the signature of the getter and setter, respectively. `[GetterCallWith]` and `[SetterCallWith]` apply to attributes, and only affects the signature of the getter and setter, respectively.
NOTE: The `ExecutionContext` that you can get with [CallWith=ExecutionContext] or that you can extract from [CallWith=ScriptState] is the ExecutionContext associated with the V8 wrapper of the receiver object, which might be different from the ExecutionContext of the document tree to which the receiver object belongs. See the following example.
```js
// V8 wrapper of |span| is associated with |windowA|.
span = windowA.document.createElement("span");
// |span| belongs to the document tree of |windowB|.
windowB.document.body.appendChild(span);
```
```c++
// Suppose [CallWith=ExecutionContext] void foo();
void HTMLSpanElement::foo(ExecutionContext* execution_context) {
// The ExecutionContext associated with the creation context of the V8 wrapper
// of the receiver object.
execution_context; // the ExecutionContext of |windowA|
// Node::GetExecutionContext() returns the ExecutionContext of the document
// tree to which |this| (the receiver object) belongs.
GetExecutionContext(); // the ExecutionContext of |windowB|
}
```
#### [CallWith=ScriptState] _(m, a*)_ #### [CallWith=ScriptState] _(m, a*)_
`[CallWith=ScriptState]` is used in a number of places for methods. `[CallWith=ScriptState]` is used in a number of places for methods.
......
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