Title: [112984] trunk/Source/WebKit/chromium
Revision
112984
Author
[email protected]
Date
2012-04-02 21:24:37 -0700 (Mon, 02 Apr 2012)

Log Message

[Chromium] Add WebKit API for WebCore::TextFieldDecorator
https://bugs.webkit.org/show_bug.cgi?id=82143

Reviewed by Dimitri Glazkov.

Expose WebCore::TextFieldDecorator as
WebKit::WebTextFieldDecoratorClient. This change add capability to add
decoration buttons to text field <input> elements.

* WebKit.gyp: Add new files.
* public/WebTextFieldDecoratorClient.h: Added.
* public/WebView.h:
(WebKit): Add addTextFieldDecoratorClient().
* src/ChromeClientImpl.cpp:
(WebKit::ChromeClientImpl::willAddTextFieldDecorationsTo):
Calls willAddDecorationTo() of TextFieldDecorator objects owned by WebViewImpl.
(WebKit::ChromeClientImpl::addTextFieldDecorationsTo):
Apply TextFieldDecorationElement::decorate() for the specified input element.
* src/ChromeClientImpl.h:
(ChromeClientImpl): Add new function declarations.
* src/TextFieldDecoratorImpl.cpp:
Added. This is a bridge of WebCore::TextFieldDecorator and
WebKit::WebTextFieldDecoratorClient. This owns CachedImage objects
specfied by WebTextFieldDecoratorClient.
(WebKit::TextFieldDecoratorImpl::TextFieldDecoratorImpl):
(WebKit::TextFieldDecoratorImpl::create):
(WebKit::TextFieldDecoratorImpl::~TextFieldDecoratorImpl):
(WebKit::TextFieldDecoratorImpl::willAddDecorationTo):
(WebKit::TextFieldDecoratorImpl::imageForNormalState):
(WebKit::TextFieldDecoratorImpl::imageForDisabledState):
(WebKit::TextFieldDecoratorImpl::imageForReadonlyState):
(WebKit::TextFieldDecoratorImpl::handleClick):
(WebKit::TextFieldDecoratorImpl::willDetach):
* src/TextFieldDecoratorImpl.h: Added.
(TextFieldDecoratorImpl):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::addTextFieldDecoratorClient):
Add implementation of WebView::addTextFieldDecoratorClient().
* src/WebViewImpl.h:
WebViewImpl owns a vector of TextFieldDecoratorImpl.
(WebViewImpl):
(WebKit::WebViewImpl::textFieldDecorators):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (112983 => 112984)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-04-03 04:14:44 UTC (rev 112983)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-04-03 04:24:37 UTC (rev 112984)
@@ -1,3 +1,48 @@
+2012-04-02  Kent Tamura  <[email protected]>
+
+        [Chromium] Add WebKit API for WebCore::TextFieldDecorator
+        https://bugs.webkit.org/show_bug.cgi?id=82143
+
+        Reviewed by Dimitri Glazkov.
+
+        Expose WebCore::TextFieldDecorator as
+        WebKit::WebTextFieldDecoratorClient. This change add capability to add
+        decoration buttons to text field <input> elements.
+
+        * WebKit.gyp: Add new files.
+        * public/WebTextFieldDecoratorClient.h: Added.
+        * public/WebView.h:
+        (WebKit): Add addTextFieldDecoratorClient().
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::willAddTextFieldDecorationsTo):
+        Calls willAddDecorationTo() of TextFieldDecorator objects owned by WebViewImpl.
+        (WebKit::ChromeClientImpl::addTextFieldDecorationsTo):
+        Apply TextFieldDecorationElement::decorate() for the specified input element.
+        * src/ChromeClientImpl.h:
+        (ChromeClientImpl): Add new function declarations.
+        * src/TextFieldDecoratorImpl.cpp:
+        Added. This is a bridge of WebCore::TextFieldDecorator and
+        WebKit::WebTextFieldDecoratorClient. This owns CachedImage objects
+        specfied by WebTextFieldDecoratorClient.
+        (WebKit::TextFieldDecoratorImpl::TextFieldDecoratorImpl):
+        (WebKit::TextFieldDecoratorImpl::create):
+        (WebKit::TextFieldDecoratorImpl::~TextFieldDecoratorImpl):
+        (WebKit::TextFieldDecoratorImpl::willAddDecorationTo):
+        (WebKit::TextFieldDecoratorImpl::imageForNormalState):
+        (WebKit::TextFieldDecoratorImpl::imageForDisabledState):
+        (WebKit::TextFieldDecoratorImpl::imageForReadonlyState):
+        (WebKit::TextFieldDecoratorImpl::handleClick):
+        (WebKit::TextFieldDecoratorImpl::willDetach):
+        * src/TextFieldDecoratorImpl.h: Added.
+        (TextFieldDecoratorImpl):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::addTextFieldDecoratorClient):
+        Add implementation of WebView::addTextFieldDecoratorClient().
+        * src/WebViewImpl.h:
+        WebViewImpl owns a vector of TextFieldDecoratorImpl.
+        (WebViewImpl):
+        (WebKit::WebViewImpl::textFieldDecorators):
+
 2012-04-02  Dana Jansens  <[email protected]>
 
         [chromium] Remove SkCanvas::LayerIter use from OpaqueRegionSkia

Modified: trunk/Source/WebKit/chromium/WebKit.gyp (112983 => 112984)


--- trunk/Source/WebKit/chromium/WebKit.gyp	2012-04-03 04:14:44 UTC (rev 112983)
+++ trunk/Source/WebKit/chromium/WebKit.gyp	2012-04-03 04:24:37 UTC (rev 112984)
@@ -259,6 +259,7 @@
                 'public/WebTextCheckingCompletion.h',
                 'public/WebTextCheckingResult.h',
                 'public/WebTextDirection.h',
+                'public/WebTextFieldDecoratorClient.h',
                 'public/WebTextInputType.h',
                 'public/WebTextRun.h',
                 'public/WebURLLoaderOptions.h',
@@ -463,6 +464,8 @@
                 'src/StorageInfoChromium.cpp',
                 'src/StorageNamespaceProxy.cpp',
                 'src/StorageNamespaceProxy.h',
+                'src/TextFieldDecoratorImpl.h',
+                'src/TextFieldDecoratorImpl.cpp',
                 'src/UserMediaClientImpl.h',
                 'src/UserMediaClientImpl.cpp',
                 'src/WebTextCheckingCompletionImpl.h',

Added: trunk/Source/WebKit/chromium/public/WebTextFieldDecoratorClient.h (0 => 112984)


--- trunk/Source/WebKit/chromium/public/WebTextFieldDecoratorClient.h	                        (rev 0)
+++ trunk/Source/WebKit/chromium/public/WebTextFieldDecoratorClient.h	2012-04-03 04:24:37 UTC (rev 112984)
@@ -0,0 +1,71 @@
+/*
+ * 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 WebTextFieldDecoratorClient_h
+#define WebTextFieldDecoratorClient_h
+
+#include "platform/WebCString.h"
+
+namespace WebKit {
+
+class WebInputElement;
+
+class WebTextFieldDecoratorClient {
+public:
+    // The function should return true if the specified input element should
+    // have a decoration icon. This function is called whenever a text field is
+    // created, and should not take much time.
+    virtual bool shouldAddDecorationTo(const WebInputElement&) = 0;
+
+    // Image resource name for the normal state. The image is stretched to
+    // font-size x font-size square. The function must return an existing
+    // resource name.
+    virtual WebCString imageNameForNormalState() = 0;
+    // Image resource name for the disabled state. If this function returns an
+    // empty string, imageNameForNormalState() is used even for the disabled
+    // state.
+    virtual WebCString imageNameForDisabledState() = 0;
+    // Image resource name for the disabled state. If this function returns an
+    // empty string, the image same as imageNameForDisabledState() is used.
+    virtual WebCString imageNameForReadOnlyState() = 0;
+
+    // This is called when the decoration icon is clicked.
+    virtual void handleClick(WebInputElement&) = 0;
+    // This is called when the input element loses its renderer. An
+    // implementation of this function should not do something which updates
+    // state of WebKit objects.
+    virtual void willDetach(const WebInputElement&) = 0;
+
+    virtual ~WebTextFieldDecoratorClient() { }
+};
+
+}
+
+#endif // WebTextFieldDecoratorClient_h

Modified: trunk/Source/WebKit/chromium/public/WebView.h (112983 => 112984)


--- trunk/Source/WebKit/chromium/public/WebView.h	2012-04-03 04:14:44 UTC (rev 112983)
+++ trunk/Source/WebKit/chromium/public/WebView.h	2012-04-03 04:24:37 UTC (rev 112984)
@@ -53,6 +53,7 @@
 class WebSettings;
 class WebSpellCheckClient;
 class WebString;
+class WebTextFieldDecoratorClient;
 class WebViewClient;
 struct WebActiveWheelFlingParameters;
 struct WebMediaPlayerAction;
@@ -104,6 +105,7 @@
     virtual void setDevToolsAgentClient(WebDevToolsAgentClient*) = 0;
     virtual void setPermissionClient(WebPermissionClient*) = 0;
     virtual void setSpellCheckClient(WebSpellCheckClient*) = 0;
+    virtual void addTextFieldDecoratorClient(WebTextFieldDecoratorClient*) = 0;
 
 
     // Options -------------------------------------------------------------

Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp (112983 => 112984)


--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2012-04-03 04:14:44 UTC (rev 112983)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp	2012-04-03 04:24:37 UTC (rev 112984)
@@ -52,6 +52,7 @@
 #include "FrameView.h"
 #include "Geolocation.h"
 #include "GraphicsLayer.h"
+#include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HitTestResult.h"
 #include "Icon.h"
@@ -68,6 +69,7 @@
 #include "SearchPopupMenuChromium.h"
 #include "SecurityOrigin.h"
 #include "Settings.h"
+#include "TextFieldDecorationElement.h"
 #if USE(V8)
 #include "V8Proxy.h"
 #endif
@@ -985,6 +987,29 @@
     return adoptRef(new SearchPopupMenuChromium(client));
 }
 
+bool ChromeClientImpl::willAddTextFieldDecorationsTo(HTMLInputElement* input)
+{
+    ASSERT(input);
+    const Vector<OwnPtr<TextFieldDecorator> >& decorators = m_webView->textFieldDecorators();
+    for (unsigned i = 0; i < decorators.size(); ++i) {
+        if (decorators[i]->willAddDecorationTo(input))
+            return true;
+    }
+    return false;
+}
+
+void ChromeClientImpl::addTextFieldDecorationsTo(HTMLInputElement* input)
+{
+    ASSERT(willAddTextFieldDecorationsTo(input));
+    const Vector<OwnPtr<TextFieldDecorator> >& decorators = m_webView->textFieldDecorators();
+    for (unsigned i = 0; i < decorators.size(); ++i) {
+        if (!decorators[i]->willAddDecorationTo(input))
+            continue;
+        RefPtr<TextFieldDecorationElement> decoration = TextFieldDecorationElement::create(input->document(), decorators[i].get());
+        decoration->decorate(input);
+    }
+}
+
 bool ChromeClientImpl::shouldRunModalDialogDuringPageDismissal(const DialogType& dialogType, const String& dialogMessage, FrameLoader::PageDismissalType dismissalType) const
 {
     const char* kDialogs[] = {"alert", "confirm", "prompt", "showModalDialog"};

Modified: trunk/Source/WebKit/chromium/src/ChromeClientImpl.h (112983 => 112984)


--- trunk/Source/WebKit/chromium/src/ChromeClientImpl.h	2012-04-03 04:14:44 UTC (rev 112983)
+++ trunk/Source/WebKit/chromium/src/ChromeClientImpl.h	2012-04-03 04:24:37 UTC (rev 112984)
@@ -195,6 +195,8 @@
     virtual bool hasOpenedPopup() const OVERRIDE;
     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
     virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
+    virtual bool willAddTextFieldDecorationsTo(WebCore::HTMLInputElement*) OVERRIDE;
+    virtual void addTextFieldDecorationsTo(WebCore::HTMLInputElement*) OVERRIDE;
 
     virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, WebCore::FrameLoader::PageDismissalType) const;
 

Added: trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.cpp (0 => 112984)


--- trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.cpp	2012-04-03 04:24:37 UTC (rev 112984)
@@ -0,0 +1,118 @@
+/*
+ * 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "TextFieldDecoratorImpl.h"
+
+#include "CachedImage.h"
+#include "HTMLInputElement.h"
+#include "WebInputElement.h"
+#include "WebTextFieldDecoratorClient.h"
+
+namespace WebKit {
+
+using namespace WebCore;
+
+inline TextFieldDecoratorImpl::TextFieldDecoratorImpl(WebTextFieldDecoratorClient* client)
+    : m_client(client)
+{
+    ASSERT(client);
+}
+
+PassOwnPtr<TextFieldDecoratorImpl> TextFieldDecoratorImpl::create(WebTextFieldDecoratorClient* client)
+{
+    return adoptPtr(new TextFieldDecoratorImpl(client));
+}
+
+TextFieldDecoratorImpl::~TextFieldDecoratorImpl()
+{
+}
+
+bool TextFieldDecoratorImpl::willAddDecorationTo(HTMLInputElement* input)
+{
+    ASSERT(input);
+    return m_client->shouldAddDecorationTo(WebInputElement(input));
+}
+
+CachedImage* TextFieldDecoratorImpl::imageForNormalState()
+{
+    if (!m_cachedImageForNormalState) {
+        WebCString imageName = m_client->imageNameForNormalState();
+        ASSERT(!imageName.isEmpty());
+        RefPtr<Image> image = Image::loadPlatformResource(imageName.data());
+        m_cachedImageForNormalState = new CachedImage(image.get());
+        // The CachedImage owns a RefPtr to the Image.
+    }
+    return m_cachedImageForNormalState.get();
+}
+
+CachedImage* TextFieldDecoratorImpl::imageForDisabledState()
+{
+    if (!m_cachedImageForDisabledState) {
+        WebCString imageName = m_client->imageNameForDisabledState();
+        if (imageName.isEmpty())
+            m_cachedImageForDisabledState = imageForNormalState();
+        else {
+            RefPtr<Image> image = Image::loadPlatformResource(imageName.data());
+            m_cachedImageForDisabledState = new CachedImage(image.get());
+        }
+    }
+    return m_cachedImageForDisabledState.get();
+}
+
+CachedImage* TextFieldDecoratorImpl::imageForReadonlyState()
+{
+    if (!m_cachedImageForReadonlyState) {
+        WebCString imageName = m_client->imageNameForReadOnlyState();
+        if (imageName.isEmpty())
+            m_cachedImageForDisabledState = imageForDisabledState();
+        else {
+            RefPtr<Image> image = Image::loadPlatformResource(imageName.data());
+            m_cachedImageForReadonlyState = new CachedImage(image.get());
+        }
+    }
+    return m_cachedImageForReadonlyState.get();
+}
+
+void TextFieldDecoratorImpl::handleClick(HTMLInputElement* input)
+{
+    ASSERT(input);
+    WebInputElement webInput(input);
+    m_client->handleClick(webInput);
+}
+
+void TextFieldDecoratorImpl::willDetach(HTMLInputElement* input)
+{
+    ASSERT(input);
+    WebInputElement webInput(input);
+    m_client->willDetach(webInput);
+}
+
+}

Added: trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.h (0 => 112984)


--- trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.h	                        (rev 0)
+++ trunk/Source/WebKit/chromium/src/TextFieldDecoratorImpl.h	2012-04-03 04:24:37 UTC (rev 112984)
@@ -0,0 +1,64 @@
+/*
+ * 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 TextFieldDecoratorImpl_h
+#define TextFieldDecoratorImpl_h
+
+#include "CachedResourceHandle.h"
+#include "TextFieldDecorationElement.h"
+
+namespace WebKit {
+
+class WebTextFieldDecoratorClient;
+
+class TextFieldDecoratorImpl : public WebCore::TextFieldDecorator {
+public:
+    static PassOwnPtr<TextFieldDecoratorImpl> create(WebTextFieldDecoratorClient*);
+    virtual ~TextFieldDecoratorImpl();
+
+private:
+    virtual bool willAddDecorationTo(WebCore::HTMLInputElement*) OVERRIDE;
+    virtual WebCore::CachedImage* imageForNormalState() OVERRIDE;
+    virtual WebCore::CachedImage* imageForDisabledState() OVERRIDE;
+    virtual WebCore::CachedImage* imageForReadonlyState() OVERRIDE;
+    virtual void handleClick(WebCore::HTMLInputElement*) OVERRIDE;
+    virtual void willDetach(WebCore::HTMLInputElement*) OVERRIDE;
+
+    TextFieldDecoratorImpl(WebTextFieldDecoratorClient*);
+
+    WebTextFieldDecoratorClient* m_client;
+    WebCore::CachedResourceHandle<WebCore::CachedImage> m_cachedImageForNormalState;
+    WebCore::CachedResourceHandle<WebCore::CachedImage> m_cachedImageForDisabledState;
+    WebCore::CachedResourceHandle<WebCore::CachedImage> m_cachedImageForReadonlyState;
+};
+
+}
+
+#endif // TextFieldDecoratorImpl_h

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (112983 => 112984)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-04-03 04:14:44 UTC (rev 112983)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-04-03 04:24:37 UTC (rev 112984)
@@ -108,6 +108,7 @@
 #include "SharedGraphicsContext3D.h"
 #include "SpeechInputClientImpl.h"
 #include "SpeechRecognitionClient.h"
+#include "TextFieldDecoratorImpl.h"
 #include "TextIterator.h"
 #include "Timer.h"
 #include "TouchpadFlingPlatformGestureCurve.h"
@@ -320,6 +321,18 @@
     m_spellCheckClient = spellCheckClient;
 }
 
+void WebViewImpl::addTextFieldDecoratorClient(WebTextFieldDecoratorClient* client)
+{
+    ASSERT(client);
+    // We limit the number of decorators because it affects performance of text
+    // field creation. If you'd like to add more decorators, consider moving
+    // your decorator or existing decorators to WebCore.
+    const unsigned maximumNumberOfDecorators = 8;
+    if (m_textFieldDecorators.size() >= maximumNumberOfDecorators)
+        CRASH();
+    m_textFieldDecorators.append(TextFieldDecoratorImpl::create(client));
+}
+
 WebViewImpl::WebViewImpl(WebViewClient* client)
     : m_client(client)
     , m_autofillClient(0)

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (112983 => 112984)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-04-03 04:14:44 UTC (rev 112983)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2012-04-03 04:24:37 UTC (rev 112984)
@@ -73,6 +73,7 @@
 class PopupMenuClient;
 class Range;
 class RenderTheme;
+class TextFieldDecorator;
 class Widget;
 }
 
@@ -152,6 +153,7 @@
     virtual void setDevToolsAgentClient(WebDevToolsAgentClient*);
     virtual void setPermissionClient(WebPermissionClient*);
     virtual void setSpellCheckClient(WebSpellCheckClient*);
+    virtual void addTextFieldDecoratorClient(WebTextFieldDecoratorClient*) OVERRIDE;
     virtual WebSettings* settings();
     virtual WebString pageEncoding() const;
     virtual void setPageEncoding(const WebString& encoding);
@@ -307,6 +309,8 @@
         return m_spellCheckClient;
     }
 
+    const Vector<OwnPtr<WebCore::TextFieldDecorator> >& textFieldDecorators() const { return m_textFieldDecorators; }
+
     // Returns the page object associated with this view. This may be null when
     // the page is shutting down, but will be valid at all other times.
     WebCore::Page* page() const
@@ -588,6 +592,7 @@
     WebAutofillClient* m_autofillClient;
     WebPermissionClient* m_permissionClient;
     WebSpellCheckClient* m_spellCheckClient;
+    Vector<OwnPtr<WebCore::TextFieldDecorator> > m_textFieldDecorators;
 
     ChromeClientImpl m_chromeClientImpl;
     ContextMenuClientImpl m_contextMenuClientImpl;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to