Skip to content

Commit

Permalink
Backed out changeset 00daf2c5342a (bug 1340661) for Android reftest f…
Browse files Browse the repository at this point in the history
…ailures in ua-style-sheet-checkbox-radio-1.html
  • Loading branch information
philor committed Mar 8, 2017
1 parent 2fc141b commit f2e2207
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 260 deletions.
130 changes: 0 additions & 130 deletions layout/forms/nsGfxCheckboxControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,133 +47,3 @@ nsGfxCheckboxControlFrame::AccessibleType()
return a11y::eHTMLCheckboxType;
}
#endif

#ifdef ANDROID

#include "mozilla/widget/AndroidColors.h"

static void
PaintCheckboxBorder(nsIFrame* aFrame,
DrawTarget* aDrawTarget,
const nsRect& aDirtyRect,
nsPoint aPt)
{
nsRect rect(aPt, aFrame->GetSize());
rect.Deflate(aFrame->GetUsedBorderAndPadding());

// Checkbox controls aren't something that we can render on Android
// natively. We fake native drawing of appearance: checkbox items
// out here, and use hardcoded colours from AndroidColors.h to
// simulate native theming.
int32_t appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
Rect devPxRect = NSRectToSnappedRect(rect, appUnitsPerDevPixel, *aDrawTarget);
aDrawTarget->StrokeRect(devPxRect,
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidBorderColor)));
}

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(mozilla::widget::sAndroidCheckColor)));
}

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(mozilla::widget::sAndroidCheckColor)));
}

void
nsGfxCheckboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists)
{
nsFormControlFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);

if (!IsVisibleForPainting(aBuilder)) {
return; // nothing to paint.
}

if (IsThemed()) {
return; // No need to paint the checkmark. The theme will do it.
}

if (StyleDisplay()->mAppearance != NS_THEME_CHECKBOX) {
return;
}

aLists.Content()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, this, PaintCheckboxBorder,
"CheckboxBorder", nsDisplayItem::TYPE_CHECKBOX_BORDER));

if (IsChecked() || IsIndeterminate()) {
aLists.Content()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, this,
IsIndeterminate()
? PaintIndeterminateMark : PaintCheckMark,
"CheckedCheckbox",
nsDisplayItem::TYPE_CHECKED_CHECKBOX));
}
}

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;
}
#endif
15 changes: 0 additions & 15 deletions layout/forms/nsGfxCheckboxControlFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,9 @@ class nsGfxCheckboxControlFrame : public nsFormControlFrame
}
#endif

#ifdef ANDROID
// On Android, there's no native theme or native widget support for
// checkbox or radio buttons. We draw them ourselves here using
// hardcoded colour values in order to simulate native drawing.
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) override;
#endif

#ifdef ACCESSIBILITY
virtual mozilla::a11y::AccType AccessibleType() override;
#endif

#ifdef ANDROID
protected:
bool IsChecked();
bool IsIndeterminate();
#endif
};

#endif
Expand Down
87 changes: 0 additions & 87 deletions layout/forms/nsGfxRadioControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,90 +40,3 @@ nsGfxRadioControlFrame::AccessibleType()
return a11y::eHTMLRadioButtonType;
}
#endif

#ifdef ANDROID

#include "mozilla/widget/AndroidColors.h"

static void
PaintRadioBorder(nsIFrame* aFrame,
DrawTarget* aDrawTarget,
const nsRect& aDirtyRect,
nsPoint aPt)
{
nsRect rect(aPt, aFrame->GetSize());
rect.Deflate(aFrame->GetUsedBorderAndPadding());

Rect devPxRect =
ToRect(nsLayoutUtils::RectToGfxRect(rect,
aFrame->PresContext()->AppUnitsPerDevPixel()));
// Radio controls aren't something that we can render on Android
// natively. We fake native drawing of appearance: radio items
// out here, and use hardcoded colours to simulate native
// theming.
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size());
RefPtr<Path> ellipse = builder->Finish();
aDrawTarget->Stroke(ellipse,
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidBorderColor)));
}

//--------------------------------------------------------------
// 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()));

RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder();
AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size());
RefPtr<Path> ellipse = builder->Finish();
aDrawTarget->Fill(ellipse,
ColorPattern(ToDeviceColor(mozilla::widget::sAndroidCheckColor)));
}

void
nsGfxRadioControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists)
{
nsFormControlFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);

if (!IsVisibleForPainting(aBuilder)) {
return;
}

if (IsThemed()) {
return; // The theme will paint the check, if any.
}

if (StyleDisplay()->mAppearance != NS_THEME_RADIO) {
return;
}

aLists.Content()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, this, PaintRadioBorder,
"RadioBorder", nsDisplayItem::TYPE_RADIOBUTTON_BORDER));

bool checked = true;
GetCurrentCheckState(&checked); // Get check state from the content model
if (checked) {
aLists.Content()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(aBuilder, this, PaintCheckedRadioButton,
"CheckedRadioButton",
nsDisplayItem::TYPE_CHECKED_RADIOBUTTON));
}
}
#endif
9 changes: 0 additions & 9 deletions layout/forms/nsGfxRadioControlFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ class nsGfxRadioControlFrame : public nsFormControlFrame
#ifdef ACCESSIBILITY
virtual mozilla::a11y::AccType AccessibleType() override;
#endif

#ifdef ANDROID
// On Android, there's no native theme or native widget support for
// checkbox or radio buttons. We draw them ourselves here using
// hardcoded colour values in order to simulate native drawing.
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) override;
#endif
};

#endif
2 changes: 0 additions & 2 deletions layout/painting/nsDisplayItemTypesList.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ DECLARE_DISPLAY_ITEM_TYPE(CANVAS_THEMED_BACKGROUND)
DECLARE_DISPLAY_ITEM_TYPE(CANVAS_BACKGROUND_IMAGE)
DECLARE_DISPLAY_ITEM_TYPE(CANVAS_FOCUS)
DECLARE_DISPLAY_ITEM_TYPE(CARET)
DECLARE_DISPLAY_ITEM_TYPE(CHECKBOX_BORDER)
DECLARE_DISPLAY_ITEM_TYPE(CHECKED_CHECKBOX)
DECLARE_DISPLAY_ITEM_TYPE(CHECKED_RADIOBUTTON)
DECLARE_DISPLAY_ITEM_TYPE(CLEAR_BACKGROUND)
Expand All @@ -42,7 +41,6 @@ DECLARE_DISPLAY_ITEM_TYPE(PLUGIN)
DECLARE_DISPLAY_ITEM_TYPE(PLUGIN_READBACK)
DECLARE_DISPLAY_ITEM_TYPE(PLUGIN_VIDEO)
DECLARE_DISPLAY_ITEM_TYPE(PRINT_PLUGIN)
DECLARE_DISPLAY_ITEM_TYPE(RADIOBUTTON_BORDER)
DECLARE_DISPLAY_ITEM_TYPE(RANGE_FOCUS_RING)
DECLARE_DISPLAY_ITEM_TYPE(REMOTE)
DECLARE_DISPLAY_ITEM_TYPE(RESOLUTION)
Expand Down
2 changes: 1 addition & 1 deletion mobile/android/themes/core/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ select[size="1"] xul|scrollbarbutton {
textarea,
button,
xul|button,
* > input:not(:-moz-any([type="image"], [type="checkbox"], [type="radio"])) {
* > input:not([type="image"]) {
-moz-appearance: none !important; /* See bug 598421 for fixing the platform */
}

Expand Down
15 changes: 0 additions & 15 deletions widget/android/AndroidColors.h

This file was deleted.

1 change: 0 additions & 1 deletion widget/android/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ EXPORTS += [
]

EXPORTS.mozilla.widget += [
'AndroidColors.h',
'AndroidCompositorWidget.h',
'AndroidUiThread.h',
]
Expand Down

0 comments on commit f2e2207

Please sign in to comment.