Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7a746dd

Browse files
authored
Add external factories for @staticInterop classes instead of synthetic constructor (#37443)
Per dart-lang/sdk#49941, synthetic constructors will be disallowed on @staticInterop classes. Functionally, they are lowered to the same code. Also fixes an erroneous call to the DomHTMLStyleConstructor instead of the relevant factory method.
1 parent a9fbf6a commit 7a746dd

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,9 @@ class SkParagraphStyle {}
18651865
@JS()
18661866
@anonymous
18671867
@staticInterop
1868-
class SkParagraphStyleProperties {}
1868+
class SkParagraphStyleProperties {
1869+
external factory SkParagraphStyleProperties();
1870+
}
18691871

18701872
extension SkParagraphStylePropertiesExtension on SkParagraphStyleProperties {
18711873
external set textAlign(SkTextAlign? value);
@@ -1981,7 +1983,9 @@ SkPlaceholderAlignment toSkPlaceholderAlignment(
19811983
@JS()
19821984
@anonymous
19831985
@staticInterop
1984-
class SkTextStyleProperties {}
1986+
class SkTextStyleProperties {
1987+
external factory SkTextStyleProperties();
1988+
}
19851989

19861990
extension SkTextStylePropertiesExtension on SkTextStyleProperties {
19871991
external set backgroundColor(Float32List? value);
@@ -2008,7 +2012,9 @@ extension SkTextStylePropertiesExtension on SkTextStyleProperties {
20082012
@JS()
20092013
@anonymous
20102014
@staticInterop
2011-
class SkStrutStyleProperties {}
2015+
class SkStrutStyleProperties {
2016+
external factory SkStrutStyleProperties();
2017+
}
20122018

20132019
extension SkStrutStylePropertiesExtension on SkStrutStyleProperties {
20142020
external set fontFamilies(List<String>? value);
@@ -2024,7 +2030,9 @@ extension SkStrutStylePropertiesExtension on SkStrutStyleProperties {
20242030
@JS()
20252031
@anonymous
20262032
@staticInterop
2027-
class SkFontStyle {}
2033+
class SkFontStyle {
2034+
external factory SkFontStyle();
2035+
}
20282036

20292037
extension SkFontStyleExtension on SkFontStyle {
20302038
external set weight(SkFontWeight? value);
@@ -2034,7 +2042,9 @@ extension SkFontStyleExtension on SkFontStyle {
20342042
@JS()
20352043
@anonymous
20362044
@staticInterop
2037-
class SkTextShadow {}
2045+
class SkTextShadow {
2046+
external factory SkTextShadow();
2047+
}
20382048

20392049
extension SkTextShadowExtension on SkTextShadow {
20402050
external set color(Float32List? value);
@@ -2045,7 +2055,9 @@ extension SkTextShadowExtension on SkTextShadow {
20452055
@JS()
20462056
@anonymous
20472057
@staticInterop
2048-
class SkFontFeature {}
2058+
class SkFontFeature {
2059+
external factory SkFontFeature();
2060+
}
20492061

20502062
extension SkFontFeatureExtension on SkFontFeature {
20512063
external set name(String? value);
@@ -2055,7 +2067,9 @@ extension SkFontFeatureExtension on SkFontFeature {
20552067
@JS()
20562068
@anonymous
20572069
@staticInterop
2058-
class SkFontVariation {}
2070+
class SkFontVariation {
2071+
external factory SkFontVariation();
2072+
}
20592073

20602074
extension SkFontVariationExtension on SkFontVariation {
20612075
external set axis(String? value);

lib/web_ui/lib/src/engine/text/font_collection.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class _PolyfillFontManager extends FontManager {
325325
final String fontFaceDeclaration = fontStyleMap.keys
326326
.map((String name) => '$name: ${fontStyleMap[name]};')
327327
.join(' ');
328-
final DomHTMLStyleElement fontLoadStyle = DomHTMLStyleElement();
328+
final DomHTMLStyleElement fontLoadStyle = createDomHTMLStyleElement();
329329
fontLoadStyle.type = 'text/css';
330330
fontLoadStyle.innerHtml = '@font-face { $fontFaceDeclaration }';
331331
domDocument.head!.append(fontLoadStyle);

0 commit comments

Comments
 (0)