Title: [185089] trunk
Revision
185089
Author
[email protected]
Date
2015-06-01 17:01:40 -0700 (Mon, 01 Jun 2015)

Log Message

Notify client that we began editing when text field is focused
https://bugs.webkit.org/show_bug.cgi?id=145439
<rdar://problem/21142108>

Reviewed by Anders Carlsson.

Source/WebCore:

Inform the editor client that we began editing when a text field is focused either
by being explicitly focused (programmatically or by user interaction) or implicitly
focused when the window became active.

Currently we only notify the editor client that we began editing a text field when
when a person actually changes the value of the field. And we always notify the
client that we ended editing when a text field is defocused regardless of whether
we executed a began editing callback. Moreover we notify a client that we
ended editing when the field is defocused (either explicitly or implicitly when the
window becomes inactive). Instead we should always notify the client that we began
editing when the field is focused so that this callback is symmetric with the end
editing callback.

* html/SearchInputType.cpp:
(WebCore::SearchInputType::didSetValueByUserEdit): Remove parameter for ValueChangeState,
which was used to determine whether we should notify the client that we began editing, because
we we will notify the client that editing began when the text field is focused as opposed to
when the value of text field first changes.
* html/SearchInputType.h: Ditto.
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::forwardEvent): Notify the client that we began editing when
the text field is focused.
(WebCore::TextFieldInputType::subtreeHasChanged): Update call site of didSetValueByUserEdit()
following the removal of its parameter.
(WebCore::TextFieldInputType::didSetValueByUserEdit): Ditto.
* html/TextFieldInputType.h:

Tools:

Add API test to ensure that we dispatch textFieldDid{Begin, End}Editing callbacks when
a text field is focused and defocused.

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/PlatformEfl.cmake:
* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp: Added.
(TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::didReceiveMessageFromInjectedBundle):
(TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::didFinishLoadForFrame):
(TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::setInjectedBundleClient):
(TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::setPageLoaderClient):
(TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::nullJavaScriptCallback):
(TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::executeJavaScriptAndCheckDidReceiveMessage):
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp: Added.
(TestWebKitAPI::textFieldDidBeginEditing):
(TestWebKitAPI::textFieldDidEndEditing):
(TestWebKitAPI::TextFieldDidBeginAndEndEditingEventsTest::TextFieldDidBeginAndEndEditingEventsTest):
(TestWebKitAPI::TextFieldDidBeginAndEndEditingEventsTest::didCreatePage):
* TestWebKitAPI/Tests/WebKit2/input-focus-blur.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (185088 => 185089)


--- trunk/Source/WebCore/ChangeLog	2015-06-01 23:57:39 UTC (rev 185088)
+++ trunk/Source/WebCore/ChangeLog	2015-06-02 00:01:40 UTC (rev 185089)
@@ -1,3 +1,38 @@
+2015-06-01  Daniel Bates  <[email protected]>
+
+        Notify client that we began editing when text field is focused
+        https://bugs.webkit.org/show_bug.cgi?id=145439
+        <rdar://problem/21142108>
+
+        Reviewed by Anders Carlsson.
+
+        Inform the editor client that we began editing when a text field is focused either
+        by being explicitly focused (programmatically or by user interaction) or implicitly
+        focused when the window became active.
+
+        Currently we only notify the editor client that we began editing a text field when
+        when a person actually changes the value of the field. And we always notify the
+        client that we ended editing when a text field is defocused regardless of whether
+        we executed a began editing callback. Moreover we notify a client that we
+        ended editing when the field is defocused (either explicitly or implicitly when the
+        window becomes inactive). Instead we should always notify the client that we began
+        editing when the field is focused so that this callback is symmetric with the end
+        editing callback.
+
+        * html/SearchInputType.cpp:
+        (WebCore::SearchInputType::didSetValueByUserEdit): Remove parameter for ValueChangeState,
+        which was used to determine whether we should notify the client that we began editing, because
+        we we will notify the client that editing began when the text field is focused as opposed to
+        when the value of text field first changes.
+        * html/SearchInputType.h: Ditto.
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::forwardEvent): Notify the client that we began editing when
+        the text field is focused.
+        (WebCore::TextFieldInputType::subtreeHasChanged): Update call site of didSetValueByUserEdit()
+        following the removal of its parameter.
+        (WebCore::TextFieldInputType::didSetValueByUserEdit): Ditto.
+        * html/TextFieldInputType.h:
+
 2015-06-01  Anders Carlsson  <[email protected]>
 
         WAKScrollView.h cannot be imported standalone

Modified: trunk/Source/WebCore/html/SearchInputType.cpp (185088 => 185089)


--- trunk/Source/WebCore/html/SearchInputType.cpp	2015-06-01 23:57:39 UTC (rev 185088)
+++ trunk/Source/WebCore/html/SearchInputType.cpp	2015-06-02 00:01:40 UTC (rev 185089)
@@ -183,7 +183,7 @@
     return element().fastHasAttribute(incrementalAttr);
 }
 
-void SearchInputType::didSetValueByUserEdit(ValueChangeState state)
+void SearchInputType::didSetValueByUserEdit()
 {
     if (m_cancelButton && element().renderer())
         downcast<RenderSearchField>(*element().renderer()).updateCancelButtonVisibility();
@@ -192,7 +192,7 @@
     if (searchEventsShouldBeDispatched())
         startSearchEventTimer();
 
-    TextFieldInputType::didSetValueByUserEdit(state);
+    TextFieldInputType::didSetValueByUserEdit();
 }
 
 bool SearchInputType::sizeShouldIncludeDecoration(int, int& preferredSize) const

Modified: trunk/Source/WebCore/html/SearchInputType.h (185088 => 185089)


--- trunk/Source/WebCore/html/SearchInputType.h	2015-06-01 23:57:39 UTC (rev 185088)
+++ trunk/Source/WebCore/html/SearchInputType.h	2015-06-02 00:01:40 UTC (rev 185089)
@@ -57,7 +57,7 @@
     virtual HTMLElement* resultsButtonElement() const override;
     virtual HTMLElement* cancelButtonElement() const override;
     virtual void handleKeydownEvent(KeyboardEvent*) override;
-    virtual void didSetValueByUserEdit(ValueChangeState) override;
+    virtual void didSetValueByUserEdit() override;
     virtual bool sizeShouldIncludeDecoration(int defaultSize, int& preferredSize) const override;
     virtual float decorationWidth() const override;
 

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (185088 => 185089)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2015-06-01 23:57:39 UTC (rev 185088)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2015-06-02 00:01:40 UTC (rev 185089)
@@ -206,8 +206,11 @@
                 }
 
                 capsLockStateMayHaveChanged();
-            } else if (event->type() == eventNames().focusEvent)
+            } else if (event->type() == eventNames().focusEvent) {
+                if (Frame* frame = element().document().frame())
+                    frame->editor().textFieldDidBeginEditing(&element());
                 capsLockStateMayHaveChanged();
+            }
 
             element().forwardEvent(event);
         }
@@ -482,7 +485,6 @@
 
 void TextFieldInputType::subtreeHasChanged()
 {
-    bool wasChanged = element().wasChangedSinceLastFormControlChangeEvent();
     element().setChangedSinceLastFormControlChangeEvent(true);
 
     // We don't need to call sanitizeUserInputValue() function here because
@@ -494,18 +496,15 @@
     // Recalc for :invalid change.
     element().setNeedsStyleRecalc();
 
-    didSetValueByUserEdit(wasChanged ? ValueChangeStateChanged : ValueChangeStateNone);
+    didSetValueByUserEdit();
 }
 
-void TextFieldInputType::didSetValueByUserEdit(ValueChangeState state)
+void TextFieldInputType::didSetValueByUserEdit()
 {
     if (!element().focused())
         return;
-    if (Frame* frame = element().document().frame()) {
-        if (state == ValueChangeStateNone)
-            frame->editor().textFieldDidBeginEditing(&element());
+    if (Frame* frame = element().document().frame())
         frame->editor().textDidChangeInTextField(&element());
-    }
 }
 
 void TextFieldInputType::spinButtonStepDown()

Modified: trunk/Source/WebCore/html/TextFieldInputType.h (185088 => 185089)


--- trunk/Source/WebCore/html/TextFieldInputType.h	2015-06-01 23:57:39 UTC (rev 185088)
+++ trunk/Source/WebCore/html/TextFieldInputType.h	2015-06-02 00:01:40 UTC (rev 185089)
@@ -72,11 +72,7 @@
 #endif
 
     virtual String convertFromVisibleValue(const String&) const;
-    enum ValueChangeState {
-        ValueChangeStateNone,
-        ValueChangeStateChanged
-    };
-    virtual void didSetValueByUserEdit(ValueChangeState);
+    virtual void didSetValueByUserEdit();
 
 private:
     virtual bool isKeyboardFocusable(KeyboardEvent*) const override final;

Modified: trunk/Tools/ChangeLog (185088 => 185089)


--- trunk/Tools/ChangeLog	2015-06-01 23:57:39 UTC (rev 185088)
+++ trunk/Tools/ChangeLog	2015-06-02 00:01:40 UTC (rev 185089)
@@ -1,3 +1,33 @@
+2015-06-01  Daniel Bates  <[email protected]>
+
+        Notify client that we began editing when text field is focused
+        https://bugs.webkit.org/show_bug.cgi?id=145439
+        <rdar://problem/21142108>
+
+        Reviewed by Anders Carlsson.
+
+        Add API test to ensure that we dispatch textFieldDid{Begin, End}Editing callbacks when
+        a text field is focused and defocused.
+
+        * TestWebKitAPI/CMakeLists.txt:
+        * TestWebKitAPI/PlatformEfl.cmake:
+        * TestWebKitAPI/PlatformGTK.cmake:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp: Added.
+        (TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::didReceiveMessageFromInjectedBundle):
+        (TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::didFinishLoadForFrame):
+        (TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::setInjectedBundleClient):
+        (TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::setPageLoaderClient):
+        (TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::nullJavaScriptCallback):
+        (TestWebKitAPI::WebKit2TextFieldBeginAndEditEditingTest::executeJavaScriptAndCheckDidReceiveMessage):
+        (TestWebKitAPI::TEST_F):
+        * TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp: Added.
+        (TestWebKitAPI::textFieldDidBeginEditing):
+        (TestWebKitAPI::textFieldDidEndEditing):
+        (TestWebKitAPI::TextFieldDidBeginAndEndEditingEventsTest::TextFieldDidBeginAndEndEditingEventsTest):
+        (TestWebKitAPI::TextFieldDidBeginAndEndEditingEventsTest::didCreatePage):
+        * TestWebKitAPI/Tests/WebKit2/input-focus-blur.html: Added.
+
 2015-06-01  Alex Christensen  <[email protected]>
 
         [Content Extensions] resource-type and load-type should be independent.

Modified: trunk/Tools/TestWebKitAPI/CMakeLists.txt (185088 => 185089)


--- trunk/Tools/TestWebKitAPI/CMakeLists.txt	2015-06-01 23:57:39 UTC (rev 185088)
+++ trunk/Tools/TestWebKitAPI/CMakeLists.txt	2015-06-02 00:01:40 UTC (rev 185089)
@@ -121,6 +121,7 @@
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ParentFrame_Bundle.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/UserMessage_Bundle.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillLoad_Bundle.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillSendSubmitEvent_Bundle.cpp

Modified: trunk/Tools/TestWebKitAPI/PlatformEfl.cmake (185088 => 185089)


--- trunk/Tools/TestWebKitAPI/PlatformEfl.cmake	2015-06-01 23:57:39 UTC (rev 185088)
+++ trunk/Tools/TestWebKitAPI/PlatformEfl.cmake	2015-06-02 00:01:40 UTC (rev 185089)
@@ -92,6 +92,7 @@
     ResponsivenessTimerDoesntFireEarly
     ShouldGoToBackForwardListItem
     TerminateTwice
+    TextFieldDidBeginAndEndEditing
     WKPreferences
     WKString
     WKStringJSString

Modified: trunk/Tools/TestWebKitAPI/PlatformGTK.cmake (185088 => 185089)


--- trunk/Tools/TestWebKitAPI/PlatformGTK.cmake	2015-06-01 23:57:39 UTC (rev 185088)
+++ trunk/Tools/TestWebKitAPI/PlatformGTK.cmake	2015-06-02 00:01:40 UTC (rev 185089)
@@ -97,6 +97,7 @@
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ResizeWindowAfterCrash.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ShouldGoToBackForwardListItem.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/UserMedia.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/UserMessage.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillSendSubmitEvent.cpp

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (185088 => 185089)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2015-06-01 23:57:39 UTC (rev 185088)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2015-06-02 00:01:40 UTC (rev 185089)
@@ -286,6 +286,9 @@
 		CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */; };
 		CDBFCC461A9FF49E00A7B691 /* FullscreenZoomInitialFrame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */; };
 		CE14F1A4181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */; };
+		CE3524F81B1431F60028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE3524F21B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp */; };
+		CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE3524F11B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing.cpp */; };
+		CE3524FA1B1443890028A7C5 /* input-focus-blur.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */; };
 		CEA6CF2819CCF69D0064F5A7 /* open-and-close-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */; };
 		E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
 		E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
@@ -364,6 +367,7 @@
 				9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */,
 				9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */,
 				BCBD3737125ABBEB00D2C29F /* icon.png in Copy Resources */,
+				CE3524FA1B1443890028A7C5 /* input-focus-blur.html in Copy Resources */,
 				C2CF975B16CEC71B0054E99D /* JSContextBackForwardCache1.html in Copy Resources */,
 				C2CF975A16CEC7140054E99D /* JSContextBackForwardCache2.html in Copy Resources */,
 				378E64791632707400B6C676 /* link-with-title.html in Copy Resources */,
@@ -696,6 +700,9 @@
 		CDC2C7141797089D00E627FB /* TimeRanges.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TimeRanges.cpp; sourceTree = "<group>"; };
 		CE14F1A2181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = WillPerformClientRedirectToURLCrash.html; sourceTree = "<group>"; };
 		CE32C7C718184C4900CD8C28 /* WillPerformClientRedirectToURLCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WillPerformClientRedirectToURLCrash.mm; sourceTree = "<group>"; };
+		CE3524F11B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextFieldDidBeginAndEndEditing.cpp; sourceTree = "<group>"; };
+		CE3524F21B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextFieldDidBeginAndEndEditing_Bundle.cpp; sourceTree = "<group>"; };
+		CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "input-focus-blur.html"; sourceTree = "<group>"; };
 		CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OpenAndCloseWindow.mm; sourceTree = "<group>"; };
 		CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "open-and-close-window.html"; sourceTree = "<group>"; };
 		E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheDisableWithinResourceLoadDelegate.mm; sourceTree = "<group>"; };
@@ -1012,6 +1019,8 @@
 				76734997193016DC00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad.cpp */,
 				7673499A1930182E00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp */,
 				1AE72F47173EB214006362F0 /* TerminateTwice.cpp */,
+				CE3524F11B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing.cpp */,
+				CE3524F21B142B8D0028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp */,
 				4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */,
 				BC22D31314DC689800FFB1DD /* UserMessage.cpp */,
 				BC22D31714DC68B800FFB1DD /* UserMessage_Bundle.cpp */,
@@ -1105,6 +1114,7 @@
 				26F52EB118288F0F0023D412 /* geolocationWatchPositionWithHighAccuracy.html */,
 				4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */,
 				BCBD372E125ABBE600D2C29F /* icon.png */,
+				CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */,
 				378E647816326FDF00B6C676 /* link-with-title.html */,
 				9361002814DC957B0061379D /* lots-of-iframes.html */,
 				93AF4ECF1506F123007FD57E /* lots-of-images.html */,
@@ -1398,6 +1408,7 @@
 				7CCE7F301A411B8E00447C4C /* AtomicString.cpp in Sources */,
 				7CCE7EB41A411A7E00447C4C /* AttributedString.mm in Sources */,
 				7CCE7EB51A411A7E00447C4C /* BackForwardList.mm in Sources */,
+				E40019331ACE9B88001B0A2A /* BloomFilter.cpp in Sources */,
 				7CCE7EDC1A411A9200447C4C /* CalculationValue.cpp in Sources */,
 				7CCE7EB61A411A7E00447C4C /* CancelLoadFromResourceLoadDelegate.mm in Sources */,
 				7CCE7EE71A411AE600447C4C /* CanHandleRequest.cpp in Sources */,
@@ -1467,6 +1478,7 @@
 				7CCE7F061A411AE600447C4C /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */,
 				7CCE7EDF1A411A9200447C4C /* LayoutUnit.cpp in Sources */,
 				7CCE7F381A411B8E00447C4C /* ListHashSet.cpp in Sources */,
+				37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */,
 				7CCE7EFE1A411AE600447C4C /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp in Sources */,
 				7CCE7EFF1A411AE600447C4C /* LoadCanceledNoServerRedirectCallback.cpp in Sources */,
 				7CCE7F001A411AE600447C4C /* LoadPageOnCrash.cpp in Sources */,
@@ -1541,12 +1553,11 @@
 				7CCE7F161A411AE600447C4C /* TerminateTwice.cpp in Sources */,
 				7CCE7EA91A411A1D00447C4C /* TestBrowsingContextLoadDelegate.mm in Sources */,
 				7CCE7EAA1A411A2400447C4C /* TestProtocol.mm in Sources */,
-				E40019331ACE9B88001B0A2A /* BloomFilter.cpp in Sources */,
 				7CCE7EAE1A411A3400447C4C /* TestsController.cpp in Sources */,
+				CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */,
 				7CCE7EDD1A411A9200447C4C /* TimeRanges.cpp in Sources */,
 				7CCE7ED31A411A7E00447C4C /* TypingStyleCrash.mm in Sources */,
 				7CCE7EDE1A411A9200447C4C /* URL.cpp in Sources */,
-				37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */,
 				7CCE7EB01A411A4400447C4C /* URLExtras.mm in Sources */,
 				7CCE7F271A411AF600447C4C /* UserContentController.mm in Sources */,
 				7CCE7F2D1A411B1000447C4C /* UserContentTest.mm in Sources */,
@@ -1630,6 +1641,7 @@
 				C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */,
 				51FCF7A11534B2A000104491 /* ShouldGoToBackForwardListItem_Bundle.cpp in Sources */,
 				7673499D1930C5BB00E44DF9 /* StopLoadingDuringDidFailProvisionalLoad_bundle.cpp in Sources */,
+				CE3524F81B1431F60028A7C5 /* TextFieldDidBeginAndEndEditing_Bundle.cpp in Sources */,
 				BC22D31914DC68B900FFB1DD /* UserMessage_Bundle.cpp in Sources */,
 				520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */,
 				7CFBCAE51743238F00B2BFCF /* WillLoad_Bundle.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp (0 => 185089)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing.cpp	2015-06-02 00:01:40 UTC (rev 185089)
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+#include "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+#include <wtf/StdLibExtras.h>
+
+namespace TestWebKitAPI {
+
+struct WebKit2TextFieldBeginAndEditEditingTest : public ::testing::Test {
+    std::unique_ptr<PlatformWebView> webView;
+
+    WKRetainPtr<WKStringRef> messageName;
+
+    bool didFinishLoad { false };
+    bool didReceiveMessage { false };
+
+    static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef, const void* clientInfo)
+    {
+        WebKit2TextFieldBeginAndEditEditingTest& client = *static_cast<WebKit2TextFieldBeginAndEditEditingTest*>(const_cast<void*>(clientInfo));
+        client.messageName = messageName;
+        client.didReceiveMessage = true;
+    }
+
+    static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo)
+    {
+        WebKit2TextFieldBeginAndEditEditingTest& client = *static_cast<WebKit2TextFieldBeginAndEditEditingTest*>(const_cast<void*>(clientInfo));
+        client.didFinishLoad = true;
+    }
+
+    static void setInjectedBundleClient(WKContextRef context, const void* clientInfo)
+    {
+        WKContextInjectedBundleClientV1 injectedBundleClient;
+        memset(&injectedBundleClient, 0, sizeof(injectedBundleClient));
+
+        injectedBundleClient.base.version = 1;
+        injectedBundleClient.base.clientInfo = clientInfo;
+        injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle;
+
+        WKContextSetInjectedBundleClient(context, &injectedBundleClient.base);
+    }
+
+    static void setPageLoaderClient(WKPageRef page, const void* clientInfo)
+    {
+        WKPageLoaderClientV6 loaderClient;
+        memset(&loaderClient, 0, sizeof(loaderClient));
+
+        loaderClient.base.version = 6;
+        loaderClient.base.clientInfo = clientInfo;
+        loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+
+        WKPageSetPageLoaderClient(page, &loaderClient.base);
+    }
+
+    static void nullJavaScriptCallback(WKSerializedScriptValueRef, WKErrorRef, void*)
+    {
+    }
+
+    void executeJavaScriptAndCheckDidReceiveMessage(const char* _javascript_Code, const char* expectedMessageName)
+    {
+        didReceiveMessage = false;
+        WKPageRunJavaScriptInMainFrame(webView->page(), Util::toWK(_javascript_Code).get(), 0, nullJavaScriptCallback);
+        Util::run(&didReceiveMessage);
+        EXPECT_WK_STREQ(expectedMessageName, messageName);
+    }
+
+    // From ::testing::Test
+    void SetUp() override
+    {
+        WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("TextFieldDidBeginAndEndEditingEventsTest"));
+        setInjectedBundleClient(context.get(), this);
+
+        webView = std::make_unique<PlatformWebView>(context.get());
+        setPageLoaderClient(webView->page(), this);
+
+        didFinishLoad = false;
+        didReceiveMessage = false;
+
+        WKPageLoadURL(webView->page(), adoptWK(Util::createURLForResource("input-focus-blur", "html")).get());
+        Util::run(&didFinishLoad);
+    }
+};
+
+TEST_F(WebKit2TextFieldBeginAndEditEditingTest, TextFieldDidBeginAndEndEditingEvents)
+{
+    executeJavaScriptAndCheckDidReceiveMessage("focusTextField('input')", "DidReceiveTextFieldDidBeginEditing");
+    executeJavaScriptAndCheckDidReceiveMessage("blurTextField('input')", "DidReceiveTextFieldDidEndEditing");
+}
+
+TEST_F(WebKit2TextFieldBeginAndEditEditingTest, TextFieldDidBeginAndEndEditingEventsInReadOnlyField)
+{
+    executeJavaScriptAndCheckDidReceiveMessage("focusTextField('readonly')", "DidReceiveTextFieldDidBeginEditing");
+    executeJavaScriptAndCheckDidReceiveMessage("blurTextField('readonly')", "DidReceiveTextFieldDidEndEditing");
+}
+
+} // namespace TestWebKitAPI
+
+#endif

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp (0 => 185089)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp	2015-06-02 00:01:40 UTC (rev 185089)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+#include "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "InjectedBundleTest.h"
+
+#include "PlatformUtilities.h"
+#include <WebKit/WKBundlePage.h>
+
+namespace TestWebKitAPI {
+
+class TextFieldDidBeginAndEndEditingEventsTest : public InjectedBundleTest {
+public:
+    TextFieldDidBeginAndEndEditingEventsTest(const std::string& identifier);
+
+    virtual void didCreatePage(WKBundleRef, WKBundlePageRef);
+};
+
+static InjectedBundleTest::Register<TextFieldDidBeginAndEndEditingEventsTest> registrar("TextFieldDidBeginAndEndEditingEventsTest");
+
+static void textFieldDidBeginEditing(WKBundlePageRef, WKBundleNodeHandleRef inputElement, WKBundleFrameRef, const void*)
+{
+    WKBundlePostMessage(InjectedBundleController::singleton().bundle(), Util::toWK("DidReceiveTextFieldDidBeginEditing").get(), nullptr);
+}
+
+static void textFieldDidEndEditing(WKBundlePageRef, WKBundleNodeHandleRef inputElement, WKBundleFrameRef, const void*)
+{
+    WKBundlePostMessage(InjectedBundleController::singleton().bundle(), Util::toWK("DidReceiveTextFieldDidEndEditing").get(), nullptr);
+}
+
+TextFieldDidBeginAndEndEditingEventsTest::TextFieldDidBeginAndEndEditingEventsTest(const std::string& identifier)
+    : InjectedBundleTest(identifier)
+{
+}
+
+void TextFieldDidBeginAndEndEditingEventsTest::didCreatePage(WKBundleRef bundle, WKBundlePageRef page)
+{
+    WKBundlePageFormClientV2 formClient;
+    memset(&formClient, 0, sizeof(formClient));
+
+    formClient.base.version = 2;
+    formClient.base.clientInfo = this;
+    formClient.textFieldDidBeginEditing = textFieldDidBeginEditing;
+    formClient.textFieldDidEndEditing = textFieldDidEndEditing;
+
+    WKBundlePageSetFormClient(page, &formClient.base);
+}
+
+} // namespace TestWebKitAPI
+
+#endif

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/input-focus-blur.html (0 => 185089)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/input-focus-blur.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/input-focus-blur.html	2015-06-02 00:01:40 UTC (rev 185089)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<body>
+<input id="input" type="text">
+<input id="readonly" type="text" readonly>
+<script>
+function focusTextField(id)
+{
+    document.getElementById(id).focus();
+}
+
+function blurTextField(id)
+{
+    document.getElementById(id).blur();
+}
+</script>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to