Implement <attachment> element appearance on Mac
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Feb 2015 02:07:22 +0000 (02:07 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Feb 2015 02:07:22 +0000 (02:07 +0000)
commit0ceff9daa91dba869a2e4b3bd19088b6b5e3794f
treeab65ac623c5a570d82b3028ab1c859f72408ab3e
parent1639ead58409cc3eae3d56ebfa59ca471b1c72f8
Implement <attachment> element appearance on Mac
https://bugs.webkit.org/show_bug.cgi?id=142023

Reviewed by Dean Jackson.

* css/CSSParser.cpp:
(WebCore::isValidKeywordPropertyAndValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
* css/CSSValueKeywords.in:
* css/html.css:
(attachment):
* platform/ThemeTypes.h:
Add a new -webkit-appearance value, attachment.

* WebCore.xcodeproj/project.pbxproj:
* html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::setFile):
Let the renderer know when the file changes (so it can relayout and repaint).

(WebCore::HTMLAttachmentElement::filePath):
(WebCore::HTMLAttachmentElement::fileName):
* html/HTMLAttachmentElement.h:
Handy acccessors for the full path and the name of the file.

* platform/spi/mac/IconServicesSPI.h: Added.
* platform/spi/mac/LaunchServicesSPI.h: Added.
Add some IconServices and LaunchServices SPI headers.

* rendering/RenderAttachment.cpp:
(WebCore::RenderAttachment::RenderAttachment):
Don't have a default intrinsic size; we'll adjust in layout().

(WebCore::RenderAttachment::isSelected):
(WebCore::RenderAttachment::isFocused):
(WebCore::RenderAttachment::isSelectedOrFocused):
Factor out from paintReplaced().

(WebCore::RenderAttachment::layout):
Use RenderTheme to compute the intrinsic size of this attachment.

(WebCore::RenderAttachment::paintReplaced):
Use RenderTheme to paint the attachment.

(WebCore::RenderAttachment::representedFileChanged):
When the represented file changes, we need to recompute the intrinsic size and repaint.

* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::adjustStyle):
(WebCore::RenderTheme::paint):
(WebCore::RenderTheme::adjustAttachmentStyle):
(WebCore::RenderTheme::paintAttachment):
Plumb through the attachment appearance.

* rendering/RenderAttachment.h:
* rendering/RenderTheme.h:
(WebCore::RenderTheme::paintAttachment):
(WebCore::RenderTheme::attachmentIntrinsicSize):
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::attachmentIconBackgroundColor):
(WebCore::attachmentIconBorderColor):
(WebCore::AttachmentLayout):
AttachmentLayout lays out the innards of the RenderThemeMac attachment
presentation: an icon with an optional bordered background, with a label
underneath it with an optional background.

(WebCore::RenderThemeMac::attachmentIntrinsicSize):
(WebCore::paintAttachmentIconBackground):
(WebCore::paintAttachmentIcon):
(WebCore::RenderThemeMac::paintAttachmentLabelBackground):
(WebCore::RenderThemeMac::paintAttachmentLabel):
(WebCore::RenderThemeMac::paintAttachment):
Paint the attachment element. Paint the optional backgrounds (and swap
out the text color) if the element is selected/focused.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180720 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/attachment/attachment-disabled-rendering-expected.txt
LayoutTests/fast/attachment/attachment-rendering-expected.txt
LayoutTests/platform/mac/fast/attachment/attachment-disabled-rendering-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/attachment/attachment-rendering-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/attachment/attachment-rendering-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/html.css
Source/WebCore/html/HTMLAttachmentElement.cpp
Source/WebCore/platform/ThemeTypes.h
Source/WebCore/platform/spi/mac/IconServicesSPI.h [new file with mode: 0644]
Source/WebCore/platform/spi/mac/LaunchServicesSPI.h [new file with mode: 0644]
Source/WebCore/rendering/RenderAttachment.cpp
Source/WebCore/rendering/RenderAttachment.h
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm