fix: corner smoothing feature gate crash (#47785)
* fix: corner smoothing feature gate crash Co-authored-by: clavin <clavin@electronjs.org> * Fix ElectronCornerSmoothing::CSSValueFromComputedStyleInternal Co-authored-by: clavin <clavin@electronjs.org> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: clavin <clavin@electronjs.org>
This commit is contained in:
parent
7d83554d0e
commit
f37f8d41c0
8 changed files with 65 additions and 162 deletions
|
@ -51,19 +51,17 @@ Use the `system-ui` keyword to match the smoothness to the OS design language.
|
||||||
|
|
||||||
### Controlling availibility
|
### Controlling availibility
|
||||||
|
|
||||||
This CSS rule can be disabled by setting [the `cornerSmoothingCSS` web preference](./structures/web-preferences.md) to `false`.
|
This CSS rule can be disabled using the Blink feature flag `ElectronCSSCornerSmoothing`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const myWindow = new BrowserWindow({
|
const myWindow = new BrowserWindow({
|
||||||
// [...]
|
// [...]
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
enableCornerSmoothingCSS: false // Disables the `-electron-corner-smoothing` CSS rule
|
disableBlinkFeatures: 'ElectronCSSCornerSmoothing' // Disables the `-electron-corner-smoothing` CSS rule
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
The CSS rule will still parse, but will have no visual effect.
|
|
||||||
|
|
||||||
### Formal reference
|
### Formal reference
|
||||||
|
|
||||||
* **Initial value**: `0%`
|
* **Initial value**: `0%`
|
||||||
|
|
|
@ -149,7 +149,6 @@
|
||||||
`WebContents` when the preferred size changes. Default is `false`.
|
`WebContents` when the preferred size changes. Default is `false`.
|
||||||
* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the [color scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.
|
* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the [color scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.
|
||||||
* `enableDeprecatedPaste` boolean (optional) _Deprecated_ - Whether to enable the `paste` [execCommand](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand). Default is `false`.
|
* `enableDeprecatedPaste` boolean (optional) _Deprecated_ - Whether to enable the `paste` [execCommand](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand). Default is `false`.
|
||||||
* `enableCornerSmoothingCSS` boolean (optional) _Experimental_ - Whether the [`-electron-corner-smoothing` CSS rule](../corner-smoothing-css.md) is enabled. Default is `true`.
|
|
||||||
|
|
||||||
[chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment
|
[chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment
|
||||||
[runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5
|
[runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5
|
||||||
|
|
|
@ -16,64 +16,9 @@ making three primary changes to Blink:
|
||||||
* Modifies graphics to handle smooth `ContouredRect`s, delegating to
|
* Modifies graphics to handle smooth `ContouredRect`s, delegating to
|
||||||
`//electron/shell/renderer/electron_smooth_round_rect`.
|
`//electron/shell/renderer/electron_smooth_round_rect`.
|
||||||
|
|
||||||
3. Adds a renderer preference / web setting:
|
3. Adds a renderer feature:
|
||||||
* Controls whether the CSS rule is available.
|
* Controls whether the CSS rule is available.
|
||||||
* Mostly simple "plumbing" for the setting through blink.
|
|
||||||
|
|
||||||
diff --git a/third_party/blink/common/renderer_preferences/renderer_preferences_mojom_traits.cc b/third_party/blink/common/renderer_preferences/renderer_preferences_mojom_traits.cc
|
|
||||||
index c13dfd7f20e6f281f51ae373ceebeb86104c5cd9..fac89df9f23f3f098096d2a07a07e623b1067270 100644
|
|
||||||
--- a/third_party/blink/common/renderer_preferences/renderer_preferences_mojom_traits.cc
|
|
||||||
+++ b/third_party/blink/common/renderer_preferences/renderer_preferences_mojom_traits.cc
|
|
||||||
@@ -128,6 +128,8 @@ bool StructTraits<blink::mojom::RendererPreferencesDataView,
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ out->electron_corner_smoothing_css = data.electron_corner_smoothing_css();
|
|
||||||
+
|
|
||||||
out->canvas_noise_token = data.canvas_noise_token();
|
|
||||||
|
|
||||||
out->view_source_line_wrap_enabled = data.view_source_line_wrap_enabled();
|
|
||||||
diff --git a/third_party/blink/public/common/renderer_preferences/renderer_preferences.h b/third_party/blink/public/common/renderer_preferences/renderer_preferences.h
|
|
||||||
index 75acd696a5258e52f5c17b88559dfb3f6373c669..34b5ed725702dca72c383c1def08fdb835f7fa6b 100644
|
|
||||||
--- a/third_party/blink/public/common/renderer_preferences/renderer_preferences.h
|
|
||||||
+++ b/third_party/blink/public/common/renderer_preferences/renderer_preferences.h
|
|
||||||
@@ -91,6 +91,7 @@ struct BLINK_COMMON_EXPORT RendererPreferences {
|
|
||||||
bool caret_browsing_enabled{false};
|
|
||||||
bool uses_platform_autofill{false};
|
|
||||||
std::vector<uint16_t> explicitly_allowed_network_ports;
|
|
||||||
+ bool electron_corner_smoothing_css{true};
|
|
||||||
uint64_t canvas_noise_token{0};
|
|
||||||
// The default value must be false to avoid performance problems on very large
|
|
||||||
// source pages.
|
|
||||||
diff --git a/third_party/blink/public/common/renderer_preferences/renderer_preferences_mojom_traits.h b/third_party/blink/public/common/renderer_preferences/renderer_preferences_mojom_traits.h
|
|
||||||
index defe40d7091cb4ba4b099a22aeaee71f78ff5e77..e8326fa7a3c45c08c7d9250edd52a6d73fcc3ff9 100644
|
|
||||||
--- a/third_party/blink/public/common/renderer_preferences/renderer_preferences_mojom_traits.h
|
|
||||||
+++ b/third_party/blink/public/common/renderer_preferences/renderer_preferences_mojom_traits.h
|
|
||||||
@@ -275,6 +275,11 @@ struct BLINK_COMMON_EXPORT
|
|
||||||
return data.explicitly_allowed_network_ports;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ static const bool& electron_corner_smoothing_css(
|
|
||||||
+ const ::blink::RendererPreferences& data) {
|
|
||||||
+ return data.electron_corner_smoothing_css;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
static const uint64_t& canvas_noise_token(
|
|
||||||
const ::blink::RendererPreferences& data) {
|
|
||||||
return data.canvas_noise_token;
|
|
||||||
diff --git a/third_party/blink/public/mojom/renderer_preferences.mojom b/third_party/blink/public/mojom/renderer_preferences.mojom
|
|
||||||
index f8361faf6151210d65a597562c533aaa0a5235df..328238c34a9381fbbeb5970af3de721c8412104e 100644
|
|
||||||
--- a/third_party/blink/public/mojom/renderer_preferences.mojom
|
|
||||||
+++ b/third_party/blink/public/mojom/renderer_preferences.mojom
|
|
||||||
@@ -202,6 +202,8 @@ struct RendererPreferences {
|
|
||||||
|
|
||||||
array<uint16> explicitly_allowed_network_ports;
|
|
||||||
|
|
||||||
+ bool electron_corner_smoothing_css;
|
|
||||||
+
|
|
||||||
// A randomized 64 bit token that is generated per browser session,
|
|
||||||
// used for canvas noising.
|
|
||||||
uint64 canvas_noise_token = 0;
|
|
||||||
diff --git a/third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom b/third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom
|
diff --git a/third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom b/third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom
|
||||||
index e8c017c725f9d9b4f9099c824dfdb4c2cb9cbea6..73e135476bc4c930fd011745503e7f095ccfd8ec 100644
|
index e8c017c725f9d9b4f9099c824dfdb4c2cb9cbea6..73e135476bc4c930fd011745503e7f095ccfd8ec 100644
|
||||||
--- a/third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom
|
--- a/third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom
|
||||||
|
@ -86,18 +31,6 @@ index e8c017c725f9d9b4f9099c824dfdb4c2cb9cbea6..73e135476bc4c930fd011745503e7f09
|
||||||
|
|
||||||
// This CSSSampleId represents page load for CSS histograms. It is recorded once
|
// This CSSSampleId represents page load for CSS histograms. It is recorded once
|
||||||
// per page visit for each CSS histogram being logged on the blink side and the
|
// per page visit for each CSS histogram being logged on the blink side and the
|
||||||
diff --git a/third_party/blink/public/web/web_settings.h b/third_party/blink/public/web/web_settings.h
|
|
||||||
index 7fdc9866c9db5838ac8852ba156f2f04eb238bf5..56551d8190b3672d7c00c9bc722cf7e3aed255a6 100644
|
|
||||||
--- a/third_party/blink/public/web/web_settings.h
|
|
||||||
+++ b/third_party/blink/public/web/web_settings.h
|
|
||||||
@@ -285,6 +285,7 @@ class WebSettings {
|
|
||||||
virtual void SetRequireTransientActivationAndAuthorizationForSubAppsAPIs(
|
|
||||||
bool) = 0;
|
|
||||||
virtual void SetRootScrollbarThemeColor(std::optional<SkColor>) = 0;
|
|
||||||
+ virtual void SetCornerSmoothingCSS(bool) = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
~WebSettings() = default;
|
|
||||||
diff --git a/third_party/blink/renderer/build/scripts/core/css/css_properties.py b/third_party/blink/renderer/build/scripts/core/css/css_properties.py
|
diff --git a/third_party/blink/renderer/build/scripts/core/css/css_properties.py b/third_party/blink/renderer/build/scripts/core/css/css_properties.py
|
||||||
index e189d584f05f2ce6354c03a9b19f56985df8a15e..41b430e8f2416be098494f5c49fb97cae13447aa 100755
|
index e189d584f05f2ce6354c03a9b19f56985df8a15e..41b430e8f2416be098494f5c49fb97cae13447aa 100755
|
||||||
--- a/third_party/blink/renderer/build/scripts/core/css/css_properties.py
|
--- a/third_party/blink/renderer/build/scripts/core/css/css_properties.py
|
||||||
|
@ -112,16 +45,17 @@ index e189d584f05f2ce6354c03a9b19f56985df8a15e..41b430e8f2416be098494f5c49fb97ca
|
||||||
'internal-forced-visited-'):
|
'internal-forced-visited-'):
|
||||||
internal_visited_order = 0
|
internal_visited_order = 0
|
||||||
diff --git a/third_party/blink/renderer/core/css/css_properties.json5 b/third_party/blink/renderer/core/css/css_properties.json5
|
diff --git a/third_party/blink/renderer/core/css/css_properties.json5 b/third_party/blink/renderer/core/css/css_properties.json5
|
||||||
index 9ef592d0d86e4a6296db98b9c31f008f877dd348..45b5462631a762c90c756298f8f252bccf200389 100644
|
index 9ef592d0d86e4a6296db98b9c31f008f877dd348..b16bc9b41f6b3a596a0e52a516b7182c54c66b1e 100644
|
||||||
--- a/third_party/blink/renderer/core/css/css_properties.json5
|
--- a/third_party/blink/renderer/core/css/css_properties.json5
|
||||||
+++ b/third_party/blink/renderer/core/css/css_properties.json5
|
+++ b/third_party/blink/renderer/core/css/css_properties.json5
|
||||||
@@ -9002,6 +9002,24 @@
|
@@ -9002,6 +9002,26 @@
|
||||||
property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"],
|
property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"],
|
||||||
},
|
},
|
||||||
|
|
||||||
+ {
|
+ {
|
||||||
+ name: "-electron-corner-smoothing",
|
+ name: "-electron-corner-smoothing",
|
||||||
+ property_methods: ["ParseSingleValue"],
|
+ property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"],
|
||||||
|
+ interpolable: true,
|
||||||
+ field_group: "*",
|
+ field_group: "*",
|
||||||
+ field_template: "external",
|
+ field_template: "external",
|
||||||
+ // To keep this patch small, Length is used instead of a more descriptive
|
+ // To keep this patch small, Length is used instead of a more descriptive
|
||||||
|
@ -129,12 +63,13 @@ index 9ef592d0d86e4a6296db98b9c31f008f877dd348..45b5462631a762c90c756298f8f252bc
|
||||||
+ // - `system-ui` = `Length::Auto()`
|
+ // - `system-ui` = `Length::Auto()`
|
||||||
+ // - percent = `Length::Percent`
|
+ // - percent = `Length::Percent`
|
||||||
+ type_name: "Length",
|
+ type_name: "Length",
|
||||||
+ converter: "ConvertCornerSmoothing",
|
|
||||||
+ keywords: ["system-ui"],
|
|
||||||
+ default_value: "Length::None()",
|
+ default_value: "Length::None()",
|
||||||
+ typedom_types: ["Keyword", "Percentage"],
|
+ keywords: ["system-ui"],
|
||||||
+ is_border_radius: true,
|
+ converter: "ConvertCornerSmoothing",
|
||||||
+ invalidate: ["paint", "border-radius", "clip"],
|
+ runtime_flag: "ElectronCSSCornerSmoothing",
|
||||||
|
+ valid_for_permission_element: true,
|
||||||
|
+ valid_for_page_context: true,
|
||||||
|
+ invalidate: ["border-radius", "paint", "corner-shape"],
|
||||||
+ },
|
+ },
|
||||||
+
|
+
|
||||||
// Visited properties.
|
// Visited properties.
|
||||||
|
@ -154,10 +89,10 @@ index 4f13354776da9944ed75874953a2e2c9878a649b..83728e697c5029a79fb75d84a1be5bdf
|
||||||
return a.EmptyCells() == b.EmptyCells();
|
return a.EmptyCells() == b.EmptyCells();
|
||||||
case CSSPropertyID::kFill:
|
case CSSPropertyID::kFill:
|
||||||
diff --git a/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc b/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
|
diff --git a/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc b/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
|
||||||
index dc328e04767437d2d9b6d67d07cb6c9d055773f9..01dde66dbbff0c1bf1e1a52486f1901328b4217b 100644
|
index dc328e04767437d2d9b6d67d07cb6c9d055773f9..19edb190c57b75e29e71d6342e3a648ef4611fdf 100644
|
||||||
--- a/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
|
--- a/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
|
||||||
+++ b/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
|
+++ b/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
|
||||||
@@ -12325,5 +12325,25 @@ const CSSValue* InternalEmptyLineHeight::ParseSingleValue(
|
@@ -12325,5 +12325,36 @@ const CSSValue* InternalEmptyLineHeight::ParseSingleValue(
|
||||||
CSSValueID::kNone>(stream);
|
CSSValueID::kNone>(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,12 +100,6 @@ index dc328e04767437d2d9b6d67d07cb6c9d055773f9..01dde66dbbff0c1bf1e1a52486f19013
|
||||||
+ CSSParserTokenStream& stream,
|
+ CSSParserTokenStream& stream,
|
||||||
+ const CSSParserContext& context,
|
+ const CSSParserContext& context,
|
||||||
+ const CSSParserLocalContext&) const {
|
+ const CSSParserLocalContext&) const {
|
||||||
+ // Fail parsing if this rule is disabled by document settings.
|
|
||||||
+ if (Settings* settings = context.GetDocument()->GetSettings();
|
|
||||||
+ settings && !settings->GetElectronCornerSmoothingCSS()) {
|
|
||||||
+ return nullptr;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // Try to parse `system-ui` keyword first.
|
+ // Try to parse `system-ui` keyword first.
|
||||||
+ if (auto* ident =
|
+ if (auto* ident =
|
||||||
+ css_parsing_utils::ConsumeIdent<CSSValueID::kSystemUi>(stream)) {
|
+ css_parsing_utils::ConsumeIdent<CSSValueID::kSystemUi>(stream)) {
|
||||||
|
@ -180,6 +109,23 @@ index dc328e04767437d2d9b6d67d07cb6c9d055773f9..01dde66dbbff0c1bf1e1a52486f19013
|
||||||
+ return css_parsing_utils::ConsumePercent(
|
+ return css_parsing_utils::ConsumePercent(
|
||||||
+ stream, context, CSSPrimitiveValue::ValueRange::kNonNegative);
|
+ stream, context, CSSPrimitiveValue::ValueRange::kNonNegative);
|
||||||
+}
|
+}
|
||||||
|
+
|
||||||
|
+const CSSValue* ElectronCornerSmoothing::CSSValueFromComputedStyleInternal(
|
||||||
|
+ const ComputedStyle& style,
|
||||||
|
+ const LayoutObject*,
|
||||||
|
+ bool allow_visited_style,
|
||||||
|
+ CSSValuePhase value_phase) const {
|
||||||
|
+ const Length& length = style.ElectronCornerSmoothing();
|
||||||
|
+ switch (length.GetType()) {
|
||||||
|
+ case Length::kAuto:
|
||||||
|
+ return CSSIdentifierValue::Create(CSSValueID::kSystemUi);
|
||||||
|
+ case Length::kPercent:
|
||||||
|
+ return CSSNumericLiteralValue::Create(
|
||||||
|
+ length.Percent(), CSSPrimitiveValue::UnitType::kPercentage);
|
||||||
|
+ default:
|
||||||
|
+ return CSSIdentifierValue::Create(CSSValueID::kNone);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
+
|
+
|
||||||
} // namespace css_longhand
|
} // namespace css_longhand
|
||||||
} // namespace blink
|
} // namespace blink
|
||||||
|
@ -215,60 +161,6 @@ index d1430dc2dc30a1962731492c3f53849c7ff8a4db..417ac19f5968b7300ec2f0422728cd85
|
||||||
static FitText ConvertFitText(StyleResolverState&, const CSSValue&);
|
static FitText ConvertFitText(StyleResolverState&, const CSSValue&);
|
||||||
|
|
||||||
static ScopedCSSNameList* ConvertTimelineTriggerName(StyleResolverState&,
|
static ScopedCSSNameList* ConvertTimelineTriggerName(StyleResolverState&,
|
||||||
diff --git a/third_party/blink/renderer/core/exported/web_settings_impl.cc b/third_party/blink/renderer/core/exported/web_settings_impl.cc
|
|
||||||
index 5a291913e020a785d0e9a1d07dd3bc88d223cc62..f01b25c7af9111596c53dadc5c08c4f1c031fc86 100644
|
|
||||||
--- a/third_party/blink/renderer/core/exported/web_settings_impl.cc
|
|
||||||
+++ b/third_party/blink/renderer/core/exported/web_settings_impl.cc
|
|
||||||
@@ -817,4 +817,8 @@ void WebSettingsImpl::SetRootScrollbarThemeColor(
|
|
||||||
settings_->SetRootScrollbarThemeColor(theme_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
+void WebSettingsImpl::SetCornerSmoothingCSS(bool available) {
|
|
||||||
+ settings_->SetElectronCornerSmoothingCSS(available);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
} // namespace blink
|
|
||||||
diff --git a/third_party/blink/renderer/core/exported/web_settings_impl.h b/third_party/blink/renderer/core/exported/web_settings_impl.h
|
|
||||||
index a9fa6e94716bd5e53bc550d0a8d5e200bf0242af..b8d9d99edc8310eda762c83a6a95a43246792b20 100644
|
|
||||||
--- a/third_party/blink/renderer/core/exported/web_settings_impl.h
|
|
||||||
+++ b/third_party/blink/renderer/core/exported/web_settings_impl.h
|
|
||||||
@@ -237,6 +237,7 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings {
|
|
||||||
void SetRequireTransientActivationAndAuthorizationForSubAppsAPIs(
|
|
||||||
bool) override;
|
|
||||||
void SetRootScrollbarThemeColor(std::optional<SkColor>) override;
|
|
||||||
+ void SetCornerSmoothingCSS(bool) override;
|
|
||||||
|
|
||||||
bool RenderVSyncNotificationEnabled() const {
|
|
||||||
return render_v_sync_notification_enabled_;
|
|
||||||
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
|
||||||
index bb9745b97e411c03c4757f7a96e240df93b28559..015dae15ada4ff373d0077c4078ffacf1ba9dc63 100644
|
|
||||||
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
|
|
||||||
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
|
||||||
@@ -3594,6 +3594,9 @@ void WebViewImpl::UpdateRendererPreferences(
|
|
||||||
renderer_preferences_.view_source_line_wrap_enabled);
|
|
||||||
|
|
||||||
MaybePreloadSystemFonts(GetPage());
|
|
||||||
+
|
|
||||||
+ GetSettings()->SetCornerSmoothingCSS(
|
|
||||||
+ renderer_preferences_.electron_corner_smoothing_css);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebViewImpl::SetHistoryIndexAndLength(int32_t history_index,
|
|
||||||
diff --git a/third_party/blink/renderer/core/frame/settings.json5 b/third_party/blink/renderer/core/frame/settings.json5
|
|
||||||
index 9f68384d71136da79de5fbf7e3feac2a13b7dbec..2bd6f597974c9bdf05b743c8c00182432c8e8dba 100644
|
|
||||||
--- a/third_party/blink/renderer/core/frame/settings.json5
|
|
||||||
+++ b/third_party/blink/renderer/core/frame/settings.json5
|
|
||||||
@@ -1261,5 +1261,10 @@
|
|
||||||
initial: false,
|
|
||||||
type: "bool"
|
|
||||||
},
|
|
||||||
+ {
|
|
||||||
+ name: "electronCornerSmoothingCSS",
|
|
||||||
+ initial: true,
|
|
||||||
+ invalidate: ["Style"],
|
|
||||||
+ },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
diff --git a/third_party/blink/renderer/core/paint/contoured_border_geometry.cc b/third_party/blink/renderer/core/paint/contoured_border_geometry.cc
|
diff --git a/third_party/blink/renderer/core/paint/contoured_border_geometry.cc b/third_party/blink/renderer/core/paint/contoured_border_geometry.cc
|
||||||
index ec80337fdac36fa1636f5142c3827d3bbc81644c..634db12dfb443acabde79e9faf59cb8415991464 100644
|
index ec80337fdac36fa1636f5142c3827d3bbc81644c..634db12dfb443acabde79e9faf59cb8415991464 100644
|
||||||
--- a/third_party/blink/renderer/core/paint/contoured_border_geometry.cc
|
--- a/third_party/blink/renderer/core/paint/contoured_border_geometry.cc
|
||||||
|
@ -375,7 +267,7 @@ index 59031b23d3c50aa87db48a5c5a66c5ab04a8103a..1f83cf0dff83d748bf1caafd3685202c
|
||||||
|
|
||||||
// A Corner is a axis-aligned quad, with the points ordered (start, outer,
|
// A Corner is a axis-aligned quad, with the points ordered (start, outer,
|
||||||
diff --git a/third_party/blink/renderer/platform/geometry/path_builder.cc b/third_party/blink/renderer/platform/geometry/path_builder.cc
|
diff --git a/third_party/blink/renderer/platform/geometry/path_builder.cc b/third_party/blink/renderer/platform/geometry/path_builder.cc
|
||||||
index 4a77f944e9ad0b18f10f1a572673769453473fb9..ace138137f002d0866e5cc71b44bf5b4ac85bac1 100644
|
index 4a77f944e9ad0b18f10f1a572673769453473fb9..73a3fac1be9a8c29d1b3391bf05eef13df9415d9 100644
|
||||||
--- a/third_party/blink/renderer/platform/geometry/path_builder.cc
|
--- a/third_party/blink/renderer/platform/geometry/path_builder.cc
|
||||||
+++ b/third_party/blink/renderer/platform/geometry/path_builder.cc
|
+++ b/third_party/blink/renderer/platform/geometry/path_builder.cc
|
||||||
@@ -4,6 +4,7 @@
|
@@ -4,6 +4,7 @@
|
||||||
|
@ -386,7 +278,7 @@ index 4a77f944e9ad0b18f10f1a572673769453473fb9..ace138137f002d0866e5cc71b44bf5b4
|
||||||
#include "third_party/blink/renderer/platform/geometry/contoured_rect.h"
|
#include "third_party/blink/renderer/platform/geometry/contoured_rect.h"
|
||||||
#include "third_party/blink/renderer/platform/geometry/infinite_int_rect.h"
|
#include "third_party/blink/renderer/platform/geometry/infinite_int_rect.h"
|
||||||
#include "third_party/blink/renderer/platform/geometry/path.h"
|
#include "third_party/blink/renderer/platform/geometry/path.h"
|
||||||
@@ -248,6 +249,26 @@ PathBuilder& PathBuilder::AddContouredRect(
|
@@ -248,6 +249,32 @@ PathBuilder& PathBuilder::AddContouredRect(
|
||||||
AddRoundedRect(target_rect);
|
AddRoundedRect(target_rect);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -402,10 +294,16 @@ index 4a77f944e9ad0b18f10f1a572673769453473fb9..ace138137f002d0866e5cc71b44bf5b4
|
||||||
+ float smoothness = std::clamp(
|
+ float smoothness = std::clamp(
|
||||||
+ contoured_rect.GetCornerCurvature().Smoothness(), 0.0f, 1.0f);
|
+ contoured_rect.GetCornerCurvature().Smoothness(), 0.0f, 1.0f);
|
||||||
+
|
+
|
||||||
|
+ // Since the Electron implementation of DrawSmoothRoundRect uses one radius
|
||||||
|
+ // for both dimensions, we need to use the minimum of the two supplied.
|
||||||
|
+ auto min_radius = [](const gfx::SizeF& radius) -> float {
|
||||||
|
+ return std::min(radius.width(), radius.height());
|
||||||
|
+ };
|
||||||
|
+
|
||||||
+ builder_.addPath(electron::DrawSmoothRoundRect(
|
+ builder_.addPath(electron::DrawSmoothRoundRect(
|
||||||
+ box.x(), box.y(), box.width(), box.height(), smoothness,
|
+ box.x(), box.y(), box.width(), box.height(), smoothness,
|
||||||
+ radii.TopLeft().width(), radii.TopRight().width(),
|
+ min_radius(radii.TopLeft()), min_radius(radii.TopRight()),
|
||||||
+ radii.BottomRight().width(), radii.BottomLeft().width()));
|
+ min_radius(radii.BottomRight()), min_radius(radii.BottomLeft())));
|
||||||
+
|
+
|
||||||
+ return *this;
|
+ return *this;
|
||||||
+ }
|
+ }
|
||||||
|
@ -413,3 +311,18 @@ index 4a77f944e9ad0b18f10f1a572673769453473fb9..ace138137f002d0866e5cc71b44bf5b4
|
||||||
const FloatRoundedRect& origin_rect = contoured_rect.GetOriginRect();
|
const FloatRoundedRect& origin_rect = contoured_rect.GetOriginRect();
|
||||||
|
|
||||||
auto DrawAsSinglePath = [&]() {
|
auto DrawAsSinglePath = [&]() {
|
||||||
|
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5
|
||||||
|
index 382c9749aaaf2827b76c0a63df96e45a7c88b62b..88c2310c5cccfab7e5a3cdad54657bae185655dd 100644
|
||||||
|
--- a/third_party/blink/renderer/platform/runtime_enabled_features.json5
|
||||||
|
+++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
|
||||||
|
@@ -214,6 +214,10 @@
|
||||||
|
},
|
||||||
|
|
||||||
|
data: [
|
||||||
|
+ {
|
||||||
|
+ name: "ElectronCSSCornerSmoothing",
|
||||||
|
+ status: "stable",
|
||||||
|
+ },
|
||||||
|
{
|
||||||
|
name: "Accelerated2dCanvas",
|
||||||
|
settable_from_internals: true,
|
||||||
|
|
|
@ -149,7 +149,6 @@ void WebContentsPreferences::Clear() {
|
||||||
preload_path_ = std::nullopt;
|
preload_path_ = std::nullopt;
|
||||||
v8_cache_options_ = blink::mojom::V8CacheOptions::kDefault;
|
v8_cache_options_ = blink::mojom::V8CacheOptions::kDefault;
|
||||||
deprecated_paste_enabled_ = false;
|
deprecated_paste_enabled_ = false;
|
||||||
corner_smoothing_css_ = true;
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_MAC)
|
#if BUILDFLAG(IS_MAC)
|
||||||
scroll_bounce_ = false;
|
scroll_bounce_ = false;
|
||||||
|
@ -229,8 +228,6 @@ void WebContentsPreferences::SetFromDictionary(
|
||||||
if (web_preferences.Get(options::kDisableBlinkFeatures,
|
if (web_preferences.Get(options::kDisableBlinkFeatures,
|
||||||
&disable_blink_features))
|
&disable_blink_features))
|
||||||
disable_blink_features_ = disable_blink_features;
|
disable_blink_features_ = disable_blink_features;
|
||||||
web_preferences.Get(options::kEnableCornerSmoothingCSS,
|
|
||||||
&corner_smoothing_css_);
|
|
||||||
|
|
||||||
base::FilePath::StringType preload_path;
|
base::FilePath::StringType preload_path;
|
||||||
if (web_preferences.Get(options::kPreloadScript, &preload_path)) {
|
if (web_preferences.Get(options::kPreloadScript, &preload_path)) {
|
||||||
|
@ -481,8 +478,6 @@ void WebContentsPreferences::OverrideWebkitPrefs(
|
||||||
prefs->v8_cache_options = v8_cache_options_;
|
prefs->v8_cache_options = v8_cache_options_;
|
||||||
|
|
||||||
prefs->dom_paste_enabled = deprecated_paste_enabled_;
|
prefs->dom_paste_enabled = deprecated_paste_enabled_;
|
||||||
|
|
||||||
renderer_prefs->electron_corner_smoothing_css = corner_smoothing_css_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsPreferences);
|
WEB_CONTENTS_USER_DATA_KEY_IMPL(WebContentsPreferences);
|
||||||
|
|
|
@ -134,7 +134,6 @@ class WebContentsPreferences
|
||||||
std::optional<base::FilePath> preload_path_;
|
std::optional<base::FilePath> preload_path_;
|
||||||
blink::mojom::V8CacheOptions v8_cache_options_;
|
blink::mojom::V8CacheOptions v8_cache_options_;
|
||||||
bool deprecated_paste_enabled_ = false;
|
bool deprecated_paste_enabled_ = false;
|
||||||
bool corner_smoothing_css_;
|
|
||||||
|
|
||||||
#if BUILDFLAG(IS_MAC)
|
#if BUILDFLAG(IS_MAC)
|
||||||
bool scroll_bounce_;
|
bool scroll_bounce_;
|
||||||
|
|
|
@ -219,9 +219,6 @@ inline constexpr std::string_view kSpellcheck = "spellcheck";
|
||||||
inline constexpr std::string_view kEnableDeprecatedPaste =
|
inline constexpr std::string_view kEnableDeprecatedPaste =
|
||||||
"enableDeprecatedPaste";
|
"enableDeprecatedPaste";
|
||||||
|
|
||||||
// Whether the -electron-corner-smoothing CSS rule is enabled.
|
|
||||||
inline constexpr std::string_view kEnableCornerSmoothingCSS =
|
|
||||||
"enableCornerSmoothingCSS";
|
|
||||||
} // namespace options
|
} // namespace options
|
||||||
|
|
||||||
// Following are actually command line switches, should be moved to other files.
|
// Following are actually command line switches, should be moved to other files.
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <numbers>
|
#include <numbers>
|
||||||
#include "base/check.h"
|
#include "base/check.h"
|
||||||
|
#include "base/check_op.h"
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
|
@ -263,13 +264,14 @@ SkPath DrawSmoothRoundRect(float x,
|
||||||
float top_right_radius,
|
float top_right_radius,
|
||||||
float bottom_right_radius,
|
float bottom_right_radius,
|
||||||
float bottom_left_radius) {
|
float bottom_left_radius) {
|
||||||
DCHECK(0.0f <= smoothness && smoothness <= 1.0f);
|
DCHECK_GE(smoothness, 0.0f);
|
||||||
|
DCHECK_LE(smoothness, 1.0f);
|
||||||
|
|
||||||
// Assume the radii are already constrained within the rectangle size
|
// Assume the radii are already constrained within the rectangle size
|
||||||
DCHECK(top_left_radius + top_right_radius <= width);
|
DCHECK_LE(top_left_radius + top_right_radius, width);
|
||||||
DCHECK(bottom_left_radius + bottom_right_radius <= width);
|
DCHECK_LE(bottom_left_radius + bottom_right_radius, width);
|
||||||
DCHECK(top_left_radius + bottom_left_radius <= height);
|
DCHECK_LE(top_left_radius + bottom_left_radius, height);
|
||||||
DCHECK(top_right_radius + bottom_right_radius <= height);
|
DCHECK_LE(top_right_radius + bottom_right_radius, height);
|
||||||
|
|
||||||
if (width <= 0.0f || height <= 0.0f) {
|
if (width <= 0.0f || height <= 0.0f) {
|
||||||
return SkPath();
|
return SkPath();
|
||||||
|
|
|
@ -85,7 +85,7 @@ async function pageCaptureTestRecipe (
|
||||||
height: 600,
|
height: 600,
|
||||||
useContentSize: true,
|
useContentSize: true,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
enableCornerSmoothingCSS: cornerSmoothingAvailable
|
disableBlinkFeatures: cornerSmoothingAvailable ? undefined : 'ElectronCSSCornerSmoothing'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await w.loadFile(pagePath);
|
await w.loadFile(pagePath);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue