Add a borderless mode to <attachment>, and make it respect its layout size
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jun 2017 18:08:48 +0000 (18:08 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jun 2017 18:08:48 +0000 (18:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173079
<rdar://problem/32491584>

Reviewed by Simon Fraser.

Source/WebCore:

Tests: fast/attachment/attachment-borderless.html
       fast/attachment/attachment-respects-css-size.html

* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
* css/CSSValueKeywords.in:
* platform/ThemeTypes.h:
* rendering/RenderAttachment.cpp:
(WebCore::RenderAttachment::shouldDrawBorder):
* rendering/RenderAttachment.h:
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::adjustStyle):
(WebCore::RenderTheme::paint):
Add "-webkit-appearance: borderless-attachment;" in addition to "attachment",
so clients can specify the borderless appearance. This isn't specified as a
CSS border because it's a very custom appearance that isn't achievable that way.

* rendering/RenderThemeIOS.mm:
(WebCore::AttachmentInfo::AttachmentInfo):
Use the layout size of the attachment, not the fixed size; we use the fixed
size as our intrinsic size, so most attachments will still be that size,
but if a client specifies a different size, we'll lay out correctly.

LayoutTests:

* TestExpectations:
* platform/ios/TestExpectations:
* fast/attachment/attachment-borderless-expected-mismatch.html: Added.
* fast/attachment/attachment-borderless.html: Added.
* fast/attachment/attachment-respects-css-size-expected-mismatch.html: Added.
* fast/attachment/attachment-respects-css-size.html: Added.
Add mismatch tests ensuring that CSS width/height and borderless-attachment
have *some* kind of impact on rendering.

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/attachment/attachment-borderless-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/attachment/attachment-borderless.html [new file with mode: 0644]
LayoutTests/fast/attachment/attachment-respects-css-size-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/attachment/attachment-respects-css-size.html [new file with mode: 0644]
LayoutTests/platform/ios/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/platform/ThemeTypes.h
Source/WebCore/rendering/RenderAttachment.cpp
Source/WebCore/rendering/RenderAttachment.h
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderThemeIOS.mm

index c004384..06d8a58 100644 (file)
@@ -1,3 +1,20 @@
+2017-06-08  Tim Horton  <timothy_horton@apple.com>
+
+        Add a borderless mode to <attachment>, and make it respect its layout size
+        https://bugs.webkit.org/show_bug.cgi?id=173079
+        <rdar://problem/32491584>
+
+        Reviewed by Simon Fraser.
+
+        * TestExpectations:
+        * platform/ios/TestExpectations:
+        * fast/attachment/attachment-borderless-expected-mismatch.html: Added.
+        * fast/attachment/attachment-borderless.html: Added.
+        * fast/attachment/attachment-respects-css-size-expected-mismatch.html: Added.
+        * fast/attachment/attachment-respects-css-size.html: Added.
+        Add mismatch tests ensuring that CSS width/height and borderless-attachment
+        have *some* kind of impact on rendering.
+
 2017-06-08  Marcos Chavarría Teijeiro  <chavarria1991@gmail.com>
 
         Modify security test to avoid spacing differences.
index 12d10f8..b263289 100644 (file)
@@ -81,6 +81,7 @@ fast/attachment/attachment-subtitle-resize.html
 
 # This test only makes sense on iOS
 fast/attachment/attachment-wrapping-action.html
+fast/attachment/attachment-borderless.html
 editing/selection/character-granularity-selected-range-after-dismissing-selection.html [ Skip ]
 editing/selection/character-granularity-select-text-with-click-handler.html [ Skip ]
 editing/selection/caret-after-tap-in-editable-selection.html [ Skip ]
diff --git a/LayoutTests/fast/attachment/attachment-borderless-expected-mismatch.html b/LayoutTests/fast/attachment/attachment-borderless-expected-mismatch.html
new file mode 100644 (file)
index 0000000..2e9a12f
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<script>
+    if (window.internals)
+        window.internals.settings.setAttachmentElementEnabled(true)
+</script>
+<body>
+<attachment id="attachment" title="overridden title" subtitle="1024 bytes"></attachment>
+</body>
+</html>
diff --git a/LayoutTests/fast/attachment/attachment-borderless.html b/LayoutTests/fast/attachment/attachment-borderless.html
new file mode 100644 (file)
index 0000000..c4dcd87
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<script>
+    if (window.internals)
+        window.internals.settings.setAttachmentElementEnabled(true)
+</script>
+<body>
+<attachment id="attachment" title="overridden title" subtitle="1024 bytes" style="-webkit-appearance: borderless-attachment;"></attachment>
+</body>
+</html>
diff --git a/LayoutTests/fast/attachment/attachment-respects-css-size-expected-mismatch.html b/LayoutTests/fast/attachment/attachment-respects-css-size-expected-mismatch.html
new file mode 100644 (file)
index 0000000..2e9a12f
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<script>
+    if (window.internals)
+        window.internals.settings.setAttachmentElementEnabled(true)
+</script>
+<body>
+<attachment id="attachment" title="overridden title" subtitle="1024 bytes"></attachment>
+</body>
+</html>
diff --git a/LayoutTests/fast/attachment/attachment-respects-css-size.html b/LayoutTests/fast/attachment/attachment-respects-css-size.html
new file mode 100644 (file)
index 0000000..176f349
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<script>
+    if (window.internals)
+        window.internals.settings.setAttachmentElementEnabled(true)
+</script>
+<body>
+<attachment id="attachment" title="overridden title" subtitle="1024 bytes" style="width: 500px; height: 500px;"></attachment>
+</body>
+</html>
index 7e86226..21df331 100644 (file)
@@ -2674,6 +2674,7 @@ media/W3C/audio/canPlayType/canPlayType_supported_but_no_codecs_parameter_1.html
 media/video-seek-to-current-time.html [ Failure ]
 
 fast/attachment/attachment-wrapping-action.html [ Pass ]
+fast/attachment/attachment-borderless.html [ Pass ]
 
 fast/events/page-visibility-iframe-move-test.html [ Skip ]
 
index 29ba365..e72ad5b 100644 (file)
@@ -1,3 +1,34 @@
+2017-06-08  Tim Horton  <timothy_horton@apple.com>
+
+        Add a borderless mode to <attachment>, and make it respect its layout size
+        https://bugs.webkit.org/show_bug.cgi?id=173079
+        <rdar://problem/32491584>
+
+        Reviewed by Simon Fraser.
+
+        Tests: fast/attachment/attachment-borderless.html
+               fast/attachment/attachment-respects-css-size.html
+
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        * css/CSSValueKeywords.in:
+        * platform/ThemeTypes.h:
+        * rendering/RenderAttachment.cpp:
+        (WebCore::RenderAttachment::shouldDrawBorder):
+        * rendering/RenderAttachment.h:
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::adjustStyle):
+        (WebCore::RenderTheme::paint):
+        Add "-webkit-appearance: borderless-attachment;" in addition to "attachment",
+        so clients can specify the borderless appearance. This isn't specified as a
+        CSS border because it's a very custom appearance that isn't achievable that way.
+
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::AttachmentInfo::AttachmentInfo):
+        Use the layout size of the attachment, not the fixed size; we use the fixed
+        size as our intrinsic size, so most attachments will still be that size,
+        but if a client specifies a different size, we'll lay out correctly.
+
 2017-06-08  Jer Noble  <jer.noble@apple.com>
 
         YouTube audio stutters when page changes visibility.
index 6a4366d..4390911 100644 (file)
@@ -607,6 +607,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e)
     case AttachmentPart:
         m_value.valueID = CSSValueAttachment;
         break;
+    case BorderlessAttachmentPart:
+        m_value.valueID = CSSValueBorderlessAttachment;
+        break;
 #endif
 #if ENABLE(SERVICE_CONTROLS)
     case ImageControlsButtonPart:
index c45e0ea..15cfb0f 100644 (file)
@@ -816,6 +816,7 @@ image-controls-button
 textarea
 #if defined(ENABLE_ATTACHMENT_ELEMENT) && ENABLE_ATTACHMENT_ELEMENT
 attachment
+borderless-attachment
 #endif
 caps-lock-indicator
 
index 50e6edc..33cb30e 100644 (file)
@@ -53,7 +53,7 @@ enum ControlPart {
 #endif
     TextAreaPart,
 #if ENABLE(ATTACHMENT_ELEMENT)
-    AttachmentPart,
+    AttachmentPart, BorderlessAttachmentPart,
 #endif
     CapsLockIndicatorPart
 };
index 4accf14..a45134d 100644 (file)
@@ -70,6 +70,13 @@ int RenderAttachment::baselinePosition(FontBaseline, bool, LineDirectionMode, Li
     return theme().attachmentBaseline(*this);
 }
 
+bool RenderAttachment::shouldDrawBorder() const
+{
+    if (style().appearance() == BorderlessAttachmentPart)
+        return false;
+    return m_shouldDrawBorder;
+}
+
 } // namespace WebCore
 
 #endif
index b55b5d2..91d262b 100644 (file)
@@ -39,7 +39,7 @@ public:
     HTMLAttachmentElement& attachmentElement() const;
 
     void setShouldDrawBorder(bool drawBorder) { m_shouldDrawBorder = drawBorder; }
-    bool shouldDrawBorder() const { return m_shouldDrawBorder; }
+    bool shouldDrawBorder() const;
 
     void invalidate();
 
index 308e0df..99df773 100644 (file)
@@ -258,6 +258,7 @@ void RenderTheme::adjustStyle(StyleResolver& styleResolver, RenderStyle& style,
 #endif
 #if ENABLE(ATTACHMENT_ELEMENT)
     case AttachmentPart:
+    case BorderlessAttachmentPart:
         return adjustAttachmentStyle(styleResolver, style, element);
 #endif
     default:
@@ -410,6 +411,7 @@ bool RenderTheme::paint(const RenderBox& box, ControlStates& controlStates, cons
 #endif
 #if ENABLE(ATTACHMENT_ELEMENT)
     case AttachmentPart:
+    case BorderlessAttachmentPart:
         return paintAttachment(box, paintInfo, integralSnappedRect);
 #endif
     default:
index 89aa7d5..6a1e434 100644 (file)
@@ -1661,7 +1661,7 @@ static RetainPtr<UIImage> iconForAttachment(const RenderAttachment& attachment,
 
 AttachmentInfo::AttachmentInfo(const RenderAttachment& attachment)
 {
-    attachmentRect = FloatRect(0, 0, attachmentSize.width, attachmentSize.height);
+    attachmentRect = FloatRect(0, 0, attachment.width().toFloat(), attachment.height().toFloat());
 
     hasProgress = getAttachmentProgress(attachment, progress);