mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
auto merge of #1117 : Ms2ger/servo/HTMLCollection, r=kmcallister
This commit is contained in:
commit
d222443b38
7 changed files with 32 additions and 39 deletions
|
@ -219,13 +219,11 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn GetElementsByTagNameNS(&self, _ns: &DOMString, _tag: &DOMString) -> @mut HTMLCollection {
|
pub fn GetElementsByTagNameNS(&self, _ns: &DOMString, _tag: &DOMString) -> @mut HTMLCollection {
|
||||||
let (scope, cx) = self.get_scope_and_cx();
|
HTMLCollection::new(self.window, ~[])
|
||||||
HTMLCollection::new(~[], cx, scope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn GetElementsByClassName(&self, _class: &DOMString) -> @mut HTMLCollection {
|
pub fn GetElementsByClassName(&self, _class: &DOMString) -> @mut HTMLCollection {
|
||||||
let (scope, cx) = self.get_scope_and_cx();
|
HTMLCollection::new(self.window, ~[])
|
||||||
HTMLCollection::new(~[], cx, scope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn GetElementById(&self, id: &DOMString) -> Option<AbstractNode<ScriptView>> {
|
pub fn GetElementById(&self, id: &DOMString) -> Option<AbstractNode<ScriptView>> {
|
||||||
|
@ -366,8 +364,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let (scope, cx) = self.get_scope_and_cx();
|
HTMLCollection::new(self.window, elements)
|
||||||
HTMLCollection::new(elements, cx, scope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn content_changed(&self) {
|
pub fn content_changed(&self) {
|
||||||
|
|
|
@ -252,18 +252,15 @@ impl Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn GetElementsByTagName(&self, _localname: &DOMString) -> @mut HTMLCollection {
|
pub fn GetElementsByTagName(&self, _localname: &DOMString) -> @mut HTMLCollection {
|
||||||
let (scope, cx) = self.node.get_scope_and_cx();
|
HTMLCollection::new(self.node.owner_doc().document().window, ~[])
|
||||||
HTMLCollection::new(~[], cx, scope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn GetElementsByTagNameNS(&self, _namespace: &DOMString, _localname: &DOMString) -> Fallible<@mut HTMLCollection> {
|
pub fn GetElementsByTagNameNS(&self, _namespace: &DOMString, _localname: &DOMString) -> Fallible<@mut HTMLCollection> {
|
||||||
let (scope, cx) = self.node.get_scope_and_cx();
|
Ok(HTMLCollection::new(self.node.owner_doc().document().window, ~[]))
|
||||||
Ok(HTMLCollection::new(~[], cx, scope))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn GetElementsByClassName(&self, _names: &DOMString) -> @mut HTMLCollection {
|
pub fn GetElementsByClassName(&self, _names: &DOMString) -> @mut HTMLCollection {
|
||||||
let (scope, cx) = self.node.get_scope_and_cx();
|
HTMLCollection::new(self.node.owner_doc().document().window, ~[])
|
||||||
HTMLCollection::new(~[], cx, scope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn MozMatchesSelector(&self, _selector: &DOMString) -> Fallible<bool> {
|
pub fn MozMatchesSelector(&self, _selector: &DOMString) -> Fallible<bool> {
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::HTMLCollectionBinding;
|
use dom::bindings::codegen::HTMLCollectionBinding;
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::bindings::utils::{DOMString, Fallible};
|
use dom::bindings::utils::{DOMString, Fallible};
|
||||||
use dom::node::{AbstractNode, ScriptView};
|
use dom::node::{AbstractNode, ScriptView};
|
||||||
use script_task::page_from_context;
|
use dom::window::Window;
|
||||||
|
|
||||||
use js::jsapi::{JSObject, JSContext};
|
use js::jsapi::{JSObject, JSContext};
|
||||||
|
|
||||||
|
@ -14,21 +14,24 @@ use std::ptr;
|
||||||
|
|
||||||
pub struct HTMLCollection {
|
pub struct HTMLCollection {
|
||||||
elements: ~[AbstractNode<ScriptView>],
|
elements: ~[AbstractNode<ScriptView>],
|
||||||
reflector_: Reflector
|
reflector_: Reflector,
|
||||||
|
window: @mut Window,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLCollection {
|
impl HTMLCollection {
|
||||||
pub fn new(elements: ~[AbstractNode<ScriptView>], cx: *JSContext, scope: *JSObject) -> @mut HTMLCollection {
|
pub fn new_inherited(window: @mut Window,
|
||||||
let collection = @mut HTMLCollection {
|
elements: ~[AbstractNode<ScriptView>]) -> HTMLCollection {
|
||||||
|
HTMLCollection {
|
||||||
elements: elements,
|
elements: elements,
|
||||||
reflector_: Reflector::new()
|
reflector_: Reflector::new(),
|
||||||
};
|
window: window,
|
||||||
collection.init_wrapper(cx, scope);
|
}
|
||||||
collection
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_wrapper(@mut self, cx: *JSContext, scope: *JSObject) {
|
pub fn new(window: @mut Window,
|
||||||
self.wrap_object_shared(cx, scope);
|
elements: ~[AbstractNode<ScriptView>]) -> @mut HTMLCollection {
|
||||||
|
reflect_dom_object(@mut HTMLCollection::new_inherited(window, elements),
|
||||||
|
window, HTMLCollectionBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Length(&self) -> u32 {
|
pub fn Length(&self) -> u32 {
|
||||||
|
@ -66,15 +69,11 @@ impl Reflectable for HTMLCollection {
|
||||||
&mut self.reflector_
|
&mut self.reflector_
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||||
HTMLCollectionBinding::Wrap(cx, scope, self)
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut Reflectable> {
|
fn GetParentObject(&self, _cx: *JSContext) -> Option<@mut Reflectable> {
|
||||||
let page = page_from_context(cx);
|
Some(self.window as @mut Reflectable)
|
||||||
// TODO(tkuehn): This only handles the top-level frame. Need to grab subframes.
|
|
||||||
unsafe {
|
|
||||||
Some((*page).frame.get_ref().window as @mut Reflectable)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub struct HTMLDataListElement {
|
||||||
|
|
||||||
impl HTMLDataListElement {
|
impl HTMLDataListElement {
|
||||||
pub fn Options(&self) -> @mut HTMLCollection {
|
pub fn Options(&self) -> @mut HTMLCollection {
|
||||||
let (scope, cx) = self.htmlelement.element.node.get_scope_and_cx();
|
let window = self.htmlelement.element.node.owner_doc().document().window;
|
||||||
HTMLCollection::new(~[], cx, scope)
|
HTMLCollection::new(window, ~[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ impl HTMLFieldSetElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Elements(&self) -> @mut HTMLCollection {
|
pub fn Elements(&self) -> @mut HTMLCollection {
|
||||||
let (scope, cx) = self.htmlelement.element.node.get_scope_and_cx();
|
let window = self.htmlelement.element.node.owner_doc().document().window;
|
||||||
HTMLCollection::new(~[], cx, scope)
|
HTMLCollection::new(window, ~[])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn WillValidate(&self) -> bool {
|
pub fn WillValidate(&self) -> bool {
|
||||||
|
|
|
@ -85,8 +85,8 @@ impl HTMLFormElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Elements(&self) -> @mut HTMLCollection {
|
pub fn Elements(&self) -> @mut HTMLCollection {
|
||||||
let (scope, cx) = self.htmlelement.element.node.get_scope_and_cx();
|
let window = self.htmlelement.element.node.owner_doc().document().window;
|
||||||
HTMLCollection::new(~[], cx, scope)
|
HTMLCollection::new(window, ~[])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Length(&self) -> i32 {
|
pub fn Length(&self) -> i32 {
|
||||||
|
|
|
@ -20,7 +20,7 @@ impl HTMLMapElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Areas(&self) -> @mut HTMLCollection {
|
pub fn Areas(&self) -> @mut HTMLCollection {
|
||||||
let (scope, cx) = self.htmlelement.element.node.get_scope_and_cx();
|
let window = self.htmlelement.element.node.owner_doc().document().window;
|
||||||
HTMLCollection::new(~[], cx, scope)
|
HTMLCollection::new(window, ~[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue