mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
script: Implement the width
and height
attributes for iframes per
HTML5 § 4.8.6. Improves Amazon and Ars Technica.
This commit is contained in:
parent
e52197d126
commit
1a3395e077
13 changed files with 154 additions and 290 deletions
|
@ -18,7 +18,7 @@ use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
|
|||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{ElementCast, ElementDerived, EventTargetCast};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLBodyElementDerived, HTMLFontElementDerived};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLInputElementCast};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLIFrameElementDerived, HTMLInputElementCast};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLInputElementDerived, HTMLTableElementCast};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLTableElementDerived, HTMLTableCellElementDerived};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLTableRowElementDerived, HTMLTextAreaElementDerived};
|
||||
|
@ -47,6 +47,7 @@ use dom::htmlbodyelement::{HTMLBodyElement, HTMLBodyElementHelpers};
|
|||
use dom::htmlcollection::HTMLCollection;
|
||||
use dom::htmlelement::HTMLElementTypeId;
|
||||
use dom::htmlfontelement::{HTMLFontElement, HTMLFontElementHelpers};
|
||||
use dom::htmliframeelement::{HTMLIFrameElement, RawHTMLIFrameElementHelpers};
|
||||
use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers, HTMLInputElementHelpers};
|
||||
use dom::htmltableelement::{HTMLTableElement, HTMLTableElementHelpers};
|
||||
use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementHelpers};
|
||||
|
@ -64,7 +65,7 @@ use style;
|
|||
use style::legacy::{UnsignedIntegerAttribute, from_declaration};
|
||||
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_style_attribute};
|
||||
use style::properties::DeclaredValue::SpecifiedValue;
|
||||
use style::properties::longhands::{self, border_spacing};
|
||||
use style::properties::longhands::{self, border_spacing, height};
|
||||
use style::values::CSSFloat;
|
||||
use style::values::specified::{self, CSSColor, CSSRGBA};
|
||||
use util::geometry::Au;
|
||||
|
@ -181,7 +182,8 @@ pub trait RawLayoutElementHelpers {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_attr_for_layout(elem: &Element, namespace: &Namespace, name: &Atom) -> Option<LayoutJS<Attr>> {
|
||||
pub unsafe fn get_attr_for_layout<'a>(elem: &'a Element, namespace: &Namespace, name: &Atom)
|
||||
-> Option<LayoutJS<Attr>> {
|
||||
// cast to point to T in RefCell<T> directly
|
||||
let attrs = elem.attrs.borrow_for_layout();
|
||||
attrs.iter().find(|attr: & &JS<Attr>| {
|
||||
|
@ -331,7 +333,10 @@ impl RawLayoutElementHelpers for Element {
|
|||
}
|
||||
|
||||
|
||||
let width = if self.is_htmltableelement() {
|
||||
let width = if self.is_htmliframeelement() {
|
||||
let this: &HTMLIFrameElement = mem::transmute(self);
|
||||
this.get_width()
|
||||
} else if self.is_htmltableelement() {
|
||||
let this: &HTMLTableElement = mem::transmute(self);
|
||||
this.get_width()
|
||||
} else if self.is_htmltabledatacellelement() {
|
||||
|
@ -349,13 +354,37 @@ impl RawLayoutElementHelpers for Element {
|
|||
PropertyDeclaration::Width(SpecifiedValue(width_value))));
|
||||
}
|
||||
LengthOrPercentageOrAuto::Length(length) => {
|
||||
let width_value = specified::LengthOrPercentageOrAuto::Length(specified::Length::Absolute(length));
|
||||
let width_value = specified::LengthOrPercentageOrAuto::Length(
|
||||
specified::Length::Absolute(length));
|
||||
hints.push(from_declaration(
|
||||
PropertyDeclaration::Width(SpecifiedValue(width_value))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let height = if self.is_htmliframeelement() {
|
||||
let this: &HTMLIFrameElement = mem::transmute(self);
|
||||
this.get_height()
|
||||
} else {
|
||||
LengthOrPercentageOrAuto::Auto
|
||||
};
|
||||
|
||||
match height {
|
||||
LengthOrPercentageOrAuto::Auto => {}
|
||||
LengthOrPercentageOrAuto::Percentage(percentage) => {
|
||||
let width_value = specified::LengthOrPercentageOrAuto::Percentage(percentage);
|
||||
hints.push(from_declaration(PropertyDeclaration::Height(SpecifiedValue(
|
||||
height::SpecifiedValue(width_value)))));
|
||||
}
|
||||
LengthOrPercentageOrAuto::Length(length) => {
|
||||
let width_value = specified::LengthOrPercentageOrAuto::Length(
|
||||
specified::Length::Absolute(length));
|
||||
hints.push(from_declaration(PropertyDeclaration::Height(SpecifiedValue(
|
||||
height::SpecifiedValue(width_value)))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let cols = if self.is_htmltextareaelement() {
|
||||
let this: &HTMLTextAreaElement = mem::transmute(self);
|
||||
match this.get_cols_for_layout() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue