Chromium Code Reviews| 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 <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | 9 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
| 10 #include "ui/gfx/icon_util.h" | 10 #include "ui/gfx/icon_util.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 ui::PlatformCursor WebCursor::GetPlatformCursor() { | 14 ui::PlatformCursor WebCursor::GetPlatformCursor() { |
| 15 if (!IsCustom()) | 15 if (!IsCustom()) |
| 16 return LoadCursor(NULL, IDC_ARROW); | 16 return LoadCursor(NULL, IDC_ARROW); |
| 17 | 17 |
| 18 if (custom_cursor_) | 18 if (custom_cursor_) |
| 19 return custom_cursor_; | 19 return custom_cursor_; |
| 20 | 20 |
| 21 custom_cursor_ = | 21 if (custom_data_.size() == 0) |
|
ananta
2015/12/15 23:28:17
should this be an error condition? and hence a dch
Bret
2015/12/16 19:03:59
Done.
| |
| 22 IconUtil::CreateCursorFromDIB( | 22 return 0; |
| 23 custom_size_, | 23 |
| 24 hotspot_, | 24 SkBitmap bitmap; |
| 25 !custom_data_.empty() ? &custom_data_[0] : NULL, | 25 gfx::Point hotspot; |
| 26 custom_data_.size()); | 26 CreateScaledBitmapAndHotspotFromCustomData(&bitmap, &hotspot); |
| 27 | |
| 28 gfx::Size custom_size; | |
| 29 std::vector<char> custom_data; | |
| 30 CreateCustomData(bitmap, custom_data, custom_size); | |
| 31 | |
| 32 custom_cursor_ = IconUtil::CreateCursorFromDIB( | |
| 33 custom_size, | |
| 34 hotspot, | |
| 35 !custom_data.empty() ? &custom_data[0] : NULL, | |
| 36 custom_data.size()); | |
| 27 return custom_cursor_; | 37 return custom_cursor_; |
| 28 } | 38 } |
| 29 | 39 |
| 30 void WebCursor::SetDisplayInfo(const gfx::Display& display) { | |
| 31 // TODO(winguru): Add support for scaling the cursor. | |
| 32 } | |
| 33 | |
| 34 void WebCursor::InitPlatformData() { | 40 void WebCursor::InitPlatformData() { |
| 35 custom_cursor_ = NULL; | 41 custom_cursor_ = NULL; |
| 36 } | 42 } |
| 37 | 43 |
| 38 bool WebCursor::SerializePlatformData(base::Pickle* pickle) const { | 44 bool WebCursor::SerializePlatformData(base::Pickle* pickle) const { |
| 39 return true; | 45 return true; |
| 40 } | 46 } |
| 41 | 47 |
| 42 bool WebCursor::DeserializePlatformData(base::PickleIterator* iter) { | 48 bool WebCursor::DeserializePlatformData(base::PickleIterator* iter) { |
| 43 return true; | 49 return true; |
| 44 } | 50 } |
| 45 | 51 |
| 46 bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const { | 52 bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const { |
| 47 return true; | 53 return true; |
| 48 } | 54 } |
| 49 | 55 |
| 50 void WebCursor::CleanupPlatformData() { | 56 void WebCursor::CleanupPlatformData() { |
| 51 if (custom_cursor_) { | 57 if (custom_cursor_) { |
| 52 DestroyIcon(custom_cursor_); | 58 DestroyIcon(custom_cursor_); |
| 53 custom_cursor_ = NULL; | 59 custom_cursor_ = NULL; |
| 54 } | 60 } |
| 55 } | 61 } |
| 56 | 62 |
| 57 void WebCursor::CopyPlatformData(const WebCursor& other) { | 63 void WebCursor::CopyPlatformData(const WebCursor& other) { |
| 58 } | 64 } |
| 59 | 65 |
| 60 } // namespace content | 66 } // namespace content |
| OLD | NEW |