| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 m_clipsRepaints = clipsRepaints; | 177 m_clipsRepaints = clipsRepaints; |
| 178 } | 178 } |
| 179 | 179 |
| 180 IntSize ScrollView::unscaledVisibleContentSize(IncludeScrollbarsInRect scrollbar
Inclusion) const | 180 IntSize ScrollView::unscaledVisibleContentSize(IncludeScrollbarsInRect scrollbar
Inclusion) const |
| 181 { | 181 { |
| 182 return scrollbarInclusion == ExcludeScrollbars ? excludeScrollbars(frameRect
().size()) : frameRect().size(); | 182 return scrollbarInclusion == ExcludeScrollbars ? excludeScrollbars(frameRect
().size()) : frameRect().size(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 IntSize ScrollView::excludeScrollbars(const IntSize& size) const | 185 IntSize ScrollView::excludeScrollbars(const IntSize& size) const |
| 186 { | 186 { |
| 187 int verticalScrollbarWidth = 0; | 187 // int verticalScrollbarWidth = 0; |
| 188 int horizontalScrollbarHeight = 0; | 188 int horizontalScrollbarHeight = 0; |
| 189 | 189 |
| 190 if (Scrollbar* verticalBar = verticalScrollbar()) | 190 // if (Scrollbar* verticalBar = verticalScrollbar()) |
| 191 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa
r->width() : 0; | 191 // verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBa
r->width() : 0; |
| 192 if (Scrollbar* horizontalBar = horizontalScrollbar()) | 192 if (Scrollbar* horizontalBar = horizontalScrollbar()) |
| 193 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz
ontalBar->height() : 0; | 193 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? horiz
ontalBar->height() : 0; |
| 194 | 194 |
| 195 return IntSize(max(0, size.width() - verticalScrollbarWidth), | 195 return IntSize(max(0, size.width()), |
| 196 max(0, size.height() - horizontalScrollbarHeight)); | 196 max(0, size.height() - horizontalScrollbarHeight)); |
| 197 | 197 |
| 198 } | 198 } |
| 199 | 199 |
| 200 IntRect ScrollView::visibleContentRect(IncludeScrollbarsInRect scollbarInclusion
) const | 200 IntRect ScrollView::visibleContentRect(IncludeScrollbarsInRect scollbarInclusion
) const |
| 201 { | 201 { |
| 202 FloatSize visibleContentSize = unscaledVisibleContentSize(scollbarInclusion)
; | 202 FloatSize visibleContentSize = unscaledVisibleContentSize(scollbarInclusion)
; |
| 203 visibleContentSize.scale(1 / visibleContentScaleFactor()); | 203 visibleContentSize.scale(1 / visibleContentScaleFactor()); |
| 204 return IntRect(IntPoint(m_scrollOffset), expandedIntSize(visibleContentSize)
); | 204 return IntRect(IntPoint(m_scrollOffset), expandedIntSize(visibleContentSize)
); |
| 205 } | 205 } |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 if (m_verticalScrollbar) | 491 if (m_verticalScrollbar) |
| 492 m_verticalScrollbar->offsetDidChange(); | 492 m_verticalScrollbar->offsetDidChange(); |
| 493 | 493 |
| 494 m_inUpdateScrollbars = false; | 494 m_inUpdateScrollbars = false; |
| 495 } | 495 } |
| 496 | 496 |
| 497 const int panIconSizeLength = 16; | 497 const int panIconSizeLength = 16; |
| 498 | 498 |
| 499 IntRect ScrollView::rectToCopyOnScroll() const | 499 IntRect ScrollView::rectToCopyOnScroll() const |
| 500 { | 500 { |
| 501 IntRect scrollViewRect = convertToRootView(IntRect((shouldPlaceVerticalScrol
lbarOnLeft() && verticalScrollbar()) ? verticalScrollbar()->width() : 0, 0, visi
bleWidth(), visibleHeight())); | 501 // IntRect scrollViewRect = convertToRootView(IntRect((shouldPlaceVerticalSc
rollbarOnLeft() && verticalScrollbar()) ? verticalScrollbar()->width() : 0, 0, v
isibleWidth(), visibleHeight())); |
| 502 IntRect scrollViewRect = convertToRootView(IntRect(0, 0, visibleWidth(), vis
ibleHeight())); |
| 502 if (hasOverlayScrollbars()) { | 503 if (hasOverlayScrollbars()) { |
| 503 int verticalScrollbarWidth = (verticalScrollbar() && !hasLayerForVertica
lScrollbar()) ? verticalScrollbar()->width() : 0; | 504 int verticalScrollbarWidth = (verticalScrollbar() && !hasLayerForVertica
lScrollbar()) ? verticalScrollbar()->width() : 0; |
| 504 int horizontalScrollbarHeight = (horizontalScrollbar() && !hasLayerForHo
rizontalScrollbar()) ? horizontalScrollbar()->height() : 0; | 505 int horizontalScrollbarHeight = (horizontalScrollbar() && !hasLayerForHo
rizontalScrollbar()) ? horizontalScrollbar()->height() : 0; |
| 505 | 506 |
| 506 scrollViewRect.setWidth(scrollViewRect.width() - verticalScrollbarWidth)
; | 507 scrollViewRect.setWidth(scrollViewRect.width() - verticalScrollbarWidth)
; |
| 507 scrollViewRect.setHeight(scrollViewRect.height() - horizontalScrollbarHe
ight); | 508 scrollViewRect.setHeight(scrollViewRect.height() - horizontalScrollbarHe
ight); |
| 508 } | 509 } |
| 509 return scrollViewRect; | 510 return scrollViewRect; |
| 510 } | 511 } |
| 511 | 512 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 } | 557 } |
| 557 | 558 |
| 558 void ScrollView::scrollContentsSlowPath(const IntRect& updateRect) | 559 void ScrollView::scrollContentsSlowPath(const IntRect& updateRect) |
| 559 { | 560 { |
| 560 hostWindow()->invalidateContentsForSlowScroll(updateRect); | 561 hostWindow()->invalidateContentsForSlowScroll(updateRect); |
| 561 } | 562 } |
| 562 | 563 |
| 563 IntPoint ScrollView::rootViewToContents(const IntPoint& rootViewPoint) const | 564 IntPoint ScrollView::rootViewToContents(const IntPoint& rootViewPoint) const |
| 564 { | 565 { |
| 565 IntPoint viewPoint = convertFromRootView(rootViewPoint); | 566 IntPoint viewPoint = convertFromRootView(rootViewPoint); |
| 567 viewPoint.move(-verticalScrollbarWidth(), 0); |
| 566 return viewPoint + scrollOffset(); | 568 return viewPoint + scrollOffset(); |
| 567 } | 569 } |
| 568 | 570 |
| 569 IntPoint ScrollView::contentsToRootView(const IntPoint& contentsPoint) const | 571 IntPoint ScrollView::contentsToRootView(const IntPoint& contentsPoint) const |
| 570 { | 572 { |
| 571 IntPoint viewPoint = contentsPoint - scrollOffset(); | 573 IntPoint viewPoint = contentsPoint - scrollOffset(); |
| 574 viewPoint.move(verticalScrollbarWidth(), 0); |
| 572 return convertToRootView(viewPoint); | 575 return convertToRootView(viewPoint); |
| 573 } | 576 } |
| 574 | 577 |
| 575 IntRect ScrollView::rootViewToContents(const IntRect& rootViewRect) const | 578 IntRect ScrollView::rootViewToContents(const IntRect& rootViewRect) const |
| 576 { | 579 { |
| 577 IntRect viewRect = convertFromRootView(rootViewRect); | 580 IntRect viewRect = convertFromRootView(rootViewRect); |
| 578 viewRect.move(scrollOffset()); | 581 viewRect.move(scrollOffset()); |
| 582 viewRect.move(-verticalScrollbarWidth(), 0); |
| 579 return viewRect; | 583 return viewRect; |
| 580 } | 584 } |
| 581 | 585 |
| 582 IntRect ScrollView::contentsToRootView(const IntRect& contentsRect) const | 586 IntRect ScrollView::contentsToRootView(const IntRect& contentsRect) const |
| 583 { | 587 { |
| 584 IntRect viewRect = contentsRect; | 588 IntRect viewRect = contentsRect; |
| 585 viewRect.move(-scrollOffset()); | 589 viewRect.move(-scrollOffset()); |
| 590 viewRect.move(verticalScrollbarWidth(), 0); |
| 586 return convertToRootView(viewRect); | 591 return convertToRootView(viewRect); |
| 587 } | 592 } |
| 588 | 593 |
| 589 IntPoint ScrollView::windowToContents(const IntPoint& windowPoint) const | 594 IntPoint ScrollView::windowToContents(const IntPoint& windowPoint) const |
| 590 { | 595 { |
| 591 IntPoint viewPoint = convertFromContainingWindow(windowPoint); | 596 IntPoint viewPoint = convertFromContainingWindow(windowPoint); |
| 597 viewPoint.move(-verticalScrollbarWidth(), 0); |
| 592 return viewPoint + scrollOffset(); | 598 return viewPoint + scrollOffset(); |
| 593 } | 599 } |
| 594 | 600 |
| 595 IntPoint ScrollView::contentsToWindow(const IntPoint& contentsPoint) const | 601 IntPoint ScrollView::contentsToWindow(const IntPoint& contentsPoint) const |
| 596 { | 602 { |
| 597 IntPoint viewPoint = contentsPoint - scrollOffset(); | 603 IntPoint viewPoint = contentsPoint - scrollOffset(); |
| 604 viewPoint.move(verticalScrollbarWidth(), 0); |
| 598 return convertToContainingWindow(viewPoint); | 605 return convertToContainingWindow(viewPoint); |
| 599 } | 606 } |
| 600 | 607 |
| 601 IntRect ScrollView::windowToContents(const IntRect& windowRect) const | 608 IntRect ScrollView::windowToContents(const IntRect& windowRect) const |
| 602 { | 609 { |
| 603 IntRect viewRect = convertFromContainingWindow(windowRect); | 610 IntRect viewRect = convertFromContainingWindow(windowRect); |
| 604 viewRect.move(scrollOffset()); | 611 viewRect.move(scrollOffset()); |
| 612 viewRect.move(-verticalScrollbarWidth(), 0); |
| 605 return viewRect; | 613 return viewRect; |
| 606 } | 614 } |
| 607 | 615 |
| 608 IntRect ScrollView::contentsToWindow(const IntRect& contentsRect) const | 616 IntRect ScrollView::contentsToWindow(const IntRect& contentsRect) const |
| 609 { | 617 { |
| 610 IntRect viewRect = contentsRect; | 618 IntRect viewRect = contentsRect; |
| 611 viewRect.move(-scrollOffset()); | 619 viewRect.move(-scrollOffset()); |
| 620 viewRect.move(verticalScrollbarWidth(), 0); |
| 612 return convertToContainingWindow(viewRect); | 621 return convertToContainingWindow(viewRect); |
| 613 } | 622 } |
| 614 | 623 |
| 615 IntRect ScrollView::contentsToScreen(const IntRect& rect) const | 624 IntRect ScrollView::contentsToScreen(const IntRect& rect) const |
| 616 { | 625 { |
| 617 HostWindow* window = hostWindow(); | 626 HostWindow* window = hostWindow(); |
| 618 if (!window) | 627 if (!window) |
| 619 return IntRect(); | 628 return IntRect(); |
| 620 return window->rootViewToScreen(contentsToRootView(rect)); | 629 return window->rootViewToScreen(contentsToRootView(rect)); |
| 621 } | 630 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 bool ScrollView::userInputScrollable(ScrollbarOrientation orientation) const | 771 bool ScrollView::userInputScrollable(ScrollbarOrientation orientation) const |
| 763 { | 772 { |
| 764 ScrollbarMode mode = (orientation == HorizontalScrollbar) ? | 773 ScrollbarMode mode = (orientation == HorizontalScrollbar) ? |
| 765 m_horizontalScrollbarMode : m_verticalScrollbarMode; | 774 m_horizontalScrollbarMode : m_verticalScrollbarMode; |
| 766 | 775 |
| 767 return mode == ScrollbarAuto || mode == ScrollbarAlwaysOn; | 776 return mode == ScrollbarAuto || mode == ScrollbarAlwaysOn; |
| 768 } | 777 } |
| 769 | 778 |
| 770 bool ScrollView::shouldPlaceVerticalScrollbarOnLeft() const | 779 bool ScrollView::shouldPlaceVerticalScrollbarOnLeft() const |
| 771 { | 780 { |
| 772 return false; | 781 return true; |
| 773 } | 782 } |
| 774 | 783 |
| 775 void ScrollView::repaintContentRectangle(const IntRect& rect) | 784 void ScrollView::repaintContentRectangle(const IntRect& rect) |
| 776 { | 785 { |
| 777 IntRect paintRect = rect; | 786 IntRect paintRect = rect; |
| 778 if (clipsRepaints() && !paintsEntireContents()) | 787 if (clipsRepaints() && !paintsEntireContents()) |
| 779 paintRect.intersect(visibleContentRect()); | 788 paintRect.intersect(visibleContentRect()); |
| 780 if (paintRect.isEmpty()) | 789 if (paintRect.isEmpty()) |
| 781 return; | 790 return; |
| 782 | 791 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 } | 873 } |
| 865 | 874 |
| 866 void ScrollView::paint(GraphicsContext* context, const IntRect& rect) | 875 void ScrollView::paint(GraphicsContext* context, const IntRect& rect) |
| 867 { | 876 { |
| 868 if (context->paintingDisabled() && !context->updatingControlTints()) | 877 if (context->paintingDisabled() && !context->updatingControlTints()) |
| 869 return; | 878 return; |
| 870 | 879 |
| 871 notifyPageThatContentAreaWillPaint(); | 880 notifyPageThatContentAreaWillPaint(); |
| 872 | 881 |
| 873 IntRect documentDirtyRect = rect; | 882 IntRect documentDirtyRect = rect; |
| 883 documentDirtyRect.move(-verticalScrollbarWidth(), 0); |
| 884 documentDirtyRect.setWidth(rect.width() + 2*verticalScrollbarWidth()); |
| 874 if (!paintsEntireContents()) { | 885 if (!paintsEntireContents()) { |
| 875 IntRect visibleAreaWithoutScrollbars(location(), visibleContentRect().si
ze()); | 886 IntRect visibleAreaWithoutScrollbars(location(), visibleContentRect().si
ze()); |
| 876 documentDirtyRect.intersect(visibleAreaWithoutScrollbars); | 887 documentDirtyRect.intersect(visibleAreaWithoutScrollbars); |
| 877 } | 888 } |
| 878 | 889 |
| 879 if (!documentDirtyRect.isEmpty()) { | 890 if (!documentDirtyRect.isEmpty()) { |
| 880 GraphicsContextStateSaver stateSaver(*context); | 891 GraphicsContextStateSaver stateSaver(*context); |
| 881 | 892 |
| 882 context->translate(x(), y()); | 893 context->translate(x() + verticalScrollbarWidth(), y()); |
| 883 documentDirtyRect.moveBy(-location()); | 894 documentDirtyRect.moveBy(-location()); |
| 884 | 895 |
| 885 if (!paintsEntireContents()) { | 896 if (!paintsEntireContents()) { |
| 886 context->translate(-scrollX(), -scrollY()); | 897 context->translate(-scrollX(), -scrollY()); |
| 887 documentDirtyRect.moveBy(scrollPosition()); | 898 documentDirtyRect.moveBy(scrollPosition()); |
| 888 | 899 |
| 889 context->clip(visibleContentRect()); | 900 context->clip(visibleContentRect()); |
| 890 } | 901 } |
| 891 | 902 |
| 892 paintContents(context, documentDirtyRect); | 903 paintContents(context, documentDirtyRect); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 int ScrollView::pageStep(ScrollbarOrientation orientation) const | 1148 int ScrollView::pageStep(ScrollbarOrientation orientation) const |
| 1138 { | 1149 { |
| 1139 int length = (orientation == HorizontalScrollbar) ? visibleWidth() : visible
Height(); | 1150 int length = (orientation == HorizontalScrollbar) ? visibleWidth() : visible
Height(); |
| 1140 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging()
; | 1151 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging()
; |
| 1141 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); | 1152 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); |
| 1142 | 1153 |
| 1143 return std::max(pageStep, 1); | 1154 return std::max(pageStep, 1); |
| 1144 } | 1155 } |
| 1145 | 1156 |
| 1146 } // namespace WebCore | 1157 } // namespace WebCore |
| OLD | NEW |