Bug 1536423 - Remove SVGCharClipDisplayItem r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D26191

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Miko Mynttinen 2019-04-04 18:04:49 +00:00
Родитель eafdaefb2c
Коммит 5463d7f522
5 изменённых файлов: 41 добавлений и 93 удалений

Просмотреть файл

@ -5109,7 +5109,8 @@ void nsDisplayText::RenderToContext(gfxContext* aCtx,
params.state = nsTextFrame::PaintTextParams::PaintText;
}
f->PaintText(params, *this, mOpacity);
f->PaintText(params, mVisIStartEdge, mVisIEndEdge, ToReferenceFrame(),
IsSelected(), mOpacity);
if (willClip) {
aCtx->PopClip();
@ -6771,7 +6772,10 @@ void nsTextFrame::PaintShadows(nsCSSShadowArray* aShadow,
}
void nsTextFrame::PaintText(const PaintTextParams& aParams,
const nsCharClipDisplayItem& aItem,
const nscoord aVisIStartEdge,
const nscoord aVisIEndEdge,
const nsPoint& aToReferenceFrame,
const bool aIsSelected,
float aOpacity /* = 1.0f */) {
// Don't pass in the rendering context here, because we need a
// *reference* context and rendering context might have some transform
@ -6782,11 +6786,9 @@ void nsTextFrame::PaintText(const PaintTextParams& aParams,
PropertyProvider provider(this, iter, nsTextFrame::eInflated, mFontMetrics);
const bool isSelected = aItem.IsSelected();
// Trim trailing whitespace, unless we're painting a selection highlight,
// which should include trailing spaces if present (bug 1146754).
provider.InitializeForDisplay(!isSelected);
provider.InitializeForDisplay(!aIsSelected);
const bool reversed = mTextRun->IsInlineReversed();
const bool verticalRun = mTextRun->IsVertical();
@ -6815,9 +6817,9 @@ void nsTextFrame::PaintText(const PaintTextParams& aParams,
uint32_t startOffset = range.start;
uint32_t maxLength = range.Length();
nscoord snappedStartEdge, snappedEndEdge;
if (!MeasureCharClippedText(provider, aItem.mVisIStartEdge,
aItem.mVisIEndEdge, &startOffset, &maxLength,
&snappedStartEdge, &snappedEndEdge)) {
if (!MeasureCharClippedText(provider, aVisIStartEdge, aVisIEndEdge,
&startOffset, &maxLength, &snappedStartEdge,
&snappedEndEdge)) {
return;
}
if (verticalRun) {
@ -6825,13 +6827,13 @@ void nsTextFrame::PaintText(const PaintTextParams& aParams,
} else {
textBaselinePt.x += reversed ? -snappedEndEdge : snappedStartEdge;
}
nsCharClipDisplayItem::ClipEdges clipEdges(aItem, snappedStartEdge,
snappedEndEdge);
nsCharClipDisplayItem::ClipEdges clipEdges(this, aToReferenceFrame,
snappedStartEdge, snappedEndEdge);
nsTextPaintStyle textPaintStyle(this);
textPaintStyle.SetResolveColors(!aParams.callbacks);
// Fork off to the (slower) paint-with-selection path if necessary.
if (isSelected) {
if (aIsSelected) {
MOZ_ASSERT(aOpacity == 1.0f, "We don't support opacity with selections!");
gfxSkipCharsIterator tmp(provider.GetStart());
Range contentRange(

Просмотреть файл

@ -456,8 +456,9 @@ class nsTextFrame : public nsFrame {
// to generate paths rather than paint the frame's text by passing a callback
// object. The private DrawText() is what applies the text to a graphics
// context.
void PaintText(const PaintTextParams& aParams,
const nsCharClipDisplayItem& aItem, float aOpacity = 1.0f);
void PaintText(const PaintTextParams& aParams, const nscoord aVisIStartEdge,
const nscoord aVisIEndEdge, const nsPoint& aToReferenceFrame,
const bool aIsSelected, float aOpacity = 1.0f);
// helper: paint text frame when we're impacted by at least one selection.
// Return false if the text was not painted and we should continue with
// the fast path.

Просмотреть файл

@ -66,8 +66,6 @@ DECLARE_DISPLAY_ITEM_TYPE(FILTER, TYPE_RENDERS_NO_IMAGES)
DECLARE_DISPLAY_ITEM_TYPE(SVG_OUTER_SVG, TYPE_RENDERS_NO_IMAGES)
DECLARE_DISPLAY_ITEM_TYPE(SVG_GEOMETRY, TYPE_IS_CONTENTFUL)
DECLARE_DISPLAY_ITEM_TYPE(SVG_TEXT, TYPE_IS_CONTENTFUL)
DECLARE_DISPLAY_ITEM_TYPE(SVG_CHAR_CLIP,
TYPE_RENDERS_NO_IMAGES | TYPE_IS_CONTENTFUL)
DECLARE_DISPLAY_ITEM_TYPE(SVG_WRAPPER, 0)
DECLARE_DISPLAY_ITEM_TYPE(FOREIGN_OBJECT, TYPE_IS_CONTENTFUL)
DECLARE_DISPLAY_ITEM_TYPE(TABLE_CELL_BACKGROUND, 0)

Просмотреть файл

@ -2162,33 +2162,6 @@ class nsDisplayItem : public nsDisplayItemLink {
nsDisplayItem(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
const ActiveScrolledRoot* aActiveScrolledRoot);
/**
* This constructor is only used in rare cases when we need to construct
* temporary items.
*/
explicit nsDisplayItem(nsIFrame* aFrame)
: mFrame(aFrame),
mClipChain(nullptr),
mClip(nullptr),
mActiveScrolledRoot(nullptr),
mReferenceFrame(nullptr),
mAnimatedGeometryRoot(nullptr),
mForceNotVisible(false),
mDisableSubpixelAA(false),
mReusedItem(false),
mBackfaceIsHidden(mFrame->BackfaceIsHidden()),
mCombines3DTransformWithAncestors(
mFrame->Combines3DTransformWithAncestors()),
mPaintRectValid(false),
mCanBeReused(true)
#ifdef MOZ_DUMP_PAINTING
,
mPainted(false)
#endif
{
MOZ_COUNT_CTOR(nsDisplayItem);
}
nsDisplayItem() = delete;
protected:
@ -7071,9 +7044,6 @@ class nsCharClipDisplayItem : public nsDisplayItem {
nsCharClipDisplayItem(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
: nsDisplayItem(aBuilder, aFrame), mVisIStartEdge(0), mVisIEndEdge(0) {}
explicit nsCharClipDisplayItem(nsIFrame* aFrame)
: nsDisplayItem(aFrame), mVisIStartEdge(0), mVisIEndEdge(0) {}
void RestoreState() override { nsDisplayItem::RestoreState(); }
nsDisplayItemGeometry* AllocateGeometry(
@ -7084,11 +7054,10 @@ class nsCharClipDisplayItem : public nsDisplayItem {
nsRegion* aInvalidRegion) const override;
struct ClipEdges {
ClipEdges(const nsDisplayItem& aItem, nscoord aVisIStartEdge,
nscoord aVisIEndEdge) {
nsRect r =
aItem.Frame()->GetScrollableOverflowRect() + aItem.ToReferenceFrame();
if (aItem.Frame()->GetWritingMode().IsVertical()) {
ClipEdges(const nsIFrame* aFrame, const nsPoint& aToReferenceFrame,
nscoord aVisIStartEdge, nscoord aVisIEndEdge) {
nsRect r = aFrame->GetScrollableOverflowRect() + aToReferenceFrame;
if (aFrame->GetWritingMode().IsVertical()) {
mVisIStart = aVisIStartEdge > 0 ? r.y + aVisIStartEdge : nscoord_MIN;
mVisIEnd = aVisIEndEdge > 0
? std::max(r.YMost() - aVisIEndEdge, mVisIStart)
@ -7111,14 +7080,8 @@ class nsCharClipDisplayItem : public nsDisplayItem {
nscoord mVisIEnd;
};
ClipEdges Edges() const {
return ClipEdges(*this, mVisIStartEdge, mVisIEndEdge);
}
static nsCharClipDisplayItem* CheckCast(nsDisplayItem* aItem) {
DisplayItemType t = aItem->GetType();
return (t == DisplayItemType::TYPE_TEXT ||
t == DisplayItemType::TYPE_SVG_CHAR_CLIP)
return (aItem->GetType() == DisplayItemType::TYPE_TEXT)
? static_cast<nsCharClipDisplayItem*>(aItem)
: nullptr;
}

Просмотреть файл

@ -557,13 +557,10 @@ struct TextRenderedRun {
* GetTransformFromRunUserSpaceToUserSpace should be used.
*
* @param aContext The context to use for unit conversions.
* @param aItem The nsCharClipDisplayItem that holds the amount of clipping
* from the left and right edges of the text frame for this rendered run.
* An appropriate nsCharClipDisplayItem can be obtained by constructing an
* SVGCharClipDisplayItem for the TextRenderedRun.
*/
gfxMatrix GetTransformFromUserSpaceForPainting(
nsPresContext* aContext, const nsCharClipDisplayItem& aItem) const;
nsPresContext* aContext, const nscoord aVisIStartEdge,
const nscoord aVisIEndEdge) const;
/**
* Returns the transform that converts from "run user space" to a <text>
@ -745,7 +742,8 @@ struct TextRenderedRun {
};
gfxMatrix TextRenderedRun::GetTransformFromUserSpaceForPainting(
nsPresContext* aContext, const nsCharClipDisplayItem& aItem) const {
nsPresContext* aContext, const nscoord aVisIStartEdge,
const nscoord aVisIEndEdge) const {
// We transform to device pixels positioned such that painting the text frame
// at (0,0) with aItem will result in the text being in the right place.
@ -770,13 +768,14 @@ gfxMatrix TextRenderedRun::GetTransformFromUserSpaceForPainting(
// Translation to get the text frame in the right place.
nsPoint t;
if (IsVertical()) {
t = nsPoint(-mBaseline, IsRightToLeft()
? -mFrame->GetRect().height + aItem.mVisIEndEdge
: -aItem.mVisIStartEdge);
? -mFrame->GetRect().height + aVisIEndEdge
: -aVisIStartEdge);
} else {
t = nsPoint(IsRightToLeft() ? -mFrame->GetRect().width + aItem.mVisIEndEdge
: -aItem.mVisIStartEdge,
t = nsPoint(IsRightToLeft() ? -mFrame->GetRect().width + aVisIEndEdge
: -aVisIStartEdge,
-mBaseline);
}
m.PreTranslate(AppUnitsToGfxUnits(t, aContext));
@ -2513,23 +2512,6 @@ bool CharIterator::MatchesFilter() const {
IsClusterAndLigatureGroupStart();
}
// -----------------------------------------------------------------------------
// nsCharClipDisplayItem
/**
* An nsCharClipDisplayItem that obtains its left and right clip edges from a
* TextRenderedRun object.
*/
class SVGCharClipDisplayItem final : public nsCharClipDisplayItem {
public:
explicit SVGCharClipDisplayItem(const TextRenderedRun& aRun)
: nsCharClipDisplayItem(aRun.mFrame) {
aRun.GetClipEdges(mVisIStartEdge, mVisIEndEdge);
}
NS_DISPLAY_DECL_NAME("SVGCharClip", TYPE_SVG_CHAR_CLIP)
};
// -----------------------------------------------------------------------------
// SVGTextDrawPathCallbacks
@ -3355,10 +3337,6 @@ void SVGTextFrame::PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform,
while (run.mFrame) {
nsTextFrame* frame = run.mFrame;
// Determine how much of the left and right edges of the text frame we
// need to ignore.
SVGCharClipDisplayItem item(run);
RefPtr<SVGContextPaintImpl> contextPaint = new SVGContextPaintImpl();
DrawMode drawMode = contextPaint->Init(&aDrawTarget, initialMatrix, frame,
outerContextPaint, aImgParams);
@ -3369,11 +3347,14 @@ void SVGTextFrame::PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform,
nsSVGUtils::SetupStrokeGeometry(frame, &aContext, outerContextPaint);
}
nscoord startEdge, endEdge;
run.GetClipEdges(startEdge, endEdge);
// Set up the transform for painting the text frame for the substring
// indicated by the run.
gfxMatrix runTransform =
run.GetTransformFromUserSpaceForPainting(presContext, item) *
currentMatrix;
gfxMatrix runTransform = run.GetTransformFromUserSpaceForPainting(
presContext, startEdge, endEdge) *
currentMatrix;
aContext.SetMatrixDouble(runTransform);
if (drawMode != DrawMode(0)) {
@ -3383,14 +3364,17 @@ void SVGTextFrame::PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform,
params.dirtyRect = LayoutDevicePixel::FromAppUnits(
frame->GetVisualOverflowRect(), auPerDevPx);
params.contextPaint = contextPaint;
const bool isSelected = frame->IsSelected();
if (ShouldRenderAsPath(frame, paintSVGGlyphs)) {
SVGTextDrawPathCallbacks callbacks(this, aContext, frame,
matrixForPaintServers, aImgParams,
paintSVGGlyphs);
params.callbacks = &callbacks;
frame->PaintText(params, item);
frame->PaintText(params, startEdge, endEdge, nsPoint(), isSelected);
} else {
frame->PaintText(params, item);
frame->PaintText(params, startEdge, endEdge, nsPoint(), isSelected);
}
}