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

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