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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2514003002: [DO NOT SUBMIT] Testing a reverted CL to see if changes catch regression. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 if (!scrollbar) 437 if (!scrollbar)
438 return; 438 return;
439 439
440 m_scrollableArea->willRemoveScrollbar(*scrollbar, orientation); 440 m_scrollableArea->willRemoveScrollbar(*scrollbar, orientation);
441 m_scrollableArea->layoutBox()->document().view()->removeChild( 441 m_scrollableArea->layoutBox()->document().view()->removeChild(
442 scrollbar.get()); 442 scrollbar.get());
443 scrollbar->disconnectFromScrollableArea(); 443 scrollbar->disconnectFromScrollableArea();
444 scrollbar = nullptr; 444 scrollbar = nullptr;
445 } 445 }
446 446
447 ScrollableArea* FrameView::ScrollbarManager::scrollableArea() const {
448 return m_scrollableArea.get();
449 }
450
451 void FrameView::ScrollbarManager::updateScrollbarGeometry(IntSize viewSize) {
452 if (!hasHorizontalScrollbar() && !hasVerticalScrollbar())
453 return;
454
455 bool scrollbarOnLeft = m_scrollableArea->shouldPlaceVerticalScrollbarOnLeft();
456
457 if (hasHorizontalScrollbar()) {
458 int thickness = m_hBar->scrollbarThickness();
459 IntRect oldRect(m_hBar->frameRect());
460 IntRect hBarRect(
461 (scrollbarOnLeft && hasVerticalScrollbar()) ? m_vBar->width() : 0,
462 viewSize.height() - thickness,
463 viewSize.width() - (hasVerticalScrollbar() ? m_vBar->width() : 0),
464 thickness);
465 m_hBar->setFrameRect(hBarRect);
466 if (oldRect != m_hBar->frameRect())
467 m_scrollableArea->setScrollbarNeedsPaintInvalidation(HorizontalScrollbar);
468
469 int visibleWidth = m_scrollableArea->visibleWidth();
470 int contentsWidth = m_scrollableArea->contentsSize().width();
471 m_hBar->setEnabled(contentsWidth > visibleWidth &&
472 !m_scrollableArea->scrollbarsHidden());
473 m_hBar->setProportion(visibleWidth, contentsWidth);
474 m_hBar->offsetDidChange();
475 }
476
477 if (hasVerticalScrollbar()) {
478 int thickness = m_vBar->scrollbarThickness();
479 IntRect oldRect(m_vBar->frameRect());
480 IntRect vBarRect(
481 scrollbarOnLeft ? 0 : (viewSize.width() - thickness), 0, thickness,
482 viewSize.height() - (hasHorizontalScrollbar() ? m_hBar->height() : 0));
483 m_vBar->setFrameRect(vBarRect);
484 if (oldRect != m_vBar->frameRect())
485 m_scrollableArea->setScrollbarNeedsPaintInvalidation(VerticalScrollbar);
486
487 int clientHeight = m_scrollableArea->visibleHeight();
488 int contentsHeight = m_scrollableArea->contentsSize().height();
489 m_vBar->setEnabled(contentsHeight > clientHeight &&
490 !m_scrollableArea->scrollbarsHidden());
491 m_vBar->setProportion(clientHeight, contentsHeight);
492 m_vBar->offsetDidChange();
493 }
494 }
495
447 void FrameView::recalculateCustomScrollbarStyle() { 496 void FrameView::recalculateCustomScrollbarStyle() {
448 bool didStyleChange = false; 497 bool didStyleChange = false;
449 if (horizontalScrollbar() && horizontalScrollbar()->isCustomScrollbar()) { 498 if (horizontalScrollbar() && horizontalScrollbar()->isCustomScrollbar()) {
450 horizontalScrollbar()->styleChanged(); 499 horizontalScrollbar()->styleChanged();
451 didStyleChange = true; 500 didStyleChange = true;
452 } 501 }
453 if (verticalScrollbar() && verticalScrollbar()->isCustomScrollbar()) { 502 if (verticalScrollbar() && verticalScrollbar()->isCustomScrollbar()) {
454 verticalScrollbar()->styleChanged(); 503 verticalScrollbar()->styleChanged();
455 didStyleChange = true; 504 didStyleChange = true;
456 } 505 }
457 if (didStyleChange) { 506 if (didStyleChange) {
458 updateScrollbarGeometry(); 507 m_scrollbarManager.updateScrollbarGeometry(size());
459 updateScrollCorner(); 508 updateScrollCorner();
460 positionScrollbarLayers(); 509 positionScrollbarLayers();
461 } 510 }
462 } 511 }
463 512
464 void FrameView::invalidateAllCustomScrollbarsOnActiveChanged() { 513 void FrameView::invalidateAllCustomScrollbarsOnActiveChanged() {
465 bool usesWindowInactiveSelector = 514 bool usesWindowInactiveSelector =
466 m_frame->document()->styleEngine().usesWindowInactiveSelector(); 515 m_frame->document()->styleEngine().usesWindowInactiveSelector();
467 516
468 const ChildrenWidgetSet* viewChildren = children(); 517 const ChildrenWidgetSet* viewChildren = children();
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 850
802 bool hasHorizontalScrollbar = horizontalScrollbar(); 851 bool hasHorizontalScrollbar = horizontalScrollbar();
803 bool hasVerticalScrollbar = verticalScrollbar(); 852 bool hasVerticalScrollbar = verticalScrollbar();
804 if (hasHorizontalScrollbar != shouldHaveHorizontalScrollbar || 853 if (hasHorizontalScrollbar != shouldHaveHorizontalScrollbar ||
805 hasVerticalScrollbar != shouldHaveVerticalScrollbar) { 854 hasVerticalScrollbar != shouldHaveVerticalScrollbar) {
806 setNeedsLayout(); 855 setNeedsLayout();
807 return; 856 return;
808 } 857 }
809 858
810 adjustViewSize(); 859 adjustViewSize();
811 updateScrollbarGeometry(); 860 m_scrollbarManager.updateScrollbarGeometry(size());
812 861
813 if (scrollOriginChanged()) 862 if (scrollOriginChanged())
814 setNeedsLayout(); 863 setNeedsLayout();
815 } 864 }
816 865
817 bool FrameView::usesCompositedScrolling() const { 866 bool FrameView::usesCompositedScrolling() const {
818 LayoutViewItem layoutView = this->layoutViewItem(); 867 LayoutViewItem layoutView = this->layoutViewItem();
819 if (layoutView.isNull()) 868 if (layoutView.isNull())
820 return false; 869 return false;
821 if (m_frame->settings() && 870 if (m_frame->settings() &&
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 2468
2420 return ScrollableArea::shouldUseIntegerScrollOffset(); 2469 return ScrollableArea::shouldUseIntegerScrollOffset();
2421 } 2470 }
2422 2471
2423 bool FrameView::isActive() const { 2472 bool FrameView::isActive() const {
2424 Page* page = frame().page(); 2473 Page* page = frame().page();
2425 return page && page->focusController().isActive(); 2474 return page && page->focusController().isActive();
2426 } 2475 }
2427 2476
2428 void FrameView::invalidatePaintForTickmarks() { 2477 void FrameView::invalidatePaintForTickmarks() {
2429 if (Scrollbar* scrollbar = verticalScrollbar()) 2478 if (Scrollbar* scrollbar = getScrollableArea()->verticalScrollbar())
2430 scrollbar->setNeedsPaintInvalidation( 2479 scrollbar->setNeedsPaintInvalidation(
2431 static_cast<ScrollbarPart>(~ThumbPart)); 2480 static_cast<ScrollbarPart>(~ThumbPart));
2432 } 2481 }
2433 2482
2434 void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const { 2483 void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const {
2435 if (!m_tickmarks.isEmpty()) 2484 if (!m_tickmarks.isEmpty())
2436 tickmarks = m_tickmarks; 2485 tickmarks = m_tickmarks;
2437 else 2486 else
2438 tickmarks = frame().document()->markers().renderedRectsForMarkers( 2487 tickmarks = frame().document()->markers().renderedRectsForMarkers(
2439 DocumentMarker::TextMatch); 2488 DocumentMarker::TextMatch);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
2587 2636
2588 if (m_frame->isMainFrame()) { 2637 if (m_frame->isMainFrame()) {
2589 ScrollableArea& visualViewport = frameHost->visualViewport(); 2638 ScrollableArea& visualViewport = frameHost->visualViewport();
2590 ScrollableArea* layoutViewport = layoutViewportScrollableArea(); 2639 ScrollableArea* layoutViewport = layoutViewportScrollableArea();
2591 DCHECK(layoutViewport); 2640 DCHECK(layoutViewport);
2592 2641
2593 RootFrameViewport* rootFrameViewport = 2642 RootFrameViewport* rootFrameViewport =
2594 RootFrameViewport::create(visualViewport, *layoutViewport); 2643 RootFrameViewport::create(visualViewport, *layoutViewport);
2595 m_viewportScrollableArea = rootFrameViewport; 2644 m_viewportScrollableArea = rootFrameViewport;
2596 2645
2646 // TODO(crbug.com/661236): Currently for the main frame, the scroller that
2647 // the scrollbar manager works with is RootFrameViewport which is needed so
2648 // that the visual viewport is taken into account when determining scrollbar
2649 // extent and existence. Eventually, each scroller should have its own
2650 // scrollbar manager and we shouldn't set the scroller here.
2651 m_scrollbarManager.setScroller(rootFrameViewport);
2652
2597 frameHost->globalRootScrollerController().initializeViewportScrollCallback( 2653 frameHost->globalRootScrollerController().initializeViewportScrollCallback(
2598 *rootFrameViewport); 2654 *rootFrameViewport);
2599 } 2655 }
2600 } 2656 }
2601 2657
2602 void FrameView::updateScrollCorner() { 2658 void FrameView::updateScrollCorner() {
2603 RefPtr<ComputedStyle> cornerStyle; 2659 RefPtr<ComputedStyle> cornerStyle;
2604 IntRect cornerRect = scrollCornerRect(); 2660 IntRect cornerRect = scrollCornerRect();
2605 Document* doc = m_frame->document(); 2661 Document* doc = m_frame->document();
2606 2662
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
3725 setNeedsPaintPropertyUpdate(); 3781 setNeedsPaintPropertyUpdate();
3726 } 3782 }
3727 } 3783 }
3728 3784
3729 void FrameView::clearScrollAnchor() { 3785 void FrameView::clearScrollAnchor() {
3730 if (!RuntimeEnabledFeatures::scrollAnchoringEnabled()) 3786 if (!RuntimeEnabledFeatures::scrollAnchoringEnabled())
3731 return; 3787 return;
3732 m_scrollAnchor.clear(); 3788 m_scrollAnchor.clear();
3733 } 3789 }
3734 3790
3735 bool FrameView::hasOverlayScrollbars() const {
3736 return (horizontalScrollbar() &&
3737 horizontalScrollbar()->isOverlayScrollbar()) ||
3738 (verticalScrollbar() && verticalScrollbar()->isOverlayScrollbar());
3739 }
3740
3741 void FrameView::computeScrollbarExistence( 3791 void FrameView::computeScrollbarExistence(
3742 bool& newHasHorizontalScrollbar, 3792 bool& newHasHorizontalScrollbar,
3743 bool& newHasVerticalScrollbar, 3793 bool& newHasVerticalScrollbar,
3744 const IntSize& docSize, 3794 const IntSize& docSize,
3745 ComputeScrollbarExistenceOption option) const { 3795 ComputeScrollbarExistenceOption option) const {
3746 if (m_frame->settings() && m_frame->settings()->hideScrollbars()) { 3796 if (m_frame->settings() && m_frame->settings()->hideScrollbars()) {
3747 newHasHorizontalScrollbar = false; 3797 newHasHorizontalScrollbar = false;
3748 newHasVerticalScrollbar = false; 3798 newHasVerticalScrollbar = false;
3749 return; 3799 return;
3750 } 3800 }
(...skipping 12 matching lines...) Expand all
3763 3813
3764 if (hScroll != ScrollbarAuto) 3814 if (hScroll != ScrollbarAuto)
3765 newHasHorizontalScrollbar = (hScroll == ScrollbarAlwaysOn); 3815 newHasHorizontalScrollbar = (hScroll == ScrollbarAlwaysOn);
3766 if (vScroll != ScrollbarAuto) 3816 if (vScroll != ScrollbarAuto)
3767 newHasVerticalScrollbar = (vScroll == ScrollbarAlwaysOn); 3817 newHasVerticalScrollbar = (vScroll == ScrollbarAlwaysOn);
3768 3818
3769 if (m_scrollbarsSuppressed || 3819 if (m_scrollbarsSuppressed ||
3770 (hScroll != ScrollbarAuto && vScroll != ScrollbarAuto)) 3820 (hScroll != ScrollbarAuto && vScroll != ScrollbarAuto))
3771 return; 3821 return;
3772 3822
3823 ScrollableArea* scroller = m_scrollbarManager.scrollableArea();
3773 if (hScroll == ScrollbarAuto) 3824 if (hScroll == ScrollbarAuto)
3774 newHasHorizontalScrollbar = docSize.width() > visibleWidth(); 3825 newHasHorizontalScrollbar = docSize.width() > scroller->visibleWidth();
3775 if (vScroll == ScrollbarAuto) 3826 if (vScroll == ScrollbarAuto)
3776 newHasVerticalScrollbar = docSize.height() > visibleHeight(); 3827 newHasVerticalScrollbar = docSize.height() > scroller->visibleHeight();
3777 3828
3778 if (hasOverlayScrollbars()) 3829 if (hasOverlayScrollbars())
3779 return; 3830 return;
3780 3831
3781 IntSize fullVisibleSize = visibleContentRect(IncludeScrollbars).size(); 3832 IntSize fullVisibleSize =
3833 scroller->visibleContentRect(IncludeScrollbars).size();
3782 3834
3783 bool attemptToRemoveScrollbars = 3835 bool attemptToRemoveScrollbars =
3784 (option == FirstPass && docSize.width() <= fullVisibleSize.width() && 3836 (option == FirstPass && docSize.width() <= fullVisibleSize.width() &&
3785 docSize.height() <= fullVisibleSize.height()); 3837 docSize.height() <= fullVisibleSize.height());
3786 if (attemptToRemoveScrollbars) { 3838 if (attemptToRemoveScrollbars) {
3787 if (hScroll == ScrollbarAuto) 3839 if (hScroll == ScrollbarAuto)
3788 newHasHorizontalScrollbar = false; 3840 newHasHorizontalScrollbar = false;
3789 if (vScroll == ScrollbarAuto) 3841 if (vScroll == ScrollbarAuto)
3790 newHasVerticalScrollbar = false; 3842 newHasVerticalScrollbar = false;
3791 } 3843 }
3792 } 3844 }
3793 3845
3794 void FrameView::updateScrollbarGeometry() {
3795 if (horizontalScrollbar()) {
3796 int thickness = horizontalScrollbar()->scrollbarThickness();
3797 int clientWidth = visibleWidth();
3798 IntRect oldRect(horizontalScrollbar()->frameRect());
3799 IntRect hBarRect(
3800 (shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar())
3801 ? verticalScrollbar()->width()
3802 : 0,
3803 height() - thickness,
3804 width() - (verticalScrollbar() ? verticalScrollbar()->width() : 0),
3805 thickness);
3806 horizontalScrollbar()->setFrameRect(hBarRect);
3807 if (oldRect != horizontalScrollbar()->frameRect())
3808 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar);
3809
3810 horizontalScrollbar()->setEnabled(contentsWidth() > clientWidth);
3811 horizontalScrollbar()->setProportion(clientWidth, contentsWidth());
3812 horizontalScrollbar()->offsetDidChange();
3813 }
3814
3815 if (verticalScrollbar()) {
3816 int thickness = verticalScrollbar()->scrollbarThickness();
3817 int clientHeight = visibleHeight();
3818 IntRect oldRect(verticalScrollbar()->frameRect());
3819 IntRect vBarRect(
3820 shouldPlaceVerticalScrollbarOnLeft() ? 0 : (width() - thickness), 0,
3821 thickness,
3822 height() -
3823 (horizontalScrollbar() ? horizontalScrollbar()->height() : 0));
3824 verticalScrollbar()->setFrameRect(vBarRect);
3825 if (oldRect != verticalScrollbar()->frameRect())
3826 setScrollbarNeedsPaintInvalidation(VerticalScrollbar);
3827
3828 verticalScrollbar()->setEnabled(contentsHeight() > clientHeight);
3829 verticalScrollbar()->setProportion(clientHeight, contentsHeight());
3830 verticalScrollbar()->offsetDidChange();
3831 }
3832 }
3833
3834 bool FrameView::adjustScrollbarExistence( 3846 bool FrameView::adjustScrollbarExistence(
3835 ComputeScrollbarExistenceOption option) { 3847 ComputeScrollbarExistenceOption option) {
3836 ASSERT(m_inUpdateScrollbars); 3848 ASSERT(m_inUpdateScrollbars);
3837 3849
3838 // If we came in here with the view already needing a layout, then go ahead 3850 // If we came in here with the view already needing a layout, then go ahead
3839 // and do that first. (This will be the common case, e.g., when the page 3851 // and do that first. (This will be the common case, e.g., when the page
3840 // changes due to window resizing for example). This layout will not re-enter 3852 // changes due to window resizing for example). This layout will not re-enter
3841 // updateScrollbars and does not count towards our max layout pass total. 3853 // updateScrollbars and does not count towards our max layout pass total.
3842 if (!m_scrollbarsSuppressed) 3854 if (!m_scrollbarsSuppressed)
3843 scrollbarExistenceDidChange(); 3855 scrollbarExistenceDidChange();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3922 int maxUpdateScrollbarsPass = 3934 int maxUpdateScrollbarsPass =
3923 hasOverlayScrollbars() || m_scrollbarsSuppressed ? 1 : 3; 3935 hasOverlayScrollbars() || m_scrollbarsSuppressed ? 1 : 3;
3924 for (int updateScrollbarsPass = 0; 3936 for (int updateScrollbarsPass = 0;
3925 updateScrollbarsPass < maxUpdateScrollbarsPass; updateScrollbarsPass++) { 3937 updateScrollbarsPass < maxUpdateScrollbarsPass; updateScrollbarsPass++) {
3926 if (!adjustScrollbarExistence(updateScrollbarsPass ? Incremental 3938 if (!adjustScrollbarExistence(updateScrollbarsPass ? Incremental
3927 : FirstPass)) 3939 : FirstPass))
3928 break; 3940 break;
3929 scrollbarExistenceChanged = true; 3941 scrollbarExistenceChanged = true;
3930 } 3942 }
3931 3943
3932 updateScrollbarGeometry(); 3944 m_scrollbarManager.updateScrollbarGeometry(size());
3933 3945
3934 if (scrollbarExistenceChanged) { 3946 if (scrollbarExistenceChanged) {
3935 // FIXME: Is frameRectsChanged really necessary here? Have any frame rects 3947 // FIXME: Is frameRectsChanged really necessary here? Have any frame rects
3936 // changed? 3948 // changed?
3937 frameRectsChanged(); 3949 frameRectsChanged();
3938 positionScrollbarLayers(); 3950 positionScrollbarLayers();
3939 updateScrollCorner(); 3951 updateScrollCorner();
3940 } 3952 }
3941 3953
3942 adjustScrollOffsetFromUpdateScrollbars(); 3954 adjustScrollOffsetFromUpdateScrollbars();
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
4580 DCHECK(m_frame->isMainFrame()); 4592 DCHECK(m_frame->isMainFrame());
4581 return m_initialViewportSize.width(); 4593 return m_initialViewportSize.width();
4582 } 4594 }
4583 4595
4584 int FrameView::initialViewportHeight() const { 4596 int FrameView::initialViewportHeight() const {
4585 DCHECK(m_frame->isMainFrame()); 4597 DCHECK(m_frame->isMainFrame());
4586 return m_initialViewportSize.height(); 4598 return m_initialViewportSize.height();
4587 } 4599 }
4588 4600
4589 } // namespace blink 4601 } // namespace blink
OLDNEW
« 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