Changeset 127988 in webkit


Ignore:
Timestamp:
Sep 9, 2012 10:22:58 AM (12 years ago)
Author:
pierre.rossi@gmail.com
Message:

[WK2] expose element rect for color input type
https://bugs.webkit.org/show_bug.cgi?id=91664

Reviewed by Simon Hausmann.

Source/WebKit2:

In the same way we do for select elements already. This allows placing the picker
in a sensible location.

  • UIProcess/API/efl/PageClientImpl.cpp: Update the function's signature.

(WebKit::PageClientImpl::createColorChooserProxy): Ditto.

  • UIProcess/API/efl/PageClientImpl.h: Ditto.

(PageClientImpl):

  • UIProcess/API/gtk/PageClientImpl.cpp:

(WebKit::PageClientImpl::createColorChooserProxy): Ditto.

  • UIProcess/API/gtk/PageClientImpl.h: Ditto.

(PageClientImpl):

  • UIProcess/API/mac/PageClientImpl.h: Ditto.

(PageClientImpl):

  • UIProcess/API/mac/PageClientImpl.mm:

(WebKit::PageClientImpl::createColorChooserProxy): Ditto.

  • UIProcess/API/qt/raw/qrawwebview.cpp:

(QRawWebViewPrivate::createColorChooserProxy): Ditto.

  • UIProcess/API/qt/raw/qrawwebview_p_p.h: Ditto.

(QRawWebViewPrivate):

  • UIProcess/PageClient.h: Ditto.

(PageClient):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::showColorChooser): Compute the rect mapped to the current view's transform.

  • UIProcess/WebPageProxy.h:

(WebPageProxy):

  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/qt/QtPageClient.cpp:

(WebKit::QtPageClient::createColorChooserProxy):

  • UIProcess/qt/QtPageClient.h:

(QtPageClient):

  • UIProcess/qt/WebColorChooserProxyQt.cpp:

(ColorChooserContextObject):
(WebKit::ColorChooserContextObject::ColorChooserContextObject):
(WebKit::ColorChooserContextObject::elementRect):
(WebKit::ColorChooserContextObject::accept):
(WebKit::WebColorChooserProxyQt::WebColorChooserProxyQt):

  • UIProcess/qt/WebColorChooserProxyQt.h:

(WebKit::WebColorChooserProxyQt::create):
(WebColorChooserProxyQt):

  • UIProcess/win/WebView.cpp:

(WebKit::WebView::createColorChooserProxy): Update the function's signature.

  • UIProcess/win/WebView.h:

(WebView): Ditto.

  • WebProcess/WebCoreSupport/WebColorChooser.cpp:

(WebKit::WebColorChooser::WebColorChooser):

Tools:

Update the QML logic in MiniBrowser to take advantage of this.
The picker size is now hardcoded and we try to place it below the
input element if possible.

  • MiniBrowser/qt/qml/ColorChooser.qml:
Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r127986 r127988  
     12012-09-09  Pierre Rossi  <pierre.rossi@gmail.com>
     2
     3        [WK2] expose element rect for color input type
     4        https://bugs.webkit.org/show_bug.cgi?id=91664
     5
     6        Reviewed by Simon Hausmann.
     7
     8        In the same way we do for select elements already. This allows placing the picker
     9        in a sensible location.
     10
     11        * UIProcess/API/efl/PageClientImpl.cpp: Update the function's signature.
     12        (WebKit::PageClientImpl::createColorChooserProxy): Ditto.
     13        * UIProcess/API/efl/PageClientImpl.h: Ditto.
     14        (PageClientImpl):
     15        * UIProcess/API/gtk/PageClientImpl.cpp:
     16        (WebKit::PageClientImpl::createColorChooserProxy): Ditto.
     17        * UIProcess/API/gtk/PageClientImpl.h: Ditto.
     18        (PageClientImpl):
     19        * UIProcess/API/mac/PageClientImpl.h: Ditto.
     20        (PageClientImpl):
     21        * UIProcess/API/mac/PageClientImpl.mm:
     22        (WebKit::PageClientImpl::createColorChooserProxy): Ditto.
     23        * UIProcess/API/qt/raw/qrawwebview.cpp:
     24        (QRawWebViewPrivate::createColorChooserProxy): Ditto.
     25        * UIProcess/API/qt/raw/qrawwebview_p_p.h: Ditto.
     26        (QRawWebViewPrivate):
     27        * UIProcess/PageClient.h: Ditto.
     28        (PageClient):
     29        * UIProcess/WebPageProxy.cpp:
     30        (WebKit::WebPageProxy::showColorChooser): Compute the rect mapped to the current view's transform.
     31        * UIProcess/WebPageProxy.h:
     32        (WebPageProxy):
     33        * UIProcess/WebPageProxy.messages.in:
     34        * UIProcess/qt/QtPageClient.cpp:
     35        (WebKit::QtPageClient::createColorChooserProxy):
     36        * UIProcess/qt/QtPageClient.h:
     37        (QtPageClient):
     38        * UIProcess/qt/WebColorChooserProxyQt.cpp:
     39        (ColorChooserContextObject):
     40        (WebKit::ColorChooserContextObject::ColorChooserContextObject):
     41        (WebKit::ColorChooserContextObject::elementRect):
     42        (WebKit::ColorChooserContextObject::accept):
     43        (WebKit::WebColorChooserProxyQt::WebColorChooserProxyQt):
     44        * UIProcess/qt/WebColorChooserProxyQt.h:
     45        (WebKit::WebColorChooserProxyQt::create):
     46        (WebColorChooserProxyQt):
     47        * UIProcess/win/WebView.cpp:
     48        (WebKit::WebView::createColorChooserProxy): Update the function's signature.
     49        * UIProcess/win/WebView.h:
     50        (WebView): Ditto.
     51        * WebProcess/WebCoreSupport/WebColorChooser.cpp:
     52        (WebKit::WebColorChooser::WebColorChooser):
     53
    1542012-09-09  Simon Hausmann  <simon.hausmann@nokia.com>
    255
  • trunk/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp

    r126866 r127988  
    209209
    210210#if ENABLE(INPUT_TYPE_COLOR)
    211 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
     211PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&)
    212212{
    213213    notImplemented();
  • trunk/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h

    r126844 r127988  
    8787
    8888#if ENABLE(INPUT_TYPE_COLOR)
    89     virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor);
     89    virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&);
    9090#endif
    9191
  • trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp

    r124087 r127988  
    234234
    235235#if ENABLE(INPUT_TYPE_COLOR)
    236 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
     236PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&)
    237237{
    238238    notImplemented();
  • trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h

    r126958 r127988  
    8383    virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
    8484#if ENABLE(INPUT_TYPE_COLOR)
    85     virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& intialColor);
     85    virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& intialColor, const WebCore::IntRect&);
    8686#endif
    8787    virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate);
  • trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h

    r126958 r127988  
    9898
    9999#if ENABLE(INPUT_TYPE_COLOR)
    100     virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor);
     100    virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&);
    101101#endif
    102102
  • trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm

    r122400 r127988  
    367367
    368368#if ENABLE(INPUT_TYPE_COLOR)
    369 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
     369PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&,  const WebCore::IntRect&)
    370370{
    371371    notImplemented();
  • trunk/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview.cpp

    r127559 r127988  
    186186
    187187#if ENABLE(INPUT_TYPE_COLOR)
    188 PassRefPtr<WebKit::WebColorChooserProxy> QRawWebViewPrivate::createColorChooserProxy(WebKit::WebPageProxy*, const WebCore::Color& intialColor)
     188PassRefPtr<WebKit::WebColorChooserProxy> QRawWebViewPrivate::createColorChooserProxy(WebKit::WebPageProxy*, const WebCore::Color& intialColor, const WebCore::IntRect&)
    189189{
    190190    notImplemented();
  • trunk/Source/WebKit2/UIProcess/API/qt/raw/qrawwebview_p_p.h

    r121620 r127988  
    8888
    8989#if ENABLE(INPUT_TYPE_COLOR)
    90     virtual PassRefPtr<WebKit::WebColorChooserProxy> createColorChooserProxy(WebKit::WebPageProxy*, const WebCore::Color& intialColor);
     90    virtual PassRefPtr<WebKit::WebColorChooserProxy> createColorChooserProxy(WebKit::WebPageProxy*, const WebCore::Color& intialColor, const WebCore::IntRect&);
    9191#endif
    9292
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r124989 r127988  
    181181
    182182#if ENABLE(INPUT_TYPE_COLOR)
    183     virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor) = 0;
     183    virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) = 0;
    184184#endif
    185185
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r127968 r127988  
    27082708
    27092709#if ENABLE(INPUT_TYPE_COLOR)
    2710 void WebPageProxy::showColorChooser(const WebCore::Color& initialColor)
     2710void WebPageProxy::showColorChooser(const WebCore::Color& initialColor, const IntRect& elementRect)
    27112711{
    27122712    ASSERT(!m_colorChooser);
    27132713
    2714     m_colorChooser = m_pageClient->createColorChooserProxy(this, initialColor);
     2714    m_colorChooser = m_pageClient->createColorChooserProxy(this, initialColor, elementRect);
    27152715}
    27162716
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r127525 r127988  
    850850
    851851#if ENABLE(INPUT_TYPE_COLOR)
    852     void showColorChooser(const WebCore::Color& initialColor);
     852    void showColorChooser(const WebCore::Color& initialColor, const WebCore::IntRect&);
    853853    void setColorChooserColor(const WebCore::Color&);
    854854    void endColorChooser();
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r124989 r127988  
    8989
    9090#if ENABLE(INPUT_TYPE_COLOR)
    91     ShowColorChooser(WebCore::Color initialColor);
     91    ShowColorChooser(WebCore::Color initialColor, WebCore::IntRect elementRect);
    9292    SetColorChooserColor(WebCore::Color color);
    9393    EndColorChooser();
  • trunk/Source/WebKit2/UIProcess/qt/QtPageClient.cpp

    r123476 r127988  
    210210
    211211#if ENABLE(INPUT_TYPE_COLOR)
    212 PassRefPtr<WebColorChooserProxy> QtPageClient::createColorChooserProxy(WebPageProxy* webPageProxy, const WebCore::Color& initialColor)
    213 {
    214     return WebColorChooserProxyQt::create(webPageProxy, m_webView, initialColor);
     212PassRefPtr<WebColorChooserProxy> QtPageClient::createColorChooserProxy(WebPageProxy* webPageProxy, const WebCore::Color& initialColor, const WebCore::IntRect& elementRect)
     213{
     214    return WebColorChooserProxyQt::create(webPageProxy, m_webView, initialColor, elementRect);
    215215}
    216216#endif
  • trunk/Source/WebKit2/UIProcess/qt/QtPageClient.h

    r120890 r127988  
    8888    virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
    8989#if ENABLE(INPUT_TYPE_COLOR)
    90     virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& intialColor);
     90    virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&);
    9191#endif
    9292    virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate) { }
  • trunk/Source/WebKit2/UIProcess/qt/WebColorChooserProxyQt.cpp

    r124758 r127988  
    3535    Q_OBJECT
    3636    Q_PROPERTY(QColor currentColor READ currentColor CONSTANT FINAL)
     37    Q_PROPERTY(QRectF elementRect READ elementRect CONSTANT FINAL)
    3738
    3839public:
    39     ColorChooserContextObject(const QColor& color)
     40    ColorChooserContextObject(const QColor& color, const QRectF& rect)
    4041        : m_currentColor(color)
     42        , m_rect(rect)
    4143    {
    4244    }
    4345
    4446    QColor currentColor() const { return m_currentColor; }
     47    QRectF elementRect() const { return m_rect; }
    4548
    46     Q_INVOKABLE void accept(const QColor& color) { emit accepted(color); };
     49    Q_INVOKABLE void accept(const QColor& color) { emit accepted(color); }
    4750    Q_INVOKABLE void reject() { emit rejected(); }
    4851
     
    5356private:
    5457    QColor m_currentColor;
     58    QRectF m_rect;
    5559};
    5660
    57 WebColorChooserProxyQt::WebColorChooserProxyQt(WebColorChooserProxy::Client* client, QQuickWebView* webView, const Color& initialColor)
     61WebColorChooserProxyQt::WebColorChooserProxyQt(WebColorChooserProxy::Client* client, QQuickWebView* webView, const Color& initialColor, const IntRect& elementRect)
    5862    : WebColorChooserProxy(client)
    5963    , m_webView(webView)
    6064{
    61     ColorChooserContextObject* contextObject = new ColorChooserContextObject(initialColor);
     65    const QRectF mappedRect= m_webView->mapRectFromWebContent(QRect(elementRect));
     66    ColorChooserContextObject* contextObject = new ColorChooserContextObject(initialColor, mappedRect);
    6267    createItem(contextObject);
    6368}
  • trunk/Source/WebKit2/UIProcess/qt/WebColorChooserProxyQt.h

    r123456 r127988  
    2222#define WebColorChooserProxyQt_h
    2323
     24#include "IntRect.h"
    2425#include "WebColorChooserProxy.h"
    2526#include <QtCore/QObject>
     
    4445
    4546public:
    46     static PassRefPtr<WebColorChooserProxy> create(WebColorChooserProxy::Client* client, QQuickWebView* webView, const WebCore::Color& initialColor)
     47    static PassRefPtr<WebColorChooserProxy> create(WebColorChooserProxy::Client* client, QQuickWebView* webView, const WebCore::Color& initialColor, const WebCore::IntRect& elementRect)
    4748    {
    48         return adoptRef(new WebColorChooserProxyQt(client, webView, initialColor));
     49        return adoptRef(new WebColorChooserProxyQt(client, webView, initialColor, elementRect));
    4950    }
    5051    ~WebColorChooserProxyQt();
     
    5960
    6061private:
    61     WebColorChooserProxyQt(WebColorChooserProxy::Client*, QQuickWebView*, const WebCore::Color&);
     62    WebColorChooserProxyQt(WebColorChooserProxy::Client*, QQuickWebView*, const WebCore::Color&, const WebCore::IntRect&);
    6263
    6364    void createItem(QObject*);
  • trunk/Source/WebKit2/UIProcess/win/WebView.cpp

    r127732 r127988  
    14321432
    14331433#if ENABLE(INPUT_TYPE_COLOR)
    1434 PassRefPtr<WebColorChooserProxy> WebView::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
     1434PassRefPtr<WebColorChooserProxy> WebView::createColorChooserProxy(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&)
    14351435{
    14361436    notImplemented();
  • trunk/Source/WebKit2/UIProcess/win/WebView.h

    r120890 r127988  
    200200    virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
    201201#if ENABLE(INPUT_TYPE_COLOR)
    202     virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& intialColor);
     202    virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& intialColor, const WebCore::IntRect&);
    203203#endif
    204204    virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate);
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebColorChooser.cpp

    r120890 r127988  
    4444{
    4545    m_page->setActiveColorChooser(this);
    46     WebProcess::shared().connection()->send(Messages::WebPageProxy::ShowColorChooser(initialColor), m_page->pageID());
     46    WebProcess::shared().connection()->send(Messages::WebPageProxy::ShowColorChooser(initialColor, client->elementRectRelativeToRootView()), m_page->pageID());
    4747}
    4848
  • trunk/Tools/ChangeLog

    r127966 r127988  
     12012-09-09  Pierre Rossi  <pierre.rossi@gmail.com>
     2
     3        [WK2] expose element rect for color input type
     4        https://bugs.webkit.org/show_bug.cgi?id=91664
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Update the QML logic in MiniBrowser to take advantage of this.
     9        The picker size is now hardcoded and we try to place it below the
     10        input element if possible.
     11
     12        * MiniBrowser/qt/qml/ColorChooser.qml:
     13
    1142012-09-08  Christophe Dumez  <christophe.dumez@intel.com>
    215
  • trunk/Tools/MiniBrowser/qt/qml/ColorChooser.qml

    r120921 r127988  
    3939        opacity: 0.8
    4040        radius: 5
    41         width: parent.width / 4
    42         height: parent.height / 4
    43         anchors.centerIn: parent
     41        width: 200
     42        height: 200
     43        x: (model.elementRect.x + width > parent.width) ? parent.width - width : model.elementRect.x
     44        y: (model.elementRect.y + model.elementRect.height + height < parent.height ) ? model.elementRect.y + model.elementRect.height
     45                                                                                      : model.elementRect.y - height;
    4446
    4547        Rectangle {
Note: See TracChangeset for help on using the changeset viewer.