Bug 1507127 - Also move page-break-inside outside of mako. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 15 Nov 2018 08:16:23 +0000
changeset 502980 488a0a90ca916e094358cf9766a8aef648e711a5
parent 502979 f678d3408301ff96414b17c1cd4e20958c6034b2
child 502981 8ee9454879c874c0bd1a3b8788707adb52193eb0
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1507127
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1507127 - Also move page-break-inside outside of mako. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D11876
layout/generic/BlockReflowInput.cpp
layout/generic/nsFrame.cpp
layout/style/ServoBindings.toml
layout/style/ServoCSSPropList.mako.py
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
servo/components/style/cbindgen.toml
servo/components/style/properties/data.py
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/longhands/box.mako.rs
servo/components/style/values/computed/box.rs
servo/components/style/values/computed/mod.rs
servo/components/style/values/specified/box.rs
servo/components/style/values/specified/mod.rs
--- a/layout/generic/BlockReflowInput.cpp
+++ b/layout/generic/BlockReflowInput.cpp
@@ -990,17 +990,17 @@ BlockReflowInput::FlowAndPlaceFloat(nsIF
   }
 
   // We can't use aFloat->ShouldAvoidBreakInside(mReflowInput) here since
   // its mIsTopOfPage may be true even though the float isn't at the
   // top when floatPos.B(wm) > 0.
   if (ContentBSize() != NS_UNCONSTRAINEDSIZE &&
       !mustPlaceFloat &&
       (!mReflowInput.mFlags.mIsTopOfPage || floatPos.B(wm) > 0) &&
-      NS_STYLE_PAGE_BREAK_AVOID == aFloat->StyleDisplay()->mBreakInside &&
+      StyleBreakWithin::Avoid == aFloat->StyleDisplay()->mBreakInside &&
       (!reflowStatus.IsFullyComplete() ||
        aFloat->BSize(wm) + floatMargin.BStartEnd(wm) >
        ContentBEnd() - floatPos.B(wm)) &&
       !aFloat->GetPrevInFlow()) {
     PushFloatPastBreak(aFloat);
     return false;
   }
 
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -9809,17 +9809,17 @@ nsFrame::ConsiderChildOverflow(nsOverflo
   }
 }
 
 bool
 nsFrame::ShouldAvoidBreakInside(const ReflowInput& aReflowInput) const
 {
   const auto* disp = StyleDisplay();
   return !aReflowInput.mFlags.mIsTopOfPage &&
-    NS_STYLE_PAGE_BREAK_AVOID == disp->mBreakInside &&
+    StyleBreakWithin::Avoid == disp->mBreakInside &&
     !(HasAnyStateBits(NS_FRAME_OUT_OF_FLOW) && IsAbsolutelyPositioned(disp)) &&
     !GetPrevInFlow();
 }
 
 /**
  * This function takes a frame that is part of a block-in-inline split,
  * and _if_ that frame is an anonymous block created by an ib split it
  * returns the block's preceding inline.  This is needed because the
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -393,16 +393,17 @@ cbindgen-types = [
     { gecko = "StyleFontDisplay", servo = "font_face::FontDisplay" },
     { gecko = "StyleFontFaceSourceListComponent", servo = "font_face::FontFaceSourceListComponent" },
     { gecko = "StyleFontLanguageOverride", servo = "values::computed::font::FontLanguageOverride" },
     { gecko = "StylePathCommand", servo = "values::specified::svg_path::PathCommand" },
     { gecko = "StyleUnicodeRange", servo = "cssparser::UnicodeRange" },
     { gecko = "StyleOverflowWrap", servo = "values::computed::OverflowWrap" },
     { gecko = "StyleUserSelect", servo = "values::computed::UserSelect" },
     { gecko = "StyleBreakBetween", servo = "values::computed::BreakBetween" },
+    { gecko = "StyleBreakWithin", servo = "values::computed::BreakWithin" },
 ]
 
 mapped-generic-types = [
     { generic = true, gecko = "mozilla::RustCell", servo = "::std::cell::Cell" },
     { generic = false, gecko = "ServoNodeData", servo = "AtomicRefCell<ElementData>" },
     { generic = false, gecko = "mozilla::ServoWritingMode", servo = "::logical_geometry::WritingMode" },
     { generic = false, gecko = "mozilla::ServoCustomPropertiesMap", servo = "Option<::servo_arc::Arc<::custom_properties::CustomPropertiesMap>>" },
     { generic = false, gecko = "mozilla::ServoRuleNode", servo = "Option<::rule_tree::StrongRuleNode>" },
--- a/layout/style/ServoCSSPropList.mako.py
+++ b/layout/style/ServoCSSPropList.mako.py
@@ -66,16 +66,17 @@ def method(prop):
 # moved or perhaps using a blacklist for the ones with non-layout-dependence
 # but other non-trivial dependence like scrollbar colors.
 SERIALIZED_PREDEFINED_TYPES = [
     "Appearance",
     "BackgroundRepeat",
     "BackgroundSize",
     "BorderImageRepeat",
     "BreakBetween",
+    "BreakWithin",
     "Clear",
     "ClipRectOrAuto",
     "Color",
     "Content",
     "CounterIncrement",
     "CounterReset",
     "FillRule",
     "Float",
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -3379,17 +3379,17 @@ nsStyleDisplay::nsStyleDisplay(const nsP
   : mDisplay(StyleDisplay::Inline)
   , mOriginalDisplay(StyleDisplay::Inline)
   , mContain(NS_STYLE_CONTAIN_NONE)
   , mAppearance(StyleAppearance::None)
   , mPosition(NS_STYLE_POSITION_STATIC)
   , mFloat(StyleFloat::None)
   , mOriginalFloat(StyleFloat::None)
   , mBreakType(StyleClear::None)
-  , mBreakInside(NS_STYLE_PAGE_BREAK_AUTO)
+  , mBreakInside(StyleBreakWithin::Auto)
   , mPageBreakBefore(StyleBreakBetween::Auto)
   , mPageBreakAfter(StyleBreakBetween::Auto)
   , mOverflowX(NS_STYLE_OVERFLOW_VISIBLE)
   , mOverflowY(NS_STYLE_OVERFLOW_VISIBLE)
   , mOverflowClipBoxBlock(NS_STYLE_OVERFLOW_CLIP_BOX_PADDING_BOX)
   , mOverflowClipBoxInline(NS_STYLE_OVERFLOW_CLIP_BOX_PADDING_BOX)
   , mResize(NS_STYLE_RESIZE_NONE)
   , mOrient(StyleOrient::Inline)
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2009,17 +2009,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   mozilla::StyleAppearance mAppearance;
   uint8_t mPosition;            // NS_STYLE_POSITION_*
 
   mozilla::StyleFloat mFloat;
   // Save mFloat for position:absolute/fixed; otherwise equal to mFloat.
   mozilla::StyleFloat mOriginalFloat;
 
   mozilla::StyleClear mBreakType;
-  uint8_t mBreakInside;         // NS_STYLE_PAGE_BREAK_AUTO/AVOID
+  mozilla::StyleBreakWithin mBreakInside;
   mozilla::StyleBreakBetween mPageBreakBefore;
   mozilla::StyleBreakBetween mPageBreakAfter;
   uint8_t mOverflowX;           // NS_STYLE_OVERFLOW_*
   uint8_t mOverflowY;           // NS_STYLE_OVERFLOW_*
   uint8_t mOverflowClipBoxBlock;     // NS_STYLE_OVERFLOW_CLIP_BOX_*
   uint8_t mOverflowClipBoxInline;    // NS_STYLE_OVERFLOW_CLIP_BOX_*
   uint8_t mResize;              // NS_STYLE_RESIZE_*
   mozilla::StyleOrient mOrient;
--- a/servo/components/style/cbindgen.toml
+++ b/servo/components/style/cbindgen.toml
@@ -35,16 +35,17 @@ derive_eq = true
 [enum]
 derive_helper_methods = true
 
 [export]
 prefix = "Style"
 include = [
   "Appearance",
   "BreakBetween",
+  "BreakWithin",
   "ComputedFontStretchRange",
   "ComputedFontStyleDescriptor",
   "ComputedFontWeightRange",
   "ComputedTimingFunction",
   "Display",
   "DisplayMode",
   "FillRule",
   "FontDisplay",
--- a/servo/components/style/properties/data.py
+++ b/servo/components/style/properties/data.py
@@ -287,16 +287,17 @@ class Longhand(object):
             return False
         if self.predefined_type:
             return self.predefined_type in {
                 "AlignContent",
                 "AlignItems",
                 "AlignSelf",
                 "Appearance",
                 "BreakBetween",
+                "BreakWithin",
                 "BackgroundRepeat",
                 "BorderImageRepeat",
                 "BorderStyle",
                 "Clear",
                 "ColumnCount",
                 "Contain",
                 "Display",
                 "FillRule",
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -1392,16 +1392,17 @@ impl Clone for ${style_struct.gecko_stru
 <%
     style_struct = next(x for x in data.style_structs if x.name == style_struct_name)
     longhands = [x for x in style_struct.longhands
                 if not (skip_longhands == "*" or x.name in skip_longhands.split())]
 
     # Types used with predefined_type()-defined properties that we can auto-generate.
     predefined_types = {
         "BreakBetween": impl_simple,
+        "BreakWithin": impl_simple,
         "Color": impl_color,
         "ColorOrAuto": impl_color,
         "GreaterThanOrEqualToOneNumber": impl_simple,
         "Integer": impl_simple,
         "length::LengthOrAuto": impl_style_coord,
         "length::LengthOrNormal": impl_style_coord,
         "length::NonNegativeLengthOrAuto": impl_style_coord,
         "length::NonNegativeLengthOrPercentageOrNormal": impl_style_coord,
--- a/servo/components/style/properties/longhands/box.mako.rs
+++ b/servo/components/style/properties/longhands/box.mako.rs
@@ -452,22 +452,23 @@
     "BreakBetween",
     "computed::BreakBetween::Auto",
     needs_context=False,
     products="gecko",
     spec="https://drafts.csswg.org/css2/page.html#propdef-page-break-before",
     animation_value_type="discrete",
 )}
 
-${helpers.single_keyword(
+${helpers.predefined_type(
     "page-break-inside",
-    "auto avoid",
+    "BreakWithin",
+    "computed::BreakWithin::Auto",
+    gecko_ffi_name="mBreakInside",
+    needs_context=False,
     products="gecko",
-    gecko_ffi_name="mBreakInside",
-    gecko_constant_prefix="NS_STYLE_PAGE_BREAK",
     spec="https://drafts.csswg.org/css2/page.html#propdef-page-break-inside",
     animation_value_type="discrete",
 )}
 
 // CSS Basic User Interface Module Level 3
 // http://dev.w3.org/csswg/css-ui
 //
 // This is APPLIES_TO_PLACEHOLDER so we can override, in the UA sheet, the
--- a/servo/components/style/values/computed/box.rs
+++ b/servo/components/style/values/computed/box.rs
@@ -6,17 +6,17 @@
 
 use crate::values::computed::length::{LengthOrPercentage, NonNegativeLength};
 use crate::values::computed::{Context, Number, ToComputedValue};
 use crate::values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
 use crate::values::generics::box_::Perspective as GenericPerspective;
 use crate::values::generics::box_::VerticalAlign as GenericVerticalAlign;
 use crate::values::specified::box_ as specified;
 
-pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween};
+pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween, BreakWithin};
 pub use crate::values::specified::box_::{Contain, Display, OverflowClipBox};
 pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat};
 pub use crate::values::specified::box_::{OverscrollBehavior, ScrollSnapType};
 pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange};
 
 /// A computed value for the `vertical-align` property.
 pub type VerticalAlign = GenericVerticalAlign<LengthOrPercentage>;
 
--- a/servo/components/style/values/computed/mod.rs
+++ b/servo/components/style/values/computed/mod.rs
@@ -37,17 +37,17 @@ pub use self::align::{AlignContent, Alig
 pub use self::align::{AlignSelf, JustifySelf};
 pub use self::angle::Angle;
 pub use self::background::{BackgroundRepeat, BackgroundSize};
 pub use self::basic_shape::FillRule;
 pub use self::border::{BorderCornerRadius, BorderRadius, BorderSpacing};
 pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
 pub use self::border::{BorderImageSlice, BorderImageWidth};
 pub use self::box_::{AnimationIterationCount, AnimationName, Contain};
-pub use self::box_::{Appearance, BreakBetween, Clear, Float};
+pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float};
 pub use self::box_::{Display, TransitionProperty};
 pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
 pub use self::box_::{ScrollSnapType, TouchAction, VerticalAlign, WillChange};
 pub use self::color::{Color, ColorPropertyValue, RGBAColor};
 pub use self::column::ColumnCount;
 pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset};
 pub use self::easing::TimingFunction;
 pub use self::effects::{BoxShadow, Filter, SimpleShadow};
--- a/servo/components/style/values/specified/box.rs
+++ b/servo/components/style/values/specified/box.rs
@@ -1310,8 +1310,31 @@ pub enum Appearance {
 #[repr(u8)]
 pub enum BreakBetween {
     Auto,
     Always,
     Avoid,
     Left,
     Right,
 }
+
+/// A kind of break within a box.
+///
+/// https://drafts.csswg.org/css-break/#break-within
+#[allow(missing_docs)]
+#[derive(
+    Clone,
+    Copy,
+    Debug,
+    Eq,
+    Hash,
+    MallocSizeOf,
+    Parse,
+    PartialEq,
+    SpecifiedValueInfo,
+    ToCss,
+    ToComputedValue,
+)]
+#[repr(u8)]
+pub enum BreakWithin {
+    Auto,
+    Avoid,
+}
--- a/servo/components/style/values/specified/mod.rs
+++ b/servo/components/style/values/specified/mod.rs
@@ -31,17 +31,17 @@ pub use self::align::{AlignContent, Alig
 pub use self::align::{JustifyContent, JustifyItems, JustifySelf, SelfAlignment};
 pub use self::angle::Angle;
 pub use self::background::{BackgroundRepeat, BackgroundSize};
 pub use self::basic_shape::FillRule;
 pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
 pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
 pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing};
 pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
-pub use self::box_::{Appearance, BreakBetween, Clear, Float};
+pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float};
 pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
 pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange};
 pub use self::color::{Color, ColorPropertyValue, RGBAColor};
 pub use self::column::ColumnCount;
 pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset};
 pub use self::easing::TimingFunction;
 pub use self::effects::{BoxShadow, Filter, SimpleShadow};
 pub use self::flex::FlexBasis;