Title: [225833] trunk
Revision
225833
Author
[email protected]
Date
2017-12-12 18:52:43 -0800 (Tue, 12 Dec 2017)

Log Message

[WK] Add modern WebKit SPI to set auto fill button type and query if the auto fill button is enabled
https://bugs.webkit.org/show_bug.cgi?id=180686

Reviewed by Alex Christensen.

Source/WebKit:

* WebKit.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:
(-[WKWebProcessPlugInNodeHandle isHTMLInputElementAutoFillButtonEnabled]):
(toAutoFillButtonType):
(-[WKWebProcessPlugInNodeHandle setHTMLInputElementAutoFillButtonEnabledWithButtonType:]):
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandleInternal.h:
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandlePrivate.h:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/ClickAutoFillButton.mm:
(-[ClickAutoFillButton webProcessPlugIn:didCreateBrowserContextController:]):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (225832 => 225833)


--- trunk/Source/WebKit/ChangeLog	2017-12-13 02:49:00 UTC (rev 225832)
+++ trunk/Source/WebKit/ChangeLog	2017-12-13 02:52:43 UTC (rev 225833)
@@ -1,3 +1,18 @@
+2017-12-12  Daniel Bates  <[email protected]>
+
+        [WK] Add modern WebKit SPI to set auto fill button type and query if the auto fill button is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=180686
+
+        Reviewed by Alex Christensen.
+
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:
+        (-[WKWebProcessPlugInNodeHandle isHTMLInputElementAutoFillButtonEnabled]):
+        (toAutoFillButtonType):
+        (-[WKWebProcessPlugInNodeHandle setHTMLInputElementAutoFillButtonEnabledWithButtonType:]):
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandleInternal.h:
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandlePrivate.h:
+
 2017-12-12  John Wilander  <[email protected]>
 
         Storage Access API: Implement frame-specific access in the network storage session layer

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (225832 => 225833)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2017-12-13 02:49:00 UTC (rev 225832)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2017-12-13 02:52:43 UTC (rev 225833)
@@ -2025,6 +2025,7 @@
 		CE1A0BD51A48E6C60054EF74 /* ManagedConfigurationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1A0BCF1A48E6C60054EF74 /* ManagedConfigurationSPI.h */; };
 		CE1A0BD61A48E6C60054EF74 /* TCCSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1A0BD01A48E6C60054EF74 /* TCCSPI.h */; };
 		CE1A0BD71A48E6C60054EF74 /* TextInputSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1A0BD11A48E6C60054EF74 /* TextInputSPI.h */; };
+		CEC8F9CB1FDF5870002635E7 /* WKWebProcessPlugInNodeHandlePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = CEC8F9CA1FDF5870002635E7 /* WKWebProcessPlugInNodeHandlePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CEDA12E2152CD1AE00D9E08D /* WebAlternativeTextClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEDA12DF152CCAE800D9E08D /* WebAlternativeTextClient.cpp */; };
 		CEDA12E3152CD1B300D9E08D /* WebAlternativeTextClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CEDA12DE152CCAE800D9E08D /* WebAlternativeTextClient.h */; };
 		CEE4AE2B1A5DCF430002F49B /* UIKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CEE4AE2A1A5DCF430002F49B /* UIKitSPI.h */; };
@@ -4487,6 +4488,7 @@
 		CE1A0BCF1A48E6C60054EF74 /* ManagedConfigurationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ManagedConfigurationSPI.h; sourceTree = "<group>"; };
 		CE1A0BD01A48E6C60054EF74 /* TCCSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TCCSPI.h; sourceTree = "<group>"; };
 		CE1A0BD11A48E6C60054EF74 /* TextInputSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputSPI.h; sourceTree = "<group>"; };
+		CEC8F9CA1FDF5870002635E7 /* WKWebProcessPlugInNodeHandlePrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInNodeHandlePrivate.h; sourceTree = "<group>"; };
 		CEDA12DE152CCAE800D9E08D /* WebAlternativeTextClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAlternativeTextClient.h; sourceTree = "<group>"; };
 		CEDA12DF152CCAE800D9E08D /* WebAlternativeTextClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAlternativeTextClient.cpp; sourceTree = "<group>"; };
 		CEE4AE2A1A5DCF430002F49B /* UIKitSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIKitSPI.h; sourceTree = "<group>"; };
@@ -5498,6 +5500,7 @@
 				1F01816F1858DC1600F92884 /* WKWebProcessPlugInNodeHandle.h */,
 				1F0181701858DC1600F92884 /* WKWebProcessPlugInNodeHandle.mm */,
 				1F0181711858DC1600F92884 /* WKWebProcessPlugInNodeHandleInternal.h */,
+				CEC8F9CA1FDF5870002635E7 /* WKWebProcessPlugInNodeHandlePrivate.h */,
 				1FB00AC4185F76460019142E /* WKWebProcessPlugInPageGroup.h */,
 				1FB00AC5185F76460019142E /* WKWebProcessPlugInPageGroup.mm */,
 				1FB00AC6185F76460019142E /* WKWebProcessPlugInPageGroupInternal.h */,
@@ -9509,6 +9512,7 @@
 				1F335BC0185B84F0001A201A /* WKWebProcessPlugInLoadDelegate.h in Headers */,
 				1F7506B31859164500EC0FF7 /* WKWebProcessPlugInNodeHandle.h in Headers */,
 				1F7506B61859165700EC0FF7 /* WKWebProcessPlugInNodeHandleInternal.h in Headers */,
+				CEC8F9CB1FDF5870002635E7 /* WKWebProcessPlugInNodeHandlePrivate.h in Headers */,
 				1FB00AC7185F76460019142E /* WKWebProcessPlugInPageGroup.h in Headers */,
 				1FB00AC9185F76460019142E /* WKWebProcessPlugInPageGroupInternal.h in Headers */,
 				BC04EFFC16E65AFB00E336F0 /* WKWebProcessPlugInPrivate.h in Headers */,

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm (225832 => 225833)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm	2017-12-13 02:49:00 UTC (rev 225832)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm	2017-12-13 02:52:43 UTC (rev 225833)
@@ -28,6 +28,7 @@
 
 #import "WKSharedAPICast.h"
 #import "WKWebProcessPlugInFrameInternal.h"
+#import <WebCore/HTMLTextFormControlElement.h>
 #import <WebCore/IntRect.h>
 #import <WebKit/WebImage.h>
 
@@ -120,6 +121,30 @@
     _nodeHandle->setHTMLInputElementAutoFilled(isAutoFilled);
 }
 
+- (BOOL)isHTMLInputElementAutoFillButtonEnabled
+{
+    return _nodeHandle->isHTMLInputElementAutoFillButtonEnabled();
+}
+
+static WebCore::AutoFillButtonType toAutoFillButtonType(_WKAutoFillButtonType autoFillButtonType)
+{
+    switch (autoFillButtonType) {
+    case _WKAutoFillButtonTypeNone:
+        return WebCore::AutoFillButtonType::None;
+    case _WKAutoFillButtonTypeContacts:
+        return WebCore::AutoFillButtonType::Contacts;
+    case _WKAutoFillButtonTypeCredentials:
+        return WebCore::AutoFillButtonType::Credentials;
+    }
+    ASSERT_NOT_REACHED();
+    return WebCore::AutoFillButtonType::None;
+}
+
+- (void)setHTMLInputElementAutoFillButtonEnabledWithButtonType:(_WKAutoFillButtonType)autoFillButtonType
+{
+    _nodeHandle->setHTMLInputElementAutoFillButtonEnabled(toAutoFillButtonType(autoFillButtonType));
+}
+
 - (BOOL)HTMLInputElementIsUserEdited
 {
     return _nodeHandle->htmlInputElementLastChangeWasUserEdit();

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandleInternal.h (225832 => 225833)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandleInternal.h	2017-12-13 02:49:00 UTC (rev 225832)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandleInternal.h	2017-12-13 02:52:43 UTC (rev 225833)
@@ -23,7 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "WKWebProcessPlugInNodeHandle.h"
+#import "WKWebProcessPlugInNodeHandlePrivate.h"
 
 #if WK_API_ENABLED
 

Copied: trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandlePrivate.h (from rev 225831, trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandleInternal.h) (0 => 225833)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandlePrivate.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandlePrivate.h	2017-12-13 02:52:43 UTC (rev 225833)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 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 "WKWebProcessPlugInNodeHandle.h"
+
+#if WK_API_ENABLED
+
+typedef NS_ENUM(NSInteger, _WKAutoFillButtonType) {
+    _WKAutoFillButtonTypeNone,
+    _WKAutoFillButtonTypeCredentials,
+    _WKAutoFillButtonTypeContacts,
+} WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
+@interface WKWebProcessPlugInNodeHandle (WKPrivate)
+
+- (BOOL)isHTMLInputElementAutoFillButtonEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)setHTMLInputElementAutoFillButtonEnabledWithButtonType:(_WKAutoFillButtonType)autoFillButtonType WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
+@end
+
+#endif // WK_API_ENABLED

Modified: trunk/Tools/ChangeLog (225832 => 225833)


--- trunk/Tools/ChangeLog	2017-12-13 02:49:00 UTC (rev 225832)
+++ trunk/Tools/ChangeLog	2017-12-13 02:52:43 UTC (rev 225833)
@@ -1,3 +1,13 @@
+2017-12-12  Daniel Bates  <[email protected]>
+
+        [WK] Add modern WebKit SPI to set auto fill button type and query if the auto fill button is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=180686
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ClickAutoFillButton.mm:
+        (-[ClickAutoFillButton webProcessPlugIn:didCreateBrowserContextController:]):
+
 2017-12-12  Alex Christensen  <[email protected]>
 
         Fix possible out-of-bounds read in protocolIsInHTTPFamily

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ClickAutoFillButton.mm (225832 => 225833)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ClickAutoFillButton.mm	2017-12-13 02:49:00 UTC (rev 225832)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ClickAutoFillButton.mm	2017-12-13 02:52:43 UTC (rev 225833)
@@ -27,7 +27,6 @@
 
 #if WK_API_ENABLED
 
-#import <WebKit/WKBundleNodeHandlePrivate.h>
 #import <WebKit/WKBundlePage.h>
 #import <WebKit/WKBundlePageUIClient.h>
 #import <WebKit/WKDOMDocument.h>
@@ -38,6 +37,7 @@
 #import <WebKit/WKWebProcessPlugIn.h>
 #import <WebKit/WKWebProcessPlugInBrowserContextControllerPrivate.h>
 #import <WebKit/WKWebProcessPlugInFrame.h>
+#import <WebKit/WKWebProcessPlugInNodeHandlePrivate.h>
 #import <WebKit/WKWebProcessPlugInScriptWorld.h>
 
 void didClickAutoFillButton(WKBundlePageRef, WKBundleNodeHandleRef, WKTypeRef* userData, const void *)
@@ -61,9 +61,12 @@
     WKDOMDocument *document = [browserContextController mainFrameDocument];
     WKDOMElement *inputElement = [document createElement:@"input"];
     [[document body] appendChild:inputElement];
-    WKBundleNodeHandleRef node = [inputElement _copyBundleNodeHandleRef];
-    WKBundleNodeHandleSetHTMLInputElementAutofilled(node, true);
-    WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabledWithButtonType(node, kWKAutoFillButtonTypeContacts);
+
+    auto *jsContext = [[browserContextController mainFrame] jsContextForWorld:[WKWebProcessPlugInScriptWorld normalWorld]];
+    auto *jsValue = [jsContext evaluateScript:@"document.querySelector('input')"];
+    auto* nodeHandle = [WKWebProcessPlugInNodeHandle nodeHandleWithJSValue:jsValue inContext:jsContext];
+    [nodeHandle setHTMLInputElementIsAutoFilled:YES];
+    [nodeHandle setHTMLInputElementAutoFillButtonEnabledWithButtonType:_WKAutoFillButtonTypeContacts];
     [[[browserContextController mainFrame] jsContextForWorld:[WKWebProcessPlugInScriptWorld normalWorld]] evaluateScript:@"alert('ready for click!')"];
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to