diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index efef7033d..2dc1270db 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -4528,6 +4528,10 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; + /** + * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. + */ + getSelection(): Selection | null; /** * Gets a value indicating whether the object currently has focus. */ @@ -4583,9 +4587,6 @@ interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, Par * @param content The text and HTML tags to write. */ writeln(...text: string[]): void; - /** - * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. - */ addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -5408,6 +5409,8 @@ interface GlobalEventHandlersEventMap { "seeked": Event; "seeking": Event; "select": Event; + "selectionchange": Event; + "selectstart": Event; "stalled": Event; "submit": Event; "suspend": Event; @@ -5655,6 +5658,8 @@ interface GlobalEventHandlers { * @param ev The event. */ onselect: ((this: GlobalEventHandlers, ev: Event) => any) | null; + onselectionchange: ((this: GlobalEventHandlers, ev: Event) => any) | null; + onselectstart: ((this: GlobalEventHandlers, ev: Event) => any) | null; /** * Occurs when the download has stopped. * @param ev The event. @@ -14461,32 +14466,27 @@ declare var SecurityPolicyViolationEvent: { /** A Selection object represents the range of text selected by the user or the current position of the caret. To obtain a Selection object for examination or modification, call Window.getSelection(). */ interface Selection { - readonly anchorNode: Node; + readonly anchorNode: Node | null; readonly anchorOffset: number; - readonly baseNode: Node; - readonly baseOffset: number; - readonly extentNode: Node; - readonly extentOffset: number; - readonly focusNode: Node; + readonly focusNode: Node | null; readonly focusOffset: number; readonly isCollapsed: boolean; readonly rangeCount: number; readonly type: string; addRange(range: Range): void; - collapse(parentNode: Node, offset: number): void; + collapse(node: Node | null, offset?: number): void; collapseToEnd(): void; collapseToStart(): void; - containsNode(node: Node, partlyContained: boolean): boolean; + containsNode(node: Node, allowPartialContainment?: boolean): boolean; deleteFromDocument(): void; empty(): void; - extend(newNode: Node, offset: number): void; + extend(node: Node, offset?: number): void; getRangeAt(index: number): Range; removeAllRanges(): void; removeRange(range: Range): void; - selectAllChildren(parentNode: Node): void; - setBaseAndExtent(baseNode: Node, baseOffset: number, extentNode: Node, extentOffset: number): void; - setPosition(parentNode: Node, offset: number): void; - toString(): string; + selectAllChildren(node: Node): void; + setBaseAndExtent(anchorNode: Node, anchorOffset: number, focusNode: Node, focusOffset: number): void; + setPosition(node: Node | null, offset?: number): void; } declare var Selection: { @@ -16979,7 +16979,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window focus(): void; getComputedStyle(elt: Element, pseudoElt?: string | null): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string | null): CSSRuleList; - getSelection(): Selection; + getSelection(): Selection | null; matchMedia(query: string): MediaQueryList; moveBy(x: number, y: number): void; moveTo(x: number, y: number): void; @@ -17855,7 +17855,7 @@ declare function departFocus(navigationReason: NavigationReason, origin: FocusNa declare function focus(): void; declare function getComputedStyle(elt: Element, pseudoElt?: string | null): CSSStyleDeclaration; declare function getMatchedCSSRules(elt: Element, pseudoElt?: string | null): CSSRuleList; -declare function getSelection(): Selection; +declare function getSelection(): Selection | null; declare function matchMedia(query: string): MediaQueryList; declare function moveBy(x: number, y: number): void; declare function moveTo(x: number, y: number): void; @@ -18117,6 +18117,8 @@ declare var onseeking: ((this: Window, ev: Event) => any) | null; * @param ev The event. */ declare var onselect: ((this: Window, ev: Event) => any) | null; +declare var onselectionchange: ((this: Window, ev: Event) => any) | null; +declare var onselectstart: ((this: Window, ev: Event) => any) | null; /** * Occurs when the download has stopped. * @param ev The event. diff --git a/inputfiles/idl/Selection.widl b/inputfiles/idl/Selection.widl new file mode 100644 index 000000000..d42cf3099 --- /dev/null +++ b/inputfiles/idl/Selection.widl @@ -0,0 +1,38 @@ +interface Selection { + readonly attribute Node? anchorNode; + readonly attribute unsigned long anchorOffset; + readonly attribute Node? focusNode; + readonly attribute unsigned long focusOffset; + readonly attribute boolean isCollapsed; + readonly attribute unsigned long rangeCount; + readonly attribute DOMString type; + Range getRangeAt(unsigned long index); + void addRange(Range range); + void removeRange(Range range); + void removeAllRanges(); + void empty(); + void collapse(Node? node, optional unsigned long offset = 0); + void setPosition(Node? node, optional unsigned long offset = 0); + void collapseToStart(); + void collapseToEnd(); + void extend(Node node, optional unsigned long offset = 0); + void setBaseAndExtent(Node anchorNode, unsigned long anchorOffset, Node focusNode, unsigned long focusOffset); + void selectAllChildren(Node node); + [CEReactions] + void deleteFromDocument(); + boolean containsNode(Node node, optional boolean allowPartialContainment = false); + stringifier DOMString (); +}; + +partial interface Document { + Selection? getSelection(); +}; + +partial interface Window { + Selection? getSelection(); +}; + +partial interface GlobalEventHandlers { + attribute EventHandler onselectstart; + attribute EventHandler onselectionchange; +}; diff --git a/inputfiles/idlSources.json b/inputfiles/idlSources.json index ff0a665cf..ff949486a 100644 --- a/inputfiles/idlSources.json +++ b/inputfiles/idlSources.json @@ -218,6 +218,10 @@ "url": "https://www.w3.org/TR/screen-orientation/", "title": "Screen Orientation" }, + { + "url": "https://www.w3.org/TR/selection-api/", + "title": "Selection" + }, { "url": "https://w3c.github.io/ServiceWorker/", "title": "Service Workers"