Title: [209252] trunk
Revision
209252
Author
[email protected]
Date
2016-12-02 12:05:07 -0800 (Fri, 02 Dec 2016)

Log Message

[Mac][WK1] Implement new HTML interactive form validation user interface
https://bugs.webkit.org/show_bug.cgi?id=164483

Reviewed by Simon Fraser.

Source/WebKit:

Add new files to xcode project.

* WebKit.xcodeproj/project.pbxproj:

Source/WebKit/mac:

Implement new HTML interactive form validation user interface on Mac
WK1 and enable it by default.

* WebCoreSupport/WebValidationMessageClient.h: Added.
* WebCoreSupport/WebValidationMessageClient.mm: Added.
(WebValidationMessageClient::WebValidationMessageClient):
(WebValidationMessageClient::~WebValidationMessageClient):
(WebValidationMessageClient::showValidationMessage):
(WebValidationMessageClient::hideValidationMessage):
(WebValidationMessageClient::isValidationMessageVisible):
* WebView/WebHTMLView.mm:
(-[WebHTMLView _frameOrBoundsChanged]):
* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView _willStartScrollingOrZooming]):
(-[WebView _contentsOfUserInterfaceItem:]):
(-[WebView _scaleWebView:atOrigin:]):
(-[WebView _didScrollDocumentInFrameView:]):
(-[WebView _setZoomMultiplier:isTextOnly:]):
(-[WebView showFormValidationMessage:withAnchorRect:]):
(-[WebView hideFormValidationMessage]):
* WebView/WebViewData.h:
* WebView/WebViewData.mm:
(-[WebViewPrivate init]):
* WebView/WebViewInternal.h:
* WebView/WebViewPrivate.h:

Tools:

Add support for UIScriptController's contentsOfUserInterfaceItem("validationBubble")
on Mac DRT as this is needed by the HTML form validation layout tests.

* DumpRenderTree/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::contentsOfUserInterfaceItem):

LayoutTests:

Unskip tests for HTML form validation that are now passing on Mac WK1.

* platform/mac-wk1/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (209251 => 209252)


--- trunk/LayoutTests/ChangeLog	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/LayoutTests/ChangeLog	2016-12-02 20:05:07 UTC (rev 209252)
@@ -1,3 +1,14 @@
+2016-12-02  Chris Dumez  <[email protected]>
+
+        [Mac][WK1] Implement new HTML interactive form validation user interface
+        https://bugs.webkit.org/show_bug.cgi?id=164483
+
+        Reviewed by Simon Fraser.
+
+        Unskip tests for HTML form validation that are now passing on Mac WK1.
+
+        * platform/mac-wk1/TestExpectations:
+
 2016-12-02  Ryan Haddad  <[email protected]>
 
         Marking media/modern-media-controls/tracks-support/tracks-support-click-track-in-panel.html as flaky on mac-wk1.

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (209251 => 209252)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2016-12-02 20:05:07 UTC (rev 209252)
@@ -93,6 +93,17 @@
 http/tests/media/media-stream
 http/tests/ssl/media-stream
 
+# These tests test the Shadow DOM based HTML form validation UI but Mac WK1 is using native dialogs instead.
+fast/forms/validation-message-on-listbox.html
+fast/forms/validation-message-on-menulist.html
+fast/forms/validation-message-on-radio.html
+fast/forms/validation-message-on-checkbox.html
+fast/forms/validation-message-on-range.html
+fast/forms/validation-message-clone.html
+fast/forms/validation-message-in-relative-body.html
+fast/forms/validation-message-appearance.html
+fast/forms/validation-message-on-textarea.html
+
 # Disable snapshotting tests on WK1 only
 plugins/snapshotting
 
@@ -243,10 +254,6 @@
 # rdar://problem/26478296
 [ Sierra+ ] svg/hixie/text/003.html [ Failure ]
 
-# We do not support the new HTML validation UI on WebKit1 yet (rdar://problem/28944652).
-fast/forms/validation-custom-message.html [ Skip ]
-fast/forms/validation-messages.html [ Skip ]
-
 [ Yosemite ] http/tests/media/hls/video-controller-getStartDate.html [ Pass Timeout ]
 
 webkit.org/b/159893 [ Debug ] imported/w3c/web-platform-tests/XMLHttpRequest/event-readystatechange-loaded.htm [ Pass Failure ]

Modified: trunk/Source/WebKit/ChangeLog (209251 => 209252)


--- trunk/Source/WebKit/ChangeLog	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/Source/WebKit/ChangeLog	2016-12-02 20:05:07 UTC (rev 209252)
@@ -1,3 +1,14 @@
+2016-12-02  Chris Dumez  <[email protected]>
+
+        [Mac][WK1] Implement new HTML interactive form validation user interface
+        https://bugs.webkit.org/show_bug.cgi?id=164483
+
+        Reviewed by Simon Fraser.
+
+        Add new files to xcode project.
+
+        * WebKit.xcodeproj/project.pbxproj:
+
 2016-11-17  Yusuke Suzuki  <[email protected]>
 
         [JSC] WTF::TemporaryChange with WTF::SetForScope

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (209251 => 209252)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2016-12-02 20:05:07 UTC (rev 209252)
@@ -122,6 +122,8 @@
 		3ABB3C7B1309C3B500E93D94 /* WebStorageTrackerClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3ABB3C791309C3B500E93D94 /* WebStorageTrackerClient.mm */; };
 		3AE15D5012DBDED4009323C8 /* WebStorageManagerInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AE15D4F12DBDED4009323C8 /* WebStorageManagerInternal.h */; };
 		44BB8B141241A022001E3A22 /* WebArchiveInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 44BB8B131241A022001E3A22 /* WebArchiveInternal.h */; };
+		4618DFF81DEF760A0033C3AA /* WebValidationMessageClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4618DFF61DEF760A0033C3AA /* WebValidationMessageClient.h */; };
+		4618DFF91DEF760A0033C3AA /* WebValidationMessageClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4618DFF71DEF760A0033C3AA /* WebValidationMessageClient.mm */; };
 		4BF99F900AE050BC00815C2B /* WebEditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF99F8E0AE050BC00815C2B /* WebEditorClient.h */; settings = {ATTRIBUTES = (); }; };
 		4BF99F910AE050BC00815C2B /* WebEditorClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BF99F8F0AE050BC00815C2B /* WebEditorClient.mm */; };
 		511F3FD50CECC88F00852565 /* WebDatabaseManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 511F3FD10CECC88F00852565 /* WebDatabaseManager.mm */; };
@@ -942,6 +944,8 @@
 		3AE15D4F12DBDED4009323C8 /* WebStorageManagerInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebStorageManagerInternal.h; sourceTree = "<group>"; };
 		449098B90F8F82DF0076A327 /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
 		44BB8B131241A022001E3A22 /* WebArchiveInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebArchiveInternal.h; sourceTree = "<group>"; };
+		4618DFF61DEF760A0033C3AA /* WebValidationMessageClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebValidationMessageClient.h; sourceTree = "<group>"; };
+		4618DFF71DEF760A0033C3AA /* WebValidationMessageClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebValidationMessageClient.mm; sourceTree = "<group>"; };
 		4BF99F8E0AE050BC00815C2B /* WebEditorClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebEditorClient.h; sourceTree = "<group>"; };
 		4BF99F8F0AE050BC00815C2B /* WebEditorClient.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebEditorClient.mm; sourceTree = "<group>"; };
 		511F3FD10CECC88F00852565 /* WebDatabaseManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDatabaseManager.mm; sourceTree = "<group>"; };
@@ -2633,6 +2637,8 @@
 				93EB178C09F88D460091F8FF /* WebSystemInterface.mm */,
 				070F549917F1E42B00169E04 /* WebUserMediaClient.h */,
 				070F549A17F1E42B00169E04 /* WebUserMediaClient.mm */,
+				4618DFF61DEF760A0033C3AA /* WebValidationMessageClient.h */,
+				4618DFF71DEF760A0033C3AA /* WebValidationMessageClient.mm */,
 				1430C12A1B2C5DF700DEA01D /* WebViewGroup.cpp */,
 				1430C12B1B2C5DF700DEA01D /* WebViewGroup.h */,
 				1AC7176D1A26568A002E3115 /* WebVisitedLinkStore.h */,
@@ -3166,6 +3172,7 @@
 				E4AEF97C1C0DF4BC00B01727 /* WebResourceLoadScheduler.h in Headers */,
 				939810890824BF01008DF038 /* WebResourcePrivate.h in Headers */,
 				7E6FEF0808985A7200C44C3F /* WebScriptDebugDelegate.h in Headers */,
+				4618DFF81DEF760A0033C3AA /* WebValidationMessageClient.h in Headers */,
 				C0167BF80D7F5DD00028696E /* WebScriptDebugger.h in Headers */,
 				C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */,
 				C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */,
@@ -3427,6 +3434,7 @@
 				93D4368C1D57ABEE00AB85EA /* DOMDocument.mm in Sources */,
 				93D4368E1D57ABEE00AB85EA /* DOMDocumentFragment.mm in Sources */,
 				93D436941D57ABEE00AB85EA /* DOMDocumentType.mm in Sources */,
+				4618DFF91DEF760A0033C3AA /* WebValidationMessageClient.mm in Sources */,
 				93D436971D57ABEE00AB85EA /* DOMDOMImplementation.mm in Sources */,
 				93D4369A1D57ABEE00AB85EA /* DOMDOMTokenList.mm in Sources */,
 				93D4369D1D57ABEE00AB85EA /* DOMElement.mm in Sources */,

Modified: trunk/Source/WebKit/mac/ChangeLog (209251 => 209252)


--- trunk/Source/WebKit/mac/ChangeLog	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-12-02 20:05:07 UTC (rev 209252)
@@ -1,3 +1,37 @@
+2016-12-02  Chris Dumez  <[email protected]>
+
+        [Mac][WK1] Implement new HTML interactive form validation user interface
+        https://bugs.webkit.org/show_bug.cgi?id=164483
+
+        Reviewed by Simon Fraser.
+
+        Implement new HTML interactive form validation user interface on Mac
+        WK1 and enable it by default.
+
+        * WebCoreSupport/WebValidationMessageClient.h: Added.
+        * WebCoreSupport/WebValidationMessageClient.mm: Added.
+        (WebValidationMessageClient::WebValidationMessageClient):
+        (WebValidationMessageClient::~WebValidationMessageClient):
+        (WebValidationMessageClient::showValidationMessage):
+        (WebValidationMessageClient::hideValidationMessage):
+        (WebValidationMessageClient::isValidationMessageVisible):
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _frameOrBoundsChanged]):
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+        (-[WebView _willStartScrollingOrZooming]):
+        (-[WebView _contentsOfUserInterfaceItem:]):
+        (-[WebView _scaleWebView:atOrigin:]):
+        (-[WebView _didScrollDocumentInFrameView:]):
+        (-[WebView _setZoomMultiplier:isTextOnly:]):
+        (-[WebView showFormValidationMessage:withAnchorRect:]):
+        (-[WebView hideFormValidationMessage]):
+        * WebView/WebViewData.h:
+        * WebView/WebViewData.mm:
+        (-[WebViewPrivate init]):
+        * WebView/WebViewInternal.h:
+        * WebView/WebViewPrivate.h:
+
 2016-12-01  Jiewen Tan  <[email protected]>
 
         Add a runtime flag for SubtleCrypto

Added: trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.h (0 => 209252)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.h	                        (rev 0)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.h	2016-12-02 20:05:07 UTC (rev 209252)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#import <WebCore/ValidationMessageClient.h>
+
+namespace WebCore {
+class Element;
+}
+
+@class WebView;
+
+class WebValidationMessageClient final : public WebCore::ValidationMessageClient {
+public:
+    explicit WebValidationMessageClient(WebView*);
+    ~WebValidationMessageClient();
+
+    // ValidationMessageClient API.
+    void showValidationMessage(const WebCore::Element& anchor, const String& message) final;
+    void hideValidationMessage(const WebCore::Element& anchor) final;
+    bool isValidationMessageVisible(const WebCore::Element& anchor) final;
+
+private:
+    WebView* m_view;
+    const WebCore::Element* m_currentAnchor { nullptr };
+};

Added: trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.mm (0 => 209252)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.mm	                        (rev 0)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebValidationMessageClient.mm	2016-12-02 20:05:07 UTC (rev 209252)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebValidationMessageClient.h"
+
+#import "WebView.h"
+#import "WebViewInternal.h"
+#import <WebCore/Element.h>
+
+using namespace WebCore;
+
+WebValidationMessageClient::WebValidationMessageClient(WebView* view)
+    : m_view(view)
+{
+}
+
+WebValidationMessageClient::~WebValidationMessageClient()
+{
+    if (m_currentAnchor)
+        hideValidationMessage(*m_currentAnchor);
+}
+
+void WebValidationMessageClient::showValidationMessage(const Element& anchor, const String& message)
+{
+    if (m_currentAnchor)
+        hideValidationMessage(*m_currentAnchor);
+
+    m_currentAnchor = &anchor;
+    [m_view showFormValidationMessage:message withAnchorRect:anchor.clientRect()];
+}
+
+void WebValidationMessageClient::hideValidationMessage(const Element& anchor)
+{
+    if (!isValidationMessageVisible(anchor))
+        return;
+
+    m_currentAnchor = nullptr;
+    [m_view hideFormValidationMessage];
+}
+
+bool WebValidationMessageClient::isValidationMessageVisible(const Element& anchor)
+{
+    return m_currentAnchor == &anchor;
+}

Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (209251 => 209252)


--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm	2016-12-02 20:05:07 UTC (rev 209252)
@@ -1689,7 +1689,7 @@
         [_private->completionController endRevertingChange:NO moveLeft:NO];
 #endif
         
-        [[webView _UIDelegateForwarder] webView:webView didScrollDocumentInFrameView:[self _frameView]];
+        [webView _didScrollDocumentInFrameView:[self _frameView]];
     }
     _private->lastScrollPosition = origin;
 }

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (209251 => 209252)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2016-12-02 20:05:07 UTC (rev 209252)
@@ -111,6 +111,7 @@
 #import "WebUIDelegate.h"
 #import "WebUIDelegatePrivate.h"
 #import "WebUserMediaClient.h"
+#import "WebValidationMessageClient.h"
 #import "WebViewGroup.h"
 #import "WebVisitedLinkStore.h"
 #import <CoreFoundation/CFSet.h>
@@ -194,6 +195,7 @@
 #import <WebCore/UserContentController.h>
 #import <WebCore/UserScript.h>
 #import <WebCore/UserStyleSheet.h>
+#import <WebCore/ValidationBubble.h>
 #import <WebCore/WebCoreObjCExtras.h>
 #import <WebCore/WebCoreView.h>
 #import <WebCore/Widget.h>
@@ -1311,6 +1313,8 @@
 #if !PLATFORM(IOS)
     pageConfiguration.chromeClient = new WebChromeClient(self);
     pageConfiguration.contextMenuClient = new WebContextMenuClient(self);
+    // FIXME: We should enable this on iOS as well.
+    pageConfiguration.validationMessageClient = std::make_unique<WebValidationMessageClient>(self);
 #if ENABLE(DRAG_SUPPORT)
     pageConfiguration.dragClient = new WebDragClient(self);
 #endif
@@ -1961,6 +1965,8 @@
         return;
     _private->mainViewIsScrollingOrZooming = YES;
 
+    [self hideFormValidationMessage];
+
     // This suspends active DOM objects like timers, but not media.
     [[self mainFrame] setTimeoutsPaused:YES];
 
@@ -4308,6 +4314,17 @@
     _private->validationMessageTimerMagnification = newValue;
 }
 
+- (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem
+{
+    if ([userInterfaceItem isEqualToString:@"validationBubble"]) {
+        auto* validationBubble = _private->formValidationBubble.get();
+        String message = validationBubble ? validationBubble->message() : emptyString();
+        return @{ userInterfaceItem: @{ @"message": (NSString *)message } };
+    }
+
+    return nil;
+}
+
 - (BOOL)_isSoftwareRenderable
 {
     Frame* coreFrame = [self _mainCoreFrame];
@@ -4627,6 +4644,8 @@
 
 - (void)_scaleWebView:(float)scale atOrigin:(NSPoint)origin
 {
+    [self hideFormValidationMessage];
+
     _private->page->setPageScaleFactor(scale, IntPoint(origin));
 }
 
@@ -4927,6 +4946,12 @@
     ResourceRequest::setHTTPPipeliningEnabled(enabled);
 }
 
+- (void)_didScrollDocumentInFrameView:(WebFrameView *)frameView
+{
+    [self hideFormValidationMessage];
+    [[self _UIDelegateForwarder] webView:self didScrollDocumentInFrameView:frameView];
+}
+
 #if PLATFORM(IOS)
 - (WebFixedPositionContent*)_fixedPositionContent
 {
@@ -6136,6 +6161,8 @@
     _private->zoomMultiplier = multiplier;
     _private->zoomsTextOnly = isTextOnly;
 
+    [self hideFormValidationMessage];
+
     // FIXME: It might be nice to rework this code so that _private->zoomMultiplier doesn't exist
     // and instead the zoom factors stored in Frame are used.
     Frame* coreFrame = [self _mainCoreFrame];
@@ -9235,8 +9262,26 @@
 {
     [self _clearTextIndicatorWithAnimation:TextIndicatorWindowDismissalAnimation::FadeOut];
 }
+
 #endif // PLATFORM(MAC)
 
+- (void)showFormValidationMessage:(NSString *)message withAnchorRect:(NSRect)anchorRect
+{
+    // FIXME: We should enable this on iOS as well.
+#if PLATFORM(MAC)
+    _private->formValidationBubble = std::make_unique<ValidationBubble>(self, message);
+    _private->formValidationBubble->showRelativeTo(enclosingIntRect([self _convertRectFromRootView:anchorRect]));
+#else
+    UNUSED_PARAM(message);
+    UNUSED_PARAM(anchorRect);
+#endif
+}
+
+- (void)hideFormValidationMessage
+{
+    _private->formValidationBubble = nullptr;
+}
+
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
 - (WebMediaPlaybackTargetPicker *) _devicePicker
 {

Modified: trunk/Source/WebKit/mac/WebView/WebViewData.h (209251 => 209252)


--- trunk/Source/WebKit/mac/WebView/WebViewData.h	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.h	2016-12-02 20:05:07 UTC (rev 209252)
@@ -48,6 +48,7 @@
 class HistoryItem;
 class Page;
 class TextIndicatorWindow;
+class ValidationBubble;
 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
 class WebPlaybackSessionInterfaceMac;
 class WebPlaybackSessionModelMediaElement;
@@ -205,6 +206,8 @@
     RetainPtr<NSEvent> pressureEvent;
 #endif // PLATFORM(MAC)
 
+    std::unique_ptr<WebCore::ValidationBubble> formValidationBubble;
+
     BOOL shouldMaintainInactiveSelection;
 
     BOOL allowsUndo;

Modified: trunk/Source/WebKit/mac/WebView/WebViewData.mm (209251 => 209252)


--- trunk/Source/WebKit/mac/WebView/WebViewData.mm	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.mm	2016-12-02 20:05:07 UTC (rev 209252)
@@ -37,6 +37,7 @@
 #import <WebCore/WebCoreObjCExtras.h>
 #import <WebCore/HistoryItem.h>
 #import <WebCore/TextIndicatorWindow.h>
+#import <WebCore/ValidationBubble.h>
 #import <runtime/InitializeThreading.h>
 #import <wtf/MainThread.h>
 #import <wtf/RunLoop.h>
@@ -143,7 +144,7 @@
     zoomMultiplier = 1;
     zoomsTextOnly = NO;
 
-    interactiveFormValidationEnabled = NO;
+    interactiveFormValidationEnabled = YES;
     // The default value should be synchronized with WebCore/page/Settings.cpp.
     validationMessageTimerMagnification = 50;
 

Modified: trunk/Source/WebKit/mac/WebView/WebViewInternal.h (209251 => 209252)


--- trunk/Source/WebKit/mac/WebView/WebViewInternal.h	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/Source/WebKit/mac/WebView/WebViewInternal.h	2016-12-02 20:05:07 UTC (rev 209252)
@@ -300,4 +300,7 @@
 - (void)_dismissTextTouchBarPopoverItemWithIdentifier:(NSString *)identifier;
 - (NSCandidateListTouchBarItem *)candidateList;
 
+- (void)showFormValidationMessage:(NSString *)message withAnchorRect:(NSRect)anchorRect;
+- (void)hideFormValidationMessage;
+
 @end

Modified: trunk/Source/WebKit/mac/WebView/WebViewPrivate.h (209251 => 209252)


--- trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2016-12-02 20:05:07 UTC (rev 209252)
@@ -486,6 +486,8 @@
 // SPI for DumpRenderTree
 - (void)_updateActiveState;
 
+- (void)_didScrollDocumentInFrameView:(WebFrameView *)frameView;
+
 /*!
     @method _registerViewClass:representationClass:forURLScheme:
     @discussion Register classes that implement WebDocumentView and WebDocumentRepresentation respectively.
@@ -742,6 +744,7 @@
 - (void)setInteractiveFormValidationEnabled:(BOOL)enabled;
 - (int)validationMessageTimerMagnification;
 - (void)setValidationMessageTimerMagnification:(int)newValue;
+- (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem;
 
 // Returns YES if NSView -displayRectIgnoringOpacity:inContext: will produce a faithful representation of the content.
 - (BOOL)_isSoftwareRenderable;

Modified: trunk/Tools/ChangeLog (209251 => 209252)


--- trunk/Tools/ChangeLog	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/Tools/ChangeLog	2016-12-02 20:05:07 UTC (rev 209252)
@@ -1,3 +1,16 @@
+2016-12-02  Chris Dumez  <[email protected]>
+
+        [Mac][WK1] Implement new HTML interactive form validation user interface
+        https://bugs.webkit.org/show_bug.cgi?id=164483
+
+        Reviewed by Simon Fraser.
+
+        Add support for UIScriptController's contentsOfUserInterfaceItem("validationBubble")
+        on Mac DRT as this is needed by the HTML form validation layout tests.
+
+        * DumpRenderTree/mac/UIScriptControllerMac.mm:
+        (WTR::UIScriptController::contentsOfUserInterfaceItem):
+
 2016-12-02  Brady Eidson  <[email protected]>
 
         IndexedDB.IndexedDBMultiProcess and IndexedDB.WebProcessKillIDBCleanup sometimes timeout.

Modified: trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm (209251 => 209252)


--- trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm	2016-12-02 19:55:09 UTC (rev 209251)
+++ trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm	2016-12-02 20:05:07 UTC (rev 209252)
@@ -28,6 +28,9 @@
 
 #import "DumpRenderTree.h"
 #import "UIScriptContext.h"
+#import <_javascript_Core/JSContext.h>
+#import <_javascript_Core/JSStringRefCF.h>
+#import <_javascript_Core/JSValue.h>
 #import <WebKit/WebKit.h>
 #import <WebKit/WebViewPrivate.h>
 
@@ -75,7 +78,15 @@
 
 JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const
 {
+#if JSC_OBJC_API_ENABLED
+    WebView *webView = [mainFrame webView];
+    RetainPtr<CFStringRef> interfaceItemCF = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, interfaceItem));
+    NSDictionary *contentDictionary = [webView _contentsOfUserInterfaceItem:(NSString *)interfaceItemCF.get()];
+    return JSValueToObject(m_context->jsContext(), [JSValue valueWithObject:contentDictionary inContext:[JSContext contextWithJSGlobalContextRef:m_context->jsContext()]].JSValueRef, nullptr);
+#else
+    UNUSED_PARAM(interfaceItem);
     return nullptr;
+#endif
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to