Bug 1311270 - Part 2. Rename StyleClipPathGeometryBox to StyleGeometryBox and extend contained values.
MozReview-Commit-ID: 85zjcifAycX
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -9174,35 +9174,35 @@ nsLayoutUtils::IsInvisibleBreak(nsINode*
}
}
return lineNonEmpty;
}
static nsRect
ComputeSVGReferenceRect(nsIFrame* aFrame,
- StyleClipPathGeometryBox aGeometryBox)
+ StyleGeometryBox aGeometryBox)
{
MOZ_ASSERT(aFrame->GetContent()->IsSVGElement());
nsRect r;
// For SVG elements without associated CSS layout box, the used value for
// content-box, padding-box, border-box and margin-box is fill-box.
switch (aGeometryBox) {
- case StyleClipPathGeometryBox::Stroke: {
+ case StyleGeometryBox::Stroke: {
// XXX Bug 1299876
// The size of srtoke-box is not correct if this graphic element has
// specific stroke-linejoin or stroke-linecap.
gfxRect bbox = nsSVGUtils::GetBBox(aFrame,
nsSVGUtils::eBBoxIncludeFill | nsSVGUtils::eBBoxIncludeStroke);
r = nsLayoutUtils::RoundGfxRectToAppRect(bbox,
nsPresContext::AppUnitsPerCSSPixel());
break;
}
- case StyleClipPathGeometryBox::View: {
+ case StyleGeometryBox::View: {
nsIContent* content = aFrame->GetContent();
nsSVGElement* element = static_cast<nsSVGElement*>(content);
SVGSVGElement* svgElement = element->GetCtx();
MOZ_ASSERT(svgElement);
if (svgElement && svgElement->HasViewBoxRect()) {
// If a ‘viewBox‘ attribute is specified for the SVG viewport creating
// element:
@@ -9222,78 +9222,78 @@ ComputeSVGReferenceRect(nsIFrame* aFrame
svgFloatSize viewportSize = svgElement->GetViewportSize();
r = nsRect(0, 0,
nsPresContext::CSSPixelsToAppUnits(viewportSize.width),
nsPresContext::CSSPixelsToAppUnits(viewportSize.height));
}
break;
}
- case StyleClipPathGeometryBox::NoBox:
- case StyleClipPathGeometryBox::Border:
- case StyleClipPathGeometryBox::Content:
- case StyleClipPathGeometryBox::Padding:
- case StyleClipPathGeometryBox::Margin:
- case StyleClipPathGeometryBox::Fill: {
+ case StyleGeometryBox::NoBox:
+ case StyleGeometryBox::Border:
+ case StyleGeometryBox::Content:
+ case StyleGeometryBox::Padding:
+ case StyleGeometryBox::Margin:
+ case StyleGeometryBox::Fill: {
gfxRect bbox = nsSVGUtils::GetBBox(aFrame,
nsSVGUtils::eBBoxIncludeFill);
r = nsLayoutUtils::RoundGfxRectToAppRect(bbox,
nsPresContext::AppUnitsPerCSSPixel());
break;
}
default:{
- MOZ_ASSERT_UNREACHABLE("unknown StyleClipPathGeometryBox type");
+ MOZ_ASSERT_UNREACHABLE("unknown StyleGeometryBox type");
gfxRect bbox = nsSVGUtils::GetBBox(aFrame,
nsSVGUtils::eBBoxIncludeFill);
r = nsLayoutUtils::RoundGfxRectToAppRect(bbox,
nsPresContext::AppUnitsPerCSSPixel());
break;
}
}
return r;
}
static nsRect
ComputeHTMLReferenceRect(nsIFrame* aFrame,
- StyleClipPathGeometryBox aGeometryBox)
+ StyleGeometryBox aGeometryBox)
{
nsRect r;
// For elements with associated CSS layout box, the used value for fill-box,
// stroke-box and view-box is border-box.
switch (aGeometryBox) {
- case StyleClipPathGeometryBox::Content:
+ case StyleGeometryBox::Content:
r = aFrame->GetContentRectRelativeToSelf();
break;
- case StyleClipPathGeometryBox::Padding:
+ case StyleGeometryBox::Padding:
r = aFrame->GetPaddingRectRelativeToSelf();
break;
- case StyleClipPathGeometryBox::Margin:
+ case StyleGeometryBox::Margin:
r = aFrame->GetMarginRectRelativeToSelf();
break;
- case StyleClipPathGeometryBox::NoBox:
- case StyleClipPathGeometryBox::Border:
- case StyleClipPathGeometryBox::Fill:
- case StyleClipPathGeometryBox::Stroke:
- case StyleClipPathGeometryBox::View:
+ case StyleGeometryBox::NoBox:
+ case StyleGeometryBox::Border:
+ case StyleGeometryBox::Fill:
+ case StyleGeometryBox::Stroke:
+ case StyleGeometryBox::View:
r = aFrame->GetRectRelativeToSelf();
break;
default:
- MOZ_ASSERT_UNREACHABLE("unknown StyleClipPathGeometryBox type");
+ MOZ_ASSERT_UNREACHABLE("unknown StyleGeometryBox type");
r = aFrame->GetRectRelativeToSelf();
break;
}
return r;
}
/* static */ nsRect
nsLayoutUtils::ComputeGeometryBox(nsIFrame* aFrame,
- StyleClipPathGeometryBox aGeometryBox)
+ StyleGeometryBox aGeometryBox)
{
// We use ComputeSVGReferenceRect for all SVG elements, except <svg>
// element, which does have an associated CSS layout box. In this case we
// should still use ComputeHTMLReferenceRect for region computing.
nsRect r = aFrame->IsFrameOfType(nsIFrame::eSVG) &&
(aFrame->GetType() != nsGkAtoms::svgOuterSVGFrame)
? ComputeSVGReferenceRect(aFrame, aGeometryBox)
: ComputeHTMLReferenceRect(aFrame, aGeometryBox);
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -147,17 +147,17 @@ public:
typedef mozilla::layers::ScrollMetadata ScrollMetadata;
typedef FrameMetrics::ViewID ViewID;
typedef mozilla::CSSPoint CSSPoint;
typedef mozilla::CSSSize CSSSize;
typedef mozilla::CSSIntSize CSSIntSize;
typedef mozilla::CSSRect CSSRect;
typedef mozilla::ScreenMargin ScreenMargin;
typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
- typedef mozilla::StyleClipPathGeometryBox StyleClipPathGeometryBox;
+ typedef mozilla::StyleGeometryBox StyleGeometryBox;
/**
* Finds previously assigned ViewID for the given content element, if any.
* Returns whether a ViewID was previously assigned.
*/
static bool FindIDFor(const nsIContent* aContent, ViewID* aOutViewId);
/**
@@ -2866,17 +2866,17 @@ public:
* false if the node causes a visible break or if the node is no break.
*
* @param aNextLineFrame assigned to first frame on the next line if such a
* next line exists, null otherwise.
*/
static bool IsInvisibleBreak(nsINode* aNode, nsIFrame** aNextLineFrame = nullptr);
static nsRect ComputeGeometryBox(nsIFrame* aFrame,
- StyleClipPathGeometryBox aGeometryBox);
+ StyleGeometryBox aGeometryBox);
private:
static uint32_t sFontSizeInflationEmPerLine;
static uint32_t sFontSizeInflationMinTwips;
static uint32_t sFontSizeInflationLineThreshold;
static int32_t sFontSizeInflationMappingIntercept;
static uint32_t sFontSizeInflationMaxRatio;
static bool sFontSizeInflationForceEnabled;
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -897,43 +897,43 @@ static_assert(NS_STYLE_IMAGELAYER_CLIP_B
const KTableEntry nsCSSProps::kBackgroundOriginKTable[] = {
{ eCSSKeyword_border_box, NS_STYLE_IMAGELAYER_ORIGIN_BORDER },
{ eCSSKeyword_padding_box, NS_STYLE_IMAGELAYER_ORIGIN_PADDING },
{ eCSSKeyword_content_box, NS_STYLE_IMAGELAYER_ORIGIN_CONTENT },
{ eCSSKeyword_UNKNOWN, -1 }
};
KTableEntry nsCSSProps::kBackgroundClipKTable[] = {
- { eCSSKeyword_border_box, NS_STYLE_IMAGELAYER_CLIP_BORDER },
- { eCSSKeyword_padding_box, NS_STYLE_IMAGELAYER_CLIP_PADDING },
- { eCSSKeyword_content_box, NS_STYLE_IMAGELAYER_CLIP_CONTENT },
+ { eCSSKeyword_border_box, StyleGeometryBox::Border },
+ { eCSSKeyword_padding_box, StyleGeometryBox::Padding },
+ { eCSSKeyword_content_box, StyleGeometryBox::Content },
// The next entry is controlled by the layout.css.background-clip-text.enabled
// pref.
- { eCSSKeyword_text, NS_STYLE_IMAGELAYER_CLIP_TEXT },
+ { eCSSKeyword_text, StyleGeometryBox::Text },
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kMaskOriginKTable[] = {
{ eCSSKeyword_border_box, NS_STYLE_IMAGELAYER_ORIGIN_BORDER },
{ eCSSKeyword_padding_box, NS_STYLE_IMAGELAYER_ORIGIN_PADDING },
{ eCSSKeyword_content_box, NS_STYLE_IMAGELAYER_ORIGIN_CONTENT },
{ eCSSKeyword_fill_box, NS_STYLE_IMAGELAYER_ORIGIN_FILL },
{ eCSSKeyword_stroke_box, NS_STYLE_IMAGELAYER_ORIGIN_STROKE },
{ eCSSKeyword_view_box, NS_STYLE_IMAGELAYER_ORIGIN_VIEW },
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kMaskClipKTable[] = {
- { eCSSKeyword_border_box, NS_STYLE_IMAGELAYER_CLIP_BORDER },
- { eCSSKeyword_padding_box, NS_STYLE_IMAGELAYER_CLIP_PADDING },
- { eCSSKeyword_content_box, NS_STYLE_IMAGELAYER_CLIP_CONTENT },
- { eCSSKeyword_fill_box, NS_STYLE_IMAGELAYER_CLIP_FILL },
- { eCSSKeyword_stroke_box, NS_STYLE_IMAGELAYER_CLIP_STROKE },
- { eCSSKeyword_view_box, NS_STYLE_IMAGELAYER_CLIP_VIEW },
- { eCSSKeyword_no_clip, NS_STYLE_IMAGELAYER_CLIP_NO_CLIP },
+ { eCSSKeyword_border_box, StyleGeometryBox::Border },
+ { eCSSKeyword_padding_box, StyleGeometryBox::Padding },
+ { eCSSKeyword_content_box, StyleGeometryBox::Content },
+ { eCSSKeyword_fill_box, StyleGeometryBox::Fill },
+ { eCSSKeyword_stroke_box, StyleGeometryBox::Stroke },
+ { eCSSKeyword_view_box, StyleGeometryBox::View },
+ { eCSSKeyword_no_clip, StyleGeometryBox::NoClip },
{ eCSSKeyword_UNKNOWN, -1 }
};
// Note: Don't change this table unless you update
// ParseImageLayerPosition!
const KTableEntry nsCSSProps::kImageLayerPositionKTable[] = {
{ eCSSKeyword_center, NS_STYLE_IMAGELAYER_POSITION_CENTER },
@@ -2298,23 +2298,23 @@ const KTableEntry nsCSSProps::kDominantB
const KTableEntry nsCSSProps::kFillRuleKTable[] = {
{ eCSSKeyword_nonzero, StyleFillRule::Nonzero },
{ eCSSKeyword_evenodd, StyleFillRule::Evenodd },
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kClipPathGeometryBoxKTable[] = {
- { eCSSKeyword_content_box, StyleClipPathGeometryBox::Content },
- { eCSSKeyword_padding_box, StyleClipPathGeometryBox::Padding },
- { eCSSKeyword_border_box, StyleClipPathGeometryBox::Border },
- { eCSSKeyword_margin_box, StyleClipPathGeometryBox::Margin },
- { eCSSKeyword_fill_box, StyleClipPathGeometryBox::Fill },
- { eCSSKeyword_stroke_box, StyleClipPathGeometryBox::Stroke },
- { eCSSKeyword_view_box, StyleClipPathGeometryBox::View },
+ { eCSSKeyword_content_box, StyleGeometryBox::Content },
+ { eCSSKeyword_padding_box, StyleGeometryBox::Padding },
+ { eCSSKeyword_border_box, StyleGeometryBox::Border },
+ { eCSSKeyword_margin_box, StyleGeometryBox::Margin },
+ { eCSSKeyword_fill_box, StyleGeometryBox::Fill },
+ { eCSSKeyword_stroke_box, StyleGeometryBox::Stroke },
+ { eCSSKeyword_view_box, StyleGeometryBox::View },
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kShapeRadiusKTable[] = {
{ eCSSKeyword_closest_side, StyleShapeRadius::ClosestSide },
{ eCSSKeyword_farthest_side, StyleShapeRadius::FarthestSide },
{ eCSSKeyword_UNKNOWN, -1 }
};
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -107,26 +107,45 @@ enum class StyleClear : uint8_t {
InlineEnd,
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)
};
-// clip-path geometry box
-enum class StyleClipPathGeometryBox : uint8_t {
- NoBox,
+// Define geometry box for clip-path's reference-box, background-clip,
+// background-origin, mask-clip and mask-origin.
+enum class StyleGeometryBox : uint8_t {
Content,
Padding,
Border,
- Margin,
- Fill,
- Stroke,
- View,
+ 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.
+ Stroke, // mask-clip, mask-origin and clip-path reference-box only.
+ View, // mask-clip, mask-origin and clip-path reference-box only.
+ 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.
+ // clip-path reference-box only.
+ MozAlmostPadding = 127 // A magic value that we use for our "pretend that
+ // background-clip is 'padding' when we have a solid
+ // border" optimization. This isn't actually equal
+ // to StyleGeometryBox::Padding because using that
+ // causes antialiasing seams between the background
+ // and border.
+ // background-clip only.
};
// fill-rule
enum class StyleFillRule : uint8_t {
Nonzero,
Evenodd,
};
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2746,17 +2746,17 @@ private:
union {
StyleBasicShape* mBasicShape;
css::URLValue* mURL;
};
StyleShapeSourceType mType = StyleShapeSourceType::None;
ReferenceBox mReferenceBox = ReferenceBox::NoBox;
};
-using StyleClipPath = StyleShapeSource<StyleClipPathGeometryBox>;
+using StyleClipPath = StyleShapeSource<StyleGeometryBox>;
using StyleShapeOutside = StyleShapeSource<StyleShapeOutsideShapeBox>;
} // namespace mozilla
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay
{
explicit nsStyleDisplay(StyleStructContext aContext);
nsStyleDisplay(const nsStyleDisplay& aOther);