gh-13844: Fixed boosts not working when anon content exists (gh-13847)

This commit is contained in:
mr. m
2026-05-25 19:58:38 +02:00
committed by GitHub
parent 7e449ccdc9
commit 69e76e51b7
25 changed files with 565 additions and 245 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/gfx/layers/AnimationInfo.cpp b/gfx/layers/AnimationInfo.cpp
index 1d330056bd7a4e89aac5e5296a3c164fb42b5c42..38bfbcfcaf0c791ee817aafbd24b1cad67974e62 100644
index 1d330056bd7a4e89aac5e5296a3c164fb42b5c42..629fbdd748310c31aeb16b0a8d8e862a99314cc9 100644
--- a/gfx/layers/AnimationInfo.cpp
+++ b/gfx/layers/AnimationInfo.cpp
@@ -14,6 +14,7 @@
@@ -10,22 +10,20 @@ index 1d330056bd7a4e89aac5e5296a3c164fb42b5c42..38bfbcfcaf0c791ee817aafbd24b1cad
#include "nsIContent.h"
#include "nsLayoutUtils.h"
#include "nsRefreshDriver.h"
@@ -343,7 +344,17 @@ static void SetAnimatable(NonCustomCSSPropertyId aProperty,
@@ -341,9 +342,13 @@ static void SetAnimatable(NonCustomCSSPropertyId aProperty,
case eCSSProperty_background_color: {
// We don't support color animation on the compositor yet so that we can
// resolve currentColor at this moment.
nscolor foreground =
aFrame->Style()->GetVisitedDependentColor(&nsStyleText::mColor);
- nscolor foreground =
- aFrame->Style()->GetVisitedDependentColor(&nsStyleText::mColor);
- aAnimatable = aAnimationValue.GetColor(foreground);
+ nscolor foreground = aFrame->Style()->GetVisitedDependentColor(
+ &nsStyleText::mColor, nullptr);
+ nscolor resolved = aAnimationValue.GetColor(foreground);
+ // |foreground| is already boost-resolved through
+ // StyleAbsoluteColor::ToColor, so a currentColor keyframe is already
+ // filtered; only absolute keyframe colors still need the boost applied
+ // here, exactly once, so the composited transition endpoint matches the
+ // resting/static paint and doesn't snap when the transition ends.
+ aAnimatable =
+ aAnimationValue.IsCurrentColor()
+ ? resolved
+ : zen::nsZenBoostsBackend::FilterColorFromPresContext(
+ resolved, aFrame->PresContext());
+ aAnimatable = aAnimationValue.IsCurrentColor()
+ ? resolved
+ : zen::nsZenBoostsBackend::ResolveStyleColor(resolved,
+ aFrame);
break;
}
case eCSSProperty_opacity:

View File

@@ -1,5 +1,5 @@
diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp
index b5930f71e362eb78f74888e1b33b2a6f9dbb4ea4..dc1ba0b462402f62e47fcb32e2d7cd1a671a7fd8 100644
index b5930f71e362eb78f74888e1b33b2a6f9dbb4ea4..2105911a18b64e210d3125fec1bfa8058ca07d4e 100644
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -135,6 +135,7 @@
@@ -10,12 +10,13 @@ index b5930f71e362eb78f74888e1b33b2a6f9dbb4ea4..dc1ba0b462402f62e47fcb32e2d7cd1a
#include "nsAnimationManager.h"
#include "nsAutoLayoutPhase.h"
#include "nsCOMArray.h"
@@ -5572,7 +5573,7 @@ nscolor PresShell::GetDefaultBackgroundColorToDraw() const {
@@ -5572,7 +5573,8 @@ nscolor PresShell::GetDefaultBackgroundColorToDraw() const {
if (!mPresContext) {
return NS_RGB(255, 255, 255);
}
- return mPresContext->DefaultBackgroundColor();
+ return zen::nsZenBoostsBackend::FilterColorFromPresContext(mPresContext->DefaultBackgroundColor(), mPresContext);
+ return zen::nsZenBoostsBackend::ResolveStyleColor(
+ mPresContext->DefaultBackgroundColor(), GetRootFrame());
}
void PresShell::UpdateCanvasBackground() {

View File

@@ -1,33 +0,0 @@
diff --git a/layout/generic/ViewportFrame.cpp b/layout/generic/ViewportFrame.cpp
index 9d1c25c3834da50fd7dfa3a9583144f5817ee231..08b69a63ea3a8067861984fa2fcd25435c921c0d 100644
--- a/layout/generic/ViewportFrame.cpp
+++ b/layout/generic/ViewportFrame.cpp
@@ -23,6 +23,7 @@
#include "nsLayoutUtils.h"
#include "nsPlaceholderFrame.h"
#include "nsSubDocumentFrame.h"
+#include "mozilla/nsZenBoostsBackend.h"
using namespace mozilla;
@@ -291,15 +292,20 @@ ViewportFrame::BuildDisplayListForViewTransitionsAndNACTopLayer(
}
}
+ bool isAnonContent = false;
if (dom::Element* container = doc->GetCustomContentContainer()) {
if (nsIFrame* frame = container->GetPrimaryFrame()) {
MOZ_ASSERT(frame->StyleDisplay()->mTopLayer != StyleTopLayer::None,
"ua.css should ensure this");
MOZ_ASSERT(frame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW));
+ isAnonContent = frame->ContentIsRootOfNativeAnonymousSubtree();
BuildDisplayListForTopLayerFrame(aBuilder, frame, &topLayerList);
}
}
+ if (auto zenBackend = zen::nsZenBoostsBackend::GetInstance()) {
+ zenBackend->mCurrentFrameIsAnonymousContent = isAnonContent;
+ }
return MaybeWrapTopLayerList(
aBuilder, uint16_t(TopLayerIndex::ViewTransitionsAndAnonymousContent),
topLayerList);

View File

@@ -0,0 +1,47 @@
diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp
index c27fec39f9e32e61f0e335e5880ce3e97074965b..7b4f7760dcf92ead74c9f89cfc7a067892af9e34 100644
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -349,7 +349,8 @@ class nsDisplaySelectionOverlay final : public nsPaintedDisplayItem {
nsDisplayListBuilder* aDisplayListBuilder) override;
NS_DISPLAY_DECL_NAME("SelectionOverlay", TYPE_SELECTION_OVERLAY)
- static DeviceColor ComputeColorFromSelectionStyle(const ComputedStyle&);
+ static DeviceColor ComputeColorFromSelectionStyle(const ComputedStyle&,
+ const nsIFrame*);
static DeviceColor ApplyTransparencyIfNecessary(nscolor);
private:
@@ -371,9 +372,9 @@ DeviceColor nsDisplaySelectionOverlay::ApplyTransparencyIfNecessary(
}
DeviceColor nsDisplaySelectionOverlay::ComputeColorFromSelectionStyle(
- const ComputedStyle& aStyle) {
- return ApplyTransparencyIfNecessary(
- aStyle.GetVisitedDependentColor(&nsStyleBackground::mBackgroundColor));
+ const ComputedStyle& aStyle, const nsIFrame* aFrame) {
+ return ApplyTransparencyIfNecessary(aStyle.GetVisitedDependentColor(
+ &nsStyleBackground::mBackgroundColor, aFrame));
}
void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
@@ -472,7 +473,8 @@ void nsContainerFrame::DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder,
ComputeHighlightSelectionStyle(sd->mHighlightData.mHighlightName)) {
aList->AppendNewToTopWithIndex<nsDisplaySelectionOverlay>(
aBuilder, this, index++,
- nsDisplaySelectionOverlay::ComputeColorFromSelectionStyle(*style));
+ nsDisplaySelectionOverlay::ComputeColorFromSelectionStyle(*style,
+ this));
}
}
@@ -480,7 +482,8 @@ void nsContainerFrame::DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder,
if (normal) {
DeviceColor color;
if (RefPtr<ComputedStyle> style = ComputeSelectionStyle(selectionValue)) {
- color = nsDisplaySelectionOverlay::ComputeColorFromSelectionStyle(*style);
+ color = nsDisplaySelectionOverlay::ComputeColorFromSelectionStyle(*style,
+ this);
} else {
LookAndFeel::ColorID colorID;
if (selectionValue == nsISelectionController::SELECTION_ON) {

View File

@@ -0,0 +1,13 @@
diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h
index 588b00d7ee115f0a7513e357af7ab5eee28311c1..bf07b69c7e7957e6e558403e069f16e2dec3cad0 100644
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -1008,7 +1008,7 @@ class nsIFrame : public nsQueryFrame {
/** Also forward GetVisitedDependentColor to the style */
template <typename T, typename S>
nscolor GetVisitedDependentColor(T S::* aField) {
- return mComputedStyle->GetVisitedDependentColor(aField);
+ return mComputedStyle->GetVisitedDependentColor(aField, this);
}
/**

View File

@@ -0,0 +1,13 @@
diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp
index c4ff60477e3061aeeecbdedb5ad8054d3808ab6e..40857d430eda576c4fca613857860f32abb39e2d 100644
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1764,7 +1764,7 @@ void nsImageFrame::DisplayAltText(nsPresContext* aPresContext,
const nsRect& aRect) {
// Set font and color
aRenderingContext.SetColor(
- sRGBColor::FromABGR(StyleText()->mColor.ToColor()));
+ sRGBColor::FromABGR(StyleText()->mColor.ToColor(this)));
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetInflatedFontMetricsForFrame(this);

View File

@@ -0,0 +1,13 @@
diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp
index e7f7943a19d3ac71872d0a8439b6ed90e8fd423d..eb3e84fabc67d95b6d194b5aaf3aaef7c38480c0 100644
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -6381,7 +6381,7 @@ void nsTextFrame::DrawSelectionDecorations(
computedStyleFromPseudo->StyleTextReset()->mTextDecorationStyle;
params.color =
computedStyleFromPseudo->StyleTextReset()
- ->mTextDecorationColor.CalcColor(*computedStyleFromPseudo);
+ ->mTextDecorationColor.CalcColor(*computedStyleFromPseudo, this);
params.decoration =
computedStyleFromPseudo->StyleTextReset()->mTextDecorationLine;
params.descentLimit = -1.f;

View File

@@ -0,0 +1,67 @@
diff --git a/layout/generic/nsTextPaintStyle.cpp b/layout/generic/nsTextPaintStyle.cpp
index 5d1bf44687e925aff67f44c8e0629f7f06e84e98..1fa60a4d91edc60ba733cefc5f73ab8b7684d02a 100644
--- a/layout/generic/nsTextPaintStyle.cpp
+++ b/layout/generic/nsTextPaintStyle.cpp
@@ -240,7 +240,7 @@ bool nsTextPaintStyle::GetTargetTextColor(nscolor* aForeColor) {
(mTargetTextPseudoStyle->HasAuthorSpecifiedTextColor() ||
mTargetTextPseudoStyle->HasAuthorSpecifiedBorderOrBackground())) {
*aForeColor = mTargetTextPseudoStyle->GetVisitedDependentColor(
- &nsStyleText::mWebkitTextFillColor);
+ &nsStyleText::mWebkitTextFillColor, mFrame);
return mTargetTextPseudoStyle->HasAuthorSpecifiedTextColor();
}
*aForeColor = LookAndFeel::Color(
@@ -257,7 +257,7 @@ bool nsTextPaintStyle::GetTargetTextBackgroundColor(nscolor* aBackColor) {
(mTargetTextPseudoStyle->HasAuthorSpecifiedTextColor() ||
mTargetTextPseudoStyle->HasAuthorSpecifiedBorderOrBackground())) {
*aBackColor = mTargetTextPseudoStyle->GetVisitedDependentColor(
- &nsStyleBackground::mBackgroundColor);
+ &nsStyleBackground::mBackgroundColor, mFrame);
return NS_GET_A(*aBackColor) != 0;
}
*aBackColor = LookAndFeel::Color(
@@ -295,7 +295,8 @@ bool nsTextPaintStyle::GetCustomHighlightTextColor(nsAtom* aHighlightName,
return false;
}
- *aForeColor = highlightStyle->GetVisitedDependentColor(&nsStyleText::mColor);
+ *aForeColor =
+ highlightStyle->GetVisitedDependentColor(&nsStyleText::mColor, mFrame);
return highlightStyle->HasAuthorSpecifiedTextColor();
}
@@ -317,7 +318,7 @@ bool nsTextPaintStyle::GetCustomHighlightBackgroundColor(nsAtom* aHighlightName,
}
*aBackColor = highlightStyle->GetVisitedDependentColor(
- &nsStyleBackground::mBackgroundColor);
+ &nsStyleBackground::mBackgroundColor, mFrame);
return NS_GET_A(*aBackColor) != 0;
}
@@ -466,19 +467,19 @@ bool nsTextPaintStyle::InitSelectionColorsAndShadow() {
// this is web content or chrome content. See bug 2029839.
if (!mFrame->PresContext()->Document()->ChromeRulesEnabled()) {
mSelectionBGColor = mSelectionPseudoStyle->GetVisitedDependentColor(
- &nsStyleBackground::mBackgroundColor);
- mSelectionTextColor =
- mSelectionPseudoStyle->GetVisitedDependentColor(&nsStyleText::mColor);
+ &nsStyleBackground::mBackgroundColor, mFrame);
+ mSelectionTextColor = mSelectionPseudoStyle->GetVisitedDependentColor(
+ &nsStyleText::mColor, mFrame);
return true;
}
if (nscolor bgColor = mSelectionPseudoStyle->GetVisitedDependentColor(
- &nsStyleBackground::mBackgroundColor);
+ &nsStyleBackground::mBackgroundColor, mFrame);
mSelectionPseudoStyle->HasAuthorSpecifiedTextColor() ||
NS_GET_A(bgColor) > 0) {
mSelectionBGColor = bgColor;
- mSelectionTextColor =
- mSelectionPseudoStyle->GetVisitedDependentColor(&nsStyleText::mColor);
+ mSelectionTextColor = mSelectionPseudoStyle->GetVisitedDependentColor(
+ &nsStyleText::mColor, mFrame);
return true;
}
}

View File

@@ -0,0 +1,13 @@
diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp
index befaf7fed81a486f61e1186775c138ce5473a057..c7eb36dc9fcd06f8641d2d1a974e75eb24e07669 100644
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -1686,7 +1686,7 @@ void nsMathMLChar::PaintForeground(nsIFrame* aForFrame,
// Set color ...
nscolor fgColor = computedStyle->GetVisitedDependentColor(
- &nsStyleText::mWebkitTextFillColor);
+ &nsStyleText::mWebkitTextFillColor, aForFrame);
if (aIsSelected) {
// get color to use for selection from the look&feel object
fgColor = LookAndFeel::Color(LookAndFeel::ColorID::Highlighttext, aForFrame,

View File

@@ -0,0 +1,87 @@
diff --git a/layout/painting/nsCSSRendering.cpp b/layout/painting/nsCSSRendering.cpp
index a581b039a8681f7d8191edfad100d287af38592e..4cd3d6695a04a42d806c36f8d5a324cac9efda34 100644
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -598,7 +598,8 @@ void nsCSSRendering::ComputePixelRadii(const nsRectCornerRadii& aRadii,
}
}
-static Maybe<nsStyleBorder> GetBorderIfVisited(const ComputedStyle& aStyle) {
+static Maybe<nsStyleBorder> GetBorderIfVisited(const ComputedStyle& aStyle,
+ const nsIFrame* aFrame) {
Maybe<nsStyleBorder> result;
// Don't check RelevantLinkVisited here, since we want to take the
// same amount of time whether or not it's true.
@@ -611,7 +612,7 @@ static Maybe<nsStyleBorder> GetBorderIfVisited(const ComputedStyle& aStyle) {
auto& newBorder = result.ref();
for (const auto side : mozilla::AllPhysicalSides()) {
nscolor color = aStyle.GetVisitedDependentColor(
- nsStyleBorder::BorderColorFieldFor(side));
+ nsStyleBorder::BorderColorFieldFor(side), aFrame);
newBorder.BorderColorFor(side) = StyleColor::FromColor(color);
}
@@ -624,7 +625,7 @@ ImgDrawResult nsCSSRendering::PaintBorder(
ComputedStyle* aStyle, PaintBorderFlags aFlags, Sides aSkipSides) {
AUTO_PROFILER_LABEL("nsCSSRendering::PaintBorder", GRAPHICS);
- Maybe<nsStyleBorder> visitedBorder = GetBorderIfVisited(*aStyle);
+ Maybe<nsStyleBorder> visitedBorder = GetBorderIfVisited(*aStyle, aForFrame);
return PaintBorderWithStyleBorder(
aPresContext, aRenderingContext, aForFrame, aDirtyRect, aBorderArea,
visitedBorder.refOr(*aStyle->StyleBorder()), aStyle, aFlags, aSkipSides);
@@ -634,7 +635,7 @@ Maybe<nsCSSBorderRenderer> nsCSSRendering::CreateBorderRenderer(
nsPresContext* aPresContext, DrawTarget* aDrawTarget, nsIFrame* aForFrame,
const nsRect& aDirtyRect, const nsRect& aBorderArea, ComputedStyle* aStyle,
bool* aOutBorderIsEmpty, Sides aSkipSides) {
- Maybe<nsStyleBorder> visitedBorder = GetBorderIfVisited(*aStyle);
+ Maybe<nsStyleBorder> visitedBorder = GetBorderIfVisited(*aStyle, aForFrame);
return CreateBorderRendererWithStyleBorder(
aPresContext, aDrawTarget, aForFrame, aDirtyRect, aBorderArea,
visitedBorder.refOr(*aStyle->StyleBorder()), aStyle, aOutBorderIsEmpty,
@@ -649,7 +650,7 @@ ImgDrawResult nsCSSRendering::CreateWebRenderCommandsForBorder(
mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) {
const auto* style = aForFrame->Style();
- Maybe<nsStyleBorder> visitedBorder = GetBorderIfVisited(*style);
+ Maybe<nsStyleBorder> visitedBorder = GetBorderIfVisited(*style, aForFrame);
return nsCSSRendering::CreateWebRenderCommandsForBorderWithStyleBorder(
aItem, aForFrame, aBorderArea, aBuilder, aResources, aSc, aManager,
aDisplayListBuilder, visitedBorder.refOr(*style->StyleBorder()));
@@ -785,7 +786,7 @@ static nsCSSBorderRenderer ConstructBorderRenderer(
// pull out styles, colors
for (const auto i : mozilla::AllPhysicalSides()) {
borderStyles[i] = aStyleBorder.GetBorderStyle(i);
- borderColors[i] = aStyleBorder.BorderColorFor(i).CalcColor(*aStyle);
+ borderColors[i] = aStyleBorder.BorderColorFor(i).CalcColor(*aStyle, aForFrame);
}
PrintAsFormatString(
@@ -1005,7 +1006,7 @@ nsCSSRendering::CreateBorderRendererForNonThemedOutline(
// This handles treating the initial color as 'currentColor'; if we
// ever want 'invert' back we'll need to do a bit of work here too.
nscolor outlineColor =
- aStyle->GetVisitedDependentColor(&nsStyleOutline::mOutlineColor);
+ aStyle->GetVisitedDependentColor(&nsStyleOutline::mOutlineColor, aForFrame);
nscolor outlineColors[4] = {outlineColor, outlineColor, outlineColor,
outlineColor};
@@ -2341,7 +2342,7 @@ static Maybe<nscolor> CalcScrollbarColor(nsIFrame* aFrame,
const auto& color = aKind == ScrollbarColorKind::Thumb
? colors.AsColors().thumb
: colors.AsColors().track;
- return Some(color.CalcColor(*scrollbarStyle));
+ return Some(color.CalcColor(*scrollbarStyle, aFrame));
}
static nscolor GetBackgroundColor(nsIFrame* aFrame,
@@ -2367,7 +2368,8 @@ static nscolor GetBackgroundColor(nsIFrame* aFrame,
default:
break;
}
- return aStyle->GetVisitedDependentColor(&nsStyleBackground::mBackgroundColor);
+ return aStyle->GetVisitedDependentColor(&nsStyleBackground::mBackgroundColor,
+ aFrame);
}
nscolor nsCSSRendering::DetermineBackgroundColor(nsPresContext* aPresContext,

View File

@@ -1,23 +0,0 @@
diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp
index 4488dc2025da64fbad0e0ec998793a476de640ef..82990853e7279723666635ab8d9a929ede3f3aca 100644
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -81,6 +81,7 @@
#include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/layers/WebRenderMessages.h"
#include "mozilla/layers/WebRenderScrollData.h"
+#include "mozilla/nsZenBoostsBackend.h"
#include "nsCSSProps.h"
#include "nsCSSRendering.h"
#include "nsCSSRenderingGradients.h"
@@ -1252,6 +1253,10 @@ void nsDisplayListBuilder::EnterPresShell(const nsIFrame* aReferenceFrame,
docShell->GetWindowDraggingAllowed(&mWindowDraggingAllowed);
}
+ if (auto zenBackend = zen::nsZenBoostsBackend::GetInstance(); zenBackend && !mIsInChromePresContext) {
+ zenBackend->onPresShellEntered(pc->Document());
+ }
+
state->mTouchEventPrefEnabledDoc = dom::TouchEvent::PrefEnabled(docShell);
if (auto* vt = pc->Document()->GetActiveViewTransition()) {

View File

@@ -0,0 +1,65 @@
diff --git a/layout/style/ComputedStyle.cpp b/layout/style/ComputedStyle.cpp
index 18308d7891aab4ff0542e774190abeed6aad7c59..453da8ffa14ee5f31fbce873721779cbadce240d 100644
--- a/layout/style/ComputedStyle.cpp
+++ b/layout/style/ComputedStyle.cpp
@@ -285,29 +285,32 @@ static nscolor GetVisitedDependentColorInternal(const ComputedStyle& aStyle,
}
static nscolor ExtractColor(const ComputedStyle& aStyle,
- const StyleAbsoluteColor& aColor) {
- return aColor.ToColor();
+ const StyleAbsoluteColor& aColor,
+ const nsIFrame* aFrame) {
+ return aColor.ToColor(aFrame);
}
static nscolor ExtractColor(const ComputedStyle& aStyle,
- const StyleColor& aColor) {
- return aColor.CalcColor(aStyle);
+ const StyleColor& aColor, const nsIFrame* aFrame) {
+ return aColor.CalcColor(aStyle, aFrame);
}
// Currently caret-color, the only property in the list which is a ColorOrAuto,
// always maps auto to currentcolor.
static nscolor ExtractColor(const ComputedStyle& aStyle,
- const StyleColorOrAuto& aColor) {
+ const StyleColorOrAuto& aColor,
+ const nsIFrame* aFrame) {
if (aColor.IsAuto()) {
- return ExtractColor(aStyle, StyleColor::CurrentColor());
+ return ExtractColor(aStyle, StyleColor::CurrentColor(), aFrame);
}
- return ExtractColor(aStyle, aColor.AsColor());
+ return ExtractColor(aStyle, aColor.AsColor(), aFrame);
}
static nscolor ExtractColor(const ComputedStyle& aStyle,
- const StyleSVGPaint& aPaintServer) {
+ const StyleSVGPaint& aPaintServer,
+ const nsIFrame* aFrame) {
return aPaintServer.kind.IsColor()
- ? ExtractColor(aStyle, aPaintServer.kind.AsColor())
+ ? ExtractColor(aStyle, aPaintServer.kind.AsColor(), aFrame)
: NS_RGBA(0, 0, 0, 0);
}
@@ -315,14 +318,14 @@ static nscolor ExtractColor(const ComputedStyle& aStyle,
#define GENERATE_VISITED_COLOR_TEMPLATE(name_, fields_) \
template <> \
nscolor ComputedStyle::GetVisitedDependentColor( \
- decltype(nsStyle##name_::MOZ_ARG_1 fields_) nsStyle##name_::* aField) \
- const { \
+ decltype(nsStyle##name_::MOZ_ARG_1 fields_) nsStyle##name_::* aField, \
+ const nsIFrame* aFrame) const { \
MOZ_ASSERT(MOZ_FOR_EACH(STYLE_FIELD, (nsStyle##name_, ), fields_) false, \
"Getting visited-dependent color for a field in nsStyle" #name_ \
" which is not listed in nsCSSVisitedDependentPropList.h"); \
return GetVisitedDependentColorInternal( \
- *this, [aField](const ComputedStyle& aStyle) { \
- return ExtractColor(aStyle, aStyle.Style##name_()->*aField); \
+ *this, [aField, aFrame](const ComputedStyle& aStyle) { \
+ return ExtractColor(aStyle, aStyle.Style##name_()->*aField, aFrame); \
}); \
}
FOR_EACH_VISITED_DEPENDENT_STYLE_STRUCT(GENERATE_VISITED_COLOR_TEMPLATE)

View File

@@ -0,0 +1,22 @@
diff --git a/layout/style/ComputedStyle.h b/layout/style/ComputedStyle.h
index 661ec439dea1bc59dbc4507c9788df8821ea9086..7aa21f5388d6e3b5f1a85e38acdd646254ca8b01 100644
--- a/layout/style/ComputedStyle.h
+++ b/layout/style/ComputedStyle.h
@@ -18,6 +18,7 @@
enum nsChangeHint : uint32_t;
class nsWindowSizes;
+class nsIFrame;
#define FORWARD_STRUCT(name_) struct nsStyle##name_;
FOR_EACH_STYLE_STRUCT(FORWARD_STRUCT, FORWARD_STRUCT)
@@ -338,7 +339,8 @@ class ComputedStyle {
* been listed in nsCSSVisitedDependentPropList.h.
*/
template <typename T, typename S>
- nscolor GetVisitedDependentColor(T S::* aField) const;
+ nscolor GetVisitedDependentColor(T S::* aField,
+ const nsIFrame* aFrame) const;
/**
* aColors should be a two element array of nscolor in which the first

View File

@@ -1,5 +1,5 @@
diff --git a/layout/style/StyleColor.cpp b/layout/style/StyleColor.cpp
index 95c7ae6abea5032bef0466e8d59d212374d7a4d0..3b2118e224141f5151a31ac663dfbe17864ef182 100644
index 95c7ae6abea5032bef0466e8d59d212374d7a4d0..234a5fc3d94c341d6f8aea8f619661054d2f6a49 100644
--- a/layout/style/StyleColor.cpp
+++ b/layout/style/StyleColor.cpp
@@ -8,6 +8,7 @@
@@ -10,7 +10,34 @@ index 95c7ae6abea5032bef0466e8d59d212374d7a4d0..3b2118e224141f5151a31ac663dfbe17
namespace mozilla {
@@ -68,10 +69,11 @@ nscolor StyleAbsoluteColor::ToColor() const {
@@ -44,13 +45,14 @@ nscolor StyleColor::CalcColor(
}
template <>
-nscolor StyleColor::CalcColor(const ComputedStyle& aStyle) const {
- return ResolveColor(aStyle.StyleText()->mColor).ToColor();
+nscolor StyleColor::CalcColor(const ComputedStyle& aStyle,
+ const nsIFrame* aFrame) const {
+ return ResolveColor(aStyle.StyleText()->mColor).ToColor(aFrame);
}
template <>
nscolor StyleColor::CalcColor(const nsIFrame* aFrame) const {
- return ResolveColor(aFrame->StyleText()->mColor).ToColor();
+ return ResolveColor(aFrame->StyleText()->mColor).ToColor(aFrame);
}
StyleAbsoluteColor StyleAbsoluteColor::ToColorSpace(
@@ -58,7 +60,7 @@ StyleAbsoluteColor StyleAbsoluteColor::ToColorSpace(
return Servo_ConvertColorSpace(this, aColorSpace);
}
-nscolor StyleAbsoluteColor::ToColor() const {
+nscolor StyleAbsoluteColor::ToColor(const nsIFrame* aFrame) const {
auto srgb = ToColorSpace(StyleColorSpace::Srgb);
// TODO(tlouw): Needs gamut mapping here. Right now we just hard clip the
@@ -68,10 +70,12 @@ nscolor StyleAbsoluteColor::ToColor() const {
auto green = std::clamp(srgb.components._1, 0.0f, 1.0f);
auto blue = std::clamp(srgb.components._2, 0.0f, 1.0f);
@@ -20,7 +47,8 @@ index 95c7ae6abea5032bef0466e8d59d212374d7a4d0..3b2118e224141f5151a31ac663dfbe17
nsStyleUtil::FloatToColorComponent(green),
nsStyleUtil::FloatToColorComponent(blue),
- nsStyleUtil::FloatToColorComponent(srgb.alpha));
+ nsStyleUtil::FloatToColorComponent(srgb.alpha)));
+ nsStyleUtil::FloatToColorComponent(srgb.alpha)),
+ aFrame);
}
} // namespace mozilla

View File

@@ -0,0 +1,13 @@
diff --git a/layout/style/StyleColorInlines.h b/layout/style/StyleColorInlines.h
index 332f715ca2a11c98afcb80a870da98c038a7e4f0..a5bddde67165fcb40d40b3aec76a9d19d8880d64 100644
--- a/layout/style/StyleColorInlines.h
+++ b/layout/style/StyleColorInlines.h
@@ -66,7 +66,7 @@ template <>
nscolor StyleColor::CalcColor(nscolor) const;
template <>
-nscolor StyleColor::CalcColor(const ComputedStyle&) const;
+nscolor StyleColor::CalcColor(const ComputedStyle&, const nsIFrame*) const;
template <>
nscolor StyleColor::CalcColor(const nsIFrame*) const;

View File

@@ -0,0 +1,13 @@
diff --git a/layout/svg/FilterInstance.cpp b/layout/svg/FilterInstance.cpp
index 499f824aaeed6ac014974ff11848cf40ac0bba09..bec724baf0ae97cd9dea59a1609d8ea9baaad715 100644
--- a/layout/svg/FilterInstance.cpp
+++ b/layout/svg/FilterInstance.cpp
@@ -1681,7 +1681,7 @@ nsresult FilterInstance::BuildPrimitivesForFilter(
// If we don't have a frame, use opaque black for shadows with unspecified
// shadow colors.
nscolor shadowFallbackColor =
- mTargetFrame ? mTargetFrame->StyleText()->mColor.ToColor()
+ mTargetFrame ? mTargetFrame->StyleText()->mColor.ToColor(mTargetFrame)
: NS_RGB(0, 0, 0);
CSSFilterInstance cssFilterInstance(aFilter, shadowFallbackColor,

View File

@@ -0,0 +1,28 @@
diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp
index 93f6f2a704734314586fa16b6a45b434f9c2304d..4503ee2b48be39bb2e61962316ef43ad292a7b27 100644
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -2662,9 +2662,9 @@ void SVGTextDrawPathCallbacks::ApplyOpacity(
sRGBColor& aColor, const StyleSVGPaint& aPaint,
const StyleSVGOpacity& aOpacity) const {
if (aPaint.kind.tag == StyleSVGPaintKind::Tag::Color) {
- aColor.a *=
- sRGBColor::FromABGR(aPaint.kind.AsColor().CalcColor(*mFrame->Style()))
- .a;
+ aColor.a *= sRGBColor::FromABGR(
+ aPaint.kind.AsColor().CalcColor(*mFrame->Style(), mFrame))
+ .a;
}
aColor.a *= SVGUtils::GetOpacity(aOpacity, mContextPaint);
}
@@ -5076,8 +5076,8 @@ bool SVGTextFrame::ShouldRenderAsPath(nsTextFrame* aFrame,
// It's possible nsTextFrame will support non-opaque shadows in the future,
// in which case this test can be removed.
if (style->mFill.kind.IsColor() && aFrame->StyleText()->HasTextShadow() &&
- NS_GET_A(style->mFill.kind.AsColor().CalcColor(*aFrame->Style())) !=
- 0xFF) {
+ NS_GET_A(style->mFill.kind.AsColor().CalcColor(*aFrame->Style(),
+ aFrame)) != 0xFF) {
return true;
}

View File

@@ -0,0 +1,13 @@
diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp
index 7c39ea94392dc158656621dfbee1be72bbcd46f8..e2fe47662b92ac6fb7fe2177d1d2cdab500bb969 100644
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -4088,7 +4088,7 @@ static void GetColorAndStyle(const nsIFrame* aFrame, WritingMode aTableWM,
return;
}
*aColor = aFrame->Style()->GetVisitedDependentColor(
- nsStyleBorder::BorderColorFieldFor(physicalSide));
+ nsStyleBorder::BorderColorFieldFor(physicalSide), aFrame);
if (aWidth) {
*aWidth = styleData->GetComputedBorderWidth(physicalSide);

View File

@@ -0,0 +1,23 @@
diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp
index b6aa10336e7994c830e0326298820c3a534f8094..b3ddb7b9b3ceb8b868e7e48e02fdb70a876c9019 100644
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -2865,7 +2865,8 @@ ImgDrawResult nsTreeBodyFrame::PaintCell(
const nsStyleBorder* borderStyle = lineContext->StyleBorder();
// Resolve currentcolor values against the treeline context
- nscolor color = borderStyle->mBorderLeftColor.CalcColor(*lineContext);
+ nscolor color =
+ borderStyle->mBorderLeftColor.CalcColor(*lineContext, this);
ColorPattern colorPatt(ToDeviceColor(color));
StyleBorderStyle style = borderStyle->GetBorderStyle(eSideLeft);
@@ -3340,7 +3341,7 @@ ImgDrawResult nsTreeBodyFrame::PaintText(
}
aRenderingContext.SetColor(
- sRGBColor::FromABGR(textContext->StyleText()->mColor.ToColor()));
+ sRGBColor::FromABGR(textContext->StyleText()->mColor.ToColor(this)));
nsLayoutUtils::DrawString(
this, *fontMet, &aRenderingContext, text.get(), text.Length(),
textRect.TopLeft() + nsPoint(0, baseline), cellContext);

View File

@@ -0,0 +1,30 @@
diff --git a/servo/ports/geckolib/cbindgen.toml b/servo/ports/geckolib/cbindgen.toml
index e9ae0149e80a241b2a32ce445deb923af2fac445..464f4e8b853d26bd2da327de8bf8bb50e5ab8599 100644
--- a/servo/ports/geckolib/cbindgen.toml
+++ b/servo/ports/geckolib/cbindgen.toml
@@ -679,9 +679,9 @@ renaming_overrides_prefixing = true
nscolor CalcColor(const nsIFrame*) const;
/**
* Compute the final color, taking into account the foreground color from the
- * style.
+ * style. The frame, when supplied, is used to resolve Zen boosts.
*/
- nscolor CalcColor(const ComputedStyle&) const;
+ nscolor CalcColor(const ComputedStyle&, const nsIFrame* = nullptr) const;
/**
* Compute the final color, making the argument the foreground color.
*/
@@ -704,9 +704,11 @@ renaming_overrides_prefixing = true
/**
* Convert this color to an nscolor. The color will be converted to sRGB first
- * if required.
+ * if required. The frame, when supplied, is used to resolve Zen boosts; pass
+ * the frame the color is being resolved for so boosts can be derived from its
+ * document, or null to skip boost resolution.
*/
- nscolor ToColor() const;
+ nscolor ToColor(const nsIFrame* = nullptr) const;
"""
"OwnedSlice" = """

View File

@@ -70,6 +70,17 @@ export class ZenBoostsChild extends JSWindowActorChild {
static PREVENTABLE_SET = new Set(ZenBoostsChild.PREVENTABLE_EVENTS);
actorCreated() {
this.#applyBoostForPageIfAvailable();
}
didDestroy() {
if (this.#currentState === ZenBoostsChild.STATES.ZAP) {
this.disableZapMode();
}
this.#removeEventListeners();
}
/**
* Inverse of https://searchfox.org/firefox-main/rev/1a8c62b86277005f907151bc5389cf5c5091e76f/gfx/src/nsColor.h#23-27
*
@@ -179,28 +190,6 @@ export class ZenBoostsChild extends JSWindowActorChild {
return [h * 60, s, l];
}
/**
* Handles DOM events for the actor. Applies boost settings when a document
* element is inserted.
*
* @param {Event} event - The DOM event to handle.
*/
handleEvent(event) {
switch (event.type) {
case "unload":
if (this.#currentState === ZenBoostsChild.STATES.ZAP) {
this.disableZapMode();
}
this.#removeEventListeners();
break;
case "DOMWindowCreated":
this.#applyBoostForPageIfAvailable();
break;
default:
break;
}
}
handleZapEvent(event) {
if (ZenBoostsChild.ALL_EVENTS_SET.has(event.type)) {
this.#overlay.handleEvent(

View File

@@ -38,18 +38,6 @@ void BrowsingContext::WalkPresContexts(Callback&& aCallback) {
});
}
static void RefreshBoostCacheIfMatchesCurrent(BrowsingContext* aChanged) {
auto* backend = zen::nsZenBoostsBackend::GetInstance();
if (!backend) {
return;
}
RefPtr<BrowsingContext> current = backend->GetCurrentBrowsingContext();
if (!current || current->Top() != aChanged) {
return;
}
backend->RefreshCachedBoostState();
}
/**
* @brief Called when the ZenBoostsData field is set on a browsing context.
* Triggers a restyle if the boost data has changed.
@@ -61,7 +49,6 @@ void BrowsingContext::DidSet(FieldIndex<IDX_ZenBoostsData>,
if (ZenBoostsData() == aOldValue) {
return;
}
RefreshBoostCacheIfMatchesCurrent(this);
PresContextAffectingFieldChanged();
TRIGGER_PRES_CONTEXT_RESTYLE();
}
@@ -79,7 +66,6 @@ void BrowsingContext::DidSet(FieldIndex<IDX_ZenBoostsComplementaryRotation>,
if (ZenBoostsComplementaryRotation() == aOldValue) {
return;
}
RefreshBoostCacheIfMatchesCurrent(this);
PresContextAffectingFieldChanged();
TRIGGER_PRES_CONTEXT_RESTYLE();
}
@@ -95,7 +81,6 @@ void BrowsingContext::DidSet(FieldIndex<IDX_IsZenBoostsInverted>,
if (IsZenBoostsInverted() == aOldValue) {
return;
}
RefreshBoostCacheIfMatchesCurrent(this);
PresContextAffectingFieldChanged();
TRIGGER_PRES_CONTEXT_RESTYLE();
}

View File

@@ -12,6 +12,8 @@
#include "nsIXULRuntime.h"
#include "nsPresContext.h"
#include "nsIFrame.h"
#include "nsIContent.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/StaticPtr.h"
@@ -31,9 +33,6 @@
#define INVERT_CHANNEL_FLOOR() \
(mozilla::StaticPrefs::zen_boosts_invert_channel_floor_AtStartup())
#define SHOULD_APPLY_BOOSTS_TO_ANONYMOUS_CONTENT() \
(!mozilla::StaticPrefs::zen_boosts_disable_on_anonymous_content_AtStartup())
#if defined(__clang__) || defined(__GNUC__)
# define ZEN_HOT_FUNCTION __attribute__((hot))
#else
@@ -381,27 +380,36 @@ inline static nscolor zenInvertColorChannel(nscolor aColor) {
}
/**
* @brief Retrieves the current boost data from the browsing context. When
* called without aPresContext, reads the precomputed cache populated on
* presshell entry; otherwise resolves from the supplied PresContext.
* @brief Whether the given frame belongs to anonymous content that boosts must
* not touch (devtools highlighters, screenshots, the boosts overlays
* themselves, and other native-anonymous UI such as scrollbars). A null frame
* gives no document to anchor the boost on, so it is treated the same way.
*/
ZEN_HOT_FUNCTION
inline static void GetZenBoostsDataFromBrowsingContext(
ZenBoostData* aData, float* aComplementaryRotation, bool* aIsInverted,
nsPresContext* aPresContext = nullptr) {
auto zenBoosts = nsZenBoostsBackend::GetInstance();
if (!zenBoosts || (zenBoosts->mCurrentFrameIsAnonymousContent &&
!SHOULD_APPLY_BOOSTS_TO_ANONYMOUS_CONTENT())) {
inline static bool IsBoostExemptFrame(const nsIFrame* aFrame) {
if (!aFrame) {
return true;
}
const nsIContent* content = aFrame->GetContent();
return content && content->IsInNativeAnonymousSubtree();
}
/**
* @brief Retrieves the boost data for the document the given frame belongs to.
* Resolves from the frame's PresContext -> Document -> top BrowsingContext,
* which carries the accent/inversion fields.
*/
ZEN_HOT_FUNCTION
inline static void GetZenBoostsDataForFrame(const nsIFrame* aFrame,
ZenBoostData* aData,
float* aComplementaryRotation,
bool* aIsInverted) {
nsPresContext* presContext = aFrame->PresContext();
if (!presContext) {
return;
}
if (!aPresContext) {
*aData = zenBoosts->mCachedCurrentAccent;
*aComplementaryRotation = zenBoosts->mCachedCurrentComplementaryRotation;
*aIsInverted = zenBoosts->mCachedCurrentInverted;
return;
}
mozilla::dom::BrowsingContext* browsingContext = nullptr;
if (auto document = aPresContext->Document()) {
const mozilla::dom::BrowsingContext* browsingContext = nullptr;
if (auto document = presContext->Document()) {
browsingContext = document->GetBrowsingContext();
}
if (!browsingContext) {
@@ -456,59 +464,24 @@ auto nsZenBoostsBackend::GetInstance() -> nsZenBoostsBackend* {
return sZenBoostsBackend.get();
}
auto nsZenBoostsBackend::onPresShellEntered(mozilla::dom::Document* aDocument)
-> void {
if (auto displayDoc = aDocument->GetDisplayDocument()) {
onPresShellEntered(displayDoc);
return;
}
// Note that aDocument can be null when entering anonymous content frames.
// We explicitly do this to prevent applying boosts to anonymous content, such
// as devtools or screenshots.
mozilla::dom::BrowsingContext* browsingContext =
aDocument ? aDocument->GetBrowsingContext() : nullptr;
if (!browsingContext) {
return;
}
mCurrentBrowsingContextId = browsingContext->Id();
RefreshCachedBoostState();
}
already_AddRefed<mozilla::dom::BrowsingContext>
nsZenBoostsBackend::GetCurrentBrowsingContext() const {
return mozilla::dom::BrowsingContext::Get(mCurrentBrowsingContextId);
}
auto nsZenBoostsBackend::RefreshCachedBoostState() -> void {
RefPtr<mozilla::dom::BrowsingContext> current =
mozilla::dom::BrowsingContext::Get(mCurrentBrowsingContextId);
if (!current) {
mCachedCurrentAccent = 0;
mCachedCurrentComplementaryRotation = 0.0f;
mCachedCurrentInverted = false;
return;
}
auto top = current->Top();
mCachedCurrentAccent = top->ZenBoostsData();
mCachedCurrentComplementaryRotation = top->ZenBoostsComplementaryRotation();
mCachedCurrentInverted = top->IsZenBoostsInverted();
}
[[nodiscard]] ZEN_HOT_FUNCTION auto
nsZenBoostsBackend::FilterColorFromPresContext(nscolor aColor,
nsPresContext* aPresContext)
-> nscolor {
[[nodiscard]] ZEN_HOT_FUNCTION auto nsZenBoostsBackend::ResolveStyleColor(
nscolor aColor, const nsIFrame* aFrame) -> nscolor {
if (NS_GET_A(aColor) == 0) {
// Skip processing fully transparent colors since they won't be visible and
// we want to avoid unnecessary computations. This also prevents issues with
// using the alpha channel for contrast information in the accent color.
return aColor;
}
// Boosts are only supported in content; GetInstance() is null in the parent
// process, which keeps the browser chrome from being tinted.
if (!GetInstance() || IsBoostExemptFrame(aFrame)) {
return aColor;
}
ZenBoostData accentNS = 0;
float complementaryRotation = 0.0f;
bool invertColors = false;
GetZenBoostsDataFromBrowsingContext(&accentNS, &complementaryRotation,
&invertColors, aPresContext);
GetZenBoostsDataForFrame(aFrame, &accentNS, &complementaryRotation,
&invertColors);
if (accentNS) {
// Resolve (and cache) the base + complementary accent for this accent and
// complementary rotation. Apply a filter-like tint:
@@ -526,9 +499,4 @@ nsZenBoostsBackend::FilterColorFromPresContext(nscolor aColor,
return aColor;
}
[[nodiscard]] ZEN_HOT_FUNCTION auto nsZenBoostsBackend::ResolveStyleColor(
nscolor aColor) -> nscolor {
return FilterColorFromPresContext(aColor);
}
} // namespace zen

View File

@@ -9,10 +9,7 @@
#include "nsISupportsImpl.h"
#include "nsPresContext.h"
#include "mozilla/RefPtr.h"
#include "mozilla/AlreadyAddRefed.h"
#include <cstdint>
class nsIFrame;
namespace mozilla::dom {
class BrowsingContext;
@@ -49,80 +46,29 @@ class nsZenBoostsBackend final : public nsISupports {
explicit nsZenBoostsBackend() = default;
/**
* Indicates whether the current frame being rendered is for anonymous
* content.
*/
bool mCurrentFrameIsAnonymousContent = false;
/**
* @brief Resolve a color to take into account Zen boosts. This is the single
* place style colors are filtered; it is reached for every style color via
* StyleAbsoluteColor::ToColor. Do not add a second StyleColor::ResolveColor
* filter on top of this or colors get filtered multiple times (which also
* makes resting colors disagree with composited transition endpoints).
*
* The boost state is derived from the frame the color is being resolved for:
* its document's top BrowsingContext carries the accent/inversion data. When
* @p aFrame is null, or belongs to anonymous content (devtools, screenshots,
* the boosts overlays themselves), the color is returned unfiltered.
* @param aColor The color to resolve.
* @param aFrame The frame the color is being resolved for, or null.
* @return The resolved color with Zen boost filters applied, or the original
* color if no boost is active.
* @see StyleAbsoluteColor::ToColor for reference.
*/
static auto ResolveStyleColor(nscolor aColor) -> nscolor;
/**
* @brief Filter a color based on the current Zen boost settings.
* @param aColor The color to filter.
* @param aPresContext The presentation context to use for filtering.
* @return The filtered color.
*/
static auto FilterColorFromPresContext(nscolor aColor,
nsPresContext* aPresContext = nullptr)
static auto ResolveStyleColor(nscolor aColor, const nsIFrame* aFrame)
-> nscolor;
/**
* @brief Called when a presshell is entered during rendering.
* @param aDocument The document associated with the presshell being entered.
*/
auto onPresShellEntered(mozilla::dom::Document* aDocument) -> void;
/**
* @brief Refresh the cached boost state from the current top BrowsingContext.
* Called from onPresShellEntered and from BrowsingContext::DidSet hooks when
* the underlying boost fields change.
*/
auto RefreshCachedBoostState() -> void;
/**
* Resolves the current top BrowsingContext from its stored id. May return
* null if it has since been discarded. Not on the per-color hot path; the
* hot path uses the mCachedCurrent* fields instead.
*/
[[nodiscard]] already_AddRefed<mozilla::dom::BrowsingContext>
GetCurrentBrowsingContext() const;
/**
* Cached boost data for the current top BrowsingContext, refreshed on
* presshell entry and on DidSet hooks. Read by the per-color hot path so
* that boost-off pages don't pay for a BrowsingContext walk on every color
* resolve.
*/
ZenBoostData mCachedCurrentAccent = 0;
// Hue rotation in degrees applied to the base accent to derive the
// complementary accent. Zero means the complementary accent equals the base
// accent (the duotone collapses to a single-accent tint).
float mCachedCurrentComplementaryRotation = 0.0f;
bool mCachedCurrentInverted = false;
private:
~nsZenBoostsBackend() = default;
/**
* Id of the top BrowsingContext of the current document being rendered.
* Stored as an id rather than a strong RefPtr so the process-wide singleton
* does not keep a navigated-away BrowsingContext (and its subtree) alive
* until the next presshell entry.
*/
uint64_t mCurrentBrowsingContextId = 0;
public:
/**
* @brief Get the singleton instance of the ZenBoostsBackend.

View File

@@ -67,8 +67,9 @@ if (!Services.appinfo.inSafeMode) {
child: {
esModuleURI: "resource:///actors/ZenBoostsChild.sys.mjs",
events: {
// Needed to let the actor be created, please don't remove
// without checking if boosts still work without it, thanks <3
DOMWindowCreated: {},
unload: {},
},
},
allFrames: true,