-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AbstractRange
and StaticRange
interfaces
#4221
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#![allow(unused_imports)] | ||
#![allow(clippy::all)] | ||
use super::*; | ||
use wasm_bindgen::prelude::*; | ||
#[wasm_bindgen] | ||
extern "C" { | ||
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AbstractRange , typescript_type = "AbstractRange")] | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
#[doc = "The `AbstractRange` class."] | ||
#[doc = ""] | ||
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbstractRange)"] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `AbstractRange`*"] | ||
pub type AbstractRange; | ||
#[cfg(feature = "Node")] | ||
# [wasm_bindgen (structural , catch , method , getter , js_class = "AbstractRange" , js_name = startContainer)] | ||
#[doc = "Getter for the `startContainer` field of this object."] | ||
#[doc = ""] | ||
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbstractRange/startContainer)"] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `AbstractRange`, `Node`*"] | ||
pub fn start_container(this: &AbstractRange) -> Result<Node, JsValue>; | ||
# [wasm_bindgen (structural , catch , method , getter , js_class = "AbstractRange" , js_name = startOffset)] | ||
#[doc = "Getter for the `startOffset` field of this object."] | ||
#[doc = ""] | ||
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbstractRange/startOffset)"] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `AbstractRange`*"] | ||
pub fn start_offset(this: &AbstractRange) -> Result<u32, JsValue>; | ||
#[cfg(feature = "Node")] | ||
# [wasm_bindgen (structural , catch , method , getter , js_class = "AbstractRange" , js_name = endContainer)] | ||
#[doc = "Getter for the `endContainer` field of this object."] | ||
#[doc = ""] | ||
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbstractRange/endContainer)"] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `AbstractRange`, `Node`*"] | ||
pub fn end_container(this: &AbstractRange) -> Result<Node, JsValue>; | ||
# [wasm_bindgen (structural , catch , method , getter , js_class = "AbstractRange" , js_name = endOffset)] | ||
#[doc = "Getter for the `endOffset` field of this object."] | ||
#[doc = ""] | ||
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbstractRange/endOffset)"] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `AbstractRange`*"] | ||
pub fn end_offset(this: &AbstractRange) -> Result<u32, JsValue>; | ||
# [wasm_bindgen (structural , method , getter , js_class = "AbstractRange" , js_name = collapsed)] | ||
#[doc = "Getter for the `collapsed` field of this object."] | ||
#[doc = ""] | ||
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbstractRange/collapsed)"] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `AbstractRange`*"] | ||
pub fn collapsed(this: &AbstractRange) -> bool; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![allow(unused_imports)] | ||
#![allow(clippy::all)] | ||
use super::*; | ||
use wasm_bindgen::prelude::*; | ||
#[wasm_bindgen] | ||
extern "C" { | ||
# [wasm_bindgen (extends = AbstractRange , extends = :: js_sys :: Object , js_name = StaticRange , typescript_type = "StaticRange")] | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
#[doc = "The `StaticRange` class."] | ||
#[doc = ""] | ||
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/StaticRange)"] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `StaticRange`*"] | ||
pub type StaticRange; | ||
#[cfg(feature = "StaticRangeInit")] | ||
#[wasm_bindgen(catch, constructor, js_class = "StaticRange")] | ||
#[doc = "The `new StaticRange(..)` constructor, creating a new instance of `StaticRange`."] | ||
#[doc = ""] | ||
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/StaticRange/StaticRange)"] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `StaticRange`, `StaticRangeInit`*"] | ||
pub fn new(init: &StaticRangeInit) -> Result<StaticRange, JsValue>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#![allow(unused_imports)] | ||
#![allow(clippy::all)] | ||
use super::*; | ||
use wasm_bindgen::prelude::*; | ||
#[wasm_bindgen] | ||
extern "C" { | ||
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = StaticRangeInit)] | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
#[doc = "The `StaticRangeInit` dictionary."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `StaticRangeInit`*"] | ||
pub type StaticRangeInit; | ||
#[cfg(feature = "Node")] | ||
#[doc = "Get the `endContainer` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `Node`, `StaticRangeInit`*"] | ||
#[wasm_bindgen(method, getter = "endContainer")] | ||
pub fn get_end_container(this: &StaticRangeInit) -> Node; | ||
#[cfg(feature = "Node")] | ||
#[doc = "Change the `endContainer` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `Node`, `StaticRangeInit`*"] | ||
#[wasm_bindgen(method, setter = "endContainer")] | ||
pub fn set_end_container(this: &StaticRangeInit, val: &Node); | ||
#[doc = "Get the `endOffset` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `StaticRangeInit`*"] | ||
#[wasm_bindgen(method, getter = "endOffset")] | ||
pub fn get_end_offset(this: &StaticRangeInit) -> u32; | ||
#[doc = "Change the `endOffset` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `StaticRangeInit`*"] | ||
#[wasm_bindgen(method, setter = "endOffset")] | ||
pub fn set_end_offset(this: &StaticRangeInit, val: u32); | ||
#[cfg(feature = "Node")] | ||
#[doc = "Get the `startContainer` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `Node`, `StaticRangeInit`*"] | ||
#[wasm_bindgen(method, getter = "startContainer")] | ||
pub fn get_start_container(this: &StaticRangeInit) -> Node; | ||
#[cfg(feature = "Node")] | ||
#[doc = "Change the `startContainer` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `Node`, `StaticRangeInit`*"] | ||
#[wasm_bindgen(method, setter = "startContainer")] | ||
pub fn set_start_container(this: &StaticRangeInit, val: &Node); | ||
#[doc = "Get the `startOffset` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `StaticRangeInit`*"] | ||
#[wasm_bindgen(method, getter = "startOffset")] | ||
pub fn get_start_offset(this: &StaticRangeInit) -> u32; | ||
#[doc = "Change the `startOffset` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `StaticRangeInit`*"] | ||
#[wasm_bindgen(method, setter = "startOffset")] | ||
pub fn set_start_offset(this: &StaticRangeInit, val: u32); | ||
} | ||
impl StaticRangeInit { | ||
#[cfg(feature = "Node")] | ||
#[doc = "Construct a new `StaticRangeInit`."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `Node`, `StaticRangeInit`*"] | ||
pub fn new( | ||
end_container: &Node, | ||
end_offset: u32, | ||
start_container: &Node, | ||
start_offset: u32, | ||
) -> Self { | ||
#[allow(unused_mut)] | ||
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); | ||
ret.end_container(end_container); | ||
ret.end_offset(end_offset); | ||
ret.start_container(start_container); | ||
ret.start_offset(start_offset); | ||
ret | ||
} | ||
#[cfg(feature = "Node")] | ||
#[deprecated = "Use `set_end_container()` instead."] | ||
pub fn end_container(&mut self, val: &Node) -> &mut Self { | ||
self.set_end_container(val); | ||
self | ||
} | ||
#[deprecated = "Use `set_end_offset()` instead."] | ||
pub fn end_offset(&mut self, val: u32) -> &mut Self { | ||
self.set_end_offset(val); | ||
self | ||
} | ||
#[cfg(feature = "Node")] | ||
#[deprecated = "Use `set_start_container()` instead."] | ||
pub fn start_container(&mut self, val: &Node) -> &mut Self { | ||
self.set_start_container(val); | ||
self | ||
} | ||
#[deprecated = "Use `set_start_offset()` instead."] | ||
pub fn start_offset(&mut self, val: u32) -> &mut Self { | ||
self.set_start_offset(val); | ||
self | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EOL missing. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* The origin of this IDL file is | ||
* https://dom.spec.whatwg.org/#abstractrange | ||
* | ||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C | ||
* liability, trademark and document use rules apply. | ||
*/ | ||
|
||
|
||
interface AbstractRange { | ||
[Throws] | ||
readonly attribute Node startContainer; | ||
[Throws] | ||
readonly attribute unsigned long startOffset; | ||
[Throws] | ||
readonly attribute Node endContainer; | ||
[Throws] | ||
readonly attribute unsigned long endOffset; | ||
Comment on lines
+14
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't find anything in the specification saying that this could throw. Let me know if you have different information. |
||
readonly attribute boolean collapsed; | ||
}; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,10 +10,10 @@ | |||||
* | ||||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C | ||||||
* liability, trademark and document use rules apply. | ||||||
*/ | ||||||
*/ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
[Constructor] | ||||||
interface Range { | ||||||
interface Range : AbstractRange { | ||||||
[Throws] | ||||||
readonly attribute Node startContainer; | ||||||
behrenle marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
[Throws] | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EOL missing. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,22 @@ | ||||||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. | ||||||
* | ||||||
* The origin of this IDL file is | ||||||
* https://dom.spec.whatwg.org/#staticrange | ||||||
* | ||||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C | ||||||
* liability, trademark and document use rules apply. | ||||||
*/ | ||||||
|
||||||
dictionary StaticRangeInit { | ||||||
required Node startContainer; | ||||||
required unsigned long startOffset; | ||||||
required Node endContainer; | ||||||
required unsigned long endOffset; | ||||||
}; | ||||||
|
||||||
[Exposed=Window] | ||||||
interface StaticRange : AbstractRange { | ||||||
constructor(StaticRangeInit init); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Constructors are marked as throwing by default, but just in case we want to change this in the future. |
||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets combine those.