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

Side by Side 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: minor adjustment Created 6 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir); 1964 webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir);
1965 params.is_anchor_first = webwidget_->isSelectionAnchorFirst(); 1965 params.is_anchor_first = webwidget_->isSelectionAnchorFirst();
1966 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params)); 1966 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params));
1967 } 1967 }
1968 } 1968 }
1969 1969
1970 UpdateCompositionInfo(false); 1970 UpdateCompositionInfo(false);
1971 } 1971 }
1972 1972
1973 // Check blink::WebTextInputType and ui::TextInputType is kept in sync. 1973 // Check blink::WebTextInputType and ui::TextInputType is kept in sync.
1974 COMPILE_ASSERT(int(blink::WebTextInputTypeNone) == \ 1974 #define STATIC_ASSERT_WTIT_ENUM_MATCH(a, b) \
1975 int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums); 1975 static_assert(int(blink::WebTextInputType##a) \
1976 COMPILE_ASSERT(int(blink::WebTextInputTypeText) == \ 1976 == int(ui::TEXT_INPUT_TYPE_##b), \
1977 int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums); 1977 "mismatching enums: " #a)
1978 COMPILE_ASSERT(int(blink::WebTextInputTypePassword) == \ 1978
1979 int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums); 1979 STATIC_ASSERT_WTIT_ENUM_MATCH(None, NONE);
1980 COMPILE_ASSERT(int(blink::WebTextInputTypeSearch) == \ 1980 STATIC_ASSERT_WTIT_ENUM_MATCH(Text, TEXT);
1981 int(ui::TEXT_INPUT_TYPE_SEARCH), mismatching_enums); 1981 STATIC_ASSERT_WTIT_ENUM_MATCH(Password, PASSWORD);
1982 COMPILE_ASSERT(int(blink::WebTextInputTypeEmail) == \ 1982 STATIC_ASSERT_WTIT_ENUM_MATCH(Search, SEARCH);
1983 int(ui::TEXT_INPUT_TYPE_EMAIL), mismatching_enums); 1983 STATIC_ASSERT_WTIT_ENUM_MATCH(Email, EMAIL);
1984 COMPILE_ASSERT(int(blink::WebTextInputTypeNumber) == \ 1984 STATIC_ASSERT_WTIT_ENUM_MATCH(Number, NUMBER);
1985 int(ui::TEXT_INPUT_TYPE_NUMBER), mismatching_enums); 1985 STATIC_ASSERT_WTIT_ENUM_MATCH(Telephone, TELEPHONE);
1986 COMPILE_ASSERT(int(blink::WebTextInputTypeTelephone) == \ 1986 STATIC_ASSERT_WTIT_ENUM_MATCH(URL, URL);
1987 int(ui::TEXT_INPUT_TYPE_TELEPHONE), mismatching_enums); 1987 STATIC_ASSERT_WTIT_ENUM_MATCH(Date, DATE);
1988 COMPILE_ASSERT(int(blink::WebTextInputTypeURL) == \ 1988 STATIC_ASSERT_WTIT_ENUM_MATCH(DateTime, DATE_TIME);
1989 int(ui::TEXT_INPUT_TYPE_URL), mismatching_enums); 1989 STATIC_ASSERT_WTIT_ENUM_MATCH(DateTimeLocal, DATE_TIME_LOCAL);
1990 COMPILE_ASSERT(int(blink::WebTextInputTypeDate) == \ 1990 STATIC_ASSERT_WTIT_ENUM_MATCH(Month, MONTH);
1991 int(ui::TEXT_INPUT_TYPE_DATE), mismatching_enum); 1991 STATIC_ASSERT_WTIT_ENUM_MATCH(Time, TIME);
1992 COMPILE_ASSERT(int(blink::WebTextInputTypeDateTime) == \ 1992 STATIC_ASSERT_WTIT_ENUM_MATCH(Week, WEEK);
1993 int(ui::TEXT_INPUT_TYPE_DATE_TIME), mismatching_enum); 1993 STATIC_ASSERT_WTIT_ENUM_MATCH(TextArea, TEXT_AREA);
1994 COMPILE_ASSERT(int(blink::WebTextInputTypeDateTimeLocal) == \ 1994 STATIC_ASSERT_WTIT_ENUM_MATCH(ContentEditable, CONTENT_EDITABLE);
1995 int(ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL), mismatching_enum); 1995 STATIC_ASSERT_WTIT_ENUM_MATCH(DateTimeField, DATE_TIME_FIELD);
1996 COMPILE_ASSERT(int(blink::WebTextInputTypeMonth) == \
1997 int(ui::TEXT_INPUT_TYPE_MONTH), mismatching_enum);
1998 COMPILE_ASSERT(int(blink::WebTextInputTypeTime) == \
1999 int(ui::TEXT_INPUT_TYPE_TIME), mismatching_enum);
2000 COMPILE_ASSERT(int(blink::WebTextInputTypeWeek) == \
2001 int(ui::TEXT_INPUT_TYPE_WEEK), mismatching_enum);
2002 COMPILE_ASSERT(int(blink::WebTextInputTypeTextArea) == \
2003 int(ui::TEXT_INPUT_TYPE_TEXT_AREA), mismatching_enums);
2004 COMPILE_ASSERT(int(blink::WebTextInputTypeContentEditable) == \
2005 int(ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE), mismatching_enums);
2006 COMPILE_ASSERT(int(blink::WebTextInputTypeDateTimeField) == \
2007 int(ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD), mismatching_enums);
2008 1996
2009 ui::TextInputType RenderWidget::WebKitToUiTextInputType( 1997 ui::TextInputType RenderWidget::WebKitToUiTextInputType(
2010 blink::WebTextInputType type) { 1998 blink::WebTextInputType type) {
2011 // Check the type is in the range representable by ui::TextInputType. 1999 // Check the type is in the range representable by ui::TextInputType.
2012 DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX)) << 2000 DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX)) <<
2013 "blink::WebTextInputType and ui::TextInputType not synchronized"; 2001 "blink::WebTextInputType and ui::TextInputType not synchronized";
2014 return static_cast<ui::TextInputType>(type); 2002 return static_cast<ui::TextInputType>(type);
2015 } 2003 }
2016 2004
2017 ui::TextInputType RenderWidget::GetTextInputType() { 2005 ui::TextInputType RenderWidget::GetTextInputType() {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 if (input_handler_manager) { 2222 if (input_handler_manager) {
2235 input_handler_manager->ObserveWheelEventAndResultOnMainThread( 2223 input_handler_manager->ObserveWheelEventAndResultOnMainThread(
2236 routing_id_, wheel_event, scroll_result); 2224 routing_id_, wheel_event, scroll_result);
2237 } 2225 }
2238 } 2226 }
2239 2227
2240 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { 2228 void RenderWidget::hasTouchEventHandlers(bool has_handlers) {
2241 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); 2229 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers));
2242 } 2230 }
2243 2231
2232 // Check blink::WebTouchAction and blink::WebTouchActionAuto is kept in sync
2233 #define STATIC_ASSERT_WTI_ENUM_MATCH(a, b) \
2234 static_assert(int(blink::WebTouchAction##a) == int(TOUCH_ACTION_##b), \
2235 "mismatching enums: " #a)
2236
2244 void RenderWidget::setTouchAction( 2237 void RenderWidget::setTouchAction(
2245 blink::WebTouchAction web_touch_action) { 2238 blink::WebTouchAction web_touch_action) {
2246 2239
2247 // Ignore setTouchAction calls that result from synthetic touch events (eg. 2240 // Ignore setTouchAction calls that result from synthetic touch events (eg.
2248 // when blink is emulating touch with mouse). 2241 // when blink is emulating touch with mouse).
2249 if (handling_event_type_ != WebInputEvent::TouchStart) 2242 if (handling_event_type_ != WebInputEvent::TouchStart)
2250 return; 2243 return;
2251 2244
2252 // Verify the same values are used by the types so we can cast between them. 2245 // Verify the same values are used by the types so we can cast between them.
2253 COMPILE_ASSERT(static_cast<blink::WebTouchAction>(TOUCH_ACTION_AUTO) == 2246 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO);
2254 blink::WebTouchActionAuto, 2247 STATIC_ASSERT_WTI_ENUM_MATCH(None, NONE);
2255 enum_values_must_match_for_touch_action); 2248 STATIC_ASSERT_WTI_ENUM_MATCH(PanX, PAN_X);
2256 COMPILE_ASSERT(static_cast<blink::WebTouchAction>(TOUCH_ACTION_NONE) == 2249 STATIC_ASSERT_WTI_ENUM_MATCH(PanY, PAN_Y);
2257 blink::WebTouchActionNone, 2250 STATIC_ASSERT_WTI_ENUM_MATCH(PinchZoom, PINCH_ZOOM);
2258 enum_values_must_match_for_touch_action);
2259 COMPILE_ASSERT(static_cast<blink::WebTouchAction>(TOUCH_ACTION_PAN_X) ==
2260 blink::WebTouchActionPanX,
2261 enum_values_must_match_for_touch_action);
2262 COMPILE_ASSERT(static_cast<blink::WebTouchAction>(TOUCH_ACTION_PAN_Y) ==
2263 blink::WebTouchActionPanY,
2264 enum_values_must_match_for_touch_action);
2265 COMPILE_ASSERT(
2266 static_cast<blink::WebTouchAction>(TOUCH_ACTION_PINCH_ZOOM) ==
2267 blink::WebTouchActionPinchZoom,
2268 enum_values_must_match_for_touch_action);
2269 2251
2270 content::TouchAction content_touch_action = 2252 content::TouchAction content_touch_action =
2271 static_cast<content::TouchAction>(web_touch_action); 2253 static_cast<content::TouchAction>(web_touch_action);
2272 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); 2254 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action));
2273 } 2255 }
2274 2256
2275 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { 2257 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() {
2276 #if defined(OS_ANDROID) 2258 #if defined(OS_ANDROID)
2277 text_field_is_dirty_ = true; 2259 text_field_is_dirty_ = true;
2278 #endif 2260 #endif
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2352 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2371 video_hole_frames_.AddObserver(frame); 2353 video_hole_frames_.AddObserver(frame);
2372 } 2354 }
2373 2355
2374 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2356 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2375 video_hole_frames_.RemoveObserver(frame); 2357 video_hole_frames_.RemoveObserver(frame);
2376 } 2358 }
2377 #endif // defined(VIDEO_HOLE) 2359 #endif // defined(VIDEO_HOLE)
2378 2360
2379 } // namespace content 2361 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698