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

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

Issue 1093383003: Remove mainthread overhang painting code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/loader/EmptyClients.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 return Scrollbar::create(this, orientation, RegularScrollbar); 494 return Scrollbar::create(this, orientation, RegularScrollbar);
495 } 495 }
496 496
497 void FrameView::setContentsSize(const IntSize& size) 497 void FrameView::setContentsSize(const IntSize& size)
498 { 498 {
499 if (size == contentsSize()) 499 if (size == contentsSize())
500 return; 500 return;
501 501
502 m_contentsSize = size; 502 m_contentsSize = size;
503 updateScrollbars(scrollOffsetDouble()); 503 updateScrollbars(scrollOffsetDouble());
504 updateOverhangAreas();
505 ScrollableArea::contentsResized(); 504 ScrollableArea::contentsResized();
506 505
507 Page* page = frame().page(); 506 Page* page = frame().page();
508 if (!page) 507 if (!page)
509 return; 508 return;
510 509
511 updateScrollableAreaSet(); 510 updateScrollableAreaSet();
512 511
513 page->chrome().contentsSizeChanged(m_frame.get(), size); 512 page->chrome().contentsSizeChanged(m_frame.get(), size);
514 } 513 }
(...skipping 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after
3268 } 3267 }
3269 3268
3270 bool FrameView::scroll(ScrollDirection direction, ScrollGranularity granularity) 3269 bool FrameView::scroll(ScrollDirection direction, ScrollGranularity granularity)
3271 { 3270 {
3272 ScrollDirection physicalDirection = 3271 ScrollDirection physicalDirection =
3273 toPhysicalDirection(direction, isVerticalDocument(), isFlippedDocument() ); 3272 toPhysicalDirection(direction, isVerticalDocument(), isFlippedDocument() );
3274 3273
3275 return ScrollableArea::scroll(physicalDirection, granularity); 3274 return ScrollableArea::scroll(physicalDirection, granularity);
3276 } 3275 }
3277 3276
3278 IntSize FrameView::overhangAmount() const
3279 {
3280 IntSize stretch;
3281
3282 IntPoint currentScrollPosition = scrollPosition();
3283 IntPoint minScrollPosition = minimumScrollPosition();
3284 IntPoint maxScrollPosition = maximumScrollPosition();
3285
3286 if (currentScrollPosition.x() < minScrollPosition.x())
3287 stretch.setWidth(currentScrollPosition.x() - minScrollPosition.x());
3288 if (currentScrollPosition.x() > maxScrollPosition.x())
3289 stretch.setWidth(currentScrollPosition.x() - maxScrollPosition.x());
3290
3291 if (currentScrollPosition.y() < minScrollPosition.y())
3292 stretch.setHeight(currentScrollPosition.y() - minScrollPosition.y());
3293 if (currentScrollPosition.y() > maxScrollPosition.y())
3294 stretch.setHeight(currentScrollPosition.y() - maxScrollPosition.y());
3295
3296 return stretch;
3297 }
3298
3299 void FrameView::windowResizerRectChanged() 3277 void FrameView::windowResizerRectChanged()
3300 { 3278 {
3301 updateScrollbars(scrollOffsetDouble()); 3279 updateScrollbars(scrollOffsetDouble());
3302 } 3280 }
3303 3281
3304 bool FrameView::hasOverlayScrollbars() const 3282 bool FrameView::hasOverlayScrollbars() const
3305 { 3283 {
3306 3284
3307 return (m_horizontalScrollbar && m_horizontalScrollbar->isOverlayScrollbar() ) 3285 return (m_horizontalScrollbar && m_horizontalScrollbar->isOverlayScrollbar() )
3308 || (m_verticalScrollbar && m_verticalScrollbar->isOverlayScrollbar()); 3286 || (m_verticalScrollbar && m_verticalScrollbar->isOverlayScrollbar());
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
3581 int panIconDirtySquareSizeLength = 2 * (panIconSizeLength + std::max(abs (scrollDelta.width()), abs(scrollDelta.height()))); // We only want to repaint w hat's necessary 3559 int panIconDirtySquareSizeLength = 2 * (panIconSizeLength + std::max(abs (scrollDelta.width()), abs(scrollDelta.height()))); // We only want to repaint w hat's necessary
3582 IntPoint panIconDirtySquareLocation = IntPoint(m_panScrollIconPoint.x() - (panIconDirtySquareSizeLength / 2), m_panScrollIconPoint.y() - (panIconDirtySq uareSizeLength / 2)); 3560 IntPoint panIconDirtySquareLocation = IntPoint(m_panScrollIconPoint.x() - (panIconDirtySquareSizeLength / 2), m_panScrollIconPoint.y() - (panIconDirtySq uareSizeLength / 2));
3583 IntRect panScrollIconDirtyRect = IntRect(panIconDirtySquareLocation, Int Size(panIconDirtySquareSizeLength, panIconDirtySquareSizeLength)); 3561 IntRect panScrollIconDirtyRect = IntRect(panIconDirtySquareLocation, Int Size(panIconDirtySquareSizeLength, panIconDirtySquareSizeLength));
3584 panScrollIconDirtyRect.intersect(clipRect); 3562 panScrollIconDirtyRect.intersect(clipRect);
3585 window->invalidateRect(panScrollIconDirtyRect); 3563 window->invalidateRect(panScrollIconDirtyRect);
3586 } 3564 }
3587 3565
3588 if (!scrollContentsFastPath(-scrollDelta)) 3566 if (!scrollContentsFastPath(-scrollDelta))
3589 scrollContentsSlowPath(updateRect); 3567 scrollContentsSlowPath(updateRect);
3590 3568
3591 // Invalidate the overhang areas if they are visible.
3592 updateOverhangAreas();
3593
3594 // This call will move children with native widgets (plugins) and invalidate them as well. 3569 // This call will move children with native widgets (plugins) and invalidate them as well.
3595 frameRectsChanged(); 3570 frameRectsChanged();
3596 } 3571 }
3597 3572
3598 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const 3573 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const
3599 { 3574 {
3600 return pointInContentSpace - scrollOffset(); 3575 return pointInContentSpace - scrollOffset();
3601 } 3576 }
3602 3577
3603 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const 3578 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
3860 void FrameView::paint(GraphicsContext* context, const IntRect& rect) 3835 void FrameView::paint(GraphicsContext* context, const IntRect& rect)
3861 { 3836 {
3862 FramePainter(*this).paint(context, rect); 3837 FramePainter(*this).paint(context, rect);
3863 } 3838 }
3864 3839
3865 void FrameView::paintContents(GraphicsContext* context, const IntRect& damageRec t) 3840 void FrameView::paintContents(GraphicsContext* context, const IntRect& damageRec t)
3866 { 3841 {
3867 FramePainter(*this).paintContents(context, damageRect); 3842 FramePainter(*this).paintContents(context, damageRect);
3868 } 3843 }
3869 3844
3870 void FrameView::calculateOverhangAreasForPainting(IntRect& horizontalOverhangRec t, IntRect& verticalOverhangRect)
3871 {
3872 int verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->i sOverlayScrollbar())
3873 ? verticalScrollbar()->width() : 0;
3874 int horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollb ar()->isOverlayScrollbar())
3875 ? horizontalScrollbar()->height() : 0;
3876
3877 int physicalScrollY = scrollPosition().y() + scrollOrigin().y();
3878 if (physicalScrollY < 0) {
3879 horizontalOverhangRect = frameRect();
3880 horizontalOverhangRect.setHeight(-physicalScrollY);
3881 horizontalOverhangRect.setWidth(horizontalOverhangRect.width() - vertica lScrollbarWidth);
3882 } else if (physicalScrollY > 0 && contentsHeight() && physicalScrollY > cont entsHeight() - visibleHeight()) {
3883 int height = physicalScrollY - (contentsHeight() - visibleHeight());
3884 horizontalOverhangRect = frameRect();
3885 horizontalOverhangRect.setY(frameRect().maxY() - height - horizontalScro llbarHeight);
3886 horizontalOverhangRect.setHeight(height);
3887 horizontalOverhangRect.setWidth(horizontalOverhangRect.width() - vertica lScrollbarWidth);
3888 }
3889
3890 int physicalScrollX = scrollPosition().x() + scrollOrigin().x();
3891 if (physicalScrollX < 0) {
3892 verticalOverhangRect.setWidth(-physicalScrollX);
3893 verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhang Rect.height() - horizontalScrollbarHeight);
3894 verticalOverhangRect.setX(frameRect().x());
3895 if (horizontalOverhangRect.y() == frameRect().y())
3896 verticalOverhangRect.setY(frameRect().y() + horizontalOverhangRect.h eight());
3897 else
3898 verticalOverhangRect.setY(frameRect().y());
3899 } else if (physicalScrollX > 0 && contentsWidth() && physicalScrollX > conte ntsWidth() - visibleWidth()) {
3900 int width = physicalScrollX - (contentsWidth() - visibleWidth());
3901 verticalOverhangRect.setWidth(width);
3902 verticalOverhangRect.setHeight(frameRect().height() - horizontalOverhang Rect.height() - horizontalScrollbarHeight);
3903 verticalOverhangRect.setX(frameRect().maxX() - width - verticalScrollbar Width);
3904 if (horizontalOverhangRect.y() == frameRect().y())
3905 verticalOverhangRect.setY(frameRect().y() + horizontalOverhangRect.h eight());
3906 else
3907 verticalOverhangRect.setY(frameRect().y());
3908 }
3909 }
3910
3911 void FrameView::updateOverhangAreas()
3912 {
3913 HostWindow* window = hostWindow();
3914 if (!window)
3915 return;
3916
3917 TRACE_EVENT0("blink", "FrameView::updateOverhangAreas");
3918
3919 IntRect horizontalOverhangRect;
3920 IntRect verticalOverhangRect;
3921 calculateOverhangAreasForPainting(horizontalOverhangRect, verticalOverhangRe ct);
3922 if (!horizontalOverhangRect.isEmpty())
3923 window->invalidateRect(horizontalOverhangRect);
3924 if (!verticalOverhangRect.isEmpty())
3925 window->invalidateRect(verticalOverhangRect);
3926 }
3927
3928 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint) 3845 bool FrameView::isPointInScrollbarCorner(const IntPoint& windowPoint)
3929 { 3846 {
3930 if (!scrollbarCornerPresent()) 3847 if (!scrollbarCornerPresent())
3931 return false; 3848 return false;
3932 3849
3933 IntPoint framePoint = convertFromContainingWindow(windowPoint); 3850 IntPoint framePoint = convertFromContainingWindow(windowPoint);
3934 3851
3935 if (m_horizontalScrollbar) { 3852 if (m_horizontalScrollbar) {
3936 int horizontalScrollbarYMin = m_horizontalScrollbar->frameRect().y(); 3853 int horizontalScrollbarYMin = m_horizontalScrollbar->frameRect().y();
3937 int horizontalScrollbarYMax = m_horizontalScrollbar->frameRect().y() + m _horizontalScrollbar->frameRect().height(); 3854 int horizontalScrollbarYMax = m_horizontalScrollbar->frameRect().y() + m _horizontalScrollbar->frameRect().height();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
4069 { 3986 {
4070 Settings* settings = frame().settings(); 3987 Settings* settings = frame().settings();
4071 if (!settings || !settings->rootLayerScrolls()) 3988 if (!settings || !settings->rootLayerScrolls())
4072 return this; 3989 return this;
4073 3990
4074 LayoutView* layoutView = this->layoutView(); 3991 LayoutView* layoutView = this->layoutView();
4075 return layoutView ? layoutView->scrollableArea() : nullptr; 3992 return layoutView ? layoutView->scrollableArea() : nullptr;
4076 } 3993 }
4077 3994
4078 } // namespace blink 3995 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/loader/EmptyClients.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698