diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-04-16 20:19:06 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2020-04-16 20:19:06 -0400 |
commit | de45820b64ab03768336c7242622ef9f499347cf (patch) | |
tree | 718a67a64a29f2440850e693f8ba707f3b91c179 /layout/base | |
parent | ab05e6f9ad185a1f7c405fd29876edca9e0567ba (diff) | |
download | UXP-de45820b64ab03768336c7242622ef9f499347cf.tar UXP-de45820b64ab03768336c7242622ef9f499347cf.tar.gz UXP-de45820b64ab03768336c7242622ef9f499347cf.tar.lz UXP-de45820b64ab03768336c7242622ef9f499347cf.tar.xz UXP-de45820b64ab03768336c7242622ef9f499347cf.zip |
Bug 1346623 - Allow anonymous content created with nsIDocument::InsertAnonymousContent can change from non-native to native AC
* Prevent canvas custom content from becoming NAC when reframing the root element
* Add an API to get computed style values through an AnonymousContent object
Tag #1375
Diffstat (limited to 'layout/base')
-rw-r--r-- | layout/base/nsCSSFrameConstructor.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 374764203..3be7c2a0b 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -4192,13 +4192,28 @@ nsCSSFrameConstructor::GetAnonymousContent(nsIContent* aParent, ConnectAnonymousTreeDescendants(content, aContent[i].mChildren); - // least-surprise CSS binding until we do the SVG specified - // cascading rules for <svg:use> - bug 265894 - if (aParentFrame->GetType() == nsGkAtoms::svgUseFrame) { + nsIAtom* parentFrameType = aParentFrame->GetType(); + if (parentFrameType == nsGkAtoms::svgUseFrame) { + // least-surprise CSS binding until we do the SVG specified + // cascading rules for <svg:use> - bug 265894 content->SetFlags(NODE_IS_ANONYMOUS_ROOT); } else { content->SetIsNativeAnonymousRoot(); - SetNativeAnonymousBitOnDescendants(content); + // Don't mark descendants of the custom content container + // as native anonymous. When canvas custom content is initially + // created and appended to the custom content container, in + // nsIDocument::InsertAnonymousContent, it is not considered native + // anonymous content. But if we end up reframing the root element, + // we will re-create the nsCanvasFrame, and we would end up in here, + // marking it as NAC. Existing uses of canvas custom content would + // break if it becomes NAC (since each element starts inheriting + // styles from its closest non-NAC ancestor, rather than from its + // parent). + if (!(parentFrameType == nsGkAtoms::canvasFrame && + content == static_cast<nsCanvasFrame*>(aParentFrame) + ->GetCustomContentContainer())) { + SetNativeAnonymousBitOnDescendants(content); + } } bool anonContentIsEditable = content->HasFlag(NODE_IS_EDITABLE); |