fix: Revert "feat: Corner Smoothing CSS rule" (#46231)
Revert "feat: Corner Smoothing CSS rule (#45185)"
This reverts commit b75e802280
.
This commit is contained in:
parent
cfd64b5f89
commit
abaef13c0b
26 changed files with 1 additions and 1313 deletions
|
@ -134,7 +134,6 @@ fix_software_compositing_infinite_loop.patch
|
|||
fix_add_method_which_disables_headless_mode_on_native_widget.patch
|
||||
refactor_unfilter_unresponsive_events.patch
|
||||
build_disable_thin_lto_mac.patch
|
||||
feat_corner_smoothing_css_rule_and_blink_painting.patch
|
||||
build_add_public_config_simdutf_config.patch
|
||||
revert_code_health_clean_up_stale_macwebcontentsocclusion.patch
|
||||
ignore_parse_errors_for_pkey_appusermodel_toastactivatorclsid.patch
|
||||
|
|
|
@ -1,522 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Calvin Watford <watfordcalvin@gmail.com>
|
||||
Date: Mon, 9 Dec 2024 16:58:15 -0700
|
||||
Subject: feat: Corner Smoothing CSS rule and Blink painting
|
||||
|
||||
This patch implements the `-electron-corner-smoothing` CSS rule by
|
||||
making three primary changes to Blink:
|
||||
|
||||
1. Adds the `-electron-corner-smoothing` CSS rule:
|
||||
* Metadata in `blink/renderer/core/css/css_properties.json5`
|
||||
* Parsing in `blink/renderer/core/css/properties/longhands/longhands_custom.cc`
|
||||
* Other required definitions for all CSS rules (`css_property_id.mojom`, `css_property_equality.cc`)
|
||||
|
||||
2. Modifies how Blink paints rounded rectangles:
|
||||
* Augments `blink::FloatRoundedRect` to store smoothness & hook into
|
||||
drawing smooth corners.
|
||||
* Modifies all call sites of `blink::FloatRoundedRect::operator SkRRect`
|
||||
to identify and use smooth rounded corners.
|
||||
|
||||
3. Adds a renderer preference / web setting:
|
||||
* Controls whether the CSS rule is available.
|
||||
|
||||
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 25cf6b544dcee15a9616b6963eaae0264aba3db6..13d5b30d00ce8dca96eb3bc5454f9d353375d4c6 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();
|
||||
+
|
||||
return true;
|
||||
}
|
||||
|
||||
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 cae096396b0635f1c4bba6ac8fee47fd957dc698..03db6cddab5cd1b9f3f7c90390bc53baa9e14b65 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;
|
||||
|
||||
RendererPreferences();
|
||||
RendererPreferences(const RendererPreferences& other);
|
||||
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 33b4bd3f0c9488f1013aea026c7fe559ba750cd8..6b4157199c14a4c276e65512e89f2429253aec5c 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 bool Read(blink::mojom::RendererPreferencesDataView,
|
||||
::blink::RendererPreferences* out);
|
||||
};
|
||||
diff --git a/third_party/blink/public/mojom/renderer_preferences.mojom b/third_party/blink/public/mojom/renderer_preferences.mojom
|
||||
index bbcec1dcdaaaf932b3d82c64e8aeb2e7c04b05bf..689205607a763c1d6e040069b1357d84e8ba4bd5 100644
|
||||
--- a/third_party/blink/public/mojom/renderer_preferences.mojom
|
||||
+++ b/third_party/blink/public/mojom/renderer_preferences.mojom
|
||||
@@ -201,4 +201,6 @@ struct RendererPreferences {
|
||||
bool uses_platform_autofill = false;
|
||||
|
||||
array<uint16> explicitly_allowed_network_ports;
|
||||
+
|
||||
+ bool electron_corner_smoothing_css;
|
||||
};
|
||||
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 ff34492a1b3e0d57847a35f5921337debdf14d10..02e77d7f080de9311f8ac70e3e935dbd38cb285f 100644
|
||||
--- 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
|
||||
@@ -48,6 +48,7 @@ enum CSSSampleId {
|
||||
kInternalForcedVisitedColor = 0,
|
||||
kInternalOverflowBlock = 0,
|
||||
kInternalOverflowInline = 0,
|
||||
+ kElectronCornerSmoothing = 0,
|
||||
|
||||
// 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
|
||||
diff --git a/third_party/blink/public/web/web_settings.h b/third_party/blink/public/web/web_settings.h
|
||||
index 0255879e4ae048554041ca03891fbc7ba8484187..8248d8f54eb5d35caa39a306a6477ace6597b03a 100644
|
||||
--- a/third_party/blink/public/web/web_settings.h
|
||||
+++ b/third_party/blink/public/web/web_settings.h
|
||||
@@ -284,6 +284,7 @@ class WebSettings {
|
||||
virtual void SetModalContextMenu(bool) = 0;
|
||||
virtual void SetRequireTransientActivationAndAuthorizationForSubAppsAPIs(
|
||||
bool) = 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
|
||||
index 753ba8990f722bafd1770a5e70307cff3764d3f1..16cec517d72887c089f85867e8e37c03199ab394 100755
|
||||
--- a/third_party/blink/renderer/build/scripts/core/css/css_properties.py
|
||||
+++ b/third_party/blink/renderer/build/scripts/core/css/css_properties.py
|
||||
@@ -311,7 +311,13 @@ class CSSProperties(object):
|
||||
name_without_leading_dash = property_.name.original
|
||||
if name_without_leading_dash.startswith('-'):
|
||||
name_without_leading_dash = name_without_leading_dash[1:]
|
||||
+ # Extra sort level to avoid -internal-* properties being assigned
|
||||
+ # values too large to fit in a byte.
|
||||
+ internal_weight = 0
|
||||
+ if property_.name.original.startswith('-internal'):
|
||||
+ internal_weight = -1
|
||||
property_.sorting_key = (-property_.priority,
|
||||
+ internal_weight,
|
||||
name_without_leading_dash)
|
||||
|
||||
sorting_keys = {}
|
||||
diff --git a/third_party/blink/renderer/core/css/css_properties.json5 b/third_party/blink/renderer/core/css/css_properties.json5
|
||||
index 561cf75a5fc16e94485296e4607df70037e53525..23ece6535cab358fdc8f9dfc1481c1a020475daf 100644
|
||||
--- a/third_party/blink/renderer/core/css/css_properties.json5
|
||||
+++ b/third_party/blink/renderer/core/css/css_properties.json5
|
||||
@@ -8732,6 +8732,24 @@
|
||||
property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"],
|
||||
},
|
||||
|
||||
+ {
|
||||
+ name: "-electron-corner-smoothing",
|
||||
+ property_methods: ["ParseSingleValue"],
|
||||
+ field_group: "*",
|
||||
+ field_template: "external",
|
||||
+ // To keep this patch small, Length is used instead of a more descriptive
|
||||
+ // custom type.
|
||||
+ // - `system-ui` = `Length::Auto()`
|
||||
+ // - percent = `Length::Percent`
|
||||
+ type_name: "Length",
|
||||
+ converter: "ConvertCornerSmoothing",
|
||||
+ keywords: ["system-ui"],
|
||||
+ default_value: "Length::None()",
|
||||
+ typedom_types: ["Keyword", "Percentage"],
|
||||
+ is_border_radius: true,
|
||||
+ invalidate: ["paint", "border-radius", "clip"],
|
||||
+ },
|
||||
+
|
||||
// Visited properties.
|
||||
{
|
||||
name: "-internal-visited-color",
|
||||
diff --git a/third_party/blink/renderer/core/css/css_property_equality.cc b/third_party/blink/renderer/core/css/css_property_equality.cc
|
||||
index d0c6c6b54dd773c6d3f8b9767b126689198df4ee..2348a1d8ebb1d734ee8cea32b9d67adf3f5fb605 100644
|
||||
--- a/third_party/blink/renderer/core/css/css_property_equality.cc
|
||||
+++ b/third_party/blink/renderer/core/css/css_property_equality.cc
|
||||
@@ -346,6 +346,8 @@ bool CSSPropertyEquality::PropertiesEqual(const PropertyHandle& property,
|
||||
return a.DominantBaseline() == b.DominantBaseline();
|
||||
case CSSPropertyID::kDynamicRangeLimit:
|
||||
return a.GetDynamicRangeLimit() == b.GetDynamicRangeLimit();
|
||||
+ case CSSPropertyID::kElectronCornerSmoothing:
|
||||
+ return a.ElectronCornerSmoothing() == b.ElectronCornerSmoothing();
|
||||
case CSSPropertyID::kEmptyCells:
|
||||
return a.EmptyCells() == b.EmptyCells();
|
||||
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
|
||||
index b1b513c8d89055f3e77d406f0d889243b5e7ad7f..2b0a37f496fad6b7b56896cc1811f624e89e9aad 100644
|
||||
--- a/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
|
||||
+++ b/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
|
||||
@@ -11826,5 +11826,25 @@ const CSSValue* InternalEmptyLineHeight::ParseSingleValue(
|
||||
CSSValueID::kNone>(stream);
|
||||
}
|
||||
|
||||
+const CSSValue* ElectronCornerSmoothing::ParseSingleValue(
|
||||
+ CSSParserTokenStream& stream,
|
||||
+ const CSSParserContext& context,
|
||||
+ 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.
|
||||
+ if (auto* ident =
|
||||
+ css_parsing_utils::ConsumeIdent<CSSValueID::kSystemUi>(stream)) {
|
||||
+ return ident;
|
||||
+ }
|
||||
+ // Try to parse as percent.
|
||||
+ return css_parsing_utils::ConsumePercent(
|
||||
+ stream, context, CSSPrimitiveValue::ValueRange::kNonNegative);
|
||||
+}
|
||||
+
|
||||
} // namespace css_longhand
|
||||
} // namespace blink
|
||||
diff --git a/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc b/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
|
||||
index 26222ba06232da5d98b35173a7ab0e55a3e6d076..92cdc2aed6a68581187ae654358cc7f2b2409cb3 100644
|
||||
--- a/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
|
||||
+++ b/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
|
||||
@@ -3875,4 +3875,12 @@ PositionArea StyleBuilderConverter::ConvertPositionArea(
|
||||
return PositionArea(span[0], span[1], span[2], span[3]);
|
||||
}
|
||||
|
||||
+Length StyleBuilderConverter::ConvertCornerSmoothing(StyleResolverState& state, const CSSValue& value) {
|
||||
+ auto* ident = DynamicTo<CSSIdentifierValue>(value);
|
||||
+ if (ident && ident->GetValueID() == CSSValueID::kSystemUi) {
|
||||
+ return Length::Auto();
|
||||
+ }
|
||||
+ return ConvertLength(state, value);
|
||||
+}
|
||||
+
|
||||
} // namespace blink
|
||||
diff --git a/third_party/blink/renderer/core/css/resolver/style_builder_converter.h b/third_party/blink/renderer/core/css/resolver/style_builder_converter.h
|
||||
index c0f4544a38dc486708dec5a4b3646fb3f15ff2e0..8b3d4e95fb690f9e7b38265be0a77d6e49271944 100644
|
||||
--- a/third_party/blink/renderer/core/css/resolver/style_builder_converter.h
|
||||
+++ b/third_party/blink/renderer/core/css/resolver/style_builder_converter.h
|
||||
@@ -421,6 +421,8 @@ class StyleBuilderConverter {
|
||||
const CSSValue&);
|
||||
|
||||
static PositionArea ConvertPositionArea(StyleResolverState&, const CSSValue&);
|
||||
+
|
||||
+ static Length ConvertCornerSmoothing(StyleResolverState&, const CSSValue&);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
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 673bafce059a21da812155ef1c6c5577fe211a91..40dfafd5828cac131bb1b4bbc0c8d64f2d09d4f2 100644
|
||||
--- a/third_party/blink/renderer/core/exported/web_settings_impl.cc
|
||||
+++ b/third_party/blink/renderer/core/exported/web_settings_impl.cc
|
||||
@@ -809,4 +809,8 @@ void WebSettingsImpl::
|
||||
is_required);
|
||||
}
|
||||
|
||||
+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 ea27e0cfabfec4cba6d39b4dbfbaca59cae84f8e..48abf7909b9e6b095d431739094bf8145282a01c 100644
|
||||
--- a/third_party/blink/renderer/core/exported/web_settings_impl.h
|
||||
+++ b/third_party/blink/renderer/core/exported/web_settings_impl.h
|
||||
@@ -236,6 +236,7 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings {
|
||||
void SetModalContextMenu(bool) override;
|
||||
void SetRequireTransientActivationAndAuthorizationForSubAppsAPIs(
|
||||
bool) 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 64f243d595920a87e7115ca8047822a7368752df..1a1b92ae3dd892413c76d3d61a41d33736c04d9f 100644
|
||||
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
@@ -3579,6 +3579,9 @@ void WebViewImpl::UpdateRendererPreferences(
|
||||
#endif
|
||||
|
||||
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 6566580ef5e20ac5a66507e6ef625db9258ca906..b36ed88cf2f8c3e1554803caf9fd31c8ac70f733 100644
|
||||
--- a/third_party/blink/renderer/core/frame/settings.json5
|
||||
+++ b/third_party/blink/renderer/core/frame/settings.json5
|
||||
@@ -1252,5 +1252,10 @@
|
||||
initial: false,
|
||||
type: "bool"
|
||||
},
|
||||
+ {
|
||||
+ name: "electronCornerSmoothingCSS",
|
||||
+ initial: true,
|
||||
+ invalidate: ["Style"],
|
||||
+ },
|
||||
],
|
||||
}
|
||||
diff --git a/third_party/blink/renderer/core/paint/box_border_painter.cc b/third_party/blink/renderer/core/paint/box_border_painter.cc
|
||||
index 7996ba931a2482e9941ce4642b2c017c294fe89d..abc87db736b47b1bbaa8b9717b0520a747b1725f 100644
|
||||
--- a/third_party/blink/renderer/core/paint/box_border_painter.cc
|
||||
+++ b/third_party/blink/renderer/core/paint/box_border_painter.cc
|
||||
@@ -246,7 +246,7 @@ FloatRoundedRect CalculateAdjustedInnerBorder(
|
||||
break;
|
||||
}
|
||||
|
||||
- return FloatRoundedRect(new_rect, new_radii);
|
||||
+ return FloatRoundedRect(new_rect, new_radii, inner_border.GetSmoothness());
|
||||
}
|
||||
|
||||
void DrawSolidBorderRect(GraphicsContext& context,
|
||||
diff --git a/third_party/blink/renderer/core/paint/box_painter_base.cc b/third_party/blink/renderer/core/paint/box_painter_base.cc
|
||||
index 5c3e86f6476c58e771b16b485c4f5c0081af3f7b..6e49fcce3c7b6a9664a4a1bd63200fdb85d05980 100644
|
||||
--- a/third_party/blink/renderer/core/paint/box_painter_base.cc
|
||||
+++ b/third_party/blink/renderer/core/paint/box_painter_base.cc
|
||||
@@ -319,7 +319,8 @@ void BoxPainterBase::PaintNormalBoxShadow(const PaintInfo& info,
|
||||
context.SetDrawLooper(draw_looper_builder.DetachDrawLooper());
|
||||
|
||||
if (has_border_radius) {
|
||||
- FloatRoundedRect rounded_fill_rect(fill_rect, border.GetRadii());
|
||||
+ FloatRoundedRect rounded_fill_rect(fill_rect, border.GetRadii(),
|
||||
+ border.GetSmoothness());
|
||||
ApplySpreadToShadowShape(rounded_fill_rect, shadow.Spread());
|
||||
context.FillRoundedRect(
|
||||
rounded_fill_rect, Color::kBlack,
|
||||
@@ -403,7 +404,8 @@ void BoxPainterBase::PaintInsetBoxShadow(const PaintInfo& info,
|
||||
|
||||
gfx::RectF inner_rect = bounds.Rect();
|
||||
AdjustRectForSideClipping(inner_rect, shadow, sides_to_include);
|
||||
- FloatRoundedRect inner_rounded_rect(inner_rect, bounds.GetRadii());
|
||||
+ FloatRoundedRect inner_rounded_rect(inner_rect, bounds.GetRadii(),
|
||||
+ bounds.GetSmoothness());
|
||||
ApplySpreadToShadowShape(inner_rounded_rect, -shadow.Spread());
|
||||
if (inner_rounded_rect.IsEmpty()) {
|
||||
// |AutoDarkMode::Disabled()| is used because |shadow_color| has already
|
||||
diff --git a/third_party/blink/renderer/core/paint/rounded_border_geometry.cc b/third_party/blink/renderer/core/paint/rounded_border_geometry.cc
|
||||
index 7f4026755c285897a0892edfa40a91201a8a4830..795cece5a853662ede5a7439d17b4bee67d51fff 100644
|
||||
--- a/third_party/blink/renderer/core/paint/rounded_border_geometry.cc
|
||||
+++ b/third_party/blink/renderer/core/paint/rounded_border_geometry.cc
|
||||
@@ -52,6 +52,24 @@ FloatRoundedRect::CornerCurvature CalcCurvatureFor(
|
||||
EffectiveCurvature(style.CornerBottomLeftShape(), radii.BottomLeft()));
|
||||
}
|
||||
|
||||
+float SmoothnessFromLength(const Length& length) {
|
||||
+ // `none` = 0%
|
||||
+ if (length.IsNone()) {
|
||||
+ return 0.0f;
|
||||
+ }
|
||||
+
|
||||
+ // `system-ui` keyword, represented internally as "auto" length
|
||||
+ if (length.HasAuto()) {
|
||||
+#if BUILDFLAG(IS_MAC)
|
||||
+ return 0.6f;
|
||||
+#else
|
||||
+ return 0.0f;
|
||||
+#endif // BUILDFLAG(IS_MAC)
|
||||
+ }
|
||||
+
|
||||
+ return length.Percent() / 100.0f;
|
||||
+}
|
||||
+
|
||||
FloatRoundedRect PixelSnappedRoundedBorderInternal(
|
||||
const ComputedStyle& style,
|
||||
const PhysicalRect& border_rect,
|
||||
@@ -64,6 +82,8 @@ FloatRoundedRect PixelSnappedRoundedBorderInternal(
|
||||
rounded_rect.ConstrainRadii();
|
||||
rounded_rect.SetCornerCurvature(
|
||||
CalcCurvatureFor(style, rounded_rect.GetRadii()));
|
||||
+ rounded_rect.SetSmoothness(
|
||||
+ SmoothnessFromLength(style.ElectronCornerSmoothing()));
|
||||
}
|
||||
return rounded_rect;
|
||||
}
|
||||
@@ -80,6 +100,8 @@ FloatRoundedRect RoundedBorderGeometry::RoundedBorder(
|
||||
rounded_rect.ConstrainRadii();
|
||||
rounded_rect.SetCornerCurvature(
|
||||
CalcCurvatureFor(style, rounded_rect.GetRadii()));
|
||||
+ rounded_rect.SetSmoothness(
|
||||
+ SmoothnessFromLength(style.ElectronCornerSmoothing()));
|
||||
}
|
||||
return rounded_rect;
|
||||
}
|
||||
@@ -167,6 +189,8 @@ FloatRoundedRect RoundedBorderGeometry::RoundedInnerBorder(
|
||||
.set_right(style.BorderRightWidth())
|
||||
.set_bottom(style.BorderBottomWidth())
|
||||
.set_left(style.BorderLeftWidth()));
|
||||
+ rounded_border.SetSmoothness(
|
||||
+ SmoothnessFromLength(style.ElectronCornerSmoothing()));
|
||||
return rounded_border;
|
||||
}
|
||||
|
||||
@@ -214,6 +238,7 @@ FloatRoundedRect RoundedBorderGeometry::PixelSnappedRoundedBorderWithOutsets(
|
||||
rounded_rect.SetRadii(pixel_snapped_rounded_border.GetRadii());
|
||||
rounded_rect.SetCornerCurvature(
|
||||
pixel_snapped_rounded_border.GetCornerCurvature());
|
||||
+ rounded_rect.SetSmoothness(pixel_snapped_rounded_border.GetSmoothness());
|
||||
}
|
||||
return rounded_rect;
|
||||
}
|
||||
diff --git a/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.cc b/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.cc
|
||||
index f9f0cc13c043e4653d8a616d0ef4f2f776aace74..6217ca2a6c507c90980be54b1e3d12ce621be099 100644
|
||||
--- a/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.cc
|
||||
+++ b/third_party/blink/renderer/core/paint/rounded_inner_rect_clipper.cc
|
||||
@@ -28,16 +28,16 @@ RoundedInnerRectClipper::RoundedInnerRectClipper(
|
||||
rect.Bottom() - clip_rect.Rect().y());
|
||||
FloatRoundedRect::Radii top_corner_radii;
|
||||
top_corner_radii.SetTopLeft(clip_rect.GetRadii().TopLeft());
|
||||
- rounded_rect_clips.push_back(
|
||||
- FloatRoundedRect(top_corner, top_corner_radii));
|
||||
+ rounded_rect_clips.push_back(FloatRoundedRect(
|
||||
+ top_corner, top_corner_radii, clip_rect.GetSmoothness()));
|
||||
|
||||
gfx::RectF bottom_corner(rect.X().ToFloat(), rect.Y().ToFloat(),
|
||||
clip_rect.Rect().right() - rect.X().ToFloat(),
|
||||
clip_rect.Rect().bottom() - rect.Y().ToFloat());
|
||||
FloatRoundedRect::Radii bottom_corner_radii;
|
||||
bottom_corner_radii.SetBottomRight(clip_rect.GetRadii().BottomRight());
|
||||
- rounded_rect_clips.push_back(
|
||||
- FloatRoundedRect(bottom_corner, bottom_corner_radii));
|
||||
+ rounded_rect_clips.push_back(FloatRoundedRect(
|
||||
+ bottom_corner, bottom_corner_radii, clip_rect.GetSmoothness()));
|
||||
}
|
||||
|
||||
if (!clip_rect.GetRadii().TopRight().IsEmpty() ||
|
||||
@@ -47,16 +47,16 @@ RoundedInnerRectClipper::RoundedInnerRectClipper(
|
||||
rect.Bottom() - clip_rect.Rect().y());
|
||||
FloatRoundedRect::Radii top_corner_radii;
|
||||
top_corner_radii.SetTopRight(clip_rect.GetRadii().TopRight());
|
||||
- rounded_rect_clips.push_back(
|
||||
- FloatRoundedRect(top_corner, top_corner_radii));
|
||||
+ rounded_rect_clips.push_back(FloatRoundedRect(
|
||||
+ top_corner, top_corner_radii, clip_rect.GetSmoothness()));
|
||||
|
||||
gfx::RectF bottom_corner(clip_rect.Rect().x(), rect.Y().ToFloat(),
|
||||
rect.Right() - clip_rect.Rect().x(),
|
||||
clip_rect.Rect().bottom() - rect.Y().ToFloat());
|
||||
FloatRoundedRect::Radii bottom_corner_radii;
|
||||
bottom_corner_radii.SetBottomLeft(clip_rect.GetRadii().BottomLeft());
|
||||
- rounded_rect_clips.push_back(
|
||||
- FloatRoundedRect(bottom_corner, bottom_corner_radii));
|
||||
+ rounded_rect_clips.push_back(FloatRoundedRect(
|
||||
+ bottom_corner, bottom_corner_radii, clip_rect.GetSmoothness()));
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/third_party/blink/renderer/platform/BUILD.gn b/third_party/blink/renderer/platform/BUILD.gn
|
||||
index 8546d85128cc970cb2fd7b0b98642c1403fa5c7d..59f503cbde358d999ffc3a8499a94e1f785d7bed 100644
|
||||
--- a/third_party/blink/renderer/platform/BUILD.gn
|
||||
+++ b/third_party/blink/renderer/platform/BUILD.gn
|
||||
@@ -1634,6 +1634,8 @@ component("platform") {
|
||||
"widget/widget_base.h",
|
||||
"widget/widget_base_client.h",
|
||||
"windows_keyboard_codes.h",
|
||||
+ "//electron/shell/renderer/electron_smooth_round_rect.h",
|
||||
+ "//electron/shell/renderer/electron_smooth_round_rect.cc",
|
||||
]
|
||||
|
||||
sources -= blink_platform_avx_files
|
||||
diff --git a/third_party/blink/renderer/platform/geometry/float_rounded_rect.h b/third_party/blink/renderer/platform/geometry/float_rounded_rect.h
|
||||
index 7bf6608b57f8fc2283026dac6bff0c81bca380fd..09f34525343dacacf966f7ab4918ee57ae0c1470 100644
|
||||
--- a/third_party/blink/renderer/platform/geometry/float_rounded_rect.h
|
||||
+++ b/third_party/blink/renderer/platform/geometry/float_rounded_rect.h
|
||||
@@ -197,15 +197,19 @@ class PLATFORM_EXPORT FloatRoundedRect {
|
||||
: rect_(rect), radii_(radius) {}
|
||||
FloatRoundedRect(const gfx::RectF& r, float radius_x, float radius_y)
|
||||
: FloatRoundedRect(r, Radii(radius_x, radius_y)) {}
|
||||
+ FloatRoundedRect(const gfx::RectF& r, const Radii& radii, float smoothness)
|
||||
+ : rect_(r), radii_(radii), smoothness_(smoothness) {}
|
||||
|
||||
constexpr const gfx::RectF& Rect() const { return rect_; }
|
||||
constexpr const Radii& GetRadii() const { return radii_; }
|
||||
constexpr const CornerCurvature& GetCornerCurvature() const {
|
||||
return corner_curvature_;
|
||||
}
|
||||
+ constexpr float GetSmoothness() const { return smoothness_; }
|
||||
constexpr bool IsRounded() const { return !radii_.IsZero(); }
|
||||
+ constexpr bool IsSmooth() const { return smoothness_ > 0.0f; }
|
||||
constexpr bool HasSimpleRoundedCurvature() const {
|
||||
- return !IsRounded() || corner_curvature_.IsRound();
|
||||
+ return !IsRounded() || (corner_curvature_.IsRound() && !IsSmooth());
|
||||
}
|
||||
constexpr bool IsEmpty() const { return rect_.IsEmpty(); }
|
||||
|
||||
@@ -214,6 +218,7 @@ class PLATFORM_EXPORT FloatRoundedRect {
|
||||
void SetCornerCurvature(const CornerCurvature& curvature) {
|
||||
corner_curvature_ = curvature;
|
||||
}
|
||||
+ void SetSmoothness(float smoothness) { smoothness_ = smoothness; }
|
||||
|
||||
void Move(const gfx::Vector2dF& offset) { rect_.Offset(offset); }
|
||||
|
||||
@@ -297,6 +302,7 @@ class PLATFORM_EXPORT FloatRoundedRect {
|
||||
gfx::RectF rect_;
|
||||
Radii radii_;
|
||||
CornerCurvature corner_curvature_;
|
||||
+ float smoothness_ = 0.0f;
|
||||
};
|
||||
|
||||
inline FloatRoundedRect::operator SkRRect() const {
|
||||
diff --git a/third_party/blink/renderer/platform/geometry/path.cc b/third_party/blink/renderer/platform/geometry/path.cc
|
||||
index 96a1f38db9f42e8d47d70b82b6e1ee8034b96b47..08bc720fe0337f947461d74e29f7ce6f35509643 100644
|
||||
--- a/third_party/blink/renderer/platform/geometry/path.cc
|
||||
+++ b/third_party/blink/renderer/platform/geometry/path.cc
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
+#include "electron/shell/renderer/electron_smooth_round_rect.h"
|
||||
#include "third_party/blink/renderer/platform/geometry/skia_geometry_utils.h"
|
||||
#include "third_party/blink/renderer/platform/geometry/stroke_data.h"
|
||||
#include "third_party/blink/renderer/platform/transforms/affine_transform.h"
|
||||
@@ -657,6 +658,18 @@ void Path::AddRoundedRect(const FloatRoundedRect& rect, bool clockwise) {
|
||||
// no canvas API (at this moment) to change corner curvature.
|
||||
DCHECK(clockwise);
|
||||
|
||||
+ // TODO(clavin): decompose `electron::DrawSmoothRoundRect` into corners
|
||||
+ if (rect.IsSmooth()) {
|
||||
+ const gfx::RectF& box = rect.Rect();
|
||||
+ const FloatRoundedRect::Radii& radii = rect.GetRadii();
|
||||
+ path_.addPath(electron::DrawSmoothRoundRect(
|
||||
+ box.x(), box.y(), box.width(), box.height(),
|
||||
+ std::min(rect.GetSmoothness(), 1.0f), radii.TopLeft().width(),
|
||||
+ radii.TopRight().width(), radii.BottomRight().width(),
|
||||
+ radii.BottomLeft().width()));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
path_.moveTo(gfx::PointFToSkPoint(rect.TopLeftCorner().top_right()));
|
||||
|
||||
path_.lineTo(gfx::PointFToSkPoint((rect.TopRightCorner().origin())));
|
||||
diff --git a/third_party/blink/renderer/platform/graphics/graphics_context.cc b/third_party/blink/renderer/platform/graphics/graphics_context.cc
|
||||
index 5d7887ae589af529a9f4c3e29b9fa314903e26bb..0d2f753a3b189bae69729b4da3cc2af72a98453a 100644
|
||||
--- a/third_party/blink/renderer/platform/graphics/graphics_context.cc
|
||||
+++ b/third_party/blink/renderer/platform/graphics/graphics_context.cc
|
||||
@@ -819,6 +819,13 @@ void GraphicsContext::FillRoundedRect(const FloatRoundedRect& rrect,
|
||||
return;
|
||||
}
|
||||
|
||||
+ if (!rrect.HasSimpleRoundedCurvature()) {
|
||||
+ Path path;
|
||||
+ path.AddRoundedRect(rrect);
|
||||
+ FillPath(path, auto_dark_mode);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
const cc::PaintFlags& fill_flags = ImmutableState()->FillFlags();
|
||||
const SkColor4f sk_color = color.toSkColor4f();
|
||||
if (sk_color == fill_flags.getColor4f()) {
|
Loading…
Add table
Add a link
Reference in a new issue