Project: chromium Issues People Development process History Sign in
New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 5 users
Status: Fixed
Owner:
NOT IN USE
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug

Blocked on:
issue 671596

Blocking:
issue 318468
issue 589924
issue 589929
issue 603621



Sign in to add a comment
Make updateActiveStyleSheets happen asynchronously
Reported by r...@opera.com, Dec 7 2015 Back to list
Currently, we call updateActiveStyleSheets synchronously on StyleEngine::resolverChanged() which typically happens when we add/remove/modify a stylesheet. We do a so called "analyzed style update" as part of updateActiveStyleSheets where we only mark some nodes with SubtreeStyleChange based on the selectors of the added/removed stylesheet. Yet, we update the RuleFeatures upon request.

A couple of consequences is that we repeatedly do this analysis when adding multiple stylesheets like:

document.head.appendChild(sheet1);
document.head.appendChild(sheet2);

also, since we do the stylesheet analysis synchronously, we also need to update the RuleFeatures synchronously when we schedule invalidations (e.g. for changing className) like this:

document.head.appendChild(sheet1);
document.body.className = "myclass";

If we did the active stylesheet update asynchronously, we could schedule invalidations without updating the RuleFeatures because a subsequent updateActiveStyleSheets would invalidate elements with myclass according to the new selectors added.

This issue is about adding updateActiveStyleSheets as one of the steps in updateLayoutTree(), before we do updateStyle(), and making sure we don't have active stylesheets and rule features out of sync. Then we can schedule invalidations based on the current rule features and avoid problems like crbug.com/559292.

 
Comment 1 by r...@opera.com, Dec 7 2015
updateActiveStyleSheets() also updates the list which is accessible from document.styleSheets. We can update that list on demand without requiring an update of the active stylesheets + rule features.
Chrome does not update the document.styleSheets list reliably, I don't believe https://github.com/tim-evans/ember-autoresize/issues/27
Comment 3 by r...@opera.com, Feb 19 2016
Owner: r...@opera.com
Status: Assigned
Project Member Comment 4 by bugdroid1@chromium.org, Feb 20 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/56b2dd877e857cda63f913bb8b53b0037dee9477

commit 56b2dd877e857cda63f913bb8b53b0037dee9477
Author: rune <rune@opera.com>
Date: Sat Feb 20 01:24:44 2016

Trigger repaint on first paint only on pending stylesheet decrement.

Also, since Document::styleResolverChanged() is now just a call to
StyleEngine::resolverChanged(), remove it.

This is in preparation for splitting (style)resolverChanged() into more
descriptive methods on StyleEngine for what is necessary to nuke and
rebuild in the various cases. That, in turn, is in preparation for the
componentized style resolver and asynchronous update of active
stylesheets.

BUG=401359,567021

Review URL: https://codereview.chromium.org/1716803002

Cr-Commit-Position: refs/heads/master@{#376594}

[modify] https://crrev.com/56b2dd877e857cda63f913bb8b53b0037dee9477/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/56b2dd877e857cda63f913bb8b53b0037dee9477/third_party/WebKit/Source/core/dom/Document.h
[modify] https://crrev.com/56b2dd877e857cda63f913bb8b53b0037dee9477/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/56b2dd877e857cda63f913bb8b53b0037dee9477/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
[modify] https://crrev.com/56b2dd877e857cda63f913bb8b53b0037dee9477/third_party/WebKit/Source/core/html/imports/HTMLImportChild.cpp
[modify] https://crrev.com/56b2dd877e857cda63f913bb8b53b0037dee9477/third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp
[modify] https://crrev.com/56b2dd877e857cda63f913bb8b53b0037dee9477/third_party/WebKit/Source/core/loader/HttpEquiv.cpp
[modify] https://crrev.com/56b2dd877e857cda63f913bb8b53b0037dee9477/third_party/WebKit/Source/core/page/Page.cpp
[modify] https://crrev.com/56b2dd877e857cda63f913bb8b53b0037dee9477/third_party/WebKit/Source/core/paint/BlockPainter.cpp
[modify] https://crrev.com/56b2dd877e857cda63f913bb8b53b0037dee9477/third_party/WebKit/Source/core/xml/parser/XMLDocumentParser.cpp

Comment 5 by r...@opera.com, Feb 23 2016
Status: Started
Project Member Comment 6 by bugdroid1@chromium.org, Feb 23 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e4fec04138c05a31edf8942afef26914e8b38e52

commit e4fec04138c05a31edf8942afef26914e8b38e52
Author: rune <rune@opera.com>
Date: Tue Feb 23 01:30:56 2016

Removed Document::addedStyleSheet.

Replace it with resolverChanged(). It was only a call from StyleEngine
into Document and back into StyleEngine. Removed a couple of comments
referring to the removed method which were confusing/out-of-date.

Moved call to resolverChanged() immediately following
modifiedStyleSheetCandidateNode() into the latter method.

Made StyleEngine::markDocumentDirty() private.

No functional changes.

BUG=567021

Review URL: https://codereview.chromium.org/1721673002

Cr-Commit-Position: refs/heads/master@{#376894}

[modify] https://crrev.com/e4fec04138c05a31edf8942afef26914e8b38e52/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/e4fec04138c05a31edf8942afef26914e8b38e52/third_party/WebKit/Source/core/dom/Document.h
[modify] https://crrev.com/e4fec04138c05a31edf8942afef26914e8b38e52/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/e4fec04138c05a31edf8942afef26914e8b38e52/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/e4fec04138c05a31edf8942afef26914e8b38e52/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp

Comment 7 by r...@opera.com, Feb 29 2016
Blocking: 589929
Comment 8 by r...@opera.com, Feb 29 2016
Blocking: 589924
Project Member Comment 9 by bugdroid1@chromium.org, Mar 2 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d91075970aa81e6d3a9ce9744248575947436507

commit d91075970aa81e6d3a9ce9744248575947436507
Author: rune <rune@opera.com>
Date: Wed Mar 02 10:38:43 2016

Remove unnecessary feature flag update.

The feature flags in StyleEngine were always reset from
StyleResolver::finishAppendAuthorStyleSheets right before we called
combineCSSFeatureFlags with the exact same feature set.

R=dstockwell@chromium.org
BUG=401359,567021

Review URL: https://codereview.chromium.org/1743183003

Cr-Commit-Position: refs/heads/master@{#378719}

[modify] https://crrev.com/d91075970aa81e6d3a9ce9744248575947436507/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/d91075970aa81e6d3a9ce9744248575947436507/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/d91075970aa81e6d3a9ce9744248575947436507/third_party/WebKit/Source/core/dom/StyleEngine.h

Project Member Comment 10 by bugdroid1@chromium.org, Mar 7 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/440a6873196cecc4f18b7b7665694ab34dd2d2a7

commit 440a6873196cecc4f18b7b7665694ab34dd2d2a7
Author: rune <rune@opera.com>
Date: Mon Mar 07 09:12:58 2016

Re-collect rule features for watched selectors.

Instead of nuking the StyleResolver and re-collecting all stylesheets,
clear the current rule features on StyleResolver and mark them for
re-collection. We need to re-collect because the rule features on
StyleResolver are a union of the rule features from stylesheets and the
watched selectors from the declarativeContent css api for extensions.

A bonus is that this change avoids a synchronous active stylesheets
update.

R=dstockwell@chromium.org
BUG=567021

Review URL: https://codereview.chromium.org/1757503002

Cr-Commit-Position: refs/heads/master@{#379529}

[modify] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/core.gypi
[modify] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/css/resolver/StyleResolver.h
[modify] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/dom/CSSSelectorWatch.cpp
[modify] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/dom/CSSSelectorWatch.h
[add] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/dom/CSSSelectorWatchTest.cpp
[modify] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/dom/Document.h
[modify] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/dom/StyleChangeReason.cpp
[modify] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/dom/StyleChangeReason.h
[modify] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/440a6873196cecc4f18b7b7665694ab34dd2d2a7/third_party/WebKit/Source/core/dom/StyleEngine.h

Project Member Comment 11 by bugdroid1@chromium.org, Mar 8 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/861066b09b34f5644e622d195ff2f4609502c364

commit 861066b09b34f5644e622d195ff2f4609502c364
Author: rune <rune@opera.com>
Date: Tue Mar 08 06:03:24 2016

Added tests for preferred sheet insertion order.

Which stylesheet wins setting the preferred stylesheet set based on the
title attribute depends on the insertion order, and not the tree order,
since it's done as part of adding a stylesheet[1], as part of creating
a stylesheet[2], which is done on closing a style element, on inserting
or removing the style element [3].

Added two tests to make sure this is still true after active stylesheet
update has been made async.

[1] https://drafts.csswg.org/cssom/#add-a-css-style-sheet
[2] https://drafts.csswg.org/cssom/#create-a-css-style-sheet
[3] https://html.spec.whatwg.org/#update-a-style-block

BUG=567021

Review URL: https://codereview.chromium.org/1769843002

Cr-Commit-Position: refs/heads/master@{#379760}

[add] https://crrev.com/861066b09b34f5644e622d195ff2f4609502c364/third_party/WebKit/LayoutTests/fast/css/preferred-stylesheet-order-expected.txt
[add] https://crrev.com/861066b09b34f5644e622d195ff2f4609502c364/third_party/WebKit/LayoutTests/fast/css/preferred-stylesheet-order.html
[add] https://crrev.com/861066b09b34f5644e622d195ff2f4609502c364/third_party/WebKit/LayoutTests/fast/css/preferred-stylesheet-reversed-order-expected.txt
[add] https://crrev.com/861066b09b34f5644e622d195ff2f4609502c364/third_party/WebKit/LayoutTests/fast/css/preferred-stylesheet-reversed-order.html

Project Member Comment 12 by bugdroid1@chromium.org, Mar 8 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bffd0dd4e962fb31897082a9b9e34e5bb1a7f331

commit bffd0dd4e962fb31897082a9b9e34e5bb1a7f331
Author: rune <rune@opera.com>
Date: Tue Mar 08 06:05:24 2016

Move preferred stylesheet logic into StyleEngine.

To understand the code better:

We don't support selecting alternate stylesheets in Blink, although the
API for Document.selectedStylesheetSet is present. The way it works, is
that the effective selected stylesheet set is either empty or the
preferred set. Setting selectedStylesheetSet has no effect.

This CL should not impose any functional changes, but a resolverChanged
with no effect has been removed.

The next step for async active stylesheet update is to move the setting
of the preferred set name to where the the dom mutations happen as the
order of mutations is what defines which stylesheet title has
precedence.

BUG=567021

Review URL: https://codereview.chromium.org/1769903002

Cr-Commit-Position: refs/heads/master@{#379762}

[modify] https://crrev.com/bffd0dd4e962fb31897082a9b9e34e5bb1a7f331/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/bffd0dd4e962fb31897082a9b9e34e5bb1a7f331/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp
[modify] https://crrev.com/bffd0dd4e962fb31897082a9b9e34e5bb1a7f331/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/bffd0dd4e962fb31897082a9b9e34e5bb1a7f331/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/bffd0dd4e962fb31897082a9b9e34e5bb1a7f331/third_party/WebKit/Source/core/dom/StyleSheetCandidate.cpp
[modify] https://crrev.com/bffd0dd4e962fb31897082a9b9e34e5bb1a7f331/third_party/WebKit/Source/core/dom/StyleSheetCandidate.h
[modify] https://crrev.com/bffd0dd4e962fb31897082a9b9e34e5bb1a7f331/third_party/WebKit/Source/core/loader/HttpEquiv.cpp

Project Member Comment 13 by bugdroid1@chromium.org, Mar 18 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dba3b6817d37e512d4722aa642353b7d48db1a7d

commit dba3b6817d37e512d4722aa642353b7d48db1a7d
Author: rune <rune@opera.com>
Date: Fri Mar 18 07:56:38 2016

Dirty tree scopes are always a subset of active tree scopes.

No need to walk dirty tree scopes when clearing media dependent rule
sets after walking the active tree scopes.

Also clear m_dirtyTreeScopes in StyleEngine::detachFromDocument.
Currently, m_dirtyTreeScopes are synchronously updated and cleared
right after they are marked dirty, but that is supposed to change.

BUG=567021

Review URL: https://codereview.chromium.org/1786663003

Cr-Commit-Position: refs/heads/master@{#381909}

[modify] https://crrev.com/dba3b6817d37e512d4722aa642353b7d48db1a7d/third_party/WebKit/Source/core/dom/StyleEngine.cpp

Project Member Comment 14 by bugdroid1@chromium.org, Mar 18 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/da608f1745bd044fa96b58c3e0c9aa7e53eed3dc

commit da608f1745bd044fa96b58c3e0c9aa7e53eed3dc
Author: rune <rune@opera.com>
Date: Fri Mar 18 09:45:31 2016

Moved resolverChanged for mq updates into StyleEngine.

The placement of resolverChanged() needs a bit of explanation. We
incorrectly only clear the rulesets of active stylesheets when media
query evaluation changes. That currently causes crbug.com/589083.
Updating the active stylesheets (resolverChanged) before clearing the
ruleset will at least make sure that rule set for @media rules inside
sheets with a media attribute changing evaluation will be cleared
correctly. Moving resolverChanged() would have made the effects of
589083 worse.

BUG=567021

Review URL: https://codereview.chromium.org/1783913003

Cr-Commit-Position: refs/heads/master@{#381921}

[modify] https://crrev.com/da608f1745bd044fa96b58c3e0c9aa7e53eed3dc/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/da608f1745bd044fa96b58c3e0c9aa7e53eed3dc/third_party/WebKit/Source/core/dom/StyleEngine.cpp

Comment 15 by r...@opera.com, Mar 29 2016
Started a design document for the active stylesheet list updating:

http://bit.ly/25uxtnU

Project Member Comment 16 by bugdroid1@chromium.org, Mar 30 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef

commit 8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef
Author: rune <rune@opera.com>
Date: Wed Mar 30 16:53:06 2016

Introduce setNeedsActiveStyleUpdate for adding/removing stylesheets.

Remove the add/remove/modify methods which did not have different
implementations anyway. The plan is to let the async active stylesheet
update detect which StyleSheetContents have been added and which have
been removed and invalidate style and caches accordingly.

I've started to write up the plan here: http://bit.ly/25uxtnU

BUG=567021

Review URL: https://codereview.chromium.org/1843693002

Cr-Commit-Position: refs/heads/master@{#384008}

[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/Document.h
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/StyleElement.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp

Project Member Comment 17 by bugdroid1@chromium.org, Mar 30 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef

commit 8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef
Author: rune <rune@opera.com>
Date: Wed Mar 30 16:53:06 2016

Introduce setNeedsActiveStyleUpdate for adding/removing stylesheets.

Remove the add/remove/modify methods which did not have different
implementations anyway. The plan is to let the async active stylesheet
update detect which StyleSheetContents have been added and which have
been removed and invalidate style and caches accordingly.

I've started to write up the plan here: http://bit.ly/25uxtnU

BUG=567021

Review URL: https://codereview.chromium.org/1843693002

Cr-Commit-Position: refs/heads/master@{#384008}

[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/Document.h
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/StyleElement.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
[modify] https://crrev.com/8d5bee68bf505c4c0c4e1369d3a28d7ce021a6ef/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp

Project Member Comment 18 by bugdroid1@chromium.org, Mar 31 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f6c2701c8ad1c3dbde1aafb69f66861dfd1159ec

commit f6c2701c8ad1c3dbde1aafb69f66861dfd1159ec
Author: rune <rune@opera.com>
Date: Thu Mar 31 10:06:59 2016

Add trace event for updateActiveStyleSheets.

Added for inspecting performance changes for async stylesheet update
and show how much time stylesheet update will account for when moved to
the updateLayoutTree part of the lifecycle.

Will not be called often enough to cause a performance issue in itself.

R=mstensho@opera.com
BUG=567021

Review URL: https://codereview.chromium.org/1843063005

Cr-Commit-Position: refs/heads/master@{#384237}

[modify] https://crrev.com/f6c2701c8ad1c3dbde1aafb69f66861dfd1159ec/third_party/WebKit/Source/core/dom/StyleEngine.cpp

Comment 19 by r...@opera.com, Apr 14 2016
Active stylesheet comparison:

https://codereview.chromium.org/1889993002/
Comment 20 by r...@opera.com, Apr 14 2016
Blocking: 603621
Comment 21 by r...@opera.com, Apr 29 2016
Blocking: 318468
Project Member Comment 22 by bugdroid1@chromium.org, Jun 9 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/debc55c49bd4a79870be6482bc4466971cdb5a1b

commit debc55c49bd4a79870be6482bc4466971cdb5a1b
Author: rune <rune@opera.com>
Date: Thu Jun 09 09:34:26 2016

Make sure CSS agent messages flush before testing.

While working on updating active stylesheets as part of the style and
layout tree update in [1], two inspector tests started failing. The
reason was these tests rely on a console message to trigger a step in
the test after the active stylesheets have been pushed to the inspector
client. But even if the stylesheets were updated in InspectorCSSAgent
before the console message was sent, the console message arrived in the
client before the new active stylesheets. The reason was that the
console message is immediately flushed, while the messages from the
InspectorCSSAgent are lazily flushed from WebDevToolsAgentImpl::
didProcessTask.

I tried to force the active stylesheet update with a forced layout tree
update like this:

  document.documentElement.offsetTop;
  console.log(...);

But, due the console.log message being dispatched first as described
above, I ended up postponing the console.log with a rAF which means it
will run in a later task and the didProcessTask will trigger in between
to flush the active stylesheet message(s).

Note that this was not currently causing any failures. It's done in
preparation for landing changes for 567021 without breaking anything.

Looking at TestExpectations, I noticed crbug.com/597572, which might be
a similar issue.

[1] https://codereview.chromium.org/1913833002/

R=pfeldman@chromium.org,dgozman@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2049283002
Cr-Commit-Position: refs/heads/master@{#398825}

[modify] https://crrev.com/debc55c49bd4a79870be6482bc4466971cdb5a1b/third_party/WebKit/LayoutTests/http/tests/inspector/resource-tree/resources/script-navigated.js

Project Member Comment 23 by bugdroid1@chromium.org, Jun 15 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/debc55c49bd4a79870be6482bc4466971cdb5a1b

commit debc55c49bd4a79870be6482bc4466971cdb5a1b
Author: rune <rune@opera.com>
Date: Thu Jun 09 09:34:26 2016

Make sure CSS agent messages flush before testing.

While working on updating active stylesheets as part of the style and
layout tree update in [1], two inspector tests started failing. The
reason was these tests rely on a console message to trigger a step in
the test after the active stylesheets have been pushed to the inspector
client. But even if the stylesheets were updated in InspectorCSSAgent
before the console message was sent, the console message arrived in the
client before the new active stylesheets. The reason was that the
console message is immediately flushed, while the messages from the
InspectorCSSAgent are lazily flushed from WebDevToolsAgentImpl::
didProcessTask.

I tried to force the active stylesheet update with a forced layout tree
update like this:

  document.documentElement.offsetTop;
  console.log(...);

But, due the console.log message being dispatched first as described
above, I ended up postponing the console.log with a rAF which means it
will run in a later task and the didProcessTask will trigger in between
to flush the active stylesheet message(s).

Note that this was not currently causing any failures. It's done in
preparation for landing changes for 567021 without breaking anything.

Looking at TestExpectations, I noticed crbug.com/597572, which might be
a similar issue.

[1] https://codereview.chromium.org/1913833002/

R=pfeldman@chromium.org,dgozman@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2049283002
Cr-Commit-Position: refs/heads/master@{#398825}

[modify] https://crrev.com/debc55c49bd4a79870be6482bc4466971cdb5a1b/third_party/WebKit/LayoutTests/http/tests/inspector/resource-tree/resources/script-navigated.js

Project Member Comment 24 by bugdroid1@chromium.org, Jun 27 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/97c1dc4aa9e0e242e1b79ffad84806865c782509

commit 97c1dc4aa9e0e242e1b79ffad84806865c782509
Author: rune <rune@opera.com>
Date: Mon Jun 27 08:48:41 2016

Move preferred stylesheet set out of active sheet update.

There are two reasons for this:

1. In preparation for async active stylesheet update, in which case
   setting the preferred stylesheet set would otherwise be happening
   too late.

2. Doing it during the active stylesheet update means only the
   alternate stylesheets following the link with the title setting the
   preferred sheet set would be enabled appropriately. crbug.com/621479

This CL is split out of https://codereview.chromium.org/1913833002

R=timloh@chromium.org
BUG=567021,621479

Review-Url: https://codereview.chromium.org/2079303002
Cr-Commit-Position: refs/heads/master@{#402139}

[add] https://crrev.com/97c1dc4aa9e0e242e1b79ffad84806865c782509/third_party/WebKit/LayoutTests/fast/css/preferred-stylesheet-enabling-alternate.html
[modify] https://crrev.com/97c1dc4aa9e0e242e1b79ffad84806865c782509/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp
[modify] https://crrev.com/97c1dc4aa9e0e242e1b79ffad84806865c782509/third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp
[modify] https://crrev.com/97c1dc4aa9e0e242e1b79ffad84806865c782509/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/97c1dc4aa9e0e242e1b79ffad84806865c782509/third_party/WebKit/Source/core/dom/StyleSheetCandidate.cpp
[modify] https://crrev.com/97c1dc4aa9e0e242e1b79ffad84806865c782509/third_party/WebKit/Source/core/dom/StyleSheetCandidate.h
[modify] https://crrev.com/97c1dc4aa9e0e242e1b79ffad84806865c782509/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp

Project Member Comment 25 by bugdroid1@chromium.org, Jun 30 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9c88a15f059aec65af294b8789a27cc377363da6

commit 9c88a15f059aec65af294b8789a27cc377363da6
Author: rune <rune@opera.com>
Date: Thu Jun 30 08:10:17 2016

Optimize style recalc when adding @keyframes.

We only need to recalculate the elements with running animations unless
we tried to find an @keyframes rule and couldn't, for which we fall
back to a full document recalc.

The motivation for doing this is that the current WIP for issue 567021
shows that we're still getting full document recalcs due to the
presence of @keyframes rules.

R=dstockwell@chromium.org,alancutter@chromium.org
BUG=623911,567021

Review-Url: https://codereview.chromium.org/2105743002
Cr-Commit-Position: refs/heads/master@{#403118}

[add] https://crrev.com/9c88a15f059aec65af294b8789a27cc377363da6/third_party/WebKit/LayoutTests/animations/add-keyframes-recalc.html
[modify] https://crrev.com/9c88a15f059aec65af294b8789a27cc377363da6/third_party/WebKit/Source/core/animation/Animation.cpp
[modify] https://crrev.com/9c88a15f059aec65af294b8789a27cc377363da6/third_party/WebKit/Source/core/animation/Animation.h
[modify] https://crrev.com/9c88a15f059aec65af294b8789a27cc377363da6/third_party/WebKit/Source/core/animation/AnimationTimeline.cpp
[modify] https://crrev.com/9c88a15f059aec65af294b8789a27cc377363da6/third_party/WebKit/Source/core/animation/AnimationTimeline.h
[modify] https://crrev.com/9c88a15f059aec65af294b8789a27cc377363da6/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp
[modify] https://crrev.com/9c88a15f059aec65af294b8789a27cc377363da6/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp
[modify] https://crrev.com/9c88a15f059aec65af294b8789a27cc377363da6/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.h
[modify] https://crrev.com/9c88a15f059aec65af294b8789a27cc377363da6/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/9c88a15f059aec65af294b8789a27cc377363da6/third_party/WebKit/Source/core/dom/StyleEngine.h

Project Member Comment 26 by bugdroid1@chromium.org, Sep 5 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f9d162281661e2fb8805814513a549683775d56b

commit f9d162281661e2fb8805814513a549683775d56b
Author: rune <rune@opera.com>
Date: Mon Sep 05 10:18:09 2016

Implemented RuleSet diff for active stylesheets.

This is an implementation of the diffing of active stylesheets outlined
in [1] to replace the current compareStyleSheets method in
TreeScopeStyleSheetCollection which currently cause a "Reconstruct" if
you both have insertions and removals. With async stylesheet update we
will more likely end up in those situations as changes to the list can
happen in a batches.

An important new aspect here is that together with each stylesheet keep
a traced pointer to the RuleSet it had reference last time the active
stylesheet list was updated. That way we can figure out what changed on
media query and CSSOM changes.

The comparison algorithm works like this:

INPUTS: The new and old active stylesheet vectors
OUTPUTS: A vector of added and removed RuleSets.
         Also a return value saying if we only appended stylesheets at
         the end. Given that sheets were only appended we can do certain
         optimizations updating rule data.

* First linearly walk the old and new active list as long as the
  stylesheet pointers are the same. If the ruleset changed for the
  given sheet, add the old and new rulesets to the list of changed
  rulesets.

* If we are finished walking any of the active lists, we have either
  appended a set of sheets to the end, or we have removed a set from
  the tail. Add the added/removed rulesets to the changed list and we
  are finished.

* If we have remaining sheets in both the old and new active list,
  merge the remaining items from both lists and sort the merged vector
  on stylesheet pointers. For stylesheet pointers occuring in pairs, if
  the rulesets are different for the two entries, the ruleset changed
  so we add them to the changed list. For stylesheets which do not occur
  in pairs, they are either added or removed and we add the ruleset to
  the changed list.

The time complexity for the algorithm is O(k) for the common prefix
and the complexity for std::sort for the m + n remaining sheets in the
new and old active lists. Note that each scope has its active list, so
the larger n's will be for the document scope as shadow trees most
often have a single stylesheet (I measured a max of three running some
Polymer apps).

An assumption here is that we will do ensureRuleSet() including media
query evaluation for the media attribute as we collect active
stylesheets. Currently, the analysis of which elements needs a style
recalc happens synchronously while updating the active sheets while the
rulesets are (re-)created asynchronously/on-demand via
lazyAppendAuthorStyleSheets in StyleResolver. The idea is that since
the active stylesheet update will be async, we can drop the lazyAppend
things from StyleResolver and add the stylesheets directly to the
ScopedStyleResolvers during the active stylesheet update.

Creating the RuleSets as we collect active stylesheets means we have
invalidation sets readily available to use style invalidation to
trigger style recalcs only on elements affected by the added/removed
stylesheets.

[1] http://bit.ly/25uxtnU

R=esprehn@chromium.org,timloh@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/1889993002
Cr-Commit-Position: refs/heads/master@{#416520}

[modify] https://crrev.com/f9d162281661e2fb8805814513a549683775d56b/third_party/WebKit/Source/core/BUILD.gn
[add] https://crrev.com/f9d162281661e2fb8805814513a549683775d56b/third_party/WebKit/Source/core/css/ActiveStyleSheets.cpp
[add] https://crrev.com/f9d162281661e2fb8805814513a549683775d56b/third_party/WebKit/Source/core/css/ActiveStyleSheets.h
[add] https://crrev.com/f9d162281661e2fb8805814513a549683775d56b/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp
[modify] https://crrev.com/f9d162281661e2fb8805814513a549683775d56b/third_party/WebKit/Source/core/css/BUILD.gn

Project Member Comment 27 by bugdroid1@chromium.org, Sep 20 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9831d308f547fba256521a119b21b6f87db43e4e

commit 9831d308f547fba256521a119b21b6f87db43e4e
Author: rune <rune@opera.com>
Date: Tue Sep 20 09:20:56 2016

Prepare to use invalidation set for adding/removing RuleSets.

Currently, we sometimes use StyleSheetInvalidationAnalysis to be smart
about recalculating affected element when adding/removing a stylesheet.

The plan is to start using the StyleInvalidator to trigger style
recalculations When adding/removing stylesheets. We will then use the
invalidation sets from the stylesheet RuleSet and schedule them on
elements in the stylesheet's document or shadow tree.

We fall back to a full recalc for the document / shadow tree for if we
find selectors which don't have simple selectors for which we have an
invalidation set we can use. This is similar to what we do with the
universalSiblingInvalidationSet for DOM mutations.

This first implementation supports id, class, attribute, and type
selectors in the rightmost compound[1]. We could later support to use
invalidation sets for universal pseudo class rules like ":hover".

The invalidations are to be scheduled for elements in the same
TreeScope as the stylesheet, including the host element.

Rules which are boundary crossing have their features collected in
ScopedStyleResolver::addTreeBoundaryCrossingRules() and not in their
respective stylesheet's RuleSet. We fall back to full style recalc
for rules containing ::content, ::shadow, and /deep/. ::slotted rules
are currently also collected on the ScopedStyleResolver, but in order
to avoid full recalcs, we do LocalStyleChange on slot-distributed
elements for RuleSet invalidations when there are ::slotted rules in
the RuleSet.

As mentioned earlier we will schedule invalidations on the host element
as well, which means we will schedule the invalidation set for ".a" for
":host(.a)". :host-context() do also support RuleSet invalidation as
long as there are features in addition to the ones inside the
:host-context() pseudo.

As for sibling invalidations on DOM mutations, negated selectors like
":not(.a)" are considered universal.

This CL is split out of [2]. The next step is to land the invalidation
code in StyleEngine from the same CL.

[1] Even though we don't have invalidation sets for tag names, we can
check the presence of rules in the tag name hash map for the RuleSet.
This means "body *" will cause a full recalc, but "body" won't. Also
note that "div.enabled" will cause every div element to be invalidated
because the rule would end up in the class rule hashmap.

[2] https://codereview.chromium.org/1913833002/

R=ericwilligers@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2326033002
Cr-Commit-Position: refs/heads/master@{#419704}

[modify] https://crrev.com/9831d308f547fba256521a119b21b6f87db43e4e/third_party/WebKit/Source/core/css/RuleFeature.cpp
[modify] https://crrev.com/9831d308f547fba256521a119b21b6f87db43e4e/third_party/WebKit/Source/core/css/RuleFeature.h
[modify] https://crrev.com/9831d308f547fba256521a119b21b6f87db43e4e/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp
[modify] https://crrev.com/9831d308f547fba256521a119b21b6f87db43e4e/third_party/WebKit/Source/core/css/RuleSet.h

Project Member Comment 28 by bugdroid1@chromium.org, Sep 21 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3cf2f58b1be6065c5c8264e60d414ec9531a6449

commit 3cf2f58b1be6065c5c8264e60d414ec9531a6449
Author: rune <rune@opera.com>
Date: Wed Sep 21 09:22:52 2016

Make stylesheet owner node a reference instead of pointer.

The CSSStyleSheet owner node is always non-null when passed in on
sheet creation. Make it a reference in various APIs.

The real change here that triggered this was the realization that
StyleEngine::createSheet is always called with an owner node which
belongs to the very same Document/StyleEngine. So we can turn:

  e->document().styleEngine().addPendingSheet(context);

into:

  addPendingSheet(context);

Also made parseSheet non-static as it needed the StyleEngine pointer
anyway.

R=sashab@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2354773003
Cr-Commit-Position: refs/heads/master@{#420018}

[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/css/CSSStyleSheet.h
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/css/CSSTestHelper.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/dom/StyleElement.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/dom/StyleElement.h
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollection.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollection.h
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp
[modify] https://crrev.com/3cf2f58b1be6065c5c8264e60d414ec9531a6449/third_party/WebKit/Source/core/svg/SVGStyleElement.cpp

Project Member Comment 29 by bugdroid1@chromium.org, Sep 21 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/7bff558df449b9b0542b4b617331518f9ae7f36e

commit 7bff558df449b9b0542b4b617331518f9ae7f36e
Author: rune <rune@opera.com>
Date: Wed Sep 21 23:16:36 2016

Implemented scoped invalidation for added/removed RuleSets.

Async stylesheet update will schedule invalidation sets based on the
RuleFeatureSets for added/removed stylesheets. Implement the
functionality in StyleEngine for scheduling invalidations in the
stylesheet's TreeScope, including host and slotted elements if
applicable.

R=ericwilligers@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2333693002
Cr-Commit-Position: refs/heads/master@{#420192}

[modify] https://crrev.com/7bff558df449b9b0542b4b617331518f9ae7f36e/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/7bff558df449b9b0542b4b617331518f9ae7f36e/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/7bff558df449b9b0542b4b617331518f9ae7f36e/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp

Project Member Comment 30 by bugdroid1@chromium.org, Oct 7 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bb06955a67e20f613553b44a7b89c2ae0a2ba5f1

commit bb06955a67e20f613553b44a7b89c2ae0a2ba5f1
Author: rune <rune@opera.com>
Date: Fri Oct 07 06:04:49 2016

Allow active sheets to have nullptr for RuleSet.

CSSStyleSheets which have a non-matching media attribute may have a
nullptr for RuleSet since it's not needed. Handle that in active style-
sheet diffing. That means adding a sheet with non-matching media should
not cause any style recalculations.

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2401573002
Cr-Commit-Position: refs/heads/master@{#423804}

[modify] https://crrev.com/bb06955a67e20f613553b44a7b89c2ae0a2ba5f1/third_party/WebKit/Source/core/css/ActiveStyleSheets.cpp
[modify] https://crrev.com/bb06955a67e20f613553b44a7b89c2ae0a2ba5f1/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp

Project Member Comment 31 by bugdroid1@chromium.org, Oct 7 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f8da12ea4e2bb01417c8a86a4e2b21f54b5d93fd

commit f8da12ea4e2bb01417c8a86a4e2b21f54b5d93fd
Author: rune <rune@opera.com>
Date: Fri Oct 07 06:45:50 2016

Apply RuleSet changes for active stylesheet changes.

Introduce an applyRuleSetChanges method which will take the old and new
ActiveStyleSheetVector use the existing comparison method and apply the
RuleSet diff to invalidate style for the document.

The normal mode for style rules is to schedule RuleSet invalidations
which will decide what to recalculate based on the invalidation sets.
Universal selectors, the presence of Shadow DOM v0 combinators, or
@font-face rules for the document scope, will cause a subtree recalc
for the TreeScope.

@keyframes rules utilizes the existing functionality for invalidating
style in the TreeScope and the host TreeScope for running and
unresolved animations.

This CL introduces appendActiveStyleSheets which will eventually
replace the combination of the lazy appending of sheets in
StyleResolver and appending pending sheets into the ScopedStyleResolver
through appendCSSStyleSheet.

This CL is split out of https://codereview.chromium.org/1913833002 and
re-worked a bit.

The functionality is not yet in use.

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2394353003
Cr-Commit-Position: refs/heads/master@{#423810}

[modify] https://crrev.com/f8da12ea4e2bb01417c8a86a4e2b21f54b5d93fd/third_party/WebKit/Source/core/css/ActiveStyleSheets.cpp
[modify] https://crrev.com/f8da12ea4e2bb01417c8a86a4e2b21f54b5d93fd/third_party/WebKit/Source/core/css/ActiveStyleSheets.h
[modify] https://crrev.com/f8da12ea4e2bb01417c8a86a4e2b21f54b5d93fd/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp
[modify] https://crrev.com/f8da12ea4e2bb01417c8a86a4e2b21f54b5d93fd/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
[modify] https://crrev.com/f8da12ea4e2bb01417c8a86a4e2b21f54b5d93fd/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.h
[modify] https://crrev.com/f8da12ea4e2bb01417c8a86a4e2b21f54b5d93fd/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/f8da12ea4e2bb01417c8a86a4e2b21f54b5d93fd/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/f8da12ea4e2bb01417c8a86a4e2b21f54b5d93fd/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp

Project Member Comment 32 by bugdroid1@chromium.org, Oct 18 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5f7120199c7334506d9384891532f864512ae3b8

commit 5f7120199c7334506d9384891532f864512ae3b8
Author: rune <rune@opera.com>
Date: Tue Oct 18 11:51:59 2016

Implement collection of @viewport rules from DocumentStyleCollection.

The @viewport rules will be recollected and re-resolved from a new
updateViewport() method. Rule will need to be re-collected when
stylesheets are added, or when media queries change. Re-resolution
needs to happen when the viewport descriptors contain vh/vw units, or
after a re-collection of rules.

Store the viewport and device dependent mq results on the
ViewportStyleResolver as these may be different from the results
collected when constructing the rulesets because of the initial/actual
viewport difference. The device dependent will not be different, but
nested media queries may cause some media queries to be skipped for
ruleset construction which would not be skipped for @viewport rule
collection.

We also change the existing code to lazily reset() in preparation for
the re-collect/re-resolve distinction.

R=timloh@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2424823002
Cr-Commit-Position: refs/heads/master@{#425942}

[modify] https://crrev.com/5f7120199c7334506d9384891532f864512ae3b8/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.cpp
[modify] https://crrev.com/5f7120199c7334506d9384891532f864512ae3b8/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.h
[modify] https://crrev.com/5f7120199c7334506d9384891532f864512ae3b8/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp
[modify] https://crrev.com/5f7120199c7334506d9384891532f864512ae3b8/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.h

Project Member Comment 33 by bugdroid1@chromium.org, Oct 20 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17

commit 70d21a8093c3096a01fa62e6ac7c7bdba3aeca17
Author: rune <rune@opera.com>
Date: Thu Oct 20 07:56:44 2016

Collect @viewport before constructing RuleSets.

- Move ViewportStyleResolver to StyleEngine.

- Only create a ViewportStyleResolver for top level documents.

- Collect @viewport rules via the DocumentStyleSheetCollection.

- Use the initial viewport size for resolving viewport relative
  lengths.

- Introduce initialViewportChanged() and viewportRulesChanged() in
  StyleEngine to trigger re-collection and resolution of the actual
  viewport. These currently trigger an immediate call to updateViewport
  which will later be a part of the document lifecycle phase for
  updating active stylesheets.

This finally fixes issues 332763, 455136, and 463098.

R=timloh@chromium.org
BUG=567021,463098,455136,332763

Review-Url: https://chromiumcodereview.appspot.com/2420413005
Cr-Commit-Position: refs/heads/master@{#426427}

[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/css/RuleSet.cpp
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/css/RuleSet.h
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.h
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/css/resolver/StyleResolver.h
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.cpp
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.h
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/frame/FrameView.cpp
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/core/page/Page.cpp
[modify] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
[add] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/web/tests/data/viewport-and-media.html
[add] https://crrev.com/70d21a8093c3096a01fa62e6ac7c7bdba3aeca17/third_party/WebKit/Source/web/tests/data/viewport-lengths.html

Project Member Comment 34 by bugdroid1@chromium.org, Oct 25 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/c65b3eb1cc989a7a13813e4ef68042ae2e030c22

commit c65b3eb1cc989a7a13813e4ef68042ae2e030c22
Author: rune <rune@opera.com>
Date: Tue Oct 25 06:08:36 2016

Move TreeBoundaryCrossingScopes to StyleEngine.

This is split out of the work for async stylesheet updates [1], but is
also part of the work on componentized style resolving in general.

The moved resetAuthorStyle method on StyleEngine may soon be gone
altogether as it does so in [1].

The plan is that TreeBoundaryCrossingScopes will also be completely
gone when we remove support for Shadow DOM v0. For Shadow DOM v1 we can
look up the scoped resolvers for the affecting scopes directly like we
already do in StyleResolver::matchScopedRules for the pure v1 case.

The documentation of the special casing of VTT and custom pseudo
elements is updated to not suggest that these rules are handled as part
of boundary crossing scopes as the current solution is better once v0
shadows go away.

[1] https://codereview.chromium.org/1913833002

R=meade@chromium.org
BUG=567021,401359

Review-Url: https://codereview.chromium.org/2443933002
Cr-Commit-Position: refs/heads/master@{#427284}

[modify] https://crrev.com/c65b3eb1cc989a7a13813e4ef68042ae2e030c22/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
[modify] https://crrev.com/c65b3eb1cc989a7a13813e4ef68042ae2e030c22/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/c65b3eb1cc989a7a13813e4ef68042ae2e030c22/third_party/WebKit/Source/core/css/resolver/StyleResolver.h
[modify] https://crrev.com/c65b3eb1cc989a7a13813e4ef68042ae2e030c22/third_party/WebKit/Source/core/dom/DocumentOrderedList.h
[modify] https://crrev.com/c65b3eb1cc989a7a13813e4ef68042ae2e030c22/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp
[modify] https://crrev.com/c65b3eb1cc989a7a13813e4ef68042ae2e030c22/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp
[modify] https://crrev.com/c65b3eb1cc989a7a13813e4ef68042ae2e030c22/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/c65b3eb1cc989a7a13813e4ef68042ae2e030c22/third_party/WebKit/Source/core/dom/StyleEngine.h

Project Member Comment 35 by bugdroid1@chromium.org, Oct 28 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/17bc158897bb9b9d6b1400ed76092a412de16bc9

commit 17bc158897bb9b9d6b1400ed76092a412de16bc9
Author: rune <rune@opera.com>
Date: Fri Oct 28 10:20:27 2016

Move Document global rule data to CSSGlobalRuleSet.

This CL is split out from [1] with some modifications.

Instead of storing these data in the StyleResolver, create a new class
to store them in StyleEngine instead. See the design document linked
from issue 401359 which talks about moving this content off of
StyleResolver. Also made a note that we should further try to contain
as much of this data as possible per TreeScope to avoid the need for
constantly having to update these meta data for shadow tree
modifications.

We get rid of some of the duplicate storing of some of these features.
See what was previously set on StyleEngine (resetCSSFeatureFlags()).

This is also in preparation for async stylesheet update (issue 567021).
There are few places where we synchronously update this new rule set
directly after marking it as dirty which will happen later when all
parts of [1] lands.

Another synchronous update we will be able to remove later is making
the RuleFeatureSet up-to-date when scheduling style invalidations
(marked as TODOs for sync calls to ensureResolver()). The need for
these calls is supported by the added invalidation tests which would
otherwise fail.

[1] https://codereview.chromium.org/1913833002/

BUG=401359,567021

Review-Url: https://codereview.chromium.org/2451893003
Cr-Commit-Position: refs/heads/master@{#428327}

[add] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/LayoutTests/fast/css/invalidation/class-invalidation-after-adding-sheet.html
[modify] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/Source/core/css/BUILD.gn
[modify] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/Source/core/css/CSSDefaultStyleSheets.cpp
[modify] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/Source/core/css/CSSDefaultStyleSheets.h
[add] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/Source/core/css/CSSGlobalRuleSet.cpp
[add] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/Source/core/css/CSSGlobalRuleSet.h
[modify] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/Source/core/css/resolver/StyleResolver.h
[modify] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/Source/core/dom/Element.cpp
[modify] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/Source/core/dom/Fullscreen.cpp
[modify] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/17bc158897bb9b9d6b1400ed76092a412de16bc9/third_party/WebKit/Source/core/dom/StyleEngine.h

Cc: yosin@chromium.org
Project Member Comment 37 by bugdroid1@chromium.org, Nov 10 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/c2e0d164125e177ce62925ac66f9fcdb4f457e1c

commit c2e0d164125e177ce62925ac66f9fcdb4f457e1c
Author: rune <rune@opera.com>
Date: Thu Nov 10 09:49:15 2016

Moved applyRuleSetChanges functions to StyleEngine.

A lot of the side effects were calls to StyleEngine, so moved the
method there instead. Also fixed the TODO for adding the call to make
CSSGlobalRuleSet dirty.

BUG=567021

Review-Url: https://codereview.chromium.org/2487653002
Cr-Commit-Position: refs/heads/master@{#431227}

[modify] https://crrev.com/c2e0d164125e177ce62925ac66f9fcdb4f457e1c/third_party/WebKit/Source/core/css/ActiveStyleSheets.cpp
[modify] https://crrev.com/c2e0d164125e177ce62925ac66f9fcdb4f457e1c/third_party/WebKit/Source/core/css/ActiveStyleSheets.h
[modify] https://crrev.com/c2e0d164125e177ce62925ac66f9fcdb4f457e1c/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp
[modify] https://crrev.com/c2e0d164125e177ce62925ac66f9fcdb4f457e1c/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/c2e0d164125e177ce62925ac66f9fcdb4f457e1c/third_party/WebKit/Source/core/dom/StyleEngine.h

Project Member Comment 38 by bugdroid1@chromium.org, Nov 15 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b50a2f4a9fe9733ed204f55f83a2e32727ba003d

commit b50a2f4a9fe9733ed204f55f83a2e32727ba003d
Author: rune <rune@opera.com>
Date: Tue Nov 15 15:24:51 2016

Make updateStyleAndLayoutTree ready for async stylesheet update.

Introduce Document::updateActiveStyle() and corresponding
updateActiveStyle()/updateActiveStyleSheets() methods in StyleEngine to
prepare for doing active stylesheet updates as part of
updateStyleAndLayoutTree.

We move updateViewport() to updateActiveStyle() as the first step. This
is done by removing the synchronous calls to ViewportStyleResolver::
updateViewport() and instead schedule a layout tree update. In order to
trigger actual work to be done when the layout tree update happens, we
need to return true from Document::needsFullLayoutTreeUpdate() when we
need an active style update (for viewport atm).

BUG=567021

Review-Url: https://codereview.chromium.org/2484863003
Cr-Commit-Position: refs/heads/master@{#432182}

[modify] https://crrev.com/b50a2f4a9fe9733ed204f55f83a2e32727ba003d/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.cpp
[modify] https://crrev.com/b50a2f4a9fe9733ed204f55f83a2e32727ba003d/third_party/WebKit/Source/core/css/resolver/ViewportStyleResolver.h
[modify] https://crrev.com/b50a2f4a9fe9733ed204f55f83a2e32727ba003d/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/b50a2f4a9fe9733ed204f55f83a2e32727ba003d/third_party/WebKit/Source/core/dom/Document.h
[modify] https://crrev.com/b50a2f4a9fe9733ed204f55f83a2e32727ba003d/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp
[modify] https://crrev.com/b50a2f4a9fe9733ed204f55f83a2e32727ba003d/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/b50a2f4a9fe9733ed204f55f83a2e32727ba003d/third_party/WebKit/Source/core/dom/StyleEngine.h

Project Member Comment 39 by bugdroid1@chromium.org, Nov 16 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/33002601a6ab8429f122c105b3d0179730a3384f

commit 33002601a6ab8429f122c105b3d0179730a3384f
Author: rune <rune@opera.com>
Date: Wed Nov 16 21:23:23 2016

No forced active stylesheet recollect when pending sheets reach 0.

We forced a FullStyleUpdate which causes an active stylesheet update
for all tree scopes in the presence of placeholder style. What we need
to do for placeholder style is to trigger a full style recalc. For
instance, we don't need to update active stylesheets in shadow trees
if the last blocking resource that finishes loading is a document scope
stylesheet or import.

BUG=567021

Review-Url: https://codereview.chromium.org/2500923002
Cr-Commit-Position: refs/heads/master@{#432630}

[modify] https://crrev.com/33002601a6ab8429f122c105b3d0179730a3384f/third_party/WebKit/Source/core/dom/Document.cpp

Project Member Comment 40 by bugdroid1@chromium.org, Nov 23 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f01a414b7cafd436503dac1407fa7422533ffa47

commit f01a414b7cafd436503dac1407fa7422533ffa47
Author: rune <rune@opera.com>
Date: Wed Nov 23 11:08:55 2016

Move MediaQueryEvaluator from StyleResolver to StyleEngine.

The plan is to move active stylesheet update and viewport/device-
dependent media query results from StyleResolver to StyleEngine which
means it makes sense to move the MediaQueryEvaluator there as well.
That means that the StyleResolver will temporarily ask the StyleEngine
for the evaluator when needed.

See https://codereview.chromium.org/1913833002/ for planned changes.

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2521063005
Cr-Commit-Position: refs/heads/master@{#434144}

[modify] https://crrev.com/f01a414b7cafd436503dac1407fa7422533ffa47/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/f01a414b7cafd436503dac1407fa7422533ffa47/third_party/WebKit/Source/core/css/resolver/StyleResolver.h
[modify] https://crrev.com/f01a414b7cafd436503dac1407fa7422533ffa47/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/f01a414b7cafd436503dac1407fa7422533ffa47/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/f01a414b7cafd436503dac1407fa7422533ffa47/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/f01a414b7cafd436503dac1407fa7422533ffa47/third_party/WebKit/Source/core/frame/FrameView.cpp

Project Member Comment 41 by bugdroid1@chromium.org, Nov 24 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b84fb60b526a67365228bc2a4bb6f0005b21a555

commit b84fb60b526a67365228bc2a4bb6f0005b21a555
Author: rune <rune@opera.com>
Date: Thu Nov 24 18:44:44 2016

Check explicitly for style invalidation/recalc in @font-face test.

needsLayoutTreeUpdate will return true for needing to update the global
ruleset for async style update. Even if the test only tries to add a
@font-face rule, we unconditionally recollect the CSSGlobalRuleSet when
stylesheets are added or removed.

Instead check that adding a @font-face rule in a shadow tree does not
cause style invalidation or recalc.

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2520263002
Cr-Commit-Position: refs/heads/master@{#434367}

[modify] https://crrev.com/b84fb60b526a67365228bc2a4bb6f0005b21a555/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp

Project Member Comment 42 by bugdroid1@chromium.org, Nov 24 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2790e7fc5577e8f434410719e00f3b55a155c981

commit 2790e7fc5577e8f434410719e00f3b55a155c981
Author: rune <rune@opera.com>
Date: Thu Nov 24 18:58:18 2016

Force adding sheets and recalc for html import re-ordering.

When we remove an import link and re-insert it into the document, the
import Document and CSSStyleSheet pointers are persisted. That means the
comparison of active stylesheets is not able to figure out that the
order of the stylesheets have changed after insertion.

We fall back to re-add all sheets to the scoped resolver and recalculate
style for the whole document if we remove an import in case it is re-
inserted into the document. The assumption is that removing html imports
is very rare.

For re-ordering of link rel=stylesheet the CSSStyleSheet object is
cleared on removal and recreated on insertion. Since the active
stylesheet list keeps references to CSSStyleSheet, CSSStyleSheet
pointers will not be re-used.

R=meade@chromium.org
TEST=fast/html/imports/import-readd-*
BUG=567021

Review-Url: https://codereview.chromium.org/2519393002
Cr-Commit-Position: refs/heads/master@{#434374}

[modify] https://crrev.com/2790e7fc5577e8f434410719e00f3b55a155c981/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp
[modify] https://crrev.com/2790e7fc5577e8f434410719e00f3b55a155c981/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
[modify] https://crrev.com/2790e7fc5577e8f434410719e00f3b55a155c981/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.h
[modify] https://crrev.com/2790e7fc5577e8f434410719e00f3b55a155c981/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/2790e7fc5577e8f434410719e00f3b55a155c981/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/2790e7fc5577e8f434410719e00f3b55a155c981/third_party/WebKit/Source/core/html/imports/LinkImport.cpp
[modify] https://crrev.com/2790e7fc5577e8f434410719e00f3b55a155c981/third_party/WebKit/Source/core/html/imports/LinkImport.h

Project Member Comment 43 by bugdroid1@chromium.org, Nov 24 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4462ce68a6f0808d4f3d7e530b4920250d3675fd

commit 4462ce68a6f0808d4f3d7e530b4920250d3675fd
Author: rune <rune@opera.com>
Date: Thu Nov 24 19:50:19 2016

Move MediaQueryResults to RuleFeatureSet.

The existing code only cleared the query results on the StyleResolver
when the StyleResolver was cleared. That meant we could end up in a
situation where the result list was ever-growing. That wasn't a big
issue in practice as the StyleResolver would be cleared quite often on
stylesheet changes. However, that will change when the RuleSet based
style invalidation is enabled.

We move the media query results to RuleFeatureSet so that:

- Results for @media rules are stored in RuleFeatureSet instead of
  RuleSet.
- Results for media attributes are stored in the ScopedStyleResolver
  when added instead of appending them directly to StyleResolver.
- Accumulated results for all scopes are stored in CSSGlobalRuleSet
  on StyleEngine instead of StyleResolver and are accumulated with
  other rule features in ScopedStyleResolver::collectFeaturesTo().

This CL introduces StyleEngine::ruleSetForSheet() for evaluating the
media attribute of the stylesheet node and create the RuleSet if the
media attribute matches. That way we are able to make the
MediaQueryEvaluator private to StyleEngine. Also, this method is
required when we start using ActiveStyleSheets.

R=meade@chromium.org
BUG=567021,614026

Review-Url: https://codereview.chromium.org/2528633003
Cr-Commit-Position: refs/heads/master@{#434383}

[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/css/CSSStyleSheet.h
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/css/RuleFeature.cpp
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/css/RuleFeature.h
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/css/RuleSet.cpp
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/css/RuleSet.h
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.h
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/css/resolver/StyleResolver.h
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
[modify] https://crrev.com/4462ce68a6f0808d4f3d7e530b4920250d3675fd/third_party/WebKit/Source/core/frame/FrameView.cpp

Project Member Comment 44 by bugdroid1@chromium.org, Nov 25 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ff9f0b0877fcbe48fef3a32fc1c86cb706764b54

commit ff9f0b0877fcbe48fef3a32fc1c86cb706764b54
Author: rune <rune@opera.com>
Date: Fri Nov 25 05:41:35 2016

Check for styleResolver() in preparation for async style update.

Currently, active stylesheets are appended to ScopedStyleResolver
through the StyleResolver. When we move to async stylesheet update with
ActiveStyleSheets being appended from StyleEngine, styleResolver() is
typically null the first time we update the active stylesheets.

Add a null check before accessing styleResolver() when adding
@font-face rules.

R=nainar@chromium.org,meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2522423002
Cr-Commit-Position: refs/heads/master@{#434437}

[modify] https://crrev.com/ff9f0b0877fcbe48fef3a32fc1c86cb706764b54/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp

Project Member Comment 45 by bugdroid1@chromium.org, Nov 29 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/c3481b639b36688d7f855ebd3de077dd9466a7f8

commit c3481b639b36688d7f855ebd3de077dd9466a7f8
Author: rune <rune@opera.com>
Date: Tue Nov 29 09:41:16 2016

Introduce markAllTreeScopesDirty.

When we need to recollect active stylesheets for all scopes, have an
explicit markAllTreeScopesDirty method instead of relying on
FullStyleUpdate which will go away for async active stylesheet updates.

This CL does not contain functional changes.

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2534863002
Cr-Commit-Position: refs/heads/master@{#434940}

[modify] https://crrev.com/c3481b639b36688d7f855ebd3de077dd9466a7f8/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/c3481b639b36688d7f855ebd3de077dd9466a7f8/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/c3481b639b36688d7f855ebd3de077dd9466a7f8/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp

Project Member Comment 46 by bugdroid1@chromium.org, Dec 2 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3923dd2cc24a9f454b4c09f2f020718969b61f3a

commit 3923dd2cc24a9f454b4c09f2f020718969b61f3a
Author: rune <rune@opera.com>
Date: Fri Dec 02 12:26:12 2016

Make updateStyleInvalidationIfNeeded() private.

It is not invoked outside of Document.

This is split out of the larger CL for 567021.

R=mstensho@opera.com
BUG=567021

Review-Url: https://codereview.chromium.org/2537863006
Cr-Commit-Position: refs/heads/master@{#435922}

[modify] https://crrev.com/3923dd2cc24a9f454b4c09f2f020718969b61f3a/third_party/WebKit/Source/core/dom/Document.h

Project Member Comment 47 by bugdroid1@chromium.org, Dec 5 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2e3e5148b008e60b37270fec3f6099914550a310

commit 2e3e5148b008e60b37270fec3f6099914550a310
Author: rune <rune@opera.com>
Date: Mon Dec 05 07:22:09 2016

Correctly re-collect active style for html imports.

- Need to re-collect active stylesheets when inserting already cached
  import documents.

- Missing markDocumentDirty() when inserting import documents.

- Added test for missing coverage of the need for marking for re-
  collection from HTMLImportChild::ownerInserted().

The fact that we need to recollect sheets in the document scope and
recalculate style for the whole document is not a perf regression, this
is how it used to be before considering the async stylesheet update
with ruleset invalidations, but ideally we would like to do better.
It's unlikely a common use case as html imports are typically loaded in
head as script and rendering blocking.

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2551473002
Cr-Commit-Position: refs/heads/master@{#436238}

[add] https://crrev.com/2e3e5148b008e60b37270fec3f6099914550a310/third_party/WebKit/LayoutTests/fast/html/imports/import-add-child-to-change-order-of-dup-css.html
[modify] https://crrev.com/2e3e5148b008e60b37270fec3f6099914550a310/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/2e3e5148b008e60b37270fec3f6099914550a310/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/2e3e5148b008e60b37270fec3f6099914550a310/third_party/WebKit/Source/core/html/imports/HTMLImportChild.cpp
[modify] https://crrev.com/2e3e5148b008e60b37270fec3f6099914550a310/third_party/WebKit/Source/core/html/imports/LinkImport.cpp

Project Member Comment 48 by bugdroid1@chromium.org, Dec 5 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/27d26e3a00a4e59b6b52071dcd177fcb45f91a97

commit 27d26e3a00a4e59b6b52071dcd177fcb45f91a97
Author: rune <rune@opera.com>
Date: Mon Dec 05 09:38:13 2016

Schedule layout tree update for dirty tree scopes.

In preparation for async stylesheet update, schedule a layout tree
update when marking tree scopes dirty for active style sheets. This is
necessary to trigger a beginFrame which will in turn call
updateActiveStyle as part of the lifecycle update.

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2547883002
Cr-Commit-Position: refs/heads/master@{#436248}

[modify] https://crrev.com/27d26e3a00a4e59b6b52071dcd177fcb45f91a97/third_party/WebKit/Source/core/dom/StyleEngine.cpp

Comment 49 by r...@opera.com, Dec 6 2016
Blockedon: 671596
Project Member Comment 50 by bugdroid1@chromium.org, Dec 8 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/11bf99aa6426685ed8bf15b98a2680b02a841455

commit 11bf99aa6426685ed8bf15b98a2680b02a841455
Author: rune <rune@opera.com>
Date: Thu Dec 08 08:46:56 2016

Make setNeedsActiveStyleUpdate mark treescope dirty only.

Pass the treeScope instead of a stylesheet pointer and remove the
synchronous resolverChanged() call. Instead add the resolveChanged()
calls where currently necessary and mark them for removal.

This makes the setNeedsActiveStyleUpdate implementation like what we
want to end up with [1]. I've done it this way to make the following
CLs easier to review.

Also, setNeedsActiveStyleUpdate calls are removed where we call
removeStyleSheetCandidateNode() since that method already marks the
tree-scope dirty.

[1] https://codereview.chromium.org/1913833002/

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2546393002
Cr-Commit-Position: refs/heads/master@{#437212}

[modify] https://crrev.com/11bf99aa6426685ed8bf15b98a2680b02a841455/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp
[modify] https://crrev.com/11bf99aa6426685ed8bf15b98a2680b02a841455/third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp
[modify] https://crrev.com/11bf99aa6426685ed8bf15b98a2680b02a841455/third_party/WebKit/Source/core/dom/StyleElement.cpp
[modify] https://crrev.com/11bf99aa6426685ed8bf15b98a2680b02a841455/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/11bf99aa6426685ed8bf15b98a2680b02a841455/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/11bf99aa6426685ed8bf15b98a2680b02a841455/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
[modify] https://crrev.com/11bf99aa6426685ed8bf15b98a2680b02a841455/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp
[modify] https://crrev.com/11bf99aa6426685ed8bf15b98a2680b02a841455/third_party/WebKit/Source/core/html/LinkStyle.cpp

Project Member Comment 51 by bugdroid1@chromium.org, Dec 8 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f46992525f72e0bdf4331f8cf6fcc31602f307e7

commit f46992525f72e0bdf4331f8cf6fcc31602f307e7
Author: rune <rune@opera.com>
Date: Thu Dec 08 08:54:46 2016

Make sure media query results are re-collected.

When media attributes change on style elements, we need to re-append
all sheets in the scope in order to collect the viewport and device
dependent media results correctly. This already done forced by the
FullStyleUpdate in parseAttribute, but we want to minimize the changes
here with async style update and ruleset based invalidations by marking
the treeScope dirty, and if nothing changed, invalidate no style.

However, we need to re-add global rule data, or at least the media
query results.

Example: say that we have a window width of 800px below. After the
media attribute has been changed, we don't need to recalculate any
styles, but we need to make sure we detect style changes crossing the
width of 2000px instead of 1000px.

<style media="(min-width: 1000px)"> ... </style>

<script>
  styleElement.setAttribute("media", "(min-width: 2000px");
</script>

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2554193002
Cr-Commit-Position: refs/heads/master@{#437213}

[modify] https://crrev.com/f46992525f72e0bdf4331f8cf6fcc31602f307e7/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/f46992525f72e0bdf4331f8cf6fcc31602f307e7/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/f46992525f72e0bdf4331f8cf6fcc31602f307e7/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
[modify] https://crrev.com/f46992525f72e0bdf4331f8cf6fcc31602f307e7/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp

Project Member Comment 52 by bugdroid1@chromium.org, Dec 13 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5eefd373b4c293d23cb5f69a7e2fc0620eaead3b

commit 5eefd373b4c293d23cb5f69a7e2fc0620eaead3b
Author: rune <rune@opera.com>
Date: Tue Dec 13 05:18:29 2016

Use hash set instead of vector for changed RuleSets.

That way, we don't have to consider the same RuleSet multiple times for
invalidation on active stylesheet update. This fixes a regression in
PerformanceTests/CSS/StyleSheetInsert.html which would have been
introduced by https://codereview.chromium.org/2557533005

This works because the same style element source text used multiple
times will make us use the same StyleSheetContents from the cache and
hence the same RuleSet for all 50 sheets added in that test. It's a bit
like cheating, but this will also make sure we don't invalidate for the
same RuleSet twice if we re-order stylesheets by removing/inserting a
style element where the CSSStyleSheet pointer will be different, but
the RuleSet stays the same.

R=sashab@chromium.org,esprehn@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2569733003
Cr-Commit-Position: refs/heads/master@{#438062}

[modify] https://crrev.com/5eefd373b4c293d23cb5f69a7e2fc0620eaead3b/third_party/WebKit/Source/core/css/ActiveStyleSheets.cpp
[modify] https://crrev.com/5eefd373b4c293d23cb5f69a7e2fc0620eaead3b/third_party/WebKit/Source/core/css/ActiveStyleSheets.h
[modify] https://crrev.com/5eefd373b4c293d23cb5f69a7e2fc0620eaead3b/third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp
[modify] https://crrev.com/5eefd373b4c293d23cb5f69a7e2fc0620eaead3b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/5eefd373b4c293d23cb5f69a7e2fc0620eaead3b/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/5eefd373b4c293d23cb5f69a7e2fc0620eaead3b/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp

Project Member Comment 53 by bugdroid1@chromium.org, Dec 13 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9fb5b60edfb769134733009f9447bad3eaf347b0

commit 9fb5b60edfb769134733009f9447bad3eaf347b0
Author: rune <rune@opera.com>
Date: Tue Dec 13 13:03:11 2016

Collect active stylesheets and and apply asynchronously.

This CL enables asynchronously updating the lists of active stylesheets
applying any style changes using rule set invalidations. This means we
more often avoid full style recalcs when we add or remove stylesheets
from the document as well as when the evaluation of media queries
change.

In general, we now alway compare new and old stylesheets by comparing
their rulesets and schedule style invalidations for removed and added
rulesets.

When media queries changes, we used to give completely in and
recalculate all style once we discovered a media query changed its
evaluation. With this patch, we clear rule sets for sheets which
contain media queries which means we will invalidate rules for the sets
before and after the query change. This can be further refined by only
clearing rule sets when the sheets has a media query which actually did
change evaluation, and also just schedule invalidations for rules which
are inside @media rules.

TreeScopeStyleSheetCollectionTest.cpp is removed as it is replaced by
ActiveStyleSheetsTest.cpp which landed earlier.

updateActiveStyle() has been added a few places where
ensureStyleResolver() previously caused active stylesheets to be up-to-
date. ensureStyleResolver() is now merely a method which creates the
StyleResolver if necessary and returns it.

There are some cleanups and code removal which needs to be done after
this CL, but I have left those out to make this CL as small as
possible. For instance resolverChanged(), which synchronously updated
the active stylesheets, has an empty implementation instead of
including a lot of removals in this CL. The code for lazy-appending
stylesheets in StyleResolver is still there, but not in use.

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2557533005
Cr-Commit-Position: refs/heads/master@{#438148}

[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/LayoutTests/animations/add-keyframes-in-shadow-recalc.html
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/LayoutTests/fast/css/modify-stylesheet-minimal-recalc-style-expected.txt
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/LayoutTests/fast/css/modify-stylesheet-minimal-recalc-style.html
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/BUILD.gn
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/css/FontFaceSet.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.h
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollector.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollector.h
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.h
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/StyleSheetCollection.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/StyleSheetCollection.h
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollection.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollection.h
[delete] https://crrev.com/bb887bb505f695aba03436ed8e5fd4b772265921/third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollectionTest.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/frame/FrameView.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/frame/LocalFrame.cpp
[modify] https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp

Project Member Comment 54 by bugdroid1@chromium.org, Dec 13 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/14e73349c627e9e861263bd069d63ac7df9c3147

commit 14e73349c627e9e861263bd069d63ac7df9c3147
Author: paulmeyer <paulmeyer@chromium.org>
Date: Tue Dec 13 20:54:32 2016

Revert of Collect active stylesheets and and apply asynchronously. (patchset #4 id:60001 of https://codereview.chromium.org/2557533005/ )

Reason for revert:
Suspected cause of failing WebKit tests on bots. Example: https://uberchromegw.corp.google.com/i/chromium.webkit/builders/WebKit%20Mac10.11%20%28dbg%29/builds/6390

BUG=673850

Original issue's description:
> Collect active stylesheets and and apply asynchronously.
>
> This CL enables asynchronously updating the lists of active stylesheets
> applying any style changes using rule set invalidations. This means we
> more often avoid full style recalcs when we add or remove stylesheets
> from the document as well as when the evaluation of media queries
> change.
>
> In general, we now alway compare new and old stylesheets by comparing
> their rulesets and schedule style invalidations for removed and added
> rulesets.
>
> When media queries changes, we used to give completely in and
> recalculate all style once we discovered a media query changed its
> evaluation. With this patch, we clear rule sets for sheets which
> contain media queries which means we will invalidate rules for the sets
> before and after the query change. This can be further refined by only
> clearing rule sets when the sheets has a media query which actually did
> change evaluation, and also just schedule invalidations for rules which
> are inside @media rules.
>
> TreeScopeStyleSheetCollectionTest.cpp is removed as it is replaced by
> ActiveStyleSheetsTest.cpp which landed earlier.
>
> updateActiveStyle() has been added a few places where
> ensureStyleResolver() previously caused active stylesheets to be up-to-
> date. ensureStyleResolver() is now merely a method which creates the
> StyleResolver if necessary and returns it.
>
> There are some cleanups and code removal which needs to be done after
> this CL, but I have left those out to make this CL as small as
> possible. For instance resolverChanged(), which synchronously updated
> the active stylesheets, has an empty implementation instead of
> including a lot of removals in this CL. The code for lazy-appending
> stylesheets in StyleResolver is still there, but not in use.
>
> R=meade@chromium.org
> BUG=567021
>
> Committed: https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0
> Cr-Commit-Position: refs/heads/master@{#438148}

TBR=esprehn@chromium.org,meade@chromium.org,sashab@chromium.org,rune@opera.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=567021

Review-Url: https://codereview.chromium.org/2572473006
Cr-Commit-Position: refs/heads/master@{#438278}

[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/LayoutTests/animations/add-keyframes-in-shadow-recalc.html
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/LayoutTests/fast/css/modify-stylesheet-minimal-recalc-style-expected.txt
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/LayoutTests/fast/css/modify-stylesheet-minimal-recalc-style.html
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/BUILD.gn
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/css/FontFaceSet.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.h
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollector.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollector.h
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.h
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/StyleSheetCollection.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/StyleSheetCollection.h
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollection.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollection.h
[add] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollectionTest.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/frame/FrameView.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/frame/LocalFrame.cpp
[modify] https://crrev.com/14e73349c627e9e861263bd069d63ac7df9c3147/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp

Project Member Comment 55 by bugdroid1@chromium.org, Dec 16 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ad541b1bdc92608984093593d9eb864ad51ed1e6

commit ad541b1bdc92608984093593d9eb864ad51ed1e6
Author: rune <rune@opera.com>
Date: Fri Dec 16 04:52:36 2016

Merge setTimeout calls with same timeout for webfont tests.

Landing async stylesheet update caused a regression in font-display
tests. The values "fallback" and "optional" block display for 100ms
according to the spec. The tests had a setTimeout call to trigger font
loading and a setTimeout call to trigger notifyDone() to render before
100ms has passed with the same timeout value. However, the timer for
allowing fallback display triggers before the notifyDone triggers in
Debug builds on Mac. Calling notifyDone from the same setTimeout
callback as triggering font loading.

The intention of the test is to trigger the screen dump when 0s has
passed, so this should be OK. I have not identified what exactly changed
with the async stylesheet patch and why the timeout methods are
interleaved with the timeout for enabling fallback rendering.

Removing one of the other tests or one of the font-display values from
the test array also makes the "fallback" and "optional" start passing
without this change, so there is clearly a timing issue here.

BUG=567021

Review-Url: https://codereview.chromium.org/2584473002
Cr-Commit-Position: refs/heads/master@{#439026}

[modify] https://crrev.com/ad541b1bdc92608984093593d9eb864ad51ed1e6/third_party/WebKit/LayoutTests/http/tests/webfont/font-display-intervention.html
[modify] https://crrev.com/ad541b1bdc92608984093593d9eb864ad51ed1e6/third_party/WebKit/LayoutTests/http/tests/webfont/font-display.html

Project Member Comment 56 by bugdroid1@chromium.org, Dec 16 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/90d4ea3d543f0031769b3aacac2d3e084b95fb7d

commit 90d4ea3d543f0031769b3aacac2d3e084b95fb7d
Author: rune <rune@opera.com>
Date: Fri Dec 16 12:22:13 2016

Reland: Collect active stylesheets and and apply asynchronously.

This CL enables asynchronously updating the lists of active stylesheets
applying any style changes using rule set invalidations. This means we
more often avoid full style recalcs when we add or remove stylesheets
from the document as well as when the evaluation of media queries
change.

In general, we now alway compare new and old stylesheets by comparing
their rulesets and schedule style invalidations for removed and added
rulesets.

When media queries changes, we used to give completely in and
recalculate all style once we discovered a media query changed its
evaluation. With this patch, we clear rule sets for sheets which
contain media queries which means we will invalidate rules for the sets
before and after the query change. This can be further refined by only
clearing rule sets when the sheets has a media query which actually did
change evaluation, and also just schedule invalidations for rules which
are inside @media rules.

TreeScopeStyleSheetCollectionTest.cpp is removed as it is replaced by
ActiveStyleSheetsTest.cpp which landed earlier.

updateActiveStyle() has been added a few places where
ensureStyleResolver() previously caused active stylesheets to be up-to-
date. ensureStyleResolver() is now merely a method which creates the
StyleResolver if necessary and returns it.

There are some cleanups and code removal which needs to be done after
this CL, but I have left those out to make this CL as small as
possible. For instance resolverChanged(), which synchronously updated
the active stylesheets, has an empty implementation instead of
including a lot of removals in this CL. The code for lazy-appending
stylesheets in StyleResolver is still there, but not in use.

R=meade@chromium.org
BUG=567021

Committed: https://crrev.com/9fb5b60edfb769134733009f9447bad3eaf347b0
Review-Url: https://codereview.chromium.org/2557533005
Cr-Original-Commit-Position: refs/heads/master@{#438148}
Cr-Commit-Position: refs/heads/master@{#439092}

[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/LayoutTests/animations/add-keyframes-in-shadow-recalc.html
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/LayoutTests/fast/css/modify-stylesheet-minimal-recalc-style-expected.txt
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/LayoutTests/fast/css/modify-stylesheet-minimal-recalc-style.html
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/BUILD.gn
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/css/FontFaceSet.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.h
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollector.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/DocumentStyleSheetCollector.h
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.h
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/StyleEngineTest.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/StyleSheetCollection.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/StyleSheetCollection.h
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollection.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollection.h
[delete] https://crrev.com/206fee6c2a7ddb33c400a56adda7f53bf62157c2/third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollectionTest.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/frame/FrameView.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/frame/LocalFrame.cpp
[modify] https://crrev.com/90d4ea3d543f0031769b3aacac2d3e084b95fb7d/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp

Project Member Comment 57 by bugdroid1@chromium.org, Dec 16 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2650087b9cb225894d5d4972bd7d32d6e38c9e68

commit 2650087b9cb225894d5d4972bd7d32d6e38c9e68
Author: rune <rune@opera.com>
Date: Fri Dec 16 14:04:41 2016

Remove ensureResolver before invalidation set scheduling.

ensureResolver() used to make sure the invalidation sets were up-to-
date with the currently active stylesheets. This is no longer necessary
as ruleset invalidation of changes in active stylesheets will make sure
changes are applied correctly.

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2555083002
Cr-Commit-Position: refs/heads/master@{#439096}

[modify] https://crrev.com/2650087b9cb225894d5d4972bd7d32d6e38c9e68/third_party/WebKit/Source/core/dom/StyleEngine.cpp

Project Member Comment 58 by bugdroid1@chromium.org, Dec 16 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8054f79ac69c13a74e7b3c1c4d102c3604109068

commit 8054f79ac69c13a74e7b3c1c4d102c3604109068
Author: rune <rune@opera.com>
Date: Fri Dec 16 14:07:47 2016

Removed unused StyleSheetInvalidationAnalysis class.

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2546343006
Cr-Commit-Position: refs/heads/master@{#439097}

[modify] https://crrev.com/8054f79ac69c13a74e7b3c1c4d102c3604109068/third_party/WebKit/Source/core/css/BUILD.gn
[delete] https://crrev.com/2650087b9cb225894d5d4972bd7d32d6e38c9e68/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp
[delete] https://crrev.com/2650087b9cb225894d5d4972bd7d32d6e38c9e68/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.h

Project Member Comment 59 by bugdroid1@chromium.org, Dec 16 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/22928d81b2c3c0b72cf0416819e6c6d41fc0f526

commit 22928d81b2c3c0b72cf0416819e6c6d41fc0f526
Author: rune <rune@opera.com>
Date: Fri Dec 16 14:39:02 2016

Remove unused lazyAppend from StyleResolver.

Active stylesheet update is now asynchronous and handled from
StyleEngine::updateActiveStyleSheets().

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2557773004
Cr-Commit-Position: refs/heads/master@{#439102}

[modify] https://crrev.com/22928d81b2c3c0b72cf0416819e6c6d41fc0f526/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
[modify] https://crrev.com/22928d81b2c3c0b72cf0416819e6c6d41fc0f526/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.h
[modify] https://crrev.com/22928d81b2c3c0b72cf0416819e6c6d41fc0f526/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
[modify] https://crrev.com/22928d81b2c3c0b72cf0416819e6c6d41fc0f526/third_party/WebKit/Source/core/css/resolver/StyleResolver.h

Project Member Comment 60 by bugdroid1@chromium.org, Dec 16 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/626379c7a2bed66978eb739ee3afcc3df47ac4b2

commit 626379c7a2bed66978eb739ee3afcc3df47ac4b2
Author: rune <rune@opera.com>
Date: Fri Dec 16 15:53:05 2016

Setting preferred stylesheet simplified.

With active stylesheets being applied asynchronously, we no longer need
to avoid the synchronous stylesheet update during link processing. We
can just mark the treeScope dirty to trigger the preferred set to be
updated as part of updateActiveStyleSheets().

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2552353003
Cr-Commit-Position: refs/heads/master@{#439115}

[modify] https://crrev.com/626379c7a2bed66978eb739ee3afcc3df47ac4b2/third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp
[modify] https://crrev.com/626379c7a2bed66978eb739ee3afcc3df47ac4b2/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/626379c7a2bed66978eb739ee3afcc3df47ac4b2/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/626379c7a2bed66978eb739ee3afcc3df47ac4b2/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
[modify] https://crrev.com/626379c7a2bed66978eb739ee3afcc3df47ac4b2/third_party/WebKit/Source/core/html/LinkStyle.cpp
[modify] https://crrev.com/626379c7a2bed66978eb739ee3afcc3df47ac4b2/third_party/WebKit/Source/core/html/LinkStyle.h

Project Member Comment 61 by bugdroid1@chromium.org, Dec 16 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/461fe03024acd4ae50eb3c4790ba8fd68f0470c3

commit 461fe03024acd4ae50eb3c4790ba8fd68f0470c3
Author: rune <rune@opera.com>
Date: Fri Dec 16 17:50:04 2016

Removed resolverChanged().

This method was now empty and has been replaced by asynchronous active
stylesheet update in updateActiveStyleSheets().

R=meade@chromium.org
BUG=567021

Review-Url: https://codereview.chromium.org/2559613002
Cr-Commit-Position: refs/heads/master@{#439142}

[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp
[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/css/CSSStyleSheet.h
[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/dom/Document.cpp
[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/dom/Document.h
[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp
[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/dom/StyleElement.cpp
[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/dom/StyleEngine.h
[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/html/HTMLStyleElement.cpp
[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/html/LinkStyle.cpp
[modify] https://crrev.com/461fe03024acd4ae50eb3c4790ba8fd68f0470c3/third_party/WebKit/Source/core/html/imports/HTMLImportChild.cpp

Project Member Comment 62 by bugdroid1@chromium.org, Dec 21 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b0f03812c4f8ca50a0cc07caaca0c8eafbb2862a

commit b0f03812c4f8ca50a0cc07caaca0c8eafbb2862a
Author: rune <rune@opera.com>
Date: Wed Dec 21 01:55:16 2016

Clear active tree scopes on StyleEngine::didDetach().

clearResolver() is not only called on didDetach(). Make it private and
name it clearResolvers to reflect that it clears scoped resolvers as
well. The comments related to style resolver reconstructruction is
removed as that does not happen anymore.

Clearing m_treeBoundaryCrossingScopes is moved into didDetach()
which was a more natural place.

Clear active and dirty tree scopes in didDetach to not unnecessarily
hang on to any memory associated with them.

These changes were done investigating issue 675533, but won't
necessarily fix anything for that issue.

BUG=567021,675533

Review-Url: https://codereview.chromium.org/2593643002
Cr-Commit-Position: refs/heads/master@{#439973}

[modify] https://crrev.com/b0f03812c4f8ca50a0cc07caaca0c8eafbb2862a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
[modify] https://crrev.com/b0f03812c4f8ca50a0cc07caaca0c8eafbb2862a/third_party/WebKit/Source/core/dom/StyleEngine.h

Comment 63 by r...@opera.com, Jan 6 2017
Status: Fixed
Enabled before Christmas. Taking a chance that it'll stick and marking the issue as fixed.

Sign in to add a comment