| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <vector> | |
| 6 | |
| 7 #include "ppapi/cpp/dev/scrollbar_dev.h" | |
| 8 | |
| 9 #include "ppapi/cpp/instance_handle.h" | |
| 10 #include "ppapi/cpp/module.h" | |
| 11 #include "ppapi/cpp/module_impl.h" | |
| 12 #include "ppapi/cpp/rect.h" | |
| 13 | |
| 14 namespace pp { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 template <> const char* interface_name<PPB_Scrollbar_Dev>() { | |
| 19 return PPB_SCROLLBAR_DEV_INTERFACE; | |
| 20 } | |
| 21 | |
| 22 } // namespace | |
| 23 | |
| 24 Scrollbar_Dev::Scrollbar_Dev(PP_Resource resource) : Widget_Dev(resource) { | |
| 25 } | |
| 26 | |
| 27 Scrollbar_Dev::Scrollbar_Dev(const InstanceHandle& instance, bool vertical) { | |
| 28 if (!has_interface<PPB_Scrollbar_Dev>()) | |
| 29 return; | |
| 30 PassRefFromConstructor(get_interface<PPB_Scrollbar_Dev>()->Create( | |
| 31 instance.pp_instance(), PP_FromBool(vertical))); | |
| 32 } | |
| 33 | |
| 34 Scrollbar_Dev::Scrollbar_Dev(const Scrollbar_Dev& other) | |
| 35 : Widget_Dev(other) { | |
| 36 } | |
| 37 | |
| 38 uint32_t Scrollbar_Dev::GetThickness() { | |
| 39 if (!has_interface<PPB_Scrollbar_Dev>()) | |
| 40 return 0; | |
| 41 return get_interface<PPB_Scrollbar_Dev>()->GetThickness(pp_resource()); | |
| 42 } | |
| 43 | |
| 44 bool Scrollbar_Dev::IsOverlay() { | |
| 45 if (!has_interface<PPB_Scrollbar_Dev>()) | |
| 46 return false; | |
| 47 return | |
| 48 PP_ToBool(get_interface<PPB_Scrollbar_Dev>()->IsOverlay(pp_resource())); | |
| 49 } | |
| 50 | |
| 51 uint32_t Scrollbar_Dev::GetValue() { | |
| 52 if (!has_interface<PPB_Scrollbar_Dev>()) | |
| 53 return 0; | |
| 54 return get_interface<PPB_Scrollbar_Dev>()->GetValue(pp_resource()); | |
| 55 } | |
| 56 | |
| 57 void Scrollbar_Dev::SetValue(uint32_t value) { | |
| 58 if (has_interface<PPB_Scrollbar_Dev>()) | |
| 59 get_interface<PPB_Scrollbar_Dev>()->SetValue(pp_resource(), value); | |
| 60 } | |
| 61 | |
| 62 void Scrollbar_Dev::SetDocumentSize(uint32_t size) { | |
| 63 if (has_interface<PPB_Scrollbar_Dev>()) | |
| 64 get_interface<PPB_Scrollbar_Dev>()->SetDocumentSize(pp_resource(), size); | |
| 65 } | |
| 66 | |
| 67 void Scrollbar_Dev::SetTickMarks(const Rect* tick_marks, uint32_t count) { | |
| 68 if (!has_interface<PPB_Scrollbar_Dev>()) | |
| 69 return; | |
| 70 | |
| 71 std::vector<PP_Rect> temp; | |
| 72 temp.resize(count); | |
| 73 for (uint32_t i = 0; i < count; ++i) | |
| 74 temp[i] = tick_marks[i]; | |
| 75 | |
| 76 get_interface<PPB_Scrollbar_Dev>()->SetTickMarks( | |
| 77 pp_resource(), count ? &temp[0] : NULL, count); | |
| 78 } | |
| 79 | |
| 80 void Scrollbar_Dev::ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) { | |
| 81 if (has_interface<PPB_Scrollbar_Dev>()) | |
| 82 get_interface<PPB_Scrollbar_Dev>()->ScrollBy(pp_resource(), | |
| 83 unit, | |
| 84 multiplier); | |
| 85 } | |
| 86 | |
| 87 } // namespace pp | |
| OLD | NEW |