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.
|
|
|
|
|
|
|
|
#include "libcef/browser/views/scroll_view_impl.h"
|
|
|
|
|
|
|
|
// 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());
|
|
|
|
if (!view.get() || !view->IsValid() || view->IsAttached())
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void CefScrollViewImpl::GetDebugInfo(base::DictionaryValue* info,
|
|
|
|
bool include_children) {
|
|
|
|
ParentClass::GetDebugInfo(info, include_children);
|
|
|
|
if (include_children) {
|
|
|
|
views::View* view = root_view()->contents();
|
|
|
|
CefViewAdapter* adapter = CefViewAdapter::GetFor(view);
|
|
|
|
if (adapter) {
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<base::DictionaryValue> child_info(
|
2016-01-19 21:09:01 +01:00
|
|
|
new base::DictionaryValue());
|
|
|
|
adapter->GetDebugInfo(child_info.get(), include_children);
|
|
|
|
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();
|
|
|
|
}
|