Skip to content

Commit

Permalink
Backed out changeset 0e8e25c04938 (bug 1216851) for reftest failures
Browse files Browse the repository at this point in the history
  • Loading branch information
BavarianTomcat committed Oct 29, 2015
1 parent ed04efa commit 513d05c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 96 deletions.
130 changes: 38 additions & 92 deletions layout/generic/nsTextFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4578,11 +4578,28 @@ nsTextFrame::CharacterDataChanged(CharacterDataChangeInfo* aInfo)
return NS_OK;
}

class nsDisplayTextGeometry : public nsCharClipGeometry
{
public:
nsDisplayTextGeometry(nsCharClipDisplayItem* aItem, nsDisplayListBuilder* aBuilder)
: nsCharClipGeometry(aItem, aBuilder)
{
nsTextFrame* f = static_cast<nsTextFrame*>(aItem->Frame());
f->GetTextDecorations(f->PresContext(), nsTextFrame::eResolvedColors, mDecorations);
}

/**
* We store the computed text decorations here since they are
* computed using style data from parent frames. Any changes to these
* styles will only invalidate the parent frame and not this frame.
*/
nsTextFrame::TextDecorations mDecorations;
};

class nsDisplayText : public nsCharClipDisplayItem {
public:
nsDisplayText(nsDisplayListBuilder* aBuilder, nsTextFrame* aFrame) :
nsCharClipDisplayItem(aBuilder, aFrame),
mOpacity(1.0f),
mDisableSubpixelAA(false) {
MOZ_COUNT_CTOR(nsDisplayText);
}
Expand Down Expand Up @@ -4617,102 +4634,40 @@ class nsDisplayText : public nsCharClipDisplayItem {
return GetBounds(aBuilder, &snap);
}

virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override;
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override
{
return new nsDisplayTextGeometry(this, aBuilder);
}

virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion) override;

virtual void DisableComponentAlpha() override {
mDisableSubpixelAA = true;
}

bool CanApplyOpacity() const override
nsRegion *aInvalidRegion) override
{
const nsDisplayTextGeometry* geometry = static_cast<const nsDisplayTextGeometry*>(aGeometry);
nsTextFrame* f = static_cast<nsTextFrame*>(mFrame);
if (f->IsSelected()) {
return false;
}

const nsStyleText* textStyle = f->StyleText();
if (textStyle->mTextShadow) {
return false;
}

nsTextFrame::TextDecorations decorations;
f->GetTextDecorations(f->PresContext(), nsTextFrame::eResolvedColors, decorations);
if (decorations.HasDecorationLines()) {
return false;
}

return true;
}

void ApplyOpacity(nsDisplayListBuilder* aBuilder,
float aOpacity,
const DisplayItemClip* aClip) override
{
NS_ASSERTION(CanApplyOpacity(), "ApplyOpacity should be allowed");
mOpacity = aOpacity;
if (aClip) {
IntersectClip(aBuilder, *aClip);
bool snap;
nsRect newRect = geometry->mBounds;
nsRect oldRect = GetBounds(aBuilder, &snap);
if (decorations != geometry->mDecorations ||
mVisIStartEdge != geometry->mVisIStartEdge ||
mVisIEndEdge != geometry->mVisIEndEdge ||
!oldRect.IsEqualInterior(newRect) ||
!geometry->mBorderRect.IsEqualInterior(GetBorderRect())) {
aInvalidRegion->Or(oldRect, newRect);
}
}

float mOpacity;
bool mDisableSubpixelAA;
};

class nsDisplayTextGeometry : public nsCharClipGeometry
{
public:
nsDisplayTextGeometry(nsDisplayText* aItem, nsDisplayListBuilder* aBuilder)
: nsCharClipGeometry(aItem, aBuilder)
, mOpacity(aItem->mOpacity)
{
nsTextFrame* f = static_cast<nsTextFrame*>(aItem->Frame());
f->GetTextDecorations(f->PresContext(), nsTextFrame::eResolvedColors, mDecorations);
virtual void DisableComponentAlpha() override {
mDisableSubpixelAA = true;
}

/**
* We store the computed text decorations here since they are
* computed using style data from parent frames. Any changes to these
* styles will only invalidate the parent frame and not this frame.
*/
nsTextFrame::TextDecorations mDecorations;
float mOpacity;
bool mDisableSubpixelAA;
};

nsDisplayItemGeometry*
nsDisplayText::AllocateGeometry(nsDisplayListBuilder* aBuilder)
{
return new nsDisplayTextGeometry(this, aBuilder);
}

void
nsDisplayText::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion)
{
const nsDisplayTextGeometry* geometry = static_cast<const nsDisplayTextGeometry*>(aGeometry);
nsTextFrame* f = static_cast<nsTextFrame*>(mFrame);

nsTextFrame::TextDecorations decorations;
f->GetTextDecorations(f->PresContext(), nsTextFrame::eResolvedColors, decorations);

bool snap;
nsRect newRect = geometry->mBounds;
nsRect oldRect = GetBounds(aBuilder, &snap);
if (decorations != geometry->mDecorations ||
mVisIStartEdge != geometry->mVisIStartEdge ||
mVisIEndEdge != geometry->mVisIEndEdge ||
!oldRect.IsEqualInterior(newRect) ||
!geometry->mBorderRect.IsEqualInterior(GetBorderRect()) ||
mOpacity != geometry->mOpacity) {
aInvalidRegion->Or(oldRect, newRect);
}
}

void
nsDisplayText::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx) {
Expand Down Expand Up @@ -4743,8 +4698,7 @@ nsDisplayText::Paint(nsDisplayListBuilder* aBuilder,

NS_ASSERTION(mVisIStartEdge >= 0, "illegal start edge");
NS_ASSERTION(mVisIEndEdge >= 0, "illegal end edge");
f->PaintText(aCtx, ToReferenceFrame(), extraVisible, *this,
nullptr, nullptr, mOpacity);
f->PaintText(aCtx, ToReferenceFrame(), extraVisible, *this);
}

void
Expand Down Expand Up @@ -6280,8 +6234,7 @@ nsTextFrame::PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
const nsRect& aDirtyRect,
const nsCharClipDisplayItem& aItem,
gfxTextContextPaint* aContextPaint,
nsTextFrame::DrawPathCallbacks* aCallbacks,
float aOpacity /* = 1.0f */)
nsTextFrame::DrawPathCallbacks* aCallbacks)
{
// Don't pass in aRenderingContext here, because we need a *reference*
// context and aRenderingContext might have some transform in it
Expand Down Expand Up @@ -6338,7 +6291,6 @@ nsTextFrame::PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
aDirtyRect.width, aDirtyRect.height);
// Fork off to the (slower) paint-with-selection path if necessary.
if (IsSelected()) {
MOZ_ASSERT(aOpacity == 1.0f, "We don't support opacity with selections!");
gfxSkipCharsIterator tmp(provider.GetStart());
int32_t contentOffset = tmp.ConvertSkippedToOriginal(startOffset);
int32_t contentLength =
Expand All @@ -6352,12 +6304,6 @@ nsTextFrame::PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
}

nscolor foregroundColor = textPaintStyle.GetTextColor();
if (aOpacity != 1.0f) {
gfx::Color gfxColor = gfx::Color::FromABGR(foregroundColor);
gfxColor.a *= aOpacity;
foregroundColor = gfxColor.ToABGR();
}

if (!aCallbacks) {
const nsStyleText* textStyle = StyleText();
PaintShadows(textStyle->mTextShadow, startOffset, maxLength,
Expand Down
3 changes: 1 addition & 2 deletions layout/generic/nsTextFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ class nsTextFrame : public nsTextFrameBase {
void PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
const nsRect& aDirtyRect, const nsCharClipDisplayItem& aItem,
gfxTextContextPaint* aContextPaint = nullptr,
DrawPathCallbacks* aCallbacks = nullptr,
float aOpacity = 1.0f);
DrawPathCallbacks* aCallbacks = nullptr);
// 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.
Expand Down
2 changes: 1 addition & 1 deletion layout/reftests/bugs/reftest.list
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ random-if(Android&&AndroidVersion<15) == 776265-1a.html 776265-1-ref.html
== 786254-1.html 786254-1-ref.html
== 787947-1.html 787947-1-ref.html
== 796847-1.svg 796847-1-ref.svg
fuzzy(40,875) fuzzy-if(azureQuartz,73,542) == 797797-1.html 797797-1-ref.html # 'opacity:N' and rgba(,,,N) text don't match precisely
fuzzy(40,850) fuzzy-if(azureQuartz,73,542) == 797797-1.html 797797-1-ref.html # 'opacity:N' and rgba(,,,N) text don't match precisely
fuzzy(40,850) fuzzy-if(azureQuartz,68,586) == 797797-2.html 797797-2-ref.html # 'opacity:N' and rgba(,,,N) text don't match precisely
== 801994-1.html 801994-1-ref.html
== 804323-1.html 804323-1-ref.html
Expand Down
2 changes: 1 addition & 1 deletion layout/reftests/text-overflow/reftest.list
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ skip-if(B2G||Mulet) HTTP(..) == marker-string.html marker-string-ref.html # Init
skip-if(Android||B2G) HTTP(..) == bidi-simple.html bidi-simple-ref.html # Fails on Android due to anti-aliasing
skip-if(!gtkWidget) fuzzy-if(gtkWidget,2,289) HTTP(..) == bidi-simple-scrolled.html bidi-simple-scrolled-ref.html # Fails on Windows and OSX due to anti-aliasing
skip-if(B2G||Mulet) fuzzy-if(Android&&AndroidVersion<15,206,41) fuzzy-if(Android&&AndroidVersion>=15,24,4000) fuzzy-if(cocoaWidget,1,40) fuzzy-if(asyncPan&&!layersGPUAccelerated,102,1770) HTTP(..) == scroll-rounding.html scroll-rounding-ref.html # bug 760264 # Initial mulet triage: parity with B2G/B2G Desktop
fuzzy(2,304) HTTP(..) == anonymous-block.html anonymous-block-ref.html
fuzzy-if(OSX==1008,1,1) HTTP(..) == anonymous-block.html anonymous-block-ref.html
skip-if(B2G||Mulet) HTTP(..) == false-marker-overlap.html false-marker-overlap-ref.html # Initial mulet triage: parity with B2G/B2G Desktop
HTTP(..) == visibility-hidden.html visibility-hidden-ref.html
skip-if(B2G||Mulet) fuzzy-if(asyncPan&&!layersGPUAccelerated,102,1724) HTTP(..) == block-padding.html block-padding-ref.html # Initial mulet triage: parity with B2G/B2G Desktop
Expand Down

0 comments on commit 513d05c

Please sign in to comment.