Commit 904f0086 authored by Kevin Ellis's avatar Kevin Ellis Committed by Commit Bot

Fix commitStyles for transforms.

Include layout object when retrieving values for computed properties.

Bug: 1056197
Change-Id: I8fd97b101047b473038a26dd9bb30dcff4ae6903
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2074801Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744688}
parent 98a43411
...@@ -2129,7 +2129,7 @@ void Animation::commitStyles(ExceptionState& exception_state) { ...@@ -2129,7 +2129,7 @@ void Animation::commitStyles(ExceptionState& exception_state) {
// 2. If, after applying any pending style changes, target is not being // 2. If, after applying any pending style changes, target is not being
// rendered, throw an "InvalidStateError" DOMException and abort these // rendered, throw an "InvalidStateError" DOMException and abort these
// steps. // steps.
target->GetDocument().UpdateStyleAndLayoutTreeForNode(target); target->GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kJavaScript);
if (!target->GetLayoutObject()) { if (!target->GetLayoutObject()) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError, exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
"Target element is not rendered."); "Target element is not rendered.");
...@@ -2173,7 +2173,7 @@ void Animation::commitStyles(ExceptionState& exception_state) { ...@@ -2173,7 +2173,7 @@ void Animation::commitStyles(ExceptionState& exception_state) {
CSSPropertyRef ref(property.GetCSSPropertyName(), target->GetDocument()); CSSPropertyRef ref(property.GetCSSPropertyName(), target->GetDocument());
const CSSValue* value = ref.GetProperty().CSSValueFromComputedStyle( const CSSValue* value = ref.GetProperty().CSSValueFromComputedStyle(
*style, nullptr, false); *style, target->GetLayoutObject(), false);
inline_style->setProperty(target->GetDocument().ToExecutionContext(), inline_style->setProperty(target->GetDocument().ToExecutionContext(),
property.GetCSSPropertyName().ToAtomicString(), property.GetCSSPropertyName().ToAtomicString(),
value->CssText(), "", ASSERT_NO_EXCEPTION); value->CssText(), "", ASSERT_NO_EXCEPTION);
......
...@@ -7,6 +7,7 @@ PASS Commits values calculated mid-interval ...@@ -7,6 +7,7 @@ PASS Commits values calculated mid-interval
PASS Commits variable references as their computed values PASS Commits variable references as their computed values
PASS Commits custom variables PASS Commits custom variables
PASS Commits em units as pixel values PASS Commits em units as pixel values
PASS Commits transforms
PASS Commits the intermediate value of an animation in the middle of stack PASS Commits the intermediate value of an animation in the middle of stack
PASS Commit composites on top of the underlying value PASS Commit composites on top of the underlying value
PASS Triggers mutation observers when updating style PASS Triggers mutation observers when updating style
......
...@@ -166,6 +166,18 @@ test(t => { ...@@ -166,6 +166,18 @@ test(t => {
assert_numeric_style_equals(getComputedStyle(div).width, 100); assert_numeric_style_equals(getComputedStyle(div).width, 100);
}, 'Commits em units as pixel values'); }, 'Commits em units as pixel values');
test(t => {
const div = createDiv(t);
const animation = div.animate(
{ transform: 'translate(20px, 20px)' },
{ duration: 1, fill: 'forwards' }
);
animation.finish();
animation.commitStyles();
animation.cancel();
assert_equals(getComputedStyle(div).transform, 'matrix(1, 0, 0, 1, 20, 20)');
}, 'Commits transforms');
promise_test(async t => { promise_test(async t => {
const div = createDiv(t); const div = createDiv(t);
div.style.opacity = '0.1'; div.style.opacity = '0.1';
......
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