<attachment> should have an inactive style (gray in background)
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Feb 2015 23:00:03 +0000 (23:00 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Feb 2015 23:00:03 +0000 (23:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142103
<rdar://problem/19982486>

Reviewed by Dan Bernstein.

* rendering/RenderThemeMac.mm:
(WebCore::attachmentLabelInactiveBackgroundColor):
(WebCore::attachmentLabelInactiveTextColor):
(WebCore::RenderThemeMac::paintAttachmentLabelBackground):
(WebCore::RenderThemeMac::paintAttachmentLabel):
Use a gray background and gray text when the selection containing the
attachment isn't focused and active.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180784 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderThemeMac.mm

index b1ad67a..72fb7a8 100644 (file)
@@ -1,3 +1,19 @@
+2015-02-27  Timothy Horton  <timothy_horton@apple.com>
+
+        <attachment> should have an inactive style (gray in background)
+        https://bugs.webkit.org/show_bug.cgi?id=142103
+        <rdar://problem/19982486>
+
+        Reviewed by Dan Bernstein.
+
+        * rendering/RenderThemeMac.mm:
+        (WebCore::attachmentLabelInactiveBackgroundColor):
+        (WebCore::attachmentLabelInactiveTextColor):
+        (WebCore::RenderThemeMac::paintAttachmentLabelBackground):
+        (WebCore::RenderThemeMac::paintAttachmentLabel):
+        Use a gray background and gray text when the selection containing the
+        attachment isn't focused and active.
+
 2015-02-27  Brady Eidson  <beidson@apple.com>
 
         Add a "block-cookies" rule to the user content filter.
index ba62d7c..397f753 100644 (file)
@@ -33,6 +33,7 @@
 #import "FloatRoundedRect.h"
 #import "FocusController.h"
 #import "Frame.h"
+#import "FrameSelection.h"
 #import "FrameView.h"
 #import "GraphicsContextCG.h"
 #import "HTMLAttachmentElement.h"
@@ -2086,6 +2087,9 @@ const CGFloat attachmentLabelFontSize = 12;
 const CGFloat attachmentLabelBackgroundRadius = 3;
 const CGFloat attachmentLabelBackgroundPadding = 3;
 
+static Color attachmentLabelInactiveBackgroundColor() { return Color(204, 204, 204, 255); }
+static Color attachmentLabelInactiveTextColor() { return Color(100, 100, 100, 255); }
+
 const CGFloat attachmentMargin = 3;
 
 struct AttachmentLayout {
@@ -2198,20 +2202,36 @@ static void paintAttachmentIcon(const RenderAttachment& attachment, GraphicsCont
     context.drawNativeImage(icon.get(), iconSizeInPoints, ColorSpaceDeviceRGB, layout.iconRect, FloatRect(FloatPoint(), iconSizeInPoints));
 }
 
-void RenderThemeMac::paintAttachmentLabelBackground(const RenderAttachment&, GraphicsContext& context, AttachmentLayout& layout) const
+void RenderThemeMac::paintAttachmentLabelBackground(const RenderAttachment& attachment, GraphicsContext& context, AttachmentLayout& layout) const
 {
     Path backgroundPath;
     backgroundPath.addRoundedRect(layout.textBackgroundRect, FloatSize(attachmentLabelBackgroundRadius, attachmentLabelBackgroundRadius));
-    context.setFillColor(convertNSColorToColor([NSColor alternateSelectedControlColor]), ColorSpaceDeviceRGB);
+
+    Color backgroundColor;
+    if (attachment.frame().selection().isFocusedAndActive())
+        backgroundColor = convertNSColorToColor([NSColor alternateSelectedControlColor]);
+    else
+        backgroundColor = attachmentLabelInactiveBackgroundColor();
+
+    context.setFillColor(backgroundColor, ColorSpaceDeviceRGB);
     context.fillPath(backgroundPath);
 }
 
-void RenderThemeMac::paintAttachmentLabel(const RenderAttachment&, GraphicsContext& context, AttachmentLayout& layout, bool useSelectedStyle) const
+void RenderThemeMac::paintAttachmentLabel(const RenderAttachment& attachment, GraphicsContext& context, AttachmentLayout& layout, bool useSelectedStyle) const
 {
     FloatPoint textLocation = layout.textRect.minXMaxYCorner();
     textLocation.move(0, -layout.labelFontCascade.fontMetrics().descent());
 
-    context.setFillColor(useSelectedStyle ? convertNSColorToColor([NSColor alternateSelectedControlTextColor]) : Color::black, ColorSpaceDeviceRGB);
+    Color textColor;
+    if (useSelectedStyle) {
+        if (attachment.frame().selection().isFocusedAndActive())
+            textColor = convertNSColorToColor([NSColor alternateSelectedControlTextColor]);
+        else
+            textColor = attachmentLabelInactiveTextColor();
+    } else
+        textColor = Color::black;
+
+    context.setFillColor(textColor, ColorSpaceDeviceRGB);
     context.drawBidiText(layout.labelFontCascade, *layout.labelTextRun, textLocation);
 }