Bug 1352238 Part 5 - Remove painting related methods in nsGfxCheckbox/RadioControlFrame.cpp. r?mats
MozReview-Commit-ID: GvhGm4LUaOI
--- a/layout/forms/nsGfxCheckboxControlFrame.cpp
+++ b/layout/forms/nsGfxCheckboxControlFrame.cpp
@@ -13,88 +13,25 @@
#include "nsLayoutUtils.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsDisplayList.h"
#include <algorithm>
using namespace mozilla;
using namespace mozilla::gfx;
-#ifdef MOZ_WIDGET_ANDROID
-
-static void
-PaintCheckMark(nsIFrame* aFrame,
- DrawTarget* aDrawTarget,
- const nsRect& aDirtyRect,
- nsPoint aPt)
-{
- nsRect rect(aPt, aFrame->GetSize());
- rect.Deflate(aFrame->GetUsedBorderAndPadding());
-
- // Points come from the coordinates on a 7X7 unit box centered at 0,0
- const int32_t checkPolygonX[] = { -3, -1, 3, 3, -1, -3 };
- const int32_t checkPolygonY[] = { -1, 1, -3, -1, 3, 1 };
- const int32_t checkNumPoints = sizeof(checkPolygonX) / sizeof(int32_t);
- const int32_t checkSize = 9; // 2 units of padding on either side
- // of the 7x7 unit checkmark
-
- // Scale the checkmark based on the smallest dimension
- nscoord paintScale = std::min(rect.width, rect.height) / checkSize;
- nsPoint paintCenter(rect.x + rect.width / 2,
- rect.y + rect.height / 2);
-
- RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
- nsPoint p = paintCenter + nsPoint(checkPolygonX[0] * paintScale,
- checkPolygonY[0] * paintScale);
-
- int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
- builder->MoveTo(NSPointToPoint(p, appUnitsPerDevPixel));
- for (int32_t polyIndex = 1; polyIndex < checkNumPoints; polyIndex++) {
- p = paintCenter + nsPoint(checkPolygonX[polyIndex] * paintScale,
- checkPolygonY[polyIndex] * paintScale);
- builder->LineTo(NSPointToPoint(p, appUnitsPerDevPixel));
- }
- RefPtr<Path> path = builder->Finish();
- aDrawTarget->Fill(path,
- ColorPattern(ToDeviceColor(aFrame->StyleColor()->mColor)));
-}
-
-static void
-PaintIndeterminateMark(nsIFrame* aFrame,
- DrawTarget* aDrawTarget,
- const nsRect& aDirtyRect,
- nsPoint aPt)
-{
- int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
-
- nsRect rect(aPt, aFrame->GetSize());
- rect.Deflate(aFrame->GetUsedBorderAndPadding());
- rect.y += (rect.height - rect.height/4) / 2;
- rect.height /= 4;
-
- Rect devPxRect = NSRectToSnappedRect(rect, appUnitsPerDevPixel, *aDrawTarget);
-
- aDrawTarget->FillRect(
- devPxRect, ColorPattern(ToDeviceColor(aFrame->StyleColor()->mColor)));
-}
-
-#endif
-
-//------------------------------------------------------------
nsIFrame*
NS_NewGfxCheckboxControlFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext)
{
return new (aPresShell) nsGfxCheckboxControlFrame(aContext);
}
NS_IMPL_FRAMEARENA_HELPERS(nsGfxCheckboxControlFrame)
-
-//------------------------------------------------------------
// Initialize GFX-rendered state
nsGfxCheckboxControlFrame::nsGfxCheckboxControlFrame(nsStyleContext* aContext)
: nsFormControlFrame(aContext, kClassID)
{
}
nsGfxCheckboxControlFrame::~nsGfxCheckboxControlFrame()
{
@@ -102,52 +39,8 @@ nsGfxCheckboxControlFrame::~nsGfxCheckbo
#ifdef ACCESSIBILITY
a11y::AccType
nsGfxCheckboxControlFrame::AccessibleType()
{
return a11y::eHTMLCheckboxType;
}
#endif
-
-//------------------------------------------------------------
-#ifdef MOZ_WIDGET_ANDROID
-
-void
-nsGfxCheckboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
- const nsDisplayListSet& aLists)
-{
- nsFormControlFrame::BuildDisplayList(aBuilder, aLists);
-
- // Get current checked state through content model.
- if ((!IsChecked() && !IsIndeterminate()) || !IsVisibleForPainting(aBuilder))
- return; // we're not checked or not visible, nothing to paint.
-
- if (IsThemed())
- return; // No need to paint the checkmark. The theme will do it.
-
- aLists.Content()->AppendNewToTop(new (aBuilder)
- nsDisplayGeneric(aBuilder, this,
- IsIndeterminate()
- ? PaintIndeterminateMark : PaintCheckMark,
- "CheckedCheckbox",
- DisplayItemType::TYPE_CHECKED_CHECKBOX));
-}
-
-#endif
-//------------------------------------------------------------
-bool
-nsGfxCheckboxControlFrame::IsChecked()
-{
- nsCOMPtr<nsIDOMHTMLInputElement> elem(do_QueryInterface(mContent));
- bool retval = false;
- elem->GetChecked(&retval);
- return retval;
-}
-
-bool
-nsGfxCheckboxControlFrame::IsIndeterminate()
-{
- nsCOMPtr<nsIDOMHTMLInputElement> elem(do_QueryInterface(mContent));
- bool retval = false;
- elem->GetIndeterminate(&retval);
- return retval;
-}
--- a/layout/forms/nsGfxCheckboxControlFrame.h
+++ b/layout/forms/nsGfxCheckboxControlFrame.h
@@ -17,25 +17,15 @@ public:
virtual ~nsGfxCheckboxControlFrame();
#ifdef DEBUG_FRAME_DUMP
virtual nsresult GetFrameName(nsAString& aResult) const override {
return MakeFrameName(NS_LITERAL_STRING("CheckboxControl"), aResult);
}
#endif
-#ifdef MOZ_WIDGET_ANDROID
- virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
- const nsDisplayListSet& aLists) override;
-#endif
-
#ifdef ACCESSIBILITY
virtual mozilla::a11y::AccType AccessibleType() override;
#endif
-
-protected:
-
- bool IsChecked();
- bool IsIndeterminate();
};
#endif
--- a/layout/forms/nsGfxRadioControlFrame.cpp
+++ b/layout/forms/nsGfxRadioControlFrame.cpp
@@ -35,62 +35,8 @@ nsGfxRadioControlFrame::~nsGfxRadioContr
#ifdef ACCESSIBILITY
a11y::AccType
nsGfxRadioControlFrame::AccessibleType()
{
return a11y::eHTMLRadioButtonType;
}
#endif
-
-#ifdef MOZ_WIDGET_ANDROID
-
-//--------------------------------------------------------------
-// Draw the dot for a non-native radio button in the checked state.
-static void
-PaintCheckedRadioButton(nsIFrame* aFrame,
- DrawTarget* aDrawTarget,
- const nsRect& aDirtyRect,
- nsPoint aPt)
-{
- // The dot is an ellipse 2px on all sides smaller than the content-box,
- // drawn in the foreground color.
- nsRect rect(aPt, aFrame->GetSize());
- rect.Deflate(aFrame->GetUsedBorderAndPadding());
- rect.Deflate(nsPresContext::CSSPixelsToAppUnits(2),
- nsPresContext::CSSPixelsToAppUnits(2));
-
- Rect devPxRect =
- ToRect(nsLayoutUtils::RectToGfxRect(rect,
- aFrame->PresContext()->AppUnitsPerDevPixel()));
-
- ColorPattern color(ToDeviceColor(aFrame->StyleColor()->mColor));
-
- RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
- AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size());
- RefPtr<Path> ellipse = builder->Finish();
- aDrawTarget->Fill(ellipse, color);
-}
-
-void
-nsGfxRadioControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
- const nsDisplayListSet& aLists)
-{
- nsFormControlFrame::BuildDisplayList(aBuilder, aLists);
-
- if (!IsVisibleForPainting(aBuilder))
- return;
-
- if (IsThemed())
- return; // The theme will paint the check, if any.
-
- bool checked = true;
- GetCurrentCheckState(&checked); // Get check state from the content model
- if (!checked)
- return;
-
- aLists.Content()->AppendNewToTop(new (aBuilder)
- nsDisplayGeneric(aBuilder, this, PaintCheckedRadioButton,
- "CheckedRadioButton",
- DisplayItemType::TYPE_CHECKED_RADIOBUTTON));
-}
-
-#endif
--- a/layout/forms/nsGfxRadioControlFrame.h
+++ b/layout/forms/nsGfxRadioControlFrame.h
@@ -18,16 +18,11 @@ public:
explicit nsGfxRadioControlFrame(nsStyleContext* aContext);
~nsGfxRadioControlFrame();
NS_DECL_FRAMEARENA_HELPERS(nsGfxRadioControlFrame)
#ifdef ACCESSIBILITY
virtual mozilla::a11y::AccType AccessibleType() override;
#endif
-
-#ifdef MOZ_WIDGET_ANDROID
- virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
- const nsDisplayListSet& aLists) override;
-#endif
};
#endif