Skip to content

Commit

Permalink
Bug 1454165 - Make :host() and ::slotted() account for the inner sele…
Browse files Browse the repository at this point in the history
…ctor's specificity. r=xidorn

As resolved in w3c/csswg-drafts#1915.

Differential Revision: https://phabricator.services.mozilla.com/D1849

UltraBlame original commit: ca14c36e4280927a10e43e95b8f459e767fc8178
  • Loading branch information
marco-c committed Oct 3, 2019
1 parent 22fe007 commit 376e5bd
Show file tree
Hide file tree
Showing 5 changed files with 1,258 additions and 65 deletions.
279 changes: 214 additions & 65 deletions servo/components/selectors/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ std
ops
:
:
{
AddAssign
Add
}
;
use
std
Expand Down Expand Up @@ -1831,6 +1834,55 @@ element_selectors
u32
}
impl
AddAssign
for
Specificity
{
#
[
inline
]
fn
add_assign
(
&
mut
self
rhs
:
Self
)
{
self
.
id_selectors
+
=
rhs
.
id_selectors
;
self
.
class_like_selectors
+
=
rhs
.
class_like_selectors
;
self
.
element_selectors
+
=
rhs
.
element_selectors
;
}
}
impl
Add
for
Specificity
Expand Down Expand Up @@ -1919,6 +1971,10 @@ u32
for
Specificity
{
#
[
inline
]
fn
from
(
Expand Down Expand Up @@ -1983,6 +2039,10 @@ Specificity
for
u32
{
#
[
inline
]
fn
from
(
Expand Down Expand Up @@ -2184,42 +2244,106 @@ builder
)
;
}
/
/
FIXME
Component
:
:
PseudoElement
(
emilio
.
.
)
|
Component
:
Spec
doesn
'
t
define
any
particular
:
LocalName
(
.
.
)
=
>
{
specificity
for
.
element_selectors
+
=
1
}
Component
:
:
Slotted
(
ref
selector
)
=
>
{
specificity
.
element_selectors
+
=
1
;
/
/
Note
that
due
to
the
way
:
:
slotted
(
)
works
we
only
compete
with
/
/
other
:
:
slotted
rules
so
apply
the
general
above
rule
doesn
'
t
really
/
/
matter
but
we
do
it
still
for
pseudos
per
:
consistency
with
other
/
/
pseudo
-
elements
.
/
/
/
/
See
:
https
:
/
Expand All @@ -2237,62 +2361,90 @@ drafts
issues
/
1915
/
/
/
/
Though
other
engines
compute
it
dynamically
so
maybe
we
should
/
/
do
that
instead
eventually
.
Component
*
specificity
+
=
Specificity
:
:
Slotted
from
(
selector
.
.
)
|
Component
:
:
PseudoElement
specificity
(
.
.
)
|
)
;
}
Component
:
:
LocalName
Host
(
.
.
ref
selector
)
=
>
{
specificity
.
element_selectors
class_like_selectors
+
=
1
;
if
let
Some
(
ref
selector
)
=
*
selector
{
/
/
See
:
https
:
/
/
github
.
com
/
w3c
/
csswg
-
drafts
/
issues
/
1915
*
specificity
+
=
Specificity
:
:
from
(
selector
.
specificity
(
)
)
;
}
}
Component
:
Expand All @@ -2304,12 +2456,15 @@ ID
)
=
>
{
specificity
.
id_selectors
+
=
1
;
}
Component
:
:
Expand Down Expand Up @@ -2379,15 +2534,6 @@ Scope
Component
:
:
Host
(
.
.
)
|
Component
:
:
NthChild
(
.
Expand Down Expand Up @@ -2446,12 +2592,15 @@ NonTSPseudoClass
)
=
>
{
specificity
.
class_like_selectors
+
=
1
;
}
Component
:
:
Expand Down
Loading

0 comments on commit 376e5bd

Please sign in to comment.