Changeset 209252 in webkit


Ignore:
Timestamp:
Dec 2, 2016, 12:05:07 PM (9 years ago)
Author:
Chris Dumez
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:
Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r209250 r209252  
     12016-12-02  Chris Dumez  <cdumez@apple.com>
     2
     3        [Mac][WK1] Implement new HTML interactive form validation user interface
     4        https://bugs.webkit.org/show_bug.cgi?id=164483
     5
     6        Reviewed by Simon Fraser.
     7
     8        Unskip tests for HTML form validation that are now passing on Mac WK1.
     9
     10        * platform/mac-wk1/TestExpectations:
     11
    1122016-12-02  Ryan Haddad  <ryanhaddad@apple.com>
    213
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r209250 r209252  
    9393http/tests/media/media-stream
    9494http/tests/ssl/media-stream
     95
     96# These tests test the Shadow DOM based HTML form validation UI but Mac WK1 is using native dialogs instead.
     97fast/forms/validation-message-on-listbox.html
     98fast/forms/validation-message-on-menulist.html
     99fast/forms/validation-message-on-radio.html
     100fast/forms/validation-message-on-checkbox.html
     101fast/forms/validation-message-on-range.html
     102fast/forms/validation-message-clone.html
     103fast/forms/validation-message-in-relative-body.html
     104fast/forms/validation-message-appearance.html
     105fast/forms/validation-message-on-textarea.html
    95106
    96107# Disable snapshotting tests on WK1 only
     
    244255[ Sierra+ ] svg/hixie/text/003.html [ Failure ]
    245256
    246 # We do not support the new HTML validation UI on WebKit1 yet (rdar://problem/28944652).
    247 fast/forms/validation-custom-message.html [ Skip ]
    248 fast/forms/validation-messages.html [ Skip ]
    249 
    250257[ Yosemite ] http/tests/media/hls/video-controller-getStartDate.html [ Pass Timeout ]
    251258
  • trunk/Source/WebKit/ChangeLog

    r208841 r209252  
     12016-12-02  Chris Dumez  <cdumez@apple.com>
     2
     3        [Mac][WK1] Implement new HTML interactive form validation user interface
     4        https://bugs.webkit.org/show_bug.cgi?id=164483
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add new files to xcode project.
     9
     10        * WebKit.xcodeproj/project.pbxproj:
     11
    1122016-11-17  Yusuke Suzuki  <utatane.tea@gmail.com>
    213
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r208624 r209252  
    123123                3AE15D5012DBDED4009323C8 /* WebStorageManagerInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AE15D4F12DBDED4009323C8 /* WebStorageManagerInternal.h */; };
    124124                44BB8B141241A022001E3A22 /* WebArchiveInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 44BB8B131241A022001E3A22 /* WebArchiveInternal.h */; };
     125                4618DFF81DEF760A0033C3AA /* WebValidationMessageClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4618DFF61DEF760A0033C3AA /* WebValidationMessageClient.h */; };
     126                4618DFF91DEF760A0033C3AA /* WebValidationMessageClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4618DFF71DEF760A0033C3AA /* WebValidationMessageClient.mm */; };
    125127                4BF99F900AE050BC00815C2B /* WebEditorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BF99F8E0AE050BC00815C2B /* WebEditorClient.h */; settings = {ATTRIBUTES = (); }; };
    126128                4BF99F910AE050BC00815C2B /* WebEditorClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BF99F8F0AE050BC00815C2B /* WebEditorClient.mm */; };
     
    943945                449098B90F8F82DF0076A327 /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
    944946                44BB8B131241A022001E3A22 /* WebArchiveInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebArchiveInternal.h; sourceTree = "<group>"; };
     947                4618DFF61DEF760A0033C3AA /* WebValidationMessageClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebValidationMessageClient.h; sourceTree = "<group>"; };
     948                4618DFF71DEF760A0033C3AA /* WebValidationMessageClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebValidationMessageClient.mm; sourceTree = "<group>"; };
    945949                4BF99F8E0AE050BC00815C2B /* WebEditorClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebEditorClient.h; sourceTree = "<group>"; };
    946950                4BF99F8F0AE050BC00815C2B /* WebEditorClient.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebEditorClient.mm; sourceTree = "<group>"; };
     
    26342638                                070F549917F1E42B00169E04 /* WebUserMediaClient.h */,
    26352639                                070F549A17F1E42B00169E04 /* WebUserMediaClient.mm */,
     2640                                4618DFF61DEF760A0033C3AA /* WebValidationMessageClient.h */,
     2641                                4618DFF71DEF760A0033C3AA /* WebValidationMessageClient.mm */,
    26362642                                1430C12A1B2C5DF700DEA01D /* WebViewGroup.cpp */,
    26372643                                1430C12B1B2C5DF700DEA01D /* WebViewGroup.h */,
     
    31673173                                939810890824BF01008DF038 /* WebResourcePrivate.h in Headers */,
    31683174                                7E6FEF0808985A7200C44C3F /* WebScriptDebugDelegate.h in Headers */,
     3175                                4618DFF81DEF760A0033C3AA /* WebValidationMessageClient.h in Headers */,
    31693176                                C0167BF80D7F5DD00028696E /* WebScriptDebugger.h in Headers */,
    31703177                                C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */,
     
    34283435                                93D4368E1D57ABEE00AB85EA /* DOMDocumentFragment.mm in Sources */,
    34293436                                93D436941D57ABEE00AB85EA /* DOMDocumentType.mm in Sources */,
     3437                                4618DFF91DEF760A0033C3AA /* WebValidationMessageClient.mm in Sources */,
    34303438                                93D436971D57ABEE00AB85EA /* DOMDOMImplementation.mm in Sources */,
    34313439                                93D4369A1D57ABEE00AB85EA /* DOMDOMTokenList.mm in Sources */,
  • trunk/Source/WebKit/mac/ChangeLog

    r209230 r209252  
     12016-12-02  Chris Dumez  <cdumez@apple.com>
     2
     3        [Mac][WK1] Implement new HTML interactive form validation user interface
     4        https://bugs.webkit.org/show_bug.cgi?id=164483
     5
     6        Reviewed by Simon Fraser.
     7
     8        Implement new HTML interactive form validation user interface on Mac
     9        WK1 and enable it by default.
     10
     11        * WebCoreSupport/WebValidationMessageClient.h: Added.
     12        * WebCoreSupport/WebValidationMessageClient.mm: Added.
     13        (WebValidationMessageClient::WebValidationMessageClient):
     14        (WebValidationMessageClient::~WebValidationMessageClient):
     15        (WebValidationMessageClient::showValidationMessage):
     16        (WebValidationMessageClient::hideValidationMessage):
     17        (WebValidationMessageClient::isValidationMessageVisible):
     18        * WebView/WebHTMLView.mm:
     19        (-[WebHTMLView _frameOrBoundsChanged]):
     20        * WebView/WebView.mm:
     21        (-[WebView _commonInitializationWithFrameName:groupName:]):
     22        (-[WebView _willStartScrollingOrZooming]):
     23        (-[WebView _contentsOfUserInterfaceItem:]):
     24        (-[WebView _scaleWebView:atOrigin:]):
     25        (-[WebView _didScrollDocumentInFrameView:]):
     26        (-[WebView _setZoomMultiplier:isTextOnly:]):
     27        (-[WebView showFormValidationMessage:withAnchorRect:]):
     28        (-[WebView hideFormValidationMessage]):
     29        * WebView/WebViewData.h:
     30        * WebView/WebViewData.mm:
     31        (-[WebViewPrivate init]):
     32        * WebView/WebViewInternal.h:
     33        * WebView/WebViewPrivate.h:
     34
    1352016-12-01  Jiewen Tan  <jiewen_tan@apple.com>
    236
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r208985 r209252  
    16901690#endif
    16911691       
    1692         [[webView _UIDelegateForwarder] webView:webView didScrollDocumentInFrameView:[self _frameView]];
     1692        [webView _didScrollDocumentInFrameView:[self _frameView]];
    16931693    }
    16941694    _private->lastScrollPosition = origin;
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r209230 r209252  
    112112#import "WebUIDelegatePrivate.h"
    113113#import "WebUserMediaClient.h"
     114#import "WebValidationMessageClient.h"
    114115#import "WebViewGroup.h"
    115116#import "WebVisitedLinkStore.h"
     
    195196#import <WebCore/UserScript.h>
    196197#import <WebCore/UserStyleSheet.h>
     198#import <WebCore/ValidationBubble.h>
    197199#import <WebCore/WebCoreObjCExtras.h>
    198200#import <WebCore/WebCoreView.h>
     
    13121314    pageConfiguration.chromeClient = new WebChromeClient(self);
    13131315    pageConfiguration.contextMenuClient = new WebContextMenuClient(self);
     1316    // FIXME: We should enable this on iOS as well.
     1317    pageConfiguration.validationMessageClient = std::make_unique<WebValidationMessageClient>(self);
    13141318#if ENABLE(DRAG_SUPPORT)
    13151319    pageConfiguration.dragClient = new WebDragClient(self);
     
    19611965        return;
    19621966    _private->mainViewIsScrollingOrZooming = YES;
     1967
     1968    [self hideFormValidationMessage];
    19631969
    19641970    // This suspends active DOM objects like timers, but not media.
     
    43094315}
    43104316
     4317- (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem
     4318{
     4319    if ([userInterfaceItem isEqualToString:@"validationBubble"]) {
     4320        auto* validationBubble = _private->formValidationBubble.get();
     4321        String message = validationBubble ? validationBubble->message() : emptyString();
     4322        return @{ userInterfaceItem: @{ @"message": (NSString *)message } };
     4323    }
     4324
     4325    return nil;
     4326}
     4327
    43114328- (BOOL)_isSoftwareRenderable
    43124329{
     
    46284645- (void)_scaleWebView:(float)scale atOrigin:(NSPoint)origin
    46294646{
     4647    [self hideFormValidationMessage];
     4648
    46304649    _private->page->setPageScaleFactor(scale, IntPoint(origin));
    46314650}
     
    49264945{
    49274946    ResourceRequest::setHTTPPipeliningEnabled(enabled);
     4947}
     4948
     4949- (void)_didScrollDocumentInFrameView:(WebFrameView *)frameView
     4950{
     4951    [self hideFormValidationMessage];
     4952    [[self _UIDelegateForwarder] webView:self didScrollDocumentInFrameView:frameView];
    49284953}
    49294954
     
    61366161    _private->zoomMultiplier = multiplier;
    61376162    _private->zoomsTextOnly = isTextOnly;
     6163
     6164    [self hideFormValidationMessage];
    61386165
    61396166    // FIXME: It might be nice to rework this code so that _private->zoomMultiplier doesn't exist
     
    92369263    [self _clearTextIndicatorWithAnimation:TextIndicatorWindowDismissalAnimation::FadeOut];
    92379264}
     9265
    92389266#endif // PLATFORM(MAC)
     9267
     9268- (void)showFormValidationMessage:(NSString *)message withAnchorRect:(NSRect)anchorRect
     9269{
     9270    // FIXME: We should enable this on iOS as well.
     9271#if PLATFORM(MAC)
     9272    _private->formValidationBubble = std::make_unique<ValidationBubble>(self, message);
     9273    _private->formValidationBubble->showRelativeTo(enclosingIntRect([self _convertRectFromRootView:anchorRect]));
     9274#else
     9275    UNUSED_PARAM(message);
     9276    UNUSED_PARAM(anchorRect);
     9277#endif
     9278}
     9279
     9280- (void)hideFormValidationMessage
     9281{
     9282    _private->formValidationBubble = nullptr;
     9283}
    92399284
    92409285#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
  • trunk/Source/WebKit/mac/WebView/WebViewData.h

    r208452 r209252  
    4949class Page;
    5050class TextIndicatorWindow;
     51class ValidationBubble;
    5152#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
    5253class WebPlaybackSessionInterfaceMac;
     
    206207#endif // PLATFORM(MAC)
    207208
     209    std::unique_ptr<WebCore::ValidationBubble> formValidationBubble;
     210
    208211    BOOL shouldMaintainInactiveSelection;
    209212
  • trunk/Source/WebKit/mac/WebView/WebViewData.mm

    r207562 r209252  
    3838#import <WebCore/HistoryItem.h>
    3939#import <WebCore/TextIndicatorWindow.h>
     40#import <WebCore/ValidationBubble.h>
    4041#import <runtime/InitializeThreading.h>
    4142#import <wtf/MainThread.h>
     
    144145    zoomsTextOnly = NO;
    145146
    146     interactiveFormValidationEnabled = NO;
     147    interactiveFormValidationEnabled = YES;
    147148    // The default value should be synchronized with WebCore/page/Settings.cpp.
    148149    validationMessageTimerMagnification = 50;
  • trunk/Source/WebKit/mac/WebView/WebViewInternal.h

    r208452 r209252  
    301301- (NSCandidateListTouchBarItem *)candidateList;
    302302
    303 @end
     303- (void)showFormValidationMessage:(NSString *)message withAnchorRect:(NSRect)anchorRect;
     304- (void)hideFormValidationMessage;
     305
     306@end
  • trunk/Source/WebKit/mac/WebView/WebViewPrivate.h

    r208452 r209252  
    487487- (void)_updateActiveState;
    488488
     489- (void)_didScrollDocumentInFrameView:(WebFrameView *)frameView;
     490
    489491/*!
    490492    @method _registerViewClass:representationClass:forURLScheme:
     
    743745- (int)validationMessageTimerMagnification;
    744746- (void)setValidationMessageTimerMagnification:(int)newValue;
     747- (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem;
    745748
    746749// Returns YES if NSView -displayRectIgnoringOpacity:inContext: will produce a faithful representation of the content.
  • trunk/Tools/ChangeLog

    r209251 r209252  
     12016-12-02  Chris Dumez  <cdumez@apple.com>
     2
     3        [Mac][WK1] Implement new HTML interactive form validation user interface
     4        https://bugs.webkit.org/show_bug.cgi?id=164483
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add support for UIScriptController's contentsOfUserInterfaceItem("validationBubble")
     9        on Mac DRT as this is needed by the HTML form validation layout tests.
     10
     11        * DumpRenderTree/mac/UIScriptControllerMac.mm:
     12        (WTR::UIScriptController::contentsOfUserInterfaceItem):
     13
    1142016-12-02  Brady Eidson  <beidson@apple.com>
    215
  • trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm

    r208926 r209252  
    2929#import "DumpRenderTree.h"
    3030#import "UIScriptContext.h"
     31#import <JavaScriptCore/JSContext.h>
     32#import <JavaScriptCore/JSStringRefCF.h>
     33#import <JavaScriptCore/JSValue.h>
    3134#import <WebKit/WebKit.h>
    3235#import <WebKit/WebViewPrivate.h>
     
    7679JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const
    7780{
     81#if JSC_OBJC_API_ENABLED
     82    WebView *webView = [mainFrame webView];
     83    RetainPtr<CFStringRef> interfaceItemCF = adoptCF(JSStringCopyCFString(kCFAllocatorDefault, interfaceItem));
     84    NSDictionary *contentDictionary = [webView _contentsOfUserInterfaceItem:(NSString *)interfaceItemCF.get()];
     85    return JSValueToObject(m_context->jsContext(), [JSValue valueWithObject:contentDictionary inContext:[JSContext contextWithJSGlobalContextRef:m_context->jsContext()]].JSValueRef, nullptr);
     86#else
     87    UNUSED_PARAM(interfaceItem);
    7888    return nullptr;
     89#endif
    7990}
    8091
Note: See TracChangeset for help on using the changeset viewer.