summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/pepper_scrollbar.h
blob: bf251365e69356d62a783b2e0969d14e97952572 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_SCROLLBAR_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_SCROLLBAR_H_

#include <vector>

#include "gfx/rect.h"
#include "third_party/ppapi/c/ppb_scrollbar.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebScrollbarClient.h"
#include "webkit/glue/plugins/pepper_widget.h"

typedef struct _ppb_Scrollbar PPB_Scrollbar;

namespace pepper {

class PluginInstance;

class Scrollbar : public Widget, public WebKit::WebScrollbarClient {
 public:
  Scrollbar(PluginInstance* instance, bool vertical);
  virtual ~Scrollbar();

  // Returns a pointer to the interface implementing PPB_Scrollbar that is
  // exposed to the plugin.
  static const PPB_Scrollbar* GetInterface();

  // Resource overrides.
  Scrollbar* AsScrollbar() { return this; }

  // PPB_Scrollbar implementation.
  uint32_t GetValue();
  void SetValue(uint32_t value);
  void SetDocumentSize(uint32_t size);
  void SetTickMarks(const PP_Rect* tick_marks, uint32_t count);
  void ScrollBy(PP_ScrollBy unit, int32_t multiplier);

  // PPB_Widget implementation.
  virtual bool Paint(const PP_Rect* rect, ImageData* image);
  virtual bool HandleEvent(const PP_Event* event);
  virtual void SetLocationInternal(const PP_Rect* location);

 private:
  // WebKit::WebScrollbarClient implementation.
  virtual void valueChanged(WebKit::WebScrollbar* scrollbar);
  virtual void invalidateScrollbarRect(WebKit::WebScrollbar* scrollbar,
                                       const WebKit::WebRect& rect);
  virtual void getTickmarks(
      WebKit::WebScrollbar* scrollbar,
      WebKit::WebVector<WebKit::WebRect>* tick_marks) const;

  void NotifyInvalidate();

  gfx::Rect dirty_;
  std::vector<WebKit::WebRect> tickmarks_;
  scoped_ptr<WebKit::WebScrollbar> scrollbar_;
};

}  // namespace pepper

#endif  // WEBKIT_GLUE_PLUGINS_PEPPER_SCROLLBAR_H_