Merge autoland to m-c, a=merge

MozReview-Commit-ID: 2zgTtus4xpl
This commit is contained in:
Phil Ringnalda 2017-01-01 11:16:06 -08:00
commit b1f454d8aa
22 changed files with 111 additions and 77 deletions

View File

@ -374,10 +374,9 @@ bool
TextAttrsMgr::BGColorTextAttr::
GetColor(nsIFrame* aFrame, nscolor* aColor)
{
const nsStyleBackground* styleBackground = aFrame->StyleBackground();
if (NS_GET_A(styleBackground->mBackgroundColor) > 0) {
*aColor = styleBackground->mBackgroundColor;
nscolor backgroundColor = aFrame->StyleBackground()->BackgroundColor(aFrame);
if (NS_GET_A(backgroundColor) > 0) {
*aColor = backgroundColor;
return true;
}

View File

@ -1075,7 +1075,7 @@ HTMLTableAccessible::IsProbablyLayoutTable()
if (child->Role() == roles::ROW) {
prevRowColor = rowColor;
nsIFrame* rowFrame = child->GetFrame();
rowColor = rowFrame->StyleBackground()->mBackgroundColor;
rowColor = rowFrame->StyleBackground()->BackgroundColor(rowFrame);
if (childIdx > 0 && prevRowColor != rowColor)
RETURN_LAYOUT_ANSWER(false, "2 styles of row background color, non-bordered");

View File

@ -117,8 +117,9 @@ ia2AccessibleComponent::get_background(IA2Color* aBackground)
return CO_E_OBJNOTCONNECTED;
nsIFrame* frame = acc->GetFrame();
if (frame)
*aBackground = frame->StyleBackground()->mBackgroundColor;
if (frame) {
*aBackground = frame->StyleBackground()->BackgroundColor(frame);
}
return S_OK;

View File

@ -6851,7 +6851,7 @@ nsLayoutUtils::GetFrameTransparency(nsIFrame* aBackgroundFrame,
return eTransparencyTransparent;
}
const nsStyleBackground* bg = bgSC->StyleBackground();
if (NS_GET_A(bg->mBackgroundColor) < 255 ||
if (NS_GET_A(bg->BackgroundColor(bgSC)) < 255 ||
// bottom layer's clip is used for the color
bg->BottomLayer().mClip != StyleGeometryBox::Border)
return eTransparencyTransparent;
@ -8798,8 +8798,9 @@ nsLayoutUtils::ComputeScrollMetadata(nsIFrame* aForFrame,
} else {
nsStyleContext* backgroundStyle;
if (nsCSSRendering::FindBackground(aScrollFrame, &backgroundStyle)) {
metadata.SetBackgroundColor(Color::FromABGR(
backgroundStyle->StyleBackground()->mBackgroundColor));
nscolor backgroundColor = backgroundStyle->
StyleBackground()->BackgroundColor(backgroundStyle);
metadata.SetBackgroundColor(Color::FromABGR(backgroundColor));
}
}
}
@ -9332,4 +9333,4 @@ nsLayoutUtils::ComputeGeometryBox(nsIFrame* aFrame,
: ComputeHTMLReferenceRect(aFrame, aGeometryBox);
return r;
}
}

View File

@ -1453,7 +1453,7 @@ nsListControlFrame::AboutToDropDown()
mLastDropdownBackstopColor = NS_RGBA(0,0,0,0);
while (NS_GET_A(mLastDropdownBackstopColor) < 255 && context) {
mLastDropdownBackstopColor =
NS_ComposeColors(context->StyleBackground()->mBackgroundColor,
NS_ComposeColors(context->StyleBackground()->BackgroundColor(context),
mLastDropdownBackstopColor);
context = context->GetParent();
}

View File

@ -1894,7 +1894,7 @@ nsFrame::DisplayBackgroundUnconditional(nsDisplayListBuilder* aBuilder,
// receive a propagated background should just set aForceBackground to
// true.
if (aBuilder->IsForEventDelivery() || aForceBackground ||
!StyleBackground()->IsTransparent() || StyleDisplay()->mAppearance) {
!StyleBackground()->IsTransparent(this) || StyleDisplay()->mAppearance) {
return nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
aBuilder, this, GetRectRelativeToSelf(), aLists.BorderBackground());
}
@ -5436,7 +5436,7 @@ nsRect
nsFrame::ComputeSimpleTightBounds(DrawTarget* aDrawTarget) const
{
if (StyleOutline()->mOutlineStyle != NS_STYLE_BORDER_STYLE_NONE ||
StyleBorder()->HasBorder() || !StyleBackground()->IsTransparent() ||
StyleBorder()->HasBorder() || !StyleBackground()->IsTransparent(this) ||
StyleDisplay()->mAppearance) {
// Not necessarily tight, due to clipping, negative
// outline-offset, and lots of other issues, but that's OK

View File

@ -1986,9 +1986,9 @@ nsMathMLChar::Display(nsDisplayListBuilder* aBuilder,
nsDisplayMathMLSelectionRect(aBuilder, aForFrame, *aSelectedRect));
}
else if (mRect.width && mRect.height) {
const nsStyleBackground* backg = styleContext->StyleBackground();
if (styleContext != parentContext &&
NS_GET_A(backg->mBackgroundColor) > 0) {
NS_GET_A(styleContext->StyleBackground()->
BackgroundColor(styleContext)) > 0) {
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
aBuilder, aForFrame, mRect, aLists.BorderBackground(),
/* aAllowWillPaintBorderOptimization */ true, styleContext);

View File

@ -4,7 +4,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "MaskLayerImageCache.h"
#include "ImageContainer.h"
#include "mozilla/layers/ShadowLayers.h"
using namespace mozilla::layers;

View File

@ -21,6 +21,7 @@
#include "nsStyleConsts.h"
#include "nsPresContext.h"
#include "nsIFrame.h"
#include "nsIFrameInlines.h"
#include "nsPoint.h"
#include "nsRect.h"
#include "nsIPresShell.h"
@ -1192,8 +1193,9 @@ nsCSSRendering::FindNonTransparentBackgroundFrame(nsIFrame* aFrame,
while (frame) {
// No need to call GetVisitedDependentColor because it always uses
// this alpha component anyway.
if (NS_GET_A(frame->StyleBackground()->mBackgroundColor) > 0)
if (NS_GET_A(frame->StyleBackground()->BackgroundColor(frame)) > 0) {
break;
}
if (frame->IsThemed())
break;
@ -1227,7 +1229,7 @@ nsCSSRendering::FindBackgroundStyleFrame(nsIFrame* aForFrame)
const nsStyleBackground* result = aForFrame->StyleBackground();
// Check if we need to do propagation from BODY rather than HTML.
if (!result->IsTransparent()) {
if (!result->IsTransparent(aForFrame)) {
return aForFrame;
}
@ -1333,7 +1335,7 @@ FindElementBackground(nsIFrame* aForFrame, nsIFrame* aRootElementFrame,
return true;
const nsStyleBackground* htmlBG = aRootElementFrame->StyleBackground();
return !htmlBG->IsTransparent();
return !htmlBG->IsTransparent(aRootElementFrame);
}
bool
@ -2249,7 +2251,7 @@ nsCSSRendering::DetermineBackgroundColor(nsPresContext* aPresContext,
// transparent, but we are expected to use white instead of whatever
// color was specified.
bgColor = NS_RGB(255, 255, 255);
if (aDrawBackgroundImage || !bg->IsTransparent()) {
if (aDrawBackgroundImage || !bg->IsTransparent(aStyleContext)) {
aDrawBackgroundColor = true;
} else {
bgColor = NS_RGBA(0,0,0,0);
@ -4464,17 +4466,17 @@ GetDashInfo(nscoord aBorderLength,
}
void
nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
uint8_t aBorderStyle,
nscolor aBorderColor,
const nsStyleBackground* aBGColor,
const nsRect& aBorder,
int32_t aAppUnitsPerDevPixel,
int32_t aAppUnitsPerCSSPixel,
uint8_t aStartBevelSide,
nscoord aStartBevelOffset,
uint8_t aEndBevelSide,
nscoord aEndBevelOffset)
nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
uint8_t aBorderStyle,
nscolor aBorderColor,
nscolor aBGColor,
const nsRect& aBorder,
int32_t aAppUnitsPerDevPixel,
int32_t aAppUnitsPerCSSPixel,
uint8_t aStartBevelSide,
nscoord aStartBevelOffset,
uint8_t aEndBevelSide,
nscoord aEndBevelOffset)
{
bool horizontal = ((eSideTop == aStartBevelSide) || (eSideBottom == aStartBevelSide));
nscoord twipsPerPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerCSSPixel);
@ -4564,8 +4566,7 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
// FIXME: In theory, this should use the visited-dependent
// background color, but I don't care.
nscolor bevelColor = MakeBevelColor(ridgeGrooveSide, ridgeGroove,
aBGColor->mBackgroundColor,
aBorderColor);
aBGColor, aBorderColor);
nsRect rect(aBorder);
nscoord half;
if (horizontal) { // top, bottom
@ -4604,7 +4605,7 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
// FIXME: In theory, this should use the visited-dependent
// background color, but I don't care.
bevelColor = MakeBevelColor(ridgeGrooveSide, ridgeGroove,
aBGColor->mBackgroundColor, aBorderColor);
aBGColor, aBorderColor);
if (horizontal) {
rect.y = rect.y + half;
rect.height = aBorder.height - half;

View File

@ -714,17 +714,17 @@ struct nsCSSRendering {
// Draw a border segment in the table collapsing border model without
// beveling corners
static void DrawTableBorderSegment(DrawTarget& aDrawTarget,
uint8_t aBorderStyle,
nscolor aBorderColor,
const nsStyleBackground* aBGColor,
const nsRect& aBorderRect,
int32_t aAppUnitsPerDevPixel,
int32_t aAppUnitsPerCSSPixel,
uint8_t aStartBevelSide = 0,
nscoord aStartBevelOffset = 0,
uint8_t aEndBevelSide = 0,
nscoord aEndBevelOffset = 0);
static void DrawTableBorderSegment(DrawTarget& aDrawTarget,
uint8_t aBorderStyle,
nscolor aBorderColor,
nscolor aBGColor,
const nsRect& aBorderRect,
int32_t aAppUnitsPerDevPixel,
int32_t aAppUnitsPerCSSPixel,
uint8_t aStartBevelSide = 0,
nscoord aStartBevelOffset = 0,
uint8_t aEndBevelSide = 0,
nscoord aEndBevelOffset = 0);
// NOTE: pt, dirtyRect, lineSize, ascent, offset in the following
// structs are non-rounded device pixels, not app units.

View File

@ -6,6 +6,7 @@
#include "DocumentStyleRootIterator.h"
#include "mozilla/dom/Element.h"
#include "nsContentUtils.h"
namespace mozilla {

View File

@ -14,6 +14,10 @@ class nsIDocument;
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
/**
* DocumentStyleRootIterator traverses the roots of the document from the
* perspective of the Servo-backed style system. This will first traverse
@ -25,7 +29,7 @@ public:
explicit DocumentStyleRootIterator(nsIDocument* aDocument);
~DocumentStyleRootIterator() { MOZ_COUNT_DTOR(DocumentStyleRootIterator); }
Element* GetNextStyleRoot();
dom::Element* GetNextStyleRoot();
private:
AutoTArray<nsIContent*, 8> mStyleRoots;

View File

@ -9,6 +9,8 @@
#include "mozilla/DocumentStyleRootIterator.h"
#include "mozilla/ServoRestyleManager.h"
#include "mozilla/dom/ChildIterator.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ElementInlines.h"
#include "nsCSSAnonBoxes.h"
#include "nsCSSPseudoElements.h"
#include "nsIDocumentInlines.h"

View File

@ -538,7 +538,7 @@ CSS_PROP_BACKGROUND(
VARIANT_HC,
nullptr,
offsetof(nsStyleBackground, mBackgroundColor),
eStyleAnimType_Color)
eStyleAnimType_ComplexColor)
CSS_PROP_BACKGROUND(
background-image,
background_image,

View File

@ -85,7 +85,7 @@ already_AddRefed<CSSValue>
GetBackgroundList(T nsStyleImageLayers::Layer::* aMember,
uint32_t nsStyleImageLayers::* aCount,
const nsStyleImageLayers& aLayers,
const KTableEntry aTable[])
const nsCSSProps::KTableEntry aTable[])
{
RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(true);
@ -1870,7 +1870,7 @@ already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetBackgroundColor()
{
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
SetToRGBAColor(val, StyleBackground()->mBackgroundColor);
SetValueFromComplexColor(val, StyleBackground()->mBackgroundColor);
return val.forget();
}

View File

@ -7417,17 +7417,13 @@ nsRuleNode::ComputeBackgroundData(void* aStartStruct,
{
COMPUTE_START_RESET(Background, bg, parentBG)
// background-color: color, string, inherit
const nsCSSValue* backColorValue = aRuleData->ValueForBackgroundColor();
if (eCSSUnit_Initial == backColorValue->GetUnit() ||
eCSSUnit_Unset == backColorValue->GetUnit()) {
bg->mBackgroundColor = NS_RGBA(0, 0, 0, 0);
} else if (!SetColor(*backColorValue, parentBG->mBackgroundColor,
mPresContext, aContext, bg->mBackgroundColor,
conditions)) {
NS_ASSERTION(eCSSUnit_Null == backColorValue->GetUnit(),
"unexpected color unit");
}
// background-color: color, inherit
SetComplexColor<eUnsetInitial>(*aRuleData->ValueForBackgroundColor(),
parentBG->mBackgroundColor,
StyleComplexColor::FromColor(
NS_RGBA(0, 0, 0, 0)),
mPresContext,
bg->mBackgroundColor, conditions);
uint32_t maxItemCount = 1;
bool rebuild = false;

View File

@ -2881,7 +2881,7 @@ nsStyleImageLayers::Layer::CalcDifference(const nsStyleImageLayers::Layer& aNewL
nsStyleBackground::nsStyleBackground(StyleStructContext aContext)
: mImage(nsStyleImageLayers::LayerType::Background)
, mBackgroundColor(NS_RGBA(0, 0, 0, 0))
, mBackgroundColor(StyleComplexColor::FromColor(NS_RGBA(0, 0, 0, 0)))
{
MOZ_COUNT_CTOR(nsStyleBackground);
}
@ -2943,12 +2943,34 @@ nsStyleBackground::HasFixedBackground(nsIFrame* aFrame) const
return false;
}
nscolor
nsStyleBackground::BackgroundColor(const nsIFrame* aFrame) const
{
return BackgroundColor(aFrame->StyleContext());
}
nscolor
nsStyleBackground::BackgroundColor(nsStyleContext* aContext) const
{
// In majority of cases, background-color should just be a numeric color.
// In that case, we can skip resolving StyleColor().
return mBackgroundColor.IsNumericColor()
? mBackgroundColor.mColor
: aContext->StyleColor()->CalcComplexColor(mBackgroundColor);
}
bool
nsStyleBackground::IsTransparent() const
nsStyleBackground::IsTransparent(const nsIFrame* aFrame) const
{
return IsTransparent(aFrame->StyleContext());
}
bool
nsStyleBackground::IsTransparent(nsStyleContext* aContext) const
{
return BottomLayer().mImage.IsEmpty() &&
mImage.mImageCount == 1 &&
NS_GET_A(mBackgroundColor) == 0;
NS_GET_A(BackgroundColor(aContext)) == 0;
}
void

View File

@ -942,8 +942,13 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBackground {
return nsChangeHint(0);
}
// Return the background color as nscolor.
nscolor BackgroundColor(const nsIFrame* aFrame) const;
nscolor BackgroundColor(nsStyleContext* aContext) const;
// True if this background is completely transparent.
bool IsTransparent() const;
bool IsTransparent(const nsIFrame* aFrame) const;
bool IsTransparent(nsStyleContext* aContext) const;
// We have to take slower codepaths for fixed background attachment,
// but we don't want to do that when there's no image.
@ -958,7 +963,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBackground {
const nsStyleImageLayers::Layer& BottomLayer() const { return mImage.BottomLayer(); }
nsStyleImageLayers mImage;
nscolor mBackgroundColor; // [reset]
mozilla::StyleComplexColor mBackgroundColor; // [reset]
};
#define NS_SPACING_MARGIN 0

View File

@ -83,7 +83,7 @@ var supported_properties = {
"-moz-outline-radius-topleft": [ test_radius_transition ],
"-moz-outline-radius-topright": [ test_radius_transition ],
"background-color": [ test_color_transition,
test_currentcolor_transition ],
test_true_currentcolor_transition ],
"background-position": [ test_background_position_transition,
// FIXME: We don't currently test clamping,
// since background-position uses calc() as

View File

@ -320,11 +320,10 @@ nsTableCellFrame::DecorateForSelection(DrawTarget* aDrawTarget, nsPoint aPt)
LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackground);
}
nscoord threePx = nsPresContext::CSSPixelsToAppUnits(3);
if ((mRect.width > threePx) && (mRect.height > threePx))
{
//compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor)
bordercolor = EnsureDifferentColors(bordercolor,
StyleBackground()->mBackgroundColor);
if ((mRect.width > threePx) && (mRect.height > threePx)) {
//compare bordercolor to background-color
bordercolor = EnsureDifferentColors(
bordercolor, StyleBackground()->BackgroundColor(this));
int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
Point devPixelOffset = NSPointToPoint(aPt, appUnitsPerDevPixel);
@ -501,7 +500,8 @@ nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// display background if we need to.
if (aBuilder->IsForEventDelivery() ||
!StyleBackground()->IsTransparent() || StyleDisplay()->mAppearance) {
!StyleBackground()->IsTransparent(this) ||
StyleDisplay()->mAppearance) {
if (!tableFrame->IsBorderCollapse() ||
aBuilder->IsAtRootOfPseudoStackingContext() ||
aBuilder->IsForEventDelivery()) {

View File

@ -1285,7 +1285,7 @@ static inline bool FrameHasBorderOrBackground(nsTableFrame* tableFrame, nsIFrame
if (f->StyleBorder()->HasBorder()) {
return true;
}
if (!f->StyleBackground()->IsTransparent() ||
if (!f->StyleBackground()->IsTransparent(f) ||
f->StyleDisplay()->mAppearance) {
nsTableCellFrame *cellFrame = do_QueryFrame(f);
@ -6362,7 +6362,7 @@ public:
nsTableCellMap* mTableCellMap;
nsCellMap* mCellMap;
WritingMode mTableWM;
const nsStyleBackground* mTableBgColor;
nscolor mTableBgColor;
nsTableFrame::RowGroupArray mRowGroups;
nsTableRowGroupFrame* mPrevRg;
@ -6480,7 +6480,7 @@ BCPaintBorderIterator::BCPaintBorderIterator(nsTableFrame* aTable)
nsIFrame* bgFrame =
nsCSSRendering::FindNonTransparentBackgroundFrame(aTable);
mTableBgColor = bgFrame->StyleBackground();
mTableBgColor = bgFrame->StyleBackground()->BackgroundColor(bgFrame);
}
bool

View File

@ -759,12 +759,12 @@ nsNativeTheme::IsDarkBackground(nsIFrame* aFrame)
}
nsStyleContext* bgSC = nullptr;
if (!nsCSSRendering::FindBackground(frame, &bgSC) ||
bgSC->StyleBackground()->IsTransparent()) {
bgSC->StyleBackground()->IsTransparent(bgSC)) {
nsIFrame* backgroundFrame = nsCSSRendering::FindNonTransparentBackgroundFrame(frame, true);
nsCSSRendering::FindBackground(backgroundFrame, &bgSC);
}
if (bgSC) {
nscolor bgColor = bgSC->StyleBackground()->mBackgroundColor;
nscolor bgColor = bgSC->StyleBackground()->BackgroundColor(bgSC);
// Consider the background color dark if the sum of the r, g and b values is
// less than 384 in a semi-transparent document. This heuristic matches what
// WebKit does, and we can improve it later if needed.