Commit f6bc7267 authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1817071 - Remove unused image-region support from cocoa code. r=mstange,mac-reviewers

Nobody sets -moz-image-region on macOS anyways, remove the dead code.

Differential Revision: https://phabricator.services.mozilla.com/D170008
parent cbfd5992
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ class ComputedStyle;
                               withSize:(NSSize)aSize
                            presContext:(const nsPresContext*)aPresContext
                          computedStyle:(const mozilla::ComputedStyle*)aComputedStyle
                                subrect:(const nsIntRect&)aSubRect
                            scaleFactor:(CGFloat)aScaleFactor;

@end
+0 −27
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@
                               withSize:(NSSize)aSize
                            presContext:(const nsPresContext*)aPresContext
                          computedStyle:(const mozilla::ComputedStyle*)aComputedStyle
                                subrect:(const nsIntRect&)aSubRect
                            scaleFactor:(CGFloat)aScaleFactor {
  bool isEntirelyBlack = false;
  NSImage* retainedImage = nil;
@@ -49,32 +48,6 @@
  aImage->GetWidth(&origWidth);
  aImage->GetHeight(&origHeight);

  // If the image region is invalid, don't draw the image to almost match
  // the behavior of other platforms.
  if (!aSubRect.IsEmpty() && (aSubRect.XMost() > origWidth || aSubRect.YMost() > origHeight)) {
    return nil;
  }

  bool createSubImage =
      !aSubRect.IsEmpty() && !(aSubRect.x == 0 && aSubRect.y == 0 && aSubRect.width == origWidth &&
                               aSubRect.height == origHeight);

  if (createSubImage) {
    // If aRect is set using CSS, we need to slice a piece out of the
    // overall image to use as the icon.
    NSRect subRect = NSMakeRect(aSubRect.x, aSubRect.y, aSubRect.width, aSubRect.height);
    NSImage* subImage = [NSImage imageWithSize:aSize
                                       flipped:NO
                                drawingHandler:^BOOL(NSRect subImageRect) {
                                  [image drawInRect:NSMakeRect(0, 0, aSize.width, aSize.height)
                                           fromRect:subRect
                                          operation:NSCompositingOperationCopy
                                           fraction:1.0f];
                                  return YES;
                                }];
    image = subImage;
  }

  // If all the color channels in the image are black, treat the image as a
  // template. This will cause macOS to use the image's alpha channel as a mask
  // and it will fill it with a color that looks good in the context that it's
+0 −1
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@ class nsMenuItemIconX final : public mozilla::widget::IconLoader::Listener {
  already_AddRefed<nsIURI> GetIconURI(nsIContent* aContent);

  Listener* mListener;  // [weak]
  nsIntRect mImageRegionRect;
  RefPtr<const mozilla::ComputedStyle> mComputedStyle;
  mozilla::WeakPtr<nsPresContext> mPresContext;
  NSImage* mIconImage = nil;  // [strong]
+0 −19
Original line number Diff line number Diff line
@@ -112,7 +112,6 @@ already_AddRefed<nsIURI> nsMenuItemIconX::GetIconURI(nsIContent* aContent) {
    if (NS_FAILED(rv)) {
      return nullptr;
    }
    mImageRegionRect.SetEmpty();
    return iconURI.forget();
  }

@@ -133,23 +132,6 @@ already_AddRefed<nsIURI> nsMenuItemIconX::GetIconURI(nsIContent* aContent) {
    return nullptr;
  }

  // Check if the icon has a specified image region so that it can be
  // cropped appropriately before being displayed.
  const nsRect r = sc->StyleList()->GetImageRegion();

  // Return nullptr if the image region is invalid so the image
  // is not drawn, and behavior is similar to XUL menus.
  if (r.X() < 0 || r.Y() < 0 || r.Width() < 0 || r.Height() < 0) {
    return nullptr;
  }

  // 'auto' is represented by a [0, 0, 0, 0] rect. Only set mImageRegionRect
  // if we have some other value.
  if (r.IsEmpty()) {
    mImageRegionRect.SetEmpty();
  } else {
    mImageRegionRect = r.ToNearestPixels(mozilla::AppUnitsPerCSSPixel());
  }
  mComputedStyle = std::move(sc);
  mPresContext = document->GetPresContext();

@@ -172,7 +154,6 @@ nsresult nsMenuItemIconX::OnComplete(imgIContainer* aImage) {
                                                  withSize:NSMakeSize(kIconSize, kIconSize)
                                               presContext:pc
                                             computedStyle:mComputedStyle
                                                   subrect:mImageRegionRect
                                               scaleFactor:0.0f] retain];
  mComputedStyle = nullptr;
  mPresContext = nullptr;
+0 −1
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ class nsTouchBarInputIcon : public mozilla::widget::IconLoader::Listener {

 protected:
  RefPtr<Document> mDocument;
  nsIntRect mImageRegionRect;
  bool mSetIcon;
  NSButton* mButton;
  // We accept a mShareScrubber only as a special case since
Loading