Changeset 128394 in webkit


Ignore:
Timestamp:
Sep 12, 2012 6:02:29 PM (12 years ago)
Author:
tkent@chromium.org
Message:

Introduce ValidationMessageClient
https://bugs.webkit.org/show_bug.cgi?id=96238

Reviewed by Hajime Morita.

ValidationMessageClient interface is responsible to operate validation
message UI for interactive form validation. If a Page object has a
ValidtionMessageClient, ValidationMessae class uses
ValidtionMessageClient instead of Shadow DOM.

No new tests because of no behavior changes.

  • GNUmakefile.list.am: Add ValidtionMessageClient.h.
  • Target.pri: ditto.
  • WebCore.gypi: ditto.
  • WebCore.xcodeproj/project.pbxproj: ditto.
  • html/ValidationMessage.cpp:

(WebCore::ValidationMessage::~ValidationMessage):
Hide a validation message via ValidationMessageClient if it is available.
(WebCore::ValidationMessage::validationMessageClient):
A helper function to get Page::validationMessageClient.
(WebCore::ValidationMessage::updateValidationMessage):
Adding title attribute is not neeeded if ValidationMessageClient is
used. It shoudl be handled in a ValidtionMessageClient implementation.
(WebCore::ValidationMessage::setMessage):
Show a validation message via ValidationMessageClient if it is available.
(WebCore::ValidationMessage::setMessageDOMAndStartTimer):
Add an assertion that ValidationMessageClient should not be available.
(WebCore::ValidationMessage::buildBubbleTree): ditto.
(WebCore::ValidationMessage::requestToHideMessage):
Hide a validation message via ValidationMessageClient if it is available.
(WebCore::ValidationMessage::shadowTreeContains):
Always returns false if ValidationMessageClient is available, it means no Shadow DOM.
(WebCore::ValidationMessage::deleteBubbleTree):
Add an assertion that ValidationMessageClient should not be available.
(WebCore::ValidationMessage::isVisible):
Ask ValidationMessageClient for visibility if it is available.

  • html/ValidationMessage.h:

(WebCore): Add a comment.
(ValidationMessage): Add validtionMessageClient member function.

  • page/Page.cpp:

(WebCore::Page::Page): Initialize m_validationMessageClient.
(WebCore::Page::PageClients::PageClients):
Initialize validationMessageClient member with 0.
So, existing code makes Page::m_validationMessageClient 0.

  • page/Page.h:

(PageClients): Add validationMessageClient member.
(WebCore::Page::validationMessageClient):
Added. Accessor for m_validationMessageClient.
(Page): Add m_validationMessageClient.

  • page/Settings.h:

(Settings): Updated the comment for setInteractiveFormValidationEnabled.

  • page/ValidationMessageClient.h: Added.
Location:
trunk/Source/WebCore
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r128390 r128394  
     12012-09-12  Kent Tamura  <tkent@chromium.org>
     2
     3        Introduce ValidationMessageClient
     4        https://bugs.webkit.org/show_bug.cgi?id=96238
     5
     6        Reviewed by Hajime Morita.
     7
     8        ValidationMessageClient interface is responsible to operate validation
     9        message UI for interactive form validation. If a Page object has a
     10        ValidtionMessageClient, ValidationMessae class uses
     11        ValidtionMessageClient instead of Shadow DOM.
     12
     13        No new tests because of no behavior changes.
     14
     15        * GNUmakefile.list.am: Add ValidtionMessageClient.h.
     16        * Target.pri: ditto.
     17        * WebCore.gypi: ditto.
     18        * WebCore.xcodeproj/project.pbxproj: ditto.
     19
     20        * html/ValidationMessage.cpp:
     21        (WebCore::ValidationMessage::~ValidationMessage):
     22        Hide a validation message via ValidationMessageClient if it is available.
     23        (WebCore::ValidationMessage::validationMessageClient):
     24        A helper function to get Page::validationMessageClient.
     25        (WebCore::ValidationMessage::updateValidationMessage):
     26        Adding title attribute is not neeeded if ValidationMessageClient is
     27        used. It shoudl be handled in a ValidtionMessageClient implementation.
     28        (WebCore::ValidationMessage::setMessage):
     29        Show a validation message via ValidationMessageClient if it is available.
     30        (WebCore::ValidationMessage::setMessageDOMAndStartTimer):
     31        Add an assertion that ValidationMessageClient should not be available.
     32        (WebCore::ValidationMessage::buildBubbleTree): ditto.
     33        (WebCore::ValidationMessage::requestToHideMessage):
     34        Hide a validation message via ValidationMessageClient if it is available.
     35        (WebCore::ValidationMessage::shadowTreeContains):
     36        Always returns false if ValidationMessageClient is available, it means no Shadow DOM.
     37        (WebCore::ValidationMessage::deleteBubbleTree):
     38        Add an assertion that ValidationMessageClient should not be available.
     39        (WebCore::ValidationMessage::isVisible):
     40        Ask ValidationMessageClient for visibility if it is available.
     41        * html/ValidationMessage.h:
     42        (WebCore): Add a comment.
     43        (ValidationMessage): Add validtionMessageClient member function.
     44
     45        * page/Page.cpp:
     46        (WebCore::Page::Page): Initialize m_validationMessageClient.
     47        (WebCore::Page::PageClients::PageClients):
     48        Initialize validationMessageClient member with 0.
     49        So, existing code makes Page::m_validationMessageClient 0.
     50        * page/Page.h:
     51        (PageClients): Add validationMessageClient member.
     52        (WebCore::Page::validationMessageClient):
     53        Added. Accessor for m_validationMessageClient.
     54        (Page): Add m_validationMessageClient.
     55
     56        * page/Settings.h:
     57        (Settings): Updated the comment for setInteractiveFormValidationEnabled.
     58
     59        * page/ValidationMessageClient.h: Added.
     60
    1612012-09-12  Dmitry Titov  <dimich@chromium.org>
    262
  • trunk/Source/WebCore/GNUmakefile.list.am

    r128249 r128394  
    40704070        Source/WebCore/page/UserStyleSheet.h \
    40714071        Source/WebCore/page/UserStyleSheetTypes.h \
     4072        Source/WebCore/page/ValidationMessageClient.h \
    40724073        Source/WebCore/page/WebCoreKeyboardUIMode.h \
    40734074        Source/WebCore/page/WebKitAnimation.h \
  • trunk/Source/WebCore/Target.pri

    r128174 r128394  
    20132013    page/SpeechInputResultList.h \
    20142014    page/TouchAdjustment.h \
     2015    page/ValidationMessageClient.h \
    20152016    page/WebKitAnimation.h \
    20162017    page/WebKitAnimationList.h \
  • trunk/Source/WebCore/WebCore.gypi

    r128374 r128394  
    262262            'page/UserStyleSheet.h',
    263263            'page/UserStyleSheetTypes.h',
     264            'page/ValidationMessageClient.h',
    264265            'page/WebCoreKeyboardUIMode.h',
    265266            'page/WindowFeatures.h',
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r128249 r128394  
    62306230                F508246F1548D96200A119AB /* MockPagePopupDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = F508246D1548D96200A119AB /* MockPagePopupDriver.h */; };
    62316231                F5122C901547FA1B0028A93B /* PagePopupDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = F5122C8F1547FA1B0028A93B /* PagePopupDriver.h */; };
     6232                F513A3EA15FF4841001526DB /* ValidationMessageClient.h in Headers */ = {isa = PBXBuildFile; fileRef = F513A3E915FF4841001526DB /* ValidationMessageClient.h */; };
    62326233                F5142C69123F12B000F5BD4C /* LocalizedNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = F5142C68123F12B000F5BD4C /* LocalizedNumber.h */; };
    62336234                F52AD5E41534245F0059FBE6 /* EmptyClients.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F52AD5E31534245F0059FBE6 /* EmptyClients.cpp */; };
     
    1361913620                F508246D1548D96200A119AB /* MockPagePopupDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MockPagePopupDriver.h; path = testing/MockPagePopupDriver.h; sourceTree = SOURCE_ROOT; };
    1362013621                F5122C8F1547FA1B0028A93B /* PagePopupDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PagePopupDriver.h; sourceTree = "<group>"; };
     13622                F513A3E915FF4841001526DB /* ValidationMessageClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValidationMessageClient.h; sourceTree = "<group>"; };
    1362113623                F5142C68123F12B000F5BD4C /* LocalizedNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizedNumber.h; sourceTree = "<group>"; };
    1362213624                F523D23B02DE4396018635CA /* HTMLDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLDocument.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    1591115913                                BC8BF150105813BF00A40A07 /* UserStyleSheet.h */,
    1591215914                                BC8BF1591058141800A40A07 /* UserStyleSheetTypes.h */,
     15915                                F513A3E915FF4841001526DB /* ValidationMessageClient.h */,
    1591315916                                BE983D95052A2E0A00892D85 /* WebCoreKeyboardUIMode.h */,
    1591415917                                319E69AC13299BBD004AC91A /* WebKitAnimation.cpp */,
     
    2537725380                                2E3BBF081162DA1100B9409A /* UUID.h in Headers */,
    2537825381                                F5A154281279534D00D0B0C0 /* ValidationMessage.h in Headers */,
     25382                                F513A3EA15FF4841001526DB /* ValidationMessageClient.h in Headers */,
    2537925383                                15C7708D100D3C6B005BA267 /* ValidityState.h in Headers */,
    2538025384                                FD3160AF12B026F700C1A359 /* VectorMath.h in Headers */,
  • trunk/Source/WebCore/html/ValidationMessage.cpp

    r128254 r128394  
    4747#include "StyleResolver.h"
    4848#include "Text.h"
     49#include "ValidationMessageClient.h"
    4950#include <wtf/PassOwnPtr.h>
    5051
     
    6162ValidationMessage::~ValidationMessage()
    6263{
     64    if (ValidationMessageClient* client = validationMessageClient()) {
     65        client->hideValidationMessage(*m_element);
     66        return;
     67    }
     68
    6369    deleteBubbleTree();
    6470}
     
    6975}
    7076
     77ValidationMessageClient* ValidationMessage::validationMessageClient() const
     78{
     79    if (Page* page = m_element->document()->page())
     80        return page->validationMessageClient();
     81    return 0;
     82}
     83
    7184void ValidationMessage::updateValidationMessage(const String& message)
    7285{
    7386    String updatedMessage = message;
    74     // HTML5 specification doesn't ask UA to show the title attribute value
    75     // with the validationMessage. However, this behavior is same as Opera
    76     // and the specification describes such behavior as an example.
    77     const AtomicString& title = m_element->fastGetAttribute(titleAttr);
    78     if (!updatedMessage.isEmpty() && !title.isEmpty()) {
    79         updatedMessage.append('\n');
    80         updatedMessage.append(title);
     87    if (!validationMessageClient()) {
     88        // HTML5 specification doesn't ask UA to show the title attribute value
     89        // with the validationMessage. However, this behavior is same as Opera
     90        // and the specification describes such behavior as an example.
     91        const AtomicString& title = m_element->fastGetAttribute(titleAttr);
     92        if (!updatedMessage.isEmpty() && !title.isEmpty()) {
     93            updatedMessage.append('\n');
     94            updatedMessage.append(title);
     95        }
    8196    }
    8297
     
    90105void ValidationMessage::setMessage(const String& message)
    91106{
     107    if (ValidationMessageClient* client = validationMessageClient()) {
     108        client->showValidationMessage(*m_element, message);
     109        return;
     110    }
     111
    92112    // Don't modify the DOM tree in this context.
    93113    // If so, an assertion in Node::isFocusable() fails.
     
    103123void ValidationMessage::setMessageDOMAndStartTimer(Timer<ValidationMessage>*)
    104124{
     125    ASSERT(!validationMessageClient());
    105126    ASSERT(m_messageHeading);
    106127    ASSERT(m_messageBody);
     
    154175void ValidationMessage::buildBubbleTree(Timer<ValidationMessage>*)
    155176{
     177    ASSERT(!validationMessageClient());
    156178    ShadowRoot* shadowRoot = m_element->ensureUserAgentShadowRoot();
    157179
     
    200222void ValidationMessage::requestToHideMessage()
    201223{
     224    if (ValidationMessageClient* client = validationMessageClient()) {
     225        client->hideValidationMessage(*m_element);
     226        return;
     227    }
     228
    202229    // We must not modify the DOM tree in this context by the same reason as setMessage().
    203230    m_timer = adoptPtr(new Timer<ValidationMessage>(this, &ValidationMessage::deleteBubbleTree));
     
    207234bool ValidationMessage::shadowTreeContains(Node* node) const
    208235{
    209     if (!m_bubble)
     236    if (validationMessageClient() || !m_bubble)
    210237        return false;
    211238    return m_bubble->treeScope() == node->treeScope();
     
    214241void ValidationMessage::deleteBubbleTree(Timer<ValidationMessage>*)
    215242{
     243    ASSERT(!validationMessageClient());
    216244    if (m_bubble) {
    217245        m_messageHeading = 0;
     
    225253bool ValidationMessage::isVisible() const
    226254{
     255    if (ValidationMessageClient* client = validationMessageClient())
     256        return client->isValidationMessageVisible(*m_element);
    227257    return !m_message.isEmpty();
    228258}
  • trunk/Source/WebCore/html/ValidationMessage.h

    r128254 r128394  
    4343class HTMLFormControlElement;
    4444class Node;
     45class ValidationMessageClient;
    4546
     47// FIXME: We should remove the code for !validationMessageClient() when all
     48// ports supporting interactive validation switch to ValidationMessageClient.
    4649class ValidationMessage {
    4750    WTF_MAKE_NONCOPYABLE(ValidationMessage);
     
    5659private:
    5760    ValidationMessage(HTMLFormControlElement*);
     61    ValidationMessageClient* validationMessageClient() const;
    5862    void setMessage(const String&);
    5963    void setMessageDOMAndStartTimer(Timer<ValidationMessage>* = 0);
  • trunk/Source/WebCore/page/Page.cpp

    r128134 r128394  
    134134    , m_theme(RenderTheme::themeForPage(this))
    135135    , m_editorClient(pageClients.editorClient)
     136    , m_validationMessageClient(pageClients.validationMessageClient)
    136137    , m_frameCount(0)
    137138    , m_openedByDOM(false)
     
    12281229    , dragClient(0)
    12291230    , inspectorClient(0)
     1231    , validationMessageClient(0)
    12301232{
    12311233}
  • trunk/Source/WebCore/page/Page.h

    r128134 r128394  
    8686    class Settings;
    8787    class StorageNamespace;
     88    class ValidationMessageClient;
    8889
    8990    typedef uint64_t LinkHash;
     
    125126            InspectorClient* inspectorClient;
    126127            RefPtr<BackForwardList> backForwardClient;
     128            ValidationMessageClient* validationMessageClient;
    127129        };
    128130
     
    187189        PointerLockController* pointerLockController() const { return m_pointerLockController.get(); }
    188190#endif
     191        ValidationMessageClient* validationMessageClient() const { return m_validationMessageClient; }
    189192
    190193        ScrollingCoordinator* scrollingCoordinator();
     
    383386
    384387        EditorClient* m_editorClient;
     388        ValidationMessageClient* m_validationMessageClient;
    385389
    386390        int m_frameCount;
  • trunk/Source/WebCore/page/Settings.h

    r127956 r128394  
    461461        bool quantizedMemoryInfoEnabled() const { return m_quantizedMemoryInfoEnabled; }
    462462
    463         // This setting will be removed when an HTML5 compatibility issue is
    464         // resolved and WebKit implementation of interactive validation is
    465         // completed. See http://webkit.org/b/40520, http://webkit.org/b/40747,
    466         // and http://webkit.org/b/40908
     463        // This feature requires an implementation of ValidationMessageClient.
    467464        void setInteractiveFormValidationEnabled(bool flag) { m_interactiveFormValidation = flag; }
    468465        bool interactiveFormValidationEnabled() const { return m_interactiveFormValidation; }
Note: See TracChangeset for help on using the changeset viewer.