mirror of
https://github.com/zen-browser/desktop.git
synced 2026-08-12 17:55:19 +00:00
no-bug: Fixed sites weirding out
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h
|
||||
index 42e3b22a366db0a8c470b458696d81e4bdbd537c..5d82dae436f502fa087f94f6baa7a280736d0b3e 100644
|
||||
index dc64d5c13628cb7393705ebf96110705b045471f..497c2e646e2bde4d7732fa28efe7496264d58fa0 100644
|
||||
--- a/docshell/base/BrowsingContext.h
|
||||
+++ b/docshell/base/BrowsingContext.h
|
||||
@@ -264,6 +264,8 @@ struct EmbedderColorSchemes {
|
||||
FIELD(IsInBFCache, bool) \
|
||||
@@ -263,6 +263,8 @@ struct EmbedderColorSchemes {
|
||||
FIELD(HistoryEntryCount, uint32_t) \
|
||||
FIELD(HasRestoreData, bool) \
|
||||
FIELD(SessionStoreEpoch, uint32_t) \
|
||||
+ FIELD(ZenBoostsData, nscolor) \
|
||||
@@ -11,7 +11,7 @@ index 42e3b22a366db0a8c470b458696d81e4bdbd537c..5d82dae436f502fa087f94f6baa7a280
|
||||
/* Whether we can execute scripts in this BrowsingContext. Has no effect \
|
||||
* unless scripts are also allowed in the parent WindowContext. */ \
|
||||
FIELD(AllowJavascript, bool) \
|
||||
@@ -665,6 +667,8 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
||||
@@ -674,6 +676,8 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
||||
|
||||
bool FullscreenAllowed() const;
|
||||
|
||||
@@ -20,7 +20,7 @@ index 42e3b22a366db0a8c470b458696d81e4bdbd537c..5d82dae436f502fa087f94f6baa7a280
|
||||
float FullZoom() const { return GetFullZoom(); }
|
||||
float TextZoom() const { return GetTextZoom(); }
|
||||
|
||||
@@ -1233,6 +1237,8 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
||||
@@ -1274,6 +1278,8 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
||||
}
|
||||
|
||||
void DidSet(FieldIndex<IDX_SessionStoreEpoch>, uint32_t aOldValue);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp
|
||||
index 3f9aea06257f162ded7d7cf8b32fc6597383cf27..099e825c251d4edf99b41f59160e276f5325217d 100644
|
||||
index c045de789d924d0fd652b81f4fef37cb0bc19112..ac3d3904626132257a1ffce4a8d7bd6b8c12728e 100644
|
||||
--- a/layout/painting/nsDisplayList.cpp
|
||||
+++ b/layout/painting/nsDisplayList.cpp
|
||||
@@ -82,6 +82,7 @@
|
||||
@@ -81,6 +81,7 @@
|
||||
#include "mozilla/layers/WebRenderLayerManager.h"
|
||||
#include "mozilla/layers/WebRenderMessages.h"
|
||||
#include "mozilla/layers/WebRenderScrollData.h"
|
||||
@@ -10,7 +10,7 @@ index 3f9aea06257f162ded7d7cf8b32fc6597383cf27..099e825c251d4edf99b41f59160e276f
|
||||
#include "nsCSSProps.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsCSSRenderingGradients.h"
|
||||
@@ -1212,6 +1213,10 @@ void nsDisplayListBuilder::EnterPresShell(const nsIFrame* aReferenceFrame,
|
||||
@@ -1252,6 +1253,10 @@ void nsDisplayListBuilder::EnterPresShell(const nsIFrame* aReferenceFrame,
|
||||
docShell->GetWindowDraggingAllowed(&mWindowDraggingAllowed);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
diff --git a/layout/style/StyleColor.cpp b/layout/style/StyleColor.cpp
|
||||
index 5fd5f7efba9bcb2febdc9a6b8f8812df673513d8..200e9bf82aacbf38a50f5b99671e403de5b4f61b 100644
|
||||
index 95c7ae6abea5032bef0466e8d59d212374d7a4d0..8dbfbb846b786d51af288989163aacfae12e787c 100644
|
||||
--- a/layout/style/StyleColor.cpp
|
||||
+++ b/layout/style/StyleColor.cpp
|
||||
@@ -10,6 +10,7 @@
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsStyleStruct.h"
|
||||
@@ -10,7 +10,7 @@ index 5fd5f7efba9bcb2febdc9a6b8f8812df673513d8..200e9bf82aacbf38a50f5b99671e403d
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@@ -23,6 +24,8 @@ bool StyleColor::MaybeTransparent() const {
|
||||
@@ -21,6 +22,8 @@ bool StyleColor::MaybeTransparent() const {
|
||||
template <>
|
||||
StyleAbsoluteColor StyleColor::ResolveColor(
|
||||
const StyleAbsoluteColor& aForegroundColor) const {
|
||||
@@ -19,7 +19,7 @@ index 5fd5f7efba9bcb2febdc9a6b8f8812df673513d8..200e9bf82aacbf38a50f5b99671e403d
|
||||
if (IsAbsolute()) {
|
||||
return AsAbsolute();
|
||||
}
|
||||
@@ -32,6 +35,8 @@ StyleAbsoluteColor StyleColor::ResolveColor(
|
||||
@@ -30,6 +33,8 @@ StyleAbsoluteColor StyleColor::ResolveColor(
|
||||
}
|
||||
|
||||
return Servo_ResolveColor(this, &aForegroundColor);
|
||||
@@ -28,3 +28,17 @@ index 5fd5f7efba9bcb2febdc9a6b8f8812df673513d8..200e9bf82aacbf38a50f5b99671e403d
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -68,10 +73,11 @@ 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);
|
||||
|
||||
- return NS_RGBA(nsStyleUtil::FloatToColorComponent(red),
|
||||
+ return zen::nsZenBoostsBackend::ResolveStyleColor(
|
||||
+ NS_RGBA(nsStyleUtil::FloatToColorComponent(red),
|
||||
nsStyleUtil::FloatToColorComponent(green),
|
||||
nsStyleUtil::FloatToColorComponent(blue),
|
||||
- nsStyleUtil::FloatToColorComponent(srgb.alpha));
|
||||
+ nsStyleUtil::FloatToColorComponent(srgb.alpha)));
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
@@ -493,8 +493,6 @@ void main() {
|
||||
|
||||
this.#onComplete = onComplete;
|
||||
|
||||
this.#onComplete = onComplete;
|
||||
|
||||
const rect = element.getBoundingClientRect();
|
||||
if (rect.width === 0 || rect.height === 0) {
|
||||
console.warn("[ZapDissolve]: element has zero size. Skipping dissolve");
|
||||
|
||||
@@ -284,11 +284,14 @@ auto nsZenBoostsBackend::GetInstance() -> nsZenBoostsBackend* {
|
||||
|
||||
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 =
|
||||
mCurrentBrowsingContext =
|
||||
aDocument ? aDocument->GetBrowsingContext() : nullptr;
|
||||
if (!browsingContext) {
|
||||
return;
|
||||
@@ -300,12 +303,6 @@ auto nsZenBoostsBackend::onPresShellEntered(mozilla::dom::Document* aDocument)
|
||||
nsZenBoostsBackend::FilterColorFromPresContext(nscolor aColor,
|
||||
nsPresContext* aPresContext)
|
||||
-> nscolor {
|
||||
if (!XRE_IsContentProcess()) {
|
||||
// Zen boosts are only supported in content, so if we somehow end up here
|
||||
// without a prescontext or in the parent process, just return the original
|
||||
// color.
|
||||
return aColor;
|
||||
}
|
||||
ZenBoostData accentNS = 0;
|
||||
bool invertColors = false;
|
||||
GetZenBoostsDataFromBrowsingContext(&accentNS, &invertColors, aPresContext);
|
||||
@@ -329,14 +326,19 @@ nsZenBoostsBackend::FilterColorFromPresContext(nscolor aColor,
|
||||
|
||||
[[nodiscard]] ZEN_HOT_FUNCTION auto nsZenBoostsBackend::ResolveStyleColor(
|
||||
mozilla::StyleAbsoluteColor aColor) -> mozilla::StyleAbsoluteColor {
|
||||
if (aColor.alpha == 0) {
|
||||
const auto resultColor = FilterColorFromPresContext(aColor.ToColor());
|
||||
return mozilla::StyleAbsoluteColor::FromColor(resultColor);
|
||||
}
|
||||
|
||||
[[nodiscard]] ZEN_HOT_FUNCTION auto nsZenBoostsBackend::ResolveStyleColor(
|
||||
nscolor aColor) -> 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;
|
||||
}
|
||||
const auto resultColor = FilterColorFromPresContext(aColor.ToColor());
|
||||
return mozilla::StyleAbsoluteColor::FromColor(resultColor);
|
||||
return FilterColorFromPresContext(aColor);
|
||||
}
|
||||
|
||||
} // namespace zen
|
||||
|
||||
@@ -43,6 +43,11 @@ class nsZenBoostsBackend final {
|
||||
static auto ResolveStyleColor(mozilla::StyleAbsoluteColor aColor)
|
||||
-> mozilla::StyleAbsoluteColor;
|
||||
|
||||
/**
|
||||
* @see ResolveStyleColor 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.
|
||||
|
||||
@@ -72,7 +72,7 @@ if (!Services.appinfo.inSafeMode) {
|
||||
},
|
||||
},
|
||||
allFrames: true,
|
||||
matches: ["*://*/*"],
|
||||
remoteTypes: ["web", "file"],
|
||||
enablePreference: "zen.boosts.enabled",
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user