OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
37 #include "core/rendering/RenderTheme.h" | 37 #include "core/rendering/RenderTheme.h" |
38 #include "platform/DateComponents.h" | 38 #include "platform/DateComponents.h" |
39 #include "platform/DateTimeChooserClient.h" | 39 #include "platform/DateTimeChooserClient.h" |
40 #include "platform/Language.h" | 40 #include "platform/Language.h" |
41 #include "platform/text/PlatformLocale.h" | 41 #include "platform/text/PlatformLocale.h" |
42 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
43 #include "web/ChromeClientImpl.h" | 43 #include "web/ChromeClientImpl.h" |
44 #include "web/WebViewImpl.h" | 44 #include "web/WebViewImpl.h" |
45 | 45 |
46 using namespace WebCore; | 46 using namespace blink; |
47 | 47 |
48 namespace blink { | 48 namespace blink { |
49 | 49 |
50 DateTimeChooserImpl::DateTimeChooserImpl(ChromeClientImpl* chromeClient, WebCore
::DateTimeChooserClient* client, const WebCore::DateTimeChooserParameters& param
eters) | 50 DateTimeChooserImpl::DateTimeChooserImpl(ChromeClientImpl* chromeClient, blink::
DateTimeChooserClient* client, const blink::DateTimeChooserParameters& parameter
s) |
51 : m_chromeClient(chromeClient) | 51 : m_chromeClient(chromeClient) |
52 , m_client(client) | 52 , m_client(client) |
53 , m_popup(0) | 53 , m_popup(0) |
54 , m_parameters(parameters) | 54 , m_parameters(parameters) |
55 , m_locale(WebCore::Locale::create(parameters.locale)) | 55 , m_locale(blink::Locale::create(parameters.locale)) |
56 { | 56 { |
57 ASSERT(m_chromeClient); | 57 ASSERT(m_chromeClient); |
58 ASSERT(m_client); | 58 ASSERT(m_client); |
59 m_popup = m_chromeClient->openPagePopup(this, m_parameters.anchorRectInRootV
iew); | 59 m_popup = m_chromeClient->openPagePopup(this, m_parameters.anchorRectInRootV
iew); |
60 } | 60 } |
61 | 61 |
62 PassRefPtrWillBeRawPtr<DateTimeChooserImpl> DateTimeChooserImpl::create(ChromeCl
ientImpl* chromeClient, WebCore::DateTimeChooserClient* client, const WebCore::D
ateTimeChooserParameters& parameters) | 62 PassRefPtrWillBeRawPtr<DateTimeChooserImpl> DateTimeChooserImpl::create(ChromeCl
ientImpl* chromeClient, blink::DateTimeChooserClient* client, const blink::DateT
imeChooserParameters& parameters) |
63 { | 63 { |
64 return adoptRefWillBeNoop(new DateTimeChooserImpl(chromeClient, client, para
meters)); | 64 return adoptRefWillBeNoop(new DateTimeChooserImpl(chromeClient, client, para
meters)); |
65 } | 65 } |
66 | 66 |
67 DateTimeChooserImpl::~DateTimeChooserImpl() | 67 DateTimeChooserImpl::~DateTimeChooserImpl() |
68 { | 68 { |
69 } | 69 } |
70 | 70 |
71 void DateTimeChooserImpl::endChooser() | 71 void DateTimeChooserImpl::endChooser() |
72 { | 72 { |
73 if (!m_popup) | 73 if (!m_popup) |
74 return; | 74 return; |
75 m_chromeClient->closePagePopup(m_popup); | 75 m_chromeClient->closePagePopup(m_popup); |
76 } | 76 } |
77 | 77 |
78 WebCore::IntSize DateTimeChooserImpl::contentSize() | 78 blink::IntSize DateTimeChooserImpl::contentSize() |
79 { | 79 { |
80 return WebCore::IntSize(0, 0); | 80 return blink::IntSize(0, 0); |
81 } | 81 } |
82 | 82 |
83 static String valueToDateTimeString(double value, AtomicString type) | 83 static String valueToDateTimeString(double value, AtomicString type) |
84 { | 84 { |
85 WebCore::DateComponents components; | 85 blink::DateComponents components; |
86 if (type == WebCore::InputTypeNames::date) | 86 if (type == blink::InputTypeNames::date) |
87 components.setMillisecondsSinceEpochForDate(value); | 87 components.setMillisecondsSinceEpochForDate(value); |
88 else if (type == WebCore::InputTypeNames::datetime_local) | 88 else if (type == blink::InputTypeNames::datetime_local) |
89 components.setMillisecondsSinceEpochForDateTimeLocal(value); | 89 components.setMillisecondsSinceEpochForDateTimeLocal(value); |
90 else if (type == WebCore::InputTypeNames::month) | 90 else if (type == blink::InputTypeNames::month) |
91 components.setMonthsSinceEpoch(value); | 91 components.setMonthsSinceEpoch(value); |
92 else if (type == WebCore::InputTypeNames::time) | 92 else if (type == blink::InputTypeNames::time) |
93 components.setMillisecondsSinceMidnight(value); | 93 components.setMillisecondsSinceMidnight(value); |
94 else if (type == WebCore::InputTypeNames::week) | 94 else if (type == blink::InputTypeNames::week) |
95 components.setMillisecondsSinceEpochForWeek(value); | 95 components.setMillisecondsSinceEpochForWeek(value); |
96 else | 96 else |
97 ASSERT_NOT_REACHED(); | 97 ASSERT_NOT_REACHED(); |
98 return components.type() == WebCore::DateComponents::Invalid ? String() : co
mponents.toString(); | 98 return components.type() == blink::DateComponents::Invalid ? String() : comp
onents.toString(); |
99 } | 99 } |
100 | 100 |
101 void DateTimeChooserImpl::writeDocument(WebCore::SharedBuffer* data) | 101 void DateTimeChooserImpl::writeDocument(blink::SharedBuffer* data) |
102 { | 102 { |
103 String stepString = String::number(m_parameters.step); | 103 String stepString = String::number(m_parameters.step); |
104 String stepBaseString = String::number(m_parameters.stepBase, 11, WTF::Trunc
ateTrailingZeros); | 104 String stepBaseString = String::number(m_parameters.stepBase, 11, WTF::Trunc
ateTrailingZeros); |
105 IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_parameters.a
nchorRectInRootView); | 105 IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_parameters.a
nchorRectInRootView); |
106 String todayLabelString; | 106 String todayLabelString; |
107 String otherDateLabelString; | 107 String otherDateLabelString; |
108 if (m_parameters.type == WebCore::InputTypeNames::month) { | 108 if (m_parameters.type == blink::InputTypeNames::month) { |
109 todayLabelString = locale().queryString(WebLocalizedString::ThisMonthBut
tonLabel); | 109 todayLabelString = locale().queryString(WebLocalizedString::ThisMonthBut
tonLabel); |
110 otherDateLabelString = locale().queryString(WebLocalizedString::OtherMon
thLabel); | 110 otherDateLabelString = locale().queryString(WebLocalizedString::OtherMon
thLabel); |
111 } else if (m_parameters.type == WebCore::InputTypeNames::week) { | 111 } else if (m_parameters.type == blink::InputTypeNames::week) { |
112 todayLabelString = locale().queryString(WebLocalizedString::ThisWeekButt
onLabel); | 112 todayLabelString = locale().queryString(WebLocalizedString::ThisWeekButt
onLabel); |
113 otherDateLabelString = locale().queryString(WebLocalizedString::OtherWee
kLabel); | 113 otherDateLabelString = locale().queryString(WebLocalizedString::OtherWee
kLabel); |
114 } else { | 114 } else { |
115 todayLabelString = locale().queryString(WebLocalizedString::CalendarToda
y); | 115 todayLabelString = locale().queryString(WebLocalizedString::CalendarToda
y); |
116 otherDateLabelString = locale().queryString(WebLocalizedString::OtherDat
eLabel); | 116 otherDateLabelString = locale().queryString(WebLocalizedString::OtherDat
eLabel); |
117 } | 117 } |
118 | 118 |
119 addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", data); | 119 addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", data); |
120 data->append(blink::Platform::current()->loadResource("pickerCommon.css")); | 120 data->append(blink::Platform::current()->loadResource("pickerCommon.css")); |
121 data->append(blink::Platform::current()->loadResource("pickerButton.css")); | 121 data->append(blink::Platform::current()->loadResource("pickerButton.css")); |
(...skipping 24 matching lines...) Expand all Loading... |
146 Vector<String> suggestionLabels; | 146 Vector<String> suggestionLabels; |
147 for (unsigned i = 0; i < m_parameters.suggestions.size(); i++) { | 147 for (unsigned i = 0; i < m_parameters.suggestions.size(); i++) { |
148 suggestionValues.append(valueToDateTimeString(m_parameters.suggestio
ns[i].value, m_parameters.type)); | 148 suggestionValues.append(valueToDateTimeString(m_parameters.suggestio
ns[i].value, m_parameters.type)); |
149 localizedSuggestionValues.append(m_parameters.suggestions[i].localiz
edValue); | 149 localizedSuggestionValues.append(m_parameters.suggestions[i].localiz
edValue); |
150 suggestionLabels.append(m_parameters.suggestions[i].label); | 150 suggestionLabels.append(m_parameters.suggestions[i].label); |
151 } | 151 } |
152 addProperty("suggestionValues", suggestionValues, data); | 152 addProperty("suggestionValues", suggestionValues, data); |
153 addProperty("localizedSuggestionValues", localizedSuggestionValues, data
); | 153 addProperty("localizedSuggestionValues", localizedSuggestionValues, data
); |
154 addProperty("suggestionLabels", suggestionLabels, data); | 154 addProperty("suggestionLabels", suggestionLabels, data); |
155 addProperty("inputWidth", static_cast<unsigned>(m_parameters.anchorRectI
nRootView.width()), data); | 155 addProperty("inputWidth", static_cast<unsigned>(m_parameters.anchorRectI
nRootView.width()), data); |
156 addProperty("showOtherDateEntry", WebCore::RenderTheme::theme().supports
CalendarPicker(m_parameters.type), data); | 156 addProperty("showOtherDateEntry", blink::RenderTheme::theme().supportsCa
lendarPicker(m_parameters.type), data); |
157 addProperty("otherDateLabel", otherDateLabelString, data); | 157 addProperty("otherDateLabel", otherDateLabelString, data); |
158 addProperty("suggestionHighlightColor", WebCore::RenderTheme::theme().ac
tiveListBoxSelectionBackgroundColor().serialized(), data); | 158 addProperty("suggestionHighlightColor", blink::RenderTheme::theme().acti
veListBoxSelectionBackgroundColor().serialized(), data); |
159 addProperty("suggestionHighlightTextColor", WebCore::RenderTheme::theme(
).activeListBoxSelectionForegroundColor().serialized(), data); | 159 addProperty("suggestionHighlightTextColor", blink::RenderTheme::theme().
activeListBoxSelectionForegroundColor().serialized(), data); |
160 } | 160 } |
161 addString("}\n", data); | 161 addString("}\n", data); |
162 | 162 |
163 data->append(blink::Platform::current()->loadResource("pickerCommon.js")); | 163 data->append(blink::Platform::current()->loadResource("pickerCommon.js")); |
164 data->append(blink::Platform::current()->loadResource("suggestionPicker.js")
); | 164 data->append(blink::Platform::current()->loadResource("suggestionPicker.js")
); |
165 data->append(blink::Platform::current()->loadResource("calendarPicker.js")); | 165 data->append(blink::Platform::current()->loadResource("calendarPicker.js")); |
166 addString("</script></body>\n", data); | 166 addString("</script></body>\n", data); |
167 } | 167 } |
168 | 168 |
169 WebCore::Locale& DateTimeChooserImpl::locale() | 169 blink::Locale& DateTimeChooserImpl::locale() |
170 { | 170 { |
171 return *m_locale; | 171 return *m_locale; |
172 } | 172 } |
173 | 173 |
174 void DateTimeChooserImpl::setValueAndClosePopup(int numValue, const String& stri
ngValue) | 174 void DateTimeChooserImpl::setValueAndClosePopup(int numValue, const String& stri
ngValue) |
175 { | 175 { |
176 RefPtrWillBeRawPtr<DateTimeChooserImpl> protector(this); | 176 RefPtrWillBeRawPtr<DateTimeChooserImpl> protector(this); |
177 if (numValue >= 0) | 177 if (numValue >= 0) |
178 setValue(stringValue); | 178 setValue(stringValue); |
179 endChooser(); | 179 endChooser(); |
(...skipping 18 matching lines...) Expand all Loading... |
198 | 198 |
199 void DateTimeChooserImpl::trace(Visitor* visitor) | 199 void DateTimeChooserImpl::trace(Visitor* visitor) |
200 { | 200 { |
201 visitor->trace(m_client); | 201 visitor->trace(m_client); |
202 DateTimeChooser::trace(visitor); | 202 DateTimeChooser::trace(visitor); |
203 } | 203 } |
204 | 204 |
205 } // namespace blink | 205 } // namespace blink |
206 | 206 |
207 #endif // ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 207 #endif // ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
OLD | NEW |