Bug 1335876 - Part 1. Declare mTransformBox as StyleGeometryBox.
MozReview-Commit-ID: 9fcHkDtNHhL
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -2083,19 +2083,19 @@ const KTableEntry nsCSSProps::kTouchActi
const KTableEntry nsCSSProps::kTopLayerKTable[] = {
{ eCSSKeyword_none, NS_STYLE_TOP_LAYER_NONE },
{ eCSSKeyword_top, NS_STYLE_TOP_LAYER_TOP },
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kTransformBoxKTable[] = {
- { eCSSKeyword_border_box, NS_STYLE_TRANSFORM_BOX_BORDER_BOX },
- { eCSSKeyword_fill_box, NS_STYLE_TRANSFORM_BOX_FILL_BOX },
- { eCSSKeyword_view_box, NS_STYLE_TRANSFORM_BOX_VIEW_BOX },
+ { eCSSKeyword_border_box, StyleGeometryBox::Border },
+ { eCSSKeyword_fill_box, StyleGeometryBox::Fill },
+ { eCSSKeyword_view_box, StyleGeometryBox::View },
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kTransitionTimingFunctionKTable[] = {
{ eCSSKeyword_ease, NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE },
{ eCSSKeyword_linear, NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR },
{ eCSSKeyword_ease_in, NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN },
{ eCSSKeyword_ease_out, NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_OUT },
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1450,16 +1450,17 @@ struct SetEnumValueHelper
DEFINE_ENUM_CLASS_SETTER(StyleFloatEdge, ContentBox, MarginBox)
DEFINE_ENUM_CLASS_SETTER(StyleHyphens, None, Auto)
DEFINE_ENUM_CLASS_SETTER(StyleUserFocus, None, SelectMenu)
DEFINE_ENUM_CLASS_SETTER(StyleUserSelect, None, MozText)
DEFINE_ENUM_CLASS_SETTER(StyleUserInput, None, Auto)
DEFINE_ENUM_CLASS_SETTER(StyleUserModify, ReadOnly, WriteOnly)
DEFINE_ENUM_CLASS_SETTER(StyleWindowDragging, Default, NoDrag)
DEFINE_ENUM_CLASS_SETTER(StyleOrient, Inline, Vertical)
+ DEFINE_ENUM_CLASS_SETTER(StyleGeometryBox, Border, View)
#ifdef MOZ_XUL
DEFINE_ENUM_CLASS_SETTER(StyleDisplay, None, MozPopup)
#else
DEFINE_ENUM_CLASS_SETTER(StyleDisplay, None, InlineBox)
#endif
#undef DEF_SET_ENUMERATED_VALUE
};
@@ -6592,17 +6593,17 @@ nsRuleNode::ComputeDisplayData(void* aSt
parentDisplay->mTransformStyle,
NS_STYLE_TRANSFORM_STYLE_FLAT);
// transform-box: enum, inherit, initial
SetValue(*aRuleData->ValueForTransformBox(),
display->mTransformBox, conditions,
SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
parentDisplay->mTransformBox,
- NS_STYLE_TRANSFORM_BOX_BORDER_BOX);
+ StyleGeometryBox::Border);
// orient: enum, inherit, initial
SetValue(*aRuleData->ValueForOrient(),
display->mOrient, conditions,
SETVAL_ENUMERATED | SETVAL_UNSET_INITIAL,
parentDisplay->mOrient,
StyleOrient::Inline);
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -80,28 +80,28 @@ enum class StyleClear : uint8_t {
Both,
// StyleClear::Line can be added to one of the other values in layout
// so it needs to use a bit value that none of the other values can have.
Line = 8,
Max = 13 // Max = (Both | Line)
};
// Define geometry box for clip-path's reference-box, background-clip,
-// background-origin, mask-clip and mask-origin.
+// background-origin, mask-clip, mask-origin, shape-box and transform-box.
enum class StyleGeometryBox : uint8_t {
- Content,
- Padding,
+ Content, // Used by everything, except transform-box.
+ Padding, // Used by everything, except transform-box.
Border,
Margin, // XXX Bug 1260094 comment 9.
// Although margin-box is required by mask-origin and mask-clip, we
// do not implement that due to lack of support in other browsers.
// clip-path reference-box only.
- Fill, // mask-clip, mask-origin and clip-path reference-box only.
+ Fill, // Used by everything, except shape-box.
Stroke, // mask-clip, mask-origin and clip-path reference-box only.
- View, // mask-clip, mask-origin and clip-path reference-box only.
+ View, // Used by everything, except shape-box.
NoClip, // mask-clip only.
Text, // background-clip only.
NoBox, // Depending on which kind of element this style value applied on,
// the default value of a reference-box can be different.
// For an HTML element, the default value of reference-box is
// border-box; for an SVG element, the default value is fill-box.
// Since we can not determine the default value at parsing time,
// set it as NoBox so that we make a decision later.
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -3208,17 +3208,17 @@ nsStyleDisplay::nsStyleDisplay(const nsP
, mTouchAction(NS_STYLE_TOUCH_ACTION_AUTO)
, mScrollBehavior(NS_STYLE_SCROLL_BEHAVIOR_AUTO)
, mScrollSnapTypeX(NS_STYLE_SCROLL_SNAP_TYPE_NONE)
, mScrollSnapTypeY(NS_STYLE_SCROLL_SNAP_TYPE_NONE)
, mScrollSnapPointsX(eStyleUnit_None)
, mScrollSnapPointsY(eStyleUnit_None)
, mBackfaceVisibility(NS_STYLE_BACKFACE_VISIBILITY_VISIBLE)
, mTransformStyle(NS_STYLE_TRANSFORM_STYLE_FLAT)
- , mTransformBox(NS_STYLE_TRANSFORM_BOX_BORDER_BOX)
+ , mTransformBox(StyleGeometryBox::Border)
, mSpecifiedTransform(nullptr)
, mTransformOrigin{ {0.5f, eStyleUnit_Percent}, // Transform is centered on origin
{0.5f, eStyleUnit_Percent},
{0, nsStyleCoord::CoordConstructor} }
, mChildPerspective(eStyleUnit_None)
, mPerspectiveOrigin{ {0.5f, eStyleUnit_Percent},
{0.5f, eStyleUnit_Percent} }
, mVerticalAlign(NS_STYLE_VERTICAL_ALIGN_BASELINE, eStyleUnit_Enumerated)
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2787,16 +2787,18 @@ private:
using StyleClipPath = StyleShapeSource<StyleGeometryBox>;
using StyleShapeOutside = StyleShapeSource<StyleShapeOutsideShapeBox>;
} // namespace mozilla
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay
{
+ typedef mozilla::StyleGeometryBox StyleGeometryBox;
+
explicit nsStyleDisplay(const nsPresContext* aContext);
nsStyleDisplay(const nsStyleDisplay& aOther);
~nsStyleDisplay();
void FinishStyle(nsPresContext* aPresContext) {}
void* operator new(size_t sz, nsStyleDisplay* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {
@@ -2875,17 +2877,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
nsTArray<mozilla::Position> mScrollSnapCoordinate; // [reset]
// mSpecifiedTransform is the list of transform functions as
// specified, or null to indicate there is no transform. (inherit or
// initial are replaced by an actual list of transform functions, or
// null, as appropriate.)
uint8_t mBackfaceVisibility;
uint8_t mTransformStyle;
- uint8_t mTransformBox; // [reset] see nsStyleConsts.h
+ StyleGeometryBox mTransformBox; // [reset] see nsStyleConsts.h
RefPtr<nsCSSValueSharedList> mSpecifiedTransform; // [reset]
nsStyleCoord mTransformOrigin[3]; // [reset] percent, coord, calc, 3rd param is coord, calc only
nsStyleCoord mChildPerspective; // [reset] none, coord
nsStyleCoord mPerspectiveOrigin[2]; // [reset] percent, coord, calc
nsStyleCoord mVerticalAlign; // [reset] coord, percent, calc, enum (see nsStyleConsts.h)
nsStyleAutoArray<mozilla::StyleTransition> mTransitions; // [reset]
--- a/layout/style/nsStyleTransformMatrix.cpp
+++ b/layout/style/nsStyleTransformMatrix.cpp
@@ -53,38 +53,36 @@ TransformReferenceBox::EnsureDimensionsA
if (mFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT) {
if (!nsLayoutUtils::SVGTransformBoxEnabled()) {
mX = -mFrame->GetPosition().x;
mY = -mFrame->GetPosition().y;
Size contextSize = nsSVGUtils::GetContextSize(mFrame);
mWidth = nsPresContext::CSSPixelsToAppUnits(contextSize.width);
mHeight = nsPresContext::CSSPixelsToAppUnits(contextSize.height);
} else
- if (mFrame->StyleDisplay()->mTransformBox ==
- NS_STYLE_TRANSFORM_BOX_FILL_BOX) {
+ if (mFrame->StyleDisplay()->mTransformBox == StyleGeometryBox::Fill) {
// Percentages in transforms resolve against the SVG bbox, and the
// transform is relative to the top-left of the SVG bbox.
- gfxRect bbox = nsSVGUtils::GetBBox(const_cast<nsIFrame*>(mFrame));
nsRect bboxInAppUnits =
- nsLayoutUtils::RoundGfxRectToAppRect(bbox,
- mFrame->PresContext()->AppUnitsPerCSSPixel());
+ nsLayoutUtils::ComputeGeometryBox(const_cast<nsIFrame*>(mFrame),
+ StyleGeometryBox::Fill);
// The mRect of an SVG nsIFrame is its user space bounds *including*
// stroke and markers, whereas bboxInAppUnits is its user space bounds
// including fill only. We need to note the offset of the reference box
// from the frame's mRect in mX/mY.
mX = bboxInAppUnits.x - mFrame->GetPosition().x;
mY = bboxInAppUnits.y - mFrame->GetPosition().y;
mWidth = bboxInAppUnits.width;
mHeight = bboxInAppUnits.height;
} else {
// The value 'border-box' is treated as 'view-box' for SVG content.
MOZ_ASSERT(mFrame->StyleDisplay()->mTransformBox ==
- NS_STYLE_TRANSFORM_BOX_VIEW_BOX ||
+ StyleGeometryBox::View ||
mFrame->StyleDisplay()->mTransformBox ==
- NS_STYLE_TRANSFORM_BOX_BORDER_BOX,
+ StyleGeometryBox::Border,
"Unexpected value for 'transform-box'");
// Percentages in transforms resolve against the width/height of the
// nearest viewport (or its viewBox if one is applied), and the
// transform is relative to {0,0} in current user space.
mX = -mFrame->GetPosition().x;
mY = -mFrame->GetPosition().y;
Size contextSize = nsSVGUtils::GetContextSize(mFrame);
mWidth = nsPresContext::CSSPixelsToAppUnits(contextSize.width);