summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/pepper_scrollbar_widget.h
blob: a5a1719d50ca184db45fab2e4e798a94c4e37e8c (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
// 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 CHROME_RENDERER_PEPPER_SCROLLBAR_WIDGET_H_
#define CHROME_RENDERER_PEPPER_SCROLLBAR_WIDGET_H_
#pragma once

#include <vector>

#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "build/build_config.h"
#include "gfx/point.h"
#include "gfx/rect.h"
#include "chrome/renderer/pepper_widget.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebScrollbarClient.h"

// An implementation of a horizontal/vertical scrollbar.
class PepperScrollbarWidget : public PepperWidget,
                              public WebKit::WebScrollbarClient,
                              public base::RefCounted<PepperScrollbarWidget> {
 public:
  explicit PepperScrollbarWidget(const NPScrollbarCreateParams& params);

  // PepperWidget
  virtual void Destroy();
  virtual void Paint(Graphics2DDeviceContext* context, const NPRect& dirty);
  virtual bool HandleEvent(const NPPepperEvent& event);
  virtual void GetProperty(NPWidgetProperty property, void* value);
  virtual void SetProperty(NPWidgetProperty property, void* value);

  // WebKit::WebScrollbarClient
  virtual void valueChanged(WebKit::WebScrollbar*);
  virtual void invalidateScrollbarRect(WebKit::WebScrollbar*,
                                       const WebKit::WebRect&);
  virtual void getTickmarks(WebKit::WebScrollbar*,
                            WebKit::WebVector<WebKit::WebRect>*) const;

#if defined(OS_LINUX)
  static void SetScrollbarColors(unsigned inactive_color,
                                 unsigned active_color,
                                 unsigned track_color);
#endif

 private:
  friend class base::RefCounted<PepperScrollbarWidget>;

  ~PepperScrollbarWidget();

  void NotifyInvalidate();

  gfx::Rect dirty_rect_;
  gfx::Rect location_;
  std::vector<WebKit::WebRect> tickmarks_;
  scoped_ptr<WebKit::WebScrollbar> scrollbar_;

  DISALLOW_COPY_AND_ASSIGN(PepperScrollbarWidget);
};

#endif  // CHROME_RENDERER_PEPPER_SCROLLBAR_WIDGET_H_