[Attachment SPI] Remove attachment display mode options
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Aug 2018 14:26:05 +0000 (14:26 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Aug 2018 14:26:05 +0000 (14:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188596

Reviewed by Dan Bernstein.

Source/WebCore:

Remove the ability to specify an "in-place" or "icon" representation for attachment elements, as well as logic
needed to allow an attachment element to render image or video elements in a shadow root. The requirements that
initially drove this effort are obviated by r227068, which allows Mail to intercept and provide a custom scheme
for images inserted into the document via rich editing operations.

Removed some existing API tests in _WKAttachmentTests that exercised this functionality.

* editing/Editor.cpp:
(WebCore::Editor::insertAttachmentFromFile):
* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::createFragmentForImageAttachment):
(WebCore::replaceRichContentWithAttachments):
* html/AttachmentTypes.h:
(WebCore::AttachmentDisplayOptions::encode const):
(WebCore::AttachmentDisplayOptions::decode):

Remove logic for encoding the attachment display mode. While this leaves AttachmentDisplayOptions completely
empty, I haven't removed AttachmentDisplayOptions as well in this patch, since it's not clear that we won't be
needing any mechanism for influencing the display of attachment elements inserted via native SPI.

(): Deleted.
* html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::createElementRenderer):
(WebCore::HTMLAttachmentElement::setFile):
(WebCore::HTMLAttachmentElement::parseAttribute):
(WebCore::HTMLAttachmentElement::invalidateShadowRootChildrenIfNecessary): Deleted.
(WebCore::HTMLAttachmentElement::attachmentRenderer const): Deleted.
(WebCore::HTMLAttachmentElement::updateDisplayMode): Deleted.
(WebCore::HTMLAttachmentElement::ensureInnerImage): Deleted.
(WebCore::HTMLAttachmentElement::ensureInnerVideo): Deleted.
(WebCore::HTMLAttachmentElement::innerImage const): Deleted.
(WebCore::HTMLAttachmentElement::innerVideo const): Deleted.
(WebCore::HTMLAttachmentElement::populateShadowRootIfNecessary): Deleted.

Remove logic for building the shadow root to house inline media elements.

* html/HTMLAttachmentElement.h:

The renderer of the attachment element is once again always a `RenderAttachment`, so we can remove
`attachmentRenderer()` altogether and revert to overriding `renderer()` to return a `RenderAttachment*`.

* page/DragController.cpp:
(WebCore::DragController::startDrag):
* rendering/RenderAttachment.h:
(WebCore::HTMLAttachmentElement::renderer const):

Source/WebKit:

Remove attachment display mode from WebKit. Note that _WKAttachmentDisplayOptions needs to remain in the private
header for source compatibility with Mail.

* UIProcess/API/Cocoa/_WKAttachment.mm:
(-[_WKAttachmentDisplayOptions coreDisplayOptions]): Deleted.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setAttachmentDisplayOptions):

Tools:

Remove API tests and API test helpers for verifying the behavior of in-place media attachment elements.

* TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
(-[TestWKWebView synchronouslyInsertAttachmentWithFilename:contentType:data:]):
(TestWebKitAPI::TEST):
(testVideoData): Deleted.
(displayOptionsWithMode): Deleted.
(-[TestWKWebView synchronouslyInsertAttachmentWithFilename:contentType:data:options:]): Deleted.

LayoutTests:

Remove a layout test which verified that attachment elements with `-webkit-appearance: none` would render
child elements. This was only used to implement in-place attachment display modes.

* fast/attachment/attachment-without-appearance-expected.html: Removed.
* fast/attachment/attachment-without-appearance.html: Removed.
* platform/gtk/TestExpectations:

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

17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/attachment/attachment-without-appearance-expected.html [deleted file]
LayoutTests/fast/attachment/attachment-without-appearance.html [deleted file]
LayoutTests/platform/gtk/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
Source/WebCore/html/AttachmentTypes.h
Source/WebCore/html/HTMLAttachmentElement.cpp
Source/WebCore/html/HTMLAttachmentElement.h
Source/WebCore/page/DragController.cpp
Source/WebCore/rendering/RenderAttachment.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm

index c562171..0622a2f 100644 (file)
@@ -1,3 +1,17 @@
+2018-08-15  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Attachment SPI] Remove attachment display mode options
+        https://bugs.webkit.org/show_bug.cgi?id=188596
+
+        Reviewed by Dan Bernstein.
+
+        Remove a layout test which verified that attachment elements with `-webkit-appearance: none` would render
+        child elements. This was only used to implement in-place attachment display modes.
+
+        * fast/attachment/attachment-without-appearance-expected.html: Removed.
+        * fast/attachment/attachment-without-appearance.html: Removed.
+        * platform/gtk/TestExpectations:
+
 2018-08-15  Ali Juma  <ajuma@chromium.org>
 
         [IntersectionObserver] Do not hold a strong reference to the root element
diff --git a/LayoutTests/fast/attachment/attachment-without-appearance-expected.html b/LayoutTests/fast/attachment/attachment-without-appearance-expected.html
deleted file mode 100644 (file)
index 24cbfc2..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<html>
-<style>
-    span {
-        display: inline-block;
-    }
-</style>
-<body>
-<div>This test passes if you observe two green squares below.</div>
-<span><div style="width: 100px; height: 100px; background-color: green; color: white;">Lorem.</div></span>
-<span><div style="width: 100px; height: 100px; background-color: green; color: white;">Ipsum.</div></span>
-</body>
-</html>
diff --git a/LayoutTests/fast/attachment/attachment-without-appearance.html b/LayoutTests/fast/attachment/attachment-without-appearance.html
deleted file mode 100644 (file)
index 1cfa479..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
-<html>
-<body>
-<div>This test passes if you observe two green squares below.</div>
-<attachment style="-webkit-appearance: none;"><div style="width: 100px; height: 100px; background-color: green; color: white;">Lorem.</div></attachment>
-<attachment id="attachment"><div style="width: 100px; height: 100px; background-color: green; color: white;">Ipsum.</div></attachment>
-<script>
-    attachment.style.webkitAppearance = "none";
-</script>
-</body>
-</html>
index 955d55d..bce938a 100644 (file)
@@ -3385,8 +3385,6 @@ webkit.org/b/177632 fast/text/flag-codepoint.html [ ImageOnlyFailure ]
 
 webkit.org/b/179052 compositing/contents-format/subpixel-antialiased-nested-layer.html [ Failure ]
 
-webkit.org/b/180371 fast/attachment/attachment-without-appearance.html [ ImageOnlyFailure ]
-
 webkit.org/b/180749 http/wpt/offscreen-canvas/transferToImageBitmap-webgl.html [ ImageOnlyFailure ]
 
 webkit.org/b/180802 imported/w3c/web-platform-tests/html/webappapis/system-state-and-capabilities/the-navigator-object/navigator-pluginarray.html [ Failure ]
index 549c524..c052c63 100644 (file)
@@ -1,3 +1,56 @@
+2018-08-15  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Attachment SPI] Remove attachment display mode options
+        https://bugs.webkit.org/show_bug.cgi?id=188596
+
+        Reviewed by Dan Bernstein.
+
+        Remove the ability to specify an "in-place" or "icon" representation for attachment elements, as well as logic
+        needed to allow an attachment element to render image or video elements in a shadow root. The requirements that
+        initially drove this effort are obviated by r227068, which allows Mail to intercept and provide a custom scheme
+        for images inserted into the document via rich editing operations.
+
+        Removed some existing API tests in _WKAttachmentTests that exercised this functionality.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::insertAttachmentFromFile):
+        * editing/cocoa/WebContentReaderCocoa.mm:
+        (WebCore::createFragmentForImageAttachment):
+        (WebCore::replaceRichContentWithAttachments):
+        * html/AttachmentTypes.h:
+        (WebCore::AttachmentDisplayOptions::encode const):
+        (WebCore::AttachmentDisplayOptions::decode):
+
+        Remove logic for encoding the attachment display mode. While this leaves AttachmentDisplayOptions completely
+        empty, I haven't removed AttachmentDisplayOptions as well in this patch, since it's not clear that we won't be
+        needing any mechanism for influencing the display of attachment elements inserted via native SPI.
+
+        (): Deleted.
+        * html/HTMLAttachmentElement.cpp:
+        (WebCore::HTMLAttachmentElement::createElementRenderer):
+        (WebCore::HTMLAttachmentElement::setFile):
+        (WebCore::HTMLAttachmentElement::parseAttribute):
+        (WebCore::HTMLAttachmentElement::invalidateShadowRootChildrenIfNecessary): Deleted.
+        (WebCore::HTMLAttachmentElement::attachmentRenderer const): Deleted.
+        (WebCore::HTMLAttachmentElement::updateDisplayMode): Deleted.
+        (WebCore::HTMLAttachmentElement::ensureInnerImage): Deleted.
+        (WebCore::HTMLAttachmentElement::ensureInnerVideo): Deleted.
+        (WebCore::HTMLAttachmentElement::innerImage const): Deleted.
+        (WebCore::HTMLAttachmentElement::innerVideo const): Deleted.
+        (WebCore::HTMLAttachmentElement::populateShadowRootIfNecessary): Deleted.
+
+        Remove logic for building the shadow root to house inline media elements.
+
+        * html/HTMLAttachmentElement.h:
+
+        The renderer of the attachment element is once again always a `RenderAttachment`, so we can remove
+        `attachmentRenderer()` altogether and revert to overriding `renderer()` to return a `RenderAttachment*`.
+
+        * page/DragController.cpp:
+        (WebCore::DragController::startDrag):
+        * rendering/RenderAttachment.h:
+        (WebCore::HTMLAttachmentElement::renderer const):
+
 2018-08-15  Ali Juma  <ajuma@chromium.org>
 
         [IntersectionObserver] Do not hold a strong reference to the root element
index 1bac7f4..7d26c56 100644 (file)
@@ -3873,7 +3873,7 @@ void Editor::insertAttachment(const String& identifier, const AttachmentDisplayO
     insertAttachmentFromFile(identifier, options, filename, *contentType, File::create(Blob::create(WTFMove(data), *contentType), filename));
 }
 
-void Editor::insertAttachmentFromFile(const String& identifier, const AttachmentDisplayOptions& options, const String& filename, const String& contentType, Ref<File>&& file)
+void Editor::insertAttachmentFromFile(const String& identifier, const AttachmentDisplayOptions&, const String& filename, const String& contentType, Ref<File>&& file)
 {
     auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document());
     attachment->setAttribute(HTMLNames::titleAttr, filename);
@@ -3881,7 +3881,6 @@ void Editor::insertAttachmentFromFile(const String& identifier, const Attachment
     attachment->setAttribute(HTMLNames::typeAttr, contentType);
     attachment->setUniqueIdentifier(identifier);
     attachment->setFile(WTFMove(file));
-    attachment->updateDisplayMode(options.mode);
 
     auto fragmentToInsert = document().createDocumentFragment();
     fragmentToInsert->appendChild(attachment.get());
index 9728558..1cb2b1c 100644 (file)
@@ -209,7 +209,6 @@ static Ref<DocumentFragment> createFragmentForImageAttachment(Document& document
 #if ENABLE(ATTACHMENT_ELEMENT)
     auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document);
     attachment->setFile(File::create(blob, AtomicString("image")), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
-    attachment->updateDisplayMode(AttachmentDisplayMode::InPlace);
 
     auto fragment = document.createDocumentFragment();
     fragment->appendChild(attachment);
@@ -225,7 +224,6 @@ static void replaceRichContentWithAttachments(DocumentFragment& fragment, const
 {
 #if ENABLE(ATTACHMENT_ELEMENT)
     struct AttachmentReplacementInfo {
-        AttachmentDisplayMode displayMode;
         Ref<File> file;
         Ref<Element> elementToReplace;
     };
@@ -257,7 +255,7 @@ static void replaceRichContentWithAttachments(DocumentFragment& fragment, const
         if (title.isEmpty())
             title = AtomicString("media");
 
-        attachmentReplacementInfo.append({ AttachmentDisplayMode::InPlace, File::create(*blob, title), image });
+        attachmentReplacementInfo.append({ File::create(*blob, title), image });
     }
 
     for (auto& object : descendantsOfType<HTMLObjectElement>(fragment)) {
@@ -277,7 +275,7 @@ static void replaceRichContentWithAttachments(DocumentFragment& fragment, const
         if (title.isEmpty())
             title = AtomicString("file");
 
-        attachmentReplacementInfo.append({ AttachmentDisplayMode::AsIcon, File::create(*blob, title), object });
+        attachmentReplacementInfo.append({ File::create(*blob, title), object });
     }
 
     for (auto& info : attachmentReplacementInfo) {
@@ -289,7 +287,6 @@ static void replaceRichContentWithAttachments(DocumentFragment& fragment, const
 
         auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, fragment.document());
         attachment->setFile(WTFMove(file), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
-        attachment->updateDisplayMode(info.displayMode);
         parent->replaceChild(attachment, elementToReplace);
     }
 
index 88c1817..b5077ca 100644 (file)
@@ -34,31 +34,20 @@ namespace WebCore {
 
 class SharedBuffer;
 
-enum class AttachmentDisplayMode {
-    Auto,
-    InPlace,
-    AsIcon
-};
-
 struct AttachmentDisplayOptions {
-    AttachmentDisplayMode mode { AttachmentDisplayMode::Auto };
-
     template<class Encoder> void encode(Encoder&) const;
     template<class Decoder> static std::optional<AttachmentDisplayOptions> decode(Decoder&);
 };
 
 template<class Encoder> inline void AttachmentDisplayOptions::encode(Encoder& encoder) const
 {
-    encoder.encodeEnum(mode);
+    UNUSED_PARAM(encoder);
 }
 
 template<class Decoder> inline std::optional<AttachmentDisplayOptions> AttachmentDisplayOptions::decode(Decoder& decoder)
 {
-    AttachmentDisplayMode mode;
-    if (!decoder.decodeEnum(mode))
-        return std::nullopt;
-
-    return {{ mode }};
+    UNUSED_PARAM(decoder);
+    return AttachmentDisplayOptions();
 }
 
 struct AttachmentInfo {
index fe7dd53..e1719cd 100644 (file)
 #include "FileReaderLoader.h"
 #include "FileReaderLoaderClient.h"
 #include "Frame.h"
-#include "HTMLImageElement.h"
 #include "HTMLNames.h"
-#include "HTMLVideoElement.h"
-#include "MIMETypeRegistry.h"
 #include "RenderAttachment.h"
-#include "RenderBlockFlow.h"
-#include "ShadowRoot.h"
 #include "SharedBuffer.h"
 #include <pal/FileSizeFormatter.h>
 #include <wtf/IsoMallocInlines.h>
 
-#if PLATFORM(COCOA)
-#include "UTIUtilities.h"
-#endif
-
 namespace WebCore {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLAttachmentElement);
@@ -101,11 +92,6 @@ Ref<HTMLAttachmentElement> HTMLAttachmentElement::create(const QualifiedName& ta
 
 RenderPtr<RenderElement> HTMLAttachmentElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
 {
-    if (!style.hasAppearance()) {
-        // If this attachment element doesn't have an appearance, defer rendering to child elements.
-        return createRenderer<RenderBlockFlow>(*this, WTFMove(style));
-    }
-
     return createRenderer<RenderAttachment>(*this, WTFMove(style));
 }
 
@@ -135,29 +121,8 @@ void HTMLAttachmentElement::setFile(RefPtr<File>&& file, UpdateDisplayAttributes
         }
     }
 
-    if (auto* renderAttachment = attachmentRenderer())
-        renderAttachment->invalidate();
-
-    invalidateShadowRootChildrenIfNecessary();
-    populateShadowRootIfNecessary();
-}
-
-void HTMLAttachmentElement::invalidateShadowRootChildrenIfNecessary()
-{
-    if (auto image = innerImage()) {
-        image->setAttributeWithoutSynchronization(srcAttr, emptyString());
-        image->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);
-    }
-    if (auto video = innerVideo()) {
-        video->setAttributeWithoutSynchronization(srcAttr, emptyString());
-        video->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);
-    }
-}
-
-RenderAttachment* HTMLAttachmentElement::attachmentRenderer() const
-{
-    auto* renderer = this->renderer();
-    return is<RenderAttachment>(renderer) ? downcast<RenderAttachment>(renderer) : nullptr;
+    if (auto* renderer = this->renderer())
+        renderer->invalidate();
 }
 
 Node::InsertedIntoAncestorResult HTMLAttachmentElement::insertedIntoAncestor(InsertionType type, ContainerNode& ancestor)
@@ -178,8 +143,8 @@ void HTMLAttachmentElement::removedFromAncestor(RemovalType type, ContainerNode&
 void HTMLAttachmentElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     if (name == progressAttr || name == subtitleAttr || name == titleAttr || name == typeAttr) {
-        if (auto* renderAttachment = attachmentRenderer())
-            renderAttachment->invalidate();
+        if (auto* renderer = this->renderer())
+            renderer->invalidate();
     }
 
     HTMLElement::parseAttribute(name, value);
@@ -203,28 +168,6 @@ String HTMLAttachmentElement::attachmentPath() const
     return attributeWithoutSynchronization(webkitattachmentpathAttr);
 }
 
-void HTMLAttachmentElement::updateDisplayMode(AttachmentDisplayMode mode)
-{
-    mode = mode == AttachmentDisplayMode::Auto ? defaultDisplayMode() : mode;
-
-    switch (mode) {
-    case AttachmentDisplayMode::InPlace:
-        populateShadowRootIfNecessary();
-        setInlineStyleProperty(CSSPropertyWebkitAppearance, CSSValueNone, true);
-        setInlineStyleProperty(CSSPropertyDisplay, CSSValueInlineBlock, true);
-        break;
-    case AttachmentDisplayMode::AsIcon:
-        removeInlineStyleProperty(CSSPropertyWebkitAppearance);
-        removeInlineStyleProperty(CSSPropertyDisplay);
-        break;
-    default:
-        ASSERT_NOT_REACHED();
-        break;
-    }
-
-    invalidateStyleAndRenderersForSubtree();
-}
-
 void HTMLAttachmentElement::updateFileWithData(Ref<SharedBuffer>&& data, std::optional<String>&& newContentType, std::optional<String>&& newFilename)
 {
     auto filename = newFilename ? *newFilename : attachmentTitle();
@@ -233,75 +176,6 @@ void HTMLAttachmentElement::updateFileWithData(Ref<SharedBuffer>&& data, std::op
     setFile(WTFMove(file), UpdateDisplayAttributes::Yes);
 }
 
-Ref<HTMLImageElement> HTMLAttachmentElement::ensureInnerImage()
-{
-    if (auto image = innerImage())
-        return *image;
-
-    auto image = HTMLImageElement::create(document());
-    ensureUserAgentShadowRoot().appendChild(image);
-    return image;
-}
-
-Ref<HTMLVideoElement> HTMLAttachmentElement::ensureInnerVideo()
-{
-    if (auto video = innerVideo())
-        return *video;
-
-    auto video = HTMLVideoElement::create(document());
-    ensureUserAgentShadowRoot().appendChild(video);
-    return video;
-}
-
-RefPtr<HTMLImageElement> HTMLAttachmentElement::innerImage() const
-{
-    if (auto root = userAgentShadowRoot())
-        return childrenOfType<HTMLImageElement>(*root).first();
-    return nullptr;
-}
-
-RefPtr<HTMLVideoElement> HTMLAttachmentElement::innerVideo() const
-{
-    if (auto root = userAgentShadowRoot())
-        return childrenOfType<HTMLVideoElement>(*root).first();
-    return nullptr;
-}
-
-void HTMLAttachmentElement::populateShadowRootIfNecessary()
-{
-    if (!m_file)
-        return;
-
-    auto mimeType = attachmentType();
-
-#if PLATFORM(COCOA)
-    if (isDeclaredUTI(mimeType))
-        mimeType = MIMETypeFromUTI(mimeType);
-#endif
-
-    if (mimeType.isEmpty())
-        return;
-
-    if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType) || MIMETypeRegistry::isPDFMIMEType(mimeType)) {
-        auto image = ensureInnerImage();
-        if (image->attributeWithoutSynchronization(srcAttr).isEmpty()) {
-            image->setAttributeWithoutSynchronization(srcAttr, DOMURL::createObjectURL(document(), *m_file));
-            image->setAttributeWithoutSynchronization(draggableAttr, AtomicString("false"));
-            image->setInlineStyleProperty(CSSPropertyDisplay, CSSValueInline, true);
-            image->setInlineStyleProperty(CSSPropertyMaxWidth, 100, CSSPrimitiveValue::UnitType::CSS_PERCENTAGE, true);
-        }
-
-    } else if (MIMETypeRegistry::isSupportedMediaMIMEType(mimeType)) {
-        auto video = ensureInnerVideo();
-        if (video->attributeWithoutSynchronization(srcAttr).isEmpty()) {
-            video->setAttributeWithoutSynchronization(srcAttr, DOMURL::createObjectURL(document(), *m_file));
-            video->setAttributeWithoutSynchronization(controlsAttr, emptyString());
-            video->setInlineStyleProperty(CSSPropertyDisplay, CSSValueInline, true);
-            video->setInlineStyleProperty(CSSPropertyMaxWidth, 100, CSSPrimitiveValue::UnitType::CSS_PERCENTAGE, true);
-        }
-    }
-}
-
 void HTMLAttachmentElement::requestInfo(Function<void(const AttachmentInfo&)>&& callback)
 {
     if (!m_file) {
index 2367e8e..14fc84b 100644 (file)
@@ -53,7 +53,6 @@ public:
     String uniqueIdentifier() const { return m_uniqueIdentifier; }
     void setUniqueIdentifier(const String& uniqueIdentifier) { m_uniqueIdentifier = uniqueIdentifier; }
 
-    WEBCORE_EXPORT void updateDisplayMode(AttachmentDisplayMode);
     WEBCORE_EXPORT void updateFileWithData(Ref<SharedBuffer>&& data, std::optional<String>&& newContentType = std::nullopt, std::optional<String>&& newFilename = std::nullopt);
 
     InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final;
@@ -63,7 +62,7 @@ public:
     String attachmentType() const;
     String attachmentPath() const;
 
-    RenderAttachment* attachmentRenderer() const;
+    RenderAttachment* renderer() const;
 
     WEBCORE_EXPORT void requestInfo(Function<void(const AttachmentInfo&)>&& callback);
     void destroyReader(AttachmentDataReader&);
@@ -73,22 +72,6 @@ private:
     virtual ~HTMLAttachmentElement();
 
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
-    Ref<HTMLImageElement> ensureInnerImage();
-    Ref<HTMLVideoElement> ensureInnerVideo();
-    RefPtr<HTMLImageElement> innerImage() const;
-    RefPtr<HTMLVideoElement> innerVideo() const;
-
-    void populateShadowRootIfNecessary();
-    void invalidateShadowRootChildrenIfNecessary();
-
-    AttachmentDisplayMode defaultDisplayMode() const
-    {
-        // FIXME: For now, all attachment elements automatically display using a file icon.
-        // In a followup patch, we'll change the default behavior to use in-place presentation
-        // for certain image MIME types.
-        return AttachmentDisplayMode::AsIcon;
-    }
-
     bool shouldSelectOnMouseDown() final {
 #if PLATFORM(IOS)
         return false;
index 6c49e66..7b503be 100644 (file)
@@ -1088,7 +1088,7 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation
 #if ENABLE(ATTACHMENT_ELEMENT)
     if (is<HTMLAttachmentElement>(element) && m_dragSourceAction & DragSourceActionAttachment) {
         auto& attachment = downcast<HTMLAttachmentElement>(element);
-        auto* attachmentRenderer = attachment.attachmentRenderer();
+        auto* attachmentRenderer = attachment.renderer();
 
         src.editor().setIgnoreSelectionChanges(true);
         auto previousSelection = src.selection().selection();
index 8ddec5d..4caae03 100644 (file)
@@ -59,6 +59,11 @@ private:
     bool m_shouldDrawBorder { true };
 };
 
+inline RenderAttachment* HTMLAttachmentElement::renderer() const
+{
+    return downcast<RenderAttachment>(HTMLElement::renderer());
+}
+
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderAttachment, isAttachment())
index 0b82df9..8aff417 100644 (file)
@@ -1,3 +1,18 @@
+2018-08-15  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Attachment SPI] Remove attachment display mode options
+        https://bugs.webkit.org/show_bug.cgi?id=188596
+
+        Reviewed by Dan Bernstein.
+
+        Remove attachment display mode from WebKit. Note that _WKAttachmentDisplayOptions needs to remain in the private
+        header for source compatibility with Mail.
+
+        * UIProcess/API/Cocoa/_WKAttachment.mm:
+        (-[_WKAttachmentDisplayOptions coreDisplayOptions]): Deleted.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setAttachmentDisplayOptions):
+
 2018-08-14 Sihui Liu <sihui_liu@apple.com>
 
         Crash in WebKit::filterPreloadHSTSEntry via NetworkProcess::getHostNamesWithHSTSCache
index 2de500c..5f00c8c 100644 (file)
@@ -39,32 +39,9 @@ using namespace WebKit;
 
 @implementation _WKAttachmentDisplayOptions : NSObject
 
-- (instancetype)init
-{
-    if (self = [super init])
-        _mode = _WKAttachmentDisplayModeAuto;
-
-    return self;
-}
-
 - (WebCore::AttachmentDisplayOptions)coreDisplayOptions
 {
-    WebCore::AttachmentDisplayMode mode;
-    switch (self.mode) {
-    case _WKAttachmentDisplayModeAuto:
-        mode = WebCore::AttachmentDisplayMode::Auto;
-        break;
-    case _WKAttachmentDisplayModeAsIcon:
-        mode = WebCore::AttachmentDisplayMode::AsIcon;
-        break;
-    case _WKAttachmentDisplayModeInPlace:
-        mode = WebCore::AttachmentDisplayMode::InPlace;
-        break;
-    default:
-        ASSERT_NOT_REACHED();
-        mode = WebCore::AttachmentDisplayMode::Auto;
-    }
-    return { mode };
+    return { };
 }
 
 @end
index d6b9655..51143a3 100644 (file)
@@ -6105,12 +6105,8 @@ void WebPage::requestAttachmentInfo(const String& identifier, CallbackID callbac
     });
 }
 
-void WebPage::setAttachmentDisplayOptions(const String& identifier, const AttachmentDisplayOptions& options, CallbackID callbackID)
+void WebPage::setAttachmentDisplayOptions(const String&, const AttachmentDisplayOptions&, CallbackID callbackID)
 {
-    if (auto attachment = attachmentElementWithIdentifier(identifier)) {
-        attachment->document().updateLayout();
-        attachment->updateDisplayMode(options.mode);
-    }
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }
 
index b7f35bb..2053b36 100644 (file)
@@ -1,3 +1,19 @@
+2018-08-15  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Attachment SPI] Remove attachment display mode options
+        https://bugs.webkit.org/show_bug.cgi?id=188596
+
+        Reviewed by Dan Bernstein.
+
+        Remove API tests and API test helpers for verifying the behavior of in-place media attachment elements.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
+        (-[TestWKWebView synchronouslyInsertAttachmentWithFilename:contentType:data:]):
+        (TestWebKitAPI::TEST):
+        (testVideoData): Deleted.
+        (displayOptionsWithMode): Deleted.
+        (-[TestWKWebView synchronouslyInsertAttachmentWithFilename:contentType:data:options:]): Deleted.
+
 2018-08-14  Devin Rousso  <drousso@apple.com>
 
         Unreviewed, change my emails.
index d8f56bd..2f7c503 100644 (file)
@@ -188,12 +188,6 @@ static NSData *testImageData()
     return [NSData dataWithContentsOfURL:testImageFileURL()];
 }
 
-static NSData *testVideoData()
-{
-    NSURL *url = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"mp4" subdirectory:@"TestWebKitAPI.resources"];
-    return [NSData dataWithContentsOfURL:url];
-}
-
 static NSURL *testPDFFileURL()
 {
     return [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"pdf" subdirectory:@"TestWebKitAPI.resources"];
@@ -204,13 +198,6 @@ static NSData *testPDFData()
     return [NSData dataWithContentsOfURL:testPDFFileURL()];
 }
 
-static _WKAttachmentDisplayOptions *displayOptionsWithMode(_WKAttachmentDisplayMode mode)
-{
-    _WKAttachmentDisplayOptions *options = [[[_WKAttachmentDisplayOptions alloc] init] autorelease];
-    options.mode = mode;
-    return options;
-}
-
 @implementation TestWKWebView (AttachmentTesting)
 
 - (NSArray<NSString *> *)tagsInBody
@@ -250,10 +237,10 @@ static _WKAttachmentDisplayOptions *displayOptionsWithMode(_WKAttachmentDisplayM
     return success;
 }
 
-- (_WKAttachment *)synchronouslyInsertAttachmentWithFilename:(NSString *)filename contentType:(NSString *)contentType data:(NSData *)data options:(_WKAttachmentDisplayOptions *)options
+- (_WKAttachment *)synchronouslyInsertAttachmentWithFilename:(NSString *)filename contentType:(NSString *)contentType data:(NSData *)data
 {
     __block bool done = false;
-    RetainPtr<_WKAttachment> attachment = [self _insertAttachmentWithFilename:filename contentType:contentType data:data options:options completion:^(BOOL) {
+    RetainPtr<_WKAttachment> attachment = [self _insertAttachmentWithFilename:filename contentType:contentType data:data options:nil completion:^(BOOL) {
         done = true;
     }];
     TestWebKitAPI::Util::run(&done);
@@ -505,7 +492,7 @@ TEST(WKAttachmentTests, AttachmentElementInsertion)
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
         // Use the given content type for the attachment element's type.
-        firstAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo" contentType:@"text/html" data:testHTMLData() options:nil];
+        firstAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo" contentType:@"text/html" data:testHTMLData()];
         EXPECT_WK_STREQ(@"foo", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
         EXPECT_WK_STREQ(@"text/html", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
         EXPECT_WK_STREQ(@"38 bytes", [webView valueOfAttribute:@"subtitle" forQuerySelector:@"attachment"]);
@@ -522,7 +509,7 @@ TEST(WKAttachmentTests, AttachmentElementInsertion)
         ObserveAttachmentUpdatesForScope scope(webView.get());
         // Since no content type is explicitly specified, compute it from the file extension.
         [webView _executeEditCommand:@"DeleteBackward" argument:nil completion:nil];
-        secondAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"bar.png" contentType:nil data:testImageData() options:nil];
+        secondAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"bar.png" contentType:nil data:testImageData()];
         EXPECT_WK_STREQ(@"bar.png", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
         EXPECT_WK_STREQ(@"image/png", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
         EXPECT_WK_STREQ(@"37 KB", [webView valueOfAttribute:@"subtitle" forQuerySelector:@"attachment"]);
@@ -542,7 +529,7 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenInsertingAndDeletingNewline)
     RetainPtr<_WKAttachment> attachment;
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData() options:nil];
+        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()];
         observer.expectAttachmentUpdates(@[ ], @[attachment.get()]);
     }
     [webView expectUpdatesAfterCommand:@"InsertParagraph" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
@@ -569,7 +556,7 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenUndoingAndRedoing)
     RetainPtr<_WKAttachment> attachment;
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData() options:nil];
+        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()];
         observer.expectAttachmentUpdates(@[ ], @[attachment.get()]);
     }
     [webView expectUpdatesAfterCommand:@"Undo" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]];
@@ -595,7 +582,7 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenChangingFontStyles)
     [webView _synchronouslyExecuteEditCommand:@"InsertText" argument:@"Hello"];
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData() options:nil];
+        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()];
         observer.expectAttachmentUpdates(@[ ], @[attachment.get()]);
     }
     [webView expectUpdatesAfterCommand:@"InsertText" withArgument:@"World" expectedRemovals:@[] expectedInsertions:@[]];
@@ -619,7 +606,7 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenInsertingLists)
     RetainPtr<_WKAttachment> attachment;
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData() options:nil];
+        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()];
         observer.expectAttachmentUpdates(@[ ], @[attachment.get()]);
     }
     [webView expectUpdatesAfterCommand:@"InsertOrderedList" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
@@ -663,7 +650,7 @@ TEST(WKAttachmentTests, AttachmentUpdatesWhenCuttingAndPasting)
     RetainPtr<_WKAttachment> attachment;
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData() options:nil];
+        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:testHTMLData()];
         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
     }
     [attachment expectRequestedDataToBe:testHTMLData()];
@@ -692,7 +679,7 @@ TEST(WKAttachmentTests, AttachmentDataForEmptyFile)
     RetainPtr<_WKAttachment> attachment;
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"empty.txt" contentType:@"text/plain" data:[NSData data] options:nil];
+        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"empty.txt" contentType:@"text/plain" data:[NSData data]];
         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
     }
     [attachment expectRequestedDataToBe:[NSData data]];
@@ -705,20 +692,6 @@ TEST(WKAttachmentTests, AttachmentDataForEmptyFile)
     [attachment expectRequestedDataToBe:nil];
 }
 
-TEST(WKAttachmentTests, InsertedImageSizeIsClampedByMaxWidth)
-{
-    auto webView = webViewForTestingAttachments(CGSizeMake(100, 100));
-    RetainPtr<NSData> imageData = testImageData();
-    RetainPtr<_WKAttachment> attachment;
-    {
-        ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"icon.png" contentType:@"image/png" data:imageData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
-        [attachment expectRequestedDataToBe:imageData.get()];
-        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
-    }
-    [webView waitForAttachmentElementSizeToBecome:CGSizeMake(84, 67)];
-}
-
 TEST(WKAttachmentTests, MultipleSimultaneousAttachmentDataRequests)
 {
     auto webView = webViewForTestingAttachments();
@@ -726,7 +699,7 @@ TEST(WKAttachmentTests, MultipleSimultaneousAttachmentDataRequests)
     RetainPtr<_WKAttachment> attachment;
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:htmlData.get() options:nil];
+        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:htmlData.get()];
         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
     }
     __block RetainPtr<NSData> dataForFirstRequest;
@@ -748,97 +721,6 @@ TEST(WKAttachmentTests, MultipleSimultaneousAttachmentDataRequests)
     EXPECT_TRUE([dataForSecondRequest isEqualToData:htmlData.get()]);
 }
 
-TEST(WKAttachmentTests, InPlaceImageAttachmentToggleDisplayMode)
-{
-    auto webView = webViewForTestingAttachments();
-    RetainPtr<NSData> imageData = testImageData();
-    RetainPtr<_WKAttachment> attachment;
-    {
-        ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"icon.png" contentType:@"image/png" data:imageData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon)];
-        [attachment expectRequestedDataToBe:imageData.get()];
-        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
-    }
-    CGSize iconAttachmentSize = [webView attachmentElementSize];
-
-    [attachment synchronouslySetDisplayOptions:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace) error:nil];
-    [attachment expectRequestedDataToBe:imageData.get()];
-    [webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
-
-    [attachment synchronouslySetDisplayOptions:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon) error:nil];
-    [attachment expectRequestedDataToBe:imageData.get()];
-    [webView waitForAttachmentElementSizeToBecome:iconAttachmentSize];
-
-    [attachment synchronouslySetDisplayOptions:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace) error:nil];
-    [attachment expectRequestedDataToBe:imageData.get()];
-    [webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
-}
-
-TEST(WKAttachmentTests, InPlaceImageAttachmentParagraphInsertion)
-{
-    auto webView = webViewForTestingAttachments();
-    RetainPtr<NSData> imageData = testImageData();
-    RetainPtr<_WKAttachment> attachment;
-    {
-        ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"icon.png" contentType:@"image/png" data:imageData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
-        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
-    }
-    [webView expectUpdatesAfterCommand:@"InsertParagraph" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
-    [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
-    [webView stringByEvaluatingJavaScript:@"getSelection().collapse(document.body)"];
-    [webView expectUpdatesAfterCommand:@"InsertParagraph" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
-    [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
-
-    [attachment expectRequestedDataToBe:imageData.get()];
-    EXPECT_WK_STREQ([attachment uniqueIdentifier], [webView stringByEvaluatingJavaScript:@"document.querySelector('attachment').uniqueIdentifier"]);
-    [webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
-
-    [webView expectUpdatesAfterCommand:@"DeleteForward" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]];
-}
-
-TEST(WKAttachmentTests, InPlaceVideoAttachmentInsertionWithinList)
-{
-    auto webView = webViewForTestingAttachments();
-    RetainPtr<NSData> videoData = testVideoData();
-    RetainPtr<_WKAttachment> attachment;
-
-    [webView _synchronouslyExecuteEditCommand:@"InsertOrderedList" argument:nil];
-    {
-        ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.mp4" contentType:@"video/mp4" data:videoData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
-        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
-    }
-    [webView waitForAttachmentElementSizeToBecome:CGSizeMake(320, 240)];
-
-    [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]];
-    [webView expectUpdatesAfterCommand:@"Undo" withArgument:nil expectedRemovals:@[] expectedInsertions:@[attachment.get()]];
-    [webView expectUpdatesAfterCommand:@"InsertOrderedList" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]];
-
-    [webView waitForAttachmentElementSizeToBecome:CGSizeMake(320, 240)];
-    [attachment expectRequestedDataToBe:videoData.get()];
-}
-
-TEST(WKAttachmentTests, InPlacePDFAttachmentCutAndPaste)
-{
-    auto webView = webViewForTestingAttachments();
-    RetainPtr<NSData> pdfData = testPDFData();
-    RetainPtr<_WKAttachment> attachment;
-    {
-        ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.pdf" contentType:@"application/pdf" data:pdfData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
-        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
-        [webView waitForAttachmentElementSizeToBecome:CGSizeMake(130, 29)];
-    }
-
-    [webView _synchronouslyExecuteEditCommand:@"SelectAll" argument:nil];
-    [webView expectUpdatesAfterCommand:@"Cut" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]];
-
-    [webView expectUpdatesAfterCommand:@"Paste" withArgument:nil expectedRemovals:@[] expectedInsertions:@[attachment.get()]];
-    [webView waitForAttachmentElementSizeToBecome:CGSizeMake(130, 29)];
-    [attachment expectRequestedDataToBe:pdfData.get()];
-}
-
 TEST(WKAttachmentTests, ChangeAttachmentDataAndFileInformation)
 {
     auto webView = webViewForTestingAttachments();
@@ -846,7 +728,7 @@ TEST(WKAttachmentTests, ChangeAttachmentDataAndFileInformation)
     {
         RetainPtr<NSData> pdfData = testPDFData();
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.pdf" contentType:@"application/pdf" data:pdfData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon)];
+        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.pdf" contentType:@"application/pdf" data:pdfData.get()];
         [attachment expectRequestedDataToBe:pdfData.get()];
         EXPECT_WK_STREQ(@"test.pdf", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
         EXPECT_WK_STREQ(@"application/pdf", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
@@ -864,7 +746,6 @@ TEST(WKAttachmentTests, ChangeAttachmentDataAndFileInformation)
     {
         RetainPtr<NSData> textData = testHTMLData();
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        [attachment synchronouslySetDisplayOptions:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon) error:nil];
         // The new content type should be inferred from the file name.
         [attachment synchronouslySetData:textData.get() newContentType:nil newFilename:@"foo.txt" error:nil];
         [attachment expectRequestedDataToBe:textData.get()];
@@ -885,43 +766,6 @@ TEST(WKAttachmentTests, ChangeAttachmentDataAndFileInformation)
     [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]];
 }
 
-TEST(WKAttachmentTests, ChangeAttachmentDataUpdatesWithInPlaceDisplay)
-{
-    auto webView = webViewForTestingAttachments();
-    RetainPtr<_WKAttachment> attachment;
-    {
-        RetainPtr<NSData> pdfData = testPDFData();
-        ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"test.pdf" contentType:@"application/pdf" data:pdfData.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
-        [webView waitForAttachmentElementSizeToBecome:CGSizeMake(130, 29)];
-        [attachment expectRequestedDataToBe:pdfData.get()];
-        EXPECT_WK_STREQ(@"test.pdf", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
-        EXPECT_WK_STREQ(@"application/pdf", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
-        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
-    }
-    {
-        RetainPtr<NSData> videoData = testVideoData();
-        ObserveAttachmentUpdatesForScope observer(webView.get());
-        [attachment synchronouslySetData:videoData.get() newContentType:@"video/mp4" newFilename:@"test.mp4" error:nil];
-        [webView waitForAttachmentElementSizeToBecome:CGSizeMake(320, 240)];
-        [attachment expectRequestedDataToBe:videoData.get()];
-        EXPECT_WK_STREQ(@"test.mp4", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
-        EXPECT_WK_STREQ(@"video/mp4", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
-        observer.expectAttachmentUpdates(@[], @[]);
-    }
-    {
-        RetainPtr<NSData> imageData = testImageData();
-        ObserveAttachmentUpdatesForScope observer(webView.get());
-        [attachment synchronouslySetData:imageData.get() newContentType:@"image/png" newFilename:@"icon.png" error:nil];
-        [webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
-        [attachment expectRequestedDataToBe:imageData.get()];
-        EXPECT_WK_STREQ(@"icon.png", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
-        EXPECT_WK_STREQ(@"image/png", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
-        observer.expectAttachmentUpdates(@[], @[]);
-    }
-    [webView expectUpdatesAfterCommand:@"DeleteBackward" withArgument:nil expectedRemovals:@[attachment.get()] expectedInsertions:@[]];
-}
-
 TEST(WKAttachmentTests, InsertPastedImageAsAttachment)
 {
     platformCopyPNG();
@@ -1054,7 +898,7 @@ TEST(WKAttachmentTests, InsertAndRemoveDuplicateAttachment)
     RetainPtr<_WKAttachment> pastedAttachment;
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        originalAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:data.get() options:nil];
+        originalAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:data.get()];
         EXPECT_EQ(0U, observer.observer().removed.count);
         observer.expectAttachmentUpdates(@[], @[originalAttachment.get()]);
     }
@@ -1090,7 +934,7 @@ TEST(WKAttachmentTests, InsertDuplicateAttachmentAndUpdateData)
     RetainPtr<_WKAttachment> pastedAttachment;
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        originalAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:originalData.get() options:nil];
+        originalAttachment = [webView synchronouslyInsertAttachmentWithFilename:@"foo.txt" contentType:@"text/plain" data:originalData.get()];
         EXPECT_EQ(0U, observer.observer().removed.count);
         observer.expectAttachmentUpdates(@[], @[originalAttachment.get()]);
     }
@@ -1386,7 +1230,7 @@ TEST(WKAttachmentTestsIOS, DragAttachmentInsertedAsData)
     RetainPtr<_WKAttachment> attachment;
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:data.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon)];
+        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:data.get()];
         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
     }
 
@@ -1408,34 +1252,6 @@ TEST(WKAttachmentTestsIOS, DragAttachmentInsertedAsData)
     [dragAndDropSimulator endDataTransfer];
 }
 
-TEST(WKAttachmentTestsIOS, DragInPlaceVideoAttachmentElement)
-{
-    auto webView = webViewForTestingAttachments();
-    auto data = retainPtr(testVideoData());
-    RetainPtr<_WKAttachment> attachment;
-    {
-        ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"video.mp4" contentType:@"video/mp4" data:data.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
-        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
-    }
-
-    [webView waitForAttachmentElementSizeToBecome:CGSizeMake(320, 240)];
-    [attachment expectRequestedDataToBe:data.get()];
-    EXPECT_WK_STREQ("video.mp4", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
-    EXPECT_WK_STREQ("video/mp4", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
-
-    [webView evaluateJavaScript:@"getSelection().removeAllRanges()" completionHandler:nil];
-    auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]);
-    [dragAndDropSimulator runFrom:CGPointMake(25, 25) to:CGPointMake(-100, -100)];
-
-    EXPECT_EQ(1U, [dragAndDropSimulator sourceItemProviders].count);
-    NSItemProvider *itemProvider = [dragAndDropSimulator sourceItemProviders].firstObject;
-    EXPECT_EQ(UIPreferredPresentationStyleAttachment, itemProvider.preferredPresentationStyle);
-    [itemProvider expectType:(NSString *)kUTTypeMPEG4 withData:data.get()];
-    EXPECT_WK_STREQ("video.mp4", [itemProvider suggestedName]);
-    [dragAndDropSimulator endDataTransfer];
-}
-
 TEST(WKAttachmentTestsIOS, MoveAttachmentElementAsIconByDragging)
 {
     auto webView = webViewForTestingAttachments();
@@ -1443,7 +1259,7 @@ TEST(WKAttachmentTestsIOS, MoveAttachmentElementAsIconByDragging)
     RetainPtr<_WKAttachment> attachment;
     {
         ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:data.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeAsIcon)];
+        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"document.pdf" contentType:@"application/pdf" data:data.get()];
         observer.expectAttachmentUpdates(@[], @[attachment.get()]);
     }
 
@@ -1464,35 +1280,6 @@ TEST(WKAttachmentTestsIOS, MoveAttachmentElementAsIconByDragging)
     [dragAndDropSimulator endDataTransfer];
 }
 
-TEST(WKAttachmentTestsIOS, MoveInPlaceAttachmentElementByDragging)
-{
-    auto webView = webViewForTestingAttachments();
-    auto data = retainPtr(testImageData());
-    RetainPtr<_WKAttachment> attachment;
-    {
-        ObserveAttachmentUpdatesForScope observer(webView.get());
-        attachment = [webView synchronouslyInsertAttachmentWithFilename:@"icon.png" contentType:@"image/png" data:data.get() options:displayOptionsWithMode(_WKAttachmentDisplayModeInPlace)];
-        observer.expectAttachmentUpdates(@[], @[attachment.get()]);
-    }
-
-    [webView waitForAttachmentElementSizeToBecome:CGSizeMake(215, 174)];
-    [webView _executeEditCommand:@"InsertParagraph" argument:nil completion:nil];
-    [webView _executeEditCommand:@"InsertHTML" argument:@"<strong>text</strong>" completion:nil];
-    [webView _synchronouslyExecuteEditCommand:@"InsertParagraph" argument:nil];
-    [webView expectElementTag:@"ATTACHMENT" toComeBefore:@"STRONG"];
-
-    auto dragAndDropSimulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]);
-    [dragAndDropSimulator runFrom:CGPointMake(25, 25) to:CGPointMake(25, 425)];
-
-    attachment = [[dragAndDropSimulator insertedAttachments] firstObject];
-    [attachment expectRequestedDataToBe:data.get()];
-    EXPECT_WK_STREQ("icon.png", [webView valueOfAttribute:@"title" forQuerySelector:@"attachment"]);
-    EXPECT_WK_STREQ("image/png", [webView valueOfAttribute:@"type" forQuerySelector:@"attachment"]);
-
-    [webView expectElementTag:@"STRONG" toComeBefore:@"ATTACHMENT"];
-    [dragAndDropSimulator endDataTransfer];
-}
-
 #endif // PLATFORM(IOS)
 
 } // namespace TestWebKitAPI