Changeset 99403 in webkit
- Timestamp:
- Nov 7, 2011, 3:39:32 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/forms/color/input-color-onchange-event.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/WebCore.exp.in (modified) (1 diff)
-
Source/WebCore/html/ColorInputType.cpp (modified) (5 diffs)
-
Source/WebCore/html/ColorInputType.h (modified) (1 diff)
-
Source/WebCore/html/HTMLInputElement.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLInputElement.h (modified) (1 diff)
-
Source/WebCore/loader/EmptyClients.h (modified) (1 diff)
-
Source/WebCore/page/Chrome.cpp (modified) (1 diff)
-
Source/WebCore/page/Chrome.h (modified) (1 diff)
-
Source/WebCore/page/ChromeClient.h (modified) (1 diff)
-
Source/WebCore/platform/ColorChooser.cpp (modified) (2 diffs)
-
Source/WebCore/platform/ColorChooser.h (modified) (2 diffs)
-
Source/WebCore/testing/Internals.cpp (modified) (1 diff)
-
Source/WebCore/testing/Internals.h (modified) (1 diff)
-
Source/WebCore/testing/Internals.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r99402 r99403 1 2011-11-07 Keishi Hattori <keishi@webkit.org> 2 3 Change ColorChooser from singleton to ordinary object 4 https://bugs.webkit.org/show_bug.cgi?id=71644 5 6 Reviewed by Kent Tamura. 7 8 * fast/forms/color/input-color-onchange-event.html: Changed to match the changes to window.internals object 9 1 10 2011-11-07 Alexander Pavlov <apavlov@chromium.org> 2 11 -
trunk/LayoutTests/fast/forms/color/input-color-onchange-event.html
r97881 r99403 8 8 <div id="console"></div> 9 9 <script> 10 description('Test if change event fires properly when color chooser changes. Bug 66848 ');10 description('Test if change event fires properly when color chooser changes. Bug 66848 <br> To manually test this, click on the input color element in the top left corner and change the value from the color chooser. See if the number of "value changed" messages matches the number of times you changed the color.'); 11 11 12 12 var input = document.createElement('input'); 13 13 input.type = 'color'; 14 14 input.value = '#000000'; 15 document.body.appendChild(input); 16 17 input.style.position = 'absolute'; 18 input.style.left = '0'; 19 input.style.top = '0'; 20 input.style.width = '20px'; 21 input.style.height = '20px'; 22 15 23 input.onchange = function() { 16 24 debug("value changed to " + input.value); 17 finishJSTest();18 25 }; 19 if (!internals.connectColorChooserClient(input)) 20 testFailed("Could not connect ColorChooserClient."); 21 internals.selectColorInColorChooser('#ff0000'); 26 27 eventSender.mouseMoveTo(10, 10); 28 eventSender.mouseDown(); 29 eventSender.mouseUp(); 30 22 31 // input.onchange should be called 23 internals.selectColorInColorChooser( '#ff0000');32 internals.selectColorInColorChooser(input, '#ff0000'); 24 33 // input.onchange should not be called 34 internals.selectColorInColorChooser(input, '#ff0000'); 35 25 36 shouldBe('input.value', '"#ff0000"'); 26 37 </script> -
trunk/Source/WebCore/ChangeLog
r99401 r99403 1 2011-11-07 Keishi Hattori <keishi@webkit.org> 2 3 Change ColorChooser from singleton to ordinary object 4 https://bugs.webkit.org/show_bug.cgi?id=71644 5 6 Reviewed by Kent Tamura. 7 8 Changing WebCore::ColorChooser from a singleton to an ordinary object can broaden how browsers implement the color chooser interface. 9 10 * WebCore.exp.in: 11 * html/ColorInputType.cpp: 12 (WebCore::ColorInputType::~ColorInputType): 13 (WebCore::ColorInputType::setValue): If a chooser exists, calls Chrome::setSelectedColorInColorChooser 14 (WebCore::ColorInputType::handleDOMActivateEvent): 15 (WebCore::ColorInputType::detach): 16 (WebCore::ColorInputType::didCleanup): Called after cleanup is complete. 17 (WebCore::ColorInputType::cleanupColorChooser): Renamed from cleanupColorChooserIfCurrentClient. 18 * html/ColorInputType.h: 19 * html/HTMLInputElement.cpp: 20 (WebCore::HTMLInputElement::selectColorInColorChooser): 21 * html/HTMLInputElement.h: 22 * loader/EmptyClients.h: 23 (WebCore::EmptyChromeClient::cleanupColorChooser): Added colorChooser argument because there are many WebCore::ColorChoosers now. 24 (WebCore::EmptyChromeClient::setSelectedColorInColorChooser): Ditto. 25 * page/Chrome.cpp: 26 (WebCore::Chrome::cleanupColorChooser): Added colorChooser argument because there are many WebCore::ColorChoosers now. 27 (WebCore::Chrome::setSelectedColorInColorChooser): Ditto. 28 * page/Chrome.h: 29 * page/ChromeClient.h: 30 * platform/ColorChooser.cpp: 31 (WebCore::ColorChooserClient::~ColorChooserClient): 32 (WebCore::ColorChooserClient::newColorChooser): Creates a new color chooser that is connected to itself. 33 (WebCore::ColorChooserClient::discardChooser): Discards the connected color chooser. 34 (WebCore::ColorChooser::ColorChooser): ColorChooser is RefCounted. 35 (WebCore::ColorChooser::create): Creates a ColorChooser that is connected to the given ColorChooserClient. 36 (WebCore::ColorChooser::~ColorChooser): 37 (WebCore::ColorChooser::didChooseColor): Called from WebKit side when user chose a color. Calls ColorChooserClient::didChooseColor 38 (WebCore::ColorChooser::didCleanup): Called from WebKit side when user color chooser was cleaned up. Calls ColorChooserClient::didCleanup 39 * platform/ColorChooser.h: 40 (WebCore::ColorChooserClient::chooser): Returns the current ColorChooser. 41 (WebCore::ColorChooser::disconnectClient): Disconnects the ColorChooserClient. 42 * testing/Internals.cpp: 43 (WebCore::Internals::selectColorInColorChooser): Added element argument. This calls didChooseColor on the ColorChooser of that element. 44 * testing/Internals.h: 45 * testing/Internals.idl: Removed connectColorChooserClient and updated selectColorInColorChooser. 46 1 47 2011-11-07 Alexander Pavlov <apavlov@chromium.org> 2 48 -
trunk/Source/WebCore/WebCore.exp.in
r99347 r99403 1980 1980 1981 1981 #if ENABLE(INPUT_COLOR) 1982 __ZN7WebCore12ColorChooser7chooserEv1983 __ZNK7WebCore12ColorChooser13didChooseColorERKNS_5ColorE1984 1982 __ZN7WebCore5ColorC1ERKN3WTF6StringE 1985 __ZN7WebCore16HTMLInputElement2 1connectToColorChooserEv1983 __ZN7WebCore16HTMLInputElement25selectColorInColorChooserERKNS_5ColorE 1986 1984 #endif 1987 1985 -
trunk/Source/WebCore/html/ColorInputType.cpp
r99395 r99403 67 67 ColorInputType::~ColorInputType() 68 68 { 69 cleanupColorChooser IfCurrentClient();69 cleanupColorChooser(); 70 70 } 71 71 … … 127 127 128 128 updateColorSwatch(); 129 if (ColorChooser::chooser()->client() == this) { 130 if (Chrome* chrome = this->chrome()) 131 chrome->setSelectedColorInColorChooser(valueAsColor()); 132 } 129 Chrome* chrome = this->chrome(); 130 if (chrome && chooser()) 131 chrome->setSelectedColorInColorChooser(chooser(), valueAsColor()); 133 132 } 134 133 … … 141 140 return; 142 141 143 if (Chrome* chrome = this->chrome()) { 144 ColorChooser::chooser()->connectClient(this); 145 chrome->openColorChooser(ColorChooser::chooser(), valueAsColor()); 146 } 142 if (Chrome* chrome = this->chrome()) 143 chrome->openColorChooser(newColorChooser(), valueAsColor()); 147 144 event->setDefaultHandled(); 148 145 } … … 150 147 void ColorInputType::detach() 151 148 { 152 cleanupColorChooser IfCurrentClient();149 cleanupColorChooser(); 153 150 } 154 151 … … 162 159 } 163 160 164 bool ColorInputType::isColorInputType() const 161 void ColorInputType::didCleanup() 165 162 { 166 return true;163 discardChooser(); 167 164 } 168 165 169 void ColorInputType::cleanupColorChooser IfCurrentClient() const166 void ColorInputType::cleanupColorChooser() 170 167 { 171 if (ColorChooser::chooser()->client() != this)172 return;173 if (Chrome* chrome = this->chrome())174 chrome->cleanupColorChooser();168 Chrome* chrome = this->chrome(); 169 if (chrome && chooser()) 170 chrome->cleanupColorChooser(chooser()); 171 discardChooser(); 175 172 } 176 173 -
trunk/Source/WebCore/html/ColorInputType.h
r99395 r99403 58 58 59 59 // ColorChooserClient implementation. 60 virtual void didChooseColor(const Color&) ;61 virtual bool isColorInputType() const;60 virtual void didChooseColor(const Color&) OVERRIDE; 61 virtual void didCleanup() OVERRIDE; 62 62 63 void cleanupColorChooser IfCurrentClient() const;63 void cleanupColorChooser(); 64 64 void updateColorSwatch(); 65 65 HTMLElement* shadowColorSwatch() const; -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r99369 r99403 1538 1538 1539 1539 #if ENABLE(INPUT_COLOR) 1540 bool HTMLInputElement::connectToColorChooser()1540 void HTMLInputElement::selectColorInColorChooser(const Color& color) 1541 1541 { 1542 1542 if (!m_inputType->isColorControl()) 1543 return false; 1544 ColorChooser::chooser()->connectClient(static_cast<ColorInputType*>(m_inputType.get())); 1545 return true; 1543 return; 1544 RefPtr<ColorChooser> chooser = static_cast<ColorInputType*>(m_inputType.get())->chooser(); 1545 if (!chooser) 1546 return; 1547 chooser->didChooseColor(color); 1546 1548 } 1547 1549 #endif -
trunk/Source/WebCore/html/HTMLInputElement.h
r99369 r99403 234 234 #if ENABLE(INPUT_COLOR) 235 235 // For test purposes. 236 bool connectToColorChooser();236 void selectColorInColorChooser(const Color&); 237 237 #endif 238 238 -
trunk/Source/WebCore/loader/EmptyClients.h
r99096 r99403 198 198 #if ENABLE(INPUT_COLOR) 199 199 void openColorChooser(ColorChooser*, const Color&) { } 200 void cleanupColorChooser( ) { }201 void setSelectedColorInColorChooser( const Color&) { }200 void cleanupColorChooser(ColorChooser*) { } 201 void setSelectedColorInColorChooser(ColorChooser*, const Color&) { } 202 202 #endif 203 203 -
trunk/Source/WebCore/page/Chrome.cpp
r98472 r99403 464 464 } 465 465 466 void Chrome::cleanupColorChooser( )467 { 468 m_client->cleanupColorChooser( );469 } 470 471 void Chrome::setSelectedColorInColorChooser( const Color& color)472 { 473 m_client->setSelectedColorInColorChooser(color );466 void Chrome::cleanupColorChooser(ColorChooser* colorChooser) 467 { 468 m_client->cleanupColorChooser(colorChooser); 469 } 470 471 void Chrome::setSelectedColorInColorChooser(ColorChooser* colorChooser, const Color& color) 472 { 473 m_client->setSelectedColorInColorChooser(colorChooser, color); 474 474 } 475 475 #endif -
trunk/Source/WebCore/page/Chrome.h
r98472 r99403 158 158 #if ENABLE(INPUT_COLOR) 159 159 void openColorChooser(ColorChooser*, const Color&); 160 void cleanupColorChooser( );161 void setSelectedColorInColorChooser( const Color&);160 void cleanupColorChooser(ColorChooser*); 161 void setSelectedColorInColorChooser(ColorChooser*, const Color&); 162 162 #endif 163 163 -
trunk/Source/WebCore/page/ChromeClient.h
r98852 r99403 229 229 #if ENABLE(INPUT_COLOR) 230 230 virtual void openColorChooser(ColorChooser*, const Color&) = 0; 231 virtual void cleanupColorChooser( ) = 0;232 virtual void setSelectedColorInColorChooser( const Color&) = 0;231 virtual void cleanupColorChooser(ColorChooser*) = 0; 232 virtual void setSelectedColorInColorChooser(ColorChooser*, const Color&) = 0; 233 233 #endif 234 234 -
trunk/Source/WebCore/platform/ColorChooser.cpp
r95901 r99403 39 39 ColorChooserClient::~ColorChooserClient() 40 40 { 41 ColorChooser::chooser()->disconnectClient(this);41 discardChooser(); 42 42 } 43 43 44 static ColorChooser* staticChooser = 0; 44 ColorChooser* ColorChooserClient::newColorChooser() 45 { 46 discardChooser(); 45 47 46 ColorChooser* ColorChooser::chooser() 47 { 48 if (!staticChooser) 49 staticChooser = adoptPtr(new ColorChooser()).leakPtr(); 50 return staticChooser; 48 m_chooser = ColorChooser::create(this); 49 return m_chooser.get(); 51 50 } 52 51 53 void ColorChooser ::connectClient(ColorChooserClient* client)52 void ColorChooserClient::discardChooser() 54 53 { 55 if (client != m_client) 56 m_client = client; 54 if (m_chooser) 55 m_chooser->disconnectClient(); 56 m_chooser.clear(); 57 57 } 58 58 59 void ColorChooser::disconnectClient(ColorChooserClient* client) 59 inline ColorChooser::ColorChooser(ColorChooserClient* client) 60 : m_client(client) 60 61 { 61 if (client == m_client)62 m_client = 0;63 62 } 64 63 65 void ColorChooser::didChooseColor(const Color& color) const 64 PassRefPtr<ColorChooser> ColorChooser::create(ColorChooserClient* client) 65 { 66 return adoptRef(new ColorChooser(client)); 67 } 68 69 ColorChooser::~ColorChooser() 70 { 71 } 72 73 void ColorChooser::didChooseColor(const Color& color) 66 74 { 67 75 if (m_client) … … 69 77 } 70 78 79 void ColorChooser::didCleanup() 80 { 81 if (m_client) 82 m_client->didCleanup(); 83 } 84 71 85 } 72 86 -
trunk/Source/WebCore/platform/ColorChooser.h
r95901 r99403 32 32 33 33 #include "Color.h" 34 #include <wtf/RefCounted.h> 35 #include <wtf/RefPtr.h> 34 36 35 37 #if ENABLE(INPUT_COLOR) … … 43 45 virtual ~ColorChooserClient(); 44 46 virtual void didChooseColor(const Color&) = 0; 45 virtual bool isColorInputType() const { return false; } 47 virtual void didCleanup() = 0; 48 ColorChooser* chooser() { return m_chooser.get(); } 49 50 protected: 51 ColorChooser* newColorChooser(); 52 void discardChooser(); 53 54 private: 55 RefPtr<ColorChooser> m_chooser; 46 56 }; 47 57 48 class ColorChooser {58 class ColorChooser : public RefCounted<ColorChooser> { 49 59 public: 50 static ColorChooser* chooser(); 60 static PassRefPtr<ColorChooser> create(ColorChooserClient*); 61 ~ColorChooser(); 51 62 52 ColorChooserClient* client() const { return m_client; }; 53 void connectClient(ColorChooserClient*); 54 void disconnectClient(ColorChooserClient*); 63 void disconnectClient() { m_client = 0; } 55 64 56 void didChooseColor(const Color&) const; 65 void didChooseColor(const Color&); 66 void didCleanup(); 57 67 58 68 private: 59 ColorChooser() 60 : m_client(0) 61 { } 69 ColorChooser(ColorChooserClient*); 62 70 63 71 ColorChooserClient* m_client; -
trunk/Source/WebCore/testing/Internals.cpp
r98990 r99403 175 175 176 176 #if ENABLE(INPUT_COLOR) 177 bool Internals::connectColorChooserClient(Element* element)177 void Internals::selectColorInColorChooser(Element* element, const String& colorValue) 178 178 { 179 179 if (!element->hasTagName(HTMLNames::inputTag)) 180 return false;180 return; 181 181 HTMLInputElement* inputElement = element->toInputElement(); 182 182 if (!inputElement) 183 return false; 184 return inputElement->connectToColorChooser(); 185 } 186 187 void Internals::selectColorInColorChooser(const String& colorValue) 188 { 189 ColorChooser::chooser()->colorSelected(Color(colorValue)); 183 return; 184 inputElement->selectColorInColorChooser(Color(colorValue)); 190 185 } 191 186 #endif -
trunk/Source/WebCore/testing/Internals.h
r98990 r99403 61 61 62 62 #if ENABLE(INPUT_COLOR) 63 bool connectColorChooserClient(Element*); 64 void selectColorInColorChooser(const String& colorValue); 63 void selectColorInColorChooser(Element*, const String& colorValue); 65 64 #endif 66 65 -
trunk/Source/WebCore/testing/Internals.idl
r98990 r99403 40 40 41 41 #if defined(ENABLE_INPUT_COLOR) && ENABLE_INPUT_COLOR 42 boolean connectColorChooserClient(in Element element); 43 void selectColorInColorChooser(in DOMString colorValue); 42 void selectColorInColorChooser(in Element element, in DOMString colorValue); 44 43 #endif 45 44
Note:
See TracChangeset
for help on using the changeset viewer.