Changeset 194184 in webkit
- Timestamp:
- Dec 16, 2015 3:41:05 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r194183 r194184 1 2015-12-16 Simon Fraser <simon.fraser@apple.com> 2 3 Simplify isOverlayScrollbar() logic 4 https://bugs.webkit.org/show_bug.cgi?id=152357 5 6 Reviewed by Beth Dakin. 7 8 Replace code that checks for isOverlayScrollbar() explicitly with calls to new 9 occupiedWidth()/occupiedHeight() functions on Scrollbar, which do the overlay 10 scrollbar check internally. 11 12 Add ScrollableArea::scrollbarIntrusion() which returns an IntSize with the occupiedWidth 13 and occupiedHeight of any scrollbars, and use it in a few places. 14 15 * page/FrameView.cpp: 16 (WebCore::FrameView::autoSizeIfEnabled): 17 * platform/ScrollView.cpp: 18 (WebCore::ScrollView::unscaledVisibleContentSizeIncludingObscuredArea): 19 (WebCore::ScrollView::calculateOverhangAreasForPainting): 20 * platform/ScrollableArea.cpp: 21 (WebCore::ScrollableArea::scrollbarIntrusion): 22 (WebCore::ScrollableArea::visibleContentRectInternal): 23 * platform/ScrollableArea.h: 24 * platform/Scrollbar.cpp: 25 (WebCore::Scrollbar::occupiedWidth): 26 (WebCore::Scrollbar::occupiedHeight): 27 * platform/Scrollbar.h: 28 * rendering/RenderLayer.cpp: 29 (WebCore::RenderLayer::visibleContentRectInternal): 30 * rendering/RenderListBox.cpp: 31 (WebCore::RenderListBox::verticalScrollbarWidth): 32 1 33 2015-12-16 Alex Christensen <achristensen@webkit.org> 2 34 -
trunk/Source/WebCore/page/FrameView.cpp
r192966 r194184 3263 3263 if (!localHorizontalScrollbar) 3264 3264 localHorizontalScrollbar = createScrollbar(HorizontalScrollbar); 3265 if (!localHorizontalScrollbar->isOverlayScrollbar()) 3266 newSize.setHeight(newSize.height() + localHorizontalScrollbar->height()); 3265 newSize.expand(0, localHorizontalScrollbar->occupiedHeight()); 3267 3266 3268 3267 // Don't bother checking for a vertical scrollbar because the width is at … … 3272 3271 if (!localVerticalScrollbar) 3273 3272 localVerticalScrollbar = createScrollbar(VerticalScrollbar); 3274 if (!localVerticalScrollbar->isOverlayScrollbar()) 3275 newSize.setWidth(newSize.width() + localVerticalScrollbar->width()); 3273 newSize.expand(localVerticalScrollbar->occupiedWidth(), 0); 3276 3274 3277 3275 // Don't bother checking for a horizontal scrollbar because the height is -
trunk/Source/WebCore/platform/ScrollView.cpp
r194155 r194184 276 276 #endif 277 277 278 int verticalScrollbarWidth = 0; 279 int horizontalScrollbarHeight = 0; 280 281 if (scrollbarInclusion == ExcludeScrollbars) { 282 if (Scrollbar* verticalBar = verticalScrollbar()) 283 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBar->width() : 0; 284 if (Scrollbar* horizontalBar = horizontalScrollbar()) 285 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horizontalBar->height() : 0; 286 } 287 288 return IntSize(width() - verticalScrollbarWidth, height() - horizontalScrollbarHeight).expandedTo(IntSize()); 278 IntSize scrollbarSpace; 279 if (scrollbarInclusion == ExcludeScrollbars) 280 scrollbarSpace = scrollbarIntrusion(); 281 282 return IntSize(width() - scrollbarSpace.width(), height() - scrollbarSpace.height()).expandedTo(IntSize()); 289 283 } 290 284 … … 1250 1244 void ScrollView::calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntRect& verticalOverhangRect) 1251 1245 { 1252 int verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) 1253 ? verticalScrollbar()->width() : 0; 1254 int horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) 1255 ? horizontalScrollbar()->height() : 0; 1246 IntSize scrollbarSpace = scrollbarIntrusion(); 1256 1247 1257 1248 int physicalScrollY = scrollPosition().y() + scrollOrigin().y(); … … 1259 1250 horizontalOverhangRect = frameRect(); 1260 1251 horizontalOverhangRect.setHeight(-physicalScrollY); 1261 horizontalOverhangRect.setWidth(horizontalOverhangRect.width() - verticalScrollbarWidth);1252 horizontalOverhangRect.setWidth(horizontalOverhangRect.width() - scrollbarSpace.width()); 1262 1253 } else if (totalContentsSize().height() && physicalScrollY > totalContentsSize().height() - visibleHeight()) { 1263 1254 int height = physicalScrollY - (totalContentsSize().height() - visibleHeight()); 1264 1255 horizontalOverhangRect = frameRect(); 1265 horizontalOverhangRect.setY(frameRect().maxY() - height - horizontalScrollbarHeight);1256 horizontalOverhangRect.setY(frameRect().maxY() - height - scrollbarSpace.height()); 1266 1257 horizontalOverhangRect.setHeight(height); 1267 horizontalOverhangRect.setWidth(horizontalOverhangRect.width() - verticalScrollbarWidth);1258 horizontalOverhangRect.setWidth(horizontalOverhangRect.width() - scrollbarSpace.width()); 1268 1259 } 1269 1260 … … 1271 1262 if (physicalScrollX < 0) { 1272 1263 verticalOverhangRect.setWidth(-physicalScrollX); 1273 verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhangRect.height() - horizontalScrollbarHeight);1264 verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhangRect.height() - scrollbarSpace.height()); 1274 1265 verticalOverhangRect.setX(frameRect().x()); 1275 1266 if (horizontalOverhangRect.y() == frameRect().y()) … … 1280 1271 int width = physicalScrollX - (contentsWidth() - visibleWidth()); 1281 1272 verticalOverhangRect.setWidth(width); 1282 verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhangRect.height() - horizontalScrollbarHeight);1283 verticalOverhangRect.setX(frameRect().maxX() - width - verticalScrollbarWidth);1273 verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhangRect.height() - scrollbarSpace.height()); 1274 verticalOverhangRect.setX(frameRect().maxX() - width - scrollbarSpace.width()); 1284 1275 if (horizontalOverhangRect.y() == frameRect().y()) 1285 1276 verticalOverhangRect.setY(frameRect().y() + horizontalOverhangRect.height()); -
trunk/Source/WebCore/platform/ScrollableArea.cpp
r191735 r194184 517 517 #endif // PLATFORM(IOS) 518 518 519 IntSize ScrollableArea::scrollbarIntrusion() const 520 { 521 return IntSize( 522 verticalScrollbar() ? verticalScrollbar()->occupiedWidth() : 0, 523 horizontalScrollbar() ? horizontalScrollbar()->occupiedHeight() : 0); 524 } 525 519 526 IntPoint ScrollableArea::scrollPosition() const 520 527 { … … 583 590 if (scrollbarInclusion == IncludeScrollbars) { 584 591 if (Scrollbar* verticalBar = verticalScrollbar()) 585 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBar->width() : 0;592 verticalScrollbarWidth = verticalBar->occupiedWidth(); 586 593 if (Scrollbar* horizontalBar = horizontalScrollbar()) 587 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horizontalBar->height() : 0;594 horizontalScrollbarHeight = horizontalBar->occupiedHeight(); 588 595 } 589 596 -
trunk/Source/WebCore/platform/ScrollableArea.h
r192193 r194184 174 174 return scrollbar->Widget::convertFromContainingView(parentPoint); 175 175 } 176 177 WEBCORE_EXPORT IntSize scrollbarIntrusion() const; 176 178 177 179 virtual Scrollbar* horizontalScrollbar() const { return 0; } -
trunk/Source/WebCore/platform/Scrollbar.cpp
r191735 r194184 98 98 } 99 99 100 int Scrollbar::occupiedWidth() const 101 { 102 return isOverlayScrollbar() ? 0 : width(); 103 } 104 105 int Scrollbar::occupiedHeight() const 106 { 107 return isOverlayScrollbar() ? 0 : height(); 108 } 109 100 110 void Scrollbar::offsetDidChange() 101 111 { -
trunk/Source/WebCore/platform/Scrollbar.h
r189270 r194184 70 70 int maximum() const { return m_totalSize - m_visibleSize; } 71 71 ScrollbarControlSize controlSize() const { return m_controlSize; } 72 73 int occupiedWidth() const; 74 int occupiedHeight() const; 72 75 73 76 int lineStep() const { return m_lineStep; } -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r193614 r194184 2748 2748 IntRect RenderLayer::visibleContentRectInternal(VisibleContentRectIncludesScrollbars scrollbarInclusion, VisibleContentRectBehavior) const 2749 2749 { 2750 int verticalScrollbarWidth = 0; 2751 int horizontalScrollbarHeight = 0; 2752 if (showsOverflowControls() && scrollbarInclusion == IncludeScrollbars) { 2753 verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) ? verticalScrollbar()->width() : 0; 2754 horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0; 2755 } 2756 2757 return IntRect(scrollPosition(), IntSize(std::max(0, m_layerSize.width() - verticalScrollbarWidth), std::max(0, m_layerSize.height() - horizontalScrollbarHeight))); 2750 IntSize scrollbarSpace; 2751 if (showsOverflowControls() && scrollbarInclusion == IncludeScrollbars) 2752 scrollbarSpace = scrollbarIntrusion(); 2753 2754 return IntRect(scrollPosition(), IntSize(std::max(0, m_layerSize.width() - scrollbarSpace.width()), std::max(0, m_layerSize.height() - scrollbarSpace.height()))); 2758 2755 } 2759 2756 -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r192193 r194184 631 631 int RenderListBox::verticalScrollbarWidth() const 632 632 { 633 return m_vBar && !m_vBar->isOverlayScrollbar() ? m_vBar->width() : 0;633 return m_vBar ? m_vBar->occupiedWidth() : 0; 634 634 } 635 635 -
trunk/Source/WebKit2/ChangeLog
r194168 r194184 1 2015-12-16 Simon Fraser <simon.fraser@apple.com> 2 3 Simplify isOverlayScrollbar() logic 4 https://bugs.webkit.org/show_bug.cgi?id=152357 5 6 Reviewed by Beth Dakin. 7 8 Replace code that checks for isOverlayScrollbar() explicitly with calls to new 9 occupiedWidth()/occupiedHeight() functions on Scrollbar, which do the overlay 10 scrollbar check internally. 11 12 Add ScrollableArea::scrollbarIntrusion() which returns an IntSize with the occupiedWidth 13 and occupiedHeight of any scrollbars, and use it in a few places. 14 15 * WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm: 16 (WebKit::PDFPlugin::updateScrollbars): 17 (WebKit::PDFPlugin::maximumScrollPosition): 18 1 19 2015-12-16 Alex Christensen <achristensen@webkit.org> 2 20 -
trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm
r192900 r194184 588 588 m_verticalScrollbar = createScrollbar(VerticalScrollbar); 589 589 590 int horizontalScrollbarHeight = (m_horizontalScrollbar && !m_horizontalScrollbar->isOverlayScrollbar()) ? m_horizontalScrollbar->height() : 0; 591 int verticalScrollbarWidth = (m_verticalScrollbar && !m_verticalScrollbar->isOverlayScrollbar()) ? m_verticalScrollbar->width() : 0; 590 IntSize scrollbarSpace = scrollbarIntrusion(); 592 591 593 592 int pageStep = m_pageBoxes.isEmpty() ? 0 : m_pageBoxes[0].height(); … … 595 594 if (m_horizontalScrollbar) { 596 595 m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); 597 m_horizontalScrollbar->setProportion(m_size.width() - verticalScrollbarWidth, m_pdfDocumentSize.width());596 m_horizontalScrollbar->setProportion(m_size.width() - scrollbarSpace.width(), m_pdfDocumentSize.width()); 598 597 IntRect scrollbarRect(pluginView()->x(), pluginView()->y() + m_size.height() - m_horizontalScrollbar->height(), m_size.width(), m_horizontalScrollbar->height()); 599 598 if (m_verticalScrollbar) … … 603 602 if (m_verticalScrollbar) { 604 603 m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); 605 m_verticalScrollbar->setProportion(m_size.height() - horizontalScrollbarHeight, m_pdfDocumentSize.height());604 m_verticalScrollbar->setProportion(m_size.height() - scrollbarSpace.height(), m_pdfDocumentSize.height()); 606 605 IntRect scrollbarRect(IntRect(pluginView()->x() + m_size.width() - m_verticalScrollbar->width(), pluginView()->y(), m_verticalScrollbar->width(), m_size.height())); 607 606 if (m_horizontalScrollbar) … … 797 796 IntPoint PDFPlugin::maximumScrollPosition() const 798 797 { 799 int horizontalScrollbarHeight = (m_horizontalScrollbar && !m_horizontalScrollbar->isOverlayScrollbar()) ? m_horizontalScrollbar->height() : 0; 800 int verticalScrollbarWidth = (m_verticalScrollbar && !m_verticalScrollbar->isOverlayScrollbar()) ? m_verticalScrollbar->width() : 0; 801 802 IntPoint maximumOffset(m_pdfDocumentSize.width() - m_size.width() + verticalScrollbarWidth, m_pdfDocumentSize.height() - m_size.height() + horizontalScrollbarHeight); 798 IntSize scrollbarSpace = scrollbarIntrusion(); 799 800 IntPoint maximumOffset(m_pdfDocumentSize.width() - m_size.width() + scrollbarSpace.width(), m_pdfDocumentSize.height() - m_size.height() + scrollbarSpace.height()); 803 801 maximumOffset.clampNegativeToZero(); 804 802 return maximumOffset;
Note: See TracChangeset
for help on using the changeset viewer.