From 6a26ce3455a7297e3558235bb0460b71080c71aa Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Mon, 27 Feb 2023 12:14:49 +0800 Subject: [PATCH 1/5] Issue #1375 - Follow-up: Remove shadow tree hacks in the frame constructor This should've been removed alongside bug 1404789 when it landed. --- layout/base/nsCSSFrameConstructor.cpp | 46 --------------------------- 1 file changed, 46 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 306ddf4ed5..fd5ee5a2a8 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -7255,21 +7255,6 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, } #endif // MOZ_XUL - if (aContainer && aContainer->HasFlag(NODE_IS_IN_SHADOW_TREE) && - !aContainer->IsInNativeAnonymousSubtree() && - !aFirstNewContent->IsInNativeAnonymousSubtree()) { - // Recreate frames if content is appended into a ShadowRoot - // because children of ShadowRoot are rendered in place of children - // of the host. - //XXXsmaug This is super unefficient! - nsIContent* bindingParent = aContainer->GetBindingParent(); - LAYOUT_PHASE_TEMP_EXIT(); - RecreateFramesForContent(bindingParent, InsertionKind::Sync, - REMOVE_FOR_RECONSTRUCTION); - LAYOUT_PHASE_TEMP_REENTER(); - return; - } - // See comment in ContentRangeInserted for why this is necessary. if (!GetContentInsertionFrameFor(aContainer) && !aContainer->IsActiveChildrenElement()) { @@ -7735,22 +7720,6 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer, return; } - if (aContainer->HasFlag(NODE_IS_IN_SHADOW_TREE) && - !aContainer->IsInNativeAnonymousSubtree() && - (!aStartChild || !aStartChild->IsInNativeAnonymousSubtree()) && - (!aEndChild || !aEndChild->IsInNativeAnonymousSubtree())) { - // Recreate frames if content is inserted into a ShadowRoot - // because children of ShadowRoot are rendered in place of - // the children of the host. - //XXXsmaug This is super unefficient! - nsIContent* bindingParent = aContainer->GetBindingParent(); - LAYOUT_PHASE_TEMP_EXIT(); - RecreateFramesForContent(bindingParent, InsertionKind::Sync, - REMOVE_FOR_RECONSTRUCTION); - LAYOUT_PHASE_TEMP_REENTER(); - return; - } - // Put 'parentFrame' inside a scope so we don't confuse it with // 'insertion.mParentFrame' later. { @@ -8238,21 +8207,6 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer, } } - if (aContainer && aContainer->HasFlag(NODE_IS_IN_SHADOW_TREE) && - !aContainer->IsInNativeAnonymousSubtree() && - !aChild->IsInNativeAnonymousSubtree()) { - // Recreate frames if content is removed from a ShadowRoot - // because it may contain an insertion point which can change - // how the host is rendered. - //XXXsmaug This is super unefficient! - nsIContent* bindingParent = aContainer->GetBindingParent(); - *aDidReconstruct = true; - LAYOUT_PHASE_TEMP_EXIT(); - RecreateFramesForContent(bindingParent, insertionKind, aFlags); - LAYOUT_PHASE_TEMP_REENTER(); - return; - } - if (aFlags == REMOVE_DESTROY_FRAMES) { CaptureStateForFramesOf(aChild, mTempFrameTreeState); } From b40c87a59aee8b5a8a7556bcebe05d076183e3f2 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Mon, 27 Feb 2023 12:56:07 +0800 Subject: [PATCH 2/5] Issue #1375 - Follow-up: Get the insertion point right when reconstructing direct children of a shadow root This should've been changed alongside bug 1404789 when it landed. --- layout/base/nsCSSFrameConstructor.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index fd5ee5a2a8..c588206d4e 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -7395,7 +7395,9 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, GetAbsoluteContainingBlock(parentFrame, FIXED_POS), GetAbsoluteContainingBlock(parentFrame, ABS_POS), containingBlock); - state.mTreeMatchContext.InitAncestors(aContainer->AsElement()); + // We use GetParentElementCrossingShadowRoot to handle the case where + // aContainer is a ShadowRoot. + state.mTreeMatchContext.InitAncestors(aFirstNewContent->GetParentElementCrossingShadowRoot()); nsIAtom* frameType = parentFrame->GetType(); @@ -7727,10 +7729,13 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer, // The xbl:children element won't have a frame, but default content can have the children as // a parent. While its uncommon to change the structure of the default content itself, a label, // for example, can be reframed by having its value attribute set or removed. - if (!parentFrame && !aContainer->IsActiveChildrenElement()) { + if (!parentFrame && + !(aContainer->IsActiveChildrenElement() || ShadowRoot::FromNode(aContainer))) { return; } + MOZ_ASSERT_IF(ShadowRoot::FromNode(aContainer), !parentFrame); + // Otherwise, we've got parent content. Find its frame. NS_ASSERTION(!parentFrame || parentFrame->GetContent() == aContainer || GetDisplayContentsStyleFor(aContainer), "New XBL code is possibly wrong!"); @@ -7839,9 +7844,9 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer, GetAbsoluteContainingBlock(insertion.mParentFrame, ABS_POS), GetFloatContainingBlock(insertion.mParentFrame), do_AddRef(aFrameState)); - state.mTreeMatchContext.InitAncestors(aContainer ? - aContainer->AsElement() : - nullptr); + // We use GetParentElementCrossingShadowRoot to handle the case where + // aContainer is a ShadowRoot. + state.mTreeMatchContext.InitAncestors(aStartChild->GetParentElementCrossingShadowRoot()); // Recover state for the containing block - we need to know if // it has :first-letter or :first-line style applied to it. The @@ -9025,8 +9030,11 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIContent* aContainer, return InsertionPoint(GetContentInsertionFrameFor(aContainer), aContainer); } - if (nsContentUtils::HasDistributedChildren(aContainer)) { - // The container distributes nodes, use the frame of the flattened tree parent. + if (nsContentUtils::HasDistributedChildren(aContainer) || + ShadowRoot::FromNode(aContainer)) { + // The container distributes nodes or is a shadow root, use the frame of + // the flattened tree parent. + // // It may be the case that the node is distributed but not matched to any // insertion points, so there is no flattened parent. nsIContent* flattenedParent = aChild->GetFlattenedTreeParent(); From 9b25202492dd3afb10253dbff6911b597a84b888 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 28 Feb 2023 00:38:44 +0100 Subject: [PATCH 3/5] Issue #1361 - Enable WebComponents by default in the platform. --- modules/libpref/init/all.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 88ffb6ca7f..d88b918d00 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1245,7 +1245,8 @@ pref("privacy.trackingprotection.pbmode.enabled", false); pref("dom.event.contextmenu.enabled", true); pref("dom.event.clipboardevents.enabled", true); -pref("dom.webcomponents.enabled", false); +// Enable Google WebComponents? +pref("dom.webcomponents.enabled", true); pref("javascript.enabled", true); // Enable Array.prototype.values From 87b94f83ca7066b2e67898f0c218e2d64c0e1863 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 28 Feb 2023 00:40:26 +0100 Subject: [PATCH 4/5] No Issue - Enable MSE for WebM on all platforms. WebM is certainly mature enough to have hooked into MSE (default on Linux and other for years now). --- modules/libpref/init/all.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index d88b918d00..944caef76c 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -582,14 +582,8 @@ pref("media.track.enabled", false); // Whether to enable MediaSource support. pref("media.mediasource.enabled", true); - pref("media.mediasource.mp4.enabled", true); - -#if defined(XP_WIN) || defined(XP_MACOSX) -pref("media.mediasource.webm.enabled", false); -#else pref("media.mediasource.webm.enabled", true); -#endif pref("media.mediasource.webm.audio.enabled", true); #ifdef MOZ_AV1 From 2d7d00b75abdb2f5e2d3d8960eb80187feeefb77 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 28 Feb 2023 00:42:11 +0100 Subject: [PATCH 5/5] No Issue - Remove speech recognition pref and enable TTS API by default. Speech recognition was removed a while back. The pref is just leftover. Having the TTS API available will provide some accessibility benefits for users, so flip that on while we're here. --- modules/libpref/init/all.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 944caef76c..41233f63c4 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -599,8 +599,8 @@ pref("media.benchmark.frames", 300); pref("media.benchmark.timeout", 1000); #ifdef MOZ_WEBSPEECH -pref("media.webspeech.recognition.enable", false); -pref("media.webspeech.synth.enabled", false); +// Web text-to-speech API enabled? +pref("media.webspeech.synth.enabled", true); #endif #ifdef MOZ_WEBM_ENCODER pref("media.encoder.webm.enabled", true);