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

Unified Diff: Source/platform/scroll/ScrollView.cpp

Issue 621653002: Don't call into ScrollView from Scrollbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@resizer
Patch Set: Created 6 years, 3 months 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: Source/platform/scroll/ScrollView.cpp
diff --git a/Source/platform/scroll/ScrollView.cpp b/Source/platform/scroll/ScrollView.cpp
index f447873afcd252407dcf492fc30e21f87f8368d5..f213c35ff65a4621acdbcd50b3b05ed596914bab 100644
--- a/Source/platform/scroll/ScrollView.cpp
+++ b/Source/platform/scroll/ScrollView.cpp
@@ -75,6 +75,8 @@ void ScrollView::setHasHorizontalScrollbar(bool hasBar)
m_horizontalScrollbar->styleChanged();
} else if (!hasBar && m_horizontalScrollbar) {
willRemoveScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar);
+ if (m_horizontalScrollbar->overlapsResizer())
Ian Vollick 2014/10/04 01:25:44 It's not obvious to me how we'll know that ScrollV
skobes 2014/10/06 18:18:53 Added a comment. Note that if adjustScrollbarRect
+ adjustScrollbarsAvoidingResizerCount(-1);
removeChild(m_horizontalScrollbar.get());
m_horizontalScrollbar = nullptr;
}
@@ -89,6 +91,8 @@ void ScrollView::setHasVerticalScrollbar(bool hasBar)
m_verticalScrollbar->styleChanged();
} else if (!hasBar && m_verticalScrollbar) {
willRemoveScrollbar(m_verticalScrollbar.get(), VerticalScrollbar);
+ if (m_verticalScrollbar->overlapsResizer())
+ adjustScrollbarsAvoidingResizerCount(-1);
removeChild(m_verticalScrollbar.get());
m_verticalScrollbar = nullptr;
}
@@ -386,7 +390,7 @@ void ScrollView::updateScrollbarGeometry()
height() - m_horizontalScrollbar->height(),
width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0),
m_horizontalScrollbar->height());
- m_horizontalScrollbar->setFrameRect(hBarRect);
+ m_horizontalScrollbar->setFrameRect(adjustScrollbarRectForResizer(hBarRect, m_horizontalScrollbar.get()));
if (!m_scrollbarsSuppressed && oldRect != m_horizontalScrollbar->frameRect())
m_horizontalScrollbar->invalidate();
@@ -406,7 +410,7 @@ void ScrollView::updateScrollbarGeometry()
0,
m_verticalScrollbar->width(),
height() - (m_horizontalScrollbar ? m_horizontalScrollbar->height() : 0));
- m_verticalScrollbar->setFrameRect(vBarRect);
+ m_verticalScrollbar->setFrameRect(adjustScrollbarRectForResizer(vBarRect, m_verticalScrollbar.get()));
if (!m_scrollbarsSuppressed && oldRect != m_verticalScrollbar->frameRect())
m_verticalScrollbar->invalidate();
@@ -420,6 +424,37 @@ void ScrollView::updateScrollbarGeometry()
}
}
+IntRect ScrollView::adjustScrollbarRectForResizer(const IntRect& rect, Scrollbar* scrollbar)
+{
+ // Get our window resizer rect and see if we overlap. Adjust to avoid the overlap
+ // if necessary.
+ IntRect adjustedRect(rect);
+ bool overlapsResizer = false;
+ if (!rect.isEmpty() && !windowResizerRect().isEmpty()) {
+ IntRect resizerRect = convertFromContainingWindow(windowResizerRect());
+ if (rect.intersects(resizerRect)) {
+ if (scrollbar->orientation() == HorizontalScrollbar) {
+ int overlap = rect.maxX() - resizerRect.x();
+ if (overlap > 0 && resizerRect.maxX() >= rect.maxX()) {
+ adjustedRect.setWidth(rect.width() - overlap);
+ overlapsResizer = true;
+ }
+ } else {
+ int overlap = rect.maxY() - resizerRect.y();
+ if (overlap > 0 && resizerRect.maxY() >= rect.maxY()) {
+ adjustedRect.setHeight(rect.height() - overlap);
+ overlapsResizer = true;
+ }
+ }
+ }
+ }
+ if (overlapsResizer != scrollbar->overlapsResizer()) {
+ scrollbar->setOverlapsResizer(overlapsResizer);
+ adjustScrollbarsAvoidingResizerCount(overlapsResizer ? 1 : -1);
+ }
+ return adjustedRect;
+}
+
bool ScrollView::adjustScrollbarExistence(ComputeScrollbarExistenceOption option)
{
ASSERT(m_inUpdateScrollbars);

Powered by Google App Engine
This is Rietveld 408576698