Changeset 127558 in webkit
- Timestamp:
- Sep 4, 2012 11:35:41 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 11 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r127557 r127558 1 2012-09-04 Keishi Hattori <keishi@webkit.org> 2 3 Move PagePopupClient implementation for input[type=date] to Chromium WebKit layer 4 https://bugs.webkit.org/show_bug.cgi?id=95681 5 6 Reviewed by Kent Tamura. 7 8 We are moving calendar picker PagePopupClient to WebKit layer so ports 9 can use their platform native chooser UI if they have one. 10 DateTimeChooser, DateTimeChooserClient etc. will be reused when we 11 implement the week picker and month picker. 12 13 No new tests. No behavior change. Covered by existing calendar picker tests. 14 15 * WebCore.gypi: 16 * html/shadow/CalendarPickerElement.cpp: 17 (WebCore::CalendarPickerElement::CalendarPickerElement): 18 (WebCore::CalendarPickerElement::~CalendarPickerElement): 19 (WebCore::CalendarPickerElement::didChooseValue): Called when user chose a value. 20 (WebCore): 21 (WebCore::CalendarPickerElement::didEndChooser): Called when chooser has ended. 22 (WebCore::CalendarPickerElement::openPopup): 23 (WebCore::CalendarPickerElement::closePopup): 24 * html/shadow/CalendarPickerElement.h: 25 (CalendarPickerElement): 26 * loader/EmptyClients.cpp: 27 (WebCore): 28 (WebCore::EmptyChromeClient::openDateTimeChooser): 29 * loader/EmptyClients.h: 30 (EmptyChromeClient): 31 * page/ChromeClient.h: 32 (WebCore): 33 (ChromeClient): 34 * platform/DateTimeChooser.h: 35 (WebCore): 36 (DateTimeChooserParameters): Contains information needed to open the DateTimeChooser. 37 (DateTimeChooser): 38 (WebCore::DateTimeChooser::~DateTimeChooser): 39 * platform/DateTimeChooserClient.h: 40 (WebCore): 41 (DateTimeChooserClient): 42 (WebCore::DateTimeChooserClient::~DateTimeChooserClient): 43 1 44 2012-09-04 Mike Lawther <mikelawther@chromium.org> 2 45 -
trunk/Source/WebCore/WebCore.gypi
r127535 r127558 338 338 'platform/Timer.h', 339 339 'platform/TreeShared.h', 340 'platform/DateTimeChooser.h', 341 'platform/DateTimeChooserClient.h', 340 342 'platform/VisitedLinkStrategy.h', 341 343 'platform/VisitedLinks.h', -
trunk/Source/WebCore/html/shadow/CalendarPickerElement.cpp
r125641 r127558 34 34 #if ENABLE(CALENDAR_PICKER) 35 35 36 #include "CalendarPicker.h"37 36 #include "Chrome.h" 38 37 #include "ChromeClient.h" 39 #include "DateComponents.h"40 38 #include "Event.h" 41 39 #include "FrameView.h" 42 40 #include "HTMLInputElement.h" 43 #include "HTMLNames.h"44 #include "Language.h"45 #include "LocalizedDate.h"46 #include "LocalizedStrings.h"47 41 #include "Page.h" 48 #include "PickerCommon.h"49 42 #include "RenderDetailsMarker.h" 50 #include "RenderTheme.h"51 #include <wtf/text/StringBuilder.h>52 43 53 44 using namespace WTF::Unicode; … … 59 50 inline CalendarPickerElement::CalendarPickerElement(Document* document) 60 51 : HTMLDivElement(divTag, document) 61 , m_ popup(0)52 , m_chooser(nullptr) 62 53 { 63 54 setShadowPseudoId("-webkit-calendar-picker-indicator"); … … 72 63 { 73 64 closePopup(); 74 ASSERT(!m_ popup);65 ASSERT(!m_chooser); 75 66 } 76 67 … … 115 106 } 116 107 108 void CalendarPickerElement::didChooseValue(const String& value) 109 { 110 hostInput()->setValue(value, DispatchChangeEvent); 111 } 112 113 void CalendarPickerElement::didEndChooser() 114 { 115 m_chooser.clear(); 116 } 117 117 118 void CalendarPickerElement::openPopup() 118 119 { 119 if (m_ popup)120 if (m_chooser) 120 121 return; 121 122 if (!document()->page()) … … 126 127 if (!document()->view()) 127 128 return; 128 IntRect elementRectInRootView = document()->view()->contentsToRootView(hostInput()->getPixelSnappedRect()); 129 m_popup = chrome->client()->openPagePopup(this, elementRectInRootView); 129 130 HTMLInputElement* input = hostInput(); 131 DateTimeChooserParameters parameters; 132 parameters.type = input->type(); 133 parameters.minimum = input->minimum(); 134 parameters.maximum = input->maximum(); 135 parameters.required = input->required(); 136 Decimal step; 137 if (hostInput()->getAllowedValueStep(&step)) 138 parameters.step = 1.0; 139 else 140 parameters.step = step.toDouble(); 141 parameters.anchorRectInRootView = document()->view()->contentsToRootView(hostInput()->getPixelSnappedRect()); 142 parameters.currentValue = input->value(); 143 // FIXME: parameters.suggestionValues and suggestionLabels will be used when we support datalist. 144 m_chooser = chrome->client()->openDateTimeChooser(this, parameters); 130 145 } 131 146 132 147 void CalendarPickerElement::closePopup() 133 148 { 134 if (!m_ popup)149 if (!m_chooser) 135 150 return; 136 if (!document()->page()) 137 return; 138 Chrome* chrome = document()->page()->chrome(); 139 if (!chrome) 140 return; 141 chrome->client()->closePagePopup(m_popup); 151 m_chooser->endChooser(); 142 152 } 143 153 … … 148 158 } 149 159 150 IntSize CalendarPickerElement::contentSize()151 {152 return IntSize(0, 0);153 }154 155 void CalendarPickerElement::writeDocument(DocumentWriter& writer)156 {157 HTMLInputElement* input = hostInput();158 DateComponents date;159 date.setMillisecondsSinceEpochForDate(input->minimum());160 String minString = date.toString();161 date.setMillisecondsSinceEpochForDate(input->maximum());162 String maxString = date.toString();163 Decimal step;164 String stepString = input->fastGetAttribute(stepAttr);165 if (stepString.isEmpty() || !input->getAllowedValueStep(&step))166 stepString = "1";167 168 addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", writer);169 writer.addData(pickerCommonCss, sizeof(pickerCommonCss));170 writer.addData(calendarPickerCss, sizeof(calendarPickerCss));171 if (document()->page()) {172 CString extraStyle = document()->page()->theme()->extraCalendarPickerStyleSheet();173 if (extraStyle.length())174 writer.addData(extraStyle.data(), extraStyle.length());175 }176 addString("</style></head><body><div id=main>Loading...</div><script>\n"177 "window.dialogArguments = {\n", writer);178 addProperty("min", minString, writer);179 addProperty("max", maxString, writer);180 addProperty("step", stepString, writer);181 addProperty("required", input->required(), writer);182 addProperty("currentValue", input->value(), writer);183 addProperty("locale", defaultLanguage(), writer);184 addProperty("todayLabel", calendarTodayText(), writer);185 addProperty("clearLabel", calendarClearText(), writer);186 addProperty("weekStartDay", firstDayOfWeek(), writer);187 addProperty("monthLabels", monthLabels(), writer);188 addProperty("dayLabels", weekDayShortLabels(), writer);189 Direction dir = direction(monthLabels()[0][0]);190 addProperty("isRTL", dir == RightToLeft || dir == RightToLeftArabic, writer);191 addString("}\n", writer);192 193 writer.addData(pickerCommonJs, sizeof(pickerCommonJs));194 writer.addData(calendarPickerJs, sizeof(calendarPickerJs));195 addString("</script></body>\n", writer);196 }197 198 void CalendarPickerElement::setValueAndClosePopup(int numValue, const String& stringValue)199 {200 ASSERT(m_popup);201 closePopup();202 if (numValue >= 0)203 hostInput()->setValue(stringValue, DispatchChangeEvent);204 }205 206 void CalendarPickerElement::didClosePopup()207 {208 m_popup = 0;209 }210 211 160 } 212 161 -
trunk/Source/WebCore/html/shadow/CalendarPickerElement.h
r124022 r127558 33 33 34 34 #if ENABLE(CALENDAR_PICKER) 35 36 #include "DateTimeChooser.h" 37 #include "DateTimeChooserClient.h" 35 38 #include "HTMLDivElement.h" 36 #include "PagePopupClient.h"39 #include <wtf/OwnPtr.h> 37 40 38 41 namespace WebCore { … … 41 44 class PagePopup; 42 45 43 class CalendarPickerElement : public HTMLDivElement, public PagePopupClient {46 class CalendarPickerElement : public HTMLDivElement, public DateTimeChooserClient { 44 47 public: 45 48 static PassRefPtr<CalendarPickerElement> create(Document*); … … 49 52 virtual bool willRespondToMouseClickEvents() OVERRIDE; 50 53 54 // DateTimeChooserClient implementation. 55 virtual void didChooseValue(const String&) OVERRIDE; 56 virtual void didEndChooser() OVERRIDE; 57 51 58 private: 52 59 CalendarPickerElement(Document*); … … 55 62 virtual void detach() OVERRIDE; 56 63 57 // PagePopupClient functions:58 virtual IntSize contentSize() OVERRIDE;59 virtual void writeDocument(DocumentWriter&) OVERRIDE;60 virtual void setValueAndClosePopup(int, const String&) OVERRIDE;61 virtual void didClosePopup() OVERRIDE;62 63 64 HTMLInputElement* hostInput(); 64 65 65 PagePopup* m_popup;66 OwnPtr<DateTimeChooser> m_chooser; 66 67 }; 67 68 -
trunk/Source/WebCore/loader/EmptyClients.cpp
r124162 r127558 29 29 #include "EmptyClients.h" 30 30 31 #include "DateTimeChooser.h" 31 32 #include "DocumentLoader.h" 32 33 #include "FileChooser.h" … … 99 100 #if ENABLE(INPUT_TYPE_COLOR) 100 101 PassOwnPtr<ColorChooser> EmptyChromeClient::createColorChooser(ColorChooserClient*, const Color&) 102 { 103 return nullptr; 104 } 105 #endif 106 107 #if ENABLE(CALENDAR_PICKER) 108 PassOwnPtr<DateTimeChooser> EmptyChromeClient::openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) 101 109 { 102 110 return nullptr; -
trunk/Source/WebCore/loader/EmptyClients.h
r123354 r127558 173 173 #endif 174 174 175 #if ENABLE(CALENDAR_PICKER) 176 virtual PassOwnPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) OVERRIDE; 177 #endif 178 175 179 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) OVERRIDE; 176 180 virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) { } -
trunk/Source/WebCore/page/ChromeClient.h
r124753 r127558 49 49 50 50 class AccessibilityObject; 51 class DateTimeChooser; 52 class DateTimeChooserClient; 51 53 class Element; 52 54 class FileChooser; … … 70 72 class Widget; 71 73 74 struct DateTimeChooserParameters; 72 75 struct FrameLoadRequest; 73 76 struct ViewportArguments; … … 221 224 #if ENABLE(INPUT_TYPE_COLOR) 222 225 virtual PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color&) = 0; 226 #endif 227 228 #if ENABLE(CALENDAR_PICKER) 229 virtual PassOwnPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) = 0; 223 230 #endif 224 231 -
trunk/Source/WebCore/platform/DateTimeChooser.h
r127557 r127558 29 29 */ 30 30 31 #ifndef CalendarPickerElement_h32 #define CalendarPickerElement_h31 #ifndef DateTimeChooser_h 32 #define DateTimeChooser_h 33 33 34 #if ENABLE(CALENDAR_PICKER) 35 #include "HTMLDivElement.h" 36 #include "PagePopupClient.h" 34 #include "IntRect.h" 35 #include <wtf/text/WTFString.h> 37 36 38 37 namespace WebCore { 39 38 40 class HTMLInputElement; 41 class PagePopup; 42 43 class CalendarPickerElement : public HTMLDivElement, public PagePopupClient { 44 public: 45 static PassRefPtr<CalendarPickerElement> create(Document*); 46 virtual ~CalendarPickerElement(); 47 void openPopup(); 48 void closePopup(); 49 virtual bool willRespondToMouseClickEvents() OVERRIDE; 50 51 private: 52 CalendarPickerElement(Document*); 53 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE; 54 virtual void defaultEventHandler(Event*) OVERRIDE; 55 virtual void detach() OVERRIDE; 56 57 // PagePopupClient functions: 58 virtual IntSize contentSize() OVERRIDE; 59 virtual void writeDocument(DocumentWriter&) OVERRIDE; 60 virtual void setValueAndClosePopup(int, const String&) OVERRIDE; 61 virtual void didClosePopup() OVERRIDE; 62 63 HTMLInputElement* hostInput(); 64 65 PagePopup* m_popup; 39 struct DateTimeChooserParameters { 40 AtomicString type; 41 IntRect anchorRectInRootView; 42 String currentValue; 43 Vector<String> suggestionValues; 44 Vector<String> suggestionLabels; 45 double minimum; 46 double maximum; 47 double step; 48 bool required; 66 49 }; 67 50 68 } 69 #endif 70 #endif 51 // For pickers like color pickers and date pickers. 52 class DateTimeChooser { 53 public: 54 virtual ~DateTimeChooser() { } 55 56 virtual void endChooser() = 0; 57 }; 58 59 } // namespace WebCore 60 61 #endif // DateTimeChooser_h -
trunk/Source/WebCore/platform/DateTimeChooserClient.h
r127557 r127558 29 29 */ 30 30 31 #ifndef CalendarPickerElement_h 32 #define CalendarPickerElement_h 33 34 #if ENABLE(CALENDAR_PICKER) 35 #include "HTMLDivElement.h" 36 #include "PagePopupClient.h" 31 #ifndef DateTimeChooserClient_h 32 #define DateTimeChooserClient_h 37 33 38 34 namespace WebCore { 39 35 40 class HTMLInputElement; 41 class PagePopup; 36 class DateTimeChooserClient { 37 public: 38 virtual ~DateTimeChooserClient() { } 42 39 43 class CalendarPickerElement : public HTMLDivElement, public PagePopupClient { 44 public: 45 static PassRefPtr<CalendarPickerElement> create(Document*); 46 virtual ~CalendarPickerElement(); 47 void openPopup(); 48 void closePopup(); 49 virtual bool willRespondToMouseClickEvents() OVERRIDE; 50 51 private: 52 CalendarPickerElement(Document*); 53 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE; 54 virtual void defaultEventHandler(Event*) OVERRIDE; 55 virtual void detach() OVERRIDE; 56 57 // PagePopupClient functions: 58 virtual IntSize contentSize() OVERRIDE; 59 virtual void writeDocument(DocumentWriter&) OVERRIDE; 60 virtual void setValueAndClosePopup(int, const String&) OVERRIDE; 61 virtual void didClosePopup() OVERRIDE; 62 63 HTMLInputElement* hostInput(); 64 65 PagePopup* m_popup; 40 // Called when user picked a value. 41 virtual void didChooseValue(const String&) = 0; 42 // Called when chooser has ended. 43 virtual void didEndChooser() = 0; 66 44 }; 67 45 68 } 69 #endif 70 #endif 46 } // namespace WebCore 47 48 #endif // DateTimeChooserClient_h -
trunk/Source/WebKit/chromium/ChangeLog
r127540 r127558 1 2012-09-04 Keishi Hattori <keishi@webkit.org> 2 3 Move PagePopupClient implementation for input[type=date] to Chromium WebKit layer 4 https://bugs.webkit.org/show_bug.cgi?id=95681 5 6 Reviewed by Kent Tamura. 7 8 * WebKit.gyp: 9 * src/ChromeClientImpl.cpp: 10 (WebKit): 11 (WebKit::ChromeClientImpl::openDateTimeChooser): 12 * src/ChromeClientImpl.h: 13 (WebCore): 14 (ChromeClientImpl): 15 * src/DateTimeChooserImpl.cpp: Added. 16 (WebKit): 17 (WebKit::DateTimeChooserImpl::DateTimeChooserImpl): 18 (WebKit::DateTimeChooserImpl::~DateTimeChooserImpl): 19 (WebKit::DateTimeChooserImpl::endChooser): 20 (WebKit::DateTimeChooserImpl::contentSize): 21 (WebKit::DateTimeChooserImpl::writeDocument): 22 (WebKit::DateTimeChooserImpl::setValueAndClosePopup): 23 (WebKit::DateTimeChooserImpl::didClosePopup): 24 * src/DateTimeChooserImpl.h: 25 (WebCore): 26 (WebKit): 27 (DateTimeChooserImpl): 28 1 29 2012-09-04 Adam Barth <abarth@chromium.org> 2 30 -
trunk/Source/WebKit/chromium/WebKit.gyp
r127378 r127558 359 359 'src/BlobRegistryProxy.cpp', 360 360 'src/BlobRegistryProxy.h', 361 'src/DateTimeChooserImpl.cpp', 362 'src/DateTimeChooserImpl.h', 361 363 'src/ChromeClientImpl.cpp', 362 364 'src/ChromeClientImpl.h', -
trunk/Source/WebKit/chromium/src/ChromeClientImpl.cpp
r126735 r127558 43 43 #include "Cursor.h" 44 44 #include "DatabaseTracker.h" 45 #include "DateTimeChooserImpl.h" 45 46 #include "Document.h" 46 47 #include "DocumentLoader.h" … … 705 706 #endif 706 707 708 #if ENABLE(CALENDAR_PICKER) 709 PassOwnPtr<WebCore::DateTimeChooser> ChromeClientImpl::openDateTimeChooser(WebCore::DateTimeChooserClient* pickerClient, const WebCore::DateTimeChooserParameters& parameters) 710 { 711 return adoptPtr(new DateTimeChooserImpl(this, pickerClient, parameters)); 712 } 713 #endif 714 707 715 void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser) 708 716 { -
trunk/Source/WebKit/chromium/src/ChromeClientImpl.h
r126735 r127558 51 51 class RenderBox; 52 52 class SecurityOrigin; 53 class DateTimeChooser; 54 class DateTimeChooserClient; 53 55 struct WindowFeatures; 54 56 } … … 145 147 PassOwnPtr<WebColorChooser> createWebColorChooser(WebColorChooserClient*, const WebColor&); 146 148 #endif 149 #if ENABLE(CALENDAR_PICKER) 150 virtual PassOwnPtr<WebCore::DateTimeChooser> openDateTimeChooser(WebCore::DateTimeChooserClient*, const WebCore::DateTimeChooserParameters&) OVERRIDE; 151 #endif 147 152 virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); 148 153 virtual void loadIconForFiles(const Vector<WTF::String>&, WebCore::FileIconLoader*); -
trunk/Source/WebKit/chromium/src/DateTimeChooserImpl.h
r127557 r127558 29 29 */ 30 30 31 #ifndef CalendarPickerElement_h 32 #define CalendarPickerElement_h 31 #ifndef DateTimeChooserImpl_h 32 #define DateTimeChooserImpl_h 33 34 #include "DateTimeChooser.h" 35 #include "PagePopupClient.h" 33 36 34 37 #if ENABLE(CALENDAR_PICKER) 35 #include "HTMLDivElement.h"36 #include "PagePopupClient.h"37 38 38 39 namespace WebCore { 40 class PagePopup; 41 class DateTimeChooserClient; 42 } 39 43 40 class HTMLInputElement; 41 class PagePopup; 44 namespace WebKit { 42 45 43 class CalendarPickerElement : public HTMLDivElement, public PagePopupClient { 46 class ChromeClientImpl; 47 48 class DateTimeChooserImpl : public WebCore::DateTimeChooser, public WebCore::PagePopupClient { 44 49 public: 45 static PassRefPtr<CalendarPickerElement> create(Document*);46 virtual ~ CalendarPickerElement();47 void openPopup(); 48 void closePopup();49 virtual bool willRespondToMouseClickEvents() OVERRIDE;50 DateTimeChooserImpl(ChromeClientImpl*, WebCore::DateTimeChooserClient*, const WebCore::DateTimeChooserParameters&); 51 virtual ~DateTimeChooserImpl(); 52 53 // DateTimeChooser functions: 54 virtual void endChooser() OVERRIDE; 50 55 51 56 private: 52 CalendarPickerElement(Document*);53 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE;54 virtual void defaultEventHandler(Event*) OVERRIDE;55 virtual void detach() OVERRIDE;56 57 57 // PagePopupClient functions: 58 virtual IntSize contentSize() OVERRIDE;59 virtual void writeDocument( DocumentWriter&) OVERRIDE;58 virtual WebCore::IntSize contentSize() OVERRIDE; 59 virtual void writeDocument(WebCore::DocumentWriter&) OVERRIDE; 60 60 virtual void setValueAndClosePopup(int, const String&) OVERRIDE; 61 61 virtual void didClosePopup() OVERRIDE; 62 62 63 HTMLInputElement* hostInput(); 64 65 PagePopup* m_popup; 63 ChromeClientImpl* m_chromeClient; 64 WebCore::DateTimeChooserClient* m_client; 65 WebCore::PagePopup* m_popup; 66 WebCore::DateTimeChooserParameters m_parameters; 66 67 }; 67 68 68 69 } 69 #endif 70 #endif 70 71 #endif // ENABLE(CALENDAR_PICKER) 72 73 #endif // DateTimeChooserImpl_h
Note: See TracChangeset
for help on using the changeset viewer.