WebKit Bugzilla
Attachment 346911 Details for
Bug 188464
: Support drag-and-drop for input[type=color]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188464-20180810102803.patch (text/plain), 75.47 KB, created by
Aditya Keerthi
on 2018-08-10 10:28:04 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Aditya Keerthi
Created:
2018-08-10 10:28:04 PDT
Size:
75.47 KB
patch
obsolete
>Subversion Revision: 234747 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index a631f6a157568d59a65c60555be0e6c084917595..f9ec88f1fc116443f80f052d22eabd2cc44ef550 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,75 @@ >+2018-08-10 Aditya Keerthi <akeerthi@apple.com> >+ >+ Support drag-and-drop for input[type=color] >+ https://bugs.webkit.org/show_bug.cgi?id=188464 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ input[type=color] should support native drag and drop on both macOS and iOS. >+ >+ Added methods to Pasteboard and PlatformPasteboard to enable colors to be read >+ from and written to the pasteboard. On macOS, colors are managed through the >+ NSColorPboardType, whereas on iOS, colors are managed through the >+ 'com.apple.uikit.color' identifier. >+ >+ DragSourceActionColor was added to the list of DragSourceActions to identify >+ when a color input is being dragged. >+ >+ Implemented createDragImageForColor to display a particular color swatch once >+ the drag session has begun. Added the visiblePath property to DragImage, in >+ order for us to be able to clip images in the UITargetedDragPreview on iOS. The >+ rendered image on macOS is designed to mimic the preview shown when dragging an >+ NSColorWell. >+ >+ Test: editing/pasteboard/drag-and-drop-color-input.html >+ >+ * page/DragActions.h: >+ * page/DragController.cpp: >+ (WebCore::DragController::dragEnteredOrUpdated): >+ (WebCore::isColorInput): >+ (WebCore::DragController::concludeEditDrag): >+ (WebCore::DragController::canProcessDrag): >+ (WebCore::DragController::draggableElement const): >+ (WebCore::DragController::startDrag): >+ * page/EventHandler.cpp: >+ (WebCore::EventHandler::dragHysteresisExceeded const): >+ (WebCore::EventHandler::handleDrag): >+ * page/EventHandler.h: >+ * page/mac/DragControllerMac.mm: >+ (WebCore::DragController::updateSupportedTypeIdentifiersForDragHandlingMethod const): >+ * platform/DragData.h: >+ * platform/DragImage.cpp: >+ (WebCore::DragImage::operator=): >+ * platform/DragImage.h: >+ * platform/DragItem.h: >+ (WebCore::DragItem::encode const): >+ (WebCore::DragItem::decode): >+ * platform/Pasteboard.h: >+ * platform/PasteboardStrategy.h: >+ * platform/PlatformPasteboard.h: >+ * platform/gtk/DragImageGtk.cpp: >+ (WebCore::createDragImageForColor): >+ * platform/gtk/PasteboardGtk.cpp: >+ (WebCore::Pasteboard::write): >+ * platform/ios/DragImageIOS.mm: >+ (WebCore::createDragImageForColor): >+ * platform/ios/PasteboardIOS.mm: >+ (WebCore::Pasteboard::write): >+ * platform/ios/PlatformPasteboardIOS.mm: >+ (WebCore::PlatformPasteboard::color): >+ (WebCore::PlatformPasteboard::setColor): >+ * platform/mac/DragDataMac.mm: >+ (WebCore::colorPasteboardType): >+ (WebCore::DragData::containsCompatibleContent const): >+ * platform/mac/DragImageMac.mm: >+ (WebCore::createDragImageForColor): >+ * platform/mac/PasteboardMac.mm: >+ (WebCore::Pasteboard::write): >+ * platform/mac/PlatformPasteboardMac.mm: >+ (WebCore::PlatformPasteboard::setColor): >+ * platform/win/PasteboardWin.cpp: >+ (WebCore::Pasteboard::write): >+ > 2018-08-09 Ben Richards <benton_richards@apple.com> > > We should cache the compiled sandbox profile in a data vault >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index f0fa5642db3a9c9a76cdeefe288d7c96bd119d78..3a95fa8fbe45fce5e6897cad9249d3a049dad655 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,44 @@ >+2018-08-10 Aditya Keerthi <akeerthi@apple.com> >+ >+ Support drag-and-drop for input[type=color] >+ https://bugs.webkit.org/show_bug.cgi?id=188464 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ On iOS, the drag preview for the color input is a rounded rectangle. In order to >+ ensure that the corners appear transparent, the visiblePath property of the >+ UIDragPreviewParameters was set to match the preview's shape. This also required >+ the creation of an additional ArgumentCoder for Path. >+ >+ When beginning the drag session, the preview should appear centered about the >+ color input. This is managed in createTargetedDragPreview. However, once the >+ preview is dragged, the preview should be at the center of the touch location. >+ Consequently, DragSourceActionColor was added to the list of sources that could >+ update the drag preview after lifting. >+ >+ * Shared/WebCoreArgumentCoders.cpp: >+ (IPC::ArgumentCoder<Path>::decode): >+ * Shared/WebCoreArgumentCoders.h: >+ * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: >+ (WebKit::WebPasteboardProxy::setPasteboardColor): >+ * UIProcess/WebPasteboardProxy.h: >+ * UIProcess/WebPasteboardProxy.messages.in: >+ * UIProcess/ios/DragDropInteractionState.h: >+ * UIProcess/ios/DragDropInteractionState.mm: >+ (WebKit::createTargetedDragPreview): >+ (WebKit::shouldUseDragImageToCreatePreviewForDragSource): >+ (WebKit::shouldUseVisiblePathToCreatePreviewForDragSource): >+ (WebKit::canUpdatePreviewForActiveDragSource): >+ (WebKit::DragDropInteractionState::previewForDragItem const): >+ (WebKit::DragDropInteractionState::stageDragItem): >+ (WebKit::DragDropInteractionState::updatePreviewsForActiveDragSources): >+ * UIProcess/ios/forms/WKFormColorPicker.mm: >+ (-[WKColorPicker initWithView:]): >+ * UIProcess/mac/WebColorPickerMac.h: >+ * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: >+ (WebKit::WebPlatformStrategies::setColor): >+ * WebProcess/WebCoreSupport/WebPlatformStrategies.h: >+ > 2018-08-09 Ben Richards <benton_richards@apple.com> > > We should cache the compiled sandbox profile in a data vault >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index deaf1f9ccd9308aebd9901eb838b770a4062d70a..fd0a2ce399db33195b66645c1ed77720e2b2abfd 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,14 @@ >+2018-08-10 Aditya Keerthi <akeerthi@apple.com> >+ >+ Support drag-and-drop for input[type=color] >+ https://bugs.webkit.org/show_bug.cgi?id=188464 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebCoreSupport/WebPlatformStrategies.h: >+ * WebCoreSupport/WebPlatformStrategies.mm: >+ (WebPlatformStrategies::setColor): >+ > 2018-08-09 Ali Juma <ajuma@chromium.org> > > Import WPTs for IntersectionObserver >diff --git a/Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig b/Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig >index 41a336c75084648f7bfc607ba82245ab25568170..df6eb2b406f055acf5bbe4bcd1ebda5a5d2c22da 100644 >--- a/Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig >+++ b/Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig >@@ -167,9 +167,9 @@ ENABLE_INDEXED_DATABASE = ENABLE_INDEXED_DATABASE; > > ENABLE_INDEXED_DATABASE_IN_WORKERS = ENABLE_INDEXED_DATABASE_IN_WORKERS; > >-ENABLE_INPUT_TYPE_COLOR = ; >+ENABLE_INPUT_TYPE_COLOR = ENABLE_INPUT_TYPE_COLOR; > >-ENABLE_INPUT_TYPE_COLOR_POPOVER = ; >+ENABLE_INPUT_TYPE_COLOR_POPOVER = ENABLE_INPUT_TYPE_COLOR_POPOVER; > > ENABLE_INPUT_TYPE_DATETIMELOCAL = $(ENABLE_INPUT_TYPE_DATETIMELOCAL_$(WK_COCOA_TOUCH)); > ENABLE_INPUT_TYPE_DATETIMELOCAL_cocoatouch = ENABLE_INPUT_TYPE_DATETIMELOCAL; >diff --git a/Source/WTF/wtf/FeatureDefines.h b/Source/WTF/wtf/FeatureDefines.h >index c3070ff92c73cbe8e2a29eeccbea0e20df80e331..e28c2176155dfaab2b3b60876597af4ab84d1025 100644 >--- a/Source/WTF/wtf/FeatureDefines.h >+++ b/Source/WTF/wtf/FeatureDefines.h >@@ -455,11 +455,11 @@ the public iOS SDK. See <https://webkit.org/b/179167>. */ > #endif > > #if !defined(ENABLE_INPUT_TYPE_COLOR) >-#define ENABLE_INPUT_TYPE_COLOR 0 >+#define ENABLE_INPUT_TYPE_COLOR 1 > #endif > > #if !defined(ENABLE_INPUT_TYPE_COLOR_POPOVER) >-#define ENABLE_INPUT_TYPE_COLOR_POPOVER 0 >+#define ENABLE_INPUT_TYPE_COLOR_POPOVER 1 > #endif > > #if !defined(ENABLE_INPUT_TYPE_DATE) >diff --git a/Source/WebCore/Configurations/FeatureDefines.xcconfig b/Source/WebCore/Configurations/FeatureDefines.xcconfig >index 41a336c75084648f7bfc607ba82245ab25568170..df6eb2b406f055acf5bbe4bcd1ebda5a5d2c22da 100644 >--- a/Source/WebCore/Configurations/FeatureDefines.xcconfig >+++ b/Source/WebCore/Configurations/FeatureDefines.xcconfig >@@ -167,9 +167,9 @@ ENABLE_INDEXED_DATABASE = ENABLE_INDEXED_DATABASE; > > ENABLE_INDEXED_DATABASE_IN_WORKERS = ENABLE_INDEXED_DATABASE_IN_WORKERS; > >-ENABLE_INPUT_TYPE_COLOR = ; >+ENABLE_INPUT_TYPE_COLOR = ENABLE_INPUT_TYPE_COLOR; > >-ENABLE_INPUT_TYPE_COLOR_POPOVER = ; >+ENABLE_INPUT_TYPE_COLOR_POPOVER = ENABLE_INPUT_TYPE_COLOR_POPOVER; > > ENABLE_INPUT_TYPE_DATETIMELOCAL = $(ENABLE_INPUT_TYPE_DATETIMELOCAL_$(WK_COCOA_TOUCH)); > ENABLE_INPUT_TYPE_DATETIMELOCAL_cocoatouch = ENABLE_INPUT_TYPE_DATETIMELOCAL; >diff --git a/Source/WebCore/PAL/Configurations/FeatureDefines.xcconfig b/Source/WebCore/PAL/Configurations/FeatureDefines.xcconfig >index 41a336c75084648f7bfc607ba82245ab25568170..df6eb2b406f055acf5bbe4bcd1ebda5a5d2c22da 100644 >--- a/Source/WebCore/PAL/Configurations/FeatureDefines.xcconfig >+++ b/Source/WebCore/PAL/Configurations/FeatureDefines.xcconfig >@@ -167,9 +167,9 @@ ENABLE_INDEXED_DATABASE = ENABLE_INDEXED_DATABASE; > > ENABLE_INDEXED_DATABASE_IN_WORKERS = ENABLE_INDEXED_DATABASE_IN_WORKERS; > >-ENABLE_INPUT_TYPE_COLOR = ; >+ENABLE_INPUT_TYPE_COLOR = ENABLE_INPUT_TYPE_COLOR; > >-ENABLE_INPUT_TYPE_COLOR_POPOVER = ; >+ENABLE_INPUT_TYPE_COLOR_POPOVER = ENABLE_INPUT_TYPE_COLOR_POPOVER; > > ENABLE_INPUT_TYPE_DATETIMELOCAL = $(ENABLE_INPUT_TYPE_DATETIMELOCAL_$(WK_COCOA_TOUCH)); > ENABLE_INPUT_TYPE_DATETIMELOCAL_cocoatouch = ENABLE_INPUT_TYPE_DATETIMELOCAL; >diff --git a/Source/WebCore/page/DragActions.h b/Source/WebCore/page/DragActions.h >index 2c1a37a6e0be5273c2c550e4849f26fe3525875e..c3d4a41767de373b3b14cd73e437a0880cf98bdd 100644 >--- a/Source/WebCore/page/DragActions.h >+++ b/Source/WebCore/page/DragActions.h >@@ -47,6 +47,9 @@ namespace WebCore { > DragSourceActionSelection = 8, > #if ENABLE(ATTACHMENT_ELEMENT) > DragSourceActionAttachment = 16, >+#endif >+#if ENABLE(INPUT_TYPE_COLOR) >+ DragSourceActionColor = 32, > #endif > DragSourceActionAny = UINT_MAX > } DragSourceAction; >diff --git a/Source/WebCore/page/DragController.cpp b/Source/WebCore/page/DragController.cpp >index 6eb63bb85521fe9b49cbcf64c5c06c4d2150cd67..20e68f3231fc40bbb920aa8dd2af8cc93d8f104f 100644 >--- a/Source/WebCore/page/DragController.cpp >+++ b/Source/WebCore/page/DragController.cpp >@@ -321,7 +321,8 @@ DragOperation DragController::dragEnteredOrUpdated(const DragData& dragData) > dragOperation = operationForLoad(dragData); > if (dragOperation != DragOperationNone) > m_dragHandlingMethod = DragHandlingMethod::PageLoad; >- } >+ } else if (m_dragHandlingMethod == DragHandlingMethod::SetColor) >+ dragOperation = DragOperationCopy; > > updateSupportedTypeIdentifiersForDragHandlingMethod(m_dragHandlingMethod, dragData); > return dragOperation; >@@ -343,6 +344,20 @@ static HTMLInputElement* asFileInput(Node& node) > return inputElement && inputElement->isFileUpload() ? inputElement : nullptr; > } > >+#if ENABLE(INPUT_TYPE_COLOR) >+static bool isColorInput(Node& node) >+{ >+ Node* n = node.deprecatedShadowAncestorNode(); >+ if (is<HTMLInputElement>(*n)) { >+ auto& input = downcast<HTMLInputElement>(*n); >+ if (input.isColorControl() && !input.isDisabledFormControl()) >+ return true; >+ } >+ >+ return false; >+} >+#endif >+ > // This can return null if an empty document is loaded. > static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint& p) > { >@@ -539,6 +554,13 @@ bool DragController::concludeEditDrag(const DragData& dragData) > Color color = dragData.asColor(); > if (!color.isValid()) > return false; >+#if ENABLE(INPUT_TYPE_COLOR) >+ if (isColorInput(*element)) { >+ auto& input = downcast<HTMLInputElement>(*element); >+ input.setValue(color.serialized(), DispatchInputAndChangeEvent); >+ return true; >+ } >+#endif > auto innerRange = innerFrame->selection().toNormalizedRange(); > if (!innerRange) > return false; >@@ -643,6 +665,10 @@ bool DragController::canProcessDrag(const DragData& dragData) > DragData::DraggingPurpose dragPurpose = DragData::DraggingPurpose::ForEditing; > if (asFileInput(*result.innerNonSharedNode())) > dragPurpose = DragData::DraggingPurpose::ForFileUpload; >+#if ENABLE(INPUT_TYPE_COLOR) >+ else if (isColorInput(*result.innerNonSharedNode())) >+ dragPurpose = DragData::DraggingPurpose::ForColorControl; >+#endif > > if (!dragData.containsCompatibleContent(dragPurpose)) > return false; >@@ -650,6 +676,11 @@ bool DragController::canProcessDrag(const DragData& dragData) > if (dragPurpose == DragData::DraggingPurpose::ForFileUpload) > return true; > >+#if ENABLE(INPUT_TYPE_COLOR) >+ if (dragPurpose == DragData::DraggingPurpose::ForColorControl) >+ return true; >+#endif >+ > if (is<HTMLPlugInElement>(*result.innerNonSharedNode())) { > if (!downcast<HTMLPlugInElement>(result.innerNonSharedNode())->canProcessDrag() && !result.innerNonSharedNode()->hasEditableStyle()) > return false; >@@ -784,6 +815,14 @@ Element* DragController::draggableElement(const Frame* sourceFrame, Element* sta > state.type = static_cast<DragSourceAction>(state.type | DragSourceActionAttachment); > return element; > } >+#endif >+#if ENABLE(INPUT_TYPE_COLOR) >+ if ((m_dragSourceAction & DragSourceActionColor) >+ && is<HTMLInputElement>(*element) >+ && downcast<HTMLInputElement>(*element).isColorControl()) { >+ state.type = static_cast<DragSourceAction>(state.type | DragSourceActionColor); >+ return element; >+ } > #endif > } > } >@@ -874,6 +913,10 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation > #endif > #if ENABLE(ATTACHMENT_ELEMENT) > includeShadowDOM = includeShadowDOM || is<HTMLAttachmentElement>(state.source.get()); >+#endif >+#if ENABLE(INPUT_TYPE_COLOR) >+ bool isColorControl = (is<HTMLInputElement>(state.source.get()) && downcast<HTMLInputElement>(*state.source.get()).isColorControl()); >+ includeShadowDOM = includeShadowDOM || isColorControl; > #endif > bool sourceContainsHitNode; > if (!includeShadowDOM) >@@ -1130,6 +1173,24 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation > } > #endif > >+#if ENABLE(INPUT_TYPE_COLOR) >+ if (isColorControl && m_dragSourceAction & DragSourceActionColor) { >+ auto& input = downcast<HTMLInputElement>(*state.source.get()); >+ Color color = input.valueAsColor(); >+ >+ Path visiblePath; >+ dragImage = DragImage { createDragImageForColor(color, input.boundsInRootViewSpace(), input.document().page()->pageScaleFactor(), visiblePath) }; >+ dragImage.setVisiblePath(visiblePath); >+ dataTransfer.pasteboard().write(color); >+ dragImageOffset = IntPoint(dragImageSize(dragImage.get())); >+ dragLoc = dragLocForDHTMLDrag(mouseDraggedPoint, dragOrigin, dragImageOffset, false); >+ >+ m_client.willPerformDragSourceAction(DragSourceActionColor, dragOrigin, dataTransfer); >+ doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state, { }); >+ return true; >+ } >+#endif >+ > if (state.type == DragSourceActionDHTML && dragImage) { > ASSERT(m_dragSourceAction & DragSourceActionDHTML); > m_client.willPerformDragSourceAction(DragSourceActionDHTML, dragOrigin, dataTransfer); >diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp >index 15bce50c7b2af8466b3279fb71259ec12abb7ea7..55c8ee53aefab1fa9a9fb2ba3a77330bb4e77074 100644 >--- a/Source/WebCore/page/EventHandler.cpp >+++ b/Source/WebCore/page/EventHandler.cpp >@@ -134,6 +134,7 @@ using namespace HTMLNames; > const int LinkDragHysteresis = 40; > const int ImageDragHysteresis = 5; > const int TextDragHysteresis = 3; >+const int ColorDragHystersis = 3; > const int GeneralDragHysteresis = 3; > #if PLATFORM(COCOA) > const Seconds EventHandler::TextDragDelay { 150_ms }; >@@ -3510,6 +3511,11 @@ bool EventHandler::dragHysteresisExceeded(const FloatPoint& dragViewportLocation > case DragSourceActionLink: > threshold = LinkDragHysteresis; > break; >+#if ENABLE(INPUT_TYPE_COLOR) >+ case DragSourceActionColor: >+ threshold = ColorDragHystersis; >+ break; >+#endif > case DragSourceActionDHTML: > break; > case DragSourceActionNone: >@@ -3690,16 +3696,16 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDr > > if (!ExactlyOneBitSet(dragState().type)) { > ASSERT((dragState().type & DragSourceActionSelection)); >-#if ENABLE(ATTACHMENT_ELEMENT) > ASSERT((dragState().type & ~DragSourceActionSelection) == DragSourceActionDHTML > || (dragState().type & ~DragSourceActionSelection) == DragSourceActionImage >+#if ENABLE(ATTACHMENT_ELEMENT) > || (dragState().type & ~DragSourceActionSelection) == DragSourceActionAttachment >- || (dragState().type & ~DragSourceActionSelection) == DragSourceActionLink); >-#else >- ASSERT((dragState().type & ~DragSourceActionSelection) == DragSourceActionDHTML >- || (dragState().type & ~DragSourceActionSelection) == DragSourceActionImage >- || (dragState().type & ~DragSourceActionSelection) == DragSourceActionLink); > #endif >+#if ENABLE(INPUT_TYPE_COLOR) >+ || (dragState().type & ~DragSourceActionSelection) == DragSourceActionColor >+#endif >+ || (dragState().type & ~DragSourceActionSelection) == DragSourceActionLink); >+ > dragState().type = DragSourceActionSelection; > } > >diff --git a/Source/WebCore/page/EventHandler.h b/Source/WebCore/page/EventHandler.h >index 3ebe56f9b413de0bf3b292e998af86a8dcc2aba4..75ad2681445c52b97508b59ce1ba9a11e0682fe9 100644 >--- a/Source/WebCore/page/EventHandler.h >+++ b/Source/WebCore/page/EventHandler.h >@@ -100,6 +100,7 @@ struct DragState; > extern const int LinkDragHysteresis; > extern const int ImageDragHysteresis; > extern const int TextDragHysteresis; >+extern const int ColorDragHystersis; > extern const int GeneralDragHysteresis; > #endif > >diff --git a/Source/WebCore/page/mac/DragControllerMac.mm b/Source/WebCore/page/mac/DragControllerMac.mm >index 55f2134065c854c06dcbccbf9376f8461626e876..5a30a6c1e77f7ae0f18bdaa0a9c2b20905f28830 100644 >--- a/Source/WebCore/page/mac/DragControllerMac.mm >+++ b/Source/WebCore/page/mac/DragControllerMac.mm >@@ -144,6 +144,9 @@ void DragController::updateSupportedTypeIdentifiersForDragHandlingMethod(DragHan > supportedTypes.append(type); > } > break; >+ case DragHandlingMethod::SetColor: >+ supportedTypes.append(String(UIColorPboardType)); >+ break; > default: > for (NSString *type in Pasteboard::supportedFileUploadPasteboardTypes()) > supportedTypes.append(type); >diff --git a/Source/WebCore/platform/DragData.h b/Source/WebCore/platform/DragData.h >index 0da8bc35e725d1e8967ea8f425f3646e4c048e46..1a4a45f805cc506ab9f191f8061578704ff49206 100644 >--- a/Source/WebCore/platform/DragData.h >+++ b/Source/WebCore/platform/DragData.h >@@ -73,7 +73,7 @@ typedef HashMap<unsigned, Vector<String>> DragDataMap; > class DragData { > public: > enum FilenameConversionPolicy { DoNotConvertFilenames, ConvertFilenames }; >- enum class DraggingPurpose { ForEditing, ForFileUpload }; >+ enum class DraggingPurpose { ForEditing, ForFileUpload, ForColorControl }; > > // clientPosition is taken to be the position of the drag event within the target window, with (0,0) at the top left > WEBCORE_EXPORT DragData(DragDataRef, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation, DragApplicationFlags = DragApplicationNone, DragDestinationAction actions = DragDestinationActionAny); >diff --git a/Source/WebCore/platform/DragImage.cpp b/Source/WebCore/platform/DragImage.cpp >index c8a94e093e77229c4a611729ea9dedb2d9e8fdc7..e463f8da85b56d37e8f9b321fc08d74b55797fdd 100644 >--- a/Source/WebCore/platform/DragImage.cpp >+++ b/Source/WebCore/platform/DragImage.cpp >@@ -259,6 +259,7 @@ DragImage::DragImage(DragImage&& other) > : m_dragImageRef { std::exchange(other.m_dragImageRef, nullptr) } > { > m_indicatorData = other.m_indicatorData; >+ m_visiblePath = other.m_visiblePath; > } > > DragImage& DragImage::operator=(DragImage&& other) >@@ -268,6 +269,7 @@ DragImage& DragImage::operator=(DragImage&& other) > > m_dragImageRef = std::exchange(other.m_dragImageRef, nullptr); > m_indicatorData = other.m_indicatorData; >+ m_visiblePath = other.m_visiblePath; > > return *this; > } >diff --git a/Source/WebCore/platform/DragImage.h b/Source/WebCore/platform/DragImage.h >index aa1699e568cb102e79021f08579ecb4b4057d9dd..384364d1837aa5db256354366e4e654b7bbb0f6f 100644 >--- a/Source/WebCore/platform/DragImage.h >+++ b/Source/WebCore/platform/DragImage.h >@@ -28,6 +28,7 @@ > #include "FloatSize.h" > #include "ImageOrientation.h" > #include "IntSize.h" >+#include "Path.h" > #include "TextFlags.h" > #include "TextIndicator.h" > #include <wtf/Forward.h> >@@ -88,6 +89,7 @@ DragImageRef createDragImageIconForCachedImageFilename(const String&); > WEBCORE_EXPORT DragImageRef createDragImageForNode(Frame&, Node&); > WEBCORE_EXPORT DragImageRef createDragImageForSelection(Frame&, TextIndicatorData&, bool forceBlackText = false); > WEBCORE_EXPORT DragImageRef createDragImageForRange(Frame&, Range&, bool forceBlackText = false); >+DragImageRef createDragImageForColor(const Color&, const FloatRect&, float, Path&); > DragImageRef createDragImageForImage(Frame&, Node&, IntRect& imageRect, IntRect& elementRect); > DragImageRef createDragImageForLink(Element&, URL&, const String& label, TextIndicatorData&, FontRenderingMode, float deviceScaleFactor); > void deleteDragImage(DragImageRef); >@@ -108,12 +110,17 @@ public: > bool hasIndicatorData() const { return !!m_indicatorData; } > std::optional<TextIndicatorData> indicatorData() const { return m_indicatorData; } > >+ void setVisiblePath(const Path& path) { m_visiblePath = path; } >+ bool hasVisiblePath() const { return !!m_visiblePath; } >+ std::optional<Path> visiblePath() const { return m_visiblePath; } >+ > explicit operator bool() const { return !!m_dragImageRef; } > DragImageRef get() const { return m_dragImageRef; } > > private: > DragImageRef m_dragImageRef; > std::optional<TextIndicatorData> m_indicatorData; >+ std::optional<Path> m_visiblePath; > }; > > } >diff --git a/Source/WebCore/platform/DragItem.h b/Source/WebCore/platform/DragItem.h >index 97680cd1560c01716ff52e3d7302761cf98069cf..3eae743754289ad1573d5309c9fb144bda8f71b9 100644 >--- a/Source/WebCore/platform/DragItem.h >+++ b/Source/WebCore/platform/DragItem.h >@@ -67,6 +67,10 @@ void DragItem::encode(Encoder& encoder) const > encoder << hasIndicatorData; > if (hasIndicatorData) > encoder << image.indicatorData().value(); >+ bool hasVisiblePath = image.hasVisiblePath(); >+ encoder << hasVisiblePath; >+ if (hasVisiblePath) >+ encoder << image.visiblePath().value(); > encoder << promisedBlob; > } > >@@ -99,6 +103,16 @@ bool DragItem::decode(Decoder& decoder, DragItem& result) > return false; > result.image.setIndicatorData(*indicatorData); > } >+ bool hasVisiblePath; >+ if (!decoder.decode(hasVisiblePath)) >+ return false; >+ if (hasVisiblePath) { >+ std::optional<Path> visiblePath; >+ decoder >> visiblePath; >+ if (!visiblePath) >+ return false; >+ result.image.setVisiblePath(*visiblePath); >+ } > if (!decoder.decode(result.promisedBlob)) > return false; > return true; >diff --git a/Source/WebCore/platform/Pasteboard.h b/Source/WebCore/platform/Pasteboard.h >index e88e28b38ea223edef70c7671b9bc5fb4c811a47..111f3afceaa7856bd71283a5b8e7a05348364063 100644 >--- a/Source/WebCore/platform/Pasteboard.h >+++ b/Source/WebCore/platform/Pasteboard.h >@@ -213,6 +213,7 @@ public: > virtual WEBCORE_EXPORT void read(PasteboardWebContentReader&, WebContentReadingPolicy = WebContentReadingPolicy::AnyType); > virtual WEBCORE_EXPORT void read(PasteboardFileReader&); > >+ virtual WEBCORE_EXPORT void write(const Color&); > virtual WEBCORE_EXPORT void write(const PasteboardURL&); > virtual WEBCORE_EXPORT void writeTrustworthyWebURLsPboardType(const PasteboardURL&); > virtual WEBCORE_EXPORT void write(const PasteboardImage&); >@@ -331,6 +332,7 @@ private: > > #if PLATFORM(IOS) > extern NSString *WebArchivePboardType; >+extern NSString *UIColorPboardType; > #endif > > #if PLATFORM(MAC) >diff --git a/Source/WebCore/platform/PasteboardStrategy.h b/Source/WebCore/platform/PasteboardStrategy.h >index be58bcfaf665b824e65b5a1760f4fcab32333a02..5ea4c6972ecaaf89d7068a6907ad68e50caf58d3 100644 >--- a/Source/WebCore/platform/PasteboardStrategy.h >+++ b/Source/WebCore/platform/PasteboardStrategy.h >@@ -71,6 +71,7 @@ public: > virtual long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0; > virtual long setBufferForType(SharedBuffer*, const String& pasteboardType, const String& pasteboardName) = 0; > virtual long setURL(const PasteboardURL&, const String& pasteboardName) = 0; >+ virtual long setColor(const Color&, const String& pasteboardName) = 0; > virtual long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) = 0; > #endif > >diff --git a/Source/WebCore/platform/PlatformPasteboard.h b/Source/WebCore/platform/PlatformPasteboard.h >index f10bb5590fb777224c87b0f2fbda876b5afe5342..ec93df08161cede48e12058f596f711837a15214 100644 >--- a/Source/WebCore/platform/PlatformPasteboard.h >+++ b/Source/WebCore/platform/PlatformPasteboard.h >@@ -85,6 +85,7 @@ public: > WEBCORE_EXPORT long copy(const String& fromPasteboard); > WEBCORE_EXPORT long setBufferForType(SharedBuffer*, const String& pasteboardType); > WEBCORE_EXPORT long setURL(const PasteboardURL&); >+ WEBCORE_EXPORT long setColor(const Color&); > WEBCORE_EXPORT long setStringForType(const String&, const String& pasteboardType); > WEBCORE_EXPORT void write(const PasteboardWebContent&); > WEBCORE_EXPORT void write(const PasteboardImage&); >diff --git a/Source/WebCore/platform/gtk/DragImageGtk.cpp b/Source/WebCore/platform/gtk/DragImageGtk.cpp >index d41a4e569235f4d822ae82cb8b8785916ddd9376..33f4fe3a42f05f2d6b93db0fada87843e9b70268 100644 >--- a/Source/WebCore/platform/gtk/DragImageGtk.cpp >+++ b/Source/WebCore/platform/gtk/DragImageGtk.cpp >@@ -97,4 +97,9 @@ DragImageRef createDragImageForLink(Element&, URL&, const String&, TextIndicator > return nullptr; > } > >+DragImageRef createDragImageForColor(const Color&, const FloatRect&, float, Path&) >+{ >+ return nullptr; >+} >+ > } >diff --git a/Source/WebCore/platform/gtk/PasteboardGtk.cpp b/Source/WebCore/platform/gtk/PasteboardGtk.cpp >index d5baa1c9b6fe507dd1288de74b18b52508cfb983..a4ab610a73ff1ac91490ddc2008c488d42c900f0 100644 >--- a/Source/WebCore/platform/gtk/PasteboardGtk.cpp >+++ b/Source/WebCore/platform/gtk/PasteboardGtk.cpp >@@ -20,6 +20,7 @@ > #include "config.h" > #include "Pasteboard.h" > >+#include "Color.h" > #include "DragData.h" > #include "Image.h" > #include "NotImplemented.h" >@@ -332,4 +333,8 @@ void Pasteboard::writeCustomData(const PasteboardCustomData&) > { > } > >+void Pasteboard::write(const Color&) >+{ >+} >+ > } >diff --git a/Source/WebCore/platform/ios/DragImageIOS.mm b/Source/WebCore/platform/ios/DragImageIOS.mm >index a7996fd0db1d22de68794c4ac3c8f9cbe24020b5..0ff850ccea0948d7e3417e64634717bd168e3c92 100644 >--- a/Source/WebCore/platform/ios/DragImageIOS.mm >+++ b/Source/WebCore/platform/ios/DragImageIOS.mm >@@ -251,6 +251,22 @@ DragImageRef createDragImageForRange(Frame& frame, Range& range, bool forceBlack > return finalImage.CGImage; > } > >+DragImageRef createDragImageForColor(const Color& color, const FloatRect& elementRect, float pageScaleFactor, Path& visiblePath) >+{ >+ FloatRect imageRect(0, 0, elementRect.width() * pageScaleFactor, elementRect.height() * pageScaleFactor); >+ >+ RetainPtr<UIGraphicsImageRenderer> render = adoptNS([allocUIGraphicsImageRendererInstance() initWithSize:imageRect.size()]); >+ UIImage *image = [render.get() imageWithActions:^(UIGraphicsImageRendererContext *rendererContext) { >+ GraphicsContext context(rendererContext.CGContext); >+ context.translate(0, CGRectGetHeight(imageRect)); >+ context.scale({ 1, -1 }); >+ context.fillRoundedRect(FloatRoundedRect(imageRect, FloatRoundedRect::Radii(4 * pageScaleFactor)), color); >+ }]; >+ >+ visiblePath.addRoundedRect(FloatRoundedRect(imageRect, FloatRoundedRect::Radii(4 * pageScaleFactor))); >+ return image.CGImage; >+} >+ > #else > > void deleteDragImage(RetainPtr<CGImageRef>) >diff --git a/Source/WebCore/platform/ios/PasteboardIOS.mm b/Source/WebCore/platform/ios/PasteboardIOS.mm >index d26c5848efeba5363f10d3c338f9acc09e3d577c..98f112e162cd1580f21e515ea7db32bfb39cff23 100644 >--- a/Source/WebCore/platform/ios/PasteboardIOS.mm >+++ b/Source/WebCore/platform/ios/PasteboardIOS.mm >@@ -83,6 +83,7 @@ static long changeCountForPasteboard(const String& pasteboardName = { }) > > // FIXME: Does this need to be declared in the header file? > WEBCORE_EXPORT NSString *WebArchivePboardType = @"Apple Web Archive pasteboard type"; >+NSString *UIColorPboardType = @"com.apple.uikit.color"; > > Pasteboard::Pasteboard() > : m_changeCount(0) >@@ -139,6 +140,11 @@ void Pasteboard::writeTrustworthyWebURLsPboardType(const PasteboardURL&) > ASSERT_NOT_REACHED(); > } > >+void Pasteboard::write(const Color& color) >+{ >+ platformStrategies()->pasteboardStrategy()->setColor(color, m_pasteboardName); >+} >+ > bool Pasteboard::canSmartReplace() > { > return false; >diff --git a/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm b/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm >index a5ca0372f4583900c2674e32f8ee4a68d2d5aa94..f1fea077afab4abb5d5f2377f9684ff21effd178 100644 >--- a/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm >+++ b/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm >@@ -37,6 +37,7 @@ > #import "WebCoreNSURLExtras.h" > #import "WebItemProviderPasteboard.h" > #import <MobileCoreServices/MobileCoreServices.h> >+#import <UIKit/UIColor.h> > #import <UIKit/UIImage.h> > #import <UIKit/UIPasteboard.h> > #import <pal/spi/cocoa/NSKeyedArchiverSPI.h> >@@ -49,6 +50,7 @@ > #define NSURL_SUPPORTS_TITLE (!PLATFORM(IOSMAC)) > > SOFT_LINK_FRAMEWORK(UIKit) >+SOFT_LINK_CLASS(UIKit, UIColor) > SOFT_LINK_CLASS(UIKit, UIImage) > SOFT_LINK_CLASS(UIKit, UIPasteboard) > >@@ -221,7 +223,9 @@ String PlatformPasteboard::stringForType(const String& type) const > > Color PlatformPasteboard::color() > { >- return Color(); >+ NSData *data = [m_pasteboard dataForPasteboardType:UIColorPboardType]; >+ UIColor *uiColor = [NSKeyedUnarchiver unarchivedObjectOfClass:getUIColorClass() fromData:data error:nil]; >+ return Color(uiColor.CGColor); > } > > URL PlatformPasteboard::url() >@@ -308,6 +312,15 @@ static void registerItemToPasteboard(WebItemProviderRegistrationInfoList *repres > > } > >+long PlatformPasteboard::setColor(const Color& color) >+{ >+ auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]); >+ UIColor *uiColor = [getUIColorClass() colorWithCGColor:cachedCGColor(color)]; >+ [representationsToRegister addData:[NSKeyedArchiver archivedDataWithRootObject:uiColor requiringSecureCoding:NO error:nil] forType:UIColorPboardType]; >+ registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get()); >+ return 0; >+} >+ > static void addRepresentationsForPlainText(WebItemProviderRegistrationInfoList *itemsToRegister, const String& plainText) > { > if (plainText.isEmpty()) >diff --git a/Source/WebCore/platform/mac/DragDataMac.mm b/Source/WebCore/platform/mac/DragDataMac.mm >index 76545e23a7acfcd66797ee1d76d9018eb3fb1351..5fc757e0bf65048ec7630bd06f64004510a70cff 100644 >--- a/Source/WebCore/platform/mac/DragDataMac.mm >+++ b/Source/WebCore/platform/mac/DragDataMac.mm >@@ -91,7 +91,7 @@ static inline String htmlPasteboardType() > static inline String colorPasteboardType() > { > #if PLATFORM(IOS) >- return "com.apple.uikit.color"; >+ return String(UIColorPboardType); > #else > return String(legacyColorPasteboardType()); > #endif >@@ -226,6 +226,9 @@ bool DragData::containsCompatibleContent(DraggingPurpose purpose) const > if (purpose == DraggingPurpose::ForFileUpload) > return containsFiles(); > >+ if (purpose == DraggingPurpose::ForColorControl) >+ return containsColor(); >+ > if (purpose == DraggingPurpose::ForEditing && RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled() && containsFiles()) > return true; > >diff --git a/Source/WebCore/platform/mac/DragImageMac.mm b/Source/WebCore/platform/mac/DragImageMac.mm >index 31b32a130baadcbdd2ab470f243830d980fe3a90..0ce5a1142a0e25635fd61adc5ac95399d7b434cc 100644 >--- a/Source/WebCore/platform/mac/DragImageMac.mm >+++ b/Source/WebCore/platform/mac/DragImageMac.mm >@@ -336,6 +336,30 @@ DragImageRef createDragImageForLink(Element& element, URL& url, const String& ti > > return dragImage; > } >+ >+const CGFloat swatchWidth = 24; >+const CGFloat swatchCornerRadius = 4; >+const CGFloat swatchStrokeSize = 4; >+ >+DragImageRef createDragImageForColor(const Color& color, const FloatRect&, float, Path&) >+{ >+ RetainPtr<NSImage> dragImage = adoptNS([[NSImage alloc] initWithSize:NSMakeSize(swatchWidth, swatchWidth)]); >+ >+ [dragImage lockFocus]; >+ >+ NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0, 0, swatchWidth, swatchWidth) xRadius:swatchCornerRadius yRadius:swatchCornerRadius]; >+ [path setLineWidth:swatchStrokeSize]; >+ >+ [nsColor(color) setFill]; >+ [path fill]; >+ >+ [[NSColor quaternaryLabelColor] setStroke]; >+ [path stroke]; >+ >+ [dragImage unlockFocus]; >+ >+ return dragImage; >+} > > } // namespace WebCore > >diff --git a/Source/WebCore/platform/mac/PasteboardMac.mm b/Source/WebCore/platform/mac/PasteboardMac.mm >index 0130bfde2e43710b3163dab09834e22ba0dc63d7..ae1c58806fac419f177b3af4601817fc9412d5fb 100644 >--- a/Source/WebCore/platform/mac/PasteboardMac.mm >+++ b/Source/WebCore/platform/mac/PasteboardMac.mm >@@ -223,6 +223,14 @@ void Pasteboard::writeTrustworthyWebURLsPboardType(const PasteboardURL& pasteboa > m_changeCount = platformStrategies()->pasteboardStrategy()->setURL(url, m_pasteboardName); > } > >+void Pasteboard::write(const Color& color) >+{ >+ Vector<String> types; >+ types.append(legacyColorPasteboardType()); >+ platformStrategies()->pasteboardStrategy()->setTypes(types, m_pasteboardName); >+ m_changeCount = platformStrategies()->pasteboardStrategy()->setColor(color, m_pasteboardName); >+} >+ > static NSFileWrapper* fileWrapper(const PasteboardImage& pasteboardImage) > { > NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:pasteboardImage.resourceData->createNSData().get()] autorelease]; >diff --git a/Source/WebCore/platform/mac/PlatformPasteboardMac.mm b/Source/WebCore/platform/mac/PlatformPasteboardMac.mm >index 535ce4e309b7cd3454df8a34192c7be97d78b55e..a1925badc93b6c71931ec9549d8cd72e622d1d7e 100644 >--- a/Source/WebCore/platform/mac/PlatformPasteboardMac.mm >+++ b/Source/WebCore/platform/mac/PlatformPasteboardMac.mm >@@ -274,6 +274,13 @@ long PlatformPasteboard::setURL(const PasteboardURL& pasteboardURL) > return changeCount(); > } > >+long PlatformPasteboard::setColor(const Color& color) >+{ >+ NSColor *pasteboardColor = nsColor(color); >+ [pasteboardColor writeToPasteboard:m_pasteboard.get()]; >+ return changeCount(); >+} >+ > long PlatformPasteboard::setStringForType(const String& string, const String& pasteboardType) > { > BOOL didWriteData; >diff --git a/Source/WebCore/platform/win/PasteboardWin.cpp b/Source/WebCore/platform/win/PasteboardWin.cpp >index 0c5e173cbcaf34ed9893e59b16cabbed4df25aea..66abe451e372d524b1cc1330cf00d9d84cba1a5f 100644 >--- a/Source/WebCore/platform/win/PasteboardWin.cpp >+++ b/Source/WebCore/platform/win/PasteboardWin.cpp >@@ -30,6 +30,7 @@ > #include "BitmapInfo.h" > #include "CachedImage.h" > #include "ClipboardUtilitiesWin.h" >+#include "Color.h" > #include "Document.h" > #include "DocumentFragment.h" > #include "Editor.h" >@@ -1085,4 +1086,8 @@ void Pasteboard::writeCustomData(const PasteboardCustomData&) > { > } > >+void Pasteboard::write(const Color&) >+{ >+} >+ > } // namespace WebCore >diff --git a/Source/WebKit/Configurations/FeatureDefines.xcconfig b/Source/WebKit/Configurations/FeatureDefines.xcconfig >index 41a336c75084648f7bfc607ba82245ab25568170..df6eb2b406f055acf5bbe4bcd1ebda5a5d2c22da 100644 >--- a/Source/WebKit/Configurations/FeatureDefines.xcconfig >+++ b/Source/WebKit/Configurations/FeatureDefines.xcconfig >@@ -167,9 +167,9 @@ ENABLE_INDEXED_DATABASE = ENABLE_INDEXED_DATABASE; > > ENABLE_INDEXED_DATABASE_IN_WORKERS = ENABLE_INDEXED_DATABASE_IN_WORKERS; > >-ENABLE_INPUT_TYPE_COLOR = ; >+ENABLE_INPUT_TYPE_COLOR = ENABLE_INPUT_TYPE_COLOR; > >-ENABLE_INPUT_TYPE_COLOR_POPOVER = ; >+ENABLE_INPUT_TYPE_COLOR_POPOVER = ENABLE_INPUT_TYPE_COLOR_POPOVER; > > ENABLE_INPUT_TYPE_DATETIMELOCAL = $(ENABLE_INPUT_TYPE_DATETIMELOCAL_$(WK_COCOA_TOUCH)); > ENABLE_INPUT_TYPE_DATETIMELOCAL_cocoatouch = ENABLE_INPUT_TYPE_DATETIMELOCAL; >diff --git a/Source/WebKit/Shared/WebCoreArgumentCoders.cpp b/Source/WebKit/Shared/WebCoreArgumentCoders.cpp >index 92d324ca7a9e2c62bbbe9c44eb329d68af0c411e..baa2fcf03e9ab2c9cff6a8adb9ff330bb03d896e 100644 >--- a/Source/WebKit/Shared/WebCoreArgumentCoders.cpp >+++ b/Source/WebKit/Shared/WebCoreArgumentCoders.cpp >@@ -852,6 +852,15 @@ bool ArgumentCoder<Path>::decode(Decoder& decoder, Path& path) > return true; > } > >+std::optional<Path> ArgumentCoder<Path>::decode(Decoder& decoder) >+{ >+ Path path; >+ if (!decode(decoder, path)) >+ return std::nullopt; >+ >+ return path; >+} >+ > void ArgumentCoder<RecentSearch>::encode(Encoder& encoder, const RecentSearch& recentSearch) > { > encoder << recentSearch.string << recentSearch.time; >diff --git a/Source/WebKit/Shared/WebCoreArgumentCoders.h b/Source/WebKit/Shared/WebCoreArgumentCoders.h >index 3a5cc681c1f29717d784aa4d1047e0883f8fb8cc..f2afcad596033940f1b49ad0623a089a8c539a75 100644 >--- a/Source/WebKit/Shared/WebCoreArgumentCoders.h >+++ b/Source/WebKit/Shared/WebCoreArgumentCoders.h >@@ -306,6 +306,7 @@ template<> struct ArgumentCoder<WebCore::LayoutPoint> { > template<> struct ArgumentCoder<WebCore::Path> { > static void encode(Encoder&, const WebCore::Path&); > static bool decode(Decoder&, WebCore::Path&); >+ static std::optional<WebCore::Path> decode(Decoder&); > }; > > template<> struct ArgumentCoder<WebCore::Region> { >diff --git a/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm b/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm >index 5dbdab8ca5cc46b28ed1540d0af42231d99e3fac..8f5a2f9f35a3fa00079c86be21dd6a2d92d8f7a4 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm >+++ b/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm >@@ -138,6 +138,11 @@ void WebPasteboardProxy::setPasteboardURL(IPC::Connection& connection, const Pas > newChangeCount = 0; > } > >+void WebPasteboardProxy::setPasteboardColor(const String& pasteboardName, const WebCore::Color& color, uint64_t& newChangeCount) >+{ >+ newChangeCount = PlatformPasteboard(pasteboardName).setColor(color); >+} >+ > void WebPasteboardProxy::setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String& string, uint64_t& newChangeCount) > { > newChangeCount = PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType); >diff --git a/Source/WebKit/UIProcess/WebPasteboardProxy.h b/Source/WebKit/UIProcess/WebPasteboardProxy.h >index 257ea3dc15f1890af150a189d5369b56803b7b43..58bdfed57d44e705326ff6c3a68b8f24478f2254 100644 >--- a/Source/WebKit/UIProcess/WebPasteboardProxy.h >+++ b/Source/WebKit/UIProcess/WebPasteboardProxy.h >@@ -96,6 +96,7 @@ private: > void addPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount); > void setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes, uint64_t& newChangeCount); > void setPasteboardURL(IPC::Connection&, const WebCore::PasteboardURL&, const String& pasteboardName, uint64_t& newChangeCount); >+ void setPasteboardColor(const String&, const WebCore::Color&, uint64_t&); > void setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String&, uint64_t& newChangeCount); > void setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, uint64_t& newChangeCount); > #endif >diff --git a/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in b/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in >index 50866872e0293ab7a25ee5694fba7d6ff61d4454..21749f97f6c94c98d5f09436024779fc0f81929e 100644 >--- a/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in >+++ b/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in >@@ -54,6 +54,7 @@ messages -> WebPasteboardProxy { > AddPasteboardTypes(String pasteboardName, Vector<String> pasteboardTypes) -> (uint64_t changeCount) > SetPasteboardTypes(String pasteboardName, Vector<String> pasteboardTypes) -> (uint64_t changeCount) > SetPasteboardURL(struct WebCore::PasteboardURL pasteboardURL, String pasteboardName) -> (uint64_t changeCount) WantsConnection >+ SetPasteboardColor(String pasteboardName, WebCore::Color color) -> (uint64_t changeCount) > SetPasteboardStringForType(String pasteboardName, String pasteboardType, String string) -> (uint64_t changeCount) > SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) -> (uint64_t changeCount) > #endif >diff --git a/Source/WebKit/UIProcess/ios/DragDropInteractionState.h b/Source/WebKit/UIProcess/ios/DragDropInteractionState.h >index 3b784f75ae69f9c60796adfad8fdc1aa78b1989b..799263eac4a2c2882464d9efaea46a843149da5f 100644 >--- a/Source/WebKit/UIProcess/ios/DragDropInteractionState.h >+++ b/Source/WebKit/UIProcess/ios/DragDropInteractionState.h >@@ -30,6 +30,7 @@ > #import "UIKitSPI.h" > #import <WebCore/DragActions.h> > #import <WebCore/DragData.h> >+#import <WebCore/Path.h> > #import <WebCore/TextIndicator.h> > #import <WebCore/URL.h> > #import <WebCore/WebItemProviderPasteboard.h> >@@ -49,6 +50,7 @@ struct DragSourceState { > CGRect dragPreviewFrameInRootViewCoordinates { CGRectZero }; > RetainPtr<UIImage> image; > std::optional<WebCore::TextIndicatorData> indicatorData; >+ std::optional<WebCore::Path> visiblePath; > String linkTitle; > WebCore::URL linkURL; > bool possiblyNeedsDragPreviewUpdate { true }; >diff --git a/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm b/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm >index 64c8f06dadfe11621b7134ae709b012ecef9efce..755993cb15817e1651b34c9cdf332472646754c8 100644 >--- a/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm >+++ b/Source/WebKit/UIProcess/ios/DragDropInteractionState.mm >@@ -46,7 +46,7 @@ static UIDragItem *dragItemMatchingIdentifier(id <UIDragSession> session, NSInte > return nil; > } > >-static UITargetedDragPreview *createTargetedDragPreview(UIImage *image, UIView *rootView, UIView *previewContainer, const FloatRect& frameInRootViewCoordinates, const Vector<FloatRect>& clippingRectsInFrameCoordinates, UIColor *backgroundColor) >+static UITargetedDragPreview *createTargetedDragPreview(UIImage *image, UIView *rootView, UIView *previewContainer, const FloatRect& frameInRootViewCoordinates, const Vector<FloatRect>& clippingRectsInFrameCoordinates, UIColor *backgroundColor, UIBezierPath *visiblePath) > { > if (frameInRootViewCoordinates.isEmpty() || !image) > return nullptr; >@@ -75,6 +75,9 @@ static UITargetedDragPreview *createTargetedDragPreview(UIImage *image, UIView * > if (backgroundColor) > [parameters setBackgroundColor:backgroundColor]; > >+ if (visiblePath) >+ [parameters setVisiblePath:visiblePath]; >+ > CGPoint centerInContainerCoordinates = { CGRectGetMidX(frameInContainerCoordinates), CGRectGetMidY(frameInContainerCoordinates) }; > auto target = adoptNS([[UIDragPreviewTarget alloc] initWithContainer:previewContainer center:centerInContainerCoordinates]); > auto dragPreview = adoptNS([[UITargetedDragPreview alloc] initWithView:imageView.get() parameters:parameters.get() target:target.get()]); >@@ -98,9 +101,27 @@ static bool shouldUseDragImageToCreatePreviewForDragSource(const DragSourceState > if (!source.image) > return false; > >+#if ENABLE(INPUT_TYPE_COLOR) >+ if (source.action & DragSourceActionColor) >+ return true; >+#endif >+ > return source.action & (DragSourceActionDHTML | DragSourceActionImage); > } > >+static bool shouldUseVisiblePathToCreatePreviewForDragSource(const DragSourceState& source) >+{ >+ if (!source.visiblePath) >+ return false; >+ >+#if ENABLE(INPUT_TYPE_COLOR) >+ if (source.action & DragSourceActionColor) >+ return true; >+#endif >+ >+ return false; >+} >+ > static bool shouldUseTextIndicatorToCreatePreviewForDragSource(const DragSourceState& source) > { > if (!source.indicatorData) >@@ -117,6 +138,22 @@ static bool shouldUseTextIndicatorToCreatePreviewForDragSource(const DragSourceS > return false; > } > >+static bool canUpdatePreviewForActiveDragSource(const DragSourceState& source) >+{ >+ if (!source.possiblyNeedsDragPreviewUpdate) >+ return false; >+ >+#if ENABLE(INPUT_TYPE_COLOR) >+ if (source.action & DragSourceActionColor) >+ return true; >+#endif >+ >+ if (source.action & DragSourceActionLink || !(source.action & DragSourceActionImage)) >+ return true; >+ >+ return false; >+} >+ > std::optional<DragSourceState> DragDropInteractionState::activeDragSourceForItem(UIDragItem *item) const > { > if (![item.privateLocalContext isKindOfClass:[NSNumber class]]) >@@ -158,13 +195,19 @@ UITargetedDragPreview *DragDropInteractionState::previewForDragItem(UIDragItem * > return nil; > > auto& source = foundSource.value(); >- if (shouldUseDragImageToCreatePreviewForDragSource(source)) >- return createTargetedDragPreview(source.image.get(), contentView, previewContainer, source.dragPreviewFrameInRootViewCoordinates, { }, nil); >+ if (shouldUseDragImageToCreatePreviewForDragSource(source)) { >+ if (shouldUseVisiblePathToCreatePreviewForDragSource(source)) { >+ auto path = source.visiblePath.value(); >+ UIBezierPath *visiblePath = [UIBezierPath bezierPathWithCGPath:path.ensurePlatformPath()]; >+ return createTargetedDragPreview(source.image.get(), contentView, previewContainer, source.dragPreviewFrameInRootViewCoordinates, { }, nil, visiblePath); >+ } >+ return createTargetedDragPreview(source.image.get(), contentView, previewContainer, source.dragPreviewFrameInRootViewCoordinates, { }, nil, nil); >+ } > > if (shouldUseTextIndicatorToCreatePreviewForDragSource(source)) { > auto indicator = source.indicatorData.value(); > auto textIndicatorImage = uiImageForImage(indicator.contentImage.get()); >- return createTargetedDragPreview(textIndicatorImage.get(), contentView, previewContainer, indicator.textBoundingRectInRootViewCoordinates, indicator.textRectsInBoundingRectCoordinates, [UIColor colorWithCGColor:cachedCGColor(indicator.estimatedBackgroundColor)]); >+ return createTargetedDragPreview(textIndicatorImage.get(), contentView, previewContainer, indicator.textBoundingRectInRootViewCoordinates, indicator.textRectsInBoundingRectCoordinates, [UIColor colorWithCGColor:cachedCGColor(indicator.estimatedBackgroundColor)], nil); > } > > return nil; >@@ -203,6 +246,7 @@ void DragDropInteractionState::stageDragItem(const DragItem& item, UIImage *drag > item.dragPreviewFrameInRootViewCoordinates, > dragImage, > item.image.indicatorData(), >+ item.image.visiblePath(), > item.title.isEmpty() ? nil : (NSString *)item.title, > item.url.isEmpty() ? nil : (NSURL *)item.url, > true, // We assume here that drag previews need to be updated until proven otherwise in updatePreviewsForActiveDragSources(). >@@ -239,29 +283,34 @@ void DragDropInteractionState::dragAndDropSessionsDidEnd() > void DragDropInteractionState::updatePreviewsForActiveDragSources() > { > for (auto& source : m_activeDragSources) { >- if (!source.possiblyNeedsDragPreviewUpdate) >- continue; >- >- if (source.action & DragSourceActionImage || !(source.action & DragSourceActionLink)) { >- // Currently, non-image links are the only type of source for which we need to update >- // drag preview providers after the initial lift. All other dragged content should maintain >- // the same targeted drag preview used during the lift animation. >+ if (!canUpdatePreviewForActiveDragSource(source)) > continue; >- } > > UIDragItem *dragItem = dragItemMatchingIdentifier(m_dragSession.get(), source.itemIdentifier); > if (!dragItem) > continue; > >- auto linkDraggingCenter = source.adjustedOrigin; >- RetainPtr<NSString> title = (NSString *)source.linkTitle; >- RetainPtr<NSURL> url = (NSURL *)source.linkURL; >- dragItem.previewProvider = [title, url, linkDraggingCenter] () -> UIDragPreview * { >- UIURLDragPreviewView *previewView = [UIURLDragPreviewView viewWithTitle:title.get() URL:url.get()]; >- previewView.center = linkDraggingCenter; >- UIDragPreviewParameters *parameters = [[[UIDragPreviewParameters alloc] initWithTextLineRects:@[ [NSValue valueWithCGRect:previewView.bounds] ]] autorelease]; >- return [[[UIDragPreview alloc] initWithView:previewView parameters:parameters] autorelease]; >- }; >+ if (source.action & DragSourceActionLink) { >+ auto draggingCenter = source.adjustedOrigin; >+ RetainPtr<NSString> title = (NSString *)source.linkTitle; >+ RetainPtr<NSURL> url = (NSURL *)source.linkURL; >+ dragItem.previewProvider = [title, url, draggingCenter] () -> UIDragPreview * { >+ UIURLDragPreviewView *previewView = [UIURLDragPreviewView viewWithTitle:title.get() URL:url.get()]; >+ previewView.center = draggingCenter; >+ UIDragPreviewParameters *parameters = [[[UIDragPreviewParameters alloc] initWithTextLineRects:@[ [NSValue valueWithCGRect:previewView.bounds] ]] autorelease]; >+ return [[[UIDragPreview alloc] initWithView:previewView parameters:parameters] autorelease]; >+ }; >+ } >+#if ENABLE(INPUT_TYPE_COLOR) >+ else if (source.action & DragSourceActionColor) { >+ RetainPtr<UIImage> image = source.image; >+ dragItem.previewProvider = [image] () -> UIDragPreview * { >+ UIImageView *imageView = [[[UIImageView alloc] initWithImage:image.get()] autorelease]; >+ UIDragPreviewParameters *parameters = [[[UIDragPreviewParameters alloc] initWithTextLineRects:@[[NSValue valueWithCGRect:[imageView bounds]]]] autorelease]; >+ return [[[UIDragPreview alloc] initWithView:imageView parameters:parameters] autorelease]; >+ }; >+ } >+#endif > > source.possiblyNeedsDragPreviewUpdate = false; > } >diff --git a/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm b/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm >index f3af8b62da5720f59b5fe4035510b90aa4803958..53fc009b5d4b7fa6e88fc13b656022567f076ed0 100644 >--- a/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm >+++ b/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm >@@ -180,7 +180,7 @@ using namespace WebKit; > colorPickerSize = CGSizeMake(keyboardSize.width, keyboardSize.height + additionalKeyboardAffordance); > } > >- _colorPicker = adoptNS([[UIView alloc] initWithSize:colorPickerSize]); >+ _colorPicker = adoptNS([[UIView alloc] initWithFrame:CGRectMake(0, 0, colorPickerSize.width, colorPickerSize.height)]); > > CGFloat totalRows = [[getPKColorMatrixViewClass() defaultColorMatrix] count] + 1; > CGFloat swatchHeight = (colorPickerSize.height - topColorMatrixPadding) / totalRows; >diff --git a/Source/WebKit/UIProcess/mac/WebColorPickerMac.h b/Source/WebKit/UIProcess/mac/WebColorPickerMac.h >index ae5e7b9fa62e33dc8f76e418adb1f3b572072d68..54af0637e60fcffed6ef3f11ee41c8982996f71e 100644 >--- a/Source/WebKit/UIProcess/mac/WebColorPickerMac.h >+++ b/Source/WebKit/UIProcess/mac/WebColorPickerMac.h >@@ -38,6 +38,7 @@ > #import "WebColorPicker.h" > #import <WebCore/IntRect.h> > #include <wtf/RetainPtr.h> >+#include <wtf/Vector.h> > > namespace WebCore { > class Color; >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp >index ae7388f9a49c30fcc6c86c851fa065821733bf50..9a11fa28e968e4550c9c45f3811cdca226f1baa7 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp >@@ -274,6 +274,13 @@ long WebPlatformStrategies::setURL(const PasteboardURL& pasteboardURL, const Str > return newChangeCount; > } > >+long WebPlatformStrategies::setColor(const Color& color, const String& pasteboardName) >+{ >+ uint64_t newChangeCount; >+ WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardColor(pasteboardName, color), Messages::WebPasteboardProxy::SetPasteboardColor::Reply(newChangeCount), 0); >+ return newChangeCount; >+} >+ > long WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName) > { > uint64_t newChangeCount { 0 }; >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h b/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h >index b59842b4e4ebc859d3f786c6d3e68ee56de34467..b88fcab576be4ee9a09343f2bee1f67b15e2a28e 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h >@@ -85,6 +85,7 @@ private: > long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override; > long setBufferForType(WebCore::SharedBuffer*, const String& pasteboardType, const String& pasteboardName) override; > long setURL(const WebCore::PasteboardURL&, const String& pasteboardName) override; >+ long setColor(const WebCore::Color&, const String& pasteboardName) override; > long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) override; > #endif > #if PLATFORM(GTK) >diff --git a/Source/WebKitLegacy/mac/Configurations/FeatureDefines.xcconfig b/Source/WebKitLegacy/mac/Configurations/FeatureDefines.xcconfig >index 41a336c75084648f7bfc607ba82245ab25568170..df6eb2b406f055acf5bbe4bcd1ebda5a5d2c22da 100644 >--- a/Source/WebKitLegacy/mac/Configurations/FeatureDefines.xcconfig >+++ b/Source/WebKitLegacy/mac/Configurations/FeatureDefines.xcconfig >@@ -167,9 +167,9 @@ ENABLE_INDEXED_DATABASE = ENABLE_INDEXED_DATABASE; > > ENABLE_INDEXED_DATABASE_IN_WORKERS = ENABLE_INDEXED_DATABASE_IN_WORKERS; > >-ENABLE_INPUT_TYPE_COLOR = ; >+ENABLE_INPUT_TYPE_COLOR = ENABLE_INPUT_TYPE_COLOR; > >-ENABLE_INPUT_TYPE_COLOR_POPOVER = ; >+ENABLE_INPUT_TYPE_COLOR_POPOVER = ENABLE_INPUT_TYPE_COLOR_POPOVER; > > ENABLE_INPUT_TYPE_DATETIMELOCAL = $(ENABLE_INPUT_TYPE_DATETIMELOCAL_$(WK_COCOA_TOUCH)); > ENABLE_INPUT_TYPE_DATETIMELOCAL_cocoatouch = ENABLE_INPUT_TYPE_DATETIMELOCAL; >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h b/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h >index 565c3f4273dcb85f2e0a9bd5245d068d90ff36ac..debb0332b12cad54e7409c7a6064fd59e7d80be0 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h >@@ -88,6 +88,7 @@ private: > long setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) override; > long setBufferForType(WebCore::SharedBuffer*, const String& pasteboardType, const String& pasteboardName) override; > long setURL(const WebCore::PasteboardURL&, const String& pasteboardName) override; >+ long setColor(const WebCore::Color&, const String& pasteboardName) override; > long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) override; > }; > >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm b/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm >index b53188ebfcdf5a74133185198ec3d24fe39ad855..0b16dcd0925dcc441df88e7ed6432a6e435839af 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm >@@ -168,6 +168,11 @@ long WebPlatformStrategies::setURL(const PasteboardURL& pasteboardURL, const Str > return PlatformPasteboard(pasteboardName).setURL(pasteboardURL); > } > >+long WebPlatformStrategies::setColor(const Color& color, const String& pasteboardName) >+{ >+ return PlatformPasteboard(pasteboardName).setColor(color); >+} >+ > long WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName) > { > return PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 2d6fbb37e61e32dcf47f7e6d87092a4f2582feee..67d14b9f50a0b7603076082bd0429ddef98dfaab 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,26 @@ >+2018-08-10 Aditya Keerthi <akeerthi@apple.com> >+ >+ Support drag-and-drop for input[type=color] >+ https://bugs.webkit.org/show_bug.cgi?id=188464 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added an API test for macOS and iOS. >+ >+ For macOS, added a test to verify that dropping an item with NSColorPboardType >+ changes the value of the color input. >+ >+ For iOS, added a test to verify that dragging from one color input to another >+ results in the color of the drop target changing to the color of the dragged >+ input. >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WebKitCocoa/color-drop.html: Added. >+ * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm: >+ (TestWebKitAPI::TEST): >+ * TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm: >+ (TestWebKitAPI::TEST): >+ > 2018-08-09 Ben Richards <benton_richards@apple.com> > > We should cache the compiled sandbox profile in a data vault >diff --git a/Tools/TestWebKitAPI/Configurations/FeatureDefines.xcconfig b/Tools/TestWebKitAPI/Configurations/FeatureDefines.xcconfig >index 41a336c75084648f7bfc607ba82245ab25568170..df6eb2b406f055acf5bbe4bcd1ebda5a5d2c22da 100644 >--- a/Tools/TestWebKitAPI/Configurations/FeatureDefines.xcconfig >+++ b/Tools/TestWebKitAPI/Configurations/FeatureDefines.xcconfig >@@ -167,9 +167,9 @@ ENABLE_INDEXED_DATABASE = ENABLE_INDEXED_DATABASE; > > ENABLE_INDEXED_DATABASE_IN_WORKERS = ENABLE_INDEXED_DATABASE_IN_WORKERS; > >-ENABLE_INPUT_TYPE_COLOR = ; >+ENABLE_INPUT_TYPE_COLOR = ENABLE_INPUT_TYPE_COLOR; > >-ENABLE_INPUT_TYPE_COLOR_POPOVER = ; >+ENABLE_INPUT_TYPE_COLOR_POPOVER = ENABLE_INPUT_TYPE_COLOR_POPOVER; > > ENABLE_INPUT_TYPE_DATETIMELOCAL = $(ENABLE_INPUT_TYPE_DATETIMELOCAL_$(WK_COCOA_TOUCH)); > ENABLE_INPUT_TYPE_DATETIMELOCAL_cocoatouch = ENABLE_INPUT_TYPE_DATETIMELOCAL; >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 198eb7d7de7c4751be0f7ef66a09179f48b4e5dc..1a84c59b72b301d39730c4f95de33b45f37a2d7e 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -774,6 +774,7 @@ > E373D7911F2CF35200C6FAAF /* Signals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3953F951F2CF32100A76A2E /* Signals.cpp */; }; > E38A0D351FD50CC300E98C8B /* Threading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38A0D341FD50CBC00E98C8B /* Threading.cpp */; }; > E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */; }; >+ E5036F78211BC25400BFDBE2 /* color-drop.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E5036F77211BC22800BFDBE2 /* color-drop.html */; }; > ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = ECA680CD1E68CC0900731D20 /* StringUtilities.mm */; }; > F407FE391F1D0DFC0017CF25 /* enormous.svg in Copy Resources */ = {isa = PBXBuildFile; fileRef = F407FE381F1D0DE60017CF25 /* enormous.svg */; }; > F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F415086C1DA040C10044BE9B /* play-audio-on-click.html */; }; >@@ -921,9 +922,6 @@ > dstPath = TestWebKitAPI.resources; > dstSubfolderSpec = 7; > files = ( >- CD57779C211CE91F001B371E /* audio-with-web-audio.html in Copy Resources */, >- CD57779D211CE91F001B371E /* video-with-audio-and-web-audio.html in Copy Resources */, >- CD577799211CE0E4001B371E /* web-audio-only.html in Copy Resources */, > 1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */, > 379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */, > 1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */, >@@ -940,6 +938,7 @@ > 7C9ED98B17A19F4B00E4DC33 /* attributedStringStrikethrough.html in Copy Resources */, > 37137E4B21124D01002BEEA4 /* AttrStyle.html in Copy Resources */, > CD9E292E1C90C33F000BB800 /* audio-only.html in Copy Resources */, >+ CD57779C211CE91F001B371E /* audio-with-web-audio.html in Copy Resources */, > 76E182DF154767E600F1FADD /* auto-submitting-form.html in Copy Resources */, > F41AB99F1EF4696B0083FA08 /* autofocus-contenteditable.html in Copy Resources */, > 93CFA8671CEB9E38000565A8 /* autofocused-text-input.html in Copy Resources */, >@@ -961,6 +960,7 @@ > 9BD4239C1E04C01C00200395 /* chinese-character-with-image.html in Copy Resources */, > 1A50AA201A2A51FC00F4C345 /* close-from-within-create-page.html in Copy Resources */, > 9B270FEE1DDC2C0B002D53F3 /* closed-shadow-tree-test.html in Copy Resources */, >+ E5036F78211BC25400BFDBE2 /* color-drop.html in Copy Resources */, > F4B825D81EF4DBFB006E417F /* compressed-files.zip in Copy Resources */, > 5C9E56871DF914AE00C9EE33 /* contentBlockerCheck.html in Copy Resources */, > F469FB241F01804B00401539 /* contenteditable-and-target.html in Copy Resources */, >@@ -1172,6 +1172,7 @@ > F41AB9AA1EF4696B0083FA08 /* textarea-to-input.html in Copy Resources */, > F4451C761EB8FD890020C5DA /* two-paragraph-contenteditable.html in Copy Resources */, > C540F784152E5A9A00A40C8C /* verboseMarkup.html in Copy Resources */, >+ CD57779D211CE91F001B371E /* video-with-audio-and-web-audio.html in Copy Resources */, > CDC8E4941BC6F10800594FEC /* video-with-audio.html in Copy Resources */, > CDC8E4951BC6F10800594FEC /* video-with-audio.mp4 in Copy Resources */, > CD321B041E3A85FA00EB21C8 /* video-with-muted-audio-and-webaudio.html in Copy Resources */, >@@ -1180,6 +1181,7 @@ > CDC8E4961BC6F10800594FEC /* video-without-audio.html in Copy Resources */, > CDC8E4971BC6F10800594FEC /* video-without-audio.mp4 in Copy Resources */, > 07CD32F82065B72B0064A4BE /* video.html in Copy Resources */, >+ CD577799211CE0E4001B371E /* web-audio-only.html in Copy Resources */, > 1C2B81861C89259D00A5529F /* webfont.html in Copy Resources */, > 51714EB41CF8C78C004723C4 /* WebProcessKillIDBCleanup-1.html in Copy Resources */, > 51714EB51CF8C78C004723C4 /* WebProcessKillIDBCleanup-2.html in Copy Resources */, >@@ -2000,6 +2002,7 @@ > E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TypingStyleCrash.mm; sourceTree = "<group>"; }; > E4A757D3178AEA5B00B5D7A4 /* Deque.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Deque.cpp; sourceTree = "<group>"; }; > E4C9ABC71B3DB1710040A987 /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = "<group>"; }; >+ E5036F77211BC22800BFDBE2 /* color-drop.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "color-drop.html"; sourceTree = "<group>"; }; > ECA680CD1E68CC0900731D20 /* StringUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringUtilities.mm; sourceTree = "<group>"; }; > F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; }; > F407FE381F1D0DE60017CF25 /* enormous.svg */ = {isa = PBXFileReference; lastKnownFileType = text; path = enormous.svg; sourceTree = "<group>"; }; >@@ -2587,6 +2590,7 @@ > 5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */, > F4856CA21E6498A8009D7EE7 /* attachment-element.html */, > 3760C4F221124BD000233ACC /* AttrStyle.html */, >+ CD57779A211CE6B7001B371E /* audio-with-web-audio.html */, > F41AB9981EF4692C0083FA08 /* autofocus-contenteditable.html */, > 93CFA8661CEB9DE1000565A8 /* autofocused-text-input.html */, > 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */, >@@ -2594,6 +2598,7 @@ > 2DE71AFF1D49C2F000904094 /* blinking-div.html */, > 2EFF06C41D8867700004BB30 /* change-video-source-on-click.html */, > 2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */, >+ E5036F77211BC22800BFDBE2 /* color-drop.html */, > F4B825D61EF4DBD4006E417F /* compressed-files.zip */, > F469FB231F01803500401539 /* contenteditable-and-target.html */, > F41AB99C1EF4692C0083FA08 /* contenteditable-and-textarea.html */, >@@ -2724,13 +2729,12 @@ > F44C7A0420FAAE320014478C /* text-with-deferred-script.html */, > F41AB9951EF4692C0083FA08 /* textarea-to-input.html */, > F4451C751EB8FD7C0020C5DA /* two-paragraph-contenteditable.html */, >+ CD57779B211CE6CE001B371E /* video-with-audio-and-web-audio.html */, >+ CD577798211CDE8F001B371E /* web-audio-only.html */, > 51714EB21CF8C761004723C4 /* WebProcessKillIDBCleanup-1.html */, > 51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */, > 5120C83B1E674E350025B250 /* WebsiteDataStoreCustomPaths.html */, > 2E131C171D83A97E001BA36C /* wide-autoplaying-video-with-audio.html */, >- CD577798211CDE8F001B371E /* web-audio-only.html */, >- CD57779A211CE6B7001B371E /* audio-with-web-audio.html */, >- CD57779B211CE6CE001B371E /* video-with-audio-and-web-audio.html */, > ); > name = Resources; > sourceTree = "<group>"; >@@ -3748,7 +3752,6 @@ > CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */, > 7C83E0BD1D0A650C00FEBCF3 /* FullscreenTopContentInset.mm in Sources */, > CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */, >- CD227E44211A4D5D00D285AF /* PreferredAudioBufferSize.mm in Sources */, > 83DB79691EF63B3C00BFA5E5 /* Function.cpp in Sources */, > 7CCE7EF81A411AE600447C4C /* Geolocation.cpp in Sources */, > 631EFFF61E7B5E8D00D2EBB8 /* Geolocation.mm in Sources */, >@@ -3867,6 +3870,7 @@ > 7CCE7EA71A411A1300447C4C /* PlatformWebViewMac.mm in Sources */, > 83BAEE8D1EF4625500DDE894 /* PluginLoadClientPolicies.mm in Sources */, > 7CCE7F261A411AF600447C4C /* Preferences.mm in Sources */, >+ CD227E44211A4D5D00D285AF /* PreferredAudioBufferSize.mm in Sources */, > 7C1AF7951E8DCBAB002645B9 /* PrepareForMoveToWindow.mm in Sources */, > 7CCE7F0B1A411AE600447C4C /* PreventEmptyUserAgent.cpp in Sources */, > 7CCE7F2C1A411B1000447C4C /* PreventImageLoadWithAutoResizing.mm in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/color-drop.html b/Tools/TestWebKitAPI/Tests/WebKitCocoa/color-drop.html >new file mode 100644 >index 0000000000000000000000000000000000000000..3e9e33868dbb4d65fae6b0fc3d7246b039894700 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/color-drop.html >@@ -0,0 +1,6 @@ >+<!DOCTYPE html> >+<meta name="viewport" content="width=device-width, initial-scale=1"> >+<body style="width: 100vw; height: 100vh; margin: 0;"> >+ <input type=color style="width: 100px; height: 100px"> >+ <input type=color id="drop-target" style="width: 100px; height: 100px;" value="#FF0000"> >+</body> >diff --git a/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm b/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm >index d60494190fc26959fcd468c5b3a92ee5da234bd5..d202c962f1239d8733d06e5a5f6a1bfd6fff7561 100644 >--- a/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm >+++ b/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm >@@ -1283,6 +1283,19 @@ TEST(DragAndDropTests, CancelledLiftDoesNotCauseSubsequentDragsToFail) > checkStringArraysAreEqual(@[@"dragstart", @"dragend"], [outputText componentsSeparatedByString:@" "]); > } > >+#if ENABLE(INPUT_TYPE_COLOR) >+TEST(DragAndDropTests, ColorInputToColorInput) >+{ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); >+ [webView synchronouslyLoadTestPageNamed:@"color-drop"]; >+ >+ auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); >+ [simulator runFrom:CGPointMake(50, 50) to:CGPointMake(150, 50)]; >+ >+ EXPECT_WK_STREQ(@"#000000", [webView stringByEvaluatingJavaScript:@"document.getElementById(\"drop-target\").value"]); >+} >+#endif >+ > static void testDragAndDropOntoTargetElements(TestWKWebView *webView) > { > auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView]); >diff --git a/Tools/TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm b/Tools/TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm >index 481bbae0c7ae5425274caa8a3a1f6f4a01444dcf..8a285073c7440213980ae6b8ca8c747e0d7c9120 100644 >--- a/Tools/TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm >+++ b/Tools/TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm >@@ -281,6 +281,37 @@ TEST(DragAndDropPasteboardTests, NumberOfValidItemsForDrop) > EXPECT_EQ(1U, [dragInfo numberOfValidItemsForDrop]); > } > >+#if ENABLE(INPUT_TYPE_COLOR) >+ >+TEST(DragAndDropPasteboardTests, DropColor) >+{ >+ NSPasteboard *pasteboard = [NSPasteboard pasteboardWithUniqueName]; >+ [pasteboard declareTypes:@[NSColorPboardType] owner:nil]; >+ [[NSColor redColor] writeToPasteboard:pasteboard]; >+ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]); >+ auto hostWindow = adoptNS([[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 400, 400) styleMask:0 backing:NSBackingStoreBuffered defer:NO]); >+ [hostWindow setFrameOrigin:NSMakePoint(0, 0)]; >+ [[hostWindow contentView] addSubview:webView.get()]; >+ >+ [webView synchronouslyLoadTestPageNamed:@"color-drop"]; >+ >+ auto dragSource = adoptNS([[DragSource alloc] init]); >+ auto dragInfo = adoptNS([[DragInfo alloc] initWithImage:getTestImage() offset:NSMakeSize(0, 0) pasteboard:pasteboard source:dragSource.get() destinationWindow:hostWindow.get()]); >+ >+ [dragInfo setLastMousePosition:NSMakePoint(10, 10)]; >+ [webView draggingEntered:dragInfo.get()]; >+ >+ [dragInfo setLastMousePosition:NSMakePoint(50, 50)]; >+ [webView draggingUpdated:dragInfo.get()]; >+ >+ EXPECT_TRUE([webView performDragOperation:dragInfo.get()]); >+ >+ EXPECT_WK_STREQ(@"#ff0000", [webView stringByEvaluatingJavaScript:@"document.querySelector(\"input\").value"]); >+} >+ >+#endif // ENABLE(INPUT_TYPE_COLOR) >+ > #endif // WK_API_ENABLED > > } // namespace TestWebKitAPI >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index cf519fa512e25098f27056b42871ae062b304138..68de644f90b04d5a7ccd234d21798cfa12608496 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,18 @@ >+2018-08-10 Aditya Keerthi <akeerthi@apple.com> >+ >+ Support drag-and-drop for input[type=color] >+ https://bugs.webkit.org/show_bug.cgi?id=188464 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added a test to verify that dragging from one color input to another behaves as >+ expected in WK1. >+ >+ * editing/pasteboard/drag-and-drop-color-input-expected.txt: Added. >+ * editing/pasteboard/drag-and-drop-color-input.html: Added. >+ * platform/ios/TestExpectations: >+ * platform/wk2/TestExpectations: >+ > 2018-08-09 Joseph Pecoraro <pecoraro@apple.com> > > Remove ElCapitan specific layout test expectations >diff --git a/LayoutTests/editing/pasteboard/drag-and-drop-color-input-expected.txt b/LayoutTests/editing/pasteboard/drag-and-drop-color-input-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..399032a80a26c4c9ec1ea73dee2b949326cb1fc6 >--- /dev/null >+++ b/LayoutTests/editing/pasteboard/drag-and-drop-color-input-expected.txt >@@ -0,0 +1,11 @@ >+This test verifies that dragging a color from one input to another changes the color of the second input. To test manually, drag the first input and drop it in the second input. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS src.value is "#ff0000" >+PASS dest.value is "#ff0000" >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/editing/pasteboard/drag-and-drop-color-input.html b/LayoutTests/editing/pasteboard/drag-and-drop-color-input.html >new file mode 100644 >index 0000000000000000000000000000000000000000..bc087c449ddc80e3fb4c194f785786e239fd1470 >--- /dev/null >+++ b/LayoutTests/editing/pasteboard/drag-and-drop-color-input.html >@@ -0,0 +1,36 @@ >+<!DOCTYPE html> >+<html> >+<head> >+ <script src="../../resources/js-test.js"></script> >+</head> >+<body onload="runTest()"> >+ <p id="description"></p> >+ <input type=color id="src" value="#ff0000"> >+ <input type=color id="dest" value="#000000"> >+</body> >+<script> >+description('This test verifies that dragging a color from one input to another changes the color of the second input. To test manually, drag the first input and drop it in the second input.'); >+ >+var jsTestIsAsync = true; >+ >+var src = document.getElementById('src'); >+var dest = document.getElementById('dest'); >+ >+function runTest() { >+ if (!window.testRunner) >+ return; >+ >+ dest.addEventListener("change", function() { >+ shouldBeEqualToString("src.value", "#ff0000"); >+ shouldBeEqualToString("dest.value", "#ff0000"); >+ finishJSTest(); >+ }); >+ >+ eventSender.mouseMoveTo(src.offsetLeft + src.offsetWidth / 2, src.offsetTop + src.offsetHeight / 2); >+ eventSender.mouseDown(); >+ eventSender.leapForward(500); >+ eventSender.mouseMoveTo(dest.offsetLeft + dest.offsetWidth / 2, dest.offsetTop + dest.offsetHeight / 2); >+ eventSender.mouseUp(); >+} >+</script> >+</html> >diff --git a/LayoutTests/platform/ios/TestExpectations b/LayoutTests/platform/ios/TestExpectations >index e0606a8971e5f58ed73032ecde7cc1975ec9011e..606bdbb21cb31e0eb5a91733a5c1048052711b9a 100644 >--- a/LayoutTests/platform/ios/TestExpectations >+++ b/LayoutTests/platform/ios/TestExpectations >@@ -1007,6 +1007,7 @@ editing/pasteboard/drop-file-svg.html [ Skip ] > editing/pasteboard/drop-inputtext-acquires-style.html [ Skip ] > editing/pasteboard/drop-link.html [ Skip ] > editing/pasteboard/drop-text-events.html [ Skip ] >+editing/pasteboard/drag-and-drop-color-input.html [ Skip ] > editing/pasteboard/drag-and-drop-image-contenteditable.html [ Skip ] > editing/pasteboard/drag-and-drop-inputimage-contenteditable.html [ Skip ] > editing/pasteboard/drag-and-drop-objectimage-contenteditable.html [ Skip ] >diff --git a/LayoutTests/platform/wk2/TestExpectations b/LayoutTests/platform/wk2/TestExpectations >index cd053c194663d24765dfe09f37621ad116c48cab..be3c09100380c9fbe6a10ae1809579fa3f2c4b81 100644 >--- a/LayoutTests/platform/wk2/TestExpectations >+++ b/LayoutTests/platform/wk2/TestExpectations >@@ -570,6 +570,7 @@ platform/mac/fast/events/objc-event-api.html > # https://bugs.webkit.org/show_bug.cgi?id=64285 > editing/pasteboard/datatransfer-items-drop-plaintext-file.html > editing/pasteboard/datatransfer-types-dropping-text-file.html >+editing/pasteboard/drag-and-drop-color-input.html > editing/pasteboard/drag-and-drop-image-contenteditable.html > editing/pasteboard/drag-and-drop-inputimage-contenteditable.html > editing/pasteboard/drag-and-drop-objectimage-contenteditable.html
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188464
:
346886
|
346889
|
346898
|
346911
|
346915
|
346917
|
346918
|
346927
|
346928
|
346938
|
346943
|
346947
|
346961
|
346994
|
347088
|
347168
|
347173
|
347225