diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 175013a135b..b59dcd8116f 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -1469,7 +1469,7 @@ void nsDisplayComboboxFocus::Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) { static_cast(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(); } //--------------------------------------------------------- diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index cfa29eb2265..39fa6ce82d4 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -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