Bug 1260094 - Implement mask-origin for margin-box support.
MozReview-Commit-ID: KIknb35LI1b
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -3108,17 +3108,23 @@ nsCSSRendering::ComputeImageLayerPositio
bgPositioningArea = nsRect(
scrollableFrame->GetScrolledFrame()->GetPosition()
// For the dir=rtl case:
+ scrollableFrame->GetScrollRange().TopLeft(),
scrollableFrame->GetScrolledRect().Size());
// The ScrolledRect’s size does not include the borders or scrollbars,
// reverse the handling of background-origin
// compared to the common case below.
- if (aLayer.mOrigin == NS_STYLE_IMAGELAYER_ORIGIN_BORDER) {
+ if (aLayer.mOrigin == NS_STYLE_IMAGELAYER_ORIGIN_MARGIN) {
+ nsMargin margin = geometryFrame->GetUsedMargin();
+ margin.ApplySkipSides(geometryFrame->GetSkipSides());
+ bgPositioningArea.Inflate(margin);
+ bgPositioningArea.Inflate(scrollableFrame->GetActualScrollbarSizes());
+ }
+ else if (aLayer.mOrigin == NS_STYLE_IMAGELAYER_ORIGIN_BORDER) {
nsMargin border = geometryFrame->GetUsedBorder();
border.ApplySkipSides(geometryFrame->GetSkipSides());
bgPositioningArea.Inflate(border);
bgPositioningArea.Inflate(scrollableFrame->GetActualScrollbarSizes());
} else if (aLayer.mOrigin != NS_STYLE_IMAGELAYER_ORIGIN_PADDING) {
nsMargin padding = geometryFrame->GetUsedPadding();
padding.ApplySkipSides(geometryFrame->GetSkipSides());
bgPositioningArea.Deflate(padding);
@@ -3139,17 +3145,20 @@ nsCSSRendering::ComputeImageLayerPositio
bgPositioningArea = geometryFrame->GetRect();
}
} else {
bgPositioningArea = nsRect(nsPoint(0,0), aBorderArea.Size());
}
// Background images are tiled over the 'background-clip' area
// but the origin of the tiling is based on the 'background-origin' area
- if (aLayer.mOrigin != NS_STYLE_IMAGELAYER_ORIGIN_BORDER && geometryFrame) {
+ if (aLayer.mOrigin == NS_STYLE_IMAGELAYER_ORIGIN_MARGIN) {
+ nsMargin margin = geometryFrame->GetUsedMargin();
+ bgPositioningArea.Inflate(margin);
+ } else if (aLayer.mOrigin != NS_STYLE_IMAGELAYER_ORIGIN_BORDER && geometryFrame) {
nsMargin border = geometryFrame->GetUsedBorder();
if (aLayer.mOrigin != NS_STYLE_IMAGELAYER_ORIGIN_PADDING) {
border += geometryFrame->GetUsedPadding();
NS_ASSERTION(aLayer.mOrigin == NS_STYLE_IMAGELAYER_ORIGIN_CONTENT,
"unknown background-origin value");
}
bgPositioningArea.Deflate(border);
}
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -892,16 +892,17 @@ static_assert(NS_STYLE_IMAGELAYER_CLIP_B
NS_STYLE_IMAGELAYER_CLIP_CONTENT == NS_STYLE_IMAGELAYER_ORIGIN_CONTENT,
"Except background-clip:text, all {background,mask}-clip and "
"{background,mask}-origin style constants must agree");
const KTableEntry nsCSSProps::kImageLayerOriginKTable[] = {
{ 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_margin_box, NS_STYLE_IMAGELAYER_ORIGIN_MARGIN },
{ 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 },
// The next entry is controlled by the layout.css.background-clip-text.enabled
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -266,31 +266,33 @@ enum class FillMode : uint32_t;
#define NS_STYLE_IMAGELAYER_ATTACHMENT_FIXED 1
#define NS_STYLE_IMAGELAYER_ATTACHMENT_LOCAL 2
// See nsStyleImageLayers
// Code depends on these constants having the same values as IMAGELAYER_ORIGIN_*
#define NS_STYLE_IMAGELAYER_CLIP_BORDER 0
#define NS_STYLE_IMAGELAYER_CLIP_PADDING 1
#define NS_STYLE_IMAGELAYER_CLIP_CONTENT 2
+#define NS_STYLE_IMAGELAYER_CLIP_MARGIN 3
// One extra constant which does not exist in IMAGELAYER_ORIGIN_*
-#define NS_STYLE_IMAGELAYER_CLIP_TEXT 3
+#define NS_STYLE_IMAGELAYER_CLIP_TEXT 4
// 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 NS_STYLE_IMAGELAYER_CLIP_PADDING because using that
// causes antialiasing seams between the background and border. This
// is a backend-only value.
#define NS_STYLE_IMAGELAYER_CLIP_MOZ_ALMOST_PADDING 127
// See nsStyleImageLayers
// Code depends on these constants having the same values as BG_CLIP_*
#define NS_STYLE_IMAGELAYER_ORIGIN_BORDER 0
#define NS_STYLE_IMAGELAYER_ORIGIN_PADDING 1
#define NS_STYLE_IMAGELAYER_ORIGIN_CONTENT 2
+#define NS_STYLE_IMAGELAYER_ORIGIN_MARGIN 3
// See nsStyleImageLayers
// The parser code depends on |ing these values together.
#define NS_STYLE_IMAGELAYER_POSITION_CENTER (1<<0)
#define NS_STYLE_IMAGELAYER_POSITION_TOP (1<<1)
#define NS_STYLE_IMAGELAYER_POSITION_BOTTOM (1<<2)
#define NS_STYLE_IMAGELAYER_POSITION_LEFT (1<<3)
#define NS_STYLE_IMAGELAYER_POSITION_RIGHT (1<<4)