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

cc / layers / scrollbar_layer_base.h [blame]

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_LAYERS_SCROLLBAR_LAYER_BASE_H_
#define CC_LAYERS_SCROLLBAR_LAYER_BASE_H_

#include "cc/cc_export.h"
#include "cc/input/scrollbar.h"
#include "cc/layers/layer.h"

namespace cc {

class CC_EXPORT ScrollbarLayerBase : public Layer {
 public:
  static scoped_refptr<ScrollbarLayerBase> CreateOrReuse(
      scoped_refptr<Scrollbar>,
      ScrollbarLayerBase* existing_layer);

  void SetScrollElementId(ElementId element_id);
  ElementId scroll_element_id() const { return scroll_element_id_.Read(*this); }

  ScrollbarOrientation orientation() const { return orientation_; }
  bool is_left_side_vertical_scrollbar() const {
    return is_left_side_vertical_scrollbar_;
  }
  bool has_find_in_page_tickmarks() const {
    return has_find_in_page_tickmarks_.Read(*this);
  }
  bool SetHasFindInPageTickmarks(bool has_find_in_page_tickmarks);

  enum ScrollbarLayerType {
    kSolidColor,
    kPainted,
    kNinePatchThumb,
  };
  virtual ScrollbarLayerType GetScrollbarLayerType() const = 0;

 protected:
  ScrollbarLayerBase(ScrollbarOrientation orientation,
                     bool is_left_side_vertical_scrollbar);
  ~ScrollbarLayerBase() override;

  void PushDirtyPropertiesTo(
      LayerImpl* layer,
      uint8_t dirty_flag,
      const CommitState& commit_state,
      const ThreadUnsafeCommitState& unsafe_state) override;

 private:
  bool IsScrollbarLayerForTesting() const final;

  const ScrollbarOrientation orientation_;
  const bool is_left_side_vertical_scrollbar_;
  ProtectedSequenceReadable<ElementId> scroll_element_id_;
  ProtectedSequenceReadable<bool> has_find_in_page_tickmarks_;
};

}  // namespace cc

#endif  // CC_LAYERS_SCROLLBAR_LAYER_BASE_H_