Title: [129443] trunk/Source
Revision
129443
Author
[email protected]
Date
2012-09-24 19:16:07 -0700 (Mon, 24 Sep 2012)

Log Message

[Chromium] Implement ValidationMessageClient for Chromium
https://bugs.webkit.org/show_bug.cgi?id=97167

Reviewed by Hajime Morita.

Source/WebCore:

* page/ValidationMessageClient.h:
Add forward declaration for WTF::String.

Source/WebKit/chromium:

Introduce ValidationMessageClientImpl. However actual popup
implementation should be done in WebViewClient.

* WebKit.gyp: Add ValidationMessageClientImpl.{cpp,h}.
* public/WebViewClient.h:
(WebKit::WebViewClient::showValidationMessage): Added.
(WebKit::WebViewClient::hideValidationMessage): Added.
* src/ValidationMessageClientImpl.cpp: Added.
(WebKit::ValidationMessageClientImpl::ValidationMessageClientImpl):
(WebKit::ValidationMessageClientImpl::create):
(WebKit::ValidationMessageClientImpl::~ValidationMessageClientImpl):
Make sure that a popup is closed.
(WebKit::ValidationMessageClientImpl::showValidationMessage):
Implementataion of ValidationMessageClient::showValidationMessage.
minimumSecondToShowValidationMessage and secondPerCharacter are same as
the corresponding values in the current Shadow DOM implementation.
(WebKit::ValidationMessageClientImpl::hideValidationMessage):
Implementataion of ValidationMessageClient::hideValidationMessage.
(WebKit::ValidationMessageClientImpl::isValidationMessageVisible):
Implementataion of ValidationMessageClient::isValidationMessageVisible.
(WebKit::ValidationMessageClientImpl::hideCurrentValidationMessage):
This is a callback function for the timer.
* src/ValidationMessageClientImpl.h: Added.

* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::WebViewImpl):
 - Initialize m_validationMessage.
 - Add a comment for PageClients.
* src/WebViewImpl.h:
Add m_validationMessage.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (129442 => 129443)


--- trunk/Source/WebCore/ChangeLog	2012-09-25 02:07:14 UTC (rev 129442)
+++ trunk/Source/WebCore/ChangeLog	2012-09-25 02:16:07 UTC (rev 129443)
@@ -1,3 +1,13 @@
+2012-09-24  Kent Tamura  <[email protected]>
+
+        [Chromium] Implement ValidationMessageClient for Chromium
+        https://bugs.webkit.org/show_bug.cgi?id=97167
+
+        Reviewed by Hajime Morita.
+
+        * page/ValidationMessageClient.h:
+        Add forward declaration for WTF::String.
+
 2012-09-24  Yoshifumi Inoue  <[email protected]>
 
         [Forms] DateTimeEditElement should return string value for ease of implementing other date/time input types.

Modified: trunk/Source/WebCore/page/ValidationMessageClient.h (129442 => 129443)


--- trunk/Source/WebCore/page/ValidationMessageClient.h	2012-09-25 02:07:14 UTC (rev 129442)
+++ trunk/Source/WebCore/page/ValidationMessageClient.h	2012-09-25 02:16:07 UTC (rev 129443)
@@ -26,6 +26,8 @@
 #ifndef ValidationMessageClient_h
 #define ValidationMessageClient_h
 
+#include <wtf/Forward.h>
+
 namespace WebCore {
 
 class Element;

Modified: trunk/Source/WebKit/chromium/ChangeLog (129442 => 129443)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-09-25 02:07:14 UTC (rev 129442)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-09-25 02:16:07 UTC (rev 129443)
@@ -1,3 +1,41 @@
+2012-09-24  Kent Tamura  <[email protected]>
+
+        [Chromium] Implement ValidationMessageClient for Chromium
+        https://bugs.webkit.org/show_bug.cgi?id=97167
+
+        Reviewed by Hajime Morita.
+
+        Introduce ValidationMessageClientImpl. However actual popup
+        implementation should be done in WebViewClient.
+
+        * WebKit.gyp: Add ValidationMessageClientImpl.{cpp,h}.
+        * public/WebViewClient.h:
+        (WebKit::WebViewClient::showValidationMessage): Added.
+        (WebKit::WebViewClient::hideValidationMessage): Added.
+        * src/ValidationMessageClientImpl.cpp: Added.
+        (WebKit::ValidationMessageClientImpl::ValidationMessageClientImpl):
+        (WebKit::ValidationMessageClientImpl::create):
+        (WebKit::ValidationMessageClientImpl::~ValidationMessageClientImpl):
+        Make sure that a popup is closed.
+        (WebKit::ValidationMessageClientImpl::showValidationMessage):
+        Implementataion of ValidationMessageClient::showValidationMessage.
+        minimumSecondToShowValidationMessage and secondPerCharacter are same as
+        the corresponding values in the current Shadow DOM implementation.
+        (WebKit::ValidationMessageClientImpl::hideValidationMessage):
+        Implementataion of ValidationMessageClient::hideValidationMessage.
+        (WebKit::ValidationMessageClientImpl::isValidationMessageVisible):
+        Implementataion of ValidationMessageClient::isValidationMessageVisible.
+        (WebKit::ValidationMessageClientImpl::hideCurrentValidationMessage):
+        This is a callback function for the timer.
+        * src/ValidationMessageClientImpl.h: Added.
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::WebViewImpl):
+         - Initialize m_validationMessage.
+         - Add a comment for PageClients.
+        * src/WebViewImpl.h:
+        Add m_validationMessage.
+
 2012-09-24  Mihai Parparita  <[email protected]>
 
         [Chromium] Remove WebRuntimeFeatures::{enablePushState,isPushStateEnabled}

Modified: trunk/Source/WebKit/chromium/WebKit.gyp (129442 => 129443)


--- trunk/Source/WebKit/chromium/WebKit.gyp	2012-09-25 02:07:14 UTC (rev 129442)
+++ trunk/Source/WebKit/chromium/WebKit.gyp	2012-09-25 02:16:07 UTC (rev 129443)
@@ -467,6 +467,8 @@
                 'src/TextFieldDecoratorImpl.cpp',
                 'src/UserMediaClientImpl.h',
                 'src/UserMediaClientImpl.cpp',
+                'src/ValidationMessageClientImpl.cpp',
+                'src/ValidationMessageClientImpl.h',
                 'src/WebTextCheckingCompletionImpl.h',
                 'src/WebTextCheckingCompletionImpl.cpp',
                 'src/WebTextCheckingResult.cpp',

Modified: trunk/Source/WebKit/chromium/public/WebViewClient.h (129442 => 129443)


--- trunk/Source/WebKit/chromium/public/WebViewClient.h	2012-09-25 02:07:14 UTC (rev 129442)
+++ trunk/Source/WebKit/chromium/public/WebViewClient.h	2012-09-25 02:16:07 UTC (rev 129443)
@@ -293,6 +293,13 @@
     // Return true to swallow the input event if the embedder will start a disambiguation popup
     virtual bool didTapMultipleTargets(const WebGestureEvent&, const WebVector<WebRect>& targetRects) { return false; }
 
+    // Show a notification popup for the specified form vaidation messages
+    // besides the anchor rectangle. An implementation of this function should
+    // not hide the popup until hideValidationMessage call.
+    virtual void showValidationMessage(const WebRect& anchorInScreen, const WebString& mainText, const WebString& supplementalText, WebTextDirection hint) { }
+    // Hide notifation popup for form validation messages.
+    virtual void hideValidationMessage() { }
+
     // Session history -----------------------------------------------------
 
     // Tells the embedder to navigate back or forward in session history by

Added: trunk/Source/WebKit/chromium/src/ValidationMessageClientImpl.cpp (0 => 129443)


--- trunk/Source/WebKit/chromium/src/ValidationMessageClientImpl.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/src/ValidationMessageClientImpl.cpp	2012-09-25 02:16:07 UTC (rev 129443)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2012 Google 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"
+#include "ValidationMessageClientImpl.h"
+
+#include "Element.h"
+#include "FrameView.h"
+#include "RenderObject.h"
+#include "WebTextDirection.h"
+#include "WebViewClient.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+ValidationMessageClientImpl::ValidationMessageClientImpl(WebViewClient& client)
+    : m_client(client)
+    , m_currentAnchor(0)
+    , m_timer(this, &ValidationMessageClientImpl::hideCurrentValidationMessage)
+{
+}
+
+PassOwnPtr<ValidationMessageClientImpl> ValidationMessageClientImpl::create(WebViewClient& client)
+{
+    return adoptPtr(new ValidationMessageClientImpl(client));
+}
+
+ValidationMessageClientImpl::~ValidationMessageClientImpl()
+{
+    if (m_currentAnchor)
+        hideValidationMessage(*m_currentAnchor);
+}
+
+void ValidationMessageClientImpl::showValidationMessage(const Element& anchor, const String& message)
+{
+    if (message.isEmpty()) {
+        hideValidationMessage(anchor);
+        return;
+    }
+    if (!anchor.renderBox())
+        return;
+    if (m_currentAnchor)
+        hideValidationMessage(*m_currentAnchor);
+    m_currentAnchor = &anchor;
+    IntRect anchorInScreen = anchor.document()->view()->contentsToScreen(anchor.pixelSnappedBoundingBox());
+    WebTextDirection dir = anchor.renderer()->style()->direction() == RTL ? WebTextDirectionRightToLeft : WebTextDirectionLeftToRight;
+    m_client.showValidationMessage(anchorInScreen, message, anchor.fastGetAttribute(HTMLNames::titleAttr), dir);
+
+    const double minimumSecondToShowValidationMessage = 5.0;
+    const double secondPerCharacter = 0.05;
+    m_timer.startOneShot(std::max(minimumSecondToShowValidationMessage, message.length() * secondPerCharacter));
+}
+
+void ValidationMessageClientImpl::hideValidationMessage(const Element& anchor)
+{
+    if (!m_currentAnchor || !isValidationMessageVisible(anchor))
+        return;
+    m_timer.stop();
+    m_client.hideValidationMessage();
+    m_currentAnchor = 0;
+}
+
+bool ValidationMessageClientImpl::isValidationMessageVisible(const Element& anchor)
+{
+    return m_currentAnchor == &anchor;
+}
+
+void ValidationMessageClientImpl::hideCurrentValidationMessage(Timer<ValidationMessageClientImpl>*)
+{
+    ASSERT(m_currentAnchor);
+    hideValidationMessage(*m_currentAnchor);
+}
+
+}

Copied: trunk/Source/WebKit/chromium/src/ValidationMessageClientImpl.h (from rev 129442, trunk/Source/WebCore/page/ValidationMessageClient.h) (0 => 129443)


--- trunk/Source/WebKit/chromium/src/ValidationMessageClientImpl.h	                        (rev 0)
+++ trunk/Source/WebKit/chromium/src/ValidationMessageClientImpl.h	2012-09-25 02:16:07 UTC (rev 129443)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Google 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.
+ */
+
+#ifndef ValidationMessageClientImpl_h
+#define ValidationMessageClientImpl_h
+
+#include "Timer.h"
+#include "ValidationMessageClient.h"
+
+namespace WebKit {
+
+class WebViewClient;
+
+class ValidationMessageClientImpl : public WebCore::ValidationMessageClient {
+public:
+    static PassOwnPtr<ValidationMessageClientImpl> create(WebViewClient&);
+    virtual ~ValidationMessageClientImpl();
+
+private:
+    explicit ValidationMessageClientImpl(WebViewClient&);
+    void hideCurrentValidationMessage(WebCore::Timer<ValidationMessageClientImpl>*);
+
+    virtual void showValidationMessage(const WebCore::Element& anchor, const String& message) OVERRIDE;
+    virtual void hideValidationMessage(const WebCore::Element& anchor) OVERRIDE;
+    virtual bool isValidationMessageVisible(const WebCore::Element& anchor) OVERRIDE;
+
+    WebViewClient& m_client;
+    const WebCore::Element* m_currentAnchor;
+    WebCore::Timer<ValidationMessageClientImpl> m_timer;
+};
+
+}
+
+#endif

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (129442 => 129443)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-09-25 02:07:14 UTC (rev 129442)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-09-25 02:16:07 UTC (rev 129443)
@@ -120,6 +120,7 @@
 #include "TextIterator.h"
 #include "Timer.h"
 #include "TraceEvent.h"
+#include "ValidationMessageClientImpl.h"
 #include "WebAccessibilityObject.h"
 #include "WebActiveWheelFlingParameters.h"
 #include "WebAutofillClient.h"
@@ -436,6 +437,7 @@
     , m_navigatorContentUtilsClient(NavigatorContentUtilsClientImpl::create(this))
 #endif
     , m_flingModifier(0)
+    , m_validationMessage(ValidationMessageClientImpl::create(*client))
 {
     // WebKit/win/WebView.cpp does the same thing, except they call the
     // KJS specific wrapper around this method. We need to have threading
@@ -450,6 +452,7 @@
     pageClients.dragClient = &m_dragClientImpl;
     pageClients.inspectorClient = &m_inspectorClientImpl;
     pageClients.backForwardClient = BackForwardListChromium::create(this);
+    // FIXME: Set pageClients.validationMessageClient when Chromium-side implementation is done.
 
     m_page = adoptPtr(new Page(pageClients));
 #if ENABLE(MEDIA_STREAM)

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (129442 => 129443)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-09-25 02:07:14 UTC (rev 129442)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-09-25 02:16:07 UTC (rev 129443)
@@ -99,6 +99,7 @@
 class SpeechInputClientImpl;
 class SpeechRecognitionClientProxy;
 class UserMediaClientImpl;
+class ValidationMessageClientImpl;
 class WebAccessibilityObject;
 class WebCompositorImpl;
 class WebDevToolsAgentClient;
@@ -862,6 +863,7 @@
 #if ENABLE(GESTURE_EVENTS)
     OwnPtr<LinkHighlight> m_linkHighlight;
 #endif
+    OwnPtr<ValidationMessageClientImpl> m_validationMessage;
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to