Skip to content

Commit

Permalink
Back out 6 changesets (bug 1227327) for Android reftest failures in 9…
Browse files Browse the repository at this point in the history
…42672-1.html, background-position-2b.html and background-position-2c.html

CLOSED TREE

Backed out changeset c9b0ba301426 (bug 1227327)
Backed out changeset c857ad1fa01c (bug 1227327)
Backed out changeset 4ba58cd94310 (bug 1227327)
Backed out changeset 30e394faeb23 (bug 1227327)
Backed out changeset ce7fd04cc749 (bug 1227327)
Backed out changeset e0fe45294034 (bug 1227327)
  • Loading branch information
philor committed May 4, 2016
1 parent 6d562f3 commit f74761a
Show file tree
Hide file tree
Showing 24 changed files with 136 additions and 437 deletions.
13 changes: 0 additions & 13 deletions layout/base/RestyleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,19 +886,6 @@ RestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
hint |= nsChangeHint_RepaintFrame;
}

if (hint & nsChangeHint_UpdateBackgroundPosition) {
// For most frame types, DLBI can detect background position changes,
// so we only need to schedule a paint.
hint |= nsChangeHint_SchedulePaint;
if (frame->IsFrameOfType(nsIFrame::eTablePart) ||
frame->IsFrameOfType(nsIFrame::eMathML)) {
// Table parts and MathML frames don't build display items for their
// backgrounds, so DLBI can't detect background-position changes for
// these frames. Repaint the whole frame.
hint |= nsChangeHint_RepaintFrame;
}
}

if (hint & (nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView |
nsChangeHint_UpdateOpacityLayer | nsChangeHint_UpdateTransformLayer |
nsChangeHint_ChildrenOnlyTransform | nsChangeHint_SchedulePaint)) {
Expand Down
15 changes: 2 additions & 13 deletions layout/base/nsChangeHint.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,6 @@ enum nsChangeHint {
*/
nsChangeHint_UpdateUsesOpacity = 1 << 25,

/**
* Indicates that the 'background-position' property changed.
* Regular frames can invalidate these changes using DLBI, but
* for some frame types we need to repaint the whole frame because
* the frame does not build individual background image display items
* for each background layer.
*/
nsChangeHint_UpdateBackgroundPosition = 1 << 26,

// IMPORTANT NOTE: When adding new hints, consider whether you need to
// add them to NS_HintsNotHandledForDescendantsIn() below. Please also
// add them to RestyleManager::ChangeHintToString.
Expand Down Expand Up @@ -312,8 +303,7 @@ inline nsChangeHint operator^=(nsChangeHint& aLeft, nsChangeHint aRight)
nsChangeHint_ReflowChangesSizeOrPosition | \
nsChangeHint_ClearAncestorIntrinsics | \
nsChangeHint_UpdateComputedBSize | \
nsChangeHint_UpdateUsesOpacity | \
nsChangeHint_UpdateBackgroundPosition)
nsChangeHint_UpdateUsesOpacity)

inline nsChangeHint NS_HintsNotHandledForDescendantsIn(nsChangeHint aChangeHint) {
nsChangeHint result = nsChangeHint(aChangeHint & (
Expand All @@ -329,8 +319,7 @@ inline nsChangeHint NS_HintsNotHandledForDescendantsIn(nsChangeHint aChangeHint)
nsChangeHint_UpdateContainingBlock |
nsChangeHint_BorderStyleNoneChange |
nsChangeHint_UpdateComputedBSize |
nsChangeHint_UpdateUsesOpacity | \
nsChangeHint_UpdateBackgroundPosition));
nsChangeHint_UpdateUsesOpacity));

if (!NS_IsHintSubset(nsChangeHint_NeedDirtyReflow, aChangeHint)) {
if (NS_IsHintSubset(nsChangeHint_NeedReflow, aChangeHint)) {
Expand Down
96 changes: 51 additions & 45 deletions layout/base/nsDisplayList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2311,11 +2311,9 @@ RegisterThemeGeometry(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsDisplayBackgroundImage::nsDisplayBackgroundImage(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
uint32_t aLayer,
const nsRect& aBackgroundRect,
const nsStyleBackground* aBackgroundStyle)
: nsDisplayImageContainer(aBuilder, aFrame)
, mBackgroundStyle(aBackgroundStyle)
, mBackgroundRect(aBackgroundRect)
, mLayer(aLayer)
, mIsRasterImage(false)
{
Expand Down Expand Up @@ -2383,12 +2381,13 @@ static nsStyleContext* GetBackgroundStyleContext(nsIFrame* aFrame)
SetBackgroundClipRegion(DisplayListClipState::AutoSaveRestore& aClipState,
nsIFrame* aFrame, const nsPoint& aToReferenceFrame,
const nsStyleImageLayers::Layer& aLayer,
const nsRect& aBackgroundRect,
bool aWillPaintBorder)
{
nsRect borderBox = nsRect(aToReferenceFrame, aFrame->GetSize());

nsCSSRendering::ImageLayerClipState clip;
nsCSSRendering::GetImageLayerClip(aLayer, aFrame, *aFrame->StyleBorder(),
aBackgroundRect, aBackgroundRect, aWillPaintBorder,
borderBox, borderBox, aWillPaintBorder,
aFrame->PresContext()->AppUnitsPerDevPixel(),
&clip);

Expand All @@ -2404,13 +2403,10 @@ SetBackgroundClipRegion(DisplayListClipState::AutoSaveRestore& aClipState,
/*static*/ bool
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
const nsRect& aBackgroundRect,
nsDisplayList* aList,
bool aAllowWillPaintBorderOptimization)
nsDisplayList* aList)
{
nsStyleContext* bgSC = nullptr;
const nsStyleBackground* bg = nullptr;
nsRect bgRect = aBackgroundRect + aBuilder->ToReferenceFrame(aFrame);
nsPresContext* presContext = aFrame->PresContext();
bool isThemed = aFrame->IsThemed();
if (!isThemed) {
Expand All @@ -2435,8 +2431,7 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
const nsStyleEffects* effectsStyle = aFrame->StyleEffects();
bool hasInsetShadow = effectsStyle->mBoxShadow &&
effectsStyle->mBoxShadow->HasShadowWithInset(true);
bool willPaintBorder = aAllowWillPaintBorderOptimization &&
!isThemed && !hasInsetShadow &&
bool willPaintBorder = !isThemed && !hasInsetShadow &&
borderStyle->HasBorder();

nsPoint toRef = aBuilder->ToReferenceFrame(aFrame);
Expand All @@ -2461,11 +2456,11 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
bool useWillPaintBorderOptimization = willPaintBorder &&
nsLayoutUtils::HasNonZeroCorner(borderStyle->mBorderRadius);
SetBackgroundClipRegion(clipState, aFrame, toRef,
bg->BottomLayer(), bgRect,
bg->BottomLayer(),
useWillPaintBorderOptimization);
}
bgItemList.AppendNewToTop(
new (aBuilder) nsDisplayBackgroundColor(aBuilder, aFrame, bgRect, bg,
new (aBuilder) nsDisplayBackgroundColor(aBuilder, aFrame, bg,
drawBackgroundColor ? color : NS_RGBA(0, 0, 0, 0)));
}

Expand All @@ -2477,7 +2472,7 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
new (aBuilder) nsDisplayClearBackground(aBuilder, aFrame));
}
nsDisplayThemedBackground* bgItem =
new (aBuilder) nsDisplayThemedBackground(aBuilder, aFrame, bgRect);
new (aBuilder) nsDisplayThemedBackground(aBuilder, aFrame);
bgItemList.AppendNewToTop(bgItem);
aList->AppendToTop(&bgItemList);
return true;
Expand Down Expand Up @@ -2508,12 +2503,12 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
if (!aBuilder->IsForEventDelivery()) {
const nsStyleImageLayers::Layer& layer = bg->mImage.mLayers[i];
SetBackgroundClipRegion(clipState, aFrame, toRef,
layer, bgRect, willPaintBorder);
layer, willPaintBorder);
}

nsDisplayList thisItemList;
nsDisplayBackgroundImage* bgItem =
new (aBuilder) nsDisplayBackgroundImage(aBuilder, aFrame, i, bgRect, bg);
new (aBuilder) nsDisplayBackgroundImage(aBuilder, aFrame, i, bg);

if (bgItem->ShouldFixToViewport(aBuilder)) {
thisItemList.AppendNewToTop(
Expand Down Expand Up @@ -2780,27 +2775,34 @@ nsDisplayBackgroundImage::ComputeVisibility(nsDisplayListBuilder* aBuilder,
/* static */ nsRegion
nsDisplayBackgroundImage::GetInsideClipRegion(nsDisplayItem* aItem,
uint8_t aClip,
const nsRect& aRect,
const nsRect& aBackgroundRect)
const nsRect& aRect)
{
nsRegion result;
if (aRect.IsEmpty())
return result;

nsIFrame *frame = aItem->Frame();

nsRect clipRect = aBackgroundRect;
nsRect clipRect;
if (frame->GetType() == nsGkAtoms::canvasFrame) {
nsCanvasFrame* canvasFrame = static_cast<nsCanvasFrame*>(frame);
clipRect = canvasFrame->CanvasArea() + aItem->ToReferenceFrame();
} else if (aClip == NS_STYLE_IMAGELAYER_CLIP_PADDING ||
aClip == NS_STYLE_IMAGELAYER_CLIP_CONTENT) {
nsMargin border = frame->GetUsedBorder();
if (aClip == NS_STYLE_IMAGELAYER_CLIP_CONTENT) {
border += frame->GetUsedPadding();
} else {
switch (aClip) {
case NS_STYLE_IMAGELAYER_CLIP_BORDER:
case NS_STYLE_IMAGELAYER_CLIP_TEXT:
clipRect = nsRect(aItem->ToReferenceFrame(), frame->GetSize());
break;
case NS_STYLE_IMAGELAYER_CLIP_PADDING:
clipRect = frame->GetPaddingRect() - frame->GetPosition() + aItem->ToReferenceFrame();
break;
case NS_STYLE_IMAGELAYER_CLIP_CONTENT:
clipRect = frame->GetContentRectRelativeToSelf() + aItem->ToReferenceFrame();
break;
default:
NS_NOTREACHED("Unknown clip type");
return result;
}
border.ApplySkipSides(frame->GetSkipSides());
clipRect.Deflate(border);
}

return clipRect.Intersect(aRect);
Expand Down Expand Up @@ -2828,7 +2830,7 @@ nsDisplayBackgroundImage::GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
const nsStyleImageLayers::Layer& layer = mBackgroundStyle->mImage.mLayers[mLayer];
if (layer.mImage.IsOpaque() && layer.mBlendMode == NS_STYLE_BLEND_NORMAL &&
layer.mClip != NS_STYLE_IMAGELAYER_CLIP_TEXT) {
result = GetInsideClipRegion(this, layer.mClip, mBounds, mBackgroundRect);
result = GetInsideClipRegion(this, layer.mClip, mBounds);
}
}

Expand All @@ -2854,7 +2856,7 @@ nsDisplayBackgroundImage::GetPositioningArea()
bool transformedFixed;
return nsCSSRendering::ComputeImageLayerPositioningArea(
mFrame->PresContext(), mFrame,
mBackgroundRect,
nsRect(ToReferenceFrame(), mFrame->GetSize()),
mBackgroundStyle->mImage.mLayers[mLayer],
&attachedToFrame,
&transformedFixed) + ToReferenceFrame();
Expand Down Expand Up @@ -2906,18 +2908,19 @@ nsDisplayBackgroundImage::PaintInternal(nsDisplayListBuilder* aBuilder,
uint32_t flags = aBuilder->GetBackgroundPaintFlags();
CheckForBorderItem(this, flags);

nsRect borderBox = nsRect(ToReferenceFrame(), mFrame->GetSize());
gfxContext* ctx = aCtx->ThebesContext();
uint8_t clip = mBackgroundStyle->mImage.mLayers[mLayer].mClip;

if (clip == NS_STYLE_IMAGELAYER_CLIP_TEXT) {
ctx->Save();
ClipBackgroundByText(mFrame, aCtx, mBackgroundRect);
ClipBackgroundByText(mFrame, aCtx, borderBox);
}

image::DrawResult result =
nsCSSRendering::PaintBackground(mFrame->PresContext(), *aCtx, mFrame,
aBounds,
mBackgroundRect,
borderBox,
flags, aClipRect, mLayer,
CompositionOp::OP_OVER);

Expand Down Expand Up @@ -2992,7 +2995,8 @@ nsDisplayBackgroundImage::GetBoundsInternal(nsDisplayListBuilder* aBuilder) {
return nsRect();
}

nsRect clipRect = mBackgroundRect;
nsRect borderBox = nsRect(ToReferenceFrame(), mFrame->GetSize());
nsRect clipRect = borderBox;
if (mFrame->GetType() == nsGkAtoms::canvasFrame) {
nsCanvasFrame* frame = static_cast<nsCanvasFrame*>(mFrame);
clipRect = frame->CanvasArea() + ToReferenceFrame();
Expand All @@ -3008,7 +3012,7 @@ nsDisplayBackgroundImage::GetBoundsInternal(nsDisplayListBuilder* aBuilder) {
}
const nsStyleImageLayers::Layer& layer = mBackgroundStyle->mImage.mLayers[mLayer];
return nsCSSRendering::GetBackgroundLayerRect(presContext, mFrame,
mBackgroundRect, clipRect, layer,
borderBox, clipRect, layer,
aBuilder->GetBackgroundPaintFlags());
}

Expand All @@ -3020,10 +3024,8 @@ nsDisplayBackgroundImage::GetPerFrameKey()
}

nsDisplayThemedBackground::nsDisplayThemedBackground(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
const nsRect& aBackgroundRect)
nsIFrame* aFrame)
: nsDisplayItem(aBuilder, aFrame)
, mBackgroundRect(aBackgroundRect)
{
MOZ_COUNT_CTOR(nsDisplayThemedBackground);

Expand Down Expand Up @@ -3066,8 +3068,8 @@ nsDisplayThemedBackground::HitTest(nsDisplayListBuilder* aBuilder,
HitTestState* aState,
nsTArray<nsIFrame*> *aOutFrames)
{
// Assume that any point in our background rect is a hit.
if (mBackgroundRect.Intersects(aRect)) {
// Assume that any point in our border rect is a hit.
if (nsRect(ToReferenceFrame(), mFrame->GetSize()).Intersects(aRect)) {
aOutFrames->AppendElement(mFrame);
}
}
Expand All @@ -3079,7 +3081,7 @@ nsDisplayThemedBackground::GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
*aSnap = false;

if (mThemeTransparency == nsITheme::eOpaque) {
result = mBackgroundRect;
result = nsRect(ToReferenceFrame(), mFrame->GetSize());
}
return result;
}
Expand All @@ -3104,7 +3106,7 @@ nsDisplayThemedBackground::ProvidesFontSmoothingBackgroundColor(nscolor* aColor)
nsRect
nsDisplayThemedBackground::GetPositioningArea()
{
return mBackgroundRect;
return nsRect(ToReferenceFrame(), mFrame->GetSize());
}

void
Expand All @@ -3123,11 +3125,12 @@ nsDisplayThemedBackground::PaintInternal(nsDisplayListBuilder* aBuilder,
// XXXzw this ignores aClipRect.
nsPresContext* presContext = mFrame->PresContext();
nsITheme *theme = presContext->GetTheme();
nsRect drawing(mBackgroundRect);
nsRect borderArea(ToReferenceFrame(), mFrame->GetSize());
nsRect drawing(borderArea);
theme->GetWidgetOverflow(presContext->DeviceContext(), mFrame, mAppearance,
&drawing);
drawing.IntersectRect(drawing, aBounds);
theme->DrawWidgetBackground(aCtx, mFrame, mAppearance, mBackgroundRect, drawing);
theme->DrawWidgetBackground(aCtx, mFrame, mAppearance, borderArea, drawing);
}

bool nsDisplayThemedBackground::IsWindowActive()
Expand Down Expand Up @@ -3172,7 +3175,7 @@ nsRect
nsDisplayThemedBackground::GetBoundsInternal() {
nsPresContext* presContext = mFrame->PresContext();

nsRect r = mBackgroundRect - ToReferenceFrame();
nsRect r(nsPoint(0,0), mFrame->GetSize());
presContext->GetTheme()->
GetWidgetOverflow(presContext->DeviceContext(), mFrame,
mFrame->StyleDisplay()->mAppearance, &r);
Expand Down Expand Up @@ -3317,6 +3320,8 @@ nsDisplayBackgroundColor::Paint(nsDisplayListBuilder* aBuilder,
return;
}

nsRect borderBox = nsRect(ToReferenceFrame(), mFrame->GetSize());

#if 0
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1148418#c21 for why this
// results in a precision induced rounding issue that makes the rect one
Expand All @@ -3330,7 +3335,7 @@ nsDisplayBackgroundColor::Paint(nsDisplayListBuilder* aBuilder,

DrawTarget& aDrawTarget = *aCtx->GetDrawTarget();

Rect rect = NSRectToSnappedRect(mBackgroundRect,
Rect rect = NSRectToSnappedRect(borderBox,
mFrame->PresContext()->AppUnitsPerDevPixel(),
aDrawTarget);
ColorPattern color(ToDeviceColor(mColor));
Expand All @@ -3342,15 +3347,15 @@ nsDisplayBackgroundColor::Paint(nsDisplayListBuilder* aBuilder,
if (clip == NS_STYLE_IMAGELAYER_CLIP_TEXT) {
gfxContextAutoSaveRestore save(ctx);

ClipBackgroundByText(mFrame, aCtx, mBackgroundRect);
ClipBackgroundByText(mFrame, aCtx, borderBox);
ctx->SetColor(mColor);
ctx->Fill();

return;
}

gfxRect bounds =
nsLayoutUtils::RectToGfxRect(mBackgroundRect, mFrame->PresContext()->AppUnitsPerDevPixel());
nsLayoutUtils::RectToGfxRect(borderBox, mFrame->PresContext()->AppUnitsPerDevPixel());

ctx->SetColor(mColor);
ctx->NewPath();
Expand All @@ -3375,8 +3380,9 @@ nsDisplayBackgroundColor::GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
*aSnap = true;

const nsStyleImageLayers::Layer& bottomLayer = mBackgroundStyle->BottomLayer();
nsRect borderBox = nsRect(ToReferenceFrame(), mFrame->GetSize());
return nsDisplayBackgroundImage::GetInsideClipRegion(this, bottomLayer.mClip,
mBackgroundRect, mBackgroundRect);
borderBox);
}

bool
Expand Down
Loading

0 comments on commit f74761a

Please sign in to comment.