Changeset 115704 in webkit


Ignore:
Timestamp:
Apr 30, 2012 7:53:15 PM (12 years ago)
Author:
keishi@webkit.org
Message:

datalist: Inconsistent behavior of HTMLInputElement::list
https://bugs.webkit.org/show_bug.cgi?id=84351

Source/WebCore:

Each platform will have a different set of input types that support the datalist UI.
This patch makes shouldRespectListAttribute ask the RenderTheme if it supports datalist UI for that input type.
Thus making it possible to do feature detection with JS.

Reviewed by Kent Tamura.

  • WebCore.gypi: Added RenderThemeChromiumCommon.{cpp,h}
  • html/ColorInputType.cpp:

(WebCore::ColorInputType::shouldRespectListAttribute):
(WebCore):

  • html/ColorInputType.h:

(ColorInputType):

  • html/InputType.cpp:

(WebCore::InputType::themeSupportsDataListUI): Static method used by TextFieldInputType, RangeInputType, and ColorInputType.
(WebCore):

  • html/InputType.h:

(InputType):

  • html/RangeInputType.cpp:

(WebCore::RangeInputType::shouldRespectListAttribute):

  • html/TextFieldInputType.cpp:

(WebCore::TextFieldInputType::shouldRespectListAttribute):

  • rendering/RenderTheme.h:

(RenderTheme):
(WebCore::RenderTheme::supportsDataListUI): Returns true if the platform can show the datalist suggestions for a given input type.

  • rendering/RenderThemeChromiumCommon.cpp: Added.

(WebCore):
(WebCore::RenderThemeChromiumCommon::supportsDataListUI):

  • rendering/RenderThemeChromiumCommon.h: Added.

(WebCore):
(RenderThemeChromiumCommon):

  • rendering/RenderThemeChromiumMac.h:

(RenderThemeChromiumMac):

  • rendering/RenderThemeChromiumMac.mm:

(WebCore::RenderThemeChromiumMac::supportsDataListUI):
(WebCore):

  • rendering/RenderThemeChromiumSkia.cpp:

(WebCore::RenderThemeChromiumMac::supportsDataListUI):
(WebCore):

  • rendering/RenderThemeChromiumSkia.h:

(RenderThemeChromiumSkia):

LayoutTests:

Reviewed by Kent Tamura.

  • fast/forms/datalist/input-list-expected.txt:
  • fast/forms/datalist/input-list.html: Added tests for all input types.
  • platform/chromium/fast/forms/datalist/input-list-expected.txt: Added.
Location:
trunk
Files:
4 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r115700 r115704  
     12012-04-30  Keishi Hattori  <keishi@webkit.org>
     2
     3        datalist: Inconsistent behavior of HTMLInputElement::list
     4        https://bugs.webkit.org/show_bug.cgi?id=84351
     5
     6        Reviewed by Kent Tamura.
     7
     8        * fast/forms/datalist/input-list-expected.txt:
     9        * fast/forms/datalist/input-list.html: Added tests for all input types.
     10        * platform/chromium/fast/forms/datalist/input-list-expected.txt: Added.
     11
    1122012-04-30  Koji Ishii  <kojiishi@gmail.com>
    213
  • trunk/LayoutTests/fast/forms/datalist/input-list-expected.txt

    r113137 r115704  
    77PASS input.list is null
    88PASS input.list is null
    9 PASS input.list is document.getElementById("dl1")
    10 PASS input.list is null
    119PASS datalist.className is "former"
     10PASS document.getElementById("text").list is document.getElementById("dl1")
     11PASS document.getElementById("search").list is document.getElementById("dl1")
     12PASS document.getElementById("url").list is document.getElementById("dl1")
     13PASS document.getElementById("telephone").list is document.getElementById("dl1")
     14PASS document.getElementById("email").list is document.getElementById("dl1")
     15PASS document.getElementById("datetime").list is document.getElementById("dl1")
     16PASS document.getElementById("date").list is document.getElementById("dl1")
     17PASS document.getElementById("month").list is document.getElementById("dl1")
     18PASS document.getElementById("week").list is document.getElementById("dl1")
     19PASS document.getElementById("time").list is document.getElementById("dl1")
     20PASS document.getElementById("datetime-local").list is document.getElementById("dl1")
     21PASS document.getElementById("number").list is document.getElementById("dl1")
     22PASS document.getElementById("range").list is document.getElementById("dl1")
     23PASS document.getElementById("color").list is document.getElementById("dl1")
     24PASS document.getElementById("hidden").list is null
     25PASS document.getElementById("password").list is null
     26PASS document.getElementById("checkbox").list is null
     27PASS document.getElementById("radio").list is null
     28PASS document.getElementById("file").list is null
     29PASS document.getElementById("submit").list is null
     30PASS document.getElementById("image").list is null
     31PASS document.getElementById("reset").list is null
     32PASS document.getElementById("button").list is null
    1233PASS successfullyParsed is true
    1334
    1435TEST COMPLETE
    15          
     36
  • trunk/LayoutTests/fast/forms/datalist/input-list.html

    r114990 r115704  
    88<div id="console"></div>
    99
    10 <!-- No list attribute -->
    11 <input type="text" id="i1">
    12 <!-- Empty list -->
    13 <input type="text" id="i2" list="">
    14 <!-- Non-existent ID -->
    15 <input type="text" id="i3" list="nonexist">
    16 <!-- Normal case -->
    17 <input type="text" id="i4" list="dl1">
    18 <!-- Unsupported type -->
    19 <input type="password" id="i5" list="dl1">
    20 <!-- ID confilict -->
    21 <Input type="text" id="i6" list="dl2">
     10<div style="display:none">
     11  <!-- No list attribute -->
     12  <input type="text" id="i1">
     13  <!-- Empty list -->
     14  <input type="text" id="i2" list="">
     15  <!-- Non-existent ID -->
     16  <input type="text" id="i3" list="nonexist">
     17  <!-- ID confilict -->
     18  <input type="text" id="i4" list="dl2">
     19  <!-- supported type -->
     20  <input type="text" id="text" list="dl1">
     21  <input type="search" id="search" list="dl1">
     22  <input type="url" id="url" list="dl1">
     23  <input type="telephone" id="telephone" list="dl1">
     24  <input type="email" id="email" list="dl1">
     25  <input type="datetime" id="datetime" list="dl1">
     26  <input type="date" id="date" list="dl1">
     27  <input type="month" id="month" list="dl1">
     28  <input type="week" id="week" list="dl1">
     29  <input type="time" id="time" list="dl1">
     30  <input type="datetime-local" id="datetime-local" list="dl1">
     31  <input type="number" id="number" list="dl1">
     32  <input type="range" id="range" list="dl1">
     33  <input type="color" id="color" list="dl1">
     34  <!-- Unsupported type -->
     35  <input type="hidden" id="hidden" list="dl1">
     36  <input type="password" id="password" list="dl1">
     37  <input type="checkbox" id="checkbox" list="dl1">
     38  <input type="radio" id="radio" list="dl1">
     39  <input type="file" id="file" list="dl1">
     40  <input type="submit" id="submit" list="dl1">
     41  <input type="image" id="image" list="dl1">
     42  <input type="reset" id="reset" list="dl1">
     43  <input type="button" id="button" list="dl1">
     44</div>
    2245
    2346<datalist id="dl1">
     
    4467shouldBeNull('input.list');
    4568
    46 input = document.getElementById('i4');
    47 shouldBe('input.list', 'document.getElementById("dl1")');
     69var datalist = document.getElementById('i4').list;
     70shouldBe('datalist.className', '"former"');
    4871
    49 input = document.getElementById('i5');
    50 shouldBeNull('input.list');
     72shouldBe('document.getElementById("text").list', 'document.getElementById("dl1")');
     73shouldBe('document.getElementById("search").list', 'document.getElementById("dl1")');
     74shouldBe('document.getElementById("url").list', 'document.getElementById("dl1")');
     75shouldBe('document.getElementById("telephone").list', 'document.getElementById("dl1")');
     76shouldBe('document.getElementById("email").list', 'document.getElementById("dl1")');
     77shouldBe('document.getElementById("datetime").list', 'document.getElementById("dl1")');
     78shouldBe('document.getElementById("date").list', 'document.getElementById("dl1")');
     79shouldBe('document.getElementById("month").list', 'document.getElementById("dl1")');
     80shouldBe('document.getElementById("week").list', 'document.getElementById("dl1")');
     81shouldBe('document.getElementById("time").list', 'document.getElementById("dl1")');
     82shouldBe('document.getElementById("datetime-local").list', 'document.getElementById("dl1")');
     83shouldBe('document.getElementById("number").list', 'document.getElementById("dl1")');
     84shouldBe('document.getElementById("range").list', 'document.getElementById("dl1")');
     85shouldBe('document.getElementById("color").list', 'document.getElementById("dl1")');
    5186
    52 var datalist = document.getElementById('i6').list;
    53 shouldBe('datalist.className', '"former"');
     87shouldBeNull('document.getElementById("hidden").list');
     88shouldBeNull('document.getElementById("password").list');
     89shouldBeNull('document.getElementById("checkbox").list');
     90shouldBeNull('document.getElementById("radio").list');
     91shouldBeNull('document.getElementById("file").list');
     92shouldBeNull('document.getElementById("submit").list');
     93shouldBeNull('document.getElementById("image").list');
     94shouldBeNull('document.getElementById("reset").list');
     95shouldBeNull('document.getElementById("button").list');
     96
    5497</script>
    5598<script src="../../../fast/js/resources/js-test-post.js"></script>
  • trunk/Source/WebCore/ChangeLog

    r115701 r115704  
     12012-04-30  Keishi Hattori  <keishi@webkit.org>
     2
     3        datalist: Inconsistent behavior of HTMLInputElement::list
     4        https://bugs.webkit.org/show_bug.cgi?id=84351
     5
     6        Each platform will have a different set of input types that support the datalist UI.
     7        This patch makes shouldRespectListAttribute ask the RenderTheme if it supports datalist UI for that input type.
     8        Thus making it possible to do feature detection with JS.
     9
     10        Reviewed by Kent Tamura.
     11
     12        * WebCore.gypi: Added RenderThemeChromiumCommon.{cpp,h}
     13        * html/ColorInputType.cpp:
     14        (WebCore::ColorInputType::shouldRespectListAttribute):
     15        (WebCore):
     16        * html/ColorInputType.h:
     17        (ColorInputType):
     18        * html/InputType.cpp:
     19        (WebCore::InputType::themeSupportsDataListUI): Static method used by TextFieldInputType, RangeInputType, and ColorInputType.
     20        (WebCore):
     21        * html/InputType.h:
     22        (InputType):
     23        * html/RangeInputType.cpp:
     24        (WebCore::RangeInputType::shouldRespectListAttribute):
     25        * html/TextFieldInputType.cpp:
     26        (WebCore::TextFieldInputType::shouldRespectListAttribute):
     27        * rendering/RenderTheme.h:
     28        (RenderTheme):
     29        (WebCore::RenderTheme::supportsDataListUI): Returns true if the platform can show the datalist suggestions for a given input type.
     30        * rendering/RenderThemeChromiumCommon.cpp: Added.
     31        (WebCore):
     32        (WebCore::RenderThemeChromiumCommon::supportsDataListUI):
     33        * rendering/RenderThemeChromiumCommon.h: Added.
     34        (WebCore):
     35        (RenderThemeChromiumCommon):
     36        * rendering/RenderThemeChromiumMac.h:
     37        (RenderThemeChromiumMac):
     38        * rendering/RenderThemeChromiumMac.mm:
     39        (WebCore::RenderThemeChromiumMac::supportsDataListUI):
     40        (WebCore):
     41        * rendering/RenderThemeChromiumSkia.cpp:
     42        (WebCore::RenderThemeChromiumMac::supportsDataListUI):
     43        (WebCore):
     44        * rendering/RenderThemeChromiumSkia.h:
     45        (RenderThemeChromiumSkia):
     46
    1472012-04-30  Levi Weintraub  <leviw@chromium.org>
    248
  • trunk/Source/WebCore/WebCore.gypi

    r115600 r115704  
    48644864            'rendering/RenderThemeChromiumAndroid.cpp',
    48654865            'rendering/RenderThemeChromiumAndroid.h',
     4866            'rendering/RenderThemeChromiumCommon.cpp',
     4867            'rendering/RenderThemeChromiumCommon.h',
    48664868            'rendering/RenderThemeChromiumLinux.cpp',
    48674869            'rendering/RenderThemeChromiumLinux.h',
  • trunk/Source/WebCore/html/ColorInputType.cpp

    r112658 r115704  
    156156}
    157157
     158bool ColorInputType::shouldRespectListAttribute()
     159{
     160    return InputType::themeSupportsDataListUI(this);
     161}
     162
    158163void ColorInputType::didChooseColor(const Color& color)
    159164{
  • trunk/Source/WebCore/html/ColorInputType.h

    r112658 r115704  
    5959    virtual void handleDOMActivateEvent(Event*) OVERRIDE;
    6060    virtual void detach() OVERRIDE;
     61    virtual bool shouldRespectListAttribute() OVERRIDE;
    6162
    6263    Color valueAsColor() const;
  • trunk/Source/WebCore/html/InputType.cpp

    r114360 r115704  
    5555#include "RegularExpression.h"
    5656#include "RenderObject.h"
     57#include "RenderTheme.h"
    5758#include "ResetInputType.h"
    5859#include "RuntimeEnabledFeatures.h"
     
    141142}
    142143
     144bool InputType::themeSupportsDataListUI(InputType* type)
     145{
     146    Document* document = type->element()->document();
     147    RefPtr<RenderTheme> theme = document->page() ? document->page()->theme() : RenderTheme::defaultTheme();
     148    return theme->supportsDataListUI(type->formControlType());
     149}
     150
    143151bool InputType::isTextField() const
    144152{
  • trunk/Source/WebCore/html/InputType.h

    r114360 r115704  
    8080    static PassOwnPtr<InputType> createText(HTMLInputElement*);
    8181    virtual ~InputType();
     82
     83    static bool themeSupportsDataListUI(InputType*);
    8284
    8385    virtual const AtomicString& formControlType() const = 0;
  • trunk/Source/WebCore/html/RangeInputType.cpp

    r108976 r115704  
    314314bool RangeInputType::shouldRespectListAttribute()
    315315{
    316     return true;
     316    return InputType::themeSupportsDataListUI(this);
    317317}
    318318
  • trunk/Source/WebCore/html/TextFieldInputType.cpp

    r114360 r115704  
    386386bool TextFieldInputType::shouldRespectListAttribute()
    387387{
    388     return true;
     388    return InputType::themeSupportsDataListUI(this);
    389389}
    390390
  • trunk/Source/WebCore/rendering/RenderTheme.h

    r115097 r115704  
    131131    // A method asking if the theme's controls actually care about redrawing when hovered.
    132132    virtual bool supportsHover(const RenderStyle*) const { return false; }
     133
     134    // A method asking if the platform is able to show datalist suggestions for a given input type.
     135    virtual bool supportsDataListUI(const AtomicString&) const { return false; }
    133136
    134137    // Text selection colors.
  • trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h

    r113030 r115704  
    2525#define RenderThemeChromiumMac_h
    2626
     27#import "RenderThemeChromiumCommon.h"
    2728#import "RenderThemeMac.h"
    2829
     
    3233public:
    3334    static PassRefPtr<RenderTheme> create();
     35
     36    virtual bool supportsDataListUI(const AtomicString& type) const OVERRIDE;
    3437
    3538protected:
  • trunk/Source/WebCore/rendering/RenderThemeChromiumMac.mm

    r113030 r115704  
    7272}
    7373
     74bool RenderThemeChromiumMac::supportsDataListUI(const AtomicString& type) const
     75{
     76    return RenderThemeChromiumCommon::supportsDataListUI(type);
     77}
     78
    7479bool RenderThemeChromiumMac::usesTestModeFocusRingColor() const
    7580{
  • trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp

    r115672 r115704  
    126126}
    127127
     128bool RenderThemeChromiumSkia::supportsDataListUI(const AtomicString& type) const
     129{
     130    return RenderThemeChromiumCommon::supportsDataListUI(type);
     131}
     132
    128133Color RenderThemeChromiumSkia::platformActiveSelectionBackgroundColor() const
    129134{
  • trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h

    r115097 r115704  
    3030
    3131#include "RenderTheme.h"
     32#include "RenderThemeChromiumCommon.h"
    3233
    3334namespace WebCore {
     
    5152        // A method asking if the theme is able to draw the focus ring.
    5253        virtual bool supportsFocusRing(const RenderStyle*) const;
     54
     55        virtual bool supportsDataListUI(const AtomicString& type) const OVERRIDE;
    5356
    5457        // The platform selection color.
Note: See TracChangeset for help on using the changeset viewer.