Backed out changeset 6a2e62e8c861 (bug 759568)

This commit is contained in:
Carsten "Tomcat" Book 2016-04-14 08:57:41 +02:00
parent 9447faf13b
commit 48bbe10c12
6 changed files with 12 additions and 112 deletions

View File

@ -1814,8 +1814,7 @@ nsCSSRendering::GetImageLayerClip(const nsStyleImageLayers::Layer& aLayer,
backgroundClip = NS_STYLE_IMAGELAYER_CLIP_PADDING; backgroundClip = NS_STYLE_IMAGELAYER_CLIP_PADDING;
} }
if (backgroundClip != NS_STYLE_IMAGELAYER_CLIP_BORDER && if (backgroundClip != NS_STYLE_IMAGELAYER_CLIP_BORDER) {
backgroundClip != NS_STYLE_IMAGELAYER_CLIP_TEXT) {
nsMargin border = aForFrame->GetUsedBorder(); nsMargin border = aForFrame->GetUsedBorder();
if (backgroundClip == NS_STYLE_IMAGELAYER_CLIP_MOZ_ALMOST_PADDING) { if (backgroundClip == NS_STYLE_IMAGELAYER_CLIP_MOZ_ALMOST_PADDING) {
// Reduce |border| by 1px (device pixels) on all sides, if // Reduce |border| by 1px (device pixels) on all sides, if

View File

@ -491,46 +491,6 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
} }
} }
static void
ClipBackgroundByText(nsIFrame* aFrame, nsRenderingContext* aContext,
const gfxRect& aFillRect)
{
// The main function of enabling background-clip:text property value.
// When a nsDisplayBackgroundImage detects "text" bg-clip style, it will call
// this function to
// 1. Ask every text frame objects in aFrame puts glyph paths into aContext.
// 2. Then, clip aContext.
//
// Then, nsDisplayBackgroundImage paints bg-images into this clipped region,
// so we get images embedded in text shape!
nsDisplayListBuilder builder(aFrame, nsDisplayListBuilder::GENERATE_GLYPH, false);
builder.EnterPresShell(aFrame);
nsDisplayList list;
aFrame->BuildDisplayListForStackingContext(&builder,
nsRect(nsPoint(0, 0), aFrame->GetSize()),
&list);
builder.LeavePresShell(aFrame);
#ifdef DEBUG
for (nsDisplayItem* i = list.GetBottom(); i; i = i->GetAbove()) {
MOZ_ASSERT(nsDisplayItem::TYPE_TEXT == i->GetType());
}
#endif
gfxContext* ctx = aContext->ThebesContext();
gfxContextMatrixAutoSaveRestore save(ctx);
ctx->SetMatrix(ctx->CurrentMatrix().Translate(aFillRect.TopLeft()));
ctx->NewPath();
RefPtr<LayerManager> layerManager =
list.PaintRoot(&builder, aContext, nsDisplayList::PAINT_DEFAULT);
ctx->Clip();
list.DeleteAll();
}
/* static */ void /* static */ void
nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer, nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer,
nsDisplayListBuilder* aBuilder, nsDisplayListBuilder* aBuilder,
@ -2824,7 +2784,6 @@ nsDisplayBackgroundImage::GetInsideClipRegion(nsDisplayItem* aItem,
} else { } else {
switch (aClip) { switch (aClip) {
case NS_STYLE_IMAGELAYER_CLIP_BORDER: case NS_STYLE_IMAGELAYER_CLIP_BORDER:
case NS_STYLE_IMAGELAYER_CLIP_TEXT:
clipRect = nsRect(aItem->ToReferenceFrame(), frame->GetSize()); clipRect = nsRect(aItem->ToReferenceFrame(), frame->GetSize());
break; break;
case NS_STYLE_IMAGELAYER_CLIP_PADDING: case NS_STYLE_IMAGELAYER_CLIP_PADDING:
@ -2862,8 +2821,7 @@ nsDisplayBackgroundImage::GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
NS_STYLE_BOX_DECORATION_BREAK_CLONE || NS_STYLE_BOX_DECORATION_BREAK_CLONE ||
(!mFrame->GetPrevContinuation() && !mFrame->GetNextContinuation())) { (!mFrame->GetPrevContinuation() && !mFrame->GetNextContinuation())) {
const nsStyleImageLayers::Layer& layer = mBackgroundStyle->mImage.mLayers[mLayer]; const nsStyleImageLayers::Layer& layer = mBackgroundStyle->mImage.mLayers[mLayer];
if (layer.mImage.IsOpaque() && layer.mBlendMode == NS_STYLE_BLEND_NORMAL && if (layer.mImage.IsOpaque() && layer.mBlendMode == NS_STYLE_BLEND_NORMAL) {
layer.mClip != NS_STYLE_IMAGELAYER_CLIP_TEXT) {
result = GetInsideClipRegion(this, layer.mClip, mBounds); result = GetInsideClipRegion(this, layer.mClip, mBounds);
} }
} }
@ -2937,30 +2895,17 @@ void
nsDisplayBackgroundImage::PaintInternal(nsDisplayListBuilder* aBuilder, nsDisplayBackgroundImage::PaintInternal(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx, const nsRect& aBounds, nsRenderingContext* aCtx, const nsRect& aBounds,
nsRect* aClipRect) { nsRect* aClipRect) {
nsPoint offset = ToReferenceFrame();
uint32_t flags = aBuilder->GetBackgroundPaintFlags(); uint32_t flags = aBuilder->GetBackgroundPaintFlags();
CheckForBorderItem(this, flags); 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) {
gfxRect bounds = nsLayoutUtils::RectToGfxRect(borderBox, mFrame->PresContext()->AppUnitsPerDevPixel());
ctx->Save();
ClipBackgroundByText(mFrame, aCtx, bounds);
}
image::DrawResult result = image::DrawResult result =
nsCSSRendering::PaintBackground(mFrame->PresContext(), *aCtx, mFrame, nsCSSRendering::PaintBackground(mFrame->PresContext(), *aCtx, mFrame,
aBounds, aBounds,
borderBox, nsRect(offset, mFrame->GetSize()),
flags, aClipRect, mLayer, flags, aClipRect, mLayer,
CompositionOp::OP_OVER); CompositionOp::OP_OVER);
if (clip == NS_STYLE_IMAGELAYER_CLIP_TEXT) {
ctx->Restore();
}
nsDisplayBackgroundGeometry::UpdateDrawResult(this, result); nsDisplayBackgroundGeometry::UpdateDrawResult(this, result);
} }
@ -3361,11 +3306,6 @@ nsDisplayBackgroundColor::Paint(nsDisplayListBuilder* aBuilder,
// pixel shorter in rare cases. Disabled in favor of the old code for now. // pixel shorter in rare cases. Disabled in favor of the old code for now.
// Note that the pref layout.css.devPixelsPerPx needs to be set to 1 to // Note that the pref layout.css.devPixelsPerPx needs to be set to 1 to
// reproduce the bug. // reproduce the bug.
//
// TODO:
// This new path does not include support for background-clip:text; need to
// be fixed if/when we switch to this new code path.
DrawTarget& aDrawTarget = *aCtx->GetDrawTarget(); DrawTarget& aDrawTarget = *aCtx->GetDrawTarget();
Rect rect = NSRectToSnappedRect(borderBox, Rect rect = NSRectToSnappedRect(borderBox,
@ -3379,17 +3319,6 @@ nsDisplayBackgroundColor::Paint(nsDisplayListBuilder* aBuilder,
gfxRect bounds = gfxRect bounds =
nsLayoutUtils::RectToGfxRect(borderBox, mFrame->PresContext()->AppUnitsPerDevPixel()); nsLayoutUtils::RectToGfxRect(borderBox, mFrame->PresContext()->AppUnitsPerDevPixel());
uint8_t clip = mBackgroundStyle->mImage.mLayers[0].mClip;
if (clip == NS_STYLE_IMAGELAYER_CLIP_TEXT) {
gfxContextAutoSaveRestore save(ctx);
ClipBackgroundByText(mFrame, aCtx, bounds);
ctx->SetColor(mColor);
ctx->Fill();
return;
}
ctx->SetColor(mColor); ctx->SetColor(mColor);
ctx->NewPath(); ctx->NewPath();
ctx->Rectangle(bounds, true); ctx->Rectangle(bounds, true);

View File

@ -226,8 +226,7 @@ public:
EVENT_DELIVERY, EVENT_DELIVERY,
PLUGIN_GEOMETRY, PLUGIN_GEOMETRY,
FRAME_VISIBILITY, FRAME_VISIBILITY,
TRANSFORM_COMPUTATION, TRANSFORM_COMPUTATION
GENERATE_GLYPH
}; };
nsDisplayListBuilder(nsIFrame* aReferenceFrame, Mode aMode, bool aBuildCaret); nsDisplayListBuilder(nsIFrame* aReferenceFrame, Mode aMode, bool aBuildCaret);
~nsDisplayListBuilder(); ~nsDisplayListBuilder();
@ -269,14 +268,6 @@ public:
*/ */
bool IsForFrameVisibility() { return mMode == FRAME_VISIBILITY; } bool IsForFrameVisibility() { return mMode == FRAME_VISIBILITY; }
/**
* @return true if the display list is being built for creating the glyph
* path from text items. While painting the display list, all text display
* items should only create glyph paths in target context, instead of
* drawing text into it.
*/
bool IsForGenerateGlyphPath() { return mMode == GENERATE_GLYPH; }
bool WillComputePluginGeometry() { return mWillComputePluginGeometry; } bool WillComputePluginGeometry() { return mWillComputePluginGeometry; }
/** /**
* @return true if "painting is suppressed" during page load and we * @return true if "painting is suppressed" during page load and we

View File

@ -1857,13 +1857,8 @@ nsFrame::DisplayBorderBackgroundOutline(nsDisplayListBuilder* aBuilder,
// The visibility check belongs here since child elements have the // The visibility check belongs here since child elements have the
// opportunity to override the visibility property and display even if // opportunity to override the visibility property and display even if
// their parent is hidden. // their parent is hidden.
if (!IsVisibleForPainting(aBuilder)) { if (!IsVisibleForPainting(aBuilder))
return; return;
}
if (aBuilder->IsForGenerateGlyphPath()) {
return;
}
nsCSSShadowArray* shadows = StyleEffects()->mBoxShadow; nsCSSShadowArray* shadows = StyleEffects()->mBoxShadow;
if (shadows && shadows->HasShadowWithInset(false)) { if (shadows && shadows->HasShadowWithInset(false)) {
@ -2559,16 +2554,10 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
if (aBuilder->IsBackgroundOnly()) if (aBuilder->IsBackgroundOnly())
return; return;
if (aBuilder->IsForGenerateGlyphPath()) {
if (nsGkAtoms::textFrame != aChild->GetType() && aChild->IsLeaf()) {
return;
}
}
nsIFrame* child = aChild; nsIFrame* child = aChild;
if (child->GetStateBits() & NS_FRAME_TOO_DEEP_IN_FRAME_TREE) if (child->GetStateBits() & NS_FRAME_TOO_DEEP_IN_FRAME_TREE)
return; return;
bool isSVG = (child->GetStateBits() & NS_FRAME_SVG_LAYOUT); bool isSVG = (child->GetStateBits() & NS_FRAME_SVG_LAYOUT);
// true if this is a real or pseudo stacking context // true if this is a real or pseudo stacking context

View File

@ -281,6 +281,8 @@ public:
explicit nsTextPaintStyle(nsTextFrame* aFrame); explicit nsTextPaintStyle(nsTextFrame* aFrame);
void SetResolveColors(bool aResolveColors) { void SetResolveColors(bool aResolveColors) {
NS_ASSERTION(mFrame->IsSVGText() || aResolveColors,
"must resolve colors is frame is not for SVG text");
mResolveColors = aResolveColors; mResolveColors = aResolveColors;
} }
@ -4797,11 +4799,9 @@ nsDisplayText::Paint(nsDisplayListBuilder* aBuilder,
pixelVisible.Inflate(2); pixelVisible.Inflate(2);
pixelVisible.RoundOut(); pixelVisible.RoundOut();
if (!aBuilder->IsForGenerateGlyphPath()) { ctx->NewPath();
ctx->NewPath(); ctx->Rectangle(pixelVisible);
ctx->Rectangle(pixelVisible); ctx->Clip();
ctx->Clip();
}
NS_ASSERTION(mVisIStartEdge >= 0, "illegal start edge"); NS_ASSERTION(mVisIStartEdge >= 0, "illegal start edge");
NS_ASSERTION(mVisIEndEdge >= 0, "illegal end edge"); NS_ASSERTION(mVisIEndEdge >= 0, "illegal end edge");
@ -4809,13 +4809,7 @@ nsDisplayText::Paint(nsDisplayListBuilder* aBuilder,
nsPoint framePt = ToReferenceFrame(); nsPoint framePt = ToReferenceFrame();
nsTextFrame::PaintTextParams params(aCtx->ThebesContext()); nsTextFrame::PaintTextParams params(aCtx->ThebesContext());
params.framePt = gfxPoint(framePt.x, framePt.y); params.framePt = gfxPoint(framePt.x, framePt.y);
params.dirtyRect = extraVisible; params.dirtyRect = extraVisible;
nsTextFrame::DrawPathCallbacks callbacks;
if (aBuilder->IsForGenerateGlyphPath()) {
params.callbacks = &callbacks;
}
f->PaintText(params, *this, mOpacity); f->PaintText(params, *this, mOpacity);
} }

View File

@ -387,8 +387,6 @@ public:
* has been emitted to the gfxContext. * has been emitted to the gfxContext.
*/ */
virtual void NotifySelectionDecorationLinePathEmitted() { } virtual void NotifySelectionDecorationLinePathEmitted() { }
virtual void NotifyGlyphPathEmitted() override {}
}; };
struct PaintTextParams struct PaintTextParams