Bug 1564673 [wpt PR 17561] - Fix first line style caching issues, a=testonly

Automatic update from web-platform-tests
Fix first line style caching issues

1. Cache conflict issue:

Previously calls to Element:: Element::CachedStyleForPseudoElement()
with different second parameters caused cache conflict. The second
call to it might get unwanted result that was cached with a different
second parameter.

Now remove the second parameter, and the function gets and caches the
pseudo style only based on its own computed style. If a caller wants
a pseudo style based on another style, the caller should call
Element::UncachedStyleForPseudoElement() and manage cache by itself.

2. Under-invalidation on change

Cached first line style needs invalidation in two cases:
a) when the ::first-line style changes, we should invalidate all
   cached first line styles affected.
b) when style of an inline element (which inherits ::first-line
   style) changes, as the inline element's style has higher priority
   than the inherited ::first-line style, even if the style doesn't
   change, we need to invalidate the cached
   kPseudoIdFirstLineInherited style if the new style is different
   from the inherited ::first-line style.

Bug: 979054

Change-Id: Icffe68d5136349d12cce6e92d1d3bf153c28903a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1678878
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#673574}

--

wpt-commits: c0a3e93389bdcc9e8ad12d3988e4568d48b78c9d
wpt-pr: 17561
This commit is contained in:
Xianzhu Wang 2019-07-19 18:18:34 +00:00 коммит произвёл James Graham
Родитель bfe2a9254a
Коммит a86f7802c4
8 изменённых файлов: 96 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,2 @@
<!DOCTYPE html>
<p style="color: blue">Blue <span style="color: green">This text should be green.</span> Blue</p>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#first-line-pseudo">
<link rel="match" href="first-line-change-inline-color-nested-ref.html">
<style>
#block { color: green; }
#block::first-line { color: blue; }
.green { color: green; }
</style>
<div id="block">
<div>
<p>Blue <span id="target"><span>This text should be green.</span></span> Blue</p>
</div>
</div>
<script>
requestAnimationFrame(() => {
requestAnimationFrame(() => {
target.className = 'green';
document.documentElement.removeAttribute('class');
});
});
</script>
</html>

Просмотреть файл

@ -0,0 +1,2 @@
<!DOCTYPE html>
<p style="color: blue">Blue <span style="color: green">This text should be green.</span> Blue</p>

Просмотреть файл

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#first-line-pseudo">
<link rel="match" href="first-line-change-inline-color-ref.html">
<style>
#block { color: green; }
#block::first-line { color: blue; }
.green { color: green; }
</style>
<div id="block">
<div>
<p>Blue <span id="target">This text should be green.</span> Blue</p>
</div>
</div>
<script>
requestAnimationFrame(() => {
requestAnimationFrame(() => {
target.className = 'green';
document.documentElement.removeAttribute('class');
});
});
</script>
</html>

Просмотреть файл

@ -0,0 +1,5 @@
<!DOCTYPE html>
<div>
<span style="color: green">This text should be green.</span><br>
<span style="color: blue">This text should be blue.</span>
</div>

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#first-line-pseudo">
<link rel="match" href="first-line-on-ancestor-block-ref.html">
<style>
#block::first-line { color: green; }
</style>
<div id="block">
<div>
<div style="color: blue">
<div>
<span><span>This text should be green.</span></span><br>
This text should be blue.
</div>
</div>
</div>
</div>

Просмотреть файл

@ -0,0 +1,5 @@
<!DOCTYPE html>
<div>
<span style="color: green">This text should be green.</span><br>
<span style="color: blue">This text should be blue.</span>
</div>

Просмотреть файл

@ -0,0 +1,20 @@
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#first-line-pseudo">
<link rel="match" href="first-line-with-out-of-flow-ref.html">
<style>
#block::first-line { color: green; }
</style>
<div id="block">
<div style="position: absolute"><br></div>
<div style="float: right"><br></div>
<div>
<div style="position: absolute"><br></div>
<div style="float: right"><br></div>
<div style="color: blue">
<div>
<span><span>This text should be green.</span></span><br>
This text should be blue.
</div>
</div>
</div>
</div>