Skip to content

Commit

Permalink
Update specs
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 committed May 8, 2023
1 parent 8dd037b commit 0fc3378
Show file tree
Hide file tree
Showing 11 changed files with 675 additions and 150 deletions.
80 changes: 76 additions & 4 deletions Patches/CSSOM.patch
Original file line number Diff line number Diff line change
@@ -1,21 +1,93 @@
--- a/Sources/CSSOM/Generated.swift
+++ b/Sources/CSSOM/Generated.swift
@@ -378,7 +378,8 @@ public class CSSColorValue: CSSStyleValue {
@@ -379,7 +379,8 @@ public class CSSColorValue: CSSStyleValue {
super.init(unsafelyWrapping: jsObject)
}

- @inlinable override public class func parse(cssText: String) -> CSSColorValue_or_CSSStyleValue {
+ // returns CSSStyleValue | CSSColorValue
+ @inlinable public class func parse(cssText: String) -> CSSStyleValue {
let this = constructor!
return this[Strings.parse].function!(this: this, arguments: [_toJSValue(cssText)]).fromJSValue()!
}
@@ -935,7 +936,7 @@ public class CSSNumericValue: CSSStyleValue {
@@ -944,7 +945,7 @@ public class CSSNumericValue: CSSStyleValue {
return this[Strings.type].function!(this: this, arguments: []).fromJSValue()!
}

- @inlinable override public class func parse(cssText: String) -> Self {
+ @inlinable public class func parse(cssText: String) -> Self {
let this = constructor!
return this[Strings.parse].function!(this: this, arguments: [_toJSValue(cssText)]).fromJSValue()!
}
@@ -1974,9 +1975,10 @@ public class StylePropertyMapReadOnly: JSBridgedClass, Sequence {
ValueIterableIterator(sequence: self)
}

- @inlinable public func get(property: String) -> CSSStyleValue_or_Void {
+ // TODO: remove patch once https://github.com/w3c/css-houdini-drafts/issues/1095 is fixed
+ @inlinable public func get(property: String) -> CSSStyleValue? {
let this = jsObject
- return this[Strings.get].function!(this: this, arguments: [_toJSValue(property)]).fromJSValue()!
+ return this[Strings.get].function!(this: this, arguments: [_toJSValue(property)]).fromJSValue()
}

@inlinable public func getAll(property: String) -> [CSSStyleValue] {
@@ -2646,58 +2648,6 @@ public enum CSSStyleValue_or_String: JSValueCompatible, Any_CSSStyleValue_or_Str
}
}

-public protocol Any_CSSStyleValue_or_Void: ConvertibleToJSValue {}
-extension CSSStyleValue: Any_CSSStyleValue_or_Void {}
-extension Void: Any_CSSStyleValue_or_Void {}
-
-public enum CSSStyleValue_or_Void: JSValueCompatible, Any_CSSStyleValue_or_Void {
- case cssStyleValue(CSSStyleValue)
- case void(Void)
-
- init(_ cssStyleValue: CSSStyleValue) {
- let val: CSSStyleValue_or_Void = .cssStyleValue(cssStyleValue)
- self = val
- }
-
- init(_ void: Void) {
- let val: CSSStyleValue_or_Void = .void(void)
- self = val
- }
-
- public var cssStyleValue: CSSStyleValue? {
- switch self {
- case let .cssStyleValue(cssStyleValue): return cssStyleValue
- default: return nil
- }
- }
-
- public var void: Void? {
- switch self {
- case let .void(void): return void
- default: return nil
- }
- }
-
- public static func construct(from value: JSValue) -> Self? {
- if let cssStyleValue: CSSStyleValue = value.fromJSValue() {
- return .cssStyleValue(cssStyleValue)
- }
- if let void: Void = value.fromJSValue() {
- return .void(void)
- }
- return nil
- }
-
- public var jsValue: JSValue {
- switch self {
- case let .cssStyleValue(cssStyleValue):
- return cssStyleValue.jsValue
- case let .void(void):
- return void.jsValue
- }
- }
-}
-
public protocol Any_CSSUnparsedSegment: ConvertibleToJSValue {}
extension CSSVariableReferenceValue: Any_CSSUnparsedSegment {}
extension String: Any_CSSUnparsedSegment {}
27 changes: 23 additions & 4 deletions Patches/DOM.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/Sources/DOM/Generated.swift
+++ b/Sources/DOM/Generated.swift
@@ -1006,8 +1006,15 @@ public class BeforeUnloadEvent: Event {
@@ -1007,8 +1007,15 @@ public class BeforeUnloadEvent: Event {
super.init(unsafelyWrapping: jsObject)
}

Expand All @@ -17,7 +17,7 @@
get { _returnValue.wrappedValue }
set { _returnValue.wrappedValue = newValue }
}
@@ -7070,7 +7077,8 @@ public class HTMLFormControlsCollection: HTMLCollection {
@@ -7095,7 +7102,8 @@ public class HTMLFormControlsCollection: HTMLCollection {
jsObject[key].fromJSValue()
}

Expand All @@ -27,7 +27,26 @@
let this = jsObject
return this[Strings.namedItem].function!(this: this, arguments: [_toJSValue(name)]).fromJSValue()
}
@@ -20369,19 +20377,9 @@ public enum CanvasImageSource: JSValueCompatible, Any_CanvasImageSource {
@@ -17153,7 +17161,6 @@ public class VisibilityStateEntry: PerformanceEntry {
_name = ReadonlyAttribute(jsObject: jsObject, name: Strings.name)
_entryType = ReadonlyAttribute(jsObject: jsObject, name: Strings.entryType)
_startTime = ReadonlyAttribute(jsObject: jsObject, name: Strings.startTime)
- _duration = ReadonlyAttribute(jsObject: jsObject, name: Strings.duration)
super.init(unsafelyWrapping: jsObject)
}

@@ -17166,8 +17173,8 @@ public class VisibilityStateEntry: PerformanceEntry {
@usableFromInline let _startTime: ReadonlyAttribute<DOMHighResTimeStamp>
@inlinable override public var startTime: DOMHighResTimeStamp { _startTime.wrappedValue }

- @usableFromInline let _duration: ReadonlyAttribute<UInt32>
- @inlinable override public var duration: UInt32 { _duration.wrappedValue }
+ // XXX: override of property `duration` removed because the type here is UInt32 but the
+ // type in the superclass is DOMHighResTimestamp (Double).
}

public class VisualViewport: EventTarget {
@@ -20687,19 +20694,9 @@ public enum CanvasImageSource: JSValueCompatible, Any_CanvasImageSource {
self = val
}

Expand All @@ -49,7 +68,7 @@
}

init(_ htmlVideoElement: HTMLVideoElement) {
@@ -21629,18 +21627,8 @@ public enum ImageBitmapSource: JSValueCompatible, Any_ImageBitmapSource {
@@ -21947,18 +21944,8 @@ public enum ImageBitmapSource: JSValueCompatible, Any_ImageBitmapSource {
self = .init(val)
}

Expand Down
17 changes: 14 additions & 3 deletions Sources/CSSOM/Generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@ public class CSSImportRule: CSSRule {
_href = ReadonlyAttribute(jsObject: jsObject, name: Strings.href)
_media = ReadonlyAttribute(jsObject: jsObject, name: Strings.media)
_styleSheet = ReadonlyAttribute(jsObject: jsObject, name: Strings.styleSheet)
_layerName = ReadonlyAttribute(jsObject: jsObject, name: Strings.layerName)
_supportsText = ReadonlyAttribute(jsObject: jsObject, name: Strings.supportsText)
super.init(unsafelyWrapping: jsObject)
}

Expand All @@ -489,7 +491,13 @@ public class CSSImportRule: CSSRule {
public var media: MediaList

@ReadonlyAttribute
public var styleSheet: CSSStyleSheet
public var styleSheet: CSSStyleSheet?

@ReadonlyAttribute
public var layerName: String?

@ReadonlyAttribute
public var supportsText: String?
}

public class CSSKeywordValue: CSSStyleValue {
Expand Down Expand Up @@ -1967,9 +1975,10 @@ public class StylePropertyMapReadOnly: JSBridgedClass, Sequence {
ValueIterableIterator(sequence: self)
}

@inlinable public func get(property: String) -> JSValue {
// TODO: remove patch once https://github.com/w3c/css-houdini-drafts/issues/1095 is fixed
@inlinable public func get(property: String) -> CSSStyleValue? {
let this = jsObject
return this[Strings.get].function!(this: this, arguments: [_toJSValue(property)]).fromJSValue()!
return this[Strings.get].function!(this: this, arguments: [_toJSValue(property)]).fromJSValue()
}

@inlinable public func getAll(property: String) -> [CSSStyleValue] {
Expand Down Expand Up @@ -2243,6 +2252,7 @@ public class VisualViewport: EventTarget {
@usableFromInline static let item: JSString = "item"
@usableFromInline static let kHz: JSString = "kHz"
@usableFromInline static let l: JSString = "l"
@usableFromInline static let layerName: JSString = "layerName"
@usableFromInline static let left: JSString = "left"
@usableFromInline static let length: JSString = "length"
@usableFromInline static let lh: JSString = "lh"
Expand Down Expand Up @@ -2313,6 +2323,7 @@ public class VisualViewport: EventTarget {
@usableFromInline static let styleSheet: JSString = "styleSheet"
@usableFromInline static let styleSheets: JSString = "styleSheets"
@usableFromInline static let sub: JSString = "sub"
@usableFromInline static let supportsText: JSString = "supportsText"
@usableFromInline static let svb: JSString = "svb"
@usableFromInline static let svh: JSString = "svh"
@usableFromInline static let svi: JSString = "svi"
Expand Down
Loading

0 comments on commit 0fc3378

Please sign in to comment.