diff options
-rw-r--r-- | components/script/dom/webidls/CSSStyleDeclaration.webidl | 12 | ||||
-rw-r--r-- | components/style/properties/data.py | 4 | ||||
-rw-r--r-- | components/style/properties/helpers.mako.rs | 34 | ||||
-rw-r--r-- | components/style/properties/longhand/position.mako.rs | 58 |
4 files changed, 64 insertions, 44 deletions
diff --git a/components/script/dom/webidls/CSSStyleDeclaration.webidl b/components/script/dom/webidls/CSSStyleDeclaration.webidl index 3cc11418150..3424e5593a6 100644 --- a/components/script/dom/webidls/CSSStyleDeclaration.webidl +++ b/components/script/dom/webidls/CSSStyleDeclaration.webidl @@ -333,6 +333,18 @@ partial interface CSSStyleDeclaration { [SetterThrows, TreatNullAs=EmptyString] attribute DOMString min-width; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString maxWidth; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString max-width; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString block-size; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString blockSize; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString inline-size; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString inlineSize; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString max-block-size; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString maxBlockSize; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString max-inline-size; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString maxInlineSize; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString min-block-size; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString minBlockSize; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString min-inline-size; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString minInlineSize; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString zIndex; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString z-index; diff --git a/components/style/properties/data.py b/components/style/properties/data.py index f8ad6e83283..afddf0f4bb7 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -6,8 +6,12 @@ import re PHYSICAL_SIDES = ["top", "left", "bottom", "right"] LOGICAL_SIDES = ["block-start", "block-end", "inline-start", "inline-end"] +PHYSICAL_SIZES = ["width", "height"] +LOGICAL_SIZES = ["block-size", "inline-size"] + # bool is True when logical ALL_SIDES = [(side, False) for side in PHYSICAL_SIDES] + [(side, True) for side in LOGICAL_SIDES] +ALL_SIZES = [(size, False) for size in PHYSICAL_SIZES] + [(size, True) for size in LOGICAL_SIZES] def to_rust_ident(name): diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index d022e2c310f..ba85b4dbaac 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -2,7 +2,7 @@ * 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/. */ -<%! from data import Keyword, to_rust_ident, to_camel_case, LOGICAL_SIDES, PHYSICAL_SIDES %> +<%! from data import Keyword, to_rust_ident, to_camel_case, LOGICAL_SIDES, PHYSICAL_SIDES, LOGICAL_SIZES %> <%def name="longhand(name, **kwargs)"> <%call expr="raw_longhand(name, **kwargs)"> @@ -615,19 +615,35 @@ <%def name="logical_setter_helper(name)"> <% side = None - maybe_side = [side for side in LOGICAL_SIDES if side in name] + size = None + maybe_side = [s for s in LOGICAL_SIDES if s in name] + maybe_size = [s for s in LOGICAL_SIZES if s in name] if len(maybe_side) == 1: side = maybe_side[0] + elif len(maybe_size) == 1: + size = maybe_size[0] %> % if side is not None: use logical_geometry::PhysicalSide; match wm.${to_rust_ident(side)}_physical_side() { % for phy_side in PHYSICAL_SIDES: PhysicalSide::${phy_side.title()} => { - ${caller.inner(side_ident=to_rust_ident(name.replace(side, phy_side)))} + ${caller.inner(physical_ident=to_rust_ident(name.replace(side, phy_side)))} } % endfor } + % elif size is not None: + <% + # (horizontal, vertical) + physical_size = ("height", "width") + if size == "inline-size": + physical_size = ("width", "height") + %> + if wm.is_vertical() { + ${caller.inner(physical_ident=to_rust_ident(name.replace(size, physical_size[1])))} + } else { + ${caller.inner(physical_ident=to_rust_ident(name.replace(size, physical_size[0])))} + } % else: <% raise Exception("Don't know what to do with logical property %s" % name) %> % endif @@ -638,15 +654,15 @@ v: longhands::${to_rust_ident(name)}::computed_value::T, wm: WritingMode) { <%self:logical_setter_helper name="${name}"> - <%def name="inner(side_ident)"> - self.set_${side_ident}(v) + <%def name="inner(physical_ident)"> + self.set_${physical_ident}(v) </%def> </%self:logical_setter_helper> } pub fn copy_${to_rust_ident(name)}_from(&mut self, other: &Self, wm: WritingMode) { <%self:logical_setter_helper name="${name}"> - <%def name="inner(side_ident)"> - self.copy_${side_ident}_from(other) + <%def name="inner(physical_ident)"> + self.copy_${physical_ident}_from(other) </%def> </%self:logical_setter_helper> } @@ -654,8 +670,8 @@ pub fn clone_${to_rust_ident(name)}(&self, wm: WritingMode) -> longhands::${to_rust_ident(name)}::computed_value::T { <%self:logical_setter_helper name="${name}"> - <%def name="inner(side_ident)"> - self.clone_${side_ident}() + <%def name="inner(physical_ident)"> + self.clone_${physical_ident}() </%def> </%self:logical_setter_helper> } diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index a3166ea8238..eed244eb5a2 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> +<% from data import ALL_SIZES %> <% data.new_style_struct("Position", inherited=False) %> @@ -137,41 +138,28 @@ ${helpers.predefined_type("flex-basis", "computed::LengthOrPercentageOrAutoOrContent::Auto", animatable=False)} -${helpers.predefined_type("width", - "LengthOrPercentageOrAuto", - "computed::LengthOrPercentageOrAuto::Auto", - "parse_non_negative", - animatable=True)} - -${helpers.predefined_type("height", - "LengthOrPercentageOrAuto", - "computed::LengthOrPercentageOrAuto::Auto", - "parse_non_negative", - animatable=True)} - -${helpers.predefined_type("min-width", - "LengthOrPercentage", - "computed::LengthOrPercentage::Length(Au(0))", - "parse_non_negative", - animatable=True)} - -${helpers.predefined_type("max-width", - "LengthOrPercentageOrNone", - "computed::LengthOrPercentageOrNone::None", - "parse_non_negative", - animatable=True)} - -${helpers.predefined_type("min-height", - "LengthOrPercentage", - "computed::LengthOrPercentage::Length(Au(0))", - "parse_non_negative", - animatable=True)} - -${helpers.predefined_type("max-height", - "LengthOrPercentageOrNone", - "computed::LengthOrPercentageOrNone::None", - "parse_non_negative", - animatable=True)} +% for (size, logical) in ALL_SIZES: + // width, height, block-size, inline-size + ${helpers.predefined_type("%s" % size, + "LengthOrPercentageOrAuto", + "computed::LengthOrPercentageOrAuto::Auto", + "parse_non_negative", + animatable=True, logical = logical)} + + // min-width, min-height, min-block-size, min-inline-size + ${helpers.predefined_type("min-%s" % size, + "LengthOrPercentage", + "computed::LengthOrPercentage::Length(Au(0))", + "parse_non_negative", + animatable=True, logical = logical)} + + // max-width, max-height, max-block-size, max-inline-size + ${helpers.predefined_type("max-%s" % size, + "LengthOrPercentageOrNone", + "computed::LengthOrPercentageOrNone::None", + "parse_non_negative", + animatable=True, logical = logical)} +% endfor ${helpers.single_keyword("box-sizing", "content-box border-box", |