Bug 1414097 - Convert nsDisplaySelectionOverlay to WebRender. r=ethlin

MozReview-Commit-ID: 5icpe4OR0Qa
This commit is contained in:
Markus Stange
2017-11-02 19:43:08 -04:00
parent c00d6ff598
commit 6d9891d83a

View File

@@ -2117,16 +2117,21 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) override;
bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
const StackingContextHelper& aSc,
mozilla::layers::WebRenderLayerManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) override;
NS_DISPLAY_DECL_NAME("SelectionOverlay", TYPE_SELECTION_OVERLAY)
private:
Color ComputeColor() const;
int16_t mSelectionValue;
};
void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx)
Color
nsDisplaySelectionOverlay::ComputeColor() const
{
DrawTarget& aDrawTarget = *aCtx->GetDrawTarget();
LookAndFeel::ColorID colorID;
if (mSelectionValue == nsISelectionController::SELECTION_ON) {
colorID = LookAndFeel::eColorID_TextSelectBackground;
@@ -2138,7 +2143,14 @@ void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
Color c = Color::FromABGR(LookAndFeel::GetColor(colorID, NS_RGB(255, 255, 255)));
c.a = .5;
ColorPattern color(ToDeviceColor(c));
return ToDeviceColor(c);
}
void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx)
{
DrawTarget& aDrawTarget = *aCtx->GetDrawTarget();
ColorPattern color(ComputeColor());
nsIntRect pxRect =
mVisibleRect.ToOutsidePixels(mFrame->PresContext()->AppUnitsPerDevPixel());
@@ -2148,6 +2160,22 @@ void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
aDrawTarget.FillRect(rect, color);
}
bool
nsDisplaySelectionOverlay::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
const StackingContextHelper& aSc,
mozilla::layers::WebRenderLayerManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder)
{
wr::LayoutRect bounds = aSc.ToRelativeLayoutRect(
LayoutDeviceRect::FromAppUnits(nsRect(ToReferenceFrame(), Frame()->GetSize()),
mFrame->PresContext()->AppUnitsPerDevPixel()));
aBuilder.PushRect(bounds, bounds, !BackfaceIsHidden(),
wr::ToColorF(ComputeColor()));
return true;
}
/********************************************************
* Refreshes each content's frame
*********************************************************/