From 29353d4bd01049fbdd86f8719512e9d4279e93dc Mon Sep 17 00:00:00 2001 From: "timothy_horton@apple.com" Date: Fri, 27 Feb 2015 21:56:43 +0000 Subject: [PATCH] 's label baseline should match that of the surrounding text https://bugs.webkit.org/show_bug.cgi?id=142099 rdar://problem/19982495 Reviewed by Dan Bernstein. * rendering/RenderAttachment.cpp: (WebCore::RenderAttachment::baselinePosition): * rendering/RenderAttachment.h: Override baselinePosition and retrieve it from RenderTheme. * rendering/RenderTheme.h: (WebCore::RenderTheme::attachmentBaseline): * rendering/RenderThemeMac.h: * rendering/RenderThemeMac.mm: (WebCore::AttachmentLayout::AttachmentLayout): (WebCore::RenderThemeMac::attachmentBaseline): Plumb the label baseline from AttachmentLayout to RenderAttachment. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180780 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 21 +++++++++++++++++++++ Source/WebCore/rendering/RenderAttachment.cpp | 5 +++++ Source/WebCore/rendering/RenderAttachment.h | 2 ++ Source/WebCore/rendering/RenderTheme.h | 1 + Source/WebCore/rendering/RenderThemeMac.h | 1 + Source/WebCore/rendering/RenderThemeMac.mm | 11 +++++++++++ 6 files changed, 41 insertions(+) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 2a4f72a..bf02f1b 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,24 @@ +2015-02-27 Timothy Horton + + 's label baseline should match that of the surrounding text + https://bugs.webkit.org/show_bug.cgi?id=142099 + rdar://problem/19982495 + + Reviewed by Dan Bernstein. + + * rendering/RenderAttachment.cpp: + (WebCore::RenderAttachment::baselinePosition): + * rendering/RenderAttachment.h: + Override baselinePosition and retrieve it from RenderTheme. + + * rendering/RenderTheme.h: + (WebCore::RenderTheme::attachmentBaseline): + * rendering/RenderThemeMac.h: + * rendering/RenderThemeMac.mm: + (WebCore::AttachmentLayout::AttachmentLayout): + (WebCore::RenderThemeMac::attachmentBaseline): + Plumb the label baseline from AttachmentLayout to RenderAttachment. + 2015-02-27 Commit Queue Unreviewed, rolling out r180752. diff --git a/Source/WebCore/rendering/RenderAttachment.cpp b/Source/WebCore/rendering/RenderAttachment.cpp index 3228078..cf99a44 100644 --- a/Source/WebCore/rendering/RenderAttachment.cpp +++ b/Source/WebCore/rendering/RenderAttachment.cpp @@ -80,6 +80,11 @@ void RenderAttachment::representedFileChanged() repaint(); } +int RenderAttachment::baselinePosition(FontBaseline, bool, LineDirectionMode, LinePositionMode) const +{ + return document().page()->theme().attachmentBaseline(*this); +} + } // namespace WebCore #endif diff --git a/Source/WebCore/rendering/RenderAttachment.h b/Source/WebCore/rendering/RenderAttachment.h index 67a1407..b68a09a 100644 --- a/Source/WebCore/rendering/RenderAttachment.h +++ b/Source/WebCore/rendering/RenderAttachment.h @@ -56,6 +56,8 @@ private: bool isSelected() const; bool isFocused() const; + + virtual int baselinePosition(FontBaseline, bool, LineDirectionMode, LinePositionMode) const; }; } // namespace WebCore diff --git a/Source/WebCore/rendering/RenderTheme.h b/Source/WebCore/rendering/RenderTheme.h index 0c0d3b0..92246f5 100644 --- a/Source/WebCore/rendering/RenderTheme.h +++ b/Source/WebCore/rendering/RenderTheme.h @@ -252,6 +252,7 @@ public: #if ENABLE(ATTACHMENT_ELEMENT) virtual LayoutSize attachmentIntrinsicSize(const RenderAttachment&) const { return LayoutSize(); } + virtual int attachmentBaseline(const RenderAttachment&) const { return -1; } #endif protected: diff --git a/Source/WebCore/rendering/RenderThemeMac.h b/Source/WebCore/rendering/RenderThemeMac.h index e70e0a5..0900f4a 100644 --- a/Source/WebCore/rendering/RenderThemeMac.h +++ b/Source/WebCore/rendering/RenderThemeMac.h @@ -170,6 +170,7 @@ protected: #if ENABLE(ATTACHMENT_ELEMENT) virtual LayoutSize attachmentIntrinsicSize(const RenderAttachment&) const override; + virtual int attachmentBaseline(const RenderAttachment&) const override; virtual bool paintAttachment(const RenderObject&, const PaintInfo&, const IntRect&) override; #endif diff --git a/Source/WebCore/rendering/RenderThemeMac.mm b/Source/WebCore/rendering/RenderThemeMac.mm index 039b120..ba62d7c 100644 --- a/Source/WebCore/rendering/RenderThemeMac.mm +++ b/Source/WebCore/rendering/RenderThemeMac.mm @@ -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 labelFont; FontCascade labelFontCascade; std::unique_ptr 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, -- 1.8.3.1