--- a/layout/generic/TextDrawTarget.h
+++ b/layout/generic/TextDrawTarget.h
@@ -89,31 +89,30 @@ public:
// Each should only happen once, and in the given order.
enum class Phase : uint8_t {
eSelection, eUnderline, eOverline, eGlyphs, eEmphasisMarks, eLineThrough
};
explicit TextDrawTarget()
: mCurrentlyDrawing(Phase::eSelection), mHasUnsupportedFeatures(false)
{
- mCurrentTarget = gfx::Factory::CreateDrawTarget(gfx::BackendType::SKIA, IntSize(1, 1), gfx::SurfaceFormat::B8G8R8A8);
SetSelectionIndex(0);
}
// Prevent this from being copied
TextDrawTarget(const TextDrawTarget& src) = delete;
TextDrawTarget& operator=(const TextDrawTarget&) = delete;
// Change the phase of text we're drawing.
void StartDrawing(Phase aPhase) { mCurrentlyDrawing = aPhase; }
void FoundUnsupportedFeature() { mHasUnsupportedFeatures = true; }
void SetSelectionIndex(size_t i) {
// i should only be accessed if i-1 has already been
- MOZ_ASSERT(mParts.Length() <= i);
+ MOZ_ASSERT(i <= mParts.Length());
if (mParts.Length() == i){
mParts.AppendElement();
}
mCurrentPart = &mParts[i];
}
@@ -382,19 +381,16 @@ private:
Phase mCurrentlyDrawing;
// Which chunk of mParts is actively being populated
SelectedTextRunFragment* mCurrentPart;
// Chunks of the text, grouped by selection
nsTArray<SelectedTextRunFragment> mParts;
- // A dummy to handle parts of the DrawTarget impl we don't care for
- RefPtr<DrawTarget> mCurrentTarget;
-
// Whether Tofu or SVG fonts were encountered
bool mHasUnsupportedFeatures;
// The rest of this is dummy implementations of DrawTarget's API
public:
DrawTargetType GetType() const override {
return DrawTargetType::SOFTWARE_RASTER;
}
@@ -402,209 +398,214 @@ public:
BackendType GetBackendType() const override {
return BackendType::WEBRENDER_TEXT;
}
bool IsRecording() const override { return true; }
bool IsCaptureDT() const override { return false; }
already_AddRefed<SourceSurface> Snapshot() override {
- return mCurrentTarget->Snapshot();
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ return nullptr;
}
already_AddRefed<SourceSurface> IntoLuminanceSource(LuminanceType aLuminanceType,
float aOpacity) override {
- return mCurrentTarget->IntoLuminanceSource(aLuminanceType, aOpacity);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ return nullptr;
}
IntSize GetSize() override {
- return mCurrentTarget->GetSize();
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ return IntSize(1, 1);
}
void Flush() override {
- mCurrentTarget->Flush();
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void DrawCapturedDT(DrawTargetCapture *aCaptureDT,
const Matrix& aTransform) override {
- mCurrentTarget->DrawCapturedDT(aCaptureDT, aTransform);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void DrawSurface(SourceSurface *aSurface,
const Rect &aDest,
const Rect &aSource,
const DrawSurfaceOptions &aSurfOptions,
const DrawOptions &aOptions) override {
- mCurrentTarget->DrawSurface(aSurface, aDest, aSource, aSurfOptions, aOptions);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void DrawFilter(FilterNode *aNode,
const Rect &aSourceRect,
const Point &aDestPoint,
const DrawOptions &aOptions) override {
- mCurrentTarget->DrawFilter(aNode, aSourceRect, aDestPoint, aOptions);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void DrawSurfaceWithShadow(SourceSurface *aSurface,
const Point &aDest,
const Color &aColor,
const Point &aOffset,
Float aSigma,
CompositionOp aOperator) override {
- mCurrentTarget->DrawSurfaceWithShadow(aSurface, aDest, aColor, aOffset, aSigma, aOperator);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void ClearRect(const Rect &aRect) override {
- mCurrentTarget->ClearRect(aRect);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void CopySurface(SourceSurface *aSurface,
const IntRect &aSourceRect,
const IntPoint &aDestination) override {
- mCurrentTarget->CopySurface(aSurface, aSourceRect, aDestination);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void FillRect(const Rect &aRect,
const Pattern &aPattern,
const DrawOptions &aOptions = DrawOptions()) override {
- mCurrentTarget->FillRect(aRect, aPattern, aOptions);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void StrokeRect(const Rect &aRect,
const Pattern &aPattern,
const StrokeOptions &aStrokeOptions,
const DrawOptions &aOptions) override {
- mCurrentTarget->StrokeRect(aRect, aPattern, aStrokeOptions, aOptions);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void StrokeLine(const Point &aStart,
const Point &aEnd,
const Pattern &aPattern,
const StrokeOptions &aStrokeOptions,
const DrawOptions &aOptions) override {
- mCurrentTarget->StrokeLine(aStart, aEnd, aPattern, aStrokeOptions, aOptions);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void Stroke(const Path *aPath,
const Pattern &aPattern,
const StrokeOptions &aStrokeOptions,
const DrawOptions &aOptions) override {
- mCurrentTarget->Stroke(aPath, aPattern, aStrokeOptions, aOptions);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void Fill(const Path *aPath,
const Pattern &aPattern,
const DrawOptions &aOptions) override {
- mCurrentTarget->Fill(aPath, aPattern, aOptions);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void StrokeGlyphs(ScaledFont* aFont,
const GlyphBuffer& aBuffer,
const Pattern& aPattern,
const StrokeOptions& aStrokeOptions,
const DrawOptions& aOptions,
const GlyphRenderingOptions* aRenderingOptions) override {
- MOZ_ASSERT(mCurrentlyDrawing == Phase::eGlyphs);
- mCurrentTarget->StrokeGlyphs(aFont, aBuffer, aPattern,
- aStrokeOptions, aOptions, aRenderingOptions);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void Mask(const Pattern &aSource,
const Pattern &aMask,
const DrawOptions &aOptions) override {
- return mCurrentTarget->Mask(aSource, aMask, aOptions);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void MaskSurface(const Pattern &aSource,
SourceSurface *aMask,
Point aOffset,
const DrawOptions &aOptions) override {
- return mCurrentTarget->MaskSurface(aSource, aMask, aOffset, aOptions);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
bool Draw3DTransformedSurface(SourceSurface* aSurface,
const Matrix4x4& aMatrix) override {
- return mCurrentTarget->Draw3DTransformedSurface(aSurface, aMatrix);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void PushClip(const Path *aPath) override {
- mCurrentTarget->PushClip(aPath);
+ // Fine to pretend we do this
}
void PushClipRect(const Rect &aRect) override {
- mCurrentTarget->PushClipRect(aRect);
+ // Fine to pretend we do this
}
void PushDeviceSpaceClipRects(const IntRect* aRects, uint32_t aCount) override {
- mCurrentTarget->PushDeviceSpaceClipRects(aRects, aCount);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
}
void PopClip() override {
- mCurrentTarget->PopClip();
+ // Fine to pretend we do this
}
void PushLayer(bool aOpaque, Float aOpacity,
SourceSurface* aMask,
const Matrix& aMaskTransform,
const IntRect& aBounds,
bool aCopyBackground) override {
- mCurrentTarget->PushLayer(aOpaque, aOpacity, aMask, aMaskTransform, aBounds, aCopyBackground);
+ // Fine to pretend we do this
}
void PopLayer() override {
- mCurrentTarget->PopLayer();
+ // Fine to pretend we do this
}
already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
const IntSize &aSize,
int32_t aStride,
SurfaceFormat aFormat) const override {
- return mCurrentTarget->CreateSourceSurfaceFromData(aData, aSize, aStride, aFormat);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ return nullptr;
}
already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override {
- return mCurrentTarget->OptimizeSourceSurface(aSurface);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ return nullptr;
}
already_AddRefed<SourceSurface>
- CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override {
- return mCurrentTarget->CreateSourceSurfaceFromNativeSurface(aSurface);
+ CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override {
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ return nullptr;
}
already_AddRefed<DrawTarget>
- CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override {
- return mCurrentTarget->CreateSimilarDrawTarget(aSize, aFormat);
+ CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override {
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ return nullptr;
}
already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule) const override {
- return mCurrentTarget->CreatePathBuilder(aFillRule);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ return nullptr;
}
already_AddRefed<FilterNode> CreateFilter(FilterType aType) override {
- return mCurrentTarget->CreateFilter(aType);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ return nullptr;
}
already_AddRefed<GradientStops>
- CreateGradientStops(GradientStop *aStops,
- uint32_t aNumStops,
- ExtendMode aExtendMode) const override {
- return mCurrentTarget->CreateGradientStops(aStops, aNumStops, aExtendMode);
- }
-
- void SetTransform(const Matrix &aTransform) override {
- mCurrentTarget->SetTransform(aTransform);
- // Need to do this to make inherited GetTransform to work
- DrawTarget::SetTransform(aTransform);
+ CreateGradientStops(GradientStop *aStops,
+ uint32_t aNumStops,
+ ExtendMode aExtendMode) const override {
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ return nullptr;
}
void* GetNativeSurface(NativeSurfaceType aType) override {
- return mCurrentTarget->GetNativeSurface(aType);
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ return nullptr;
}
- void DetachAllSnapshots() override { mCurrentTarget->DetachAllSnapshots(); }
+ void DetachAllSnapshots() override {
+ MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
+ }
};
}
}
#endif