| Differences between
and this patch
- a/Source/WebCore/ChangeLog +61 lines
Lines 1-5 a/Source/WebCore/ChangeLog_sec1
1
2011-08-05  Keishi Hattori  <keishi@webkit.org>
1
2011-08-05  Keishi Hattori  <keishi@webkit.org>
2
2
3
        Implement <input type=color> UI behavior WebCore part
4
        https://bugs.webkit.org/show_bug.cgi?id=62619
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * WebCore.exp.in: Added __ZN7WebCore12ColorChooser7chooserEv and
9
        __ZNK7WebCore12ColorChooser13colorSelectedERKNS_5ColorE
10
        * WebCore.xcodeproj/project.pbxproj: Added ColorChooser.{h,cpp}
11
        * html/ColorInputType.cpp:
12
        (WebCore::ColorInputType::~ColorInputType): Added. Close color chooser. ex. when type attribute changes.
13
        (WebCore::ColorInputType::valueAsColor): Added.
14
        (WebCore::ColorInputType::setValueAsColor): Added.
15
        (WebCore::ColorInputType::valueChanged): Update selected color in color chooser too.
16
        (WebCore::ColorInputType::handleClickEvent): Opens color chooser.
17
        (WebCore::ColorInputType::handleDOMActivateEvent): Called when element.click(). Open color chooser only
18
        when it was initiated by a user interaction.
19
        (WebCore::ColorInputType::detach): Close color chooser. Called when input element or its ancestors have "display:none"
20
        or is removed from DOM.
21
        (WebCore::ColorInputType::colorSelected): Callback from color chooser.
22
        (WebCore::ColorInputType::closeColorChooserIfClientIsInDocument): Close color chooser if element is in
23
        document. Called when the page navigates away.
24
        (WebCore::ColorInputType::closeColorChooserIfCurrentClient): Close color chooser if this input type is the current client of ColorChooser.
25
        * html/ColorInputType.h:
26
        * html/FileInputType.cpp:
27
        * html/FileInputType.h:
28
        * html/HTMLInputElement.cpp:
29
        (WebCore::HTMLInputElement::detach): Calls InputType::detach
30
        * html/InputType.cpp:
31
        (WebCore::InputType::chrome): Added. Used in FileInputType and ColorInputType.
32
        (WebCore::InputType::detach): ColorInputType overrides this.
33
        * html/InputType.h:
34
        * loader/EmptyClients.h:
35
        (WebCore::EmptyChromeClient::openColorChooser): Added.
36
        (WebCore::EmptyChromeClient::closeColorChooser): Added.
37
        (WebCore::EmptyChromeClient::setSelectedColorInColorChooser): Added.
38
        * loader/FrameLoader.cpp:
39
        (WebCore::FrameLoader::transitionToCommitted): Close color chooser when
40
        navigating away from the page.
41
        * page/Chrome.cpp:
42
        (WebCore::Chrome::openColorChooser): Added. Opens the color chooser.
43
        (WebCore::Chrome::closeColorChooser): Added. Tries to close the color chooser. Might not close if the
44
        listener of the color chooser is another part of the browser or another render process.
45
        (WebCore::Chrome::setSelectedColorInColorChooser): Added. Sets the selected color in the color chooser.
46
        Again, might not be executed if the listener of the color chooser is another part of the browser or another render process.
47
        * page/Chrome.h:
48
        * page/ChromeClient.h:
49
        * platform/ColorChooser.cpp: Added.
50
        (WebCore::ColorChooserClient::~ColorChooserClient): Disconnects itself from the ColorChooser.
51
        (WebCore::ColorChooser::chooser): Get shared instance of ColorChooser.
52
        (WebCore::ColorChooser::chooser): Get shared instance of ColorChooser.
53
        (WebCore::ColorChooser::connectClient): Connects a ColorChooserClient that receives the colorSelected callbacks.
54
        (WebCore::ColorChooser::disconnectClient): Disconnects the connectClient.
55
        (WebCore::ColorChooser::closeColorChooserIfClientIsInDocument): Close the color chooser if the client is
56
        inside the document.
57
        (WebCore::ColorChooser::colorSelected): Called from color chooser listener.
58
        * platform/ColorChooser.h: Added.
59
        (WebCore::ColorChooser::client): Added. Returns the current connected client.
60
        (WebCore::ColorChooser::ColorChooser): Added.
61
62
2011-08-05  Keishi Hattori  <keishi@webkit.org>
63
3
        Sort WebCore.xcodeproj
64
        Sort WebCore.xcodeproj
4
        Accomplished using sort-Xcode-project-file.
65
        Accomplished using sort-Xcode-project-file.
5
66
- a/Source/WebCore/WebCore.exp.in +5 lines
Lines 1945-1947 __ZNK7WebCore13ResourceErrorcvP7NSErrorEv a/Source/WebCore/WebCore.exp.in_sec1
1945
__ZN7WebCore12SchedulePairC1EP9NSRunLoopPK10__CFString
1945
__ZN7WebCore12SchedulePairC1EP9NSRunLoopPK10__CFString
1946
__ZN7WebCore14ResourceHandle12releaseProxyEv
1946
__ZN7WebCore14ResourceHandle12releaseProxyEv
1947
#endif
1947
#endif
1948
1949
#if ENABLE(INPUT_COLOR)
1950
__ZN7WebCore12ColorChooser7chooserEv
1951
__ZNK7WebCore12ColorChooser13colorSelectedERKNS_5ColorE
1952
#endif
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +8 lines
Lines 5333-5338 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
5333
		C0F2A44113869AAB0066C534 /* preprocessor.pm in Headers */ = {isa = PBXBuildFile; fileRef = C0F2A43F13869A280066C534 /* preprocessor.pm */; settings = {ATTRIBUTES = (Private, ); }; };
5333
		C0F2A44113869AAB0066C534 /* preprocessor.pm in Headers */ = {isa = PBXBuildFile; fileRef = C0F2A43F13869A280066C534 /* preprocessor.pm */; settings = {ATTRIBUTES = (Private, ); }; };
5334
		C105DA620F3AA68F001DD44F /* TextEncodingDetectorICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */; };
5334
		C105DA620F3AA68F001DD44F /* TextEncodingDetectorICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */; };
5335
		C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */; };
5335
		C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */; };
5336
		C330A22213EC196B0000B45B /* ColorChooser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C330A22013EC196B0000B45B /* ColorChooser.cpp */; };
5337
		C330A22313EC196B0000B45B /* ColorChooser.h in Headers */ = {isa = PBXBuildFile; fileRef = C330A22113EC196B0000B45B /* ColorChooser.h */; settings = {ATTRIBUTES = (Private, ); }; };
5336
		C50B561612119D23008B46E0 /* GroupSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50B561412119D23008B46E0 /* GroupSettings.cpp */; };
5338
		C50B561612119D23008B46E0 /* GroupSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50B561412119D23008B46E0 /* GroupSettings.cpp */; };
5337
		C50B561712119D23008B46E0 /* GroupSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = C50B561512119D23008B46E0 /* GroupSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
5339
		C50B561712119D23008B46E0 /* GroupSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = C50B561512119D23008B46E0 /* GroupSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
5338
		C50D0E820FF4272900AC2644 /* StorageNamespace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50D0E800FF4272900AC2644 /* StorageNamespace.cpp */; };
5340
		C50D0E820FF4272900AC2644 /* StorageNamespace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50D0E800FF4272900AC2644 /* StorageNamespace.cpp */; };
Lines 12041-12046 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
12041
		C0F2A43F13869A280066C534 /* preprocessor.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = preprocessor.pm; path = scripts/preprocessor.pm; sourceTree = "<group>"; };
12043
		C0F2A43F13869A280066C534 /* preprocessor.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = preprocessor.pm; path = scripts/preprocessor.pm; sourceTree = "<group>"; };
12042
		C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextEncodingDetectorICU.cpp; sourceTree = "<group>"; };
12044
		C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextEncodingDetectorICU.cpp; sourceTree = "<group>"; };
12043
		C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEncodingDetector.h; sourceTree = "<group>"; };
12045
		C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEncodingDetector.h; sourceTree = "<group>"; };
12046
		C330A22013EC196B0000B45B /* ColorChooser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColorChooser.cpp; sourceTree = "<group>"; };
12047
		C330A22113EC196B0000B45B /* ColorChooser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorChooser.h; sourceTree = "<group>"; };
12044
		C50B561412119D23008B46E0 /* GroupSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GroupSettings.cpp; sourceTree = "<group>"; };
12048
		C50B561412119D23008B46E0 /* GroupSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GroupSettings.cpp; sourceTree = "<group>"; };
12045
		C50B561512119D23008B46E0 /* GroupSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupSettings.h; sourceTree = "<group>"; };
12049
		C50B561512119D23008B46E0 /* GroupSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupSettings.h; sourceTree = "<group>"; };
12046
		C50D0E800FF4272900AC2644 /* StorageNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageNamespace.cpp; sourceTree = "<group>"; };
12050
		C50D0E800FF4272900AC2644 /* StorageNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageNamespace.cpp; sourceTree = "<group>"; };
Lines 19032-19037 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
19032
				89D08D9D12228451001241DF /* AsyncFileSystem.h */,
19036
				89D08D9D12228451001241DF /* AsyncFileSystem.h */,
19033
				89D08D9E12228451001241DF /* AsyncFileSystemCallbacks.h */,
19037
				89D08D9E12228451001241DF /* AsyncFileSystemCallbacks.h */,
19034
				51E1ECB10C91C55600DC255B /* AutodrainedPool.h */,
19038
				51E1ECB10C91C55600DC255B /* AutodrainedPool.h */,
19039
				C330A22013EC196B0000B45B /* ColorChooser.cpp */,
19040
				C330A22113EC196B0000B45B /* ColorChooser.h */,
19035
				BCC8CFCA0986CD2400140BF2 /* ColorData.gperf */,
19041
				BCC8CFCA0986CD2400140BF2 /* ColorData.gperf */,
19036
				41D015C90F4B5C71004A662F /* ContentType.cpp */,
19042
				41D015C90F4B5C71004A662F /* ContentType.cpp */,
19037
				41D015C80F4B5C71004A662F /* ContentType.h */,
19043
				41D015C80F4B5C71004A662F /* ContentType.h */,
Lines 20528-20533 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
20528
				93C441F00F813A1A00C1A634 /* CollectionCache.h in Headers */,
20534
				93C441F00F813A1A00C1A634 /* CollectionCache.h in Headers */,
20529
				93C442000F813AE100C1A634 /* CollectionType.h in Headers */,
20535
				93C442000F813AE100C1A634 /* CollectionType.h in Headers */,
20530
				B27535670B053814002CE64F /* Color.h in Headers */,
20536
				B27535670B053814002CE64F /* Color.h in Headers */,
20537
				C330A22313EC196B0000B45B /* ColorChooser.h in Headers */,
20531
				B22279630D00BF220071B782 /* ColorDistance.h in Headers */,
20538
				B22279630D00BF220071B782 /* ColorDistance.h in Headers */,
20532
				F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */,
20539
				F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */,
20533
				EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */,
20540
				EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */,
Lines 23816-23821 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
23816
				93C441EF0F813A1A00C1A634 /* CollectionCache.cpp in Sources */,
23823
				93C441EF0F813A1A00C1A634 /* CollectionCache.cpp in Sources */,
23817
				B27535660B053814002CE64F /* Color.cpp in Sources */,
23824
				B27535660B053814002CE64F /* Color.cpp in Sources */,
23818
				0FCF33240F2B9715004B6795 /* ColorCG.cpp in Sources */,
23825
				0FCF33240F2B9715004B6795 /* ColorCG.cpp in Sources */,
23826
				C330A22213EC196B0000B45B /* ColorChooser.cpp in Sources */,
23819
				1ABA76C911D20E47004C201C /* ColorData.cpp in Sources */,
23827
				1ABA76C911D20E47004C201C /* ColorData.cpp in Sources */,
23820
				B22279620D00BF220071B782 /* ColorDistance.cpp in Sources */,
23828
				B22279620D00BF220071B782 /* ColorDistance.cpp in Sources */,
23821
				F55B3DB31251F12D003EF269 /* ColorInputType.cpp in Sources */,
23829
				F55B3DB31251F12D003EF269 /* ColorInputType.cpp in Sources */,
- a/Source/WebCore/html/ColorInputType.cpp +78 lines
Lines 31-39 a/Source/WebCore/html/ColorInputType.cpp_sec1
31
#include "config.h"
31
#include "config.h"
32
#include "ColorInputType.h"
32
#include "ColorInputType.h"
33
33
34
#include "Chrome.h"
34
#include "Color.h"
35
#include "Color.h"
35
#include "HTMLDivElement.h"
36
#include "HTMLDivElement.h"
36
#include "HTMLInputElement.h"
37
#include "HTMLInputElement.h"
38
#include "MouseEvent.h"
39
#include "ScriptController.h"
37
#include "ShadowRoot.h"
40
#include "ShadowRoot.h"
38
#include <wtf/PassOwnPtr.h>
41
#include <wtf/PassOwnPtr.h>
39
#include <wtf/text/WTFString.h>
42
#include <wtf/text/WTFString.h>
Lines 61-66 PassOwnPtr<InputType> ColorInputType::create(HTMLInputElement* element) a/Source/WebCore/html/ColorInputType.cpp_sec2
61
    return adoptPtr(new ColorInputType(element));
64
    return adoptPtr(new ColorInputType(element));
62
}
65
}
63
66
67
ColorInputType::~ColorInputType()
68
{
69
    closeColorChooserIfCurrentClient();
70
}    
71
64
bool ColorInputType::isColorControl() const
72
bool ColorInputType::isColorControl() const
65
{
73
{
66
    return true;
74
    return true;
Lines 92-97 String ColorInputType::sanitizeValue(const String& proposedValue) a/Source/WebCore/html/ColorInputType.cpp_sec3
92
    return proposedValue.lower();
100
    return proposedValue.lower();
93
}
101
}
94
102
103
Color ColorInputType::valueAsColor() const
104
{
105
    return Color(element()->value());
106
}
107
108
void ColorInputType::setValueAsColor(const Color& color) const
109
{
110
    element()->setValue(color.serialized(), true);
111
}
112
95
void ColorInputType::createShadowSubtree()
113
void ColorInputType::createShadowSubtree()
96
{
114
{
97
    Document* document = element()->document();
115
    Document* document = element()->document();
Lines 111-116 void ColorInputType::createShadowSubtree() a/Source/WebCore/html/ColorInputType.cpp_sec4
111
void ColorInputType::valueChanged()
129
void ColorInputType::valueChanged()
112
{
130
{
113
    updateColorSwatch();
131
    updateColorSwatch();
132
    if (ColorChooser::chooser()->client() == this) {
133
        if (Chrome* chrome = this->chrome())
134
            chrome->setSelectedColorInColorChooser(valueAsColor());
135
    }
136
}
137
138
void ColorInputType::handleClickEvent(MouseEvent* event)
139
{
140
    if (event->isSimulated())
141
        return;
142
143
    if (element()->disabled() || element()->readOnly())
144
        return;
145
146
    if (Chrome* chrome = this->chrome()) {
147
        ColorChooser::chooser()->connectClient(this);
148
        chrome->openColorChooser(ColorChooser::chooser(), valueAsColor());
149
    }
150
    event->setDefaultHandled();
151
}
152
153
void ColorInputType::handleDOMActivateEvent(Event* event)
154
{
155
    if (element()->disabled() || element()->readOnly() || !element()->renderer())
156
        return;
157
158
    if (!ScriptController::processingUserGesture())
159
        return;
160
161
    if (Chrome* chrome = this->chrome()) {
162
        ColorChooser::chooser()->connectClient(this);
163
        chrome->openColorChooser(ColorChooser::chooser(), valueAsColor());
164
    }
165
    event->setDefaultHandled();
166
}
167
168
void ColorInputType::detach()
169
{
170
    closeColorChooserIfCurrentClient();
171
}
172
173
void ColorInputType::colorSelected(const Color& color)
174
{
175
    if (element()->disabled() || element()->readOnly())
176
        return;
177
    setValueAsColor(color);
178
}
179
180
void ColorInputType::closeColorChooserIfClientIsInDocument(Document* document)
181
{
182
    if (element()->document() == document)
183
        closeColorChooserIfCurrentClient();
114
}
184
}
115
185
116
void ColorInputType::updateColorSwatch()
186
void ColorInputType::updateColorSwatch()
Lines 129-134 HTMLElement* ColorInputType::shadowColorSwatch() const a/Source/WebCore/html/ColorInputType.cpp_sec5
129
    return shadow ? toHTMLElement(shadow->firstChild()->firstChild()) : 0;
199
    return shadow ? toHTMLElement(shadow->firstChild()->firstChild()) : 0;
130
}
200
}
131
201
202
void ColorInputType::closeColorChooserIfCurrentClient()
203
{
204
    if (ColorChooser::chooser()->client() == this) {
205
        if (Chrome* chrome = this->chrome())
206
            chrome->closeColorChooser();
207
    }
208
}
209
132
} // namespace WebCore
210
} // namespace WebCore
133
211
134
#endif // ENABLE(INPUT_COLOR)
212
#endif // ENABLE(INPUT_COLOR)
- a/Source/WebCore/html/ColorInputType.h -2 / +14 lines
Lines 31-58 a/Source/WebCore/html/ColorInputType.h_sec1
31
#ifndef ColorInputType_h
31
#ifndef ColorInputType_h
32
#define ColorInputType_h
32
#define ColorInputType_h
33
33
34
#include "BaseButtonInputType.h"
34
#include "ColorChooser.h"
35
#include "InputType.h"
35
36
36
#if ENABLE(INPUT_COLOR)
37
#if ENABLE(INPUT_COLOR)
37
38
38
namespace WebCore {
39
namespace WebCore {
39
40
40
class ColorInputType : public InputType {
41
class ColorInputType : public InputType, private ColorChooserClient {
41
public:
42
public:
42
    static PassOwnPtr<InputType> create(HTMLInputElement*);
43
    static PassOwnPtr<InputType> create(HTMLInputElement*);
43
44
44
private:
45
private:
45
    ColorInputType(HTMLInputElement* element) : InputType(element) { }
46
    ColorInputType(HTMLInputElement* element) : InputType(element) { }
47
    virtual ~ColorInputType();
46
    virtual bool isColorControl() const;
48
    virtual bool isColorControl() const;
47
    virtual const AtomicString& formControlType() const;
49
    virtual const AtomicString& formControlType() const;
48
    virtual bool supportsRequired() const;
50
    virtual bool supportsRequired() const;
49
    virtual String fallbackValue();
51
    virtual String fallbackValue();
50
    virtual String sanitizeValue(const String&);
52
    virtual String sanitizeValue(const String&);
53
    virtual Color valueAsColor() const;
54
    virtual void setValueAsColor(const Color&) const;
51
    virtual void createShadowSubtree();
55
    virtual void createShadowSubtree();
52
    virtual void valueChanged();
56
    virtual void valueChanged();
57
    virtual void handleClickEvent(MouseEvent*);
58
    virtual void handleDOMActivateEvent(Event*);
59
    virtual void detach();
60
61
    // ColorChooserClient implementation.
62
    virtual void colorSelected(const Color&);
63
    virtual void closeColorChooserIfClientIsInDocument(Document*);
53
64
54
    void updateColorSwatch();
65
    void updateColorSwatch();
55
    HTMLElement* shadowColorSwatch() const;
66
    HTMLElement* shadowColorSwatch() const;
67
    void closeColorChooserIfCurrentClient() const;
56
};
68
};
57
69
58
} // namespace WebCore
70
} // namespace WebCore
- a/Source/WebCore/html/FileInputType.cpp -8 lines
Lines 33-39 a/Source/WebCore/html/FileInputType.cpp_sec1
33
#include "HTMLNames.h"
33
#include "HTMLNames.h"
34
#include "Icon.h"
34
#include "Icon.h"
35
#include "LocalizedStrings.h"
35
#include "LocalizedStrings.h"
36
#include "Page.h"
37
#include "RenderFileUploadControl.h"
36
#include "RenderFileUploadControl.h"
38
#include "ScriptController.h"
37
#include "ScriptController.h"
39
#include "ShadowRoot.h"
38
#include "ShadowRoot.h"
Lines 333-345 void FileInputType::updateRendering(PassRefPtr<Icon> icon) a/Source/WebCore/html/FileInputType.cpp_sec2
333
        element()->renderer()->repaint();
332
        element()->renderer()->repaint();
334
}
333
}
335
334
336
Chrome* FileInputType::chrome() const
337
{
338
    if (Page* page = element()->document()->page())
339
        return page->chrome();
340
    return 0;
341
}
342
343
void FileInputType::receiveDroppedFiles(const Vector<String>& paths)
335
void FileInputType::receiveDroppedFiles(const Vector<String>& paths)
344
{
336
{
345
    HTMLInputElement* input = element();
337
    HTMLInputElement* input = element();
- a/Source/WebCore/html/FileInputType.h -2 lines
Lines 39-45 a/Source/WebCore/html/FileInputType.h_sec1
39
39
40
namespace WebCore {
40
namespace WebCore {
41
41
42
class Chrome;
43
class FileList;
42
class FileList;
44
43
45
class FileInputType : public BaseButtonInputType, private FileChooserClient, private FileIconLoaderClient {
44
class FileInputType : public BaseButtonInputType, private FileChooserClient, private FileIconLoaderClient {
Lines 77-83 private: a/Source/WebCore/html/FileInputType.h_sec2
77
    void receiveDropForDirectoryUpload(const Vector<String>&);
76
    void receiveDropForDirectoryUpload(const Vector<String>&);
78
#endif
77
#endif
79
    void requestIcon(const Vector<String>&);
78
    void requestIcon(const Vector<String>&);
80
    Chrome* chrome() const;
81
79
82
    RefPtr<FileList> m_fileList;
80
    RefPtr<FileList> m_fileList;
83
    RefPtr<Icon> m_icon;
81
    RefPtr<Icon> m_icon;
- a/Source/WebCore/html/HTMLInputElement.cpp +1 lines
Lines 880-885 void HTMLInputElement::detach() a/Source/WebCore/html/HTMLInputElement.cpp_sec1
880
{
880
{
881
    HTMLTextFormControlElement::detach();
881
    HTMLTextFormControlElement::detach();
882
    setFormControlValueMatchesRenderer(false);
882
    setFormControlValueMatchesRenderer(false);
883
    m_inputType->detach();
883
}
884
}
884
885
885
String HTMLInputElement::altText() const
886
String HTMLInputElement::altText() const
- a/Source/WebCore/html/InputType.cpp +12 lines
Lines 48-53 a/Source/WebCore/html/InputType.cpp_sec1
48
#include "LocalizedStrings.h"
48
#include "LocalizedStrings.h"
49
#include "MonthInputType.h"
49
#include "MonthInputType.h"
50
#include "NumberInputType.h"
50
#include "NumberInputType.h"
51
#include "Page.h"
51
#include "PasswordInputType.h"
52
#include "PasswordInputType.h"
52
#include "RadioInputType.h"
53
#include "RadioInputType.h"
53
#include "RangeInputType.h"
54
#include "RangeInputType.h"
Lines 395-400 void InputType::dispatchSimulatedClickIfActive(KeyboardEvent* event) const a/Source/WebCore/html/InputType.cpp_sec2
395
    event->setDefaultHandled();
396
    event->setDefaultHandled();
396
}
397
}
397
398
399
Chrome* InputType::chrome() const
400
{
401
    if (Page* page = element()->document()->page())
402
        return page->chrome();
403
    return 0;
404
}
405
398
bool InputType::canSetStringValue() const
406
bool InputType::canSetStringValue() const
399
{
407
{
400
    return true;
408
    return true;
Lines 423-428 void InputType::attach() a/Source/WebCore/html/InputType.cpp_sec3
423
{
431
{
424
}
432
}
425
433
434
void InputType::detach()
435
{
436
}
437
426
void InputType::altAttributeChanged()
438
void InputType::altAttributeChanged()
427
{
439
{
428
}
440
}
- a/Source/WebCore/html/InputType.h -1 / +5 lines
Lines 41-46 a/Source/WebCore/html/InputType.h_sec1
41
namespace WebCore {
41
namespace WebCore {
42
42
43
class BeforeTextInsertedEvent;
43
class BeforeTextInsertedEvent;
44
class Chrome;
45
class Color;
44
class DateComponents;
46
class DateComponents;
45
class Event;
47
class Event;
46
class FileList;
48
class FileList;
Lines 91-97 public: a/Source/WebCore/html/InputType.h_sec2
91
93
92
#if ENABLE(INPUT_COLOR)
94
#if ENABLE(INPUT_COLOR)
93
    virtual bool isColorControl() const;
95
    virtual bool isColorControl() const;
94
#endif // ENABLE(INPUT_COLOR)
96
#endif
95
    virtual bool isCheckbox() const;
97
    virtual bool isCheckbox() const;
96
    virtual bool isEmailField() const;
98
    virtual bool isEmailField() const;
97
    virtual bool isFileUpload() const;
99
    virtual bool isFileUpload() const;
Lines 205-210 public: a/Source/WebCore/html/InputType.h_sec3
205
    virtual bool rendererIsNeeded();
207
    virtual bool rendererIsNeeded();
206
    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
208
    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
207
    virtual void attach();
209
    virtual void attach();
210
    virtual void detach();
208
    virtual void minOrMaxAttributeChanged();
211
    virtual void minOrMaxAttributeChanged();
209
    virtual void altAttributeChanged();
212
    virtual void altAttributeChanged();
210
    virtual void srcAttributeChanged();
213
    virtual void srcAttributeChanged();
Lines 260-265 protected: a/Source/WebCore/html/InputType.h_sec4
260
    void dispatchSimulatedClickIfActive(KeyboardEvent*) const;
263
    void dispatchSimulatedClickIfActive(KeyboardEvent*) const;
261
    // We can't make this a static const data member because VC++ doesn't like it.
264
    // We can't make this a static const data member because VC++ doesn't like it.
262
    static double defaultStepBase() { return 0.0; }
265
    static double defaultStepBase() { return 0.0; }
266
    Chrome* chrome() const;
263
267
264
private:
268
private:
265
    // Raw pointer because the HTMLInputElement object owns this InputType object.
269
    // Raw pointer because the HTMLInputElement object owns this InputType object.
- a/Source/WebCore/loader/EmptyClients.h +6 lines
Lines 196-201 public: a/Source/WebCore/loader/EmptyClients.h_sec1
196
    virtual void enumerateChosenDirectory(FileChooser*) { }
196
    virtual void enumerateChosenDirectory(FileChooser*) { }
197
#endif
197
#endif
198
198
199
#if ENABLE(INPUT_COLOR)
200
    void openColorChooser(ColorChooser*, const Color&) { }
201
    void closeColorChooser() { }
202
    void setSelectedColorInColorChooser(const Color&) { }
203
#endif
204
199
    virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) { }
205
    virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) { }
200
    virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) { }
206
    virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) { }
201
207
- a/Source/WebCore/loader/FrameLoader.cpp +9 lines
Lines 100-105 a/Source/WebCore/loader/FrameLoader.cpp_sec1
100
#include <wtf/text/CString.h>
100
#include <wtf/text/CString.h>
101
#include <wtf/text/WTFString.h>
101
#include <wtf/text/WTFString.h>
102
102
103
#if ENABLE(INPUT_COLOR)
104
#include "ColorChooser.h"
105
#endif
106
103
#if ENABLE(SHARED_WORKERS)
107
#if ENABLE(SHARED_WORKERS)
104
#include "SharedWorkerRepository.h"
108
#include "SharedWorkerRepository.h"
105
#endif
109
#endif
Lines 1816-1821 void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage) a/Source/WebCore/loader/FrameLoader.cpp_sec2
1816
    if (m_frame->view())
1820
    if (m_frame->view())
1817
        m_frame->view()->scrollAnimator()->cancelAnimations();
1821
        m_frame->view()->scrollAnimator()->cancelAnimations();
1818
1822
1823
#if ENABLE(INPUT_COLOR)
1824
    if (m_frame->document())
1825
        ColorChooser::chooser()->closeColorChooserIfClientIsInDocument(m_frame->document());
1826
#endif
1827
1819
    m_client->setCopiesOnScroll();
1828
    m_client->setCopiesOnScroll();
1820
    history()->updateForCommit();
1829
    history()->updateForCommit();
1821
1830
- a/Source/WebCore/page/Chrome.cpp +21 lines
Lines 52-57 a/Source/WebCore/page/Chrome.cpp_sec1
52
#include "StorageNamespace.h"
52
#include "StorageNamespace.h"
53
#endif
53
#endif
54
54
55
#if ENABLE(INPUT_COLOR)
56
#include "ColorChooser.h"
57
#endif
58
55
namespace WebCore {
59
namespace WebCore {
56
60
57
using namespace HTMLNames;
61
using namespace HTMLNames;
Lines 467-472 void Chrome::enumerateChosenDirectory(FileChooser* fileChooser) a/Source/WebCore/page/Chrome.cpp_sec2
467
}
471
}
468
#endif
472
#endif
469
473
474
#if ENABLE(INPUT_COLOR)
475
void Chrome::openColorChooser(ColorChooser* colorChooser, const Color& initialColor)
476
{
477
    m_client->openColorChooser(colorChooser, initialColor);
478
}
479
480
void Chrome::closeColorChooser()
481
{
482
    m_client->closeColorChooser();
483
}
484
485
void Chrome::setSelectedColorInColorChooser(const Color& color)
486
{
487
    m_client->setSelectedColorInColorChooser(color);
488
}
489
#endif
490
470
void Chrome::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser)
491
void Chrome::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser)
471
{
492
{
472
    m_client->runOpenPanel(frame, fileChooser);
493
    m_client->runOpenPanel(frame, fileChooser);
- a/Source/WebCore/page/Chrome.h +9 lines
Lines 36-41 class NSView; a/Source/WebCore/page/Chrome.h_sec1
36
namespace WebCore {
36
namespace WebCore {
37
37
38
    class ChromeClient;
38
    class ChromeClient;
39
#if ENABLE(INPUT_COLOR)
40
    class ColorChooser;
41
#endif
39
    class FileChooser;
42
    class FileChooser;
40
    class FileIconLoader;
43
    class FileIconLoader;
41
    class FloatRect;
44
    class FloatRect;
Lines 154-159 namespace WebCore { a/Source/WebCore/page/Chrome.h_sec2
154
        void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
157
        void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
155
        void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*);
158
        void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*);
156
159
160
#if ENABLE(INPUT_COLOR)
161
        void openColorChooser(ColorChooser*, const Color&);
162
        void closeColorChooser();
163
        void setSelectedColorInColorChooser(const Color&);
164
#endif
165
157
        void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
166
        void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
158
        void loadIconForFiles(const Vector<String>&, FileIconLoader*);
167
        void loadIconForFiles(const Vector<String>&, FileIconLoader*);
159
#if ENABLE(DIRECTORY_UPLOAD)
168
#if ENABLE(DIRECTORY_UPLOAD)
- a/Source/WebCore/page/ChromeClient.h +10 lines
Lines 71-76 namespace WebCore { a/Source/WebCore/page/ChromeClient.h_sec1
71
    class GraphicsLayer;
71
    class GraphicsLayer;
72
#endif
72
#endif
73
73
74
#if ENABLE(INPUT_COLOR)
75
    class ColorChooser;
76
#endif
77
74
#if ENABLE(NOTIFICATIONS)
78
#if ENABLE(NOTIFICATIONS)
75
    class NotificationPresenter;
79
    class NotificationPresenter;
76
#endif
80
#endif
Lines 231-236 namespace WebCore { a/Source/WebCore/page/ChromeClient.h_sec2
231
        virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) = 0;
235
        virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) = 0;
232
        virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) = 0;
236
        virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) = 0;
233
237
238
#if ENABLE(INPUT_COLOR)
239
        virtual void openColorChooser(ColorChooser*, const Color&) = 0;
240
        virtual void closeColorChooser() = 0;
241
        virtual void setSelectedColorInColorChooser(const Color&) = 0;
242
#endif
243
234
        virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
244
        virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
235
        // Asynchronous request to load an icon for specified filenames.
245
        // Asynchronous request to load an icon for specified filenames.
236
        virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) = 0;
246
        virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) = 0;
- a/Source/WebCore/platform/ColorChooser.cpp +77 lines
Line 0 a/Source/WebCore/platform/ColorChooser.cpp_sec1
1
/*
2
 * Copyright (C) 2011 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer. 
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution. 
13
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14
 *     its contributors may be used to endorse or promote products derived
15
 *     from this software without specific prior written permission. 
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 *
28
 */
29
30
#include "config.h"
31
#include "ColorChooser.h"
32
33
#if ENABLE(INPUT_COLOR)
34
35
namespace WebCore {
36
37
ColorChooserClient::~ColorChooserClient()
38
{
39
    ColorChooser::chooser()->disconnectClient(this);
40
}
41
42
static ColorChooser* staticChooser = 0;
43
44
ColorChooser* ColorChooser::chooser()
45
{
46
    if (!staticChooser)
47
        staticChooser = new ColorChooser();
48
    return staticChooser;
49
}
50
51
void ColorChooser::connectClient(ColorChooserClient* client)
52
{
53
    if (client != m_client)
54
        m_client = client;
55
}
56
57
void ColorChooser::disconnectClient(ColorChooserClient* client)
58
{
59
    if (client == m_client)
60
        m_client = 0;
61
}
62
63
void ColorChooser::closeColorChooserIfClientIsInDocument(Document* document)
64
{
65
    if (m_client)
66
        m_client->closeColorChooserIfClientIsInDocument(document);
67
}
68
69
void ColorChooser::colorSelected(const Color& color) const
70
{
71
    if (m_client)
72
        m_client->colorSelected(color);
73
}
74
75
}
76
77
#endif // ENABLE(INPUT_COLOR)
- a/Source/WebCore/platform/ColorChooser.h +72 lines
Line 0 a/Source/WebCore/platform/ColorChooser.h_sec1
1
/*
2
 * Copyright (C) 2011 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1.  Redistributions of source code must retain the above copyright
9
 *     notice, this list of conditions and the following disclaimer. 
10
 * 2.  Redistributions in binary form must reproduce the above copyright
11
 *     notice, this list of conditions and the following disclaimer in the
12
 *     documentation and/or other materials provided with the distribution. 
13
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14
 *     its contributors may be used to endorse or promote products derived
15
 *     from this software without specific prior written permission. 
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 *
28
 */
29
30
#ifndef ColorChooser_h
31
#define ColorChooser_h
32
33
#include "Color.h"
34
#include "Document.h"
35
36
#if ENABLE(INPUT_COLOR)
37
38
namespace WebCore {
39
40
class ColorChooser;
41
42
class ColorChooserClient {
43
public:
44
    virtual ~ColorChooserClient();
45
    virtual void colorSelected(const Color&) = 0;
46
    virtual void closeColorChooserIfClientIsInDocument(Document*) = 0;
47
};
48
49
class ColorChooser {
50
public:
51
    static ColorChooser* chooser();
52
53
    ColorChooserClient* client() const { return m_client; };
54
    void connectClient(ColorChooserClient*);
55
    void disconnectClient(ColorChooserClient*);
56
    void closeColorChooserIfClientIsInDocument(Document*);
57
58
    void colorSelected(const Color&) const;
59
60
private:
61
    ColorChooser()
62
        : m_client(0)
63
    { }
64
65
    ColorChooserClient* m_client;
66
};
67
68
} // namespace WebCore
69
70
#endif // ENABLE(INPUT_COLOR)
71
72
#endif // ColorChooser_h

Return to Bug 62619