mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
auto merge of #4342 : jdm/servo/cssom, r=jdm,metajack
This does not implement any notion of CSSStyleDeclaration objects that do not have an owning element; there's no actual CSS object model in play here. This does support setting and getting properties of the style attribute for HTMLElement, and tries to implement the ambiguous CSS value serialization spec.
This commit is contained in:
commit
824788649c
16 changed files with 1705 additions and 47 deletions
350
components/script/dom/cssstyledeclaration.rs
Normal file
350
components/script/dom/cssstyledeclaration.rs
Normal file
|
@ -0,0 +1,350 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::{mod, CSSStyleDeclarationMethods};
|
||||
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast};
|
||||
use dom::bindings::error::ErrorResult;
|
||||
use dom::bindings::global;
|
||||
use dom::bindings::js::{JS, JSRef, OptionalRootedRootable, Temporary};
|
||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::document::DocumentHelpers;
|
||||
use dom::element::{Element, ElementHelpers};
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::{window_from_node, document_from_node, NodeDamage, Node};
|
||||
use dom::window::Window;
|
||||
use servo_util::str::DOMString;
|
||||
use string_cache::Atom;
|
||||
use style::{is_supported_property, longhands_from_shorthand, parse_style_attribute};
|
||||
use style::PropertyDeclaration;
|
||||
|
||||
use std::ascii::AsciiExt;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct CSSStyleDeclaration {
|
||||
reflector_: Reflector,
|
||||
owner: JS<HTMLElement>,
|
||||
}
|
||||
|
||||
macro_rules! css_properties(
|
||||
( $([$getter:ident, $setter:ident, $cssprop:expr]),* ) => (
|
||||
$(
|
||||
fn $getter(self) -> DOMString {
|
||||
self.GetPropertyValue($cssprop.to_string())
|
||||
}
|
||||
fn $setter(self, value: DOMString) {
|
||||
self.SetPropertyValue($cssprop.to_string(), value).unwrap();
|
||||
}
|
||||
)*
|
||||
);
|
||||
)
|
||||
|
||||
fn serialize_list(list: &Vec<PropertyDeclaration>) -> DOMString {
|
||||
let mut result = String::new();
|
||||
for declaration in list.iter() {
|
||||
result.push_str(serialize_value(declaration).as_slice());
|
||||
result.push_str(" ");
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn serialize_value(declaration: &PropertyDeclaration) -> DOMString {
|
||||
declaration.value()
|
||||
}
|
||||
|
||||
impl CSSStyleDeclaration {
|
||||
pub fn new_inherited(owner: JSRef<HTMLElement>) -> CSSStyleDeclaration {
|
||||
CSSStyleDeclaration {
|
||||
reflector_: Reflector::new(),
|
||||
owner: JS::from_rooted(owner),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: JSRef<Window>, owner: JSRef<HTMLElement>) -> Temporary<CSSStyleDeclaration> {
|
||||
reflect_dom_object(box CSSStyleDeclaration::new_inherited(owner),
|
||||
global::Window(global),
|
||||
CSSStyleDeclarationBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
trait PrivateCSSStyleDeclarationHelpers {
|
||||
fn get_declaration(self, property: &Atom) -> Option<PropertyDeclaration>;
|
||||
}
|
||||
|
||||
impl<'a> PrivateCSSStyleDeclarationHelpers for JSRef<'a, CSSStyleDeclaration> {
|
||||
fn get_declaration(self, property: &Atom) -> Option<PropertyDeclaration> {
|
||||
let owner = self.owner.root();
|
||||
let element: JSRef<Element> = ElementCast::from_ref(*owner);
|
||||
element.get_inline_style_declaration(property).map(|decl| decl.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
|
||||
fn Length(self) -> u32 {
|
||||
let owner = self.owner.root();
|
||||
let elem: JSRef<Element> = ElementCast::from_ref(*owner);
|
||||
let len = match *elem.style_attribute().borrow() {
|
||||
Some(ref declarations) => declarations.normal.len() + declarations.important.len(),
|
||||
None => 0
|
||||
};
|
||||
len as u32
|
||||
}
|
||||
|
||||
fn Item(self, index: u32) -> DOMString {
|
||||
let owner = self.owner.root();
|
||||
let elem: JSRef<Element> = ElementCast::from_ref(*owner);
|
||||
let style_attribute = elem.style_attribute().borrow();
|
||||
let result = style_attribute.as_ref().and_then(|declarations| {
|
||||
if index as uint > declarations.normal.len() {
|
||||
declarations.important
|
||||
.get(index as uint - declarations.normal.len())
|
||||
.map(|decl| format!("{} !important", decl))
|
||||
} else {
|
||||
declarations.normal
|
||||
.get(index as uint)
|
||||
.map(|decl| format!("{}", decl))
|
||||
}
|
||||
});
|
||||
|
||||
result.unwrap_or("".to_string())
|
||||
}
|
||||
|
||||
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
|
||||
fn GetPropertyValue(self, property: DOMString) -> DOMString {
|
||||
// Step 1
|
||||
let property = Atom::from_slice(property.as_slice().to_ascii_lower().as_slice());
|
||||
|
||||
// Step 2
|
||||
let longhand_properties = longhands_from_shorthand(property.as_slice());
|
||||
if let Some(longhand_properties) = longhand_properties {
|
||||
// Step 2.1
|
||||
let mut list = vec!();
|
||||
|
||||
// Step 2.2
|
||||
for longhand in longhand_properties.iter() {
|
||||
// Step 2.2.1
|
||||
let declaration = self.get_declaration(&Atom::from_slice(longhand.as_slice()));
|
||||
|
||||
// Step 2.2.2 & 2.2.3
|
||||
match declaration {
|
||||
Some(declaration) => list.push(declaration),
|
||||
None => return "".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2.3
|
||||
return serialize_list(&list);
|
||||
}
|
||||
|
||||
// Step 3 & 4
|
||||
if let Some(ref declaration) = self.get_declaration(&property) {
|
||||
serialize_value(declaration)
|
||||
} else {
|
||||
"".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty
|
||||
fn SetProperty(self, property: DOMString, value: DOMString,
|
||||
priority: DOMString) -> ErrorResult {
|
||||
//TODO: disallow modifications if readonly flag is set
|
||||
|
||||
// Step 2
|
||||
let property = property.as_slice().to_ascii_lower();
|
||||
|
||||
// Step 3
|
||||
if !is_supported_property(property.as_slice()) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Step 4
|
||||
if value.is_empty() {
|
||||
self.RemoveProperty(property);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Step 5
|
||||
let priority = priority.as_slice().to_ascii_lower();
|
||||
if priority.as_slice() != "!important" && !priority.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Step 6
|
||||
let mut synthesized_declaration = String::from_str(property.as_slice());
|
||||
synthesized_declaration.push_str(": ");
|
||||
synthesized_declaration.push_str(value.as_slice());
|
||||
|
||||
let owner = self.owner.root();
|
||||
let window = window_from_node(*owner).root();
|
||||
let page = window.page();
|
||||
let decl_block = parse_style_attribute(synthesized_declaration.as_slice(),
|
||||
&page.get_url());
|
||||
|
||||
// Step 7
|
||||
if decl_block.normal.len() == 0 {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let owner = self.owner.root();
|
||||
let element: JSRef<Element> = ElementCast::from_ref(*owner);
|
||||
|
||||
// Step 8
|
||||
for decl in decl_block.normal.iter() {
|
||||
// Step 9
|
||||
element.update_inline_style(decl.clone(), !priority.is_empty());
|
||||
}
|
||||
|
||||
let document = document_from_node(element).root();
|
||||
let node: JSRef<Node> = NodeCast::from_ref(element);
|
||||
document.content_changed(node, NodeDamage::NodeStyleDamaged);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertyvalue
|
||||
fn SetPropertyValue(self, property: DOMString, value: DOMString) -> ErrorResult {
|
||||
self.SetProperty(property, value, "".to_string())
|
||||
}
|
||||
|
||||
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty
|
||||
fn RemoveProperty(self, property: DOMString) -> DOMString {
|
||||
//TODO: disallow modifications if readonly flag is set
|
||||
|
||||
// Step 2
|
||||
let property = property.as_slice().to_ascii_lower();
|
||||
|
||||
// Step 3
|
||||
let value = self.GetPropertyValue(property.clone());
|
||||
|
||||
let longhand_properties = longhands_from_shorthand(property.as_slice());
|
||||
match longhand_properties {
|
||||
Some(longhands) => {
|
||||
// Step 4
|
||||
for longhand in longhands.iter() {
|
||||
self.RemoveProperty(longhand.clone());
|
||||
}
|
||||
}
|
||||
|
||||
None => {
|
||||
// Step 5
|
||||
let owner = self.owner.root();
|
||||
let elem: JSRef<Element> = ElementCast::from_ref(*owner);
|
||||
elem.remove_inline_style_property(property)
|
||||
}
|
||||
}
|
||||
|
||||
// Step 6
|
||||
value
|
||||
}
|
||||
|
||||
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
|
||||
fn CssFloat(self) -> DOMString {
|
||||
self.GetPropertyValue("float".to_string())
|
||||
}
|
||||
|
||||
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-cssfloat
|
||||
fn SetCssFloat(self, value: DOMString) -> ErrorResult {
|
||||
self.SetPropertyValue("float".to_string(), value)
|
||||
}
|
||||
|
||||
fn IndexedGetter(self, index: u32, found: &mut bool) -> DOMString {
|
||||
let rval = self.Item(index);
|
||||
*found = index < self.Length();
|
||||
rval
|
||||
}
|
||||
|
||||
css_properties!(
|
||||
[Color, SetColor, "color"],
|
||||
[Background, SetBackground, "background"],
|
||||
[BackgroundColor, SetBackgroundColor, "background-color"],
|
||||
[BackgroundPosition, SetBackgroundPosition, "background-position"],
|
||||
[BackgroundImage, SetBackgroundImage, "background-image"],
|
||||
[BackgroundRepeat, SetBackgroundRepeat, "background-repeat"],
|
||||
[BackgroundAttachment, SetBackgroundAttachment, "background-attachment"],
|
||||
[Border, SetBorder, "border"],
|
||||
[BorderColor, SetBorderColor, "border-color"],
|
||||
[BorderRadius, SetBorderRadius, "border-radius"],
|
||||
[BorderStyle, SetBorderStyle, "border-style"],
|
||||
[BorderWidth, SetBorderWidth, "border-width"],
|
||||
[BorderBottom, SetBorderBottom, "border-bottom"],
|
||||
[BorderBottomColor, SetBorderBottomColor, "border-bottom-color"],
|
||||
[BorderBottomStyle, SetBorderBottomStyle, "border-bottom-style"],
|
||||
[BorderBottomWidth, SetBorderBottomWidth, "border-bottom-width"],
|
||||
[BorderLeft, SetBorderLeft, "border-left"],
|
||||
[BorderLeftColor, SetBorderLeftColor, "border-left-color"],
|
||||
[BorderLeftStyle, SetBorderLeftStyle, "border-left-style"],
|
||||
[BorderLeftWidth, SetBorderLeftWidth, "border-left-width"],
|
||||
[BorderRight, SetBorderRight, "border-right"],
|
||||
[BorderRightColor, SetBorderRightColor, "border-right-color"],
|
||||
[BorderRightStyle, SetBorderRightStyle, "border-right-style"],
|
||||
[BorderRightWidth, SetBorderRightWidth, "border-right-width"],
|
||||
[BorderTop, SetBorderTop, "border-top"],
|
||||
[BorderTopColor, SetBorderTopColor, "border-top-color"],
|
||||
[BorderTopStyle, SetBorderTopStyle, "border-top-style"],
|
||||
[BorderTopWidth, SetBorderTopWidth, "border-top-width"],
|
||||
[Content, SetContent, "content"],
|
||||
[Display, SetDisplay, "display"],
|
||||
[Opacity, SetOpacity, "opacity"],
|
||||
[Width, SetWidth, "width"],
|
||||
[MinWidth, SetMinWidth, "min-width"],
|
||||
[MaxWidth, SetMaxWidth, "max-width"],
|
||||
[Height, SetHeight, "height"],
|
||||
[MinHeight, SetMinHeight, "min-height"],
|
||||
[MaxHeight, SetMaxHeight, "max-height"],
|
||||
[Clear, SetClear, "clear"],
|
||||
[Direction, SetDirection, "direction"],
|
||||
[LineHeight, SetLineHeight, "line-height"],
|
||||
[VerticalAlign, SetVerticalAlign, "vertical-align"],
|
||||
[ListStyle, SetListStyle, "list-style"],
|
||||
[ListStylePosition, SetListStylePosition, "list-style-position"],
|
||||
[ListStyleType, SetListStyleType, "list-style-type"],
|
||||
[ListStyleImage, SetListStyleImage, "list-style-image"],
|
||||
[Visibility, SetVisibility, "visibility"],
|
||||
[Cursor, SetCursor, "cursor"],
|
||||
[BoxShadow, SetBoxShadow, "box-shadow"],
|
||||
[BoxSizing, SetBoxSizing, "box-sizing"],
|
||||
[Overflow, SetOverflow, "overflow"],
|
||||
[OverflowWrap, SetOverflowWrap, "overflow-wrap"],
|
||||
[TableLayout, SetTableLayout, "table-layout"],
|
||||
[EmptyCells, SetEmptyCells, "empty-cells"],
|
||||
[CaptionSide, SetCaptionSide, "caption-side"],
|
||||
[WhiteSpace, SetWhiteSpace, "white-space"],
|
||||
[WritingMode, SetWritingMode, "writing-mode"],
|
||||
[LetterSpacing, SetLetterSpacing, "letter-spacing"],
|
||||
[WordSpacing, SetWordSpacing, "word-spacing"],
|
||||
[WordWrap, SetWordWrap, "word-wrap"],
|
||||
[TextAlign, SetTextAlign, "text-align"],
|
||||
[TextDecoration, SetTextDecoration, "text-decoration"],
|
||||
[TextIndent, SetTextIndent, "text-indent"],
|
||||
[TextOrientation, SetTextOrientation, "text-orientation"],
|
||||
[TextTransform, SetTextTransform, "text-transform"],
|
||||
[Font, SetFont, "font"],
|
||||
[FontFamily, SetFontFamily, "font-family"],
|
||||
[FontSize, SetFontSize, "font-size"],
|
||||
[FontStyle, SetFontStyle, "font-style"],
|
||||
[FontVariant, SetFontVariant, "font-variant"],
|
||||
[FontWeight, SetFontWeight, "font-weight"],
|
||||
[Margin, SetMargin, "margin"],
|
||||
[MarginBottom, SetMarginBottom, "margin-bottom"],
|
||||
[MarginLeft, SetMarginLeft, "margin-left"],
|
||||
[MarginRight, SetMarginRight, "margin-right"],
|
||||
[MarginTop, SetMarginTop, "margin-top"],
|
||||
[Padding, SetPadding, "padding"],
|
||||
[PaddingBottom, SetPaddingBottom, "padding-bottom"],
|
||||
[PaddingLeft, SetPaddingLeft, "padding-left"],
|
||||
[PaddingRight, SetPaddingRight, "padding-right"],
|
||||
[PaddingTop, SetPaddingTop, "padding-top"],
|
||||
[Outline, SetOutline, "outline"],
|
||||
[Position, SetPosition, "position"],
|
||||
[Bottom, SetBottom, "bottom"],
|
||||
[Left, SetLeft, "left"],
|
||||
[Right, SetRight, "right"],
|
||||
[Top, SetTop, "top"],
|
||||
[ZIndex, SetZIndex, "z-index"]
|
||||
)
|
||||
}
|
||||
|
||||
impl Reflectable for CSSStyleDeclaration {
|
||||
fn reflector<'a>(&'a self) -> &'a Reflector {
|
||||
&self.reflector_
|
||||
}
|
||||
}
|
|
@ -60,6 +60,7 @@ use std::ascii::AsciiExt;
|
|||
use std::cell::{Ref, RefMut};
|
||||
use std::default::Default;
|
||||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
use string_cache::{Atom, Namespace, QualName};
|
||||
use url::UrlParser;
|
||||
|
||||
|
@ -465,6 +466,9 @@ pub trait ElementHelpers<'a> {
|
|||
fn style_attribute(self) -> &'a DOMRefCell<Option<style::PropertyDeclarationBlock>>;
|
||||
fn summarize(self) -> Vec<AttrInfo>;
|
||||
fn is_void(self) -> bool;
|
||||
fn remove_inline_style_property(self, property: DOMString);
|
||||
fn update_inline_style(self, property_decl: style::PropertyDeclaration, important: bool);
|
||||
fn get_inline_style_declaration(self, property: &Atom) -> Option<style::PropertyDeclaration>;
|
||||
}
|
||||
|
||||
impl<'a> ElementHelpers<'a> for JSRef<'a, Element> {
|
||||
|
@ -522,6 +526,75 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> {
|
|||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_inline_style_property(self, property: DOMString) {
|
||||
let mut inline_declarations = self.style_attribute.borrow_mut();
|
||||
inline_declarations.as_mut().map(|declarations| {
|
||||
let index = declarations.normal
|
||||
.iter()
|
||||
.position(|decl| decl.name() == property);
|
||||
match index {
|
||||
Some(index) => {
|
||||
declarations.normal.make_unique().remove(index);
|
||||
return;
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
|
||||
let index = declarations.important
|
||||
.iter()
|
||||
.position(|decl| decl.name() == property);
|
||||
match index {
|
||||
Some(index) => {
|
||||
declarations.important.make_unique().remove(index);
|
||||
return;
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn update_inline_style(self, property_decl: style::PropertyDeclaration, important: bool) {
|
||||
let mut inline_declarations = self.style_attribute().borrow_mut();
|
||||
if let Some(ref mut declarations) = *inline_declarations.deref_mut() {
|
||||
let existing_declarations = if important {
|
||||
declarations.important.make_unique()
|
||||
} else {
|
||||
declarations.normal.make_unique()
|
||||
};
|
||||
|
||||
for declaration in existing_declarations.iter_mut() {
|
||||
if declaration.name() == property_decl.name() {
|
||||
*declaration = property_decl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
existing_declarations.push(property_decl);
|
||||
return;
|
||||
}
|
||||
|
||||
let (important, normal) = if important {
|
||||
(vec!(property_decl), vec!())
|
||||
} else {
|
||||
(vec!(), vec!(property_decl))
|
||||
};
|
||||
|
||||
*inline_declarations = Some(style::PropertyDeclarationBlock {
|
||||
important: Arc::new(important),
|
||||
normal: Arc::new(normal),
|
||||
});
|
||||
}
|
||||
|
||||
fn get_inline_style_declaration(self, property: &Atom) -> Option<style::PropertyDeclaration> {
|
||||
let inline_declarations = self.style_attribute.borrow();
|
||||
inline_declarations.as_ref().and_then(|declarations| {
|
||||
declarations.normal
|
||||
.iter()
|
||||
.chain(declarations.important.iter())
|
||||
.find(|decl| decl.matches(property.as_slice()))
|
||||
.map(|decl| decl.clone())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AttributeHandlers {
|
||||
|
|
|
@ -12,8 +12,9 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
|||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFrameSetElementDerived};
|
||||
use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLInputElementCast};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementDerived, HTMLBodyElementDerived};
|
||||
use dom::bindings::js::{JSRef, Temporary};
|
||||
use dom::bindings::js::{JSRef, Temporary, MutNullableJS};
|
||||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
use dom::cssstyledeclaration::CSSStyleDeclaration;
|
||||
use dom::document::Document;
|
||||
use dom::element::{Element, ElementTypeId, ActivationElementHelpers};
|
||||
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
|
||||
|
@ -24,9 +25,12 @@ use servo_util::str::DOMString;
|
|||
|
||||
use string_cache::Atom;
|
||||
|
||||
use std::default::Default;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct HTMLElement {
|
||||
element: Element
|
||||
element: Element,
|
||||
style_decl: MutNullableJS<CSSStyleDeclaration>,
|
||||
}
|
||||
|
||||
impl HTMLElementDerived for EventTarget {
|
||||
|
@ -42,7 +46,8 @@ impl HTMLElementDerived for EventTarget {
|
|||
impl HTMLElement {
|
||||
pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLElement {
|
||||
HTMLElement {
|
||||
element: Element::new_inherited(type_id, tag_name, ns!(HTML), prefix, document)
|
||||
element: Element::new_inherited(type_id, tag_name, ns!(HTML), prefix, document),
|
||||
style_decl: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,6 +70,13 @@ impl<'a> PrivateHTMLElementHelpers for JSRef<'a, HTMLElement> {
|
|||
}
|
||||
|
||||
impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
|
||||
fn Style(self) -> Temporary<CSSStyleDeclaration> {
|
||||
self.style_decl.or_init(|| {
|
||||
let global = window_from_node(self).root();
|
||||
CSSStyleDeclaration::new(*global, self)
|
||||
})
|
||||
}
|
||||
|
||||
make_getter!(Title)
|
||||
make_setter!(SetTitle, "title")
|
||||
|
||||
|
|
149
components/script/dom/webidls/CSSStyleDeclaration.webidl
Normal file
149
components/script/dom/webidls/CSSStyleDeclaration.webidl
Normal file
|
@ -0,0 +1,149 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
|
||||
*
|
||||
* Copyright © 2013 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved.
|
||||
*/
|
||||
|
||||
interface CSSStyleDeclaration {
|
||||
//[SetterThrows]
|
||||
// attribute DOMString cssText;
|
||||
readonly attribute unsigned long length;
|
||||
getter DOMString item(unsigned long index);
|
||||
DOMString getPropertyValue(DOMString property);
|
||||
//DOMString getPropertyPriority(DOMString property);
|
||||
[Throws]
|
||||
void setProperty(DOMString property, [TreatNullAs=EmptyString] DOMString value,
|
||||
[TreatNullAs=EmptyString] optional DOMString priority = "");
|
||||
[Throws]
|
||||
void setPropertyValue(DOMString property, [TreatNullAs=EmptyString] DOMString value);
|
||||
//[Throws]
|
||||
//void setPropertyPriority(DOMString property, [TreatNullAs=EmptyString] DOMString priority);
|
||||
DOMString removeProperty(DOMString property);
|
||||
//readonly attribute CSSRule? parentRule;
|
||||
[SetterThrows]
|
||||
attribute DOMString cssFloat;
|
||||
};
|
||||
|
||||
partial interface CSSStyleDeclaration {
|
||||
[TreatNullAs=EmptyString] attribute DOMString background;
|
||||
[TreatNullAs=EmptyString] attribute DOMString backgroundColor;
|
||||
[TreatNullAs=EmptyString] attribute DOMString backgroundPosition;
|
||||
[TreatNullAs=EmptyString] attribute DOMString backgroundRepeat;
|
||||
[TreatNullAs=EmptyString] attribute DOMString backgroundImage;
|
||||
[TreatNullAs=EmptyString] attribute DOMString backgroundAttachment;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString border;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderColor;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderRadius;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderStyle;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderWidth;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderBottom;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderBottomColor;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderBottomStyle;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderBottomWidth;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderLeft;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderLeftColor;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderLeftStyle;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderLeftWidth;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderRight;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderRightColor;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderRightStyle;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderRightWidth;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderTop;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderTopColor;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderTopStyle;
|
||||
[TreatNullAs=EmptyString] attribute DOMString borderTopWidth;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString content;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString color;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString display;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString opacity;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString visibility;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString cursor;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString boxSizing;
|
||||
[TreatNullAs=EmptyString] attribute DOMString boxShadow;
|
||||
|
||||
//[TreatNullAs=EmptyString] attribute DOMString float; //XXXjdm need BinaryName annotation
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString clear;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString direction;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString lineHeight;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString verticalAlign;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString listStyle;
|
||||
[TreatNullAs=EmptyString] attribute DOMString listStylePosition;
|
||||
[TreatNullAs=EmptyString] attribute DOMString listStyleType;
|
||||
[TreatNullAs=EmptyString] attribute DOMString listStyleImage;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString overflow;
|
||||
[TreatNullAs=EmptyString] attribute DOMString overflowWrap;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString tableLayout;
|
||||
[TreatNullAs=EmptyString] attribute DOMString emptyCells;
|
||||
[TreatNullAs=EmptyString] attribute DOMString captionSide;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString whiteSpace;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString writingMode;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString letterSpacing;
|
||||
[TreatNullAs=EmptyString] attribute DOMString wordSpacing;
|
||||
[TreatNullAs=EmptyString] attribute DOMString wordWrap;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString textAlign;
|
||||
[TreatNullAs=EmptyString] attribute DOMString textDecoration;
|
||||
[TreatNullAs=EmptyString] attribute DOMString textIndent;
|
||||
[TreatNullAs=EmptyString] attribute DOMString textOrientation;
|
||||
[TreatNullAs=EmptyString] attribute DOMString textTransform;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString font;
|
||||
[TreatNullAs=EmptyString] attribute DOMString fontFamily;
|
||||
[TreatNullAs=EmptyString] attribute DOMString fontSize;
|
||||
[TreatNullAs=EmptyString] attribute DOMString fontStyle;
|
||||
[TreatNullAs=EmptyString] attribute DOMString fontVariant;
|
||||
[TreatNullAs=EmptyString] attribute DOMString fontWeight;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString margin;
|
||||
[TreatNullAs=EmptyString] attribute DOMString marginBottom;
|
||||
[TreatNullAs=EmptyString] attribute DOMString marginLeft;
|
||||
[TreatNullAs=EmptyString] attribute DOMString marginRight;
|
||||
[TreatNullAs=EmptyString] attribute DOMString marginTop;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString padding;
|
||||
[TreatNullAs=EmptyString] attribute DOMString paddingBottom;
|
||||
[TreatNullAs=EmptyString] attribute DOMString paddingLeft;
|
||||
[TreatNullAs=EmptyString] attribute DOMString paddingRight;
|
||||
[TreatNullAs=EmptyString] attribute DOMString paddingTop;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString outline;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString position;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString top;
|
||||
[TreatNullAs=EmptyString] attribute DOMString right;
|
||||
[TreatNullAs=EmptyString] attribute DOMString left;
|
||||
[TreatNullAs=EmptyString] attribute DOMString bottom;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString height;
|
||||
[TreatNullAs=EmptyString] attribute DOMString minHeight;
|
||||
[TreatNullAs=EmptyString] attribute DOMString maxHeight;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString width;
|
||||
[TreatNullAs=EmptyString] attribute DOMString minWidth;
|
||||
[TreatNullAs=EmptyString] attribute DOMString maxWidth;
|
||||
|
||||
[TreatNullAs=EmptyString] attribute DOMString zIndex;
|
||||
};
|
11
components/script/dom/webidls/ElementCSSInlineStyle.webidl
Normal file
11
components/script/dom/webidls/ElementCSSInlineStyle.webidl
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//http://dev.w3.org/csswg/cssom/#elementcssinlinestyle
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface ElementCSSInlineStyle {
|
||||
[SameObject/*, PutForwards=cssText*/] readonly attribute CSSStyleDeclaration style;
|
||||
};
|
|
@ -46,3 +46,4 @@ interface HTMLElement : Element {
|
|||
//readonly attribute boolean? commandChecked;
|
||||
};
|
||||
HTMLElement implements GlobalEventHandlers;
|
||||
HTMLElement implements ElementCSSInlineStyle;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue