1. 序論
~pageが読込まれるに伴い, および利用者が読込まれた~pageとヤリトリする間、[ ~app, ~browser ]の両者とも,後で~browserにより実行されるような様々な~eventを~queueする — 例えば: ~UAは、 利用者の活動に基づいて入力~eventを~scheduleする / ~appは、 `requestAnimationFrame()$m 用の~callbackや他の~callback, 等々を~scheduleする。 ~queueされたこれらの~eventは、 ~browserにより 1 個ずつ~dequeueされ, 実行される。 ◎ As the page is loading and while the user is interacting with the page afterwards, both the application and browser queue various events that are then executed by the browser -- e.g. user agent schedules input events based on user’s activity, the application schedules callbacks for requestAnimationFrame and other callbacks, etc. Once in the queue, the browser dequeues these events one-by-one and executes them.
しかしながら,~taskには長い時間(複数の~frame)かかり得るものもあり、 それが起きた場合/とき, ~UI~threadは阻まれ,他のすべての~taskも阻まれる結果になり得る。 これは、 利用者からは[ 利用者~入力に対し~browserが応答-不能になり,~pageから “締め出される” ]ことにより,共通的に可視になる。 今日における~web上の不良な利用者~体験の大多数は、 それが~sourceにある: ◎ However, some tasks can take a long time (multiple frames) and if/when that happens, the UI thread may become blocked and block all other tasks as well. To the user, this is commonly visible as a "locked up" page where the browser is unable to respond to user input; this is a major source of bad user experience on the web today:
- “ヤリトリありになる時機” が遅延される: ◎ Delayed "time to Interactive":
- ~pageが読込まれる間,あるいは視覚的には完全に具現化されていても、 長い~taskは~main~thread~FN と~~連携することが多い — その結果、 利用者は~pageとヤリトリできなくなる。 よくある元凶として、 拙く設計された第三者-主体の内容が挙げられる。 ◎ while the page is loading, or even completely visually rendered, long tasks often tie up the main thread and prevent the user from interacting with the page. Poorly designed third-party content is frequently the culprit.
- 【~FN `~event~loopの処理@~WAPI#event-loop-processing-model$を遂行する~thread (`概略的な説明@https://developer.mozilla.org/docs/Glossary/Main_thread$)。 】
- 入力の待時間が~~長い/可変: ◎ High/variable input latency:
- ~criticalな利用者ヤリトリ~event (例: `tap^en, `click^en, `scroll^en, `wheel^en, 等々) は、 長い~taskの背後に~queueされ,即応しない — その結果、 利用者~体験は予測-不能になる。 ◎ critical user-interaction events (e.g. tap, click, scroll, wheel, etc.) are queued behind long tasks which yields janky and unpredictable user experience.
- ~event取扱いの待時間が~~長い/可変: ◎ High/variable event handling latency:
- 入力~同様、 ~event~callback(例: `onload^et ~event, 等々)の処理は, ~appの更新を遅延する。 ◎ like input, processing event callbacks (e.g. onload events, etc.) delay application updates.
- 即応しない[ ~animation/~scrolling ]: ◎ Janky animations and scrolling:
- 一部の[ ~animation/~scrolling ]は、 組成器と~main~threadとの間の協調を要求する — 長い~taskが~main~threadを阻んでいる場合、[ ~animation/~scrolling ]の応答性に影響し得る。 ◎ some animation and scrolling interactions require coordination between compositor and main threads; if a long task is blocking the main thread it can affect responsiveness of animations and scrolling.
一部の~app (および `RUM@https://en.wikipedia.org/wiki/Real_user_monitoring$ ~vendor 【 `Real User Monitoring^en / “現実の利用者~体験の監視” 】 )は、 すでに, “長い~task” が起こる事例を識別して追跡するよう試みている。 一例として、 短い周期的な~timerを~installした上で,各~満了から次回の満了までに経過した時間を検分する~patternが知られている。 経過した時間が~timer周期を超えるならば、 1 個~以上の長い~taskが~event~loopの実行を遅延させた見込みが高いことになる。 この~approachは、 大体は働くが,いくつかの点で処理能に~~悪影響を及ぼす: ◎ Some applications (and RUM vendors) are already attempting to identify and track cases where "long tasks" happen. For example, one known pattern is to install a short periodic timer and inspect the elapsed time between the successive expirations: if the elapsed time is greater than the timer period, then there is high likelihood that one or more long tasks have delayed execution of the event loop. This approach mostly works but has several bad performance implications:\
- 長い~taskを検出するために~pollし続けることにより、 ~appが遊休~時に走らす~codeに割り当てられる “静止期間” が細切れになる ( `requestIdleCallback()$m を見よ)。 ◎ by polling to detect long tasks, the application prevents quiescence and long idle blocks (see requestIdleCallback);\
- ~batteryが短命になる。 ◎ it’s bad for battery life;\
- 何が遅延させているか知るすべが無い (例:当事者-主体, 第三者-主体 どちらの~codeか?)。 ◎ there is no way to know what is causing the delay (e.g. first party or third party code).
`RAIL@https://developers.google.com/web/fundamentals/performance/rail$ ( `Response Animation Idle Load^en )処理能~modelから、[ ~appは,利用者~入力に対し 100ms 以内に応答するべきである ]と示唆されている (~touchによる移動-や~scrollingにおいては 16ms 以内)。 【 ms は~milli秒単位を表す(以下同様)。】 この~APIの目標は、 この~~目的に抵触し得る~taskについての通知を表面化することである。 この~APIは、 50ms 以上かかる~taskを表面化する。 そのような~taskを伴わない~web~siteならば、 利用者~入力に対し — それを受信した時点で実行-中な~taskが完遂するまで 50ms 未満, それに反応する~taskを実行するのも 50ms 未満になるので — 100ms 以内に応答することになるはずである。 ◎ The RAIL performance model suggests that applications should respond to user input in less than 100ms (for touch move and scrolling, the threshold is 16ms). The goal of this API is to surface notifications about tasks that may prevent the application from hitting these targets. This API surfaces tasks that take 50ms or more. A website without these tasks should respond to user input in under 100ms: it will take less than 50ms to finish the task that is being executed when the user input is received and less than 50ms to execute the task to react to such user input.
1.1. 用例
const %observer = new PerformanceObserver(function(%list) {
for (const %entry of %list.getEntries()) {
/*
長い~task通知を処理する:解析と監視~用に報告する…
◎
Process long task notifications: report back for analytics and monitoring ...
*/
}
});
/*
これまで, および未来における長い~animation~frameの通知~用に観測器を登録する。
以降,
~main~threadが長い期間~多忙な所では、
観測器にて `long-animation-frame^l ~entryが~queueされ,受信されるようになる。
◎
Register observer for previous and future long animation frame notifications. After this, long periods where the main thread is busy will result in queueing and receiving "long-animation-frame" entries in the observer.
*/
%observer.observe({type: "long-animation-frame", buffered: true});
1.2. 長い~animation~frameと長い~taskの違い
`長い~task$も, `長い~animation~frame$も,輻輳や非即応性( `jank^en )を測定するが、 長い~animation~frameは, この種の輻輳を利用者が どう知覚するかに もっと相関する情報を供する — 長い~animation~frameは、 ~main~threadが遊休になったときから[ 当の~frameが描画されるか,~UAが描画するものは何も無いと裁定する ]ときまでを成す ある `sequence^en を測定するので。 ◎ While both long tasks and long animation frames measure congestion and jank, long animation frames provide information that has a better correlation with how users perceive this type of congestion. That’s because long animation frames measure a sequence that begins when the main thread is idle, and end when the frame either renders or the user agents decides there is nothing to render.
`~task$には、 実装の詳細に委ねられる部分がある。 この仕様が追加する長い~animation~frame用の~APIは、 それを補償するよう試みる — 同じ[ ~main~threadの[ 輻輳/非即応性 ]を成す現象 ]に関して,もっと利用者~中心な計量を導入することにより。 ◎ The task term is somewhat of an implementation detail, and the long animation frame addition attempts to remedy that by introducing a more user-centric metric of the same phenomenon of main thread congestion/jank.
長い~animation~frameは, 1 回の描画~相にかかる最大を有することが保証されるので、 描画~相~自体について追加的な情報を公開するためにも利用できる — `renderStart$m や `styleAndLayoutStart$m など。 ◎ Because long animation frames are guaranteed to have a maximum of one rendering phase, we can also use them to expose additional information about the rendering phase itself, such as renderStart and styleAndLayoutStart.
【この訳に特有な表記規約】
◎表記記号この仕様に現れる時刻や時間の量 — `~moment$や`所要時間$など — には,特定の単位は含意されないが、[ `DOMHighResTimeStamp$I 型の値を期待する文脈/ 加算などの算術~演算/ 他の数との比較 ]に利用される所では, `暗黙的に~milli秒数に換算される@~HRTIME#dfn-implicitly-convert-a-duration-to-a-timestamp$とする。
2. 長い~animation~frameの計時
`長い~animation~frame@ とは、[ `描画を更新する手続き$で描画を更新することが必要yあり得る`~task$ ]のうち[ 必要yでない場合,そのことが判明するまで/ 必要yである場合,当の~taskの終了まで ]の所要時間が 50ms を超過するものを指す。 ◎ A long animation frame refers to any of the following occurrences whose duration exceeds 50ms: • A task, after which updating the rendering is not necessary. • A task after which updating the rendering is necessary, up until rendering is updated.
長い~animation~frameの計時は、 この節に与える新たな~interfaceを孕む。 ◎ Long Animation Frame timing involves the following new interfaces:
2.1. `PerformanceLongAnimationFrameTiming^I ~interface
[`Exposed$=Window]
interface `PerformanceLongAnimationFrameTiming@I : `PerformanceEntry$I {
/*
`PerformanceEntry$I の~memberを多重定義する:
◎
Overloading PerformanceEntry
*/
readonly attribute `DOMHighResTimeStamp$I `startTime$m1;
readonly attribute `DOMHighResTimeStamp$I `duration$m1;
readonly attribute `DOMString$ `name$m1;
readonly attribute `DOMString$ `entryType$m1;
readonly attribute `DOMHighResTimeStamp$I `renderStart$m;
readonly attribute `DOMHighResTimeStamp$I `styleAndLayoutStart$m;
readonly attribute `DOMHighResTimeStamp$I `styleDuration$m;
readonly attribute `DOMHighResTimeStamp$I `layoutDuration$m;
readonly attribute `DOMHighResTimeStamp$I `blockingDuration$m;
readonly attribute `DOMHighResTimeStamp$I `firstUIEventTimestamp$m;
[`SameObject$] readonly attribute `FrozenArray$<`PerformanceScriptTiming$I> `scripts$m;
[`Default$] `object$ `toJSON@m1();
};
`PerformanceLongAnimationFrameTiming$I includes `PaintTimingMixin$I;
各 `PerformanceLongAnimationFrameTiming$I ~objは、 `計時~報@ を有する — それは、 `~frame計時~報$である。 ◎ A PerformanceLongAnimationFrameTiming has a frame timing info timing info.
`duration@m1 取得子~手続きは:
- %開始~時刻 ~LET コレの `startTime$m1【!`startTime$m】 の値
- %終了~時刻 ~LET コレの `paintTime$m の値
- ~IF[ %終了~時刻 ~EQ 0 ] ⇒ %終了~時刻 ~SET `相対的な高分解能~時刻$( コレの`計時~報$の`終了~時刻$ftI, コレに`関連な大域~obj$ )
- ~RET `所要時間を得る$( %開始~時刻, %終了~時刻 )
`renderStart@m 取得子~手続きは: ◎ The renderStart attribute’s getter step is to\
- %開始~時刻 ~LET コレの`計時~報$の`描画~更新の開始~時刻$ftI ◎ ↓
- ~IF[ %開始~時刻 ~EQ 0 ] ⇒ ~RET 0 ◎ return 0 if this’s timing info’s update the rendering start time is 0;\
- ~RET `相対的な高分解能~時刻$( %開始~時刻, コレに`関連な大域~obj$ ) ◎ otherwise the relative high resolution time given this’s timing info’s update the rendering start time and this’s relevant global object.
`styleAndLayoutStart@m 取得子~手続きは: ◎ The styleAndLayoutStart attribute’s getter step is to\
- %開始~時刻 ~LET コレの`計時~報$の`~styleや~layoutの開始~時刻$ftI ◎ ↓
- ~IF[ %開始~時刻 ~EQ 0 ] ⇒ ~RET 0 ◎ return 0 if this’s timing info’s style and layout start time is 0;\
- ~RET `相対的な高分解能~時刻$( %開始~時刻, コレに`関連な大域~obj$ ) ◎ otherwise the relative high resolution time given this’s timing info’s style and layout start time and this’s relevant global object.
どの `PerformanceLongAnimationFrameTiming$I ~objも, 次を満たすモノトスル: ◎ For every PerformanceLongAnimationFrameTiming entry,\
- その `styleDuration$m ~PLUS その `layoutDuration$m ~LTE 次の結果 ⇒ `所要時間を得る$( ↓ ) ⇒# その `styleAndLayoutStart$m, その `startTime$m1 ~PLUS その `duration$m1 ◎ the sum of entry’s styleDuration and layoutDuration MUST be less than or equal to the duration between entry’s styleAndLayoutStart and entry’s startTime + entry’s duration.\
- その`計時~報$の`描画~更新の開始~時刻$ftI ~EQ 0 の場合 (すなわち,当の~frameには描画~更新は無い場合)、 その[ `styleDuration$m, `layoutDuration$m ]は,どちらも 0 になる。 ◎ If entry’s timing info’s update the rendering start time is 0, i.e. the frame did not include a rendering update, then entry’s styleDuration and layoutDuration MUST both be 0.
注記: 所要時間[ `styleDuration$m / `layoutDuration$m ]は、 描画~更新を成す一部として[ ~styleを再計算する/~layoutを更新する ]ことに費やした時間を表現する。 それらの総和は、 `styleAndLayoutStart$m から `paintTime$m の値までの所要時間~未満になる — その期間には[ これらの所要時間には含まれない他の作業 ( `ResizeObserver$I ~callbackを走らす, 交差~観測nを更新するなど) も含まれ得るので。 ~scriptにより同期的に遂行される[ ~style/~layout ]は含まれない — それらは、 代わりに[ `forcedStyleDuration$m, `forcedLayoutDuration$m ]を介して報告される。 ◎ Note: styleDuration and layoutDuration represent the time spent recalculating styles and updating layout, respectively, as part of the rendering update. Their sum can be less than the duration between styleAndLayoutStart and paintTime, as that period can also include other work that is not included in these durations, such as running ResizeObserver callbacks or updating intersection observations. Style and layout performed synchronously by scripts are not included, and are reported via forcedStyleDuration and forcedLayoutDuration instead.
`firstUIEventTimestamp@m 取得子~手続きは: ◎ The firstUIEventTimestamp attribute’s getter steps are:
- %時刻印 ~LET コレの`計時~報$の`最初の~UI~event時刻印$ftI ◎ Let timestamp be this’s timing info’s first ui event timestamp.
- ~IF[ %時刻印 ~EQ 0 ] ⇒ ~RET 0 ◎ If timestamp is null, then return 0.
- ~RET `相対的な粗い高分解能~時刻$( %時刻印, コレに`関連な大域~obj$ ) ◎ Return the relative high resolution coarse time given timestamp and this’s relevant global object.
`blockingDuration@m 取得子~手続きは: ◎ The blockingDuration attribute’s getter steps are:
- %~sort済み~task所要時間~群 ~LET `~listを降順に~sortする$( コレの`計時~報$の`~task所要時間~群$ftI ) ◎ Let sortedTaskDurations be this’s timing info’s task durations, sorted in descending order.
-
~IF[ コレの`計時~報$の`描画~更新の開始~時刻$ftI ~NEQ 0 ]: ◎ If this’s timing info’s update the rendering start time is not zero, then:
- %描画-終了~時刻 ~LET コレの `paintTime$m の値 ◎ Let renderEndTime be this’s paintTime\
- ~IF[ %描画-終了~時刻 ~EQ 0 ] ⇒ %描画-終了~時刻 ~SET `相対的な高分解能~時刻$( コレの`計時~報$の`終了~時刻$ftI, コレに`関連な大域~obj$ ) ◎ if this’s paintTime is not 0; otherwise the relative high resolution time given this’s timing info’s end time and this’s relevant global object.
- %描画-所要時間 ~LET `所要時間を得る$( コレの `renderStart$m の値, %描画-終了~時刻 ) ◎ Let renderDuration be the duration between this’s renderStart and renderEndTime.
- ~IF[ %~sort済み~task所要時間~群 は`空$である ] ⇒ %~sort済み~task所要時間~群 に %描画-所要時間 を`付加する$ ◎ If sortedTaskDurations is empty, then append renderDuration to sortedTaskDurations.
-
~ELSE ⇒ %~sort済み~task所要時間~群[ 0 ] ~INCBY %描画-所要時間 ◎ Otherwise, increment sortedTaskDurations[0] by renderDuration.
注記: これは、 最も長い~taskの所要時間に対しては,[ 【それ自体ではなく,】それに描画-所要時間を加算した結果 ]が 50ms を超える場合に[ 他を阻んだものと見なされる ]ようにする。 ◎ Note: This makes it so that the longest task duration + render duration would be considered blocking if their total duration is >50ms.
- %他を阻んだ所要時間の合計 ~LET 0 ◎ Let totalBlockingDuration be 0.
- %~sort済み~task所要時間~群 を成す ~EACH( %所要時間 ) に対し ⇒ ~IF[ %所要時間 ~GT 50 ] ⇒ %他を阻んだ所要時間の合計 ~INCBY %所要時間 ~MINUS 50 ◎ For each duration in sortedTaskDurations, if duration is greater than 50 then increment totalBlockingDuration by duration - 50.
- ~RET %他を阻んだ所要時間の合計 ◎ Return totalBlockingDuration.
`scripts@m 取得子~手続きは: ◎ The scripts attribute’s getter steps are:
- %~script群 ~LET 新たな`~list$ ◎ Let scripts be a list « ».
- %入口~window ~LET コレに`関連な大域~obj$ ◎ Let entryWindow be this’s relevant global object.
-
コレの`~frame計時~報$の`~script群$ftIを成す ~EACH( %~script報 ) に対し: ◎ For each scriptInfo in this’s frame timing info’s scripts:
- %~script~window ~LET %~script報 の`~window$stI 【に対し, `deref$c を~callした結果】 ◎ Let scriptWindow be scriptInfo’s window.
- %~script~entry ~LET `新たな~obj$( `PerformanceScriptTiming$I, コレに`関連な~realm$ ) ◎ Let scriptEntry be a new PerformanceScriptTiming in this’s relevant realm,\
- %~script~entry の`計時~報$psT ~SET %~script報 ◎ whose timing info is scriptInfo and\
-
%~script~entry の`~window帰属$psT ~SET 次の手続きを遂行した結果: ◎ whose window attribution is the value corresponding to the first matching statement:
手続きは:
- ~IF[ %~script~window ~EQ `undefined^jv ]~OR[ %~script~window に`結付けられた文書$は`全部的に作動中$でない ] ⇒ ~RET `other$swA ◎ scriptWindow is undefined or\ scriptWindow’s associated Document is not fully active • other
- ~IF[ %~script~window ~EQ %入口~window ] ⇒ ~RET `self$swA ◎ scriptWindow is entryWindow • self
- %~script~navigable ~LET %~script~window に`結付けられた文書$の`~node~navigable$ ◎ ↓
- %入口~navigable ~LET %入口~window に`結付けられた文書$の`~node~navigable$ ◎ ↓
- ~IF[ %~script~navigable ~IN %入口~navigable の`先祖~navigable群$ ] ⇒ ~RET `ancestor$swA ◎ entryWindow’s associated Document’s node navigable’s ancestor navigables contains scriptWindow’s associated Document’s node navigable • ancestor
- ~IF[ %入口~navigable ~IN %~script~navigable の`先祖~navigable群$ ] ⇒ ~RET `descendant$swA ◎ scriptWindow’s associated Document’s node navigable’s ancestor navigables contains entryWindow’s associated Document’s node navigable • descendant
- ~IF[ %入口~navigable の`~top-level辿可能$nav ~EQ %~script~navigable の`~top-level辿可能$nav ] ⇒ ~RET `same-page$swA ◎ entryWindow’s associated Document’s node navigable’s top-level traversable is scriptWindow’s associated Document’s node navigable’s top-level traversable • same-page
- ~RET `other$swA ◎ Otherwise • other.
- %~script群 に %~script~entry を`付加する$ ◎ Append scriptEntry to scripts.
- ~RET %~script群 ◎ Return scripts.
2.2. `PerformanceScriptTiming^I ~interface
enum `ScriptInvokerType@I {
`classic-script@siT,
`module-script@siT,
`event-listener@siT,
`user-callback@siT,
`resolve-promise@siT,
`reject-promise@siT
};
enum `ScriptWindowAttribution@I {
`self@swA,
`descendant@swA,
`ancestor@swA,
`same-page@swA,
`other@swA
};
[`Exposed$=Window]
interface `PerformanceScriptTiming@I : `PerformanceEntry$I {
/*
`PerformanceEntry$I の~memberを多重定義する:
◎
Overloading PerformanceEntry
*/
readonly attribute `DOMHighResTimeStamp$I `startTime$m1;
readonly attribute `DOMHighResTimeStamp$I `duration$m1;
readonly attribute `DOMString$ `name$m1;
readonly attribute `DOMString$ `entryType$m1;
readonly attribute `ScriptInvokerType$I `invokerType$m;
readonly attribute `DOMString$ `invoker$m;
readonly attribute `DOMHighResTimeStamp$I `executionStart$m;
readonly attribute `DOMString$ `sourceURL$m;
readonly attribute `DOMString$ `sourceFunctionName$m;
readonly attribute `long long$ `sourceCharPosition$m;
readonly attribute `long long$ `sourceLine$m;
readonly attribute `long long$ `sourceColumn$m;
readonly attribute `DOMHighResTimeStamp$I `pauseDuration$m;
readonly attribute `DOMHighResTimeStamp$I `forcedStyleAndLayoutDuration$m;
readonly attribute `DOMHighResTimeStamp$I `forcedStyleDuration$m;
readonly attribute `DOMHighResTimeStamp$I `forcedLayoutDuration$m;
readonly attribute `Window$I? `window$m;
readonly attribute `ScriptWindowAttribution$I `windowAttribution$m;
[`Default$] `object$ `toJSON@m1();
};
各 `PerformanceScriptTiming$I には、 次に挙げるものが結付けられる: ◎ ↓
- `計時~報@psT ⇒ ある`~script計時~報$ ◎ A PerformanceScriptTiming has an associated script timing info timing info.
- `~window帰属@psT ⇒ ある `ScriptWindowAttribution$I ◎ A PerformanceScriptTiming has an associated ScriptWindowAttribution window attribution.
`invoker@m 取得子~手続きは: ◎ The invoker attribute’s getter steps are:
- %~target名 ~LET %計時~報 の`呼出元の名前$stI ◎ ↓↓
- %計時~報 ~LET コレの`計時~報$psT ◎ ↓
-
%計時~報 の`呼出元~種別$stI【!`invokerType$m】に応じて: ◎ Switch on this’s invokerType:
- `classic-script$siT/ `module-script$siT ⇒ ~RET %計時~報 の`~source~URL$stI ◎ "`classic-script`" "`module-script`" • Return this’s timing info’s source url.
-
`event-listener$siT ◎ "`event-listener`"
- %結果 ~LET « %~target名 » ◎ Let targetName be this’s timing info’s invoker name.
- ~IF[ %計時~報 の`~event~target要素の~ID$stI ~NEQ 空~文字列 ] ⇒ %結果 に次を順に`付加する$ ⇒# `#^l, %計時~報 の`~event~target要素の~ID$stI ◎ If this’s timing info’s event target element id is not the empty string, then: Set targetName to the concatenation of « targetName, "#", this’s timing info’s event target element id ».
- ~ELIF[ %計時~報 の`~event~target要素の~src属性$stI ~NEQ 空~文字列 ] ⇒ %結果 に次を順に`付加する$ ⇒# `[src=\"^l, %計時~報 の`~event~target要素の~src属性$stI, `\"]^l ◎ Otherwise, if this’s timing info’s event target element src attribute is not the empty string, then: Set targetName to the concatenation of « targetName, "[src=\"", this’s timing info’s event target element src attribute, "\"]" ».
- %結果 に次を順に`付加する$ ⇒# `.on^l, %計時~報 の`~event型$stI ◎ Return the concatenation of « targetName, ".on", this’s timing info’s event type ».
- ~RET %結果 を`連結する$ ◎ ↑
これはちょっと慣習に倣っただけに感じる — 名前の生成を論じる必要がある。 ◎ this feels a bit custom, need to discuss name generation.
- `user-callback$siT ⇒ ~RET %~target名 ◎ "`user-callback`" • Return this’s timing info’s invoker name.
- `resolve-promise$siT ⇒ ~RET 次を順に`連結する$ ⇒# %~target名, `.^l, `then^l ◎ ↓
- `reject-promise$siT ⇒ ~RET 次を順に`連結する$ ⇒# %~target名, `.^l, `catch^l ◎ "`resolve-promise`" "`reject-promise`" • Let thenOrCatch be "`then`" if this’s invokerType is "`resolve-promise`"; otherwise "`catch`". • Return the concatenation of « this’s timing info’s invoker name, ".", thenOrCatch ».
`executionStart@m 取得子~手続きは:
- %実行~開始~時刻 ~LET コレの`計時~報$psTの`実行~開始~時刻$stI
- ~IF[ %実行~開始~時刻 ~EQ 0 ] ⇒ ~RET 0
- ~RET `相対的な高分解能~時刻$( %実行~開始~時刻, コレに`関連な大域~obj$ )
注記: [ `forcedStyleDuration$m / `forcedLayoutDuration$m ]は、 当の~scriptが走っていた間に同期的に[ ~styleを再計算する/~layoutを更新する ]こと~FNに費やした時間を表現する (~FN 例:[ `getComputedStyle()$m / `getBoundingClientRect()$m ]を~callすることにより)。 `§ ~styleや~layoutの監視-法@#style-and-layout-monitoring$ を見よ。 ◎ Note: forcedStyleDuration and forcedLayoutDuration represent the time spent recalculating styles and updating layout, respectively, synchronously while the script was running, e.g. when it called getComputedStyle() or getBoundingClientRect(). See § 3.2.3 Style and Layout Monitoring.
`window@m 取得子~手続きは: ◎ The window attribute’s getter steps are:
- %~window ~LET コレの`計時~報$psTの`~window$stIに対し, `deref$c を~callした結果 ◎ Let window be the result of calling deref on this’s timing info’s window.
- ~IF[ %~window ~EQ `undefined^jv ]~OR[ %~window に`結付けられた文書$は`全部的に作動中$でない ] ⇒ ~RET ~NULL ◎ If window is undefined or window’s associated Document is not fully active, then return null;\
- ~RET %~window ◎ otherwise return window.
3. 処理~model
注記: 長い~animation~frame用の~APIを実装している~UAは、 `~window$が`~supportする~entry型~群$【!`supportedEntryTypes$m】に `long-animation-frame^l を含める必要がある。 ◎ Note: A user agent implementing the Long Animation Frame API would need to include "long-animation-frame" in supportedEntryTypes for Window contexts, respectively.
3.1. ~frame計時~報
`~frame計時~報@ は、 次に挙げる`~item$sctを有する`構造体$であり, 長い~animation~frame用の~algoにおいて内部状態管理に利用される: ◎ frame timing info is a struct used as a bookkeeping detail by the long animation frame algorithms. It has the following items:
- `開始~時刻@ftI ◎ start time
- `現在の~taskの開始~時刻@ftI ◎ current task start time
- `描画~更新の開始~時刻@ftI ◎ update the rendering start time
- `~styleや~layoutの開始~時刻@ftI ◎ style and layout start time
- `終了~時刻@ftI ◎ end time
- いずれも,ある `DOMHighResTimeStamp$I — 初期~時は 0 とする。 ◎ A DOMHighResTimeStamp, initially 0.\
- 注記: これらの時刻印は,`安全ではない@~HRTIME#monotonic-clock-unsafe-current-time$ので、 ~APIを介して公開する際には,`粗化-$されるベキである。 ◎ Note: these timestamps are unsafe, and should be coarsened when exposed via an API.
- `最初の~UI~event時刻印@ftI ◎ first ui event timestamp
- ~NULL /ある`粗化-$された`~moment$~FN `on the^en `単調増加~時計$ — 初期~時は ~NULL とする。 ◎ Null or a coarsened moment on the monotonic clock, initially null.
- 【~FN `~moment$の定義~自体が`粗化-$されたことも含意するので、 冗長な記述。 】
- `~style所要時間@ftI ◎ style duration
- ある【`粗化-$された】 `DOMHighResTimeStamp$I 【!representing a number of milliseconds】 — 初期~時は 0 とする。 ◎ A DOMHighResTimeStamp representing a number of milliseconds, initially 0.
- `~layout所要時間@ftI ◎ layout duration
- ある【`粗化-$された】 `DOMHighResTimeStamp$I 【!representing a number of milliseconds】 — 初期~時は 0 とする。 ◎ A DOMHighResTimeStamp representing a number of milliseconds, initially 0.
- `~styleや~layoutの~stack@ftI ◎ style and layout stack
- 次に挙げる値たちが成す`~stack$ — 初期~時は空とする ⇒# `~style^i, `~layout^i, `~script^i ◎ A stack of "`style`", "`layout`", and "`script`" strings, initially empty.\
- これは、 【入子にされた】進捗-中な[ ~style再計算/~layout更新/~script ]たちを表現する — 最も内縁なものが上端【末尾】に来る。 ◎ It represents the style recalculations, layouts, and scripts that are in progress, with the innermost one at the top.
- `~styleや~layoutの~stackの変更~時刻@ftI ◎ style and layout stack change time
- ある `DOMHighResTimeStamp$I — 初期~時は 0 とする。 ◎ A DOMHighResTimeStamp, initially 0,\
- これは、 `~styleや~layoutの~stack$ftIが最後に改変された時刻を`粗化-$した結果を表現する。 ◎ representing the coarsened time at which the style and layout stack was last modified.
- `~styleや~layoutの期間~群@ftI ◎ style and layout periods
- `~styleか~layoutの期間$【!`~styleや~layoutの期間~群$ftI】たちが成す`~list$ — 初期~時は空とする。 ◎ A list of style and layout periods, initially empty.\
- これは、 ~scriptが走っていなかった間に遂行された[ ~style再計算や~layout更新 ]たちの期間を保持する。 ◎ It holds the style recalculations and layouts that were performed while no script was running.
- `非同一-生成元~能力は隔離されるか@ftI ◎ cross-origin isolated capability
- ある真偽値 — 初期~時は ~F とする。 ◎ A boolean, initially false,\
- これは、[ ~styleや~layout ]の所要時間を算出するために利用される`時刻を粗化する$際に利用される。 ◎ used to coarsen the times from which style and layout durations are computed.
- `~task所要時間~群@ftI ◎ task durations
- `DOMHighResTimeStamp$I たちが成す`~list$ — 初期~時は空とする。 ◎ A list of DOMHighResTimeStamp, initially empty.
- `~script群@ftI ◎ scripts
- `~script計時~報$たちが成す`~list$ — 初期~時は空とする。 ◎ A list of script timing info, initially empty.
- `処理待ち~script@ftI ◎ pending script
- ~NULL /ある`~script計時~報$ — 初期~時は ~NULL とする。 ◎ Null or a script timing info, initially null.
- `~scriptから起動されたか@ftI ◎ script initiated
- ある真偽値 — 初期~時は ~F とする。 ◎ A boolean, initially false.
`~script計時~報@ は、 次に挙げる`~item$sctを有する`構造体$である: ◎ script timing info is a struct. It has the following items:
- `呼出元~種別@stI ◎ invoker type
- ある `ScriptInvokerType$I ◎ A ScriptInvokerType.
- `開始~時刻@stI ◎ start time
- `終了~時刻@stI ◎ end time
- `実行~開始~時刻@stI ◎ execution start time
- `安全でない~moment$を表現する `DOMHighResTimeStamp$I — 初期~時は 0 とする。 ◎ An unsafe DOMHighResTimeStamp, initially 0.
- `静止-所要時間@stI ◎ pause duration
- `強制d~style所要時間@stI ◎ forced style duration
- `強制d~layout所要時間@stI ◎ forced layout duration
- ある `DOMHighResTimeStamp$I 【!representing a number of milliseconds】 — 初期~時は 0 とする。 ◎ A DOMHighResTimeStamp representing a number of milliseconds, initially 0.
- `呼出元の名前@stI ◎ invoker name
- `~source~URL@stI ◎ source url
- `~source関数~名@stI ◎ source function name
- `~event型@stI ◎ event type
- `~event~target要素の~ID@stI ◎ event target element id
- `~event~target要素の~src属性@stI ◎ event target element src attribute
- いずれも,ある文字列 — 初期~時は空~文字列とする。 ◎ A string, initially the empty string.
- `~source文字~位置@stI ◎ source character position
- ある整数 — 初期~時は −1 とする。 ◎ A number, initially -1.
- `~source行l番号@stI ◎ source line number
- ある整数 — 初期~時は −1 とする。 ◎ A number, initially -1.
- `~source列l番号@stI ◎ source column number
- ある整数 — 初期~時は −1 とする。 ◎ A number, initially -1.
- `~window@stI ◎ window
- ある `Window$I を指す ある `WeakRef$jt ◎ A WeakRef to a Window.
`~styleか~layoutの期間@ は、 次に挙げる`~item$sctを有する`構造体$である: ◎ A style and layout period is a struct. It has the following items:
- `種別@slP ◎ type
- `~style^i / `~layout^i ◎ "`style`" or "`layout`".
- `開始~時刻@slP ◎ start time
- `終了~時刻@slP ◎ end time
- ある`粗化-$された `DOMHighResTimeStamp$I ◎ A coarsened DOMHighResTimeStamp.
各`文書$は、 `現在の~frame計時~報@doc を有する — それは、[ ~NULL /ある`~frame計時~報$ ]をとり, 初期~時は~NULLとする。 ◎ A Document has a null or frame timing info current frame timing info, initially null.
各`古典~script$は、 `元の~source~URL@ を有する — それは、[ ~NULL /ある`~URL$ ]をとり, 初期~時は~NULL とする。 ◎ A classic script has a URL-or-null original source URL, initially null.
`~scriptの公開される~source~URL@ を取得する~algoは、 所与の ( `~script$ %~script ) に対し: ◎ A script script’s exposed source URL is\
-
~IF[ %~script は`古典~script$である ]:
- %~URL ~LET %~script の`元の~source~URL$
- ~IF[ %~URL ~NEQ ~NULL ] ⇒ ~RET %~URL
- ~RET %~script の`基底~URL$sC ◎ otherwise script’s base URL.
注記: 外部な古典~script用には、 `元の~source~URL$は要請された~URL ( `script$e 要素の `src^a 属性の値) になる一方で, `基底~URL$sCは対する応答の~URLになる (~redirectがあった場合、[ 前者は最初のそれより前, 後者は最後のそれより後 ]における)。 ~inlineな古典~script用には、 `元の~source~URL$は ~NULL になり, `基底~URL$sCは当の文書の基底~URLになる。 元の~source~URLを公開することは、 非同一-生成元な~scriptが~redirect先を露呈することを避ける — そのことは、 `script$e 要素~自体からすでに観測-可能なものに合致する。 ◎ Note: For an external classic script, the original source URL is the URL that was requested (the `script` element’s `src`, before any redirects), whereas the base URL is the URL of the response (after redirects). For inline classic scripts, the original source URL is null and the base URL is the document’s base URL. Exposing the original source URL avoids revealing where a cross-origin script was redirected to, matching what is already observable from the `script` element itself.
3.2. 長い~animation~frameの報告-法
3.2.1. 長い~animation~frameの監視-法
`文書と同一-生成元な最も近い根@ を取得する~algoは、 所与の ( `文書$ %文書 ) に対し: ◎ To get the nearest same-origin root for a Document document:
- %先祖~群 ~LET %文書 の`先祖~navigable群$ ◎ Let ancestors be the ancestor navigables of document.
- %先祖~群 を成す ~EACH( %先祖~navigable ) に対し ⇒ ~IF[ ( %先祖~navigable にて`作動中な文書$navの`生成元$doc, %文書 の`生成元$doc ) は`同一-生成元$である ]~AND[ %先祖~navigable にて`作動中な文書$navに`関連な~agent$ ~EQ %文書 に`関連な~agent$ ] ⇒ ~RET %先祖~navigable にて`作動中な文書$nav ◎ For each ancestorNavigable in ancestors: If ancestorNavigable’s active document’s origin is same origin with document’s origin, and ancestorNavigable’s active document’s relevant agent is document’s relevant agent, then return ancestorNavigable’s active document.
- ~RET %文書 ◎ Return document.
`文書に関連な~frame計時~報@ を取得する~algoは、 所与の ( `文書$ %文書 ) に対し:
- %根 ~LET `文書と同一-生成元な最も近い根$( %文書 )
- ~RET %根 の`現在の~frame計時~報$doc
`必要なら~task時刻の記録処理を開始する@ ~algoは、 所与の ( `環境~設定群~obj$ %設定群~obj ) に対し: ◎ To start recording task time if needed given an environment settings object settingsObject:
注記: この~algoは、[ `~eventを発火する$/`~script入口点を作成する$ ]~algoから~callされ、 それらの~algoが~taskであったかのように,当の[ ~eventの発火/~script ]の所要時間~用に~frame計時~報の記録処理を開始する。 これは、[ ~script/~event ]のうち[ どの~taskにも結付けられず,他では`暗黙な文書$を要求することになるもの ]たちの所要時間を織り込む。 ◎ Note: this is called from the fire an event algorithm and the create script entry point algorithm. It starts recording frame timing info for the duration of the event firing or script, as if it was a task. This accounts for script and event durations that are not associated with tasks, which would otherwise require an implied document.
- ~IF[ %設定群~obj の`大域~obj$enVは`~window$でない ] ⇒ ~RET ~F ◎ If settingsObject’s global object is not a Window, then return false.
- %文書 ~LET %設定群~obj の`大域~obj$enVに`結付けられた文書$ ◎ Let document be settingsObject’s global object’s associated Document.
- ~IF[ `文書に関連な~frame計時~報$( %文書 ) の結果 ~NEQ ~NULL ] ⇒ ~RET ~F ◎ If document’s relevant frame timing info is non-null, then return false.
- `~task開始~時刻を記録する$( `安全でない共有される現在の時刻$, %文書 ) ◎ Record task start time given the unsafe shared current time and document.
- ~RET ~IS[ 次の結果 ~NEQ ~NULL ] ⇒ `文書に関連な~frame計時~報$( %文書 ) ◎ Return true if document’s relevant frame timing info is non-null; otherwise false.
`~task開始~時刻を記録する@ ~algoは、 所与の ( `DOMHighResTimeStamp$I %安全でない~task開始~時刻, `文書$ %文書 ) に対し: ◎ To record task start time given a DOMHighResTimeStamp unsafeTaskStartTime, and a Document document:
- ~IF[ %文書 は`全部的に作動中$でない ]~OR[ %文書 の`可視性~状態$doc ~EQ `hidden^l ] ⇒ ~RET ◎ If document is not fully active or document’s visibility state is "`hidden`", then return.
- %根 ~LET `文書と同一-生成元な最も近い根$( %文書 ) ◎ Let root be document’s nearest same-origin root.
- ~IF[ %根 は`全部的に作動中$でない ]~OR[ %根 の`可視性~状態$doc ~EQ `hidden^l ] ⇒ ~RET ◎ If root is not fully active or root’s visibility state is "`hidden`", then return.
- ~IF[ %根 の`現在の~frame計時~報$doc ~EQ ~NULL ] ⇒ %根 の`現在の~frame計時~報$doc ~SET 新たな`~frame計時~報$ — その ⇒# `開始~時刻$ftI ~SET %安全でない~task開始~時刻 `非同一-生成元~能力は隔離されるか$ftI ~SET %根 に`関連な設定群~obj$の`非同一-生成元~能力は隔離されるか?$enV ◎ If root’s current frame timing info is null, then set root’s current frame timing info to a new frame timing info whose start time is unsafeTaskStartTime, and whose cross-origin isolated capability is root’s relevant settings object’s cross-origin isolated capability.
- %根 の`現在の~frame計時~報$docの`現在の~taskの開始~時刻$ftI ~SET %安全でない~task開始~時刻 ◎ Set root’s current frame timing info’s current task start time to unsafeTaskStartTime.
`~task終了~時刻を記録する@ ~algoは、 所与の ( `DOMHighResTimeStamp$I %安全でない~task終了~時刻, `文書$ %文書 ) に対し: ◎ To record task end time given a DOMHighResTimeStamp unsafeTaskEndTime, and a Document document:
- %計時~報 ~LET `文書に関連な~frame計時~報$( %文書 ) ◎ Let timingInfo be document’s relevant frame timing info.
-
~IF[ %計時~報 ~EQ ~NULL ] ⇒ ~RET ◎ If timingInfo is null, then return.
注記: これは、 ~browserが当の `sequence^en の間に可視でなくなる場合に生じ得る。 ◎ Note: This can occur if the browser becomes hidden during the sequence.
- %大域~obj ~LET %文書 に`関連な大域~obj$ ◎ Let global be document’s relevant global object.
- %安全な~task終了~時刻 ~LET `相対的な高分解能~時刻$( %安全でない~task終了~時刻, %大域~obj ) ◎ Let safeTaskEndTime be the relative high resolution time given unsafeTaskEndTime and global.
- %安全な~task開始~時刻 ~LET `相対的な高分解能~時刻$( %計時~報 の`現在の~taskの開始~時刻$ftI, %大域~obj ) ◎ Let safeTaskStartTime be the relative high resolution time given timingInfo’s current task start time and global.
- %計時~報 の`~task所要時間~群$ftIに次の結果を`付加する$ ⇒ `所要時間を得る$( %安全な~task開始~時刻, %安全な~task終了~時刻 ) ◎ Append the duration between safeTaskStartTime and safeTaskEndTime to timingInfo’s task durations.
-
~IF[ ~UAは、 %文書 の`~node~navigable$の描画を更新しても,可視な効果は無いものと予見する ]: ◎ If the user agent believes that updating the rendering of document’s node navigable would have no visible effect, then:
- %根 ~LET `文書と同一-生成元な最も近い根$( %文書 ) ◎ ↓
- %根 の`現在の~frame計時~報$doc ~SET ~NULL ◎ Set document’s nearest same-origin root’s current frame timing info to null.
- %計時~報 の`終了~時刻$stI ~SET %安全でない~task終了~時刻 ◎ Set timingInfo’s end time to unsafeTaskEndTime.
- %~frame所要時間 ~LET `所要時間を得る$( ↓ ) ⇒# `相対的な高分解能~時刻$( %計時~報 の`開始~時刻$ftI, %大域~obj ), %安全な~task終了~時刻 ◎ Let frameDuration be the duration between the relative high resolution time given timingInfo’s start time and global, and safeTaskEndTime.
-
~IF[ %~frame所要時間 ~GTE 50ms ]:
- %塗り計時~報 ~LET 新たな`塗り計時~報$ 【各~itemをどう初期化するか指定されていない。】
- `長い~animation~frame~entryを~queueする$( %文書, %計時~報, %塗り計時~報 )
注記: ここでは、 実際には視覚的な更新が不要であったとしても,`長い~animation~frame$を刻む — それが,ある無関係な視覚的~更新と同時に起こる局面においては、 それは,他を阻むことになるので。 ◎ Note: even though there was no actual visual update, we mark a long animation frame here because it would be blocking in a scenario where it coincided with an unrelated visual update.
`描画~時刻を記録する@ ~algoは、 所与の ( `文書$ %文書, `DOMHighResTimeStamp$I %安全でない~styleや~layoutの開始~時刻 ) に対し: ◎ To record rendering time given a Document document, and a DOMHighResTimeStamp unsafeStyleAndLayoutStart:
- %根 ~LET `文書と同一-生成元な最も近い根$( %文書 ) ◎ Let root be document’s nearest same-origin root.
- %計時~報 ~LET %根 の`現在の~frame計時~報$doc ◎ Let timingInfo be root’s current frame timing info.
-
~IF[ %計時~報 ~EQ ~NULL ] ⇒ ~RET ◎ If timingInfo is null, then return.
注記: これは、 ~browserが当の `sequence^en の間に可視でなくなる場合に生じ得る。 ◎ Note: This can occur if the browser becomes hidden during the sequence.
-
~Assert: %計時~報 の`~styleや~layoutの~stack$ftIは`空$である。 ◎ Assert: timingInfo’s style and layout stack is empty.
注記: このことは、 進捗-中な[ ~style再計算/~layout更新/~script ]は無いことを意味する。 ◎ Note: This means that no style recalculation, layout, or script is in progress.
- %大域~obj ~LET %根 に`関連な大域~obj$ ◎ Let global be root’s relevant global object.
- %~frame所要時間 ~LET `所要時間を得る$( ↓ ) ⇒# `相対的な高分解能~時刻$( %計時~報 の`開始~時刻$ftI, %大域~obj ), `現在の高分解能~時刻$( %大域~obj ) ◎ Let frameDuration be the duration between the relative high resolution time given timingInfo’s start time and global, and the current high resolution time given global.
-
~IF[ %~frame所要時間 ~LT 50ms ]:
- %根 の`現在の~frame計時~報$doc ~SET ~NULL;
- ~RET
- %計時~報 の`描画~更新の開始~時刻$ftI ~SET %計時~報 の`現在の~taskの開始~時刻$ftI ◎ Set timingInfo’s update the rendering start time to timingInfo’s current task start time.
- %計時~報 の`~styleや~layoutの開始~時刻$ftI ~SET %安全でない~styleや~layoutの開始~時刻 ◎ Set timingInfo’s style and layout start time to unsafeStyleAndLayoutStart.
- %~styleや~layoutの開始~時刻 ~LET `時刻を粗化する$( %安全でない~styleや~layoutの開始~時刻, %計時~報 の`非同一-生成元~能力は隔離されるか$ftI ) ◎ Let styleAndLayoutStart be the result of coarsening unsafeStyleAndLayoutStart given timingInfo’s cross-origin isolated capability.
-
%計時~報 の`~styleや~layoutの期間~群$ftI を成す ~EACH( %期間 ) に対し: ◎ For each period of timingInfo’s style and layout periods\
- ~IF[ %期間 の`開始~時刻$slP ~LT %~styleや~layoutの開始~時刻 ] ⇒ ~CONTINUE ◎ whose start time is greater than or equal to styleAndLayoutStart:
- %所要時間 ~LET `所要時間を得る$( %期間 の`開始~時刻$slP, %期間 の`終了~時刻$slP ) ◎ Let duration be the duration between period’s start time and period’s end time.
- ~IF[ %期間 の`種別$slP ~EQ `~style^i ] ⇒ %計時~報 の`~style所要時間$ftI ~INCBY %所要時間 ◎ If period’s type is "`style`", then increment timingInfo’s style duration by the milliseconds value of duration.
- ~ELSE ⇒ %計時~報 の`~layout所要時間$ftI ~INCBY %所要時間 ◎ Otherwise, increment timingInfo’s layout duration by the milliseconds value of duration.
注記: 描画~更新が[ ~styleを再計算する/~layoutを更新する ]前の[ 走っている~scriptが無い間 ]に遂行される[ ~style再計算や~layout更新 ](例:`接触判定$用のそれ) は、 数えられない。 ◎ Note: Style recalculation and layout performed while no script was running, before the rendering update recalculates styles and updates layout, e.g. for hit testing, are not counted.
- %計時~報 の`~styleや~layoutの期間~群$ftIを`空にする$ ◎ Empty timingInfo’s style and layout periods.
-
~IF[ %根 が`属する閲覧~文脈$は`塗り計時に適格$でない ]: ◎ If root’s browsing context is not paint-timing eligible, then:
- %根 の`現在の~frame計時~報$doc ~SET ~NULL ◎ Set root’s current frame timing info to null.
- %計時~報 の`終了~時刻$ftI ~SET `安全でない共有される現在の時刻$ ◎ Set timingInfo’s end time to the unsafe shared current time.
- `長い~animation~frame~entryを~queueする$( %根, %計時~報, 新たな`塗り計時~報$ ) ◎ Queue a long animation frame entry given root, timingInfo, and a new paint timing info.
`長い~animation~frame~entryを~queueする@ ~algoは、 所与の ( `文書$ %文書, `~frame計時~報$ %計時~報, `塗り計時~報$ %塗り計時~報 ) に対し: ◎ To queue a long animation frame entry given a Document document, a frame timing info timingInfo, and a paint timing info paintTimingInfo:
- ~Assert: %計時~報 の`~styleや~layoutの~stack$ftIは`空$である。 ◎ Assert: timingInfo’s style and layout stack is empty.
- %処理能~entry ~LET `新たな~obj$( `PerformanceLongAnimationFrameTiming$I, %文書 に`関連な~realm$ ) ◎ ↓
- %処理能~entry の ⇒# `計時~報$ ~SET %計時~報, `塗り計時~報$ptM ~SET %塗り計時~報 ◎ ↓
- `処理能~entryを~queueする$( %処理能~entry ) ◎ Queue a new PerformanceLongAnimationFrameTiming in document’s relevant realm, whose timing info is timingInfo and whose paint timing info is paintTimingInfo.
3.2.2. 長い~scriptの監視-法
`利用元~callback用に計時~報を記録する@ ~algoは、 所与の ( `~callback関数$ %~callback, `環境~設定群~obj$ %設定群 ) に対し ⇒ `~script入口点を作成する$( %設定群, `user-callback^l, 次の手続き ) ◎ To record timing info for user callback given a callback function callback and an environment settings object settings: Create script entry point given settings, "`user-callback`", and\
手続きは、 所与の ( `~script計時~報$ %~script計時~報 ) に対し: ◎ the following steps given a script timing info scriptTimingInfo:
- %~script計時~報 の`呼出元の名前$stI ~SET %~callback の`識別子$ ◎ Set scriptTimingInfo’s invoker name to callback’s identifier.
- `~source所在を適用する$( %~script計時~報, %~callback ) ◎ Apply source location for scriptTimingInfo given callback.
`~timer~handler用に計時~報を記録する@ ~algoは、 所与の ( [ 文字列/ `Function$I ] %~handler, `環境~設定群~obj$ %設定群, 真偽値 %繰返されるか ) に対し ⇒ `~script入口点を作成する$( %設定群, `user-callback^l, 次の手続き ) ◎ To record timing info for timer handler given a string or Function handler, an environment settings object settings, and a boolean repeat: Create script entry point given settings, "`user-callback`", and the following\
手続きは、 所与の ( `~script計時~報$ %~script計時~報 ) に対し: ◎ steps given a script timing info scriptTimingInfo:
- %~script計時~報 の`呼出元の名前$stI ~SET %繰返されるか に応じて ⇒# ~T ならば `TimerHandler:setInterval^l / ~F ならば `TimerHandler:setTimeout^l ◎ Let setTimeoutOrInterval be "setInterval" if repeat is true, "setTimeout" otherwise. ◎ Set scriptTimingInfo’s invoker name to concatenation of « TimerHandler:", setTimeoutOrInterval ».
- ~IF[ %~handler は `Function$I である ] ⇒ `~source所在を適用する$( %~script計時~報, %~handler ) ◎ If handler is a Function, then apply source location for scriptTimingInfo given handler.
`~event~listener用に計時~報を記録する@ ~algoは、 所与の ( `Event$I ~obj %~event, `EventListener$I ~obj %~listener ) に対し ⇒ `~script入口点を作成する$( %~listener に`関連な設定群~obj$, `event-listener^l, 次の手続き ) ◎ To record timing info for event listener given an Event event and an EventListener listener: Create script entry point given listener’s relevant settings object, "`event-listener`", and the following\
手続きは、 所与の ( `~script計時~報$ %~script計時~報, `~frame計時~報$ %~frame計時~報 ) に対し: ◎ steps given a script timing info scriptTimingInfo and a frame timing info frameTimingInfo:
- %~script計時~報 の`~event型$stI ~SET %~event の `type@~DOM4#dom-event-type$m の値 ◎ Set scriptTimingInfo’s event type to event’s type.
- %~target ~LET %~event の `currentTarget@~DOM4#dom-event-currenttarget$m の値 ◎ Let target be event’s currentTarget.
- ~Assert: %~target ~NEQ ~NULL 【この段は、この訳による補完。】
-
~IF[ %~target は `Node$I を実装する ]: ◎ If target is a Node, then:
- %~script計時~報 の`呼出元の名前$stI ~SET %~target の `nodeName@~DOM4#dom-node-nodename$m の値 ◎ Set scriptTimingInfo’s invoker name to target’s nodeName.
-
~IF[ %~target は `Element$I ~objである ]: ◎ If target is an Element, then:
- %~ID ~LET %~target の`~ID$ ◎ ↓
-
~IF[ %~ID ~EQ ε ] ⇒ %~ID ~SET 空~文字列
【 この段は、 この訳による補完。 原文は、 この事例において要求される挙動を指定していない。 】
◎ ↓ - %~script計時~報 の`~event~target要素の~ID$stI ~SET %~ID ◎ Set scriptTimingInfo’s event target element id to target’s id.
-
%~script計時~報 の`~event~target要素の~src属性$stI ~SET %~target の`属性を名前により取得する$( `src^l )
【 結果は、 属性~nodeであり,文字列でない — たぶん,`属性~値を取得する$( `src^l ) の結果になるべきであろう。 】
◎ Set scriptTimingInfo’s event target element src attribute to the result of getting an attribute value by name "`src`" and target.
- ~ELSE ⇒ %~script計時~報 の`呼出元の名前$stI ~SET %~target の~interface名【 %~target の`首~interface$の`識別子$】 ◎ Else, set scriptTimingInfo’s invoker name to target’s interface name.
- `~source所在を適用する$( %~script計時~報, %~listener の`~callback$evL ) ◎ Apply source location for scriptTimingInfo given listener’s callback.
- ~IF[ %~event は `UIEvent$I を実装する ]~AND[ %~frame計時~報 の`最初の~UI~event時刻印$ftI ~EQ ~NULL ] ⇒ %~frame計時~報 の`最初の~UI~event時刻印$ftI ~SET %~event に`関連な設定群~obj$の`時刻~起点$enV ~PLUS %~event の `timeStamp@~DOM4#dom-event-timestamp$m の値が成す`所要時間$ ◎ If event is a UIEvent, and frameTimingInfo’s first ui event timestamp is null, then set frameTimingInfo’s first ui event timestamp to event’s relevant settings object’s time origin + a duration of event’s timeStamp milliseconds.
`~promise解決器~用に計時~報を記録する@ ~algoは、 所与の ( `Promise$I %~promise, %種別 ~IN { `resolve-promise^l, `reject-promise^l } ) に対し ⇒ `~script入口点を作成する$( %~promise に`関連な~realm$の`設定群~obj$rM, %種別, 次の手続き ) ◎ To record timing info for promise resolver given a Promise promise and a "`resolve-promise`" or "`reject-promise`" type: • Create script entry point given promise’s relevant realm’s settings object, type, and the following\
手続きは、 所与の ( `~script計時~報$ %~script計時~報 ) に対し: ◎ steps given a script timing info scriptTimingInfo:
- %~script計時~報 の ⇒# `呼出元の名前$stI ~SET %~promise の`作成-時の呼出元の名前$, `~source~URL$stI ~SET %~promise の`作成-時の~script~URL$, `~source文字~位置$stI ~SET %~promise の`作成-時の~source文字~位置$, `~source行l番号$stI ~SET %~promise の`作成-時の~source行l$, `~source列l番号$stI ~SET %~promise の`作成-時の~source列l$ ◎ Set scriptTimingInfo’s invoker name to promise’s invoker name when created. ◎ Set scriptTimingInfo’s source url to promise’s script url when created. ◎ Set scriptTimingInfo’s source character position to promise’s source character position when created. ◎ Set scriptTimingInfo’s source line number to promise’s source line when created. ◎ Set scriptTimingInfo’s source column number to promise’s source column when created.
`~script~block用の~source~URLを設定する@ ~algoは、 所与の ( `~script計時~報$ %~script計時~報, `~script$ %~script, [ ~NULL /`~URL$ ] %~URL ) に対し: ◎ To set source url for script block given a script timing info scriptTimingInfo, a script script, and a URL-or-null url:
- %~script計時~報 の`~source文字~位置$stI ~SET 0 ◎ Set scriptTimingInfo’s source character position to 0.
- ~IF[ %~URL ~EQ ~NULL ] ⇒ ~RET ◎ If url is null, then return.
- %~scheme ~LET %~URL の`~scheme$url ◎ ↓
- ~IF[ %~scheme ~IN { `http^l, `https^l, `blob^l } ] ⇒ %~script計時~報 の`~source~URL$stI ~SET `~URLを直列化する$( %~URL ) ◎ If url’s scheme is "`http`", "`https`", or "`blob`", then set scriptTimingInfo’s source url to the serialization of url.
- ~ELIF[ %~scheme ~EQ `data^l ] ⇒ %~script計時~報 の`~source~URL$stI ~SET 次を順に`連結する$ ⇒# %~scheme, `:^l ◎ Otherwise, if url’s scheme is "`data`", then set scriptTimingInfo’s source url to "`data:`".
- ~IF[ %~script は`古典~script$でない ]~OR[ %~script の`~errorを黙秘するか$sC ~EQ ~F ] ⇒ %~script計時~報 の ⇒# `~source行l番号$stI ~SET 1, `~source列l番号$stI ~SET 1 ◎ If script is not a classic script whose muted errors is true, then: • Set scriptTimingInfo’s source line number to 1. • Set scriptTimingInfo’s source column number to 1.
`古典~scriptの作成~時刻を記録する@ ~algoは、 所与の ( `古典~script$ %~script, [ ~NULL /`~URL$ ] %元の~source~URL ) に対し: ◎ To record classic script creation time given a classic script script and a URL-or-null originalSourceURL:
- %~script の`元の~source~URL$ ~SET %元の~source~URL ◎ Set script’s original source URL to originalSourceURL.
-
`~script入口点を作成する$( %~script の`設定群~obj$sC, `classic-script^l, 次の手続き ) ◎ Create script entry point given script’s settings object, "`classic-script`", and the following\
手続きは、 所与の ( `~script計時~報$ %~script計時~報 ) に対し ⇒ `~script~block用の~source~URLを設定する$( ↓ ) ⇒# %~script計時~報, %~script, `~scriptの公開される~source~URL$( %~script ) ◎ step given a script timing info scriptTimingInfo: Set source url for script block given scriptTimingInfo, script, and script’s exposed source URL.
`古典~scriptの実行~開始~時刻を記録する@ ~algoは、 所与の ( `古典~script$ %~script ) に対し: ◎ To record classic script execution start time given a classic script script:
- %設定群 ~LET %~script の`設定群~obj$sC ◎ Let settings be script’s settings object.
- ~IF[ %設定群 の`大域~obj$enVは`~window$でない ] ⇒ ~RET ◎ If settings’s global object is not a Window, then return.
- %文書 ~LET %設定群 の`大域~obj$enVに`結付けられた文書$ ◎ Let document be settings’s global object’s associated Document.
- %~frame計時~報 ~LET `文書に関連な~frame計時~報$( %文書 ) ◎ Let frameTimingInfo be document’s relevant frame timing info.
-
~IF[ %~frame計時~報 ~EQ ~NULL ]~OR[ %~frame計時~報 の`処理待ち~script$ftI ~EQ ~NULL ]: ◎ If frameTimingInfo is null or frameTimingInfo’s pending script is null:
-
`~script入口点を作成する$( %設定群, `classic-script^l, 次の手続き ) ◎ Create script entry point given settings, "`classic-script`", and the following\
手続きは、 所与の ( `~script計時~報$ %~script計時~報 ) に対し ⇒ `~script~block用の~source~URLを設定する$( ↓ ) ⇒# %~script計時~報, %~script, `~scriptの公開される~source~URL$( %~script ) ◎ step given a script timing info scriptTimingInfo: Set source url for script block given scriptTimingInfo, script, and script’s exposed source URL. - ~RET ◎ Return.
注記: 古典~scriptの[ 作成(~compilation), 実行 ]が別々な~taskにおいて生じるときは (例えば、 `defer$a 属性を有する `script^e 要素のうち, 走る前に~fetchを完了したもの用に)、 各~段は,各自が生じた~task内で測定される: 当の作成~taskは、 `古典~scriptの作成~時刻を記録する$ことにより, その小task~checkpointにて開かれた入口を閉じる (~compilationに 5 ~milli秒~以上かかった場合には、 そのことを `startTime$m1 等しい `executionStart$m を伴って報告する)/ 当の実行~taskは、 ここで新たな入口を開く。 ◎ Note: When classic script creation (compilation) and execution occur in separate tasks (for example, for a `defer` script whose fetch completes before it runs), each step is measured in its respective task: the creation task closes the entry opened by record classic script creation time at its microtask checkpoint (reporting it with executionStart equal to startTime if compilation took at least 5 milliseconds), and the execution task opens a new entry here.
-
- ~IF[ %~script の`~errorを黙秘するか$sC ~EQ ~F ]~AND[ `走っている~script$ ~EQ ~NULL ] ⇒ %~frame計時~報 の`処理待ち~script$ftIの`実行~開始~時刻$stI ~SET `安全でない共有される現在の時刻$ ◎ If script’s muted errors is false and the running script is null, then set frameTimingInfo’s pending script’s execution start time to the unsafe shared current time.
`~module~scriptの実行~開始~時刻を記録する@ ~algoは、 所与の ( `~module~script$ %~script ) に対し ⇒ `~script入口点を作成する$( %~script の`設定群~obj$sC, `module-script^l, 次の手続き ) ◎ To record module script execution start time given a module script script: Create script entry point given script’s settings object, "`module-script`", and the following\
`~script入口点を作成する@ ~algoは、 所与の ( `環境~設定群~obj$ %設定群, `ScriptInvokerType$I %呼出元~種別, %手続き ) に対し: ◎ To create script entry point given an environment settings object settings, a ScriptInvokerType invokerType, and steps, which is an algorithm\
- ~Assert: %手続き は ( `~script計時~報$, `~frame計時~報$ ~DF ε ) を受容する~algoである。 ◎ that takes a script timing info and an optional frame timing info:
- ~IF[ %設定群 【の`大域~obj$enV】は`~window$でない ] ⇒ ~RET ◎ If settings is not a Window, then return.
- %文書 ~LET %設定群 【の`大域~obj$enV】に`結付けられた文書$ ◎ Let document be settings’s document.
- %記録処理を開始したか ~LET `必要なら~task時刻の記録処理を開始する$( %設定群 ) ◎ Let didStartRecording be the result of calling start recording task time if needed given settings.
- %~frame計時~報 ~LET `文書に関連な~frame計時~報$( %文書 ) ◎ Let frameTimingInfo be document’s relevant frame timing info.
- ~IF[ %~frame計時~報 ~NEQ ~NULL ] ⇒ ~RET ◎ If frameTimingInfo is null, then return.
- %~frame計時~報 の`~scriptから起動されたか$ftI ~SET %記録処理を開始したか ◎ Set frameTimingInfo’s script initiated to didStartRecording.
- ~IF[ %~frame計時~報 の`処理待ち~script$ftI ~NEQ ~NULL ] ⇒ ~RET ◎ If frameTimingInfo’s pending script is not null, then return.
- %今 ~LET `安全でない共有される現在の時刻$ ◎ Let now be the unsafe shared current time.
- %~script計時~報 ~LET 新たな`~script計時~報$ — その ⇒# `開始~時刻$stI ~SET %今, `実行~開始~時刻$stI ~SET %今, `呼出元~種別$stI ~SET %呼出元~種別 ◎ Let scriptTimingInfo be a new script timing info whose start time is now, whose execution start time is now, and whose invoker type is invokerType.
- %手続き( %~script計時~報, %~frame計時~報 ) ◎ Run steps given scriptTimingInfo and frameTimingInfo.
- %~script計時~報 の`~window$stI ~SET %設定群 【の`大域~obj$enVを指す `WeakRef$jt 】 ◎ Set scriptTimingInfo’s window to settings.
- `~styleや~layoutの時間を累積する$( %~frame計時~報 ) ◎ Accumulate style and layout time given frameTimingInfo.
- %~frame計時~報 の`~styleや~layoutの~stack$ftIに `~script^i を`~pushする$ ◎ Push "`script`" onto frameTimingInfo’s style and layout stack.
- %~frame計時~報 の`処理待ち~script$ftI ~SET %~script計時~報 ◎ Set frameTimingInfo’s pending script to scriptTimingInfo.
`小task~checkpoint用に計時~報を記録する@ ~algoは: ◎ To record timing info for microtask checkpoint:
-
~AND↓ を満たす`文書$たち…
- それに`関連な~agent$の`~event~loop$aG ~EQ `~surrounding~agent$の`~event~loop$aG
- その`現在の~frame計時~報$doc ~NEQ ~NULL
- その`現在の~frame計時~報$docの`処理待ち~script$ftI ~NEQ ~NULL
…を成す ~EACH( %根 ) に対し ⇒ `処理待ち~scriptを完遂する$( %根 )
◎ For each Document root whose relevant agent’s event loop is the surrounding agent’s event loop, and whose current frame timing info is not null and has a non-null pending script: Finish the pending script of root.
注記: これは、 `走っている~script$ — それは、 一般に,ある小task~checkpointが遂行されるとき【間?】は ~NULL になる — にも,当の~scriptの`文書$ — それはもはや`全部的に作動中$でないかもしれない (例:当の~scriptが その自前の `iframe$e 【?】から除去された場合) にも依拠しない。 ◎ Note: This doesn’t rely on the running script, which is generally null when a microtask checkpoint is performed, or on the Document of the script, which might no longer be fully active, e.g. if the script removed its own iframe.
`処理待ち~scriptを完遂する@ ~algoは、 所与の ( `文書$ %根 ) に対し: ◎ To finish the pending script of a Document root:
- %~frame計時~報 ~LET %根 の`現在の~frame計時~報$doc ◎ Let frameTimingInfo be root’s current frame timing info.
- %~script計時~報 ~LET %~frame計時~報 の`処理待ち~script$ftI ◎ Let scriptTimingInfo be frameTimingInfo’s pending script.
- `~styleや~layoutの時間を累積する$( %~frame計時~報 ) ◎ Accumulate style and layout time given frameTimingInfo.
- %最後の種別 ~LET %~frame計時~報 の`~styleや~layoutの~stack$ftIから`~popする$ ◎ Let popped be the result of popping from frameTimingInfo’s style and layout stack.
- ~Assert: %最後の種別 ~EQ `~script^i — すなわち,当の~scriptにより強制された[ ~style再計算/~layout更新 ]は終了~した。 ◎ Assert: popped is "`script`", i.e. any style recalculation or layout forced by the script has ended.
- %終了~時刻 ~LET `安全でない共有される現在の時刻$ ◎ Let endTime be the unsafe shared current time.
- %~frame計時~報 の`処理待ち~script$ftI ~SET ~NULL ◎ Set frameTimingInfo’s pending script to null.
- %~script計時~報 の`終了~時刻$stI ~SET %終了~時刻 ◎ Set scriptTimingInfo’s end time to endTime.
- %所要時間 ~LET `所要時間を得る$( %~script計時~報 の`開始~時刻$stI, %~script計時~報 の`終了~時刻$stI ) ◎ If the duration between scriptTimingInfo’s start time and scriptTimingInfo’s end time\
- ~IF[ %所要時間 ~GT 5 ] ⇒ %~frame計時~報 の`~script群$ftIに %~script計時~報 を`付加する$ ◎ is greater than 5 milliseconds, then append scriptTimingInfo to frameTimingInfo’s scripts.
-
~IF[ %~frame計時~報 の`~scriptから起動されたか$ftI ~EQ ~T ] ⇒ `~task終了~時刻を記録する$( %終了~時刻, %根 ) ◎ If frameTimingInfo is script initiated, then record task end time given endTime and root.
注記: ~event~listener用には、 当の~taskの存続期間は,`~eventを発火する$~algoにより管理される。 それは、 同じ~eventに対し複数の~listenerを呼出すこともある — 単独の~listenerの実行の終了にて,【その時刻を記録する?】ではなく。 ◎ Note: For event listeners, the task lifetime is managed by the fire an event algorithm, which may invoke multiple listeners to the same event, rather than at the end of a single listener’s execution.
`~source所在を適用する@ ~algoは、 所与の ( `~script計時~報$ %~script計時~報, `~callback関数$【!不要 or / `Function$I】 %~callback ) に対し: ◎ To apply source location to a script timing info scriptTimingInfo given a callback function or Function callback:
- %~script ~LET %~callback を定義した`~script$は[ 在るならば それ/ 無いならば ε ] ◎ ↓
- ~IF[ %~script ~EQ ε ] ⇒ ~RET ◎ If callback was not defined in a script, then return. ◎ Let script be the script where callback was defined.
- %~URL ~LET `~scriptの公開される~source~URL$( %~script ) ◎ Let url be script’s exposed source URL.
-
~IF[ %~URL ~NEQ ~NULL ]: ◎ If url is not null:
- %~scheme ~LET %~URL の`~scheme$url ◎ ↓
- ~IF[ %~scheme ~IN { `http^l, `https^l, `blob^l } ] ⇒ 任意選択で ⇒ %~script計時~報 の`~source~URL$stI ~SET `~URLを直列化する$( %~URL ) ◎ If url’s scheme is "`http`", "`https`", or "`blob`", then the user agent may set scriptTimingInfo’s source url to the serialization of url.
- ~ELIF[ %~scheme ~EQ `data^l ] ⇒ 任意選択で ⇒ %~script計時~報 の`~source~URL$stI ~SET `data:^l ◎ Otherwise, if url’s scheme is "`data`", then the user agent may set scriptTimingInfo’s source url to "`data:`".
- ~IF[ %~script は`古典~script$である ]~AND[ %~script の`~errorを黙秘するか$sC ~EQ ~T ] ⇒ ~RET ◎ If script is a classic script whose muted errors is true, then return.
- 任意選択で ⇒ %~script計時~報 の`~source関数~名$stI ~SET %~callback の関数~名 ◎ The user agent may set scriptTimingInfo’s source function name to the function name of callback.
- %定義された所 ~LET %~script 内の %~callback が定義された所 ◎ ↓
- 任意選択で ⇒ %~script計時~報 の`~source文字~位置$stI ~SET %定義された所 の文字~位置 【~source~codeの先頭からの文字~数】 ◎ The user agent may set scriptTimingInfo’s source character position to the character position where callback was defined.
- 任意選択で ⇒ %~script計時~報 の`~source行l番号$stI ~SET %定義された所 の行l番号 ◎ The user agent may set scriptTimingInfo’s source line number to the line number where callback was defined.
- 任意選択で ⇒ %~script計時~報 の`~source列l番号$stI ~SET %定義された所 の列l番号 ◎ The user agent may set scriptTimingInfo’s source column number to the column number where callback was defined.
`静止-所要時間を記録する@ ~algoは、 所与の ( `所要時間$ %所要時間 ) に対し: ◎ To record pause duration given a duration duration:
- %~script ~LET `走っている~script$ ◎ Let script be the running script.
- ~IF[ %~script ~EQ ~NULL ] ⇒ ~RET ◎ If script is null, then return.
- %大域~obj ~LET %~script の`設定群~obj$sCの`大域~obj$enV ◎ Let settings be script’s settings object.
- ~IF[ %大域~obj は`~window$でない ] ⇒ ~RET ◎ If settings’s global object is not a Window, then return.
- %~frame計時~報 ~LET `文書に関連な~frame計時~報$( %大域~obj に`結付けられた文書$【!`文書@~WINDOW#dom-document-2$】 ) ◎ Let document be settings’s document. ◎ Let frameTimingInfo be the relevant frame timing info given document.
- ~IF[ %~frame計時~報 ~EQ ~NULL ]~OR[ %~frame計時~報 の`処理待ち~script$ftI ~EQ ~NULL ] ⇒ ~RET ◎ If frameTimingInfo is null or frameTimingInfo’s pending script is null, then return.
- %~frame計時~報 の`処理待ち~script$ftIの`静止-所要時間$stI ~INCBY %所要時間 ◎ Increment frameTimingInfo’s pending script’s pause duration by the milliseconds value of duration.
3.2.3. ~styleや~layoutの監視-法
~UAは、 所与の`文書$に対し, その~style再計算を[ 開始する/完遂する ]度に[ `~style再計算を始める$/`~style再計算を終える$ ]を~callする。 その~layout更新を[ 開始する/完遂する ]度に[ `~layout更新を始める$/`~layout更新を終える$ ]を~callする。 これは、[ ~style再計算や~layout更新 ]のうち[ `描画を更新する$ための一部として遂行されるもの ]および[ ~scriptが走っている間に同期的に遂行されるもの (例: 当の~scriptが `getComputedStyle()$m や `getBoundingClientRect()$m を~callしたとき) ]を含む。 [ ~style再計算や~layout更新 ]が正確にいつ遂行されるか — したがって,これらの~algoがいつ~callされるか — は、 `実装定義$である。 ◎ The user agent calls begin style recalculation and end style recalculation given a Document whenever it starts and finishes recalculating the styles of that Document, and begin layout and end layout given a Document whenever it starts and finishes updating the layout of that Document. This includes style recalculation and layout performed as part of update the rendering, and style recalculation and layout performed synchronously while a script is running, e.g. when the script calls getComputedStyle() or getBoundingClientRect(). When exactly style recalculation and layout are performed, and therefore when these algorithms are called, is implementation-defined.
これを[ 相互運用可能/規範的 ]にするための仕方を見出す必要がある。 たぶん,それらの関数を~Web~IDLにおいて同期的な[ ~style/~layout ]を要求しているものとして~markするか? ◎ Find a way to make this interoperable/normative. Perhaps mark those functions in WebIDL as requiring synchronous style/layout?
注記: [ ~style再計算や~layout更新 ]は、 入子にされ得る — 例: `容器~size~query$を評価するときには、 ~layoutの途中で~styleを再計算することが要求される。 経過した時間は、 常に,進捗-中な最も内縁な[ ~style再計算/~layout更新/~script ]に帰属するので、 同じ時間が重ねて数えられることは決してなく, 走っている~scriptに費やした時間は[ ~styleや~layout ]として数えられない。 [ ~style再計算や~layout更新 ]のうち[ ある~scriptが走っている間に遂行されたもの ]は、 当の~scriptの[ `強制d~style所要時間$stI, `強制d~layout所要時間$stI ]に向けて数えられる。 他の[ `styleAndLayoutStart$m より後の描画~更新を成す一部として遂行されたもの ]は、 当の~frameの[ `~style所要時間$ftI, `~layout所要時間$ftI ]のみに向けて数えられる。 ◎ Note: Style recalculation and layout can be nested, e.g. when evaluating container size queries requires recalculating styles in the middle of layout. Elapsed time is always attributed to the innermost style recalculation, layout, or script in progress, so the same time is never counted twice, and time spent running scripts is not counted as style or layout. Style recalculation and layout performed while a script is running count towards that script’s forced style duration and forced layout duration. Otherwise, they only count towards the frame’s style duration and layout duration if they are performed as part of the rendering update, after styleAndLayoutStart.
注記: ある`文書$用に[ ~styleを再計算する/~layoutを更新する ]ことは、 他の文書~用にそうすることを要求し得る — 例:前者の~layoutが,その子孫の表示域の~sizeを決定するとき。 そのような事例においては、 これらの~algoは,これら各~文書に対し~callされる。 時刻は,各`文書に関連な~frame計時~報$へ帰属するので、 `文書と同一-生成元な最も近い根$が異なる各~文書の[ ~style再計算や~layout更新 ]は,それらを生じさせた~scriptへ帰属することは決してなく、 それらのうち[ 文書の描画~更新を成す一部として遂行されたもの ]は,各自の自前の根の~frameのみに向けて数えられる。 ◎ Note: Recalculating styles or updating layout for one Document can require doing so for other documents, e.g. for an ancestor whose layout determines the size of a descendant’s viewport. In that case, these algorithms are called for each of these documents. As time is attributed to each document’s relevant frame timing info, the style recalculation and layout of documents with a different nearest same-origin root are never attributed to the script that caused them, and only count towards their own root’s frame if they are performed as part of its rendering update.
`~styleか~layoutの作業を始める@ ~algoは、 所与の ( `文書$ %文書, %種別 ~IN { `~style^i, `~layout^i } ) に対し: ◎ To begin style or layout work given a Document document and a string type:
- %計時~報 ~LET `文書に関連な~frame計時~報$( %文書 ) ◎ Let timingInfo be document’s relevant frame timing info.
- ~IF[ %計時~報 ~EQ ~NULL ] ⇒ ~RET ◎ If timingInfo is null, then return.
- `~styleや~layoutの時間を累積する$( %計時~報 ) ◎ Accumulate style and layout time given timingInfo.
- %計時~報 の`~styleや~layoutの~stack$ftIに %種別 を`~pushする$ ◎ Push type onto timingInfo’s style and layout stack.
`~styleか~layoutの作業を終える@ ~algoは、 所与の ( `文書$ %文書, 文字列 %種別 ) に対し: ◎ To end style or layout work given a Document document and a string type:
- %計時~報 ~LET `文書に関連な~frame計時~報$( %文書 ) ◎ Let timingInfo be document’s relevant frame timing info.
- ~IF[ %計時~報 ~EQ ~NULL ] ⇒ ~RET ◎ If timingInfo is null, then return.
- `~styleや~layoutの時間を累積する$( %計時~報 ) ◎ Accumulate style and layout time given timingInfo.
- %最後の種別 ~LET %計時~報 の`~styleや~layoutの~stack$ftIから`~popする$ ◎ Let popped be the result of popping from timingInfo’s style and layout stack.
- ~Assert: %最後の種別 ~EQ %種別 ◎ Assert: popped is type.
注記: `~frame計時~報$は、 ある[ ~task/~script/描画~更新 ]の開始~時に限り作成され,終了~時に限り破棄される。 それは,[ ~style再計算/~layout更新 ]が進捗-中な間は起こり得ないので、[ ~style再計算/~layout更新 ]の[ 開始~時, 終了~時 ]には,同じ`文書に関連な~frame計時~報$を見る。 ◎ Note: A frame timing info is only created or discarded when a task, a script, or a rendering update starts or ends, which can’t happen while a style recalculation or layout is in progress. So both the beginning and the end of a style recalculation or layout see the same relevant frame timing info.
`~styleや~layoutの時間を累積する@ ~algoは、 所与の ( `~frame計時~報$ %計時~報 ) に対し: ◎ To accumulate style and layout time given a frame timing info timingInfo:
- %今 ~LET `粗化した共有される現在の時刻$( %計時~報 の`非同一-生成元~能力は隔離されるか$ftI ) ◎ Let now be the coarsened shared current time given timingInfo’s cross-origin isolated capability.
- %変更~時刻 ~LET %計時~報 の`~styleや~layoutの~stackの変更~時刻$ftI ◎ ↓
- %計時~報 の`~styleや~layoutの~stackの変更~時刻$ftI ~SET %今 ◎ ↓↓
- %種別 ~LET %計時~報 の`~styleや~layoutの~stack$ftIの中を`覗見る$ ◎ ↓
- ~IF[ %種別 ~EQ ε ] ⇒ ~RET ◎ If timingInfo’s style and layout stack is not empty, then: • Let type be the result of peeking into timingInfo’s style and layout stack.
- %~script ~LET %計時~報 の`処理待ち~script$ftI ◎ • Let script be timingInfo’s pending script.
- %所要時間 ~LET `所要時間を得る$( %変更~時刻, %今 ) ◎ • Let duration be the duration between timingInfo’s style and layout stack change time and now.
-
~IF[ %種別 ~IN { `~style^i, `~layout^i } ]: ◎ ↓
-
~IF[ %~script ~NEQ ~NULL ]:
- ~IF[ %種別 ~EQ `~style^i ] ⇒ %~script の`強制d~style所要時間$stI ~INCBY %所要時間
- ~ELSE ⇒ %~script の`強制d~layout所要時間$stI ~INCBY %所要時間
-
~ELSE ⇒ %計時~報 の`~styleや~layoutの期間~群$ftIに次を`付加する$ ⇒ 新たな`~styleか~layoutの期間$ — その ⇒# `種別$slP ~SET %種別, `開始~時刻$slP ~SET %変更~時刻, `終了~時刻$slP ~SET %今 ◎ Otherwise, if type is "`style`" or "`layout`", then append a new style and layout period whose type is type, start time is timingInfo’s style and layout stack change time, and end time is now, to timingInfo’s style and layout periods.
注記: `描画~時刻を記録する$~algoは、 当の描画~更新の一部を成す期間しか数えない。 ◎ Note: Record rendering time only counts the periods that are part of the rendering update.
注記: %種別 ~EQ `~script^i の場合、 経過した時間は~scriptを走らすことに費やしたそれになり,[ ~style/~layout ]として数えられない。 ◎ • Note: If type is "`script`", then the elapsed time is spent running a script, and is not counted as style or layout. • ↑↑ Set timingInfo’s style and layout stack change time to now.
-
注記: %所要時間 は、[ %計時~報 が属する`文書と同一-生成元な最も近い根$ %根 の`非同一-生成元~能力は隔離されるか?$ ]を利用して`粗化-$された時刻のみから算出される。 これは、 多数の短い期間を合算するときでも, %根 における時刻印より高い分解能で計時~情報を公開しないことを確保する。 ◎ Note: The durations are computed only from coarsened times, using the cross-origin isolated capability of the nearest same-origin root to which timingInfo belongs. This ensures that they don’t expose timing information at a higher resolution than that document’s timestamps, even when summing up many short periods.
4. 既存の標準に対する追加
4.1. ~Web~IDL標準に対する~monkey~patch
各 `Promise$I 【!~interface】には、 次に挙げるものが結付けられる: ◎ ↓
- `作成-時の呼出元の名前@ ⇒ 文字列 — 初期~時は `Promise^l とする。 ◎ The Promise interface has an associated string invoker name when created, initially "`Promise`".\
- `作成-時の~script~URL@ ⇒ 文字列 — 初期~時は空~文字列とする。 ◎ The Promise interface has an associated string script url when created, initially the empty string.\
- `作成-時の~source文字~位置@ ⇒ ある整数【!number】 — 初期~時は −1 とする。 ◎ The Promise interface has an associated number source character position when created, initially -1.\
- `作成-時の~source行l@ ⇒ ある整数【!number】 — 初期~時は −1 とする。 ◎ The Promise interface has an associated number source line when created, initially -1.\
- `作成-時の~source列l@ ⇒ ある整数【!number】 — 初期~時は −1 とする。 ◎ The Promise interface has an associated number source column when created, initially -1.
`新たな~promise$を作成する手続きを成す[ 結果の `Promise$I %~promise を返す段 ]の直前に,次を遂行する段たちを挿入する: ◎ Append the following steps to creating a new promise, before returning the Promise:
-
~IF[ %~promise は,ある`~interface$ %~interface に定義された ある[ `属性$/`正則~演算$/`静的~演算$ ] %~member 用の手続きにより作成されたものである ]: ◎ If this promise was created by the steps of an attribute, regular operation, or static operation member defined on an interface interface, then:
- %~interface名 ~LET %~interface の`識別子$ ◎ Let interfaceName be interface’s identifier.
- %~member名 ~LET %~member の`識別子$ ◎ Let memberName be member’s identifier.
- 任意選択で ⇒ %~promise の`作成-時の呼出元の名前$ ~SET 次を順に`連結する$ ⇒# %~interface名, `.^l, %~member名 ◎ The user agent may set the created Promise’s invoker name when created to the concatenation of « interfaceName, ".", memberName ».
- %~script ~LET `走っている~script$ ◎ Let script be the running script.
-
~IF[ %~script ~NEQ ~NULL ]: ◎ If script is not null:
- %~URL ~LET `~scriptの公開される~source~URL$( %~script ) ◎ Let url be script’s exposed source URL.
-
~IF[ %~URL ~NEQ ~NULL ]: ◎ If url is not null:
- %~scheme ~LET %~URL の`~scheme$url ◎ ↓
- ~IF[ %~scheme ~IN { `http^l, `https^l, `blob^l } ] ⇒ 任意選択で ⇒ %~promise の`作成-時の~script~URL$ ~SET `~URLを直列化する$( %~URL ) ◎ If url’s scheme is "`http`", "`https`", or "`blob`", then the user agent may set the created Promise’s script url when created to the serialization of url.
- ~ELIF[ %~scheme ~EQ `data^l ] ⇒ 任意選択で ⇒ %~promise の`作成-時の~script~URL$ ~SET `data:^l ◎ Otherwise, if url’s scheme is "`data`", then the user agent may set the created Promise’s script url when created to "`data:`".
-
~IF[ %~script は`古典~script$でない ]~OR[ %~script の`~errorを黙秘するか$sC ~EQ ~F ]: ◎ If script is not a classic script whose muted errors is true:
- %呼出した所 ~LET %~script 内の %~promise を作成した[ 演算/属性~取得子 ]が呼出された所 ◎ ↓
- 任意選択で ⇒ %~promise の`作成-時の~source文字~位置$ ~SET %呼出した所 の文字~位置 【~source~codeの先頭からの文字~数】 — 0 から~~数える ◎ The user agent may set the created Promise’s source character position when created to the zero-based character position in script where the operation or attribute getter that created this promise was invoked.
- 任意選択で ⇒ %~promise の`作成-時の~source行l$ ~SET %呼出した所 の行l番号 — 1 から~~数える ◎ The user agent may set the created Promise’s source line when created to the one-based line number in script where the operation or attribute getter that created this promise was invoked.
- 任意選択で ⇒ %~promise の`作成-時の~source列l$ ~SET %呼出した所 の列l番号 — 1 から~~数える ◎ The user agent may set the created Promise’s source column when created to the one-based column number in script where the operation or attribute getter that created this promise was invoked.
注記: ~promise作成~時刻の帰属【すなわち,各種 “作成-時の〜” 】は、 任意選択である — ~promiseを作成するとき,現在の実行~stackを探査すると、 処理能に~overheadを被り得るので。 この帰属を適用しない~UAは、 これらを各自の既定の値にしておくことになる ([ `invoker$m 用には[ `Promise.then^l / `Promise.catch^l ]/[ `sourceCharPosition$m, `sourceLine$m, `sourceColumn$m ]用には −1 ]を報告することになる)。 ◎ Note: Attribution at promise creation time is optional because probing the current execution stack when creating a promise can incur performance overhead. User agents that do not apply this attribution will leave these values at their defaults (reporting "`Promise.then`" or "`Promise.catch`" for invoker and `-1` for sourceCharPosition, sourceLine, and sourceColumn).
注記: ~Web~IDLの[ `~promiseを解決する$, `~promiseを却下する$ ]に~hookすることは、 ~script入口点~FN1を[ 当の~promiseを解決している~task内で当の~promiseが決着したとき ]に開いて,それを[ 後続な`小task~checkpointを遂行する$の終端 ]にて閉じるようにする — 各~個々の~promise反応~job~FN2に~hookすることなく。 その帰結として、[ 処理待ちな~script入口点が無い間に決着された~Web~IDL~promise~FN3 ]のうち最初のもの~FN4に限り,当の~checkpoint用に入口を開く — 純粋に~JS内で作成され, 決着された~promiseたちは、 各自の自前のもの【?】へは帰属しない。 ◎ Note: Hooking WebIDL resolve and reject opens the script entry point when the promise is settled in the resolving task and closes it at the end of the subsequent microtask checkpoint, rather than hooking each individual promise reaction job. As a consequence, only the first WebIDL promise settled while no script entry point is pending opens an entry for that checkpoint, and promises created and settled purely in JavaScript are not attributed on their own.
【~FN1 ~script (特定的には、 この仕様に現れる~callback — 次の段落に述べられるものなど — を指すであろう) を実行する場を意味すると思われる。 】【~FN2 ~JS仕様に定義される `NewPromiseReactionJob@~TC39#sec-newpromisereactionjob$ 抽象-演算が返す結果を指すと思われる。 】【~FN3 たぶん,~Web~IDL(~API)を介して公開される~promiseを指すと思われる。 】【~FN4 後続な記述との対比から, “…~promiseのうち最初かつ~Web~IDL~promiseでもあるもの” として解釈するべきかもしれない。 】
5. ~securityと~privacyの考慮点
長い~animation~frame用の~APIは、[ 長い~taskの~sourceについて,生成元~安全な帰属~情報を含める ]ことにより,同一-生成元~施策を固守する。 また、 長い~task用には閾値 50ms がある。 時刻印や所要時間は、 `HR-TIME$r に則って`粗化-$される — `非同一-生成元~能力は隔離されるか?$enVに依存する分解能で。 各[ ~style/~layout ]所要時間は、 多数の短い期間たちの総和なので, 粗化された時刻のみから算出される (`~styleや~layoutの時間を累積する$を見よ) — それは、[ それらを合算しても,計時~情報は それらの時刻印より高い分解能で公開されない ]ことを確保する。 これら~FNは組みで、 非同一-生成元への漏洩-に抗する必要十分な保護を供する。 【~FN 閾値 50ms と粗化すること(閾値 50ms は、~security用に導入されたものではないが)。】 ◎ The Long Animation Frames API adheres to the same-origin policy by including origin-safe attribution information about the source of the long task. There is a 50ms threshold for long tasks. Timestamps and durations are coarsened according to [HR-TIME], with a resolution that depends on the cross-origin isolated capability. Style and layout durations are sums of many short periods, so they are computed only from coarsened times (see accumulate style and layout time), which ensures that summing them up doesn’t expose timing information at a higher resolution than the timestamps. Together this provides adequate protection against cross-origin leaks.
この~APIは、[ 利用者により実行される~taskの所要時間と種別についての計時~情報 ]および[ 関数~callを生じさせた閲覧~文脈などの`帰属$ ]を供する。 これは、 攻撃者が~side-channel計時~攻撃を遂行して,[ 利用者の動作を推測する/利用者を識別する ]ことも可能化し得る。 例えば,長い~scriptに後続して長い具現化を併せる~patternで、 利用者による~social~widgetとのヤリトリを推測することもできる。 詳細な[ 関数~callの`帰属$ ]は、 利用者の動作を決定するために利用されることになろう。 ◎ The Long Animation Frames API provides timing information about the duration and type of tasks executed by the user, as well as attribution such as the browsing context causing the function calls. This could enable an attacker to perform side-channel timing attacks to guess the user’s action, or identify the user. For example, a pattern of long script followed by a long render could be put together to guess user’s interaction with a social widget. Detailed function call attribution would be used to determine the user’s action.
5.1. 何が観測器に公開されるのか?
~top-level~pageの中にある すべての観測器 (すなわち,~pageと~main~frame内のすべての~iframe) は、 `長い~animation~frame$が在ることについて通知を受信することになる。 それは、 当の~taskの[ 開始~時刻, 所要時間, 元凶~frameへの~pointer ]を公開する ( `HR-TIME$r に則って`粗化-$される)。 この情報は、 今日においてすでに, `setTimeout()^m を利用して より高-分解能に観測できる 【それは、閾値 50ms により制限されない】 。 攻撃者は、[ ~page上のすべてを~clearしてから,非同一-生成元に属する脆弱な資源を追加することで、 `setTimeout()^m からの遅延が,その資源により生じることを確保する ]ことにより,これを行える。 【元凶とは】異なる~page(~UItabや~UIwindow)内の観測器は、 ~UAの~architectureを問わず,通知【において`帰属$】を受信するベキでない。 ◎ All observers within the top level page (i.e. all iframes in the page and the main frame) will receive notifications about presence of long animation frames. We expose the start time of the task, its duration (coarsened according to [HR-TIME]), and a pointer to the culprit frame. This information can already be observed today, and with higher resolution, using setTimeout. An attacker can do this by clearing everything else on the page and adding the vulnerable cross-origin resource to ensure that delays from the setTimeout are caused by that resource. Observers in other different pages (tabs or windows) should not receive notifications, regardless of the architecture of the user agent.
5.2. 考慮される攻撃~局面
考慮される計時~攻撃として,次が挙げられる: ◎ The following are the timing attacks considered:
- 伝統的な計時~攻撃 ⇒ 外部~資源の読込nにかかる時間を利用して,私的~dataの~sizeを露呈する。 例として、 ある展示における隠された絵図の個数, ~usernameは妥当かどうか, 等々。 `例@http://crypto.stanford.edu/%7edabo/papers/webtiming.pdf$ を見よ。 ◎ Traditional timing attacks: using external resource load time to reveal the size of private data. For instance the number of hidden pictures in a gallery, whether username is valid, etc. See an example.
- ~side-channel計時~攻撃 ⇒ [ 動画~構文解析/ ~script構文解析/ ~app~cache読取n【この特能は~HTMLから廃された】/ `Cache$I ~API(~sw) ]の利用度に関する時間を利用して、 利用者を一意に識別するか, 利用者の[ 年齢, 性別, 所在, 関心事, 等々 ]が成す~profileを作成する。 `一例として@https://tom.vg/papers/timing-attacks_ccs2015.pdf$, ~social~network内の ある~permalink用の~pageからの状態s更新は、 一定の対象層(例: 20 代の女性)に制限-【するように公開-】され得る。 その~permalink~pageの~file~sizeは、 利用者は当の対象層に属するかどうか決定するために利用され得る。 【対象層に属さないならば、当の~pageを読込まないので,時間がかからない。】 ◎ Side-channel timing attacks: using time for video parsing, script parsing, App Cache reads or Cache API (service workers) usage to uniquely identify a user, or to create a profile of the user’s age, gender, location, and interests etc. For instance, status updates from a social network can be limited to certain demographic (eg. females of age 20-30) the file size of the permalink page can be used to determine whether the user is in the target demographic.
これらの局面は、[ 50ms 閾値, 非同一-生成元に関する境界 ]の組みで取組まれる。 すなわち、 信用されない非同一-生成元に属する観測器には,~taskの種別や追加的な帰属は示されない。 ◎ These scenarios are addressed by the 50ms threshold AND respecting cross-origin boundary i.e. not showing task type or additional attribution to untrusted cross origin observers.
5.3. 長い~animation~frame~APIにより公開される追加的な情報
非同一-生成元に属するいくつかの文書が同じ~event~loopを共有し得るので、 それらも,同じ `sequence^en を成す一部として 【すなわち,`描画を更新する手続き$の中で同時に】 描画され得る — その結果、 互いの描画~時間に波及する。 これらの計時は,すでに非同一-生成元からも いくぶん観測-可能であるが (例:~animation~frameを要請して,遅延されたか否か観測することにより)、 長い~animation~frame~API【!this】は,より高い忠実度でそれらを公開する。 ◎ Since several cross-origin documents can share the same event loop, they can also render as part of the same frame sequence and influence each other’s rendering time. This makes it so that these timings are already somewhat observable cross-origin, e.g. by requesting an animation frame and observing if it is delayed, though long animation frames exposes them at a higher fidelity.
これを軽減するため、 長い~animation~frameの報告-先は, “関与している局所的な根” に限られる: ◎ To mitigate this, long animation frames are only reported to "participating local roots":\
- 長い~animation~frameを観測する文書として適格になるものは、[ 当の `sequence^en に寄与した ある作業~taskに結付けられたもの/ 当の~frameを成す一部として描画されたもの ]に限られる。 ◎ only documents that are associated with a work task that contributed to the sequence, or that were rendered as part of the frame, are eligible to observe the long animation frame,\
- 長い~animation~frameが可用になる文書は、 `文書と同一-生成元な最も近い根$に限られる。 【!前項の文書の先祖のうち[その親は[無い/非同一-生成元に属する]もの]のうち文書に最も近いもの】 ◎ and that long animation frame would be available only in their nearest ancestor that is either topmost or has a cross-origin parent.
[ `styleDuration$m, `layoutDuration$m, `forcedStyleDuration$m, `forcedLayoutDuration$m ]は、[ 同じ`文書と同一-生成元な最も近い根$を共有する文書たち ]の[ ~style再計算や~layout更新 ]しか含まない ( `§ ~styleや~layoutの監視-法@#style-and-layout-monitoring$ を見よ)。 それらは、 上で述べた[ 総合的な描画の計時として公開されるもの ]を除き,非同一-生成元な文書が[ ~style/~layout ]に費やした時間を公開しない。 ◎ styleDuration, layoutDuration, forcedStyleDuration, and forcedLayoutDuration only include the style recalculation and layout of documents that share the same nearest same-origin root (see § 3.2.3 Style and Layout Monitoring). They don’t expose how much time cross-origin documents spend on style and layout, beyond what the overall rendering timings described above already expose.
5.4. `PerformanceScriptTiming$I と不透明な~script
`PerformanceScriptTiming$I は,~script実行についての情報を公開するので、[ 他では容易に演繹され得ない`~CORS非同一-生成元$な~script ]について,多過ぎる情報を公開しないようにする必要がある。 そうするため、 既存の`~errorを黙秘するか$sCが利用される。 [ `古典~script$のうち,その`~errorを黙秘するか$sC ~EQ ~T をとるもの ]および[ その内側で定義された~callbackや~promise ]用には: ◎ Since PerformanceScriptTiming exposes information about script execution, we need to make sure it doesn’t expose too much information about CORS cross-origin scripts that cannot be easily deduced otherwise. To do that, we use the existing muted errors boolean: for classic scripts whose muted errors is true (as well as callbacks or promises defined inside them),\
- `sourceURL$m は、 ~redirect前の要請~URL( `script$e 要素の初期~URL)しか公開しない — ~redirect後の応答~URLではなく。 ◎ sourceURL exposes only the pre-redirect request URL (the `script` element’s initial URL) rather than the post-redirect response URL,\
- `executionStart$m は、 `startTime$m1 に等しくなるよう設定されるので, ~compilation所要時間は公開されない。 ◎ executionStart is set equal to startTime so compilation duration is not exposed,\
- 次に挙げるものは、 省略される ⇒# `sourceFunctionName$m, `sourceCharPosition$m, `sourceLine$m, `sourceColumn$m ◎ and for callbacks or promises defined inside such scripts, sourceFunctionName, sourceCharPosition, sourceLine, and sourceColumn are omitted.