Changeset 87372 in webkit


Ignore:
Timestamp:
May 26, 2011 2:58:25 AM (13 years ago)
Author:
keishi@webkit.org
Message:

2011-05-26 Keishi Hattori <keishi@webkit.org>

Reviewed by Kent Tamura.

Add <input type=color> appearance.
https://bugs.webkit.org/show_bug.cgi?id=61275

  • fast/forms/color/input-appearance-color.html: Added. Tests appearance of input type=color.
  • platform/chromium/test_expectations.txt: Expect FAIL for fast/forms/color
  • platform/mac/fast/forms/color/input-appearance-color-expected.png: Added.
  • platform/mac/fast/forms/color/input-appearance-color-expected.txt: Added.

2011-05-26 Keishi Hattori <keishi@webkit.org>

Reviewed by Kent Tamura.

Add <input type=color> appearance.
https://bugs.webkit.org/show_bug.cgi?id=61275

Test: fast/forms/color/input-appearance-color.html

  • css/html.css: (input[type="color"]): Adds square-button appearance. (input[type="color"]::-webkit-color-swatch-wrapper): (input[type="color"]::-webkit-color-swatch): (input[type="color"][list]): Adds menulist appearance. (input[type="color"][list]::-webkit-color-swatch-wrapper): (input[type="color"][list]::-webkit-color-swatch):
  • html/ColorInputType.cpp: (WebCore::ColorInputType::createShadowSubtree): Creates -webkit-color-swatch inside -webkit-color-swatch-wrapper. (WebCore::ColorInputType::updateColorSwatch): Updates background color of shadowColorSwatch. (WebCore::ColorInputType::valueChanged): Calls updateColorSwatch. (WebCore::ColorInputType::shadowColorSwatch): Gets shadowColorSwatch element.
  • html/ColorInputType.h: (WebCore::ColorInputType::ColorInputType): Changed to inherit InputType.
Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r87371 r87372  
     12011-05-26  Keishi Hattori  <keishi@webkit.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        Add <input type=color> appearance.
     6        https://bugs.webkit.org/show_bug.cgi?id=61275
     7
     8        * fast/forms/color/input-appearance-color.html: Added. Tests appearance of input type=color.
     9        * platform/chromium/test_expectations.txt: Expect FAIL for fast/forms/color
     10        * platform/mac/fast/forms/color/input-appearance-color-expected.png: Added.
     11        * platform/mac/fast/forms/color/input-appearance-color-expected.txt: Added.
     12
    1132011-05-26  Kent Tamura  <tkent@chromium.org>
    214
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r87354 r87372  
    41174117
    41184118// New tests added in r87274
    4119 BUGCR83865 : fast/forms/color/input-value-sanitization-color.html = FAIL PASS
     4119BUGCR83865 : fast/forms/color = FAIL PASS
    41204120
    41214121// New tests added in webkit r87284
  • trunk/Source/WebCore/ChangeLog

    r87371 r87372  
     12011-05-26  Keishi Hattori  <keishi@webkit.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        Add <input type=color> appearance.
     6        https://bugs.webkit.org/show_bug.cgi?id=61275
     7
     8        Test: fast/forms/color/input-appearance-color.html
     9
     10        * css/html.css:
     11        (input[type="color"]): Adds square-button appearance.
     12        (input[type="color"]::-webkit-color-swatch-wrapper):
     13        (input[type="color"]::-webkit-color-swatch):
     14        (input[type="color"][list]): Adds menulist appearance.
     15        (input[type="color"][list]::-webkit-color-swatch-wrapper):
     16        (input[type="color"][list]::-webkit-color-swatch):
     17        * html/ColorInputType.cpp:
     18        (WebCore::ColorInputType::createShadowSubtree): Creates -webkit-color-swatch inside -webkit-color-swatch-wrapper.
     19        (WebCore::ColorInputType::updateColorSwatch): Updates background color of shadowColorSwatch.
     20        (WebCore::ColorInputType::valueChanged): Calls updateColorSwatch.
     21        (WebCore::ColorInputType::shadowColorSwatch): Gets shadowColorSwatch element.
     22        * html/ColorInputType.h:
     23        (WebCore::ColorInputType::ColorInputType): Changed to inherit InputType.
     24
    1252011-05-26  Kent Tamura  <tkent@chromium.org>
    226
  • trunk/Source/WebCore/css/html.css

    r87067 r87372  
    584584}
    585585
     586#if defined(ENABLE_INPUT_COLOR) && ENABLE_INPUT_COLOR
     587
     588input[type="color"] {
     589    -webkit-appearance: square-button;
     590    width: 44px;
     591    height: 23px;
     592}
     593
     594input[type="color"]::-webkit-color-swatch-wrapper {
     595    display:-webkit-box;
     596    padding: 4px 2px;
     597    -webkit-box-sizing: border-box;
     598    width: 100%;
     599    height: 100%
     600}
     601
     602input[type="color"]::-webkit-color-swatch {
     603    background-color: #000000;
     604    border: 1px solid #777777;
     605    -webkit-box-flex: 1;
     606}
     607
     608#if defined(ENABLE_DATALIST) && ENABLE_DATALIST
     609
     610input[type="color"][list] {
     611    -webkit-appearance: menulist;
     612    width: 88px;
     613    height: 23px;
     614}
     615
     616input[type="color"][list]::-webkit-color-swatch-wrapper {
     617    padding-left: 8px;
     618    padding-right: 24px;
     619}
     620
     621input[type="color"][list]::-webkit-color-swatch {
     622    border-color: #000000;
     623}
     624
     625#endif // defined(ENABLE_DATALIST) && ENABLE_DATALIST
     626
     627#endif // defined(ENABLE_INPUT_COLOR) && ENABLE_INPUT_COLOR
     628
    586629select {
    587630    -webkit-appearance: menulist;
  • trunk/Source/WebCore/html/ColorInputType.cpp

    r87274 r87372  
    3333
    3434#include "Color.h"
     35#include "ElementWithPseudoId.h"
    3536#include "HTMLInputElement.h"
     37#include "ShadowRoot.h"
    3638#include <wtf/PassOwnPtr.h>
    3739#include <wtf/text/WTFString.h>
     
    9193}
    9294
     95void ColorInputType::createShadowSubtree()
     96{
     97    Document* document = element()->document();
     98    RefPtr<HTMLElement> wrapperElement = ElementWithPseudoId::create(document, "-webkit-color-swatch-wrapper");
     99    ExceptionCode ec = 0;
     100    wrapperElement->appendChild(ElementWithPseudoId::create(document, "-webkit-color-swatch"), ec);
     101    element()->ensureShadowRoot()->appendChild(wrapperElement.release(), ec);
     102   
     103    updateColorSwatch();
     104}
     105
     106void ColorInputType::valueChanged()
     107{
     108    updateColorSwatch();
     109}
     110
     111void ColorInputType::updateColorSwatch()
     112{
     113    HTMLElement* colorSwatch = shadowColorSwatch();
     114    if (!colorSwatch)
     115        return;
     116
     117    ExceptionCode ec;
     118    colorSwatch->style()->setProperty("background-color", element()->value(), ec);
     119}
     120
     121HTMLElement* ColorInputType::shadowColorSwatch() const
     122{
     123    Node* shadow = element()->shadowRoot();
     124    return shadow ? toHTMLElement(shadow->firstChild()->firstChild()) : 0;
     125}
     126
    93127} // namespace WebCore
    94128
  • trunk/Source/WebCore/html/ColorInputType.h

    r87274 r87372  
    3838namespace WebCore {
    3939
    40 class ColorInputType : public BaseButtonInputType {
     40class ColorInputType : public InputType {
    4141public:
    4242    static PassOwnPtr<InputType> create(HTMLInputElement*);
    4343
    4444private:
    45     ColorInputType(HTMLInputElement* element) : BaseButtonInputType(element) { }
     45    ColorInputType(HTMLInputElement* element) : InputType(element) { }
    4646    virtual bool isColorControl() const;
    4747    virtual const AtomicString& formControlType() const;
     
    4949    virtual String fallbackValue();
    5050    virtual String sanitizeValue(const String&);
     51    virtual void createShadowSubtree();
     52    virtual void valueChanged();
     53
     54    void updateColorSwatch();
     55    HTMLElement* shadowColorSwatch() const;
    5156};
    5257
Note: See TracChangeset for help on using the changeset viewer.