Keep a separate list of :host(-context) rules.

:host and :host-context in the rightmost compound selector apply to the
host element in the parent scope of a scoped stylesheet. However, we put
all these rules into the universal rule list and collected :host rules in
its own scope and other rules in the scope outside. For example:

<custom-element>
  <:shadow-root>
    <style>
      :host { background: green }
      * { background: red; }
    </style>
    <custom-element></custom-element>
</custom-element>

":host" applies to the outer <custom-element>, "*" applies to the
inner one. We collected both rules for both elements.

Instead keep a list of :host and :host-context rules for each scope to be
matched for the outer scope only, and skip all other rules from the inner
scope when matching for the outer scope.

Note that selectors with :host(-context) in non-rightmost compounds are
still in the other rule lists as they don't match the shadow host, but an
element in the same scope as the stylesheet is.

For instance: ":host(.x) div".

R=kochi@chromium.org,esprehn@chromium.org
BUG=437846

TEST=fast/dom/shadow/host-pseudo-class.html
TEST=fast/dom/shadow/hostcontext-pseudo-class.html

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

git-svn-id: svn://svn.chromium.org/blink/trunk@187036 bbb929c8-8fbe-4397-9dbb-9b2b20218538
8 files changed
tree: 9adbe10fe9f48fd78c0a94dae8f0fde3e82cc544
  1. third_party/