aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlvideoelement.rs
diff options
context:
space:
mode:
authorFernando Jiménez Moreno <ferjmoreno@gmail.com>2018-09-21 11:26:37 +0200
committerFernando Jiménez Moreno <ferjmoreno@gmail.com>2018-10-08 16:12:02 +0200
commit6904535865c3d7edebfdfc5919bc9207013d4cf8 (patch)
tree3b4989be9743b1a9328ff7330f0eb5153200f60c /components/script/dom/htmlvideoelement.rs
parentda0e92d7f830b4f1e09d9e3099ae39cf2b62fd10 (diff)
downloadservo-6904535865c3d7edebfdfc5919bc9207013d4cf8.tar.gz
servo-6904535865c3d7edebfdfc5919bc9207013d4cf8.zip
videoWidth and videoHeight params
Diffstat (limited to 'components/script/dom/htmlvideoelement.rs')
-rw-r--r--components/script/dom/htmlvideoelement.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/components/script/dom/htmlvideoelement.rs b/components/script/dom/htmlvideoelement.rs
index 8561aa051e1..5ce8d941b61 100644
--- a/components/script/dom/htmlvideoelement.rs
+++ b/components/script/dom/htmlvideoelement.rs
@@ -3,16 +3,20 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLVideoElementBinding;
+use dom::bindings::codegen::Bindings::HTMLVideoElementBinding::HTMLVideoElementMethods;
use dom::bindings::root::DomRoot;
use dom::document::Document;
-use dom::htmlmediaelement::HTMLMediaElement;
+use dom::htmlmediaelement::{HTMLMediaElement, ReadyState};
use dom::node::Node;
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
+use std::cell::Cell;
#[dom_struct]
pub struct HTMLVideoElement {
htmlmediaelement: HTMLMediaElement,
+ video_width: Cell<u32>,
+ video_height: Cell<u32>,
}
impl HTMLVideoElement {
@@ -23,6 +27,8 @@ impl HTMLVideoElement {
) -> HTMLVideoElement {
HTMLVideoElement {
htmlmediaelement: HTMLMediaElement::new_inherited(local_name, prefix, document),
+ video_width: Cell::new(0),
+ video_height: Cell::new(0),
}
}
@@ -40,4 +46,28 @@ impl HTMLVideoElement {
HTMLVideoElementBinding::Wrap,
)
}
+
+ pub fn set_video_width(&self, width: u32) {
+ self.video_width.set(width);
+ }
+
+ pub fn set_video_height(&self, height: u32) {
+ self.video_height.set(height);
+ }
+}
+
+impl HTMLVideoElementMethods for HTMLVideoElement {
+ fn VideoWidth(&self) -> u32 {
+ if self.htmlmediaelement.get_ready_state() == ReadyState::HaveNothing {
+ return 0;
+ }
+ self.video_width.get()
+ }
+
+ fn VideoHeight(&self) -> u32 {
+ if self.htmlmediaelement.get_ready_state() == ReadyState::HaveNothing {
+ return 0;
+ }
+ self.video_height.get()
+ }
}