mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Add gecko glue for grid-{row,column}-{start,end}
This commit is contained in:
parent
7976640251
commit
6d9aed9ac3
5 changed files with 45 additions and 5 deletions
|
@ -5,7 +5,7 @@
|
||||||
// `data` comes from components/style/properties.mako.rs; see build.rs for more details.
|
// `data` comes from components/style/properties.mako.rs; see build.rs for more details.
|
||||||
|
|
||||||
<%!
|
<%!
|
||||||
from data import to_rust_ident
|
from data import to_rust_ident, to_camel_case
|
||||||
from data import Keyword
|
from data import Keyword
|
||||||
%>
|
%>
|
||||||
<%namespace name="helpers" file="/helpers.mako.rs" />
|
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||||
|
@ -631,8 +631,15 @@ class Corner(object):
|
||||||
self.x_index = 2 * index
|
self.x_index = 2 * index
|
||||||
self.y_index = 2 * index + 1
|
self.y_index = 2 * index + 1
|
||||||
|
|
||||||
|
class GridLine(object):
|
||||||
|
def __init__(self, name):
|
||||||
|
self.ident = "grid-" + name.lower()
|
||||||
|
self.name = self.ident.replace('-', '_')
|
||||||
|
self.gecko = "m" + to_camel_case(self.ident)
|
||||||
|
|
||||||
SIDES = [Side("Top", 0), Side("Right", 1), Side("Bottom", 2), Side("Left", 3)]
|
SIDES = [Side("Top", 0), Side("Right", 1), Side("Bottom", 2), Side("Left", 3)]
|
||||||
CORNERS = [Corner("TOP_LEFT", 0), Corner("TOP_RIGHT", 1), Corner("BOTTOM_RIGHT", 2), Corner("BOTTOM_LEFT", 3)]
|
CORNERS = [Corner("TOP_LEFT", 0), Corner("TOP_RIGHT", 1), Corner("BOTTOM_RIGHT", 2), Corner("BOTTOM_LEFT", 3)]
|
||||||
|
GRID_LINES = map(GridLine, ["row-start", "row-end", "column-start", "column-end"])
|
||||||
%>
|
%>
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -822,7 +829,7 @@ fn static_assert() {
|
||||||
% endfor
|
% endfor
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
<% skip_position_longhands = " ".join(x.ident for x in SIDES) %>
|
<% skip_position_longhands = " ".join(x.ident for x in SIDES + GRID_LINES) %>
|
||||||
<%self:impl_trait style_struct_name="Position"
|
<%self:impl_trait style_struct_name="Position"
|
||||||
skip_longhands="${skip_position_longhands} z-index box-sizing order">
|
skip_longhands="${skip_position_longhands} z-index box-sizing order">
|
||||||
|
|
||||||
|
@ -884,6 +891,27 @@ fn static_assert() {
|
||||||
|
|
||||||
${impl_simple_copy('order', 'mOrder')}
|
${impl_simple_copy('order', 'mOrder')}
|
||||||
|
|
||||||
|
% for value in GRID_LINES:
|
||||||
|
pub fn set_${value.name}(&mut self, v: longhands::${value.name}::computed_value::T) {
|
||||||
|
use nsstring::nsCString;
|
||||||
|
use gecko_bindings::structs::{nsStyleGridLine_kMinLine, nsStyleGridLine_kMaxLine};
|
||||||
|
|
||||||
|
let ident = v.ident.unwrap_or(String::new());
|
||||||
|
self.gecko.${value.gecko}.mLineName.assign_utf8(&nsCString::from(&*ident));
|
||||||
|
self.gecko.${value.gecko}.mHasSpan = v.is_span;
|
||||||
|
self.gecko.${value.gecko}.mInteger = v.integer.map(|i| {
|
||||||
|
// clamping the integer between a range
|
||||||
|
cmp::max(nsStyleGridLine_kMinLine, cmp::min(i, nsStyleGridLine_kMaxLine))
|
||||||
|
}).unwrap_or(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn copy_${value.name}_from(&mut self, other: &Self) {
|
||||||
|
self.gecko.${value.gecko}.mHasSpan = other.gecko.${value.gecko}.mHasSpan;
|
||||||
|
self.gecko.${value.gecko}.mInteger = other.gecko.${value.gecko}.mInteger;
|
||||||
|
self.gecko.${value.gecko}.mLineName.assign(&other.gecko.${value.gecko}.mLineName);
|
||||||
|
}
|
||||||
|
% endfor
|
||||||
|
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
<% skip_outline_longhands = " ".join("outline-style outline-width".split() +
|
<% skip_outline_longhands = " ".join("outline-style outline-width".split() +
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
values = """inline block inline-block
|
values = """inline block inline-block
|
||||||
table inline-table table-row-group table-header-group table-footer-group
|
table inline-table table-row-group table-header-group table-footer-group
|
||||||
table-row table-column-group table-column table-cell table-caption
|
table-row table-column-group table-column table-cell table-caption
|
||||||
list-item flex
|
list-item flex none
|
||||||
none
|
|
||||||
""".split()
|
""".split()
|
||||||
if product == "gecko":
|
if product == "gecko":
|
||||||
values += """inline-flex grid inline-grid ruby ruby-base ruby-base-container
|
values += """inline-flex grid inline-grid ruby ruby-base ruby-base-container
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
<%! from data import to_rust_ident %>
|
||||||
<%namespace name="helpers" file="/helpers.mako.rs" />
|
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||||
<% from data import ALL_SIZES, PHYSICAL_SIDES, LOGICAL_SIDES %>
|
<% from data import ALL_SIZES, PHYSICAL_SIDES, LOGICAL_SIDES %>
|
||||||
|
|
||||||
|
@ -180,3 +181,14 @@ ${helpers.single_keyword("box-sizing",
|
||||||
// https://drafts.csswg.org/css-images-3/
|
// https://drafts.csswg.org/css-images-3/
|
||||||
${helpers.single_keyword("object-fit", "fill contain cover none scale-down",
|
${helpers.single_keyword("object-fit", "fill contain cover none scale-down",
|
||||||
products="gecko", animatable=False)}
|
products="gecko", animatable=False)}
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-grid/#propdef-grid-row-start
|
||||||
|
<% grid_longhands = ["grid-row-start", "grid-row-end", "grid-column-start", "grid-column-end"] %>
|
||||||
|
|
||||||
|
% for longhand in grid_longhands:
|
||||||
|
${helpers.predefined_type("%s" % longhand,
|
||||||
|
"GridLine",
|
||||||
|
"Default::default()",
|
||||||
|
animatable=False,
|
||||||
|
products="gecko")}
|
||||||
|
% endfor
|
||||||
|
|
|
@ -14,7 +14,7 @@ pub use cssparser::Color as CSSColor;
|
||||||
pub use self::image::{EndingShape as GradientShape, Gradient, GradientKind, Image};
|
pub use self::image::{EndingShape as GradientShape, Gradient, GradientKind, Image};
|
||||||
pub use self::image::{LengthOrKeyword, LengthOrPercentageOrKeyword};
|
pub use self::image::{LengthOrKeyword, LengthOrPercentageOrKeyword};
|
||||||
pub use super::{Either, None_};
|
pub use super::{Either, None_};
|
||||||
pub use super::specified::{Angle, BorderStyle, Time, UrlOrNone};
|
pub use super::specified::{Angle, BorderStyle, GridLine, Time, UrlOrNone};
|
||||||
pub use super::specified::url::UrlExtraData;
|
pub use super::specified::url::UrlExtraData;
|
||||||
pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};
|
pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||||
pub use self::length::{LengthOrPercentageOrAutoOrContent, LengthOrPercentageOrNone, LengthOrNone};
|
pub use self::length::{LengthOrPercentageOrAutoOrContent, LengthOrPercentageOrNone, LengthOrNone};
|
||||||
|
|
|
@ -16,6 +16,7 @@ use super::{CSSFloat, HasViewportPercentage, NoViewportPercentage, Either, None_
|
||||||
use super::computed::{ComputedValueAsSpecified, Context, ToComputedValue};
|
use super::computed::{ComputedValueAsSpecified, Context, ToComputedValue};
|
||||||
use super::computed::Shadow as ComputedShadow;
|
use super::computed::Shadow as ComputedShadow;
|
||||||
|
|
||||||
|
pub use self::grid::GridLine;
|
||||||
pub use self::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
|
pub use self::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
|
||||||
pub use self::image::{GradientKind, HorizontalDirection, Image, LengthOrKeyword, LengthOrPercentageOrKeyword};
|
pub use self::image::{GradientKind, HorizontalDirection, Image, LengthOrKeyword, LengthOrPercentageOrKeyword};
|
||||||
pub use self::image::{SizeKeyword, VerticalDirection};
|
pub use self::image::{SizeKeyword, VerticalDirection};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue