Chromium Code Reviews| Index: webkit/plugins/ppapi/ppb_scrollbar_impl.cc |
| =================================================================== |
| --- webkit/plugins/ppapi/ppb_scrollbar_impl.cc (revision 95011) |
| +++ webkit/plugins/ppapi/ppb_scrollbar_impl.cc (working copy) |
| @@ -48,10 +48,14 @@ |
| return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->IsScrollbar(resource); |
| } |
| -uint32_t GetThickness() { |
| +uint32_t GetThickness3() { |
| return WebScrollbar::defaultThickness(); |
| } |
| +uint32_t GetThickness4(PP_Resource resource) { |
| + return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->GetThickness(resource); |
| +} |
| + |
| uint32_t GetValue(PP_Resource resource) { |
| return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->GetValue(resource); |
| } |
| @@ -82,7 +86,7 @@ |
| const PPB_Scrollbar_0_3_Dev ppb_scrollbar_0_3 = { |
| &Create, |
| &IsScrollbar, |
| - &GetThickness, |
| + &GetThickness3, |
| &GetValue, |
| &SetValue, |
| &SetDocumentSize, |
| @@ -90,18 +94,40 @@ |
| &ScrollBy |
| }; |
| +const PPB_Scrollbar_0_4_Dev ppb_scrollbar_0_4 = { |
| + &Create, |
| + &IsScrollbar, |
| + &GetThickness4, |
| + &GetValue, |
| + &SetValue, |
| + &SetDocumentSize, |
| + &SetTickMarks, |
| + &ScrollBy |
| +}; |
| + |
| } // namespace |
| -PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PluginInstance* instance, bool vertical) |
| +// static |
| +PP_Resource PPB_Scrollbar_Impl::Create(PluginInstance* instance, |
| + bool vertical) { |
| + scoped_refptr<PPB_Scrollbar_Impl> scrollbar(new PPB_Scrollbar_Impl(instance)); |
| + scrollbar->Init(vertical); |
| + return scrollbar->GetReference(); |
| +} |
| + |
| +PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PluginInstance* instance) |
| : PPB_Widget_Impl(instance) { |
| +} |
| + |
| +PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() { |
| +} |
| + |
| +void PPB_Scrollbar_Impl::Init(bool vertical) { |
| scrollbar_.reset(WebScrollbar::create( |
| static_cast<WebKit::WebScrollbarClient*>(this), |
| vertical ? WebScrollbar::Vertical : WebScrollbar::Horizontal)); |
| } |
| -PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() { |
| -} |
| - |
| PPB_Scrollbar_API* PPB_Scrollbar_Impl::AsPPB_Scrollbar_API() { |
| return this; |
| } |
| @@ -111,10 +137,24 @@ |
| return &ppb_scrollbar_0_3; |
| } |
| +// static |
| +const PPB_Scrollbar_0_4_Dev* PPB_Scrollbar_Impl::Get0_4Interface() { |
| + return &ppb_scrollbar_0_4; |
| +} |
| + |
| uint32_t PPB_Scrollbar_Impl::GetThickness() { |
| return WebScrollbar::defaultThickness(); |
| } |
| +bool PPB_Scrollbar_Impl::IsOverlay() { |
| +// TODO(jam): take this out once WebKit is rolled. |
| +#if defined(WEBSCROLLBAR_SUPPORTS_OVERLAY) |
| + return scrollbar_->isOverlay(); |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| uint32_t PPB_Scrollbar_Impl::GetValue() { |
| return scrollbar_->value(); |
| } |
| @@ -197,13 +237,31 @@ |
| const PPP_Scrollbar_Dev* ppp_scrollbar = |
| static_cast<const PPP_Scrollbar_Dev*>(instance()->module()-> |
| GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE)); |
| - if (!ppp_scrollbar) |
| - return; |
| + if (!ppp_scrollbar) { |
| + // Try the old version. |
|
brettw
2011/08/03 17:13:58
Can you add here that this is OK to do because the
|
| + ppp_scrollbar = |
| + static_cast<const PPP_Scrollbar_Dev*>(instance()->module()-> |
| + GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE_0_2)); |
| + if (!ppp_scrollbar) |
| + return; |
| + } |
| ScopedResourceId resource(this); |
| ppp_scrollbar->ValueChanged( |
| instance()->pp_instance(), resource.id, scrollbar_->value()); |
| } |
| +void PPB_Scrollbar_Impl::overlayChanged(WebScrollbar* scrollbar) { |
| + const PPP_Scrollbar_Dev* ppp_scrollbar = |
| + static_cast<const PPP_Scrollbar_Dev*>(instance()->module()-> |
| + GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE)); |
| + if (!ppp_scrollbar) |
| + return; |
| + ScopedResourceId resource(this); |
| + ppp_scrollbar->OverlayChanged( |
| + instance()->pp_instance(), resource.id, |
| + PP_FromBool(IsOverlay())); |
| +} |
| + |
| void PPB_Scrollbar_Impl::invalidateScrollbarRect( |
| WebKit::WebScrollbar* scrollbar, |
| const WebKit::WebRect& rect) { |