| OLD | NEW |
| 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/common/cursors/webcursor.h" | 5 #include "content/common/cursors/webcursor.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "third_party/WebKit/public/platform/WebImage.h" | 9 #include "third_party/WebKit/public/platform/WebImage.h" |
| 10 | 10 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 { LoadCursor(NULL, IDC_WAIT), WebCursorInfo::TypeWait }, | 185 { LoadCursor(NULL, IDC_WAIT), WebCursorInfo::TypeWait }, |
| 186 { LoadCursor(NULL, IDC_HELP), WebCursorInfo::TypeHelp }, | 186 { LoadCursor(NULL, IDC_HELP), WebCursorInfo::TypeHelp }, |
| 187 { LoadCursor(NULL, IDC_SIZENESW), WebCursorInfo::TypeNorthEastResize }, | 187 { LoadCursor(NULL, IDC_SIZENESW), WebCursorInfo::TypeNorthEastResize }, |
| 188 { LoadCursor(NULL, IDC_SIZENWSE), WebCursorInfo::TypeNorthWestResize }, | 188 { LoadCursor(NULL, IDC_SIZENWSE), WebCursorInfo::TypeNorthWestResize }, |
| 189 { LoadCursor(NULL, IDC_SIZENS), WebCursorInfo::TypeNorthSouthResize }, | 189 { LoadCursor(NULL, IDC_SIZENS), WebCursorInfo::TypeNorthSouthResize }, |
| 190 { LoadCursor(NULL, IDC_SIZEWE), WebCursorInfo::TypeEastWestResize }, | 190 { LoadCursor(NULL, IDC_SIZEWE), WebCursorInfo::TypeEastWestResize }, |
| 191 { LoadCursor(NULL, IDC_SIZEALL), WebCursorInfo::TypeMove }, | 191 { LoadCursor(NULL, IDC_SIZEALL), WebCursorInfo::TypeMove }, |
| 192 { LoadCursor(NULL, IDC_APPSTARTING), WebCursorInfo::TypeProgress }, | 192 { LoadCursor(NULL, IDC_APPSTARTING), WebCursorInfo::TypeProgress }, |
| 193 { LoadCursor(NULL, IDC_NO), WebCursorInfo::TypeNotAllowed }, | 193 { LoadCursor(NULL, IDC_NO), WebCursorInfo::TypeNotAllowed }, |
| 194 }; | 194 }; |
| 195 for (int i = 0; i < arraysize(kStandardCursors); ++i) { | 195 for (const auto& kStandardCursor : kStandardCursors) { |
| 196 if (cursor == kStandardCursors[i].cursor) | 196 if (cursor == kStandardCursor.cursor) |
| 197 return kStandardCursors[i].type; | 197 return kStandardCursor.type; |
| 198 } | 198 } |
| 199 return WebCursorInfo::TypeCustom; | 199 return WebCursorInfo::TypeCustom; |
| 200 } | 200 } |
| 201 | 201 |
| 202 void WebCursor::InitFromExternalCursor(HCURSOR cursor) { | 202 void WebCursor::InitFromExternalCursor(HCURSOR cursor) { |
| 203 WebCursorInfo::Type cursor_type = ToCursorType(cursor); | 203 WebCursorInfo::Type cursor_type = ToCursorType(cursor); |
| 204 | 204 |
| 205 InitFromCursorInfo(CursorInfo(cursor_type)); | 205 InitFromCursorInfo(CursorInfo(cursor_type)); |
| 206 | 206 |
| 207 if (cursor_type == WebCursorInfo::TypeCustom) | 207 if (cursor_type == WebCursorInfo::TypeCustom) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 return; | 262 return; |
| 263 | 263 |
| 264 // Clamp the hotspot to the custom image's dimensions. | 264 // Clamp the hotspot to the custom image's dimensions. |
| 265 hotspot_.set_x(std::max(0, | 265 hotspot_.set_x(std::max(0, |
| 266 std::min(custom_size_.width() - 1, hotspot_.x()))); | 266 std::min(custom_size_.width() - 1, hotspot_.x()))); |
| 267 hotspot_.set_y(std::max(0, | 267 hotspot_.set_y(std::max(0, |
| 268 std::min(custom_size_.height() - 1, hotspot_.y()))); | 268 std::min(custom_size_.height() - 1, hotspot_.y()))); |
| 269 } | 269 } |
| 270 | 270 |
| 271 } // namespace content | 271 } // namespace content |
| OLD | NEW |