| 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 SkBitmap bitmap; |
| 22 IconUtil::CreateCursorFromDIB( | 22 gfx::Point hotspot; |
| 23 custom_size_, | 23 CreateScaledBitmapAndHotspotFromCustomData(&bitmap, &hotspot); |
| 24 hotspot_, | 24 |
| 25 !custom_data_.empty() ? &custom_data_[0] : NULL, | 25 gfx::Size custom_size; |
| 26 custom_data_.size()); | 26 std::vector<char> custom_data; |
| 27 CreateCustomData(bitmap, &custom_data, &custom_size); |
| 28 |
| 29 custom_cursor_ = IconUtil::CreateCursorFromDIB( |
| 30 custom_size, |
| 31 hotspot, |
| 32 !custom_data.empty() ? &custom_data[0] : NULL, |
| 33 custom_data.size()); |
| 27 return custom_cursor_; | 34 return custom_cursor_; |
| 28 } | 35 } |
| 29 | 36 |
| 30 void WebCursor::SetDisplayInfo(const gfx::Display& display) { | |
| 31 // TODO(winguru): Add support for scaling the cursor. | |
| 32 } | |
| 33 | |
| 34 void WebCursor::InitPlatformData() { | 37 void WebCursor::InitPlatformData() { |
| 35 custom_cursor_ = NULL; | 38 custom_cursor_ = NULL; |
| 36 } | 39 } |
| 37 | 40 |
| 38 bool WebCursor::SerializePlatformData(base::Pickle* pickle) const { | 41 bool WebCursor::SerializePlatformData(base::Pickle* pickle) const { |
| 39 return true; | 42 return true; |
| 40 } | 43 } |
| 41 | 44 |
| 42 bool WebCursor::DeserializePlatformData(base::PickleIterator* iter) { | 45 bool WebCursor::DeserializePlatformData(base::PickleIterator* iter) { |
| 43 return true; | 46 return true; |
| 44 } | 47 } |
| 45 | 48 |
| 46 bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const { | 49 bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const { |
| 47 return true; | 50 return true; |
| 48 } | 51 } |
| 49 | 52 |
| 50 void WebCursor::CleanupPlatformData() { | 53 void WebCursor::CleanupPlatformData() { |
| 51 if (custom_cursor_) { | 54 if (custom_cursor_) { |
| 52 DestroyIcon(custom_cursor_); | 55 DestroyIcon(custom_cursor_); |
| 53 custom_cursor_ = NULL; | 56 custom_cursor_ = NULL; |
| 54 } | 57 } |
| 55 } | 58 } |
| 56 | 59 |
| 57 void WebCursor::CopyPlatformData(const WebCursor& other) { | 60 void WebCursor::CopyPlatformData(const WebCursor& other) { |
| 58 } | 61 } |
| 59 | 62 |
| 60 } // namespace content | 63 } // namespace content |
| OLD | NEW |