Bug 1123939 - Convert nsComboboxControlFrame::PaintFocus to Moz2D. r=Bas

--HG--
extra : rebase_source : 5f5bce0cb6e403b9479fd13f9cdff9646d67d268
This commit is contained in:
Jonathan Watt 2015-01-21 16:23:28 +00:00
parent a0f4338c67
commit eb9233c2be
2 changed files with 18 additions and 13 deletions

View File

@ -1469,7 +1469,7 @@ void nsDisplayComboboxFocus::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
static_cast<nsComboboxControlFrame*>(mFrame)
->PaintFocus(*aCtx, ToReferenceFrame());
->PaintFocus(*aCtx->GetDrawTarget(), ToReferenceFrame());
}
void
@ -1511,7 +1511,7 @@ nsComboboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
DisplaySelectionOverlay(aBuilder, aLists.Content());
}
void nsComboboxControlFrame::PaintFocus(nsRenderingContext& aRenderingContext,
void nsComboboxControlFrame::PaintFocus(DrawTarget& aDrawTarget,
nsPoint aPt)
{
/* Do we need to do anything? */
@ -1519,13 +1519,12 @@ void nsComboboxControlFrame::PaintFocus(nsRenderingContext& aRenderingContext,
if (eventStates.HasState(NS_EVENT_STATE_DISABLED) || sFocused != this)
return;
gfxContext* gfx = aRenderingContext.ThebesContext();
int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
gfx->Save();
nsRect clipRect = mDisplayFrame->GetRect() + aPt;
gfx->Clip(NSRectToSnappedRect(clipRect,
PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
aDrawTarget.PushClipRect(NSRectToSnappedRect(clipRect,
appUnitsPerDevPixel,
aDrawTarget));
// REVIEW: Why does the old code paint mDisplayFrame again? We've
// already painted it in the children above. So clipping it here won't do
@ -1540,12 +1539,10 @@ void nsComboboxControlFrame::PaintFocus(nsRenderingContext& aRenderingContext,
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
clipRect.width -= onePixel;
clipRect.height -= onePixel;
Rect r =
ToRect(nsLayoutUtils::RectToGfxRect(clipRect, PresContext()->AppUnitsPerDevPixel()));
StrokeSnappedEdgesOfRect(r, *aRenderingContext.GetDrawTarget(),
color, strokeOptions);
Rect r = ToRect(nsLayoutUtils::RectToGfxRect(clipRect, appUnitsPerDevPixel));
StrokeSnappedEdgesOfRect(r, aDrawTarget, color, strokeOptions);
gfx->Restore();
aDrawTarget.PopClip();
}
//---------------------------------------------------------

View File

@ -37,6 +37,12 @@ class nsComboboxDisplayFrame;
class nsIDOMEventListener;
class nsIScrollableFrame;
namespace mozilla {
namespace gfx {
class DrawTarget;
}
}
class nsComboboxControlFrame MOZ_FINAL : public nsBlockFrame,
public nsIFormControlFrame,
public nsIComboboxControlFrame,
@ -45,6 +51,8 @@ class nsComboboxControlFrame MOZ_FINAL : public nsBlockFrame,
public nsIRollupListener,
public nsIStatefulFrame
{
typedef mozilla::gfx::DrawTarget DrawTarget;
public:
friend nsContainerFrame* NS_NewComboboxControlFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext,
@ -84,7 +92,7 @@ public:
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
void PaintFocus(nsRenderingContext& aRenderingContext, nsPoint aPt);
void PaintFocus(DrawTarget& aDrawTarget, nsPoint aPt);
// XXXbz this is only needed to prevent the quirk percent height stuff from
// leaking out of the combobox. We may be able to get rid of this as more