Bug 1698763 - Part 3 - Remove custom 10.15-style toolbarbuttons. r=mac-reviewers,mstange
authorHarry Twyford <htwyford@mozilla.com>
Fri, 07 May 2021 16:23:13 +0000
changeset 578901 52ebc9d40f371f853da03bf9fbb2cff418a7744a
parent 578900 c1188e42ad46a17a12fe783bd1b9ae39b7b8538a
child 578902 1f3d0ce673ad742ac390fc4bffa30fe152d4893b
push id142786
push userhtwyford@mozilla.com
push dateFri, 07 May 2021 17:33:44 +0000
treeherderautoland@52ebc9d40f37 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmac-reviewers, mstange
bugs1698763
milestone90.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1698763 - Part 3 - Remove custom 10.15-style toolbarbuttons. r=mac-reviewers,mstange Differential Revision: https://phabricator.services.mozilla.com/D114410
browser/themes/osx/pageInfo.css
widget/cocoa/nsNativeThemeCocoa.mm
--- a/browser/themes/osx/pageInfo.css
+++ b/browser/themes/osx/pageInfo.css
@@ -24,20 +24,22 @@
   appearance: auto;
   -moz-default-appearance: toolbarbutton;
   font: menu;
   margin: 0;
   padding: 0 6px;
   height: 22px;
 }
 
-#viewGroup > radio[selected=true],
-#viewGroup > toolbarbutton[checked=true] {
-  color: #FFF !important;
-  text-shadow: rgba(0, 0, 0, 0.4) 0 1px;
+@media (-moz-mac-big-sur-theme: 0) {
+  #viewGroup > radio[selected=true],
+  #viewGroup > toolbarbutton[checked=true] {
+    color: #FFF !important;
+    text-shadow: rgba(0, 0, 0, 0.4) 0 1px;
+  }
 }
 
 #mainDeck {
   padding: 10px;
 }
 
 /* Misc */
 tree {
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -2075,93 +2075,19 @@ static SegmentedControlRenderSettings Re
   switch (aSegmentType) {
     case nsNativeThemeCocoa::SegmentType::eToolbarButton:
       return toolbarButtonRenderSettings;
     case nsNativeThemeCocoa::SegmentType::eTab:
       return tabRenderSettings;
   }
 }
 
-void nsNativeThemeCocoa::DrawSegmentBackground(CGContextRef cgContext, const HIRect& inBoxRect,
-                                               const SegmentParams& aParams) {
-  // On earlier macOS versions, the segment background is automatically
-  // drawn correctly and this method should not be used. ASSERT here
-  // to catch unnecessary usage, but the method implementation is not
-  // dependent on Big Sur in any way.
-  MOZ_ASSERT(nsCocoaFeatures::OnBigSurOrLater());
-
-  // Use colors resembling 10.15.
-  if (aParams.selected) {
-    DeviceColor color = ToDeviceColor(mozilla::gfx::sRGBColor::FromU8(93, 93, 93, 255));
-    CGContextSetRGBFillColor(cgContext, color.r, color.g, color.b, color.a);
-  } else {
-    DeviceColor color = ToDeviceColor(mozilla::gfx::sRGBColor::FromU8(247, 247, 247, 255));
-    CGContextSetRGBFillColor(cgContext, color.r, color.g, color.b, color.a);
-  }
-
-  // Create a rect for the background fill.
-  CGRect bgRect = inBoxRect;
-  bgRect.size.height -= 3.0;
-  bgRect.size.width -= 4.0;
-  bgRect.origin.x += 2.0;
-  bgRect.origin.y += 1.0;
-
-  // Round the corners unless the button is a middle button. Buttons in
-  // a grouping but on the edge will have the inner edge filled below.
-  if (aParams.atLeftEnd || aParams.atRightEnd) {
-    CGPathRef path = CGPathCreateWithRoundedRect(bgRect, 5, 4, nullptr);
-    CGContextAddPath(cgContext, path);
-    CGPathRelease(path);
-    CGContextClosePath(cgContext);
-    CGContextFillPath(cgContext);
-  }
-
-  // Handle buttons grouped together where either or both of
-  // the side edges do not have curved corners.
-  if (!aParams.atLeftEnd && aParams.atRightEnd) {
-    // Shift the rect left to draw the left side of the
-    // rect with right angle corners leaving the right side
-    // to have rounded corners drawn with the curve above.
-    // For example, the left side of the forward button in
-    // the Library window.
-    CGRect leftRectEdge = bgRect;
-    leftRectEdge.size.width -= 10;
-    leftRectEdge.origin.x -= 2;
-    CGContextFillRect(cgContext, leftRectEdge);
-  } else if (aParams.atLeftEnd && !aParams.atRightEnd) {
-    // Shift the rect right to draw the right side of the
-    // rect with right angle corners leaving the left side
-    // to have rounded corners drawn with the curve above.
-    // For example, the right side of the back button in
-    // the Library window.
-    CGRect rightRectEdge = bgRect;
-    rightRectEdge.size.width -= 10;
-    rightRectEdge.origin.x += 12;
-    CGContextFillRect(cgContext, rightRectEdge);
-  } else if (!aParams.atLeftEnd && !aParams.atRightEnd) {
-    // The middle button in a group of buttons. Widen the
-    // background rect to meet adjacent buttons seamlessly.
-    CGRect middleRect = bgRect;
-    middleRect.size.width += 4;
-    middleRect.origin.x -= 2;
-    CGContextFillRect(cgContext, middleRect);
-  }
-}
-
 void nsNativeThemeCocoa::DrawSegment(CGContextRef cgContext, const HIRect& inBoxRect,
                                      const SegmentParams& aParams) {
   SegmentedControlRenderSettings renderSettings = RenderSettingsForSegmentType(aParams.segmentType);
-
-  // On Big Sur, manually draw the background of the buttons to workaround a
-  // change in Big Sur where the backround is filled with the toolbar gradient.
-  if (nsCocoaFeatures::OnBigSurOrLater() &&
-      (aParams.segmentType == nsNativeThemeCocoa::SegmentType::eToolbarButton)) {
-    DrawSegmentBackground(cgContext, inBoxRect, aParams);
-  }
-
   NSControlSize controlSize = FindControlSize(inBoxRect.size.height, renderSettings.heights, 4.0f);
   CGRect drawRect = SeparatorAdjustedRect(inBoxRect, aParams);
 
   NSDictionary* dict = @{
     @"widget" : renderSettings.widgetName,
     @"kCUIPresentationStateKey" : (aParams.insideActiveWindow ? @"kCUIPresentationStateActiveKey"
                                                               : @"kCUIPresentationStateInactive"),
     @"kCUIPositionKey" : ToolbarButtonPosition(aParams.atLeftEnd, aParams.atRightEnd),
@@ -3521,17 +3447,16 @@ bool nsNativeThemeCocoa::ThemeSupportsWi
     case StyleAppearance::SpinnerDownbutton:
     case StyleAppearance::Toolbar:
     case StyleAppearance::Statusbar:
     case StyleAppearance::NumberInput:
     case StyleAppearance::Textfield:
     case StyleAppearance::Textarea:
     case StyleAppearance::Searchfield:
     case StyleAppearance::Toolbox:
-    // case StyleAppearance::Toolbarbutton:
     case StyleAppearance::ProgressBar:
     case StyleAppearance::Progresschunk:
     case StyleAppearance::Meter:
     case StyleAppearance::Meterchunk:
     case StyleAppearance::Separator:
 
     case StyleAppearance::Tabpanels:
     case StyleAppearance::Tab: