Diff
Modified: trunk/LayoutTests/ChangeLog (234884 => 234885)
--- trunk/LayoutTests/ChangeLog 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/LayoutTests/ChangeLog 2018-08-15 14:26:05 UTC (rev 234885)
@@ -1,3 +1,17 @@
+2018-08-15 Wenson Hsieh <wenson_hs...@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 <aj...@chromium.org>
[IntersectionObserver] Do not hold a strong reference to the root element
Deleted: trunk/LayoutTests/fast/attachment/attachment-without-appearance-expected.html (234884 => 234885)
--- trunk/LayoutTests/fast/attachment/attachment-without-appearance-expected.html 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/LayoutTests/fast/attachment/attachment-without-appearance-expected.html 2018-08-15 14:26:05 UTC (rev 234885)
@@ -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>
Deleted: trunk/LayoutTests/fast/attachment/attachment-without-appearance.html (234884 => 234885)
--- trunk/LayoutTests/fast/attachment/attachment-without-appearance.html 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/LayoutTests/fast/attachment/attachment-without-appearance.html 2018-08-15 14:26:05 UTC (rev 234885)
@@ -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>
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (234884 => 234885)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2018-08-15 14:26:05 UTC (rev 234885)
@@ -3385,8 +3385,6 @@
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 ]
Modified: trunk/Source/WebCore/ChangeLog (234884 => 234885)
--- trunk/Source/WebCore/ChangeLog 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Source/WebCore/ChangeLog 2018-08-15 14:26:05 UTC (rev 234885)
@@ -1,3 +1,56 @@
+2018-08-15 Wenson Hsieh <wenson_hs...@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 <aj...@chromium.org>
[IntersectionObserver] Do not hold a strong reference to the root element
Modified: trunk/Source/WebCore/editing/Editor.cpp (234884 => 234885)
--- trunk/Source/WebCore/editing/Editor.cpp 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Source/WebCore/editing/Editor.cpp 2018-08-15 14:26:05 UTC (rev 234885)
@@ -3873,7 +3873,7 @@
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 @@
attachment->setAttribute(HTMLNames::typeAttr, contentType);
attachment->setUniqueIdentifier(identifier);
attachment->setFile(WTFMove(file));
- attachment->updateDisplayMode(options.mode);
auto fragmentToInsert = document().createDocumentFragment();
fragmentToInsert->appendChild(attachment.get());
Modified: trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (234884 => 234885)
--- trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2018-08-15 14:26:05 UTC (rev 234885)
@@ -209,7 +209,6 @@
#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 @@
{
#if ENABLE(ATTACHMENT_ELEMENT)
struct AttachmentReplacementInfo {
- AttachmentDisplayMode displayMode;
Ref<File> file;
Ref<Element> elementToReplace;
};
@@ -257,7 +255,7 @@
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 @@
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 @@
auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, fragment.document());
attachment->setFile(WTFMove(file), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
- attachment->updateDisplayMode(info.displayMode);
parent->replaceChild(attachment, elementToReplace);
}
Modified: trunk/Source/WebCore/html/AttachmentTypes.h (234884 => 234885)
--- trunk/Source/WebCore/html/AttachmentTypes.h 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Source/WebCore/html/AttachmentTypes.h 2018-08-15 14:26:05 UTC (rev 234885)
@@ -34,15 +34,7 @@
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&);
};
@@ -49,16 +41,13 @@
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 {
Modified: trunk/Source/WebCore/html/HTMLAttachmentElement.cpp (234884 => 234885)
--- trunk/Source/WebCore/html/HTMLAttachmentElement.cpp 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Source/WebCore/html/HTMLAttachmentElement.cpp 2018-08-15 14:26:05 UTC (rev 234885)
@@ -35,21 +35,12 @@
#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 @@
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,31 +121,10 @@
}
}
- if (auto* renderAttachment = attachmentRenderer())
- renderAttachment->invalidate();
-
- invalidateShadowRootChildrenIfNecessary();
- populateShadowRootIfNecessary();
+ if (auto* renderer = this->renderer())
+ renderer->invalidate();
}
-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;
-}
-
Node::InsertedIntoAncestorResult HTMLAttachmentElement::insertedIntoAncestor(InsertionType type, ContainerNode& ancestor)
{
auto result = HTMLElement::insertedIntoAncestor(type, ancestor);
@@ -178,8 +143,8 @@
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 @@
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 @@
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) {
Modified: trunk/Source/WebCore/html/HTMLAttachmentElement.h (234884 => 234885)
--- trunk/Source/WebCore/html/HTMLAttachmentElement.h 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Source/WebCore/html/HTMLAttachmentElement.h 2018-08-15 14:26:05 UTC (rev 234885)
@@ -53,7 +53,6 @@
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 @@
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 @@
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;
Modified: trunk/Source/WebCore/page/DragController.cpp (234884 => 234885)
--- trunk/Source/WebCore/page/DragController.cpp 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Source/WebCore/page/DragController.cpp 2018-08-15 14:26:05 UTC (rev 234885)
@@ -1088,7 +1088,7 @@
#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();
Modified: trunk/Source/WebCore/rendering/RenderAttachment.h (234884 => 234885)
--- trunk/Source/WebCore/rendering/RenderAttachment.h 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Source/WebCore/rendering/RenderAttachment.h 2018-08-15 14:26:05 UTC (rev 234885)
@@ -59,6 +59,11 @@
bool m_shouldDrawBorder { true };
};
+inline RenderAttachment* HTMLAttachmentElement::renderer() const
+{
+ return downcast<RenderAttachment>(HTMLElement::renderer());
+}
+
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderAttachment, isAttachment())
Modified: trunk/Source/WebKit/ChangeLog (234884 => 234885)
--- trunk/Source/WebKit/ChangeLog 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Source/WebKit/ChangeLog 2018-08-15 14:26:05 UTC (rev 234885)
@@ -1,3 +1,18 @@
+2018-08-15 Wenson Hsieh <wenson_hs...@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_...@apple.com>
Crash in WebKit::filterPreloadHSTSEntry via NetworkProcess::getHostNamesWithHSTSCache
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm (234884 => 234885)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm 2018-08-15 14:26:05 UTC (rev 234885)
@@ -39,32 +39,9 @@
@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
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (234884 => 234885)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-08-15 14:26:05 UTC (rev 234885)
@@ -6105,12 +6105,8 @@
});
}
-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));
}
Modified: trunk/Tools/ChangeLog (234884 => 234885)
--- trunk/Tools/ChangeLog 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Tools/ChangeLog 2018-08-15 14:26:05 UTC (rev 234885)
@@ -1,3 +1,19 @@
+2018-08-15 Wenson Hsieh <wenson_hs...@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 <drou...@apple.com>
Unreviewed, change my emails.
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm (234884 => 234885)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm 2018-08-15 14:13:06 UTC (rev 234884)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm 2018-08-15 14:26:05 UTC (rev 234885)
@@ -188,12 +188,6 @@
return [NSData dataWithContentsOfURL:testImageFileURL()];
}
-static NSData *testVideoData()
-{
- NSURL *url = "" 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 @@
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 @@
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 @@
{
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 @@
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 @@
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 @@
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 @@
[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 @@
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 @@
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 @@
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 @@
[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 @@
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 @@
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 @@
{
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 @@
{
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 @@
[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 @@
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 @@
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 @@
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 @@
[dragAndDropSimulator endDataTransfer];
}
-TEST(WKAttachmentTestsIOS, DragInPlaceVideoAttachmentElement)
-{
- auto webView = webViewForTestingAttachments();
- auto data = ""
- 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 @@
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 @@
[dragAndDropSimulator endDataTransfer];
}
-TEST(WKAttachmentTestsIOS, MoveInPlaceAttachmentElementByDragging)
-{
- auto webView = webViewForTestingAttachments();
- auto data = ""
- 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