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

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

Issue 2395393003: Remove grow box rect support, renderer part. (Closed)
Patch Set: rebase Created 4 years, 2 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
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 m_needsUpdateWidgetGeometries(false), 170 m_needsUpdateWidgetGeometries(false),
171 m_needsUpdateViewportIntersection(true), 171 m_needsUpdateViewportIntersection(true),
172 m_needsUpdateViewportIntersectionInSubtree(true), 172 m_needsUpdateViewportIntersectionInSubtree(true),
173 #if ENABLE(ASSERT) 173 #if ENABLE(ASSERT)
174 m_hasBeenDisposed(false), 174 m_hasBeenDisposed(false),
175 #endif 175 #endif
176 m_horizontalScrollbarMode(ScrollbarAuto), 176 m_horizontalScrollbarMode(ScrollbarAuto),
177 m_verticalScrollbarMode(ScrollbarAuto), 177 m_verticalScrollbarMode(ScrollbarAuto),
178 m_horizontalScrollbarLock(false), 178 m_horizontalScrollbarLock(false),
179 m_verticalScrollbarLock(false), 179 m_verticalScrollbarLock(false),
180 m_scrollbarsAvoidingResizer(0),
181 m_scrollbarsSuppressed(false), 180 m_scrollbarsSuppressed(false),
182 m_inUpdateScrollbars(false), 181 m_inUpdateScrollbars(false),
183 m_frameTimingRequestsDirty(true), 182 m_frameTimingRequestsDirty(true),
184 m_viewportIntersectionValid(false), 183 m_viewportIntersectionValid(false),
185 m_hiddenForThrottling(false), 184 m_hiddenForThrottling(false),
186 m_crossOriginForThrottling(false), 185 m_crossOriginForThrottling(false),
187 m_subtreeThrottled(false), 186 m_subtreeThrottled(false),
188 m_currentUpdateLifecyclePhasesTargetState( 187 m_currentUpdateLifecyclePhasesTargetState(
189 DocumentLifecycle::Uninitialized), 188 DocumentLifecycle::Uninitialized),
190 m_scrollAnchor(this), 189 m_scrollAnchor(this),
(...skipping 2113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 } 2303 }
2305 2304
2306 void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const { 2305 void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const {
2307 if (!m_tickmarks.isEmpty()) 2306 if (!m_tickmarks.isEmpty())
2308 tickmarks = m_tickmarks; 2307 tickmarks = m_tickmarks;
2309 else 2308 else
2310 tickmarks = frame().document()->markers().renderedRectsForMarkers( 2309 tickmarks = frame().document()->markers().renderedRectsForMarkers(
2311 DocumentMarker::TextMatch); 2310 DocumentMarker::TextMatch);
2312 } 2311 }
2313 2312
2314 IntRect FrameView::windowResizerRect() const {
2315 if (Page* page = frame().page())
2316 return page->chromeClient().windowResizerRect(frame());
2317 return IntRect();
2318 }
2319
2320 void FrameView::setInputEventsTransformForEmulation(const IntSize& offset, 2313 void FrameView::setInputEventsTransformForEmulation(const IntSize& offset,
2321 float contentScaleFactor) { 2314 float contentScaleFactor) {
2322 m_inputEventsOffsetForEmulation = offset; 2315 m_inputEventsOffsetForEmulation = offset;
2323 m_inputEventsScaleFactorForEmulation = contentScaleFactor; 2316 m_inputEventsScaleFactorForEmulation = contentScaleFactor;
2324 } 2317 }
2325 2318
2326 IntSize FrameView::inputEventsOffsetForEmulation() const { 2319 IntSize FrameView::inputEventsOffsetForEmulation() const {
2327 return m_inputEventsOffsetForEmulation; 2320 return m_inputEventsOffsetForEmulation;
2328 } 2321 }
2329 2322
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
3341 void FrameView::removeAnimatingScrollableArea(ScrollableArea* scrollableArea) { 3334 void FrameView::removeAnimatingScrollableArea(ScrollableArea* scrollableArea) {
3342 if (!m_animatingScrollableAreas) 3335 if (!m_animatingScrollableAreas)
3343 return; 3336 return;
3344 m_animatingScrollableAreas->remove(scrollableArea); 3337 m_animatingScrollableAreas->remove(scrollableArea);
3345 } 3338 }
3346 3339
3347 void FrameView::setParent(Widget* parentView) { 3340 void FrameView::setParent(Widget* parentView) {
3348 if (parentView == parent()) 3341 if (parentView == parent())
3349 return; 3342 return;
3350 3343
3351 if (m_scrollbarsAvoidingResizer && parent())
3352 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(
3353 -m_scrollbarsAvoidingResizer);
3354
3355 Widget::setParent(parentView); 3344 Widget::setParent(parentView);
3356 3345
3357 if (m_scrollbarsAvoidingResizer && parent())
3358 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(
3359 m_scrollbarsAvoidingResizer);
3360
3361 updateScrollableAreaSet(); 3346 updateScrollableAreaSet();
3362 setNeedsUpdateViewportIntersection(); 3347 setNeedsUpdateViewportIntersection();
3363 } 3348 }
3364 3349
3365 void FrameView::removeChild(Widget* child) { 3350 void FrameView::removeChild(Widget* child) {
3366 ASSERT(child->parent() == this); 3351 ASSERT(child->parent() == this);
3367 3352
3368 if (child->isFrameView()) 3353 if (child->isFrameView())
3369 removeScrollableArea(toFrameView(child)); 3354 removeScrollableArea(toFrameView(child));
3370 3355
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3439 if (hasBar == !!m_horizontalScrollbar) 3424 if (hasBar == !!m_horizontalScrollbar)
3440 return; 3425 return;
3441 3426
3442 if (hasBar) { 3427 if (hasBar) {
3443 m_horizontalScrollbar = createScrollbar(HorizontalScrollbar); 3428 m_horizontalScrollbar = createScrollbar(HorizontalScrollbar);
3444 addChild(m_horizontalScrollbar.get()); 3429 addChild(m_horizontalScrollbar.get());
3445 didAddScrollbar(*m_horizontalScrollbar, HorizontalScrollbar); 3430 didAddScrollbar(*m_horizontalScrollbar, HorizontalScrollbar);
3446 m_horizontalScrollbar->styleChanged(); 3431 m_horizontalScrollbar->styleChanged();
3447 } else { 3432 } else {
3448 willRemoveScrollbar(*m_horizontalScrollbar, HorizontalScrollbar); 3433 willRemoveScrollbar(*m_horizontalScrollbar, HorizontalScrollbar);
3449 // If the scrollbar has been marked as overlapping the window resizer,
3450 // then its removal should reduce the count.
3451 if (m_horizontalScrollbar->overlapsResizer())
3452 adjustScrollbarsAvoidingResizerCount(-1);
3453 removeChild(m_horizontalScrollbar.get()); 3434 removeChild(m_horizontalScrollbar.get());
3454 m_horizontalScrollbar->disconnectFromScrollableArea(); 3435 m_horizontalScrollbar->disconnectFromScrollableArea();
3455 m_horizontalScrollbar = nullptr; 3436 m_horizontalScrollbar = nullptr;
3456 } 3437 }
3457 3438
3458 setScrollCornerNeedsPaintInvalidation(); 3439 setScrollCornerNeedsPaintInvalidation();
3459 } 3440 }
3460 3441
3461 void FrameView::setHasVerticalScrollbar(bool hasBar) { 3442 void FrameView::setHasVerticalScrollbar(bool hasBar) {
3462 if (hasBar == !!m_verticalScrollbar) 3443 if (hasBar == !!m_verticalScrollbar)
3463 return; 3444 return;
3464 3445
3465 if (hasBar) { 3446 if (hasBar) {
3466 m_verticalScrollbar = createScrollbar(VerticalScrollbar); 3447 m_verticalScrollbar = createScrollbar(VerticalScrollbar);
3467 addChild(m_verticalScrollbar.get()); 3448 addChild(m_verticalScrollbar.get());
3468 didAddScrollbar(*m_verticalScrollbar, VerticalScrollbar); 3449 didAddScrollbar(*m_verticalScrollbar, VerticalScrollbar);
3469 m_verticalScrollbar->styleChanged(); 3450 m_verticalScrollbar->styleChanged();
3470 } else { 3451 } else {
3471 willRemoveScrollbar(*m_verticalScrollbar, VerticalScrollbar); 3452 willRemoveScrollbar(*m_verticalScrollbar, VerticalScrollbar);
3472 // If the scrollbar has been marked as overlapping the window resizer,
3473 // then its removal should reduce the count.
3474 if (m_verticalScrollbar->overlapsResizer())
3475 adjustScrollbarsAvoidingResizerCount(-1);
3476 removeChild(m_verticalScrollbar.get()); 3453 removeChild(m_verticalScrollbar.get());
3477 m_verticalScrollbar->disconnectFromScrollableArea(); 3454 m_verticalScrollbar->disconnectFromScrollableArea();
3478 m_verticalScrollbar = nullptr; 3455 m_verticalScrollbar = nullptr;
3479 } 3456 }
3480 3457
3481 setScrollCornerNeedsPaintInvalidation(); 3458 setScrollCornerNeedsPaintInvalidation();
3482 } 3459 }
3483 3460
3484 void FrameView::setScrollbarModes(ScrollbarMode horizontalMode, 3461 void FrameView::setScrollbarModes(ScrollbarMode horizontalMode,
3485 ScrollbarMode verticalMode, 3462 ScrollbarMode verticalMode,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3647 if (frame().isMainFrame()) 3624 if (frame().isMainFrame())
3648 frame().host()->chromeClient().mainFrameScrollOffsetChanged(); 3625 frame().host()->chromeClient().mainFrameScrollOffsetChanged();
3649 } 3626 }
3650 3627
3651 void FrameView::clearScrollAnchor() { 3628 void FrameView::clearScrollAnchor() {
3652 if (!RuntimeEnabledFeatures::scrollAnchoringEnabled()) 3629 if (!RuntimeEnabledFeatures::scrollAnchoringEnabled())
3653 return; 3630 return;
3654 m_scrollAnchor.clear(); 3631 m_scrollAnchor.clear();
3655 } 3632 }
3656 3633
3657 void FrameView::windowResizerRectChanged() {
3658 updateScrollbars();
3659 }
3660
3661 bool FrameView::hasOverlayScrollbars() const { 3634 bool FrameView::hasOverlayScrollbars() const {
3662 return (m_horizontalScrollbar && 3635 return (m_horizontalScrollbar &&
3663 m_horizontalScrollbar->isOverlayScrollbar()) || 3636 m_horizontalScrollbar->isOverlayScrollbar()) ||
3664 (m_verticalScrollbar && m_verticalScrollbar->isOverlayScrollbar()); 3637 (m_verticalScrollbar && m_verticalScrollbar->isOverlayScrollbar());
3665 } 3638 }
3666 3639
3667 void FrameView::computeScrollbarExistence( 3640 void FrameView::computeScrollbarExistence(
3668 bool& newHasHorizontalScrollbar, 3641 bool& newHasHorizontalScrollbar,
3669 bool& newHasVerticalScrollbar, 3642 bool& newHasVerticalScrollbar,
3670 const IntSize& docSize, 3643 const IntSize& docSize,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3722 int thickness = m_horizontalScrollbar->scrollbarThickness(); 3695 int thickness = m_horizontalScrollbar->scrollbarThickness();
3723 int clientWidth = visibleWidth(); 3696 int clientWidth = visibleWidth();
3724 IntRect oldRect(m_horizontalScrollbar->frameRect()); 3697 IntRect oldRect(m_horizontalScrollbar->frameRect());
3725 IntRect hBarRect( 3698 IntRect hBarRect(
3726 (shouldPlaceVerticalScrollbarOnLeft() && m_verticalScrollbar) 3699 (shouldPlaceVerticalScrollbarOnLeft() && m_verticalScrollbar)
3727 ? m_verticalScrollbar->width() 3700 ? m_verticalScrollbar->width()
3728 : 0, 3701 : 0,
3729 height() - thickness, 3702 height() - thickness,
3730 width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0), 3703 width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0),
3731 thickness); 3704 thickness);
3732 m_horizontalScrollbar->setFrameRect( 3705 m_horizontalScrollbar->setFrameRect(hBarRect);
3733 adjustScrollbarRectForResizer(hBarRect, *m_horizontalScrollbar));
3734 if (oldRect != m_horizontalScrollbar->frameRect()) 3706 if (oldRect != m_horizontalScrollbar->frameRect())
3735 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar); 3707 setScrollbarNeedsPaintInvalidation(HorizontalScrollbar);
3736 3708
3737 m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth); 3709 m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth);
3738 m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); 3710 m_horizontalScrollbar->setProportion(clientWidth, contentsWidth());
3739 m_horizontalScrollbar->offsetDidChange(); 3711 m_horizontalScrollbar->offsetDidChange();
3740 } 3712 }
3741 3713
3742 if (m_verticalScrollbar) { 3714 if (m_verticalScrollbar) {
3743 int thickness = m_verticalScrollbar->scrollbarThickness(); 3715 int thickness = m_verticalScrollbar->scrollbarThickness();
3744 int clientHeight = visibleHeight(); 3716 int clientHeight = visibleHeight();
3745 IntRect oldRect(m_verticalScrollbar->frameRect()); 3717 IntRect oldRect(m_verticalScrollbar->frameRect());
3746 IntRect vBarRect( 3718 IntRect vBarRect(
3747 shouldPlaceVerticalScrollbarOnLeft() ? 0 : (width() - thickness), 0, 3719 shouldPlaceVerticalScrollbarOnLeft() ? 0 : (width() - thickness), 0,
3748 thickness, 3720 thickness,
3749 height() - 3721 height() -
3750 (m_horizontalScrollbar ? m_horizontalScrollbar->height() : 0)); 3722 (m_horizontalScrollbar ? m_horizontalScrollbar->height() : 0));
3751 m_verticalScrollbar->setFrameRect( 3723 m_verticalScrollbar->setFrameRect(vBarRect);
3752 adjustScrollbarRectForResizer(vBarRect, *m_verticalScrollbar));
3753 if (oldRect != m_verticalScrollbar->frameRect()) 3724 if (oldRect != m_verticalScrollbar->frameRect())
3754 setScrollbarNeedsPaintInvalidation(VerticalScrollbar); 3725 setScrollbarNeedsPaintInvalidation(VerticalScrollbar);
3755 3726
3756 m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); 3727 m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight);
3757 m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); 3728 m_verticalScrollbar->setProportion(clientHeight, contentsHeight());
3758 m_verticalScrollbar->offsetDidChange(); 3729 m_verticalScrollbar->offsetDidChange();
3759 } 3730 }
3760 } 3731 }
3761 3732
3762 IntRect FrameView::adjustScrollbarRectForResizer(const IntRect& rect,
3763 Scrollbar& scrollbar) {
3764 // Get our window resizer rect and see if we overlap. Adjust to avoid the
3765 // overlap if necessary.
3766 IntRect adjustedRect(rect);
3767 bool overlapsResizer = false;
3768 if (!rect.isEmpty() && !windowResizerRect().isEmpty()) {
3769 IntRect resizerRect = convertFromRootFrame(windowResizerRect());
3770 if (rect.intersects(resizerRect)) {
3771 if (scrollbar.orientation() == HorizontalScrollbar) {
3772 int overlap = rect.maxX() - resizerRect.x();
3773 if (overlap > 0 && resizerRect.maxX() >= rect.maxX()) {
3774 adjustedRect.setWidth(rect.width() - overlap);
3775 overlapsResizer = true;
3776 }
3777 } else {
3778 int overlap = rect.maxY() - resizerRect.y();
3779 if (overlap > 0 && resizerRect.maxY() >= rect.maxY()) {
3780 adjustedRect.setHeight(rect.height() - overlap);
3781 overlapsResizer = true;
3782 }
3783 }
3784 }
3785 }
3786 if (overlapsResizer != scrollbar.overlapsResizer()) {
3787 scrollbar.setOverlapsResizer(overlapsResizer);
3788 adjustScrollbarsAvoidingResizerCount(overlapsResizer ? 1 : -1);
3789 }
3790 return adjustedRect;
3791 }
3792
3793 bool FrameView::adjustScrollbarExistence( 3733 bool FrameView::adjustScrollbarExistence(
3794 ComputeScrollbarExistenceOption option) { 3734 ComputeScrollbarExistenceOption option) {
3795 ASSERT(m_inUpdateScrollbars); 3735 ASSERT(m_inUpdateScrollbars);
3796 3736
3797 // If we came in here with the view already needing a layout, then go ahead 3737 // If we came in here with the view already needing a layout, then go ahead
3798 // and do that first. (This will be the common case, e.g., when the page 3738 // and do that first. (This will be the common case, e.g., when the page
3799 // changes due to window resizing for example). This layout will not re-enter 3739 // changes due to window resizing for example). This layout will not re-enter
3800 // updateScrollbars and does not count towards our max layout pass total. 3740 // updateScrollbars and does not count towards our max layout pass total.
3801 if (!m_scrollbarsSuppressed) 3741 if (!m_scrollbarsSuppressed)
3802 scrollbarExistenceDidChange(); 3742 scrollbarExistenceDidChange();
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
4032 3972
4033 IntPoint FrameView::soonToBeRemovedUnscaledViewportToContents( 3973 IntPoint FrameView::soonToBeRemovedUnscaledViewportToContents(
4034 const IntPoint& pointInViewport) const { 3974 const IntPoint& pointInViewport) const {
4035 IntPoint pointInRootFrame = flooredIntPoint( 3975 IntPoint pointInRootFrame = flooredIntPoint(
4036 m_frame->host()->visualViewport().viewportCSSPixelsToRootFrame( 3976 m_frame->host()->visualViewport().viewportCSSPixelsToRootFrame(
4037 pointInViewport)); 3977 pointInViewport));
4038 IntPoint pointInThisFrame = convertFromRootFrame(pointInRootFrame); 3978 IntPoint pointInThisFrame = convertFromRootFrame(pointInRootFrame);
4039 return frameToContents(pointInThisFrame); 3979 return frameToContents(pointInThisFrame);
4040 } 3980 }
4041 3981
4042 bool FrameView::containsScrollbarsAvoidingResizer() const {
4043 return !m_scrollbarsAvoidingResizer;
4044 }
4045
4046 void FrameView::adjustScrollbarsAvoidingResizerCount(int overlapDelta) {
4047 int oldCount = m_scrollbarsAvoidingResizer;
4048 m_scrollbarsAvoidingResizer += overlapDelta;
4049 if (parent()) {
4050 toFrameView(parent())->adjustScrollbarsAvoidingResizerCount(overlapDelta);
4051 } else if (!scrollbarsSuppressed()) {
4052 // If we went from n to 0 or from 0 to n and we're the outermost view,
4053 // we need to invalidate the windowResizerRect(), since it will now need to
4054 // paint differently.
4055 if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) ||
4056 (oldCount == 0 && m_scrollbarsAvoidingResizer > 0))
4057 invalidateRect(windowResizerRect());
4058 }
4059 }
4060
4061 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame) { 3982 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame) {
4062 if (m_horizontalScrollbar && 3983 if (m_horizontalScrollbar &&
4063 m_horizontalScrollbar->shouldParticipateInHitTesting() && 3984 m_horizontalScrollbar->shouldParticipateInHitTesting() &&
4064 m_horizontalScrollbar->frameRect().contains(pointInFrame)) 3985 m_horizontalScrollbar->frameRect().contains(pointInFrame))
4065 return m_horizontalScrollbar.get(); 3986 return m_horizontalScrollbar.get();
4066 if (m_verticalScrollbar && 3987 if (m_verticalScrollbar &&
4067 m_verticalScrollbar->shouldParticipateInHitTesting() && 3988 m_verticalScrollbar->shouldParticipateInHitTesting() &&
4068 m_verticalScrollbar->frameRect().contains(pointInFrame)) 3989 m_verticalScrollbar->frameRect().contains(pointInFrame))
4069 return m_verticalScrollbar.get(); 3990 return m_verticalScrollbar.get();
4070 return nullptr; 3991 return nullptr;
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
4557 } 4478 }
4558 4479
4559 bool FrameView::canThrottleRendering() const { 4480 bool FrameView::canThrottleRendering() const {
4560 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) 4481 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled())
4561 return false; 4482 return false;
4562 return m_subtreeThrottled || 4483 return m_subtreeThrottled ||
4563 (m_hiddenForThrottling && m_crossOriginForThrottling); 4484 (m_hiddenForThrottling && m_crossOriginForThrottling);
4564 } 4485 }
4565 4486
4566 } // namespace blink 4487 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/core/loader/EmptyClients.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698