Changeset 218052 in webkit


Ignore:
Timestamp:
Jun 10, 2017 11:33:08 AM (7 years ago)
Author:
mitz@apple.com
Message:

[macOS] REGRESSION: Link drag images blend into the background in Sierra and earlier
https://bugs.webkit.org/show_bug.cgi?id=172933
<rdar://problem/32580649>

Reviewed by Tim Horton.

  • platform/mac/DragImageMac.mm:

(WebCore::createDragImageForLink): When targeting macOS Sierra and earlier, give the link

drag image a drop shadow that resembles the one that macOS High Sierra applies to drag
image layers.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r218050 r218052  
     12017-06-10  Dan Bernstein  <mitz@apple.com>
     2
     3        [macOS] REGRESSION: Link drag images blend into the background in Sierra and earlier
     4        https://bugs.webkit.org/show_bug.cgi?id=172933
     5        <rdar://problem/32580649>
     6
     7        Reviewed by Tim Horton.
     8
     9        * platform/mac/DragImageMac.mm:
     10        (WebCore::createDragImageForLink): When targeting macOS Sierra and earlier, give the link
     11          drag image a drop shadow that resembles the one that macOS High Sierra applies to drag
     12          image layers.
     13
    1142017-06-10  Andy Estes  <aestes@apple.com>
    215
  • trunk/Source/WebCore/platform/mac/DragImageMac.mm

    r216962 r218052  
    155155}
    156156
    157 
    158157const CGFloat linkImagePadding = 10;
    159158const CGFloat linkImageDomainBaselineToTitleBaseline = 18;
     
    162161const CGFloat linkImageFontSize = 11;
    163162const CFIndex linkImageTitleMaximumLineCount = 2;
    164 const int linkImageDragCornerOutsetX = 6;
    165 const int linkImageDragCornerOutsetY = 10;
     163#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
     164const int linkImageShadowRadius = 0;
     165const int linkImageShadowOffsetY = 0;
     166#else
     167const int linkImageShadowRadius = 9;
     168const int linkImageShadowOffsetY = -3;
     169#endif
     170const int linkImageDragCornerOutsetX = 6 - linkImageShadowRadius;
     171const int linkImageDragCornerOutsetY = 10 - linkImageShadowRadius + linkImageShadowOffsetY;
    166172
    167173IntPoint dragOffsetForLinkDragImage(DragImageRef dragImage)
     
    288294    LinkImageLayout layout(url, title);
    289295
    290     RetainPtr<NSImage> dragImage = adoptNS([[NSImage alloc] initWithSize:layout.boundingRect.size()]);
     296    auto imageSize = layout.boundingRect.size();
     297#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     298    imageSize.expand(2 * linkImageShadowRadius, 2 * linkImageShadowRadius - linkImageShadowOffsetY);
     299#endif
     300    RetainPtr<NSImage> dragImage = adoptNS([[NSImage alloc] initWithSize:imageSize]);
    291301    [dragImage lockFocus];
    292302
    293303    GraphicsContext context((CGContextRef)[NSGraphicsContext currentContext].graphicsPort);
     304#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     305    context.translate(linkImageShadowRadius, linkImageShadowRadius - linkImageShadowOffsetY);
     306    context.setShadow({ 0, linkImageShadowOffsetY }, linkImageShadowRadius, { 0.f, 0.f, 0.f, .25 });
     307#endif
    294308    context.fillRoundedRect(FloatRoundedRect(layout.boundingRect, FloatRoundedRect::Radii(linkImageCornerRadius)), Color::white);
     309#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     310    context.clearShadow();
     311#endif
    295312
    296313    for (const auto& label : layout.labels) {
Note: See TracChangeset for help on using the changeset viewer.