Commit 31201a58 authored by Erik Luo's avatar Erik Luo Committed by Commit Bot

Whitelist IDL callbacks that update layout/style

Marks common callbacks that produce no JS-observable side-effect, yet
may update Blink's style, layout, or scroll subsystem.

Bug: 829571
Change-Id: I0c0ef5766bdf3f246b2e7889ba70acc955a1a44b
Reviewed-on: https://chromium-review.googlesource.com/1024865
Commit-Queue: Erik Luo <luoe@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553855}
parent 5cf99c8b
......@@ -169,4 +169,44 @@ Expression `window`
has side effect: false, expected: false
Expression `location`
has side effect: false, expected: false
Expression `div.scrollTop`
has side effect: false, expected: false
Expression `div.scrollLeft`
has side effect: false, expected: false
Expression `div.scrollWidth`
has side effect: false, expected: false
Expression `div.scrollHeight`
has side effect: false, expected: false
Expression `div.clientTop`
has side effect: false, expected: false
Expression `div.clientLeft`
has side effect: false, expected: false
Expression `div.clientWidth`
has side effect: false, expected: false
Expression `div.clientHeight`
has side effect: false, expected: false
Expression `innerWidth`
has side effect: false, expected: false
Expression `innerHeight`
has side effect: false, expected: false
Expression `outerWidth`
has side effect: false, expected: false
Expression `outerHeight`
has side effect: false, expected: false
Expression `div.offsetParent`
has side effect: false, expected: false
Expression `div.offsetTop`
has side effect: false, expected: false
Expression `div.offsetLeft`
has side effect: false, expected: false
Expression `div.offsetWidth`
has side effect: false, expected: false
Expression `div.offsetHeight`
has side effect: false, expected: false
Expression `div.innerText`
has side effect: false, expected: false
Expression `div.outerText`
has side effect: false, expected: false
Expression `div.style.border`
has side effect: false, expected: false
......@@ -97,6 +97,28 @@
await checkHasNoSideEffect(`window`);
await checkHasNoSideEffect(`location`);
// May update layout/scroll/style
await checkHasNoSideEffect(`div.scrollTop`);
await checkHasNoSideEffect(`div.scrollLeft`);
await checkHasNoSideEffect(`div.scrollWidth`);
await checkHasNoSideEffect(`div.scrollHeight`);
await checkHasNoSideEffect(`div.clientTop`);
await checkHasNoSideEffect(`div.clientLeft`);
await checkHasNoSideEffect(`div.clientWidth`);
await checkHasNoSideEffect(`div.clientHeight`);
await checkHasNoSideEffect(`innerWidth`);
await checkHasNoSideEffect(`innerHeight`);
await checkHasNoSideEffect(`outerWidth`);
await checkHasNoSideEffect(`outerHeight`);
await checkHasNoSideEffect(`div.offsetParent`);
await checkHasNoSideEffect(`div.offsetTop`);
await checkHasNoSideEffect(`div.offsetLeft`);
await checkHasNoSideEffect(`div.offsetWidth`);
await checkHasNoSideEffect(`div.offsetHeight`);
await checkHasNoSideEffect(`div.innerText`);
await checkHasNoSideEffect(`div.outerText`);
await checkHasNoSideEffect(`div.style.border`);
testRunner.completeTest();
......
......@@ -161,4 +161,8 @@ Expression `namedNodeMap.length`
has side effect: false, expected: false
Expression `namedNodeMap.attr1`
has side effect: false, expected: false
Expression `div.getBoundingClientRect()`
has side effect: false, expected: false
Expression `global_getComputedStyle(div)`
has side effect: false, expected: false
......@@ -4,6 +4,7 @@
await session.evaluate(`
var global_getSelection = window.getSelection;
var global_getComputedStyle = window.getComputedStyle;
var namespace = 'http://www.w3.org/1999/xhtml';
document.documentElement.setAttribute('xmlns', namespace);
......@@ -120,6 +121,10 @@
// Named getters (e.g. CSSStyleDeclaration)
await checkHasNoSideEffect(`namedNodeMap.attr1`);
// May update layout/scroll/style
await checkHasNoSideEffect(`div.getBoundingClientRect()`);
await checkHasNoSideEffect(`global_getComputedStyle(div)`);
testRunner.completeTest();
......
......@@ -1552,7 +1552,7 @@ V8PrivateProperty::getHTMLFooBarCachedAccessor().set(context, object, newValue);
Summary: `[Affects=Nothing]` indicates that a function must not produce JS-observable side effects. Functions without this attribute are never invoked by V8 with throwOnSideEffect.
Marked functions are allowed to be nondeterministic and throw exceptions, but must not set values, cache objects, or schedule execution that will be observable after the function completes. If a marked function calls into V8, it must properly handle cases when the V8 call returns an MaybeHandle.
Marked functions are allowed to be nondeterministic, throw exceptions, force layout, and recalculate style, but must not set values, cache objects, or schedule execution that will be observable after the function completes. If a marked function calls into V8, it must properly handle cases when the V8 call returns an MaybeHandle.
All DOM constructors are assumed to have no JS-observable side effects.
......
......@@ -38,7 +38,7 @@
// The camel-cased and dashed attribute getters have custom bindings.
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-camel-cased-attribute
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-dashed-attribute
getter (DOMString or float) (DOMString name);
[Affects=Nothing] getter (DOMString or float) (DOMString name);
// TODO(crbug.com/831544): [TreatNullAs=EmptyString] should be used instead
// of [TreatNullAs=NullString].
[CEReactions, CallWith=ScriptState] setter void (DOMString property, [TreatNullAs=NullString] DOMString propertyValue);
......
......@@ -94,7 +94,7 @@ interface Element : Node {
// CSSOM View Module
// https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface
[Measure] DOMRectList getClientRects();
[Measure, RuntimeCallStatsCounter=ElementGetBoundingClientRect] DOMRect getBoundingClientRect();
[Affects=Nothing, Measure, RuntimeCallStatsCounter=ElementGetBoundingClientRect] DOMRect getBoundingClientRect();
// TODO(sunyunjia): Add default value for scrollIntoView() once
// crbug.com/734599 is fixed.
......@@ -105,14 +105,14 @@ interface Element : Node {
[RuntimeEnabled=CSSOMSmoothScroll] void scrollTo(unrestricted double x, unrestricted double y);
[RuntimeEnabled=CSSOMSmoothScroll] void scrollBy(optional ScrollToOptions options);
[RuntimeEnabled=CSSOMSmoothScroll] void scrollBy(unrestricted double x, unrestricted double y);
attribute unrestricted double scrollTop;
attribute unrestricted double scrollLeft;
readonly attribute long scrollWidth;
readonly attribute long scrollHeight;
readonly attribute long clientTop;
readonly attribute long clientLeft;
readonly attribute long clientWidth;
readonly attribute long clientHeight;
[Affects=Nothing] attribute unrestricted double scrollTop;
[Affects=Nothing] attribute unrestricted double scrollLeft;
[Affects=Nothing] readonly attribute long scrollWidth;
[Affects=Nothing] readonly attribute long scrollHeight;
[Affects=Nothing] readonly attribute long clientTop;
[Affects=Nothing] readonly attribute long clientLeft;
[Affects=Nothing] readonly attribute long clientWidth;
[Affects=Nothing] readonly attribute long clientHeight;
// Scroll Customization API. See crbug.com/410974 for details.
[RuntimeEnabled=ScrollCustomization] void setApplyScroll(ScrollStateCallback scrollStateCallback, NativeScrollBehavior nativeScrollBehavior);
......
......@@ -115,7 +115,7 @@
// CSS Object Model (CSSOM)
// https://drafts.csswg.org/cssom/#extensions-to-the-window-interface
[NewObject] CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString? pseudoElt);
[Affects=Nothing, NewObject] CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString? pseudoElt);
// CSSOM View Module
// https://drafts.csswg.org/cssom-view/#extensions-to-the-window-interface
......@@ -129,8 +129,8 @@
void resizeBy(long x, long y);
// viewport
[Replaceable] readonly attribute long innerWidth;
[Replaceable] readonly attribute long innerHeight;
[Affects=Nothing, Replaceable] readonly attribute long innerWidth;
[Affects=Nothing, Replaceable] readonly attribute long innerHeight;
// viewport scrolling
[Replaceable] readonly attribute double scrollX;
......@@ -151,8 +151,8 @@
// client
[Affects=Nothing, Replaceable] readonly attribute long screenX;
[Affects=Nothing, Replaceable] readonly attribute long screenY;
[Replaceable] readonly attribute long outerWidth;
[Replaceable] readonly attribute long outerHeight;
[Affects=Nothing, Replaceable] readonly attribute long outerWidth;
[Affects=Nothing, Replaceable] readonly attribute long outerHeight;
[Affects=Nothing, Replaceable] readonly attribute double devicePixelRatio;
// Selection API
......
......@@ -48,19 +48,19 @@ interface HTMLElement : Element {
// CSSOM View Module
// https://drafts.csswg.org/cssom-view/#extensions-to-the-htmlelement-interface
[PerWorldBindings, ImplementedAs=unclosedOffsetParent] readonly attribute Element? offsetParent;
[ImplementedAs=offsetTopForBinding] readonly attribute long offsetTop;
[ImplementedAs=offsetLeftForBinding] readonly attribute long offsetLeft;
[ImplementedAs=offsetWidthForBinding] readonly attribute long offsetWidth;
[ImplementedAs=offsetHeightForBinding] readonly attribute long offsetHeight;
[Affects=Nothing, PerWorldBindings, ImplementedAs=unclosedOffsetParent] readonly attribute Element? offsetParent;
[Affects=Nothing, ImplementedAs=offsetTopForBinding] readonly attribute long offsetTop;
[Affects=Nothing, ImplementedAs=offsetLeftForBinding] readonly attribute long offsetLeft;
[Affects=Nothing, ImplementedAs=offsetWidthForBinding] readonly attribute long offsetWidth;
[Affects=Nothing, ImplementedAs=offsetHeightForBinding] readonly attribute long offsetHeight;
// CSS Object Model (CSSOM)
// https://drafts.csswg.org/cssom/#the-elementcssinlinestyle-interface
[Affects=Nothing, SameObject, PerWorldBindings, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
// Non-standard APIs
[CEReactions, CustomElementCallbacks, RaisesException=Setter, MeasureAs=HTMLElementInnerText] attribute [TreatNullAs=NullString] DOMString innerText;
[CEReactions, CustomElementCallbacks, RaisesException=Setter, MeasureAs=HTMLElementOuterText] attribute [TreatNullAs=NullString] DOMString outerText;
[Affects=Nothing, CEReactions, CustomElementCallbacks, RaisesException=Setter, MeasureAs=HTMLElementInnerText] attribute [TreatNullAs=NullString] DOMString innerText;
[Affects=Nothing, CEReactions, CustomElementCallbacks, RaisesException=Setter, MeasureAs=HTMLElementOuterText] attribute [TreatNullAs=NullString] DOMString outerText;
};
HTMLElement implements GlobalEventHandlers;
......
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