From 1950d7fb47f942458e77b887090dfd158ee54b01 Mon Sep 17 00:00:00 2001 From: Srujan Gaddam Date: Wed, 4 Sep 2024 16:36:59 -0700 Subject: [PATCH 1/2] Refactor generation logic so partials come after Currently, the generator adds members to interfacelikes as we process various IDL files. This may lead to partial interfaces being added before the interface definition. Instead, this CL adds partials after the interface definition, and then applies mixins. It also dedups some logic around browser compatibility so that we only check compatibility and process in one location. While there is a diff in the generated files, it is functionally the same because all we do is move members around in the same extension type. --- web/lib/src/dom/cssom.dart | 36 +- web/lib/src/dom/dom.dart | 614 ++++----- web/lib/src/dom/gamepad.dart | 14 +- web/lib/src/dom/hr_time.dart | 14 +- web/lib/src/dom/html.dart | 1222 +++++++++--------- web/lib/src/dom/mathml_core.dart | 72 +- web/lib/src/dom/permissions.dart | 8 +- web/lib/src/dom/service_workers.dart | 86 +- web/lib/src/dom/storage.dart | 14 +- web/lib/src/dom/svg.dart | 80 +- web/lib/src/dom/uievents.dart | 178 +-- web/lib/src/dom/url.dart | 62 +- web/lib/src/dom/web_animations.dart | 54 +- web/lib/src/dom/webrtc.dart | 157 ++- web/lib/src/dom/webxr.dart | 54 +- web_generator/lib/src/generate_bindings.dart | 2 +- web_generator/lib/src/translator.dart | 146 +-- 17 files changed, 1406 insertions(+), 1407 deletions(-) diff --git a/web/lib/src/dom/cssom.dart b/web/lib/src/dom/cssom.dart index 7d29f291..5fce13a3 100644 --- a/web/lib/src/dom/cssom.dart +++ b/web/lib/src/dom/cssom.dart @@ -352,18 +352,6 @@ extension type CSSRuleList._(JSObject _) implements JSObject { /// API documentation sourced from /// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/CSSRule). extension type CSSRule._(JSObject _) implements JSObject { - static const int KEYFRAMES_RULE = 7; - - static const int KEYFRAME_RULE = 8; - - static const int SUPPORTS_RULE = 12; - - static const int COUNTER_STYLE_RULE = 11; - - static const int FONT_FEATURE_VALUES_RULE = 14; - - static const int VIEW_TRANSITION_RULE = 15; - static const int STYLE_RULE = 1; static const int CHARSET_RULE = 2; @@ -380,6 +368,18 @@ extension type CSSRule._(JSObject _) implements JSObject { static const int NAMESPACE_RULE = 10; + static const int KEYFRAMES_RULE = 7; + + static const int KEYFRAME_RULE = 8; + + static const int SUPPORTS_RULE = 12; + + static const int COUNTER_STYLE_RULE = 11; + + static const int FONT_FEATURE_VALUES_RULE = 14; + + static const int VIEW_TRANSITION_RULE = 15; + /// The **`cssText`** property of the [CSSRule] /// interface returns the actual text of a [CSSStyleSheet] style-rule. /// @@ -439,11 +439,6 @@ extension type CSSRule._(JSObject _) implements JSObject { /// API documentation sourced from /// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleRule). extension type CSSStyleRule._(JSObject _) implements CSSGroupingRule, JSObject { - /// The **`styleMap`** read-only property of the - /// [CSSStyleRule] interface returns a [StylePropertyMap] object - /// which provides access to the rule's property-value pairs. - external StylePropertyMap get styleMap; - /// The **`selectorText`** property of the [CSSStyleRule] interface gets and /// sets the selectors associated with the `CSSStyleRule`. external String get selectorText; @@ -454,6 +449,11 @@ extension type CSSStyleRule._(JSObject _) implements CSSGroupingRule, JSObject { /// [declaration block](https://www.w3.org/TR/1998/REC-CSS2-19980512/syndata.html#block) /// of the [CSSStyleRule]. external JSObject get style; + + /// The **`styleMap`** read-only property of the + /// [CSSStyleRule] interface returns a [StylePropertyMap] object + /// which provides access to the rule's property-value pairs. + external StylePropertyMap get styleMap; } /// The **`CSSImportRule`** interface represents an @@ -1930,6 +1930,7 @@ external $CSS get CSS; /// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/CSS). @JS('CSS') extension type $CSS._(JSObject _) implements JSObject { + external String escape(String ident); external bool supports( String conditionTextOrProperty, [ String value, @@ -1999,6 +2000,5 @@ extension type $CSS._(JSObject _) implements JSObject { external CSSUnitValue dpcm(num value); external CSSUnitValue dppx(num value); external CSSUnitValue fr(num value); - external String escape(String ident); external HighlightRegistry get highlights; } diff --git a/web/lib/src/dom/dom.dart b/web/lib/src/dom/dom.dart index 0bcb4f63..c9e14442 100644 --- a/web/lib/src/dom/dom.dart +++ b/web/lib/src/dom/dom.dart @@ -1356,70 +1356,6 @@ extension type Document._(JSObject _) implements Node, JSObject { /// of UTF-8, and a URL of "about:blank" external static Document parseHTMLUnsafe(JSAny html); - /// The **`startViewTransition()`** method of the [Document] interface starts - /// a new same-document (SPA) - /// [view transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) - /// and returns a [ViewTransition] object to represent it. - /// - /// When `startViewTransition()` is invoked, a sequence of steps is followed - /// as explained in - /// [The view transition process](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API/Using#the_view_transition_process). - external ViewTransition startViewTransition([JSObject callbackOptions]); - - /// The **`elementFromPoint()`** - /// method, available on the [Document] object, returns the topmost [Element] - /// at the specified coordinates - /// (relative to the viewport). - /// - /// If the element at the specified point belongs to another document (for - /// example, the - /// document of an `iframe`), that document's parent element is returned - /// (the `