mirror of
https://github.com/servo/servo.git
synced 2025-07-29 02:00:23 +01:00
commit
ec417a84b1
2 changed files with 21 additions and 1 deletions
|
@ -934,6 +934,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
|||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-localname
|
||||
fn LocalName(self) -> DOMString {
|
||||
self.local_name.as_slice().to_owned()
|
||||
}
|
||||
|
@ -1079,17 +1080,20 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
|||
self.GetAttributeNS(namespace, local_name).is_some()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagname
|
||||
fn GetElementsByTagName(self, localname: DOMString) -> Temporary<HTMLCollection> {
|
||||
let window = window_from_node(self).root();
|
||||
HTMLCollection::by_tag_name(window.r(), NodeCast::from_ref(self), localname)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagnamens
|
||||
fn GetElementsByTagNameNS(self, maybe_ns: Option<DOMString>,
|
||||
localname: DOMString) -> Temporary<HTMLCollection> {
|
||||
let window = window_from_node(self).root();
|
||||
HTMLCollection::by_tag_name_ns(window.r(), NodeCast::from_ref(self), localname, maybe_ns)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-getelementsbyclassname
|
||||
fn GetElementsByClassName(self, classes: DOMString) -> Temporary<HTMLCollection> {
|
||||
let window = window_from_node(self).root();
|
||||
HTMLCollection::by_class_name(window.r(), NodeCast::from_ref(self), classes)
|
||||
|
@ -1126,12 +1130,13 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
|||
rect.origin.x + rect.size.width)
|
||||
}
|
||||
|
||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#extensions-to-the-element-interface
|
||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-innerHTML
|
||||
fn GetInnerHTML(self) -> Fallible<DOMString> {
|
||||
//XXX TODO: XML case
|
||||
self.serialize(ChildrenOnly)
|
||||
}
|
||||
|
||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-innerHTML
|
||||
fn SetInnerHTML(self, value: DOMString) -> Fallible<()> {
|
||||
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
||||
// Step 1.
|
||||
|
@ -1141,10 +1146,12 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-outerHTML
|
||||
fn GetOuterHTML(self) -> Fallible<DOMString> {
|
||||
self.serialize(IncludeNode)
|
||||
}
|
||||
|
||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-outerHTML
|
||||
fn SetOuterHTML(self, value: DOMString) -> Fallible<()> {
|
||||
let context_document = document_from_node(self).root();
|
||||
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
||||
|
|
|
@ -174,55 +174,67 @@ impl Event {
|
|||
}
|
||||
|
||||
impl<'a> EventMethods for JSRef<'a, Event> {
|
||||
// https://dom.spec.whatwg.org/#dom-event-eventphase
|
||||
fn EventPhase(self) -> u16 {
|
||||
self.phase.get() as u16
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-type
|
||||
fn Type(self) -> DOMString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let type_ = self.type_.borrow();
|
||||
type_.clone()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-target
|
||||
fn GetTarget(self) -> Option<Temporary<EventTarget>> {
|
||||
self.target.get()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
||||
fn GetCurrentTarget(self) -> Option<Temporary<EventTarget>> {
|
||||
self.current_target.get()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-defaultprevented
|
||||
fn DefaultPrevented(self) -> bool {
|
||||
self.canceled.get()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-preventdefault
|
||||
fn PreventDefault(self) {
|
||||
if self.cancelable.get() {
|
||||
self.canceled.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-stoppropagation
|
||||
fn StopPropagation(self) {
|
||||
self.stop_propagation.set(true);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
|
||||
fn StopImmediatePropagation(self) {
|
||||
self.stop_immediate.set(true);
|
||||
self.stop_propagation.set(true);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-bubbles
|
||||
fn Bubbles(self) -> bool {
|
||||
self.bubbles.get()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-cancelable
|
||||
fn Cancelable(self) -> bool {
|
||||
self.cancelable.get()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-timestamp
|
||||
fn TimeStamp(self) -> u64 {
|
||||
self.timestamp
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-initevent
|
||||
fn InitEvent(self,
|
||||
type_: DOMString,
|
||||
bubbles: bool,
|
||||
|
@ -242,6 +254,7 @@ impl<'a> EventMethods for JSRef<'a, Event> {
|
|||
self.cancelable.set(cancelable);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-istrusted
|
||||
fn IsTrusted(self) -> bool {
|
||||
self.trusted.get()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue