Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: Source/web/DateTimeChooserImpl.cpp

Issue 120513004: Don't expose DocumentWriter to embedding layer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/DateTimeChooserImpl.h ('k') | Source/web/WebHelperPluginImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 components.setMonthsSinceEpoch(value); 92 components.setMonthsSinceEpoch(value);
93 else if (type == WebCore::InputTypeNames::time) 93 else if (type == WebCore::InputTypeNames::time)
94 components.setMillisecondsSinceMidnight(value); 94 components.setMillisecondsSinceMidnight(value);
95 else if (type == WebCore::InputTypeNames::week) 95 else if (type == WebCore::InputTypeNames::week)
96 components.setMillisecondsSinceEpochForWeek(value); 96 components.setMillisecondsSinceEpochForWeek(value);
97 else 97 else
98 ASSERT_NOT_REACHED(); 98 ASSERT_NOT_REACHED();
99 return components.type() == WebCore::DateComponents::Invalid ? String() : co mponents.toString(); 99 return components.type() == WebCore::DateComponents::Invalid ? String() : co mponents.toString();
100 } 100 }
101 101
102 void DateTimeChooserImpl::writeDocument(WebCore::DocumentWriter& writer) 102 void DateTimeChooserImpl::writeDocument(WebCore::SharedBuffer* data)
103 { 103 {
104 String stepString = String::number(m_parameters.step); 104 String stepString = String::number(m_parameters.step);
105 String stepBaseString = String::number(m_parameters.stepBase, 11, WTF::Trunc ateTrailingZeros); 105 String stepBaseString = String::number(m_parameters.stepBase, 11, WTF::Trunc ateTrailingZeros);
106 IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_parameters.a nchorRectInRootView); 106 IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_parameters.a nchorRectInRootView);
107 String todayLabelString; 107 String todayLabelString;
108 String otherDateLabelString; 108 String otherDateLabelString;
109 if (m_parameters.type == WebCore::InputTypeNames::month) { 109 if (m_parameters.type == WebCore::InputTypeNames::month) {
110 todayLabelString = locale().queryString(WebLocalizedString::ThisMonthBut tonLabel); 110 todayLabelString = locale().queryString(WebLocalizedString::ThisMonthBut tonLabel);
111 otherDateLabelString = locale().queryString(WebLocalizedString::OtherMon thLabel); 111 otherDateLabelString = locale().queryString(WebLocalizedString::OtherMon thLabel);
112 } else if (m_parameters.type == WebCore::InputTypeNames::week) { 112 } else if (m_parameters.type == WebCore::InputTypeNames::week) {
113 todayLabelString = locale().queryString(WebLocalizedString::ThisWeekButt onLabel); 113 todayLabelString = locale().queryString(WebLocalizedString::ThisWeekButt onLabel);
114 otherDateLabelString = locale().queryString(WebLocalizedString::OtherWee kLabel); 114 otherDateLabelString = locale().queryString(WebLocalizedString::OtherWee kLabel);
115 } else { 115 } else {
116 todayLabelString = locale().queryString(WebLocalizedString::CalendarToda y); 116 todayLabelString = locale().queryString(WebLocalizedString::CalendarToda y);
117 otherDateLabelString = locale().queryString(WebLocalizedString::OtherDat eLabel); 117 otherDateLabelString = locale().queryString(WebLocalizedString::OtherDat eLabel);
118 } 118 }
119 119
120 addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", writer); 120 addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", data);
121 writer.addData(pickerCommonCss, sizeof(pickerCommonCss)); 121 data->append(pickerCommonCss, sizeof(pickerCommonCss));
122 writer.addData(pickerButtonCss, sizeof(pickerButtonCss)); 122 data->append(pickerButtonCss, sizeof(pickerButtonCss));
123 writer.addData(suggestionPickerCss, sizeof(suggestionPickerCss)); 123 data->append(suggestionPickerCss, sizeof(suggestionPickerCss));
124 writer.addData(calendarPickerCss, sizeof(calendarPickerCss)); 124 data->append(calendarPickerCss, sizeof(calendarPickerCss));
125 addString("</style></head><body><div id=main>Loading...</div><script>\n" 125 addString("</style></head><body><div id=main>Loading...</div><script>\n"
126 "window.dialogArguments = {\n", writer); 126 "window.dialogArguments = {\n", data);
127 addProperty("anchorRectInScreen", anchorRectInScreen, writer); 127 addProperty("anchorRectInScreen", anchorRectInScreen, data);
128 addProperty("min", valueToDateTimeString(m_parameters.minimum, m_parameters. type), writer); 128 addProperty("min", valueToDateTimeString(m_parameters.minimum, m_parameters. type), data);
129 addProperty("max", valueToDateTimeString(m_parameters.maximum, m_parameters. type), writer); 129 addProperty("max", valueToDateTimeString(m_parameters.maximum, m_parameters. type), data);
130 addProperty("step", stepString, writer); 130 addProperty("step", stepString, data);
131 addProperty("stepBase", stepBaseString, writer); 131 addProperty("stepBase", stepBaseString, data);
132 addProperty("required", m_parameters.required, writer); 132 addProperty("required", m_parameters.required, data);
133 addProperty("currentValue", valueToDateTimeString(m_parameters.doubleValue, m_parameters.type), writer); 133 addProperty("currentValue", valueToDateTimeString(m_parameters.doubleValue, m_parameters.type), data);
134 addProperty("locale", m_parameters.locale.string(), writer); 134 addProperty("locale", m_parameters.locale.string(), data);
135 addProperty("todayLabel", todayLabelString, writer); 135 addProperty("todayLabel", todayLabelString, data);
136 addProperty("clearLabel", locale().queryString(WebLocalizedString::CalendarC lear), writer); 136 addProperty("clearLabel", locale().queryString(WebLocalizedString::CalendarC lear), data);
137 addProperty("weekLabel", locale().queryString(WebLocalizedString::WeekNumber Label), writer); 137 addProperty("weekLabel", locale().queryString(WebLocalizedString::WeekNumber Label), data);
138 addProperty("weekStartDay", m_locale->firstDayOfWeek(), writer); 138 addProperty("weekStartDay", m_locale->firstDayOfWeek(), data);
139 addProperty("shortMonthLabels", m_locale->shortMonthLabels(), writer); 139 addProperty("shortMonthLabels", m_locale->shortMonthLabels(), data);
140 addProperty("dayLabels", m_locale->weekDayShortLabels(), writer); 140 addProperty("dayLabels", m_locale->weekDayShortLabels(), data);
141 addProperty("isLocaleRTL", m_locale->isRTL(), writer); 141 addProperty("isLocaleRTL", m_locale->isRTL(), data);
142 addProperty("isRTL", m_parameters.isAnchorElementRTL, writer); 142 addProperty("isRTL", m_parameters.isAnchorElementRTL, data);
143 addProperty("mode", m_parameters.type.string(), writer); 143 addProperty("mode", m_parameters.type.string(), data);
144 if (m_parameters.suggestions.size()) { 144 if (m_parameters.suggestions.size()) {
145 Vector<String> suggestionValues; 145 Vector<String> suggestionValues;
146 Vector<String> localizedSuggestionValues; 146 Vector<String> localizedSuggestionValues;
147 Vector<String> suggestionLabels; 147 Vector<String> suggestionLabels;
148 for (unsigned i = 0; i < m_parameters.suggestions.size(); i++) { 148 for (unsigned i = 0; i < m_parameters.suggestions.size(); i++) {
149 suggestionValues.append(valueToDateTimeString(m_parameters.suggestio ns[i].value, m_parameters.type)); 149 suggestionValues.append(valueToDateTimeString(m_parameters.suggestio ns[i].value, m_parameters.type));
150 localizedSuggestionValues.append(m_parameters.suggestions[i].localiz edValue); 150 localizedSuggestionValues.append(m_parameters.suggestions[i].localiz edValue);
151 suggestionLabels.append(m_parameters.suggestions[i].label); 151 suggestionLabels.append(m_parameters.suggestions[i].label);
152 } 152 }
153 addProperty("suggestionValues", suggestionValues, writer); 153 addProperty("suggestionValues", suggestionValues, data);
154 addProperty("localizedSuggestionValues", localizedSuggestionValues, writ er); 154 addProperty("localizedSuggestionValues", localizedSuggestionValues, data );
155 addProperty("suggestionLabels", suggestionLabels, writer); 155 addProperty("suggestionLabels", suggestionLabels, data);
156 addProperty("inputWidth", static_cast<unsigned>(m_parameters.anchorRectI nRootView.width()), writer); 156 addProperty("inputWidth", static_cast<unsigned>(m_parameters.anchorRectI nRootView.width()), data);
157 addProperty("showOtherDateEntry", WebCore::RenderTheme::theme().supports CalendarPicker(m_parameters.type), writer); 157 addProperty("showOtherDateEntry", WebCore::RenderTheme::theme().supports CalendarPicker(m_parameters.type), data);
158 addProperty("otherDateLabel", otherDateLabelString, writer); 158 addProperty("otherDateLabel", otherDateLabelString, data);
159 addProperty("suggestionHighlightColor", WebCore::RenderTheme::theme().ac tiveListBoxSelectionBackgroundColor().serialized(), writer); 159 addProperty("suggestionHighlightColor", WebCore::RenderTheme::theme().ac tiveListBoxSelectionBackgroundColor().serialized(), data);
160 addProperty("suggestionHighlightTextColor", WebCore::RenderTheme::theme( ).activeListBoxSelectionForegroundColor().serialized(), writer); 160 addProperty("suggestionHighlightTextColor", WebCore::RenderTheme::theme( ).activeListBoxSelectionForegroundColor().serialized(), data);
161 } 161 }
162 addString("}\n", writer); 162 addString("}\n", data);
163 163
164 writer.addData(pickerCommonJs, sizeof(pickerCommonJs)); 164 data->append(pickerCommonJs, sizeof(pickerCommonJs));
165 writer.addData(suggestionPickerJs, sizeof(suggestionPickerJs)); 165 data->append(suggestionPickerJs, sizeof(suggestionPickerJs));
166 writer.addData(calendarPickerJs, sizeof(calendarPickerJs)); 166 data->append(calendarPickerJs, sizeof(calendarPickerJs));
167 addString("</script></body>\n", writer); 167 addString("</script></body>\n", data);
168 } 168 }
169 169
170 WebCore::Locale& DateTimeChooserImpl::locale() 170 WebCore::Locale& DateTimeChooserImpl::locale()
171 { 171 {
172 return *m_locale; 172 return *m_locale;
173 } 173 }
174 174
175 void DateTimeChooserImpl::setValueAndClosePopup(int numValue, const String& stri ngValue) 175 void DateTimeChooserImpl::setValueAndClosePopup(int numValue, const String& stri ngValue)
176 { 176 {
177 RefPtr<DateTimeChooserImpl> protector(this); 177 RefPtr<DateTimeChooserImpl> protector(this);
(...skipping 15 matching lines...) Expand all
193 void DateTimeChooserImpl::didClosePopup() 193 void DateTimeChooserImpl::didClosePopup()
194 { 194 {
195 ASSERT(m_client); 195 ASSERT(m_client);
196 m_popup = 0; 196 m_popup = 0;
197 m_client->didEndChooser(); 197 m_client->didEndChooser();
198 } 198 }
199 199
200 } // namespace blink 200 } // namespace blink
201 201
202 #endif // ENABLE(INPUT_MULTIPLE_FIELDS_UI) 202 #endif // ENABLE(INPUT_MULTIPLE_FIELDS_UI)
OLDNEW
« no previous file with comments | « Source/web/DateTimeChooserImpl.h ('k') | Source/web/WebHelperPluginImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698