servo: Merge #14399 - Support offset- logical properties (from Manishearth:feat-offset-logical); r=SimonSapin
authorManish Goregaokar <manishsmail@gmail.com>
Tue, 29 Nov 2016 09:27:42 -0800
changeset 340248 114b6d62d4f684d2e8807e0152705e8e4de4404b
parent 340247 f660e380f71804918aaf3c231546d0666a948af4
child 340249 8b9c40c07fb9aa87c86ca0513e99f02d8735c1bc
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersSimonSapin
servo: Merge #14399 - Support offset- logical properties (from Manishearth:feat-offset-logical); r=SimonSapin I didn't realize that these map to the top/left/bottom/right physical properties. We can just implement them. r? @SimonSapin Source-Repo: https://github.com/servo/servo Source-Revision: a88487f96a5e17dfbaf02acd3a2af49456013b6e
servo/components/script/dom/webidls/CSSStyleDeclaration.webidl
servo/components/style/properties/helpers.mako.rs
servo/components/style/properties/longhand/position.mako.rs
--- a/servo/components/script/dom/webidls/CSSStyleDeclaration.webidl
+++ b/servo/components/script/dom/webidls/CSSStyleDeclaration.webidl
@@ -316,16 +316,24 @@ partial interface CSSStyleDeclaration {
 
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString pointerEvents;
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString pointer-events;
 
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString top;
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString right;
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString left;
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString bottom;
+  [SetterThrows, TreatNullAs=EmptyString] attribute DOMString offset-block-start;
+  [SetterThrows, TreatNullAs=EmptyString] attribute DOMString offsetBlockStart;
+  [SetterThrows, TreatNullAs=EmptyString] attribute DOMString offset-block-end;
+  [SetterThrows, TreatNullAs=EmptyString] attribute DOMString offsetBlockEnd;
+  [SetterThrows, TreatNullAs=EmptyString] attribute DOMString offset-inline-start;
+  [SetterThrows, TreatNullAs=EmptyString] attribute DOMString offsetInlineStart;
+  [SetterThrows, TreatNullAs=EmptyString] attribute DOMString offset-inline-end;
+  [SetterThrows, TreatNullAs=EmptyString] attribute DOMString offsetInlineEnd;
 
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString height;
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString minHeight;
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString min-height;
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString maxHeight;
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString max-height;
 
   [SetterThrows, TreatNullAs=EmptyString] attribute DOMString width;
--- a/servo/components/style/properties/helpers.mako.rs
+++ b/servo/components/style/properties/helpers.mako.rs
@@ -558,37 +558,39 @@
         side = None
         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]
+        def phys_ident(side, phy_side):
+            return to_rust_ident(name.replace(side, phy_side).replace("offset-", ""))
     %>
     % 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(physical_ident=to_rust_ident(name.replace(side, phy_side)))}
+                    ${caller.inner(physical_ident=phys_ident(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])))}
+            ${caller.inner(physical_ident=phys_ident(size, physical_size[1]))}
         } else {
-            ${caller.inner(physical_ident=to_rust_ident(name.replace(size, physical_size[0])))}
+            ${caller.inner(physical_ident=phys_ident(size, physical_size[0]))}
         }
     % else:
         <% raise Exception("Don't know what to do with logical property %s" % name) %>
     % endif
 </%def>
 
 <%def name="logical_setter(name, need_clone=False)">
     pub fn set_${to_rust_ident(name)}(&mut self,
--- a/servo/components/style/properties/longhand/position.mako.rs
+++ b/servo/components/style/properties/longhand/position.mako.rs
@@ -1,22 +1,29 @@
 /* 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/. */
 
 <%namespace name="helpers" file="/helpers.mako.rs" />
-<% from data import ALL_SIZES %>
+<% from data import ALL_SIZES, PHYSICAL_SIDES, LOGICAL_SIDES %>
 
 <% data.new_style_struct("Position", inherited=False) %>
 
-% for side in ["top", "right", "bottom", "left"]:
+// "top" / "left" / "bottom" / "right"
+% for side in PHYSICAL_SIDES:
     ${helpers.predefined_type(side, "LengthOrPercentageOrAuto",
                               "computed::LengthOrPercentageOrAuto::Auto",
                               animatable=True)}
 % endfor
+// offset-* logical properties, map to "top" / "left" / "bottom" / "right"
+% for side in LOGICAL_SIDES:
+    ${helpers.predefined_type("offset-" + side, "LengthOrPercentageOrAuto",
+                              "computed::LengthOrPercentageOrAuto::Auto",
+                              animatable=True, logical=True)}
+% endfor
 
 <%helpers:longhand name="z-index" animatable="True">
     use values::NoViewportPercentage;
     use values::computed::ComputedValueAsSpecified;
 
     impl ComputedValueAsSpecified for SpecifiedValue {}
     impl NoViewportPercentage for SpecifiedValue {}
     pub type SpecifiedValue = computed_value::T;