script: Map HTMLCanvasElement width and height attributes.

This commit is contained in:
Emilio Cobos Álvarez 2017-04-07 16:03:25 +02:00
parent df29d02026
commit 53cad6227e
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 63 additions and 3 deletions

View file

@ -41,6 +41,7 @@ use dom::eventtarget::EventTarget;
use dom::htmlanchorelement::HTMLAnchorElement;
use dom::htmlbodyelement::{HTMLBodyElement, HTMLBodyElementLayoutHelpers};
use dom::htmlbuttonelement::HTMLButtonElement;
use dom::htmlcanvaselement::{HTMLCanvasElement, LayoutHTMLCanvasElementHelpers};
use dom::htmlcollection::HTMLCollection;
use dom::htmlelement::HTMLElement;
use dom::htmlfieldsetelement::HTMLFieldSetElement;
@ -381,6 +382,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
unsafe fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
where V: Push<ApplicableDeclarationBlock>
{
// FIXME(emilio): Just a single PDB should be enough.
#[inline]
fn from_declaration(shared_lock: &SharedRwLock, declaration: PropertyDeclaration)
-> ApplicableDeclarationBlock {
@ -541,10 +543,13 @@ impl LayoutElementHelpers for LayoutJS<Element> {
} else if let Some(this) = self.downcast::<HTMLHRElement>() {
// https://html.spec.whatwg.org/multipage/#the-hr-element-2:attr-hr-width
this.get_width()
} else if let Some(this) = self.downcast::<HTMLCanvasElement>() {
this.get_width()
} else {
LengthOrPercentageOrAuto::Auto
};
// FIXME(emilio): Use from_computed value here and below.
match width {
LengthOrPercentageOrAuto::Auto => {}
LengthOrPercentageOrAuto::Percentage(percentage) => {
@ -568,6 +573,8 @@ impl LayoutElementHelpers for LayoutJS<Element> {
this.get_height()
} else if let Some(this) = self.downcast::<HTMLImageElement>() {
this.get_height()
} else if let Some(this) = self.downcast::<HTMLCanvasElement>() {
this.get_height()
} else {
LengthOrPercentageOrAuto::Auto
};
@ -2231,7 +2238,14 @@ impl VirtualMethods for Element {
}
}
},
_ => {},
_ => {
// FIXME(emilio): This is pretty dubious, and should be done in
// the relevant super-classes.
if attr.namespace() == &ns!() &&
attr.local_name() == &local_name!("src") {
node.dirty(NodeDamage::OtherNodeDamage);
}
},
};
// Make sure we rev the version even if we didn't dirty the node. If we