Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2454913003: MainFrame scrollbars should work with RFV instead of FV (Closed)
Patch Set: Fix broken chromeos bot Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index 3c7a5ca233b60d503615bf953f2fe86955b68b4a..27a478a299d7fd1ba324e86015782fc15fcc17ff 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -439,6 +439,55 @@ void FrameView::ScrollbarManager::destroyScrollbar(
scrollbar = nullptr;
}
+ScrollableArea* FrameView::ScrollbarManager::scrollableArea() const {
+ return m_scrollableArea.get();
+}
+
+void FrameView::ScrollbarManager::updateScrollbarGeometry(IntSize viewSize) {
+ if (!hasHorizontalScrollbar() && !hasVerticalScrollbar())
+ return;
+
+ bool scrollbarOnLeft = m_scrollableArea->shouldPlaceVerticalScrollbarOnLeft();
+
+ if (hasHorizontalScrollbar()) {
+ int thickness = m_hBar->scrollbarThickness();
+ IntRect oldRect(m_hBar->frameRect());
+ IntRect hBarRect(
+ (scrollbarOnLeft && hasVerticalScrollbar()) ? m_vBar->width() : 0,
+ viewSize.height() - thickness,
+ viewSize.width() - (hasVerticalScrollbar() ? m_vBar->width() : 0),
+ thickness);
+ m_hBar->setFrameRect(hBarRect);
+ if (oldRect != m_hBar->frameRect())
+ m_scrollableArea->setScrollbarNeedsPaintInvalidation(HorizontalScrollbar);
+
+ int visibleWidth = m_scrollableArea->visibleWidth();
+ int contentsWidth = m_scrollableArea->contentsSize().width();
+ m_hBar->setEnabled(contentsWidth > visibleWidth &&
+ !m_scrollableArea->scrollbarsHidden());
+ m_hBar->setProportion(visibleWidth, contentsWidth);
+ m_hBar->offsetDidChange();
+ }
+
+ if (hasVerticalScrollbar()) {
+ int thickness = m_vBar->scrollbarThickness();
+ IntRect oldRect(m_vBar->frameRect());
+ IntRect vBarRect(
+ scrollbarOnLeft ? 0 : (viewSize.width() - thickness), 0, thickness,
+ viewSize.height() - (hasHorizontalScrollbar() ? m_hBar->height() : 0));
+ m_vBar->setFrameRect(vBarRect);
+ if (oldRect != m_vBar->frameRect())
+ m_scrollableArea->setScrollbarNeedsPaintInvalidation(VerticalScrollbar);
+
+ int clientHeight = m_scrollableArea->visibleHeight();
+ int contentsHeight = m_scrollableArea->contentsSize().height();
+ m_vBar->setEnabled(contentsHeight > clientHeight &&
+ !m_scrollableArea->scrollbarsHidden());
+ m_vBar->setProportion(clientHeight, contentsHeight);
+ m_vBar->offsetDidChange();
+ }
+}
+
void FrameView::recalculateCustomScrollbarStyle() {
bool didStyleChange = false;
if (horizontalScrollbar() && horizontalScrollbar()->isCustomScrollbar()) {
@@ -450,7 +499,7 @@ void FrameView::recalculateCustomScrollbarStyle() {
didStyleChange = true;
}
if (didStyleChange) {
- updateScrollbarGeometry();
+ m_scrollbarManager.updateScrollbarGeometry(size());
updateScrollCorner();
positionScrollbarLayers();
}
@@ -797,7 +846,7 @@ void FrameView::recalcOverflowAfterStyleChange() {
}
adjustViewSize();
- updateScrollbarGeometry();
+ m_scrollbarManager.updateScrollbarGeometry(size());
if (scrollOriginChanged())
setNeedsLayout();
@@ -2413,7 +2462,7 @@ bool FrameView::isActive() const {
}
void FrameView::invalidatePaintForTickmarks() {
- if (Scrollbar* scrollbar = verticalScrollbar())
+ if (Scrollbar* scrollbar = getScrollableArea()->verticalScrollbar())
scrollbar->setNeedsPaintInvalidation(
static_cast<ScrollbarPart>(~ThumbPart));
}
@@ -2581,6 +2630,13 @@ void FrameView::didAttachDocument() {
RootFrameViewport::create(visualViewport, *layoutViewport);
m_viewportScrollableArea = rootFrameViewport;
+ // TODO(crbug.com/661236): Currently for the main frame, the scroller that
+ // the scrollbar manager works with is RootFrameViewport which is needed so
+ // that the visual viewport is taken into account when determining scrollbar
+ // extent and existence. Eventually, each scroller should have its own
+ // scrollbar manager and we shouldn't set the scroller here.
+ m_scrollbarManager.setScroller(rootFrameViewport);
+
frameHost->globalRootScrollerController().initializeViewportScrollCallback(
*rootFrameViewport);
}
@@ -3714,12 +3770,6 @@ void FrameView::clearScrollAnchor() {
m_scrollAnchor.clear();
}
-bool FrameView::hasOverlayScrollbars() const {
- return (horizontalScrollbar() &&
- horizontalScrollbar()->isOverlayScrollbar()) ||
- (verticalScrollbar() && verticalScrollbar()->isOverlayScrollbar());
-}
-
void FrameView::computeScrollbarExistence(
bool& newHasHorizontalScrollbar,
bool& newHasVerticalScrollbar,
@@ -3752,15 +3802,17 @@ void FrameView::computeScrollbarExistence(
(hScroll != ScrollbarAuto && vScroll != ScrollbarAuto))
return;
+ ScrollableArea* scroller = m_scrollbarManager.scrollableArea();
if (hScroll == ScrollbarAuto)
- newHasHorizontalScrollbar = docSize.width() > visibleWidth();
+ newHasHorizontalScrollbar = docSize.width() > scroller->visibleWidth();
if (vScroll == ScrollbarAuto)
- newHasVerticalScrollbar = docSize.height() > visibleHeight();
+ newHasVerticalScrollbar = docSize.height() > scroller->visibleHeight();
if (hasOverlayScrollbars())
return;
- IntSize fullVisibleSize = visibleContentRect(IncludeScrollbars).size();
+ IntSize fullVisibleSize =
+ scroller->visibleContentRect(IncludeScrollbars).size();
bool attemptToRemoveScrollbars =
(option == FirstPass && docSize.width() <= fullVisibleSize.width() &&
@@ -3773,46 +3825,6 @@ void FrameView::computeScrollbarExistence(
}
}
-void FrameView::updateScrollbarGeometry() {
- if (horizontalScrollbar()) {
- int thickness = horizontalScrollbar()->scrollbarThickness();
- int clientWidth = visibleWidth();
- IntRect oldRect(horizontalScrollbar()->frameRect());
- IntRect hBarRect(
- (shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar())
- ? verticalScrollbar()->width()
- : 0,
- height() - thickness,
- width() - (verticalScrollbar() ? verticalScrollbar()->width() : 0),
- thickness);
- horizontalScrollbar()->setFrameRect(hBarRect);
- if (oldRect != horizontalScrollbar()->frameRect())
- setScrollbarNeedsPaintInvalidation(HorizontalScrollbar);
-
- horizontalScrollbar()->setEnabled(contentsWidth() > clientWidth);
- horizontalScrollbar()->setProportion(clientWidth, contentsWidth());
- horizontalScrollbar()->offsetDidChange();
- }
-
- if (verticalScrollbar()) {
- int thickness = verticalScrollbar()->scrollbarThickness();
- int clientHeight = visibleHeight();
- IntRect oldRect(verticalScrollbar()->frameRect());
- IntRect vBarRect(
- shouldPlaceVerticalScrollbarOnLeft() ? 0 : (width() - thickness), 0,
- thickness,
- height() -
- (horizontalScrollbar() ? horizontalScrollbar()->height() : 0));
- verticalScrollbar()->setFrameRect(vBarRect);
- if (oldRect != verticalScrollbar()->frameRect())
- setScrollbarNeedsPaintInvalidation(VerticalScrollbar);
-
- verticalScrollbar()->setEnabled(contentsHeight() > clientHeight);
- verticalScrollbar()->setProportion(clientHeight, contentsHeight());
- verticalScrollbar()->offsetDidChange();
- }
-}
-
bool FrameView::adjustScrollbarExistence(
ComputeScrollbarExistenceOption option) {
ASSERT(m_inUpdateScrollbars);
@@ -3911,7 +3923,7 @@ void FrameView::updateScrollbars() {
scrollbarExistenceChanged = true;
}
- updateScrollbarGeometry();
+ m_scrollbarManager.updateScrollbarGeometry(size());
if (scrollbarExistenceChanged) {
// FIXME: Is frameRectsChanged really necessary here? Have any frame rects
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/core/frame/RootFrameViewport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698