2016-01-19 21:09:01 +01:00
|
|
|
// Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found
|
|
|
|
// in the LICENSE file.
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/views/scroll_view_impl.h"
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
// static
|
|
|
|
CefRefPtr<CefScrollView> CefScrollView::CreateScrollView(
|
|
|
|
CefRefPtr<CefViewDelegate> delegate) {
|
|
|
|
return CefScrollViewImpl::Create(delegate);
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
CefRefPtr<CefScrollViewImpl> CefScrollViewImpl::Create(
|
|
|
|
CefRefPtr<CefViewDelegate> delegate) {
|
|
|
|
CEF_REQUIRE_UIT_RETURN(nullptr);
|
|
|
|
CefRefPtr<CefScrollViewImpl> view = new CefScrollViewImpl(delegate);
|
|
|
|
view->Initialize();
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefScrollViewImpl::SetContentView(CefRefPtr<CefView> view) {
|
|
|
|
CEF_REQUIRE_VALID_RETURN_VOID();
|
|
|
|
DCHECK(view.get());
|
|
|
|
DCHECK(view->IsValid());
|
|
|
|
DCHECK(!view->IsAttached());
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!view.get() || !view->IsValid() || view->IsAttached()) {
|
2016-01-19 21:09:01 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-01-19 21:09:01 +01:00
|
|
|
|
2019-04-16 16:38:48 +02:00
|
|
|
root_view()->SetContents(view_util::PassOwnership(view));
|
2016-01-19 21:09:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefView> CefScrollViewImpl::GetContentView() {
|
|
|
|
CEF_REQUIRE_VALID_RETURN(nullptr);
|
|
|
|
return view_util::GetFor(root_view()->contents(), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRect CefScrollViewImpl::GetVisibleContentRect() {
|
|
|
|
CEF_REQUIRE_VALID_RETURN(CefRect());
|
|
|
|
const gfx::Rect& rect = root_view()->GetVisibleRect();
|
|
|
|
return CefRect(rect.x(), rect.y(), rect.width(), rect.height());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefScrollViewImpl::HasHorizontalScrollbar() {
|
|
|
|
CEF_REQUIRE_VALID_RETURN(false);
|
|
|
|
const views::ScrollBar* scrollbar = root_view()->horizontal_scroll_bar();
|
2019-07-16 19:59:21 +02:00
|
|
|
return scrollbar && scrollbar->GetVisible();
|
2016-01-19 21:09:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int CefScrollViewImpl::GetHorizontalScrollbarHeight() {
|
|
|
|
CEF_REQUIRE_VALID_RETURN(0);
|
2017-01-23 18:36:54 +01:00
|
|
|
return root_view()->GetScrollBarLayoutHeight();
|
2016-01-19 21:09:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefScrollViewImpl::HasVerticalScrollbar() {
|
|
|
|
CEF_REQUIRE_VALID_RETURN(false);
|
|
|
|
const views::ScrollBar* scrollbar = root_view()->vertical_scroll_bar();
|
2019-07-16 19:59:21 +02:00
|
|
|
return scrollbar && scrollbar->GetVisible();
|
2016-01-19 21:09:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int CefScrollViewImpl::GetVerticalScrollbarWidth() {
|
|
|
|
CEF_REQUIRE_VALID_RETURN(0);
|
2017-01-23 18:36:54 +01:00
|
|
|
return root_view()->GetScrollBarLayoutWidth();
|
2016-01-19 21:09:01 +01:00
|
|
|
}
|
|
|
|
|
2023-01-30 22:42:40 +01:00
|
|
|
void CefScrollViewImpl::GetDebugInfo(base::Value::Dict* info,
|
2016-01-19 21:09:01 +01:00
|
|
|
bool include_children) {
|
|
|
|
ParentClass::GetDebugInfo(info, include_children);
|
|
|
|
if (include_children) {
|
|
|
|
views::View* view = root_view()->contents();
|
|
|
|
CefViewAdapter* adapter = CefViewAdapter::GetFor(view);
|
|
|
|
if (adapter) {
|
2023-01-30 22:42:40 +01:00
|
|
|
base::Value::Dict child_info;
|
|
|
|
adapter->GetDebugInfo(&child_info, include_children);
|
2016-01-19 21:09:01 +01:00
|
|
|
info->Set("content_view", std::move(child_info));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CefScrollViewImpl::CefScrollViewImpl(CefRefPtr<CefViewDelegate> delegate)
|
2017-05-17 11:29:28 +02:00
|
|
|
: ParentClass(delegate) {}
|
2016-01-19 21:09:01 +01:00
|
|
|
|
|
|
|
CefScrollViewView* CefScrollViewImpl::CreateRootView() {
|
|
|
|
return new CefScrollViewView(delegate());
|
|
|
|
}
|
2016-07-21 23:21:32 +02:00
|
|
|
|
|
|
|
void CefScrollViewImpl::InitializeRootView() {
|
|
|
|
static_cast<CefScrollViewView*>(root_view())->Initialize();
|
|
|
|
}
|