forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add correct equality testing for ComputedStyle's StyleVariableData
objects. This fixes the linked bug (large subtree style recalcs always when using variables) and prevents a crash in release-with-asserts builds that attempt to equality check the base style with a freshly computed style during animations. BUG=570176 Review URL: https://codereview.chromium.org/1537523003 Cr-Commit-Position: refs/heads/master@{#365814}
- Loading branch information
Showing
8 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...party/WebKit/LayoutTests/fast/css/variables/no-assert-mixing-variables-and-animation.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<script src="../../../resources/testharness.js"></script> | ||
<script src="../../../resources/testharnessreport.js"></script> | ||
|
||
<style> | ||
body { | ||
--b: 420px; | ||
} | ||
#element { | ||
--a: var(--b); | ||
width: 100px; | ||
height: 100px; | ||
background-color: red; | ||
transition: width 1s; | ||
} | ||
|
||
#element.triggered { | ||
width: var(--a); | ||
} | ||
</style> | ||
|
||
<div id='element'></div> | ||
|
||
<script> | ||
var test = async_test("this test passes if it doesn't assert"); | ||
|
||
requestAnimationFrame(x => { | ||
element.classList.add('triggered'); | ||
requestAnimationFrame(x => { | ||
requestAnimationFrame(x => { | ||
requestAnimationFrame(x => { | ||
requestAnimationFrame(x => { | ||
test.done(); | ||
}) | ||
}) | ||
}) | ||
}) | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
third_party/WebKit/Source/core/style/StyleVariableData.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "config.h" | ||
#include "core/style/StyleVariableData.h" | ||
|
||
#include "core/style/DataEquivalency.h" | ||
|
||
namespace blink { | ||
|
||
bool StyleVariableData::operator==(const StyleVariableData& other) const | ||
{ | ||
if (m_data.size() != other.m_data.size()) { | ||
return false; | ||
} | ||
|
||
for (const auto& iter : m_data) { | ||
RefPtr<CSSVariableData> otherData = other.m_data.get(iter.key); | ||
if (!dataEquivalent(iter.value, otherData)) | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
} // namespace blink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters