Address review comments.

This commit is contained in:
Josh Matthews 2014-12-18 12:38:07 -05:00
parent c8557c44a9
commit 6bffc10445
3 changed files with 82 additions and 221 deletions

View file

@ -26,19 +26,16 @@ pub struct CSSStyleDeclaration {
owner: JS<HTMLElement>, owner: JS<HTMLElement>,
} }
macro_rules! css_getter( macro_rules! css_properties(
( $idlattr:ident, $cssprop:expr ) => ( ( $([$getter:ident, $setter:ident, $cssprop:expr]),* ) => (
fn $idlattr(self) -> DOMString { $(
fn $getter(self) -> DOMString {
self.GetPropertyValue($cssprop.to_string()) self.GetPropertyValue($cssprop.to_string())
} }
); fn $setter(self, value: DOMString) {
)
macro_rules! css_setter(
( $fnname:ident, $cssprop:expr ) => (
fn $fnname(self, value: DOMString) {
self.SetPropertyValue($cssprop.to_string(), value).unwrap(); self.SetPropertyValue($cssprop.to_string(), value).unwrap();
} }
)*
); );
) )
@ -255,212 +252,77 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
rval rval
} }
css_getter!(Color, "color") css_properties!(
css_setter!(SetColor, "color") [Color, SetColor, "color"],
[Background, SetBackground, "background"],
css_getter!(Background, "background") [BackgroundColor, SetBackgroundColor, "background-color"],
css_setter!(SetBackground, "background") [BackgroundPosition, SetBackgroundPosition, "background-position"],
[BackgroundImage, SetBackgroundImage, "background-image"],
css_getter!(BackgroundColor, "background-color") [BackgroundRepeat, SetBackgroundRepeat, "background-repeat"],
css_setter!(SetBackgroundColor, "background-color") [BackgroundAttachment, SetBackgroundAttachment, "background-attachment"],
[Border, SetBorder, "border"],
css_getter!(BackgroundPosition, "background-position") [BorderColor, SetBorderColor, "border-color"],
css_setter!(SetBackgroundPosition, "background-position") [BorderStyle, SetBorderStyle, "border-style"],
[BorderWidth, SetBorderWidth, "border-width"],
css_getter!(BackgroundImage, "background-image") [BorderBottom, SetBorderBottom, "border-bottom"],
css_setter!(SetBackgroundImage, "background-image") [BorderBottomColor, SetBorderBottomColor, "border-bottom-color"],
[BorderBottomStyle, SetBorderBottomStyle, "border-bottom-style"],
css_getter!(BackgroundRepeat, "background-repeat") [BorderBottomWidth, SetBorderBottomWidth, "border-bottom-width"],
css_setter!(SetBackgroundRepeat, "background-repeat") [BorderLeft, SetBorderLeft, "border-left"],
[BorderLeftColor, SetBorderLeftColor, "border-left-color"],
css_getter!(BackgroundAttachment, "background-attachment") [BorderLeftStyle, SetBorderLeftStyle, "border-left-style"],
css_setter!(SetBackgroundAttachment, "background-attachment") [BorderLeftWidth, SetBorderLeftWidth, "border-left-width"],
[BorderRight, SetBorderRight, "border-right"],
css_getter!(Border, "border") [BorderRightColor, SetBorderRightColor, "border-right-color"],
css_setter!(SetBorder, "border") [BorderRightStyle, SetBorderRightStyle, "border-right-style"],
[BorderRightWidth, SetBorderRightWidth, "border-right-width"],
css_getter!(BorderColor, "border-color") [BorderTop, SetBorderTop, "border-top"],
css_setter!(SetBorderColor, "border-color") [BorderTopColor, SetBorderTopColor, "border-top-color"],
[BorderTopStyle, SetBorderTopStyle, "border-top-style"],
css_getter!(BorderStyle, "border-style") [BorderTopWidth, SetBorderTopWidth, "border-top-width"],
css_setter!(SetBorderStyle, "border-style") [Content, SetContent, "content"],
[Display, SetDisplay, "display"],
css_getter!(BorderWidth, "border-width") [Width, SetWidth, "width"],
css_setter!(SetBorderWidth, "border-width") [MinWidth, SetMinWidth, "min-width"],
[MaxWidth, SetMaxWidth, "max-width"],
css_getter!(BorderBottom, "border-bottom") [Height, SetHeight, "height"],
css_setter!(SetBorderBottom, "border-bottom") [MinHeight, SetMinHeight, "min-height"],
[MaxHeight, SetMaxHeight, "max-height"],
css_getter!(BorderBottomColor, "border-bottom-color") [Clear, SetClear, "clear"],
css_setter!(SetBorderBottomColor, "border-bottom-color") [Direction, SetDirection, "direction"],
[LineHeight, SetLineHeight, "line-height"],
css_getter!(BorderBottomStyle, "border-bottom-style") [VerticalAlign, SetVerticalAlign, "vertical-align"],
css_setter!(SetBorderBottomStyle, "border-bottom-style") [Visibility, SetVisibility, "visibility"],
[Overflow, SetOverflow, "overflow"],
css_getter!(BorderBottomWidth, "border-bottom-width") [TableLayout, SetTableLayout, "table-layout"],
css_setter!(SetBorderBottomWidth, "border-bottom-width") [WhiteSpace, SetWhiteSpace, "white-space"],
[WritingMode, SetWritingMode, "writing-mode"],
css_getter!(BorderLeft, "border-left") [TextAlign, SetTextAlign, "text-align"],
css_setter!(SetBorderLeft, "border-left") [TextDecoration, SetTextDecoration, "text-decoration"],
[TextOrientation, SetTextOrientation, "text-orientation"],
css_getter!(BorderLeftColor, "border-left-color") [Font, SetFont, "font"],
css_setter!(SetBorderLeftColor, "border-left-color") [FontFamily, SetFontFamily, "font-family"],
[FontSize, SetFontSize, "font-size"],
css_getter!(BorderLeftStyle, "border-left-style") [FontStyle, SetFontStyle, "font-style"],
css_setter!(SetBorderLeftStyle, "border-left-style") [FontVariant, SetFontVariant, "font-variant"],
[FontWeight, SetFontWeight, "font-weight"],
css_getter!(BorderLeftWidth, "border-left-width") [Margin, SetMargin, "margin"],
css_setter!(SetBorderLeftWidth, "border-left-width") [MarginBottom, SetMarginBottom, "margin-bottom"],
[MarginLeft, SetMarginLeft, "margin-left"],
css_getter!(BorderRight, "border-right") [MarginRight, SetMarginRight, "margin-right"],
css_setter!(SetBorderRight, "border-right") [MarginTop, SetMarginTop, "margin-top"],
[Padding, SetPadding, "padding"],
css_getter!(BorderRightColor, "border-right-color") [PaddingBottom, SetPaddingBottom, "padding-bottom"],
css_setter!(SetBorderRightColor, "border-right-color") [PaddingLeft, SetPaddingLeft, "padding-left"],
[PaddingRight, SetPaddingRight, "padding-right"],
css_getter!(BorderRightStyle, "border-right-style") [PaddingTop, SetPaddingTop, "padding-top"],
css_setter!(SetBorderRightStyle, "border-right-style") [Position, SetPosition, "position"],
[Bottom, SetBottom, "bottom"],
css_getter!(BorderRightWidth, "border-right-width") [Left, SetLeft, "left"],
css_setter!(SetBorderRightWidth, "border-right-width") [Right, SetRight, "right"],
[Top, SetTop, "top"],
css_getter!(BorderTop, "border-top") [ZIndex, SetZIndex, "z-index"]
css_setter!(SetBorderTop, "border-top") )
css_getter!(BorderTopColor, "border-top-color")
css_setter!(SetBorderTopColor, "border-top-color")
css_getter!(BorderTopStyle, "border-top-style")
css_setter!(SetBorderTopStyle, "border-top-style")
css_getter!(BorderTopWidth, "border-top-width")
css_setter!(SetBorderTopWidth, "border-top-width")
css_getter!(Content, "content")
css_setter!(SetContent, "content")
css_getter!(Display, "display")
css_setter!(SetDisplay, "display")
css_getter!(Width, "width")
css_setter!(SetWidth, "width")
css_getter!(MinWidth, "min-width")
css_setter!(SetMinWidth, "min-width")
css_getter!(MaxWidth, "max-width")
css_setter!(SetMaxWidth, "max-width")
css_getter!(Height, "height")
css_setter!(SetHeight, "height")
css_getter!(MinHeight, "min-height")
css_setter!(SetMinHeight, "min-height")
css_getter!(MaxHeight, "max-height")
css_setter!(SetMaxHeight, "max-height")
css_getter!(Clear, "clear")
css_setter!(SetClear, "clear")
css_getter!(Direction, "direction")
css_setter!(SetDirection, "direction")
css_getter!(LineHeight, "line-height")
css_setter!(SetLineHeight, "line-height")
css_getter!(VerticalAlign, "vertical-align")
css_setter!(SetVerticalAlign, "vertical-align")
css_getter!(Visibility, "visibility")
css_setter!(SetVisibility, "visibility")
css_getter!(Overflow, "overflow")
css_setter!(SetOverflow, "overflow")
css_getter!(TableLayout, "table-layout")
css_setter!(SetTableLayout, "table-layout")
css_getter!(WhiteSpace, "white-space")
css_setter!(SetWhiteSpace, "white-space")
css_getter!(WritingMode, "writing-mode")
css_setter!(SetWritingMode, "writing-mode")
css_getter!(TextAlign, "text-align")
css_setter!(SetTextAlign, "text-align")
css_getter!(TextDecoration, "text-decoration")
css_setter!(SetTextDecoration, "text-decoration")
css_getter!(TextOrientation, "text-orientation")
css_setter!(SetTextOrientation, "text-orientation")
css_getter!(Font, "font")
css_setter!(SetFont, "font")
css_getter!(FontFamily, "font-family")
css_setter!(SetFontFamily, "font-family")
css_getter!(FontSize, "font-size")
css_setter!(SetFontSize, "font-size")
css_getter!(FontStyle, "font-style")
css_setter!(SetFontStyle, "font-style")
css_getter!(FontVariant, "font-variant")
css_setter!(SetFontVariant, "font-variant")
css_getter!(FontWeight, "font-weight")
css_setter!(SetFontWeight, "font-weight")
css_getter!(Margin, "margin")
css_setter!(SetMargin, "margin")
css_getter!(MarginBottom, "margin-bottom")
css_setter!(SetMarginBottom, "margin-bottom")
css_getter!(MarginLeft, "margin-left")
css_setter!(SetMarginLeft, "margin-left")
css_getter!(MarginRight, "margin-right")
css_setter!(SetMarginRight, "margin-right")
css_getter!(MarginTop, "margin-top")
css_setter!(SetMarginTop, "margin-top")
css_getter!(Padding, "padding")
css_setter!(SetPadding, "padding")
css_getter!(PaddingBottom, "padding-bottom")
css_setter!(SetPaddingBottom, "padding-bottom")
css_getter!(PaddingLeft, "padding-left")
css_setter!(SetPaddingLeft, "padding-left")
css_getter!(PaddingRight, "padding-right")
css_setter!(SetPaddingRight, "padding-right")
css_getter!(PaddingTop, "padding-top")
css_setter!(SetPaddingTop, "padding-top")
css_getter!(Position, "position")
css_setter!(SetPosition, "position")
css_getter!(Top, "top")
css_setter!(SetTop, "top")
css_getter!(Bottom, "bottom")
css_setter!(SetBottom, "bottom")
css_getter!(Left, "left")
css_setter!(SetLeft, "left")
css_getter!(Right, "right")
css_setter!(SetRight, "right")
css_getter!(ZIndex, "z-index")
css_setter!(SetZIndex, "z-index")
} }
impl Reflectable for CSSStyleDeclaration { impl Reflectable for CSSStyleDeclaration {

View file

@ -21,6 +21,7 @@ pub mod specified {
use cssparser::ast::*; use cssparser::ast::*;
use parsing_utils::{mod, BufferedIter, ParserIter}; use parsing_utils::{mod, BufferedIter, ParserIter};
use super::{Au, CSSFloat}; use super::{Au, CSSFloat};
#[deriving(Clone, PartialEq)] #[deriving(Clone, PartialEq)]
pub struct CSSColor { pub struct CSSColor {
pub parsed: cssparser::Color, pub parsed: cssparser::Color,

View file

@ -3045,9 +3045,7 @@ pub fn cascade(applicable_declarations: &[DeclarationBlock],
DeclaredValue::SpecifiedValue(ref specified_value) => specified_value.parsed, DeclaredValue::SpecifiedValue(ref specified_value) => specified_value.parsed,
DeclaredValue::Initial => longhands::color::get_initial_value(), DeclaredValue::Initial => longhands::color::get_initial_value(),
DeclaredValue::Inherit => inherited_style.get_color().color.clone(), DeclaredValue::Inherit => inherited_style.get_color().color.clone(),
}; };
//get_specified!(get_color, color, value);
} }
PropertyDeclaration::DisplayDeclaration(ref value) => { PropertyDeclaration::DisplayDeclaration(ref value) => {
context.display = get_specified!(get_box, display, value); context.display = get_specified!(get_box, display, value);