Changeset 133396 in webkit
- Timestamp:
- Nov 3, 2012 9:08:40 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r133395 r133396 1 2012-11-03 Dan Beam <dbeam@chromium.org> 2 3 Implement HTMLFormElement#requestAutocomplete and associated events 4 https://bugs.webkit.org/show_bug.cgi?id=100557 5 6 Reviewed by Adam Barth. 7 8 Adds tests for an initial implementation of the proposal for interactive autocomplete outlined in this email: 9 http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-October/037711.html 10 11 The goal of this patch is to allow web authors to call formElement.requestAutocomplete(); after subscribing 12 for autocomplete/autocompleteerror events on formElement. If the form's [autocomplete] attribute is "off" an 13 error will be dispatched. Otherwise, a request will be issued to the FrameLoaderClient. At the moment, the 14 implementation in Chrome (https://codereview.chromium.org/11270018/) will simply dispatch an error until the 15 UI on Chrome's side is built. Both autocomplete and autocompleteerror events will be dispatched asynchronously 16 after a small delay to behave consistently in all situations and implementations. 17 18 Currently the implementation is behind the feature flag REQUEST_AUTOCOMPLETE, which is disabled, so the test 19 is expected to fail. This test verifies that currently no client implements this method on HTMLFormElement 20 (HTMLFormElement#requestAutocomplete) and returns. When the chrome-side lands I'll add a success case in 21 LayoutTests/platform/chromium/fast/forms/ with the expected successful results. 22 23 * fast/forms/form-request-autocomplete-expected.txt: Added. 24 * fast/forms/form-request-autocomplete.html: Added. 25 1 26 2012-11-03 Pavel Feldman <pfeldman@chromium.org> 2 27 -
trunk/Source/WebCore/ChangeLog
r133395 r133396 1 2012-11-03 Dan Beam <dbeam@chromium.org> 2 3 Implement HTMLFormElement#requestAutocomplete and associated events 4 https://bugs.webkit.org/show_bug.cgi?id=100557 5 6 Reviewed by Adam Barth. 7 8 Implements an initial version of the proposal for interactive autocomplete outlined in this email: 9 http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-October/037711.html 10 11 The goal of this patch is to allow web authors to call formElement.requestAutocomplete(); after subscribing for 12 autocomplete/autocompleteerror events on formElement. If the form's [autocomplete] attribute is "off" an 13 error will be dispatched. Otherwise, a request will be issued to the FrameLoaderClient. At the moment, the 14 implementation in Chrome (https://codereview.chromium.org/11270018/) will simply dispatch an error until the 15 UI on Chrome's side is built. Both autocomplete and autocompleteerror events will be dispatched asynchronously 16 after a small delay to behave consistently in all situations and implementations. 17 18 Currently this is behind the feature flag REQUEST_AUTOCOMPLETE, which is disabled. 19 20 Test: fast/forms/form-request-autocomplete.html 21 22 * dom/EventNames.h: 23 (WebCore): 24 25 Added autocomplete and autocompleteerror events. The autocomplete event is dispatched after a user adds more 26 information to a form using the future UI. This is not currently dispatched in any implementation (including Chrome) 27 but will be in the future. The autocompleteerror event is dispatched when the form has [autocomplete="off"] on the 28 node being asked for an interactive autocomplete. The user agent may also dispatch this event if it doesn't implement 29 this API but has turned on the feature flag, can't currently show an autocomplete UI (e.g. running headlessly or in 30 an HTML notification, security concerns, or any other reason it desires). 31 32 * html/HTMLAttributeNames.in: 33 34 Added onautocomplete and onautocompleteerror attributes so they can be parsed when creating form elements and used 35 as event listeners. For example: 36 37 <form onautocomplete="/* when autocomplete succeeds */" autocompleteerror="/* when autocomplete fails */"> 38 39 * html/HTMLFormElement.cpp: 40 (WebCore::HTMLFormElement::HTMLFormElement): 41 (WebCore): 42 43 Added m_requestAutocompleteTimer (a timer that's used to dispatch events asynchronously) to the initializer list that 44 triggers requestAutocompleteTimerFired when it times out. 45 46 (WebCore::HTMLFormElement::requestAutocomplete): 47 48 Called when HTMLFormElement#requestAutocomplete is called from JS (also see HTMLFormElement.idl) and decides whether 49 to dispatch an error and exit early (in the case where autocomplete="off") or pass the request on to the 50 FrameLoaderClient. 51 52 (WebCore::HTMLFormElement::finishRequestAutocomplete): 53 54 Called when the request for an interactive autocomplete is finished with either a success or error result. This 55 causes an event to queue and fired after a 0 second delay. Events are owned by HTMLFormElement and reference the 56 target element (this) until fired. 57 58 (WebCore::HTMLFormElement::requestAutocompleteTimerFired): 59 60 Called when the event timer runs out to pump the queue of current events. Events are released on dispatch. 61 62 (WebCore::HTMLFormElement::parseAttribute): 63 64 Encountering onautocomplete or onautocompleteerror attributes while parsing HTMLFormElements now adds event listeners 65 for autocomplete an autocompleteerror events (respectively) to dispatch the value of the attribute as a script. 66 67 * html/HTMLFormElement.h: 68 (HTMLFormElement): 69 70 Added various methods and data members as required by the implementation. 71 72 * html/HTMLFormElement.idl: 73 74 Added the method requestAutocomplete and associated DOM event handler attributes (onautocomplete/onautocompleteerror) 75 to HTMLFormElement's public DOM API (unprefixed, as per Ian Hickson's advice). All are require the Conditional 76 REQUEST_AUTOCOMPLETE to be enabled to be activated. 77 78 * loader/EmptyClients.cpp: 79 (WebCore): 80 (WebCore::EmptyFrameLoaderClient::didRequestAutocomplete): 81 82 Added noop implementation for FrameLoader::didRequestAutocomplete. 83 84 * loader/EmptyClients.h: 85 (EmptyFrameLoaderClient): 86 87 Added FrameLoader::didRequestAutocomplete to EmptyFrameLoaderClient interface. 88 89 * loader/FrameLoaderClient.h: 90 (FrameLoaderClient): 91 92 Added noop implementation to FrameLoaderClient interface (which is implemented chromium's FrameLoaderLoaderImpl.cpp). 93 1 94 2012-11-03 Pavel Feldman <pfeldman@chromium.org> 2 95 -
trunk/Source/WebCore/dom/EventNames.h
r131372 r133396 244 244 macro(webkitdeviceproximity) \ 245 245 \ 246 macro(autocomplete) \ 247 macro(autocompleteerror) \ 248 \ 246 249 247 250 // end of DOM_EVENT_NAMES_FOR_EACH -
trunk/Source/WebCore/html/HTMLAttributeNames.in
r133268 r133396 166 166 object 167 167 onabort 168 onautocomplete 169 onautocompleteerror 168 170 onbeforecopy 169 171 onbeforecut -
trunk/Source/WebCore/html/HTMLFormElement.cpp
r133053 r133396 75 75 , m_isInResetFunction(false) 76 76 , m_wasDemoted(false) 77 #if ENABLE(REQUEST_AUTOCOMPLETE) 78 , m_requestAutocompleteTimer(this, &HTMLFormElement::requestAutocompleteTimerFired) 79 #endif 77 80 { 78 81 ASSERT(hasTagName(formTag)); … … 387 390 m_isInResetFunction = false; 388 391 } 392 393 #if ENABLE(REQUEST_AUTOCOMPLETE) 394 void HTMLFormElement::requestAutocomplete() 395 { 396 Frame* frame = document()->frame(); 397 if (!frame) 398 return; 399 400 if (!shouldAutocomplete()) { 401 finishRequestAutocomplete(AutocompleteResultError); 402 return; 403 } 404 405 StringPairVector controlNamesAndValues; 406 getTextFieldValues(controlNamesAndValues); 407 RefPtr<FormState> formState = FormState::create(this, controlNamesAndValues, document(), SubmittedByJavaScript); 408 frame->loader()->client()->didRequestAutocomplete(formState.release()); 409 } 410 411 void HTMLFormElement::finishRequestAutocomplete(AutocompleteResult result) 412 { 413 RefPtr<Event> event(Event::create(result == AutocompleteResultSuccess ? eventNames().autocompleteEvent : eventNames().autocompleteerrorEvent, false, false)); 414 event->setTarget(this); 415 m_pendingAutocompleteEvents.append(event.release()); 416 417 // Dispatch events later as this API is meant to work asynchronously in all situations and implementations. 418 if (!m_requestAutocompleteTimer.isActive()) 419 m_requestAutocompleteTimer.startOneShot(0); 420 } 421 422 void HTMLFormElement::requestAutocompleteTimerFired(Timer<HTMLFormElement>*) 423 { 424 Vector<RefPtr<Event> > pendingEvents; 425 m_pendingAutocompleteEvents.swap(pendingEvents); 426 for (size_t i = 0; i < pendingEvents.size(); ++i) 427 dispatchEvent(pendingEvents[i].release()); 428 } 429 #endif 389 430 390 431 void HTMLFormElement::parseAttribute(const Attribute& attribute) … … 409 450 else if (attribute.name() == onresetAttr) 410 451 setAttributeEventListener(eventNames().resetEvent, createAttributeEventListener(this, attribute)); 452 #if ENABLE(REQUEST_AUTOCOMPLETE) 453 else if (attribute.name() == onautocompleteAttr) 454 setAttributeEventListener(eventNames().autocompleteEvent, createAttributeEventListener(this, attribute)); 455 else if (attribute.name() == onautocompleteerrorAttr) 456 setAttributeEventListener(eventNames().autocompleteerrorEvent, createAttributeEventListener(this, attribute)); 457 #endif 411 458 else 412 459 HTMLElement::parseAttribute(attribute); -
trunk/Source/WebCore/html/HTMLFormElement.h
r130461 r133396 100 100 bool checkValidity(); 101 101 102 #if ENABLE(REQUEST_AUTOCOMPLETE) 103 enum AutocompleteResult { AutocompleteResultSuccess, AutocompleteResultError }; 104 105 void requestAutocomplete(); 106 void finishRequestAutocomplete(AutocompleteResult); 107 108 DEFINE_ATTRIBUTE_EVENT_LISTENER(autocomplete); 109 DEFINE_ATTRIBUTE_EVENT_LISTENER(autocompleteerror); 110 #endif 111 102 112 HTMLFormControlElement* elementForAlias(const AtomicString&); 103 113 void addElementAlias(HTMLFormControlElement*, const AtomicString& alias); … … 163 173 164 174 bool m_wasDemoted; 175 176 #if ENABLE(REQUEST_AUTOCOMPLETE) 177 void requestAutocompleteTimerFired(Timer<HTMLFormElement>*); 178 179 Vector<RefPtr<Event> > m_pendingAutocompleteEvents; 180 Timer<HTMLFormElement> m_requestAutocompleteTimer; 181 #endif 165 182 }; 166 183 -
trunk/Source/WebCore/html/HTMLFormElement.idl
r131172 r133396 43 43 void reset(); 44 44 boolean checkValidity(); 45 46 [Conditional=REQUEST_AUTOCOMPLETE] void requestAutocomplete(); 47 [NotEnumerable, Conditional=REQUEST_AUTOCOMPLETE] attribute EventListener onautocomplete; 48 [NotEnumerable, Conditional=REQUEST_AUTOCOMPLETE] attribute EventListener onautocompleteerror; 45 49 }; -
trunk/Source/WebCore/loader/EmptyClients.cpp
r133284 r133396 195 195 #endif 196 196 197 } 197 #if ENABLE(REQUEST_AUTOCOMPLETE) 198 void EmptyFrameLoaderClient::didRequestAutocomplete(PassRefPtr<FormState>) 199 { 200 } 201 #endif 202 203 } -
trunk/Source/WebCore/loader/EmptyClients.h
r133284 r133396 385 385 virtual void dispatchIntent(PassRefPtr<IntentRequest>) OVERRIDE; 386 386 #endif 387 388 #if ENABLE(REQUEST_AUTOCOMPLETE) 389 virtual void didRequestAutocomplete(PassRefPtr<FormState>) OVERRIDE; 390 #endif 387 391 }; 388 392 -
trunk/Source/WebCore/loader/FrameLoaderClient.h
r130977 r133396 350 350 virtual void dispatchWillStartUsingPeerConnectionHandler(RTCPeerConnectionHandler*) { } 351 351 #endif 352 353 #if ENABLE(REQUEST_AUTOCOMPLETE) 354 virtual void didRequestAutocomplete(PassRefPtr<FormState>) = 0; 355 #endif 352 356 }; 353 357 -
trunk/Source/WebKit/chromium/ChangeLog
r133338 r133396 1 2012-11-03 Dan Beam <dbeam@chromium.org> 2 3 Implement HTMLFormElement#requestAutocomplete and associated events 4 https://bugs.webkit.org/show_bug.cgi?id=100557 5 6 Reviewed by Adam Barth. 7 8 Implements an initial version of the proposal for interactive autocomplete outlined in this email: 9 http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-October/037711.html 10 11 The goal of this patch is to allow web authors to call formElement.requestAutocomplete(); after subscribing for 12 autocomplete/autocompleteerror events on formElement. If the form's [autocomplete] attribute is "off" an 13 error will be dispatched. Otherwise, a request will be issued to the FrameLoaderClient. At the moment, the 14 implementation in Chrome (https://codereview.chromium.org/11270018/) will simply dispatch an error until the 15 UI on Chrome's side is built. Both autocomplete and autocompleteerror events will be dispatched asynchronously 16 after a small delay to behave consistently in all situations and implementations. 17 18 Currently this is behind the feature flag REQUEST_AUTOCOMPLETE, which is disabled. 19 20 Test: fast/forms/form-request-autocomplete.html 21 22 * public/WebAutofillClient.h: 23 (WebKit): 24 (WebAutofillClient): 25 (WebKit::WebAutofillClient::didRequestAutocomplete): 26 27 Added WebAutofillClient::didRequestAutocomplete to chrome's public WebKit interface. 28 29 * public/WebFormElement.h: 30 31 Added an enum that matches HTMLFormElement::AutocompleteResult (and added compile time assert) and a public method 32 (WebFormElement::finishRequestAutocomplete) to WebFormElement's public interface. 33 34 * src/AssertMatchingEnums.cpp: 35 36 Added a compile time assert to guarantee the HTMLFormElement::AutocompleteResult enum matches the 37 WebFormElement::AutocompleteResult enum. 38 39 * src/FrameLoaderClientImpl.cpp: 40 (WebKit): 41 (WebKit::FrameLoaderClientImpl::didRequestAutocomplete): 42 43 Implemented the added FrameLoaderClient::didRequestAutocomplete, which simply passes through to the 44 WebAutofillClient. 45 46 * src/FrameLoaderClientImpl.h: 47 (FrameLoaderClientImpl): 48 49 Implementing FrameLoaderClient::didRequestAutocomplete. 50 51 * src/WebFormElement.cpp: 52 (WebKit::WebFormElement::finishRequestAutocomplete): 53 (WebKit): 54 55 Added WebFormElement::finishRequestAutocomplete to allow chromium's renderer a public API to call to finish the 56 autocomplete request on a WebFormElement. 57 1 58 2012-11-02 Anders Carlsson <andersca@apple.com> 2 59 -
trunk/Source/WebKit/chromium/public/WebAutofillClient.h
r114223 r133396 34 34 namespace WebKit { 35 35 36 class WebFormElement; 37 class WebFrame; 36 38 class WebInputElement; 37 39 class WebKeyboardEvent; … … 76 78 virtual void didClearAutofillSelection(const WebNode&) { } 77 79 80 // Informs the browser an interactive autocomplete has been requested. 81 virtual void didRequestAutocomplete(WebFrame*, const WebFormElement&) { } 82 78 83 // Instructs the browser to remove the Autocomplete entry specified from 79 84 // its DB. -
trunk/Source/WebKit/chromium/public/WebFormElement.h
r101122 r133396 70 70 WEBKIT_EXPORT void getFormControlElements(WebVector<WebFormControlElement>&) const; 71 71 72 enum AutocompleteResult { AutocompleteResultSuccess, AutocompleteResultError }; 73 WEBKIT_EXPORT void finishRequestAutocomplete(WebFormElement::AutocompleteResult); 74 72 75 #if WEBKIT_IMPLEMENTATION 73 76 WebFormElement(const WTF::PassRefPtr<WebCore::HTMLFormElement>&); -
trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp
r133095 r133396 49 49 #include "GeolocationError.h" 50 50 #include "GeolocationPosition.h" 51 #if ENABLE(REQUEST_AUTOCOMPLETE) 52 #include "HTMLFormElement.h" 53 #endif 51 54 #include "HTMLInputElement.h" 52 55 #include "IDBCursor.h" … … 87 90 #include "WebFileInfo.h" 88 91 #include "WebFontDescription.h" 92 #if ENABLE(REQUEST_AUTOCOMPLETE) 93 #include "WebFormElement.h" 94 #endif 89 95 #include "WebGeolocationError.h" 90 96 #include "WebGeolocationPosition.h" … … 634 640 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeAnonymous, MediaPlayerClient::Anonymous); 635 641 COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::CORSModeUseCredentials, MediaPlayerClient::UseCredentials); 642 643 #if ENABLE(REQUEST_AUTOCOMPLETE) 644 COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultSuccess, HTMLFormElement::AutocompleteResultSuccess); 645 COMPILE_ASSERT_MATCHING_ENUM(WebFormElement::AutocompleteResultError, HTMLFormElement::AutocompleteResultError); 646 #endif -
trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp
r132478 r133396 63 63 #include "Settings.h" 64 64 #include "SocketStreamHandleInternal.h" 65 #if ENABLE(REQUEST_AUTOCOMPLETE) 66 #include "WebAutofillClient.h" 67 #endif 65 68 #include "WebDOMEvent.h" 66 69 #include "WebDataSourceImpl.h" … … 1652 1655 #endif 1653 1656 1657 #if ENABLE(REQUEST_AUTOCOMPLETE) 1658 void FrameLoaderClientImpl::didRequestAutocomplete(PassRefPtr<FormState> formState) 1659 { 1660 if (m_webFrame->viewImpl() && m_webFrame->viewImpl()->autofillClient()) 1661 m_webFrame->viewImpl()->autofillClient()->didRequestAutocomplete(m_webFrame, WebFormElement(formState->form())); 1662 } 1663 #endif 1654 1664 1655 1665 } // namespace WebKit -
trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h
r130977 r133396 226 226 #endif 227 227 228 #if ENABLE(REQUEST_AUTOCOMPLETE) 229 virtual void didRequestAutocomplete(PassRefPtr<WebCore::FormState>) OVERRIDE; 230 #endif 231 228 232 private: 229 233 void makeDocumentView(); -
trunk/Source/WebKit/chromium/src/WebFormElement.cpp
r130530 r133396 103 103 } 104 104 105 void WebFormElement::finishRequestAutocomplete(WebFormElement::AutocompleteResult result) 106 { 107 #if ENABLE(REQUEST_AUTOCOMPLETE) 108 unwrap<HTMLFormElement>()->finishRequestAutocomplete(static_cast<HTMLFormElement::AutocompleteResult>(result)); 109 #endif 110 } 111 105 112 WebFormElement::WebFormElement(const PassRefPtr<HTMLFormElement>& e) 106 113 : WebElement(e)
Note: See TracChangeset
for help on using the changeset viewer.