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

Unified Diff: content/renderer/render_widget.cc

Issue 791923003: replace COMPILE_ASSERT with static_assert in content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixups Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index f3e5a62786140b62f69e66cc9cb1a0c6fa96fb85..9eede9dc403a09f558f6c4470cf99282ef9dee0b 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -1978,40 +1978,28 @@ void RenderWidget::UpdateSelectionBounds() {
}
// Check blink::WebTextInputType and ui::TextInputType is kept in sync.
-COMPILE_ASSERT(int(blink::WebTextInputTypeNone) == \
- int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums);
-COMPILE_ASSERT(int(blink::WebTextInputTypeText) == \
- int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums);
-COMPILE_ASSERT(int(blink::WebTextInputTypePassword) == \
- int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums);
-COMPILE_ASSERT(int(blink::WebTextInputTypeSearch) == \
- int(ui::TEXT_INPUT_TYPE_SEARCH), mismatching_enums);
-COMPILE_ASSERT(int(blink::WebTextInputTypeEmail) == \
- int(ui::TEXT_INPUT_TYPE_EMAIL), mismatching_enums);
-COMPILE_ASSERT(int(blink::WebTextInputTypeNumber) == \
- int(ui::TEXT_INPUT_TYPE_NUMBER), mismatching_enums);
-COMPILE_ASSERT(int(blink::WebTextInputTypeTelephone) == \
- int(ui::TEXT_INPUT_TYPE_TELEPHONE), mismatching_enums);
-COMPILE_ASSERT(int(blink::WebTextInputTypeURL) == \
- int(ui::TEXT_INPUT_TYPE_URL), mismatching_enums);
-COMPILE_ASSERT(int(blink::WebTextInputTypeDate) == \
- int(ui::TEXT_INPUT_TYPE_DATE), mismatching_enum);
-COMPILE_ASSERT(int(blink::WebTextInputTypeDateTime) == \
- int(ui::TEXT_INPUT_TYPE_DATE_TIME), mismatching_enum);
-COMPILE_ASSERT(int(blink::WebTextInputTypeDateTimeLocal) == \
- int(ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL), mismatching_enum);
-COMPILE_ASSERT(int(blink::WebTextInputTypeMonth) == \
- int(ui::TEXT_INPUT_TYPE_MONTH), mismatching_enum);
-COMPILE_ASSERT(int(blink::WebTextInputTypeTime) == \
- int(ui::TEXT_INPUT_TYPE_TIME), mismatching_enum);
-COMPILE_ASSERT(int(blink::WebTextInputTypeWeek) == \
- int(ui::TEXT_INPUT_TYPE_WEEK), mismatching_enum);
-COMPILE_ASSERT(int(blink::WebTextInputTypeTextArea) == \
- int(ui::TEXT_INPUT_TYPE_TEXT_AREA), mismatching_enums);
-COMPILE_ASSERT(int(blink::WebTextInputTypeContentEditable) == \
- int(ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE), mismatching_enums);
-COMPILE_ASSERT(int(blink::WebTextInputTypeDateTimeField) == \
- int(ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD), mismatching_enums);
+#define STATIC_ASSERT_WTIT_ENUM_MATCH(a, b) \
+ static_assert(int(blink::WebTextInputType##a) \
+ == int(ui::TEXT_INPUT_TYPE_##b), \
+ "mismatching enums: " #a)
+
+STATIC_ASSERT_WTIT_ENUM_MATCH(None, NONE);
+STATIC_ASSERT_WTIT_ENUM_MATCH(Text, TEXT);
+STATIC_ASSERT_WTIT_ENUM_MATCH(Password, PASSWORD);
+STATIC_ASSERT_WTIT_ENUM_MATCH(Search, SEARCH);
+STATIC_ASSERT_WTIT_ENUM_MATCH(Email, EMAIL);
+STATIC_ASSERT_WTIT_ENUM_MATCH(Number, NUMBER);
+STATIC_ASSERT_WTIT_ENUM_MATCH(Telephone, TELEPHONE);
+STATIC_ASSERT_WTIT_ENUM_MATCH(URL, URL);
+STATIC_ASSERT_WTIT_ENUM_MATCH(Date, DATE);
+STATIC_ASSERT_WTIT_ENUM_MATCH(DateTime, DATE_TIME);
+STATIC_ASSERT_WTIT_ENUM_MATCH(DateTimeLocal, DATE_TIME_LOCAL);
+STATIC_ASSERT_WTIT_ENUM_MATCH(Month, MONTH);
+STATIC_ASSERT_WTIT_ENUM_MATCH(Time, TIME);
+STATIC_ASSERT_WTIT_ENUM_MATCH(Week, WEEK);
+STATIC_ASSERT_WTIT_ENUM_MATCH(TextArea, TEXT_AREA);
+STATIC_ASSERT_WTIT_ENUM_MATCH(ContentEditable, CONTENT_EDITABLE);
+STATIC_ASSERT_WTIT_ENUM_MATCH(DateTimeField, DATE_TIME_FIELD);
ui::TextInputType RenderWidget::WebKitToUiTextInputType(
blink::WebTextInputType type) {
@@ -2243,6 +2231,11 @@ void RenderWidget::hasTouchEventHandlers(bool has_handlers) {
Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers));
}
+// Check blink::WebTouchAction and blink::WebTouchActionAuto is kept in sync
+#define STATIC_ASSERT_WTI_ENUM_MATCH(a, b) \
+ static_assert(int(blink::WebTouchAction##a) == int(TOUCH_ACTION_##b), \
+ "mismatching enums: " #a)
+
void RenderWidget::setTouchAction(
blink::WebTouchAction web_touch_action) {
@@ -2252,22 +2245,11 @@ void RenderWidget::setTouchAction(
return;
// Verify the same values are used by the types so we can cast between them.
- COMPILE_ASSERT(static_cast<blink::WebTouchAction>(TOUCH_ACTION_AUTO) ==
- blink::WebTouchActionAuto,
- enum_values_must_match_for_touch_action);
- COMPILE_ASSERT(static_cast<blink::WebTouchAction>(TOUCH_ACTION_NONE) ==
- blink::WebTouchActionNone,
- enum_values_must_match_for_touch_action);
- COMPILE_ASSERT(static_cast<blink::WebTouchAction>(TOUCH_ACTION_PAN_X) ==
- blink::WebTouchActionPanX,
- enum_values_must_match_for_touch_action);
- COMPILE_ASSERT(static_cast<blink::WebTouchAction>(TOUCH_ACTION_PAN_Y) ==
- blink::WebTouchActionPanY,
- enum_values_must_match_for_touch_action);
- COMPILE_ASSERT(
- static_cast<blink::WebTouchAction>(TOUCH_ACTION_PINCH_ZOOM) ==
- blink::WebTouchActionPinchZoom,
- enum_values_must_match_for_touch_action);
+ STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO);
+ STATIC_ASSERT_WTI_ENUM_MATCH(None, NONE);
+ STATIC_ASSERT_WTI_ENUM_MATCH(PanX, PAN_X);
+ STATIC_ASSERT_WTI_ENUM_MATCH(PanY, PAN_Y);
+ STATIC_ASSERT_WTI_ENUM_MATCH(PinchZoom, PINCH_ZOOM);
content::TouchAction content_touch_action =
static_cast<content::TouchAction>(web_touch_action);
« no previous file with comments | « content/renderer/render_view_impl_android.cc ('k') | content/test/plugin/plugin_get_javascript_url2_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698