From 96765042565abb15eaf3f8e37f49a1289ea12abd Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Tue, 7 Mar 2017 20:57:57 -0800 Subject: [PATCH] Backed out changeset 00daf2c5342a (bug 1340661) for Android reftest failures in ua-style-sheet-checkbox-radio-1.html --- layout/forms/nsGfxCheckboxControlFrame.cpp | 130 --------------------- layout/forms/nsGfxCheckboxControlFrame.h | 15 --- layout/forms/nsGfxRadioControlFrame.cpp | 87 -------------- layout/forms/nsGfxRadioControlFrame.h | 9 -- layout/painting/nsDisplayItemTypesList.h | 2 - mobile/android/themes/core/content.css | 2 +- widget/android/AndroidColors.h | 15 --- widget/android/moz.build | 1 - 8 files changed, 1 insertion(+), 260 deletions(-) delete mode 100644 widget/android/AndroidColors.h diff --git a/layout/forms/nsGfxCheckboxControlFrame.cpp b/layout/forms/nsGfxCheckboxControlFrame.cpp index a2c23fca4cb0..9c867e9f471b 100644 --- a/layout/forms/nsGfxCheckboxControlFrame.cpp +++ b/layout/forms/nsGfxCheckboxControlFrame.cpp @@ -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 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 = 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 elem(do_QueryInterface(mContent)); - bool retval = false; - elem->GetChecked(&retval); - return retval; -} - -bool -nsGfxCheckboxControlFrame::IsIndeterminate() -{ - nsCOMPtr elem(do_QueryInterface(mContent)); - bool retval = false; - elem->GetIndeterminate(&retval); - return retval; -} -#endif diff --git a/layout/forms/nsGfxCheckboxControlFrame.h b/layout/forms/nsGfxCheckboxControlFrame.h index edd84c8b39ff..41b694c31785 100644 --- a/layout/forms/nsGfxCheckboxControlFrame.h +++ b/layout/forms/nsGfxCheckboxControlFrame.h @@ -22,24 +22,9 @@ public: } #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 diff --git a/layout/forms/nsGfxRadioControlFrame.cpp b/layout/forms/nsGfxRadioControlFrame.cpp index 284eea47b116..c38e3af61188 100644 --- a/layout/forms/nsGfxRadioControlFrame.cpp +++ b/layout/forms/nsGfxRadioControlFrame.cpp @@ -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 builder = aDrawTarget->CreatePathBuilder(); - AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size()); - RefPtr 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 builder = aDrawTarget->CreatePathBuilder(); - AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size()); - RefPtr 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 diff --git a/layout/forms/nsGfxRadioControlFrame.h b/layout/forms/nsGfxRadioControlFrame.h index cacd0fa56b6c..05c26298181d 100644 --- a/layout/forms/nsGfxRadioControlFrame.h +++ b/layout/forms/nsGfxRadioControlFrame.h @@ -23,15 +23,6 @@ public: #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 diff --git a/layout/painting/nsDisplayItemTypesList.h b/layout/painting/nsDisplayItemTypesList.h index dcead93e1675..3bb677e31469 100644 --- a/layout/painting/nsDisplayItemTypesList.h +++ b/layout/painting/nsDisplayItemTypesList.h @@ -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) @@ -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) diff --git a/mobile/android/themes/core/content.css b/mobile/android/themes/core/content.css index ba391c34cd04..9f6b0ebfb853 100644 --- a/mobile/android/themes/core/content.css +++ b/mobile/android/themes/core/content.css @@ -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 */ } diff --git a/widget/android/AndroidColors.h b/widget/android/AndroidColors.h deleted file mode 100644 index f71d80be162c..000000000000 --- a/widget/android/AndroidColors.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef mozilla_widget_AndroidColors_h -#define mozilla_widget_AndroidColors_h - -#include "mozilla/gfx/2D.h" - -namespace mozilla { -namespace widget { - -static const Color sAndroidBorderColor(Color(0.73f, 0.73f, 0.73f)); -static const Color sAndroidCheckColor(Color(0.19f, 0.21f, 0.23f)); - -} // namespace widget -} // namespace mozilla - -#endif diff --git a/widget/android/moz.build b/widget/android/moz.build index 5e2486754a62..2e48a72ba6a0 100644 --- a/widget/android/moz.build +++ b/widget/android/moz.build @@ -25,7 +25,6 @@ EXPORTS += [ ] EXPORTS.mozilla.widget += [ - 'AndroidColors.h', 'AndroidCompositorWidget.h', 'AndroidUiThread.h', ]