Changeset 248033 in webkit


Ignore:
Timestamp:
Jul 31, 2019 1:02:09 AM (5 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Datalist element support for TextFieldInputType
https://bugs.webkit.org/show_bug.cgi?id=98934

Reviewed by Michael Catanzaro.

.:

Enable DATALIST_ELEMENT.

  • Source/cmake/OptionsGTK.cmake:

Source/WebCore:

Add support for rendering the arrow indicator of text fields having data list.

  • rendering/RenderThemeGtk.cpp:

(WebCore::RenderThemeGtk::paintTextField):
(WebCore::RenderThemeGtk::adjustListButtonStyle const):
(WebCore::RenderThemeGtk::paintListButtonForInput):
(WebCore::RenderThemeGtk::adjustSearchFieldStyle const):

  • rendering/RenderThemeGtk.h:

Source/WebKit:

Add a WebDataListSuggestionsDropdown implementation for the GTK port using a popup window with a tree view list.

  • Sources.txt:
  • SourcesGTK.txt:
  • UIProcess/API/gtk/PageClientImpl.cpp:

(WebKit::PageClientImpl::createDataListSuggestionsDropdown):

  • UIProcess/API/gtk/PageClientImpl.h:
  • UIProcess/gtk/WebDataListSuggestionsDropdownGtk.cpp: Added.

(WebKit::firstTimeItemSelectedCallback):
(WebKit::WebDataListSuggestionsDropdownGtk::WebDataListSuggestionsDropdownGtk):
(WebKit::WebDataListSuggestionsDropdownGtk::~WebDataListSuggestionsDropdownGtk):
(WebKit::WebDataListSuggestionsDropdownGtk::treeViewRowActivatedCallback):
(WebKit::WebDataListSuggestionsDropdownGtk::didSelectOption):
(WebKit::WebDataListSuggestionsDropdownGtk::show):
(WebKit::WebDataListSuggestionsDropdownGtk::handleKeydownWithIdentifier):
(WebKit::WebDataListSuggestionsDropdownGtk::close):

  • UIProcess/gtk/WebDataListSuggestionsDropdownGtk.h: Copied from Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.h.

Tools:

Implement UIScriptControllerGtk::isShowingDataListSuggestions.

  • WebKitTestRunner/gtk/UIScriptControllerGtk.cpp:

(WTR::UIScriptControllerGtk::isShowingDataListSuggestions const):

  • WebKitTestRunner/gtk/UIScriptControllerGtk.h:

LayoutTests:

Unskip datalist tests for GTK port.

  • platform/gtk/TestExpectations:
Location:
trunk
Files:
1 added
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r247810 r248033  
     12019-07-31  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Datalist element support for TextFieldInputType
     4        https://bugs.webkit.org/show_bug.cgi?id=98934
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Enable DATALIST_ELEMENT.
     9
     10        * Source/cmake/OptionsGTK.cmake:
     11
    1122019-07-24  Fujii Hironori  <fujii.hironori@gmail.com>
    213
  • trunk/LayoutTests/ChangeLog

    r248031 r248033  
     12019-07-31  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Datalist element support for TextFieldInputType
     4        https://bugs.webkit.org/show_bug.cgi?id=98934
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Unskip datalist tests for GTK port.
     9
     10        * platform/gtk/TestExpectations:
     11
    1122019-07-31  Zan Dobersek  <zdobersek@igalia.com>
    213
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r247535 r248033  
    177177fast/history/page-cache-notification-non-suspendable.html
    178178fast/history/page-cache-notification-suspendable.html
    179 
    180 # Datalist is not yet enabled.
    181 accessibility/datalist.html [ Skip ]
    182 webkit.org/b/98934 fast/forms/datalist [ Skip ]
    183179
    184180# ENABLE_INPUT_TYPE_* are not enabled.
     
    38003796
    38013797webkit.org/b/199860 accessibility/button-with-aria-haspopup-role.html [ Failure ]
     3798webkit.org/b/199860 accessibility/datalist.html [ Failure ]
    38023799webkit.org/b/199868 accessibility/gtk/aria-haspopup.html [ Failure ]
    38033800
  • trunk/Source/WebCore/ChangeLog

    r248028 r248033  
     12019-07-31  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Datalist element support for TextFieldInputType
     4        https://bugs.webkit.org/show_bug.cgi?id=98934
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Add support for rendering the arrow indicator of text fields having data list.
     9
     10        * rendering/RenderThemeGtk.cpp:
     11        (WebCore::RenderThemeGtk::paintTextField):
     12        (WebCore::RenderThemeGtk::adjustListButtonStyle const):
     13        (WebCore::RenderThemeGtk::paintListButtonForInput):
     14        (WebCore::RenderThemeGtk::adjustSearchFieldStyle const):
     15        * rendering/RenderThemeGtk.h:
     16
    1172019-07-30  Tim Horton  <timothy_horton@apple.com>
    218
  • trunk/Source/WebCore/rendering/RenderThemeGtk.cpp

    r246790 r248033  
    521521        entryWidget.entry().setState(themePartStateFlags(*this, Entry, renderObject));
    522522        entryWidget.entry().render(paintInfo.context().platformContext()->cr(), rect);
     523
     524#if ENABLE(DATALIST_ELEMENT)
     525        if (is<HTMLInputElement>(renderObject.generatingNode())) {
     526            const auto& input = downcast<HTMLInputElement>(*(renderObject.generatingNode()));
     527            if (input.list())
     528                paintListButtonForInput(renderObject, paintInfo, rect);
     529        }
     530#endif
    523531    }
    524532    return false;
     
    597605    return paintSearchFieldIcon(this, EntryIconRight, renderObject, paintInfo, rect);
    598606}
     607
     608#if ENABLE(DATALIST_ELEMENT)
     609void RenderThemeGtk::adjustListButtonStyle(StyleResolver&, RenderStyle& style, const Element*) const
     610{
     611    // Add a margin to place the button at end of the input field.
     612    if (style.isLeftToRightDirection())
     613        style.setMarginRight(Length(-4, Fixed));
     614    else
     615        style.setMarginLeft(Length(-4, Fixed));
     616}
     617
     618void RenderThemeGtk::paintListButtonForInput(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& rect)
     619{
     620    // Use a combo box widget to render its arrow.
     621    auto& comboWidget = static_cast<RenderThemeComboBox&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::ComboBox));
     622    comboWidget.arrow().setState(themePartStateFlags(*this, ComboBoxButton, renderObject));
     623
     624    // But a search entry widget to get the contents rect, since this is a text input field.
     625    auto& searchEntryWidget = static_cast<RenderThemeSearchEntry&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::SearchEntry));
     626    auto& icon = static_cast<RenderThemeIconGadget&>(searchEntryWidget.rightIcon());
     627    icon.setIconSize(comboWidget.arrow().preferredSize().width());
     628    GtkBorder contentsBox = searchEntryWidget.entry().contentsBox();
     629    FloatRect adjustedRect(rect);
     630    adjustedRect.move(contentsBox.left, contentsBox.top);
     631    adjustedRect.contract(contentsBox.right + 1, contentsBox.top + contentsBox.bottom);
     632    comboWidget.arrow().render(paintInfo.context().platformContext()->cr(), adjustedRect);
     633}
     634#endif
    599635
    600636void RenderThemeGtk::adjustSearchFieldStyle(StyleResolver&, RenderStyle& style, const Element*) const
  • trunk/Source/WebCore/rendering/RenderThemeGtk.h

    r246632 r248033  
    144144    bool paintSearchFieldCancelButton(const RenderBox&, const PaintInfo&, const IntRect&) override;
    145145
     146#if ENABLE(DATALIST_ELEMENT)
     147    void paintListButtonForInput(const RenderObject&, const PaintInfo&, const FloatRect&);
     148    void adjustListButtonStyle(StyleResolver&, RenderStyle&, const Element*) const override;
     149#endif
     150
    146151    bool paintSliderTrack(const RenderObject&, const PaintInfo&, const IntRect&) override;
    147152    void adjustSliderTrackStyle(StyleResolver&, RenderStyle&, const Element*) const override;
  • trunk/Source/WebKit/ChangeLog

    r248032 r248033  
     12019-07-31  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Datalist element support for TextFieldInputType
     4        https://bugs.webkit.org/show_bug.cgi?id=98934
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Add a WebDataListSuggestionsDropdown implementation for the GTK port using a popup window with a tree view list.
     9
     10        * Sources.txt:
     11        * SourcesGTK.txt:
     12        * UIProcess/API/gtk/PageClientImpl.cpp:
     13        (WebKit::PageClientImpl::createDataListSuggestionsDropdown):
     14        * UIProcess/API/gtk/PageClientImpl.h:
     15        * UIProcess/gtk/WebDataListSuggestionsDropdownGtk.cpp: Added.
     16        (WebKit::firstTimeItemSelectedCallback):
     17        (WebKit::WebDataListSuggestionsDropdownGtk::WebDataListSuggestionsDropdownGtk):
     18        (WebKit::WebDataListSuggestionsDropdownGtk::~WebDataListSuggestionsDropdownGtk):
     19        (WebKit::WebDataListSuggestionsDropdownGtk::treeViewRowActivatedCallback):
     20        (WebKit::WebDataListSuggestionsDropdownGtk::didSelectOption):
     21        (WebKit::WebDataListSuggestionsDropdownGtk::show):
     22        (WebKit::WebDataListSuggestionsDropdownGtk::handleKeydownWithIdentifier):
     23        (WebKit::WebDataListSuggestionsDropdownGtk::close):
     24        * UIProcess/gtk/WebDataListSuggestionsDropdownGtk.h: Copied from Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.h.
     25
    1262019-07-31  Tim Horton  <timothy_horton@apple.com>
    227
  • trunk/Source/WebKit/Sources.txt

    r247146 r248033  
    269269UIProcess/WebCookieManagerProxy.cpp
    270270UIProcess/WebCookieManagerProxyClient.cpp
     271UIProcess/WebDataListSuggestionsDropdown.cpp
    271272UIProcess/WebEditCommandProxy.cpp
    272273UIProcess/WebFormClient.cpp
     
    533534WebProcess/WebCoreSupport/WebColorChooser.cpp
    534535WebProcess/WebCoreSupport/WebContextMenuClient.cpp
     536WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp
    535537WebProcess/WebCoreSupport/WebDiagnosticLoggingClient.cpp
    536538WebProcess/WebCoreSupport/WebDragClient.cpp
  • trunk/Source/WebKit/SourcesCocoa.txt

    r247502 r248033  
    219219UIProcess/ViewGestureController.cpp
    220220UIProcess/ViewSnapshotStore.cpp
    221 UIProcess/WebDataListSuggestionsDropdown.cpp
    222221UIProcess/WebMediaSessionFocusManager.cpp
    223222UIProcess/WebMediaSessionFocusManagerClient.cpp
     
    553552WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm
    554553
    555 WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp
    556554WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp
    557555WebProcess/WebCoreSupport/WebValidationMessageClient.cpp
  • trunk/Source/WebKit/SourcesGTK.txt

    r247096 r248033  
    252252UIProcess/gtk/WebColorPickerGtk.cpp
    253253UIProcess/gtk/WebContextMenuProxyGtk.cpp
     254UIProcess/gtk/WebDataListSuggestionsDropdownGtk.cpp
    254255UIProcess/gtk/WebInspectorProxyGtk.cpp
    255256UIProcess/gtk/WebKitInspectorWindow.cpp
  • trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp

    r246677 r248033  
    3636#include "WebColorPickerGtk.h"
    3737#include "WebContextMenuProxyGtk.h"
     38#include "WebDataListSuggestionsDropdownGtk.h"
    3839#include "WebEventFactory.h"
    3940#include "WebKitColorChooser.h"
     
    250251    return WebColorPickerGtk::create(*page, color, rect);
    251252}
     253
     254#if ENABLE(DATALIST_ELEMENT)
     255RefPtr<WebDataListSuggestionsDropdown> PageClientImpl::createDataListSuggestionsDropdown(WebPageProxy& page)
     256{
     257    return WebDataListSuggestionsDropdownGtk::create(m_viewWidget, page);
     258}
     259#endif
    252260
    253261void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
  • trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h

    r246635 r248033  
    9595    RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&, Vector<WebCore::Color>&&) override;
    9696#endif
     97#if ENABLE(DATALIST_ELEMENT)
     98    RefPtr<WebDataListSuggestionsDropdown> createDataListSuggestionsDropdown(WebPageProxy&) override;
     99#endif
    97100    void selectionDidChange() override;
    98101    RefPtr<ViewSnapshot> takeViewSnapshot() override;
  • trunk/Source/WebKit/UIProcess/gtk/WebDataListSuggestionsDropdownGtk.h

    r248032 r248033  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Igalia S.L.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    1111 *    documentation and/or other materials provided with the distribution.
    1212 *
    13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
     13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS AS IS''
    1414 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    1515 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     
    2626#pragma once
    2727
    28 #include "PlatformWebView.h"
    29 #include "TestController.h"
    30 #include "UIScriptController.h"
    31 #include <WebKit/WKViewPrivate.h>
     28#if ENABLE(DATALIST_ELEMENT)
    3229
    33 namespace WTR {
     30#include "WebDataListSuggestionsDropdown.h"
    3431
    35 class UIScriptControllerGtk : public UIScriptController {
     32typedef struct _GtkTreePath GtkTreePath;
     33typedef struct _GtkTreeView GtkTreeView;
     34typedef struct _GtkTreeViewColumn GtkTreeViewColumn;
     35
     36namespace WebKit {
     37
     38class WebPageProxy;
     39
     40class WebDataListSuggestionsDropdownGtk final : public WebDataListSuggestionsDropdown {
    3641public:
    37     explicit UIScriptControllerGtk(UIScriptContext& context)
    38         : UIScriptController(context)
     42    static Ref<WebDataListSuggestionsDropdownGtk> create(GtkWidget* webView, WebPageProxy& page)
    3943    {
     44        return adoptRef(*new WebDataListSuggestionsDropdownGtk(webView, page));
    4045    }
    4146
    42     void beginBackSwipe(JSValueRef) override;
    43     void completeBackSwipe(JSValueRef) override;
     47    ~WebDataListSuggestionsDropdownGtk();
     48
     49private:
     50    WebDataListSuggestionsDropdownGtk(GtkWidget*, WebPageProxy&);
     51
     52    void show(WebCore::DataListSuggestionInformation&&) final;
     53    void handleKeydownWithIdentifier(const String&) final;
     54    void close() final;
     55
     56    static void treeViewRowActivatedCallback(GtkTreeView*, GtkTreePath*, GtkTreeViewColumn*, WebDataListSuggestionsDropdownGtk*);
     57    void didSelectOption(const String&);
     58
     59    GtkWidget* m_webView { nullptr };
     60    GtkWidget* m_popup { nullptr };
     61    GtkWidget* m_treeView { nullptr };
    4462};
    4563
    46 } // namespace WTR
     64} // namespace WebKit
     65
     66#endif // ENABLE(DATALIST_ELEMENT)
  • trunk/Source/cmake/OptionsGTK.cmake

    r247721 r248033  
    151151WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CONTENT_EXTENSIONS PRIVATE ON)
    152152WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DARK_MODE_CSS PRIVATE ON)
     153WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DATALIST_ELEMENT PRIVATE ON)
    153154WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DOWNLOAD_ATTRIBUTE PRIVATE ON)
    154155WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
  • trunk/Tools/ChangeLog

    r248030 r248033  
     12019-07-31  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Datalist element support for TextFieldInputType
     4        https://bugs.webkit.org/show_bug.cgi?id=98934
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Implement UIScriptControllerGtk::isShowingDataListSuggestions.
     9
     10        * WebKitTestRunner/gtk/UIScriptControllerGtk.cpp:
     11        (WTR::UIScriptControllerGtk::isShowingDataListSuggestions const):
     12        * WebKitTestRunner/gtk/UIScriptControllerGtk.h:
     13
    1142019-07-30  Tim Horton  <timothy_horton@apple.com>
    215
  • trunk/Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.cpp

    r247898 r248033  
    3030#include "TestController.h"
    3131#include <WebKit/WKViewPrivate.h>
     32#include <gtk/gtk.h>
    3233
    3334namespace WTR {
     
    5253}
    5354
     55bool UIScriptControllerGtk::isShowingDataListSuggestions() const
     56{
     57    auto* webView = TestController::singleton().mainWebView()->platformView();
     58    if (auto* popup = g_object_get_data(G_OBJECT(webView), "wk-datalist-popup"))
     59        return gtk_widget_get_mapped(GTK_WIDGET(popup));
     60    return false;
     61}
     62
    5463} // namespace WTR
  • trunk/Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.h

    r247898 r248033  
    4242    void beginBackSwipe(JSValueRef) override;
    4343    void completeBackSwipe(JSValueRef) override;
     44    bool isShowingDataListSuggestions() const override;
    4445};
    4546
Note: See TracChangeset for help on using the changeset viewer.