<attachment>'s label baseline should match that of the surrounding text
[WebKit-https.git] / Source / WebCore / rendering / RenderThemeMac.mm
index 039b120..ba62d7c 100644 (file)
@@ -25,6 +25,7 @@
 #import "CSSValueKeywords.h"
 #import "CSSValueList.h"
 #import "ColorMac.h"
+#import "CoreGraphicsSPI.h"
 #import "Document.h"
 #import "Element.h"
 #import "ExceptionCodePlaceholder.h"
@@ -2096,6 +2097,8 @@ struct AttachmentLayout {
     FloatRect iconBackgroundRect;
     FloatRect attachmentRect;
 
+    int baseline;
+
     RetainPtr<CTFontRef> labelFont;
     FontCascade labelFontCascade;
     std::unique_ptr<TextRun> labelTextRun;
@@ -2117,6 +2120,8 @@ AttachmentLayout::AttachmentLayout(const RenderAttachment& attachment)
     float textHeight = labelFontCascade.fontMetrics().height();
     float xOffset = (attachmentIconBackgroundSize / 2) - (textWidth / 2);
 
+    baseline = CGRound(attachmentIconBackgroundSize + attachmentIconToLabelMargin + labelFontCascade.fontMetrics().ascent());
+
     textRect = FloatRect(xOffset, attachmentIconBackgroundSize + attachmentIconToLabelMargin, textWidth, textHeight);
     textBackgroundRect = textRect;
     textBackgroundRect.inflateX(attachmentLabelBackgroundPadding);
@@ -2140,6 +2145,12 @@ LayoutSize RenderThemeMac::attachmentIntrinsicSize(const RenderAttachment& attac
     return LayoutSize(layout.attachmentRect.size());
 }
 
+int RenderThemeMac::attachmentBaseline(const RenderAttachment& attachment) const
+{
+    AttachmentLayout layout(attachment);
+    return layout.baseline;
+}
+
 static void paintAttachmentIconBackground(const RenderAttachment&, GraphicsContext& context, AttachmentLayout& layout)
 {
     // FIXME: Finder has a discontinuous behavior here when you have a background color other than white,