#include "ui/views/controls/scroll_view.h"
#include <algorithm>
#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/i18n/rtl.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/ui_base_features.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_type.h"
#include "ui/compositor/overscroll/scroll_input_handler.h"
#include "ui/events/event.h"
#include "ui/gfx/canvas.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/focus_ring.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/view.h"
#include "ui/views/view_utils.h"
#include "ui/views/widget/widget.h"
namespace views {
namespace {
template <class T>
T CombineScrollOffsets(T x, T y) { … }
class ScrollCornerView : public View { … };
BEGIN_METADATA(…)
bool DoesDescendantHaveLayer(View* view) { … }
int CheckScrollBounds(int viewport_size, int content_size, int current_pos) { … }
void ConstrainScrollToBounds(View* viewport,
View* view,
bool scroll_with_layers_enabled) { … }
int AdjustPosition(int current_position,
int new_position,
int content_size,
int viewport_size) { … }
}
class ScrollView::Viewport : public View { … };
BEGIN_METADATA(…)
ScrollView::ScrollView()
: … { … }
ScrollView::ScrollView(ScrollWithLayers scroll_with_layers)
: … { … }
ScrollView::~ScrollView() = default;
std::unique_ptr<ScrollView> ScrollView::CreateScrollViewWithBorder() { … }
ScrollView* ScrollView::GetScrollViewForContents(View* contents) { … }
void ScrollView::SetContentsImpl(std::unique_ptr<View> a_view) { … }
void ScrollView::SetContents(std::nullptr_t) { … }
void ScrollView::SetContentsLayerType(ui::LayerType layer_type) { … }
void ScrollView::SetHeaderImpl(std::unique_ptr<View> a_header) { … }
void ScrollView::SetHeader(std::nullptr_t) { … }
void ScrollView::SetPreferredViewportMargins(const gfx::Insets& margins) { … }
void ScrollView::SetViewportRoundedCornerRadius(
const gfx::RoundedCornersF& radii) { … }
void ScrollView::SetBackgroundColor(const std::optional<SkColor>& color) { … }
void ScrollView::SetBackgroundThemeColorId(
const std::optional<ui::ColorId>& color_id) { … }
gfx::Rect ScrollView::GetVisibleRect() const { … }
void ScrollView::SetHorizontalScrollBarMode(
ScrollBarMode horizontal_scroll_bar_mode) { … }
void ScrollView::SetVerticalScrollBarMode(
ScrollBarMode vertical_scroll_bar_mode) { … }
void ScrollView::SetTreatAllScrollEventsAsHorizontal(
bool treat_all_scroll_events_as_horizontal) { … }
void ScrollView::SetAllowKeyboardScrolling(bool allow_keyboard_scrolling) { … }
void ScrollView::SetDrawOverflowIndicator(bool draw_overflow_indicator) { … }
View* ScrollView::SetCustomOverflowIndicator(OverflowIndicatorAlignment side,
std::unique_ptr<View> indicator,
int thickness,
bool fills_opaquely) { … }
void ScrollView::ClipHeightTo(int min_height, int max_height) { … }
int ScrollView::GetScrollBarLayoutWidth() const { … }
int ScrollView::GetScrollBarLayoutHeight() const { … }
ScrollBar* ScrollView::SetHorizontalScrollBar(
std::unique_ptr<ScrollBar> horiz_sb) { … }
ScrollBar* ScrollView::SetVerticalScrollBar(
std::unique_ptr<ScrollBar> vert_sb) { … }
void ScrollView::SetHasFocusIndicator(bool has_focus_indicator) { … }
base::CallbackListSubscription ScrollView::AddContentsScrolledCallback(
ScrollViewCallback callback) { … }
base::CallbackListSubscription ScrollView::AddContentsScrollEndedCallback(
ScrollViewCallback callback) { … }
gfx::Size ScrollView::CalculatePreferredSize(
const SizeBounds& available_size) const { … }
void ScrollView::Layout(PassKey) { … }
bool ScrollView::OnKeyPressed(const ui::KeyEvent& event) { … }
bool ScrollView::OnMouseWheel(const ui::MouseWheelEvent& e) { … }
void ScrollView::OnScrollEvent(ui::ScrollEvent* event) { … }
void ScrollView::OnGestureEvent(ui::GestureEvent* event) { … }
void ScrollView::OnThemeChanged() { … }
bool ScrollView::HandleAccessibleAction(const ui::AXActionData& action_data) { … }
void ScrollView::ScrollToPosition(ScrollBar* source, int position) { … }
int ScrollView::GetScrollIncrement(ScrollBar* source,
bool is_page,
bool is_positive) { … }
void ScrollView::OnScrollEnded() { … }
bool ScrollView::DoesViewportOrScrollViewHaveLayer() const { … }
void ScrollView::UpdateViewportLayerForClipping() { … }
View* ScrollView::ReplaceChildView(View* parent,
raw_ptr<View>::DanglingType old_view,
std::unique_ptr<View> new_view) { … }
void ScrollView::ScrollContentsRegionToBeVisible(const gfx::Rect& rect) { … }
void ScrollView::ComputeScrollBarsVisibility(const gfx::Size& vp_size,
const gfx::Size& content_size,
bool* horiz_is_shown,
bool* vert_is_shown) const { … }
void ScrollView::SetControlVisibility(View* control, bool should_show) { … }
void ScrollView::UpdateScrollBarPositions() { … }
gfx::PointF ScrollView::CurrentOffset() const { … }
void ScrollView::ScrollByOffset(const gfx::PointF& offset) { … }
void ScrollView::ScrollToOffset(const gfx::PointF& offset) { … }
bool ScrollView::ScrollsWithLayers() const { … }
bool ScrollView::IsHorizontalScrollEnabled() const { … }
bool ScrollView::IsVerticalScrollEnabled() const { … }
void ScrollView::EnableViewportLayer() { … }
void ScrollView::OnLayerScrolled(const gfx::PointF& current_offset,
const cc::ElementId&) { … }
void ScrollView::OnScrolled(const gfx::PointF& offset) { … }
void ScrollView::ScrollHeader() { … }
void ScrollView::AddBorder() { … }
void ScrollView::UpdateBorder() { … }
void ScrollView::UpdateBackground() { … }
std::optional<SkColor> ScrollView::GetBackgroundColor() const { … }
std::optional<ui::ColorId> ScrollView::GetBackgroundThemeColorId() const { … }
void ScrollView::PositionOverflowIndicators() { … }
void ScrollView::UpdateOverflowIndicatorVisibility(const gfx::PointF& offset) { … }
View* ScrollView::GetContentsViewportForTest() const { … }
BEGIN_METADATA(…)
VariableRowHeightScrollHelper::VariableRowHeightScrollHelper(
Controller* controller)
: … { … }
VariableRowHeightScrollHelper::~VariableRowHeightScrollHelper() = default;
int VariableRowHeightScrollHelper::GetPageScrollIncrement(
ScrollView* scroll_view,
bool is_horizontal,
bool is_positive) { … }
int VariableRowHeightScrollHelper::GetLineScrollIncrement(
ScrollView* scroll_view,
bool is_horizontal,
bool is_positive) { … }
VariableRowHeightScrollHelper::RowInfo
VariableRowHeightScrollHelper::GetRowInfo(int y) { … }
FixedRowHeightScrollHelper::FixedRowHeightScrollHelper(int top_margin,
int row_height)
: … { … }
VariableRowHeightScrollHelper::RowInfo FixedRowHeightScrollHelper::GetRowInfo(
int y) { … }
}