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

Side by Side Diff: content/renderer/render_widget.cc

Issue 1676703002: Stop using macros to paste together names for static_asserts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: static-asserts-enums: a,b,#a Created 4 years, 10 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 <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 using blink::WebRange; 122 using blink::WebRange;
123 using blink::WebRect; 123 using blink::WebRect;
124 using blink::WebScreenInfo; 124 using blink::WebScreenInfo;
125 using blink::WebSize; 125 using blink::WebSize;
126 using blink::WebTextDirection; 126 using blink::WebTextDirection;
127 using blink::WebTouchEvent; 127 using blink::WebTouchEvent;
128 using blink::WebTouchPoint; 128 using blink::WebTouchPoint;
129 using blink::WebVector; 129 using blink::WebVector;
130 using blink::WebWidget; 130 using blink::WebWidget;
131 131
132 #define STATIC_ASSERT_ENUM(a, b) \
133 static_assert(static_cast<int>(a) == static_cast<int>(b), \
134 "mismatching enums: " #a)
135
132 namespace { 136 namespace {
133 137
134 typedef std::map<std::string, ui::TextInputMode> TextInputModeMap; 138 typedef std::map<std::string, ui::TextInputMode> TextInputModeMap;
135 139
136 class TextInputModeMapSingleton { 140 class TextInputModeMapSingleton {
137 public: 141 public:
138 static TextInputModeMapSingleton* GetInstance() { 142 static TextInputModeMapSingleton* GetInstance() {
139 return base::Singleton<TextInputModeMapSingleton>::get(); 143 return base::Singleton<TextInputModeMapSingleton>::get();
140 } 144 }
141 TextInputModeMapSingleton() { 145 TextInputModeMapSingleton() {
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir); 1983 webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir);
1980 params.is_anchor_first = webwidget_->isSelectionAnchorFirst(); 1984 params.is_anchor_first = webwidget_->isSelectionAnchorFirst();
1981 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params)); 1985 Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params));
1982 } 1986 }
1983 } 1987 }
1984 1988
1985 UpdateCompositionInfo(false); 1989 UpdateCompositionInfo(false);
1986 } 1990 }
1987 1991
1988 // Check blink::WebTextInputType and ui::TextInputType is kept in sync. 1992 // Check blink::WebTextInputType and ui::TextInputType is kept in sync.
1989 #define STATIC_ASSERT_WTIT_ENUM_MATCH(a, b) \ 1993 STATIC_ASSERT_ENUM(blink::WebTextInputTypeNone, ui::TEXT_INPUT_TYPE_NONE);
1990 static_assert(int(blink::WebTextInputType##a) \ 1994 STATIC_ASSERT_ENUM(blink::WebTextInputTypeText, ui::TEXT_INPUT_TYPE_TEXT);
1991 == int(ui::TEXT_INPUT_TYPE_##b), \ 1995 STATIC_ASSERT_ENUM(blink::WebTextInputTypePassword,
1992 "mismatching enums: " #a) 1996 ui::TEXT_INPUT_TYPE_PASSWORD);
1993 1997 STATIC_ASSERT_ENUM(blink::WebTextInputTypeSearch, ui::TEXT_INPUT_TYPE_SEARCH);
1994 STATIC_ASSERT_WTIT_ENUM_MATCH(None, NONE); 1998 STATIC_ASSERT_ENUM(blink::WebTextInputTypeEmail, ui::TEXT_INPUT_TYPE_EMAIL);
1995 STATIC_ASSERT_WTIT_ENUM_MATCH(Text, TEXT); 1999 STATIC_ASSERT_ENUM(blink::WebTextInputTypeNumber, ui::TEXT_INPUT_TYPE_NUMBER);
1996 STATIC_ASSERT_WTIT_ENUM_MATCH(Password, PASSWORD); 2000 STATIC_ASSERT_ENUM(blink::WebTextInputTypeTelephone,
1997 STATIC_ASSERT_WTIT_ENUM_MATCH(Search, SEARCH); 2001 ui::TEXT_INPUT_TYPE_TELEPHONE);
1998 STATIC_ASSERT_WTIT_ENUM_MATCH(Email, EMAIL); 2002 STATIC_ASSERT_ENUM(blink::WebTextInputTypeURL, ui::TEXT_INPUT_TYPE_URL);
1999 STATIC_ASSERT_WTIT_ENUM_MATCH(Number, NUMBER); 2003 STATIC_ASSERT_ENUM(blink::WebTextInputTypeDate, ui::TEXT_INPUT_TYPE_DATE);
2000 STATIC_ASSERT_WTIT_ENUM_MATCH(Telephone, TELEPHONE); 2004 STATIC_ASSERT_ENUM(blink::WebTextInputTypeDateTime,
2001 STATIC_ASSERT_WTIT_ENUM_MATCH(URL, URL); 2005 ui::TEXT_INPUT_TYPE_DATE_TIME);
2002 STATIC_ASSERT_WTIT_ENUM_MATCH(Date, DATE); 2006 STATIC_ASSERT_ENUM(blink::WebTextInputTypeDateTimeLocal,
2003 STATIC_ASSERT_WTIT_ENUM_MATCH(DateTime, DATE_TIME); 2007 ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL);
2004 STATIC_ASSERT_WTIT_ENUM_MATCH(DateTimeLocal, DATE_TIME_LOCAL); 2008 STATIC_ASSERT_ENUM(blink::WebTextInputTypeMonth, ui::TEXT_INPUT_TYPE_MONTH);
2005 STATIC_ASSERT_WTIT_ENUM_MATCH(Month, MONTH); 2009 STATIC_ASSERT_ENUM(blink::WebTextInputTypeTime, ui::TEXT_INPUT_TYPE_TIME);
2006 STATIC_ASSERT_WTIT_ENUM_MATCH(Time, TIME); 2010 STATIC_ASSERT_ENUM(blink::WebTextInputTypeWeek, ui::TEXT_INPUT_TYPE_WEEK);
2007 STATIC_ASSERT_WTIT_ENUM_MATCH(Week, WEEK); 2011 STATIC_ASSERT_ENUM(blink::WebTextInputTypeTextArea,
2008 STATIC_ASSERT_WTIT_ENUM_MATCH(TextArea, TEXT_AREA); 2012 ui::TEXT_INPUT_TYPE_TEXT_AREA);
2009 STATIC_ASSERT_WTIT_ENUM_MATCH(ContentEditable, CONTENT_EDITABLE); 2013 STATIC_ASSERT_ENUM(blink::WebTextInputTypeContentEditable,
2010 STATIC_ASSERT_WTIT_ENUM_MATCH(DateTimeField, DATE_TIME_FIELD); 2014 ui::TEXT_INPUT_TYPE_CONTENT_EDITABLE);
2015 STATIC_ASSERT_ENUM(blink::WebTextInputTypeDateTimeField,
2016 ui::TEXT_INPUT_TYPE_DATE_TIME_FIELD);
2011 2017
2012 ui::TextInputType RenderWidget::WebKitToUiTextInputType( 2018 ui::TextInputType RenderWidget::WebKitToUiTextInputType(
2013 blink::WebTextInputType type) { 2019 blink::WebTextInputType type) {
2014 // Check the type is in the range representable by ui::TextInputType. 2020 // Check the type is in the range representable by ui::TextInputType.
2015 DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX)) << 2021 DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX)) <<
2016 "blink::WebTextInputType and ui::TextInputType not synchronized"; 2022 "blink::WebTextInputType and ui::TextInputType not synchronized";
2017 return static_cast<ui::TextInputType>(type); 2023 return static_cast<ui::TextInputType>(type);
2018 } 2024 }
2019 2025
2020 void RenderWidget::GetCompositionCharacterBounds( 2026 void RenderWidget::GetCompositionCharacterBounds(
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 void RenderWidget::IgnoreAckForMouseMoveFromDebugger() { 2169 void RenderWidget::IgnoreAckForMouseMoveFromDebugger() {
2164 input_handler_->IgnoreAckForMouseMoveFromDebugger(); 2170 input_handler_->IgnoreAckForMouseMoveFromDebugger();
2165 } 2171 }
2166 2172
2167 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { 2173 void RenderWidget::hasTouchEventHandlers(bool has_handlers) {
2168 if (render_widget_scheduling_state_) 2174 if (render_widget_scheduling_state_)
2169 render_widget_scheduling_state_->SetHasTouchHandler(has_handlers); 2175 render_widget_scheduling_state_->SetHasTouchHandler(has_handlers);
2170 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); 2176 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers));
2171 } 2177 }
2172 2178
2173 // Check blink::WebTouchAction and blink::WebTouchActionAuto is kept in sync 2179 // Check blink::WebTouchAction and content::TouchAction is kept in sync.
2174 #define STATIC_ASSERT_WTI_ENUM_MATCH(a, b) \ 2180 STATIC_ASSERT_ENUM(blink::WebTouchActionNone, TOUCH_ACTION_NONE);
2175 static_assert(int(blink::WebTouchAction##a) == int(TOUCH_ACTION_##b), \ 2181 STATIC_ASSERT_ENUM(blink::WebTouchActionPanLeft, TOUCH_ACTION_PAN_LEFT);
2176 "mismatching enums: " #a) 2182 STATIC_ASSERT_ENUM(blink::WebTouchActionPanRight, TOUCH_ACTION_PAN_RIGHT);
2183 STATIC_ASSERT_ENUM(blink::WebTouchActionPanX, TOUCH_ACTION_PAN_X);
2184 STATIC_ASSERT_ENUM(blink::WebTouchActionPanUp, TOUCH_ACTION_PAN_UP);
2185 STATIC_ASSERT_ENUM(blink::WebTouchActionPanDown, TOUCH_ACTION_PAN_DOWN);
2186 STATIC_ASSERT_ENUM(blink::WebTouchActionPanY, TOUCH_ACTION_PAN_Y);
2187 STATIC_ASSERT_ENUM(blink::WebTouchActionPan, TOUCH_ACTION_PAN);
2188 STATIC_ASSERT_ENUM(blink::WebTouchActionPinchZoom, TOUCH_ACTION_PINCH_ZOOM);
2189 STATIC_ASSERT_ENUM(blink::WebTouchActionManipulation,
2190 TOUCH_ACTION_MANIPULATION);
2191 STATIC_ASSERT_ENUM(blink::WebTouchActionDoubleTapZoom,
2192 TOUCH_ACTION_DOUBLE_TAP_ZOOM);
2193 STATIC_ASSERT_ENUM(blink::WebTouchActionAuto, TOUCH_ACTION_AUTO);
2177 2194
2178 void RenderWidget::setTouchAction( 2195 void RenderWidget::setTouchAction(
2179 blink::WebTouchAction web_touch_action) { 2196 blink::WebTouchAction web_touch_action) {
2180 2197
2181 // Ignore setTouchAction calls that result from synthetic touch events (eg. 2198 // Ignore setTouchAction calls that result from synthetic touch events (eg.
2182 // when blink is emulating touch with mouse). 2199 // when blink is emulating touch with mouse).
2183 if (input_handler_->handling_event_type() != WebInputEvent::TouchStart) 2200 if (input_handler_->handling_event_type() != WebInputEvent::TouchStart)
2184 return; 2201 return;
2185 2202
2186 // Verify the same values are used by the types so we can cast between them.
2187 STATIC_ASSERT_WTI_ENUM_MATCH(None, NONE);
2188 STATIC_ASSERT_WTI_ENUM_MATCH(PanLeft, PAN_LEFT);
2189 STATIC_ASSERT_WTI_ENUM_MATCH(PanRight, PAN_RIGHT);
2190 STATIC_ASSERT_WTI_ENUM_MATCH(PanX, PAN_X);
2191 STATIC_ASSERT_WTI_ENUM_MATCH(PanUp, PAN_UP);
2192 STATIC_ASSERT_WTI_ENUM_MATCH(PanDown, PAN_DOWN);
2193 STATIC_ASSERT_WTI_ENUM_MATCH(PanY, PAN_Y);
2194 STATIC_ASSERT_WTI_ENUM_MATCH(Pan, PAN);
2195 STATIC_ASSERT_WTI_ENUM_MATCH(PinchZoom, PINCH_ZOOM);
2196 STATIC_ASSERT_WTI_ENUM_MATCH(Manipulation, MANIPULATION);
2197 STATIC_ASSERT_WTI_ENUM_MATCH(DoubleTapZoom, DOUBLE_TAP_ZOOM);
2198 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO);
2199
2200 content::TouchAction content_touch_action = 2203 content::TouchAction content_touch_action =
2201 static_cast<content::TouchAction>(web_touch_action); 2204 static_cast<content::TouchAction>(web_touch_action);
2202 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); 2205 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action));
2203 } 2206 }
2204 2207
2205 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { 2208 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() {
2206 #if defined(OS_ANDROID) 2209 #if defined(OS_ANDROID)
2207 text_field_is_dirty_ = true; 2210 text_field_is_dirty_ = true;
2208 #endif 2211 #endif
2209 } 2212 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 video_hole_frames_.RemoveObserver(frame); 2294 video_hole_frames_.RemoveObserver(frame);
2292 } 2295 }
2293 #endif // defined(VIDEO_HOLE) 2296 #endif // defined(VIDEO_HOLE)
2294 2297
2295 void RenderWidget::OnWaitNextFrameForTests(int routing_id) { 2298 void RenderWidget::OnWaitNextFrameForTests(int routing_id) {
2296 QueueMessage(new ViewHostMsg_WaitForNextFrameForTests_ACK(routing_id), 2299 QueueMessage(new ViewHostMsg_WaitForNextFrameForTests_ACK(routing_id),
2297 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); 2300 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE);
2298 } 2301 }
2299 2302
2300 } // namespace content 2303 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.cc ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698