Skip to content

Commit

Permalink
Bug 353575 - Allow IDTracker to look up elements in <svg:use> shadow …
Browse files Browse the repository at this point in the history
…trees. r=smaug

Other UAs allow this, and it seems in the general consensus of
WICG/webcomponents#179.

This matches WebKit's behavior. Blink, for some reason shows red on the
test-case, probably because they're not doing quite this, but they
manage to render masks inside the display: none symbol element or such.

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

UltraBlame original commit: 8efff752175e177108adceddb73a60f98f8cdd27
  • Loading branch information
marco-c committed Apr 28, 2020
1 parent d32214b commit 60f19f8
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 41 deletions.
157 changes: 120 additions & 37 deletions dom/base/IDTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ h
#
include
"
mozilla
/
dom
/
DocumentOrShadowRoot
.
h
"
#
include
"
nsAtom
.
h
"
#
include
"
nsContentUtils
.
h
Expand Down Expand Up @@ -49,20 +67,72 @@ nsCycleCollectionParticipant
.
h
"
#
include
"
nsStringFwd
.
h
"
namespace
mozilla
{
namespace
dom
{
static
Element
*
LookupElement
(
DocumentOrShadowRoot
&
aDocOrShadow
const
nsAString
&
aRef
bool
aReferenceImage
)
{
if
(
aReferenceImage
)
{
return
aDocOrShadow
.
LookupImageElement
(
aRef
)
;
}
return
aDocOrShadow
.
GetElementById
(
aRef
)
;
}
static
DocumentOrShadowRoot
*
DocOrShadowFromContent
FindTreeToWatch
(
nsIContent
&
aContent
const
nsAString
&
aID
bool
aReferenceImage
)
{
ShadowRoot
Expand Down Expand Up @@ -97,6 +167,21 @@ use
)
)
{
if
(
LookupElement
(
*
shadow
aID
aReferenceImage
)
)
{
return
shadow
;
}
shadow
=
shadow
Expand Down Expand Up @@ -204,16 +289,6 @@ OwnerDoc
(
)
;
DocumentOrShadowRoot
*
docOrShadow
=
DocOrShadowFromContent
(
*
aFromContent
)
;
auto
encoding
=
Expand Down Expand Up @@ -319,6 +394,10 @@ GetDocumentURI
isEqualExceptRef
)
;
DocumentOrShadowRoot
*
docOrShadow
;
if
(
NS_FAILED
Expand Down Expand Up @@ -404,6 +483,19 @@ observer
;
}
}
else
{
docOrShadow
=
FindTreeToWatch
(
*
aFromContent
ref
aReferenceImage
)
;
}
if
(
aWatch
Expand Down Expand Up @@ -464,23 +556,28 @@ mReferencingImage
=
false
;
nsDependentAtomString
str
(
aID
)
;
DocumentOrShadowRoot
*
docOrShadow
=
DocOrShadowFromContent
FindTreeToWatch
(
aFrom
str
false
)
;
HaveNewDocumentOrShadowRoot
(
docOrShadow
aWatch
nsDependentAtomString
(
aID
)
str
)
;
}
Expand Down Expand Up @@ -551,31 +648,19 @@ aDocOrShadow
return
;
}
if
(
Element
*
e
=
mReferencingImage
?
aDocOrShadow
-
>
LookupImageElement
LookupElement
(
aRef
)
:
*
aDocOrShadow
-
>
GetElementById
(
aRef
mReferencingImage
)
;
if
(
e
)
{
mElement
Expand Down Expand Up @@ -877,7 +962,8 @@ aData
{
NS_ASSERTION
(
PL_strcmp
!
strcmp
(
aTopic
"
Expand All @@ -890,9 +976,6 @@ document
created
"
)
=
=
0
"
Unexpected
topic
Expand Down
4 changes: 2 additions & 2 deletions layout/reftests/svg/fragid-shadow-7.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
fill
=
"
lime
red
"
width
=
Expand Down Expand Up @@ -204,7 +204,7 @@
fill
=
"
red
lime
"
width
=
Expand Down
4 changes: 2 additions & 2 deletions layout/reftests/svg/fragid-shadow-8.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
fill
=
"
lime
red
"
width
=
Expand Down Expand Up @@ -91,7 +91,7 @@
fill
=
"
red
lime
"
width
=
Expand Down

0 comments on commit 60f19f8

Please sign in to comment.