OLD | NEW |
---|---|
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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 setScrollbarsSuppressed(true); | 375 setScrollbarsSuppressed(true); |
376 } | 376 } |
377 | 377 |
378 bool FrameView::didFirstLayout() const | 378 bool FrameView::didFirstLayout() const |
379 { | 379 { |
380 return !m_firstLayout; | 380 return !m_firstLayout; |
381 } | 381 } |
382 | 382 |
383 void FrameView::invalidateRect(const IntRect& rect) | 383 void FrameView::invalidateRect(const IntRect& rect) |
384 { | 384 { |
385 // For querying PaintLayer::compositingState() when invalidating scrollbars. | |
386 // FIXME: do all scrollbar invalidations after layout of all frames is compl ete. It's currently not recursively true. | |
387 DisableCompositingQueryAsserts disabler; | |
388 if (!parent()) { | 385 if (!parent()) { |
389 if (HostWindow* window = hostWindow()) | 386 if (HostWindow* window = hostWindow()) |
390 window->invalidateRect(rect); | 387 window->invalidateRect(rect); |
391 return; | 388 return; |
392 } | 389 } |
393 | 390 |
394 LayoutPart* layoutObject = m_frame->ownerLayoutObject(); | 391 LayoutPart* layoutObject = m_frame->ownerLayoutObject(); |
395 if (!layoutObject) | 392 if (!layoutObject) |
396 return; | 393 return; |
397 | 394 |
398 IntRect paintInvalidationRect = rect; | 395 IntRect paintInvalidationRect = rect; |
399 paintInvalidationRect.move(layoutObject->borderLeft() + layoutObject->paddin gLeft(), | 396 paintInvalidationRect.move(layoutObject->borderLeft() + layoutObject->paddin gLeft(), |
400 layoutObject->borderTop() + layoutObject->paddingTop()); | 397 layoutObject->borderTop() + layoutObject->paddingTop()); |
401 // FIXME: We should not allow paint invalidation out of paint invalidation s tate. crbug.com/457415 | 398 // FIXME: We should not allow paint invalidation out of paint invalidation s tate. crbug.com/457415 |
402 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; | 399 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; |
403 layoutObject->invalidatePaintRectangle(LayoutRect(paintInvalidationRect)); | 400 layoutObject->invalidatePaintRectangleNotInvalidatingDisplayItemClients(Layo utRect(paintInvalidationRect)); |
404 } | 401 } |
405 | 402 |
406 void FrameView::setFrameRect(const IntRect& newRect) | 403 void FrameView::setFrameRect(const IntRect& newRect) |
407 { | 404 { |
408 IntRect oldRect = frameRect(); | 405 IntRect oldRect = frameRect(); |
409 if (newRect == oldRect) | 406 if (newRect == oldRect) |
410 return; | 407 return; |
411 | 408 |
412 Widget::setFrameRect(newRect); | 409 Widget::setFrameRect(newRect); |
413 | 410 |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
976 m_lastZoomFactor = layoutView()->style()->zoom(); | 973 m_lastZoomFactor = layoutView()->style()->zoom(); |
977 | 974 |
978 // Set the initial vMode to AlwaysOn if we're auto. | 975 // Set the initial vMode to AlwaysOn if we're auto. |
979 if (vMode == ScrollbarAuto) | 976 if (vMode == ScrollbarAuto) |
980 setVerticalScrollbarMode(ScrollbarAlwaysOn); // This causes a vertical scrollbar to appear. | 977 setVerticalScrollbarMode(ScrollbarAlwaysOn); // This causes a vertical scrollbar to appear. |
981 // Set the initial hMode to AlwaysOff if we're auto. | 978 // Set the initial hMode to AlwaysOff if we're auto. |
982 if (hMode == ScrollbarAuto) | 979 if (hMode == ScrollbarAuto) |
983 setHorizontalScrollbarMode(ScrollbarAlwaysOff); // This caus es a horizontal scrollbar to disappear. | 980 setHorizontalScrollbarMode(ScrollbarAlwaysOff); // This caus es a horizontal scrollbar to disappear. |
984 | 981 |
985 setScrollbarModes(hMode, vMode); | 982 setScrollbarModes(hMode, vMode); |
986 setScrollbarsSuppressed(false, true); | 983 setScrollbarsSuppressed(false); |
987 } else if (hMode != currentHMode || vMode != currentVMode) { | 984 } else if (hMode != currentHMode || vMode != currentVMode) { |
988 setScrollbarModes(hMode, vMode); | 985 setScrollbarModes(hMode, vMode); |
989 } | 986 } |
990 | 987 |
991 if (needsScrollbarReconstruction()) | 988 if (needsScrollbarReconstruction()) |
992 updateScrollbars(scrollOffsetDouble()); | 989 updateScrollbars(scrollOffsetDouble()); |
993 | 990 |
994 LayoutSize oldSize = m_size; | 991 LayoutSize oldSize = m_size; |
995 | 992 |
996 m_size = LayoutSize(layoutSize().width(), layoutSize().height()); | 993 m_size = LayoutSize(layoutSize().width(), layoutSize().height()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1050 return; | 1047 return; |
1051 | 1048 |
1052 #if ENABLE(ASSERT) | 1049 #if ENABLE(ASSERT) |
1053 // Post-layout assert that nobody was re-marked as needing layout during lay out. | 1050 // Post-layout assert that nobody was re-marked as needing layout during lay out. |
1054 layoutView()->assertSubtreeIsLaidOut(); | 1051 layoutView()->assertSubtreeIsLaidOut(); |
1055 #endif | 1052 #endif |
1056 | 1053 |
1057 frame().document()->layoutUpdated(); | 1054 frame().document()->layoutUpdated(); |
1058 } | 1055 } |
1059 | 1056 |
1060 // The plan is to move to compositor-queried paint invalidation, in which case t his | |
1061 // method would setNeedsRedraw on the GraphicsLayers with invalidations and | |
1062 // let the compositor pick which to actually draw. | |
1063 // See http://crbug.com/306706 | |
1064 void FrameView::invalidateTreeIfNeeded(PaintInvalidationState& paintInvalidation State) | 1057 void FrameView::invalidateTreeIfNeeded(PaintInvalidationState& paintInvalidation State) |
1065 { | 1058 { |
1066 if (shouldThrottleRendering()) | 1059 if (shouldThrottleRendering()) |
1067 return; | 1060 return; |
1068 | 1061 |
1069 lifecycle().advanceTo(DocumentLifecycle::InPaintInvalidation); | 1062 lifecycle().advanceTo(DocumentLifecycle::InPaintInvalidation); |
1070 | 1063 |
1071 ASSERT(layoutView()); | 1064 ASSERT(layoutView()); |
1072 LayoutView& rootForPaintInvalidation = *layoutView(); | 1065 LayoutView& rootForPaintInvalidation = *layoutView(); |
1073 ASSERT(!rootForPaintInvalidation.needsLayout()); | 1066 ASSERT(!rootForPaintInvalidation.needsLayout()); |
1074 | 1067 |
1075 TRACE_EVENT1("blink", "FrameView::invalidateTree", "root", rootForPaintInval idation.debugName().ascii()); | 1068 TRACE_EVENT1("blink", "FrameView::invalidateTree", "root", rootForPaintInval idation.debugName().ascii()); |
1076 | 1069 |
1077 rootForPaintInvalidation.invalidateTreeIfNeeded(paintInvalidationState); | 1070 rootForPaintInvalidation.invalidateTreeIfNeeded(paintInvalidationState); |
1078 | 1071 |
1079 // Invalidate the paint of the frameviews scrollbars if needed | 1072 |
1080 if (hasVerticalBarDamage()) | 1073 if (!m_frame->settings() || !m_frame->settings()->rootLayerScrolls()) { |
1081 invalidateRect(verticalBarDamage()); | 1074 paintInvalidationState.setViewClippingAndScrollOffsetDisabled(true); |
1082 if (hasHorizontalBarDamage()) | 1075 invalidatePaintOfScrollControlsIfNeeded(rootForPaintInvalidation, paintI nvalidationState, paintInvalidationState.paintInvalidationContainer(), m_scrollC orner, nullptr); |
chrishtr
2015/11/17 00:35:47
How about just passing a null pointer for PaintInv
Xianzhu
2015/11/17 00:56:05
For now the only purpose of the paintInvalidationS
| |
1083 invalidateRect(horizontalBarDamage()); | 1076 paintInvalidationState.setViewClippingAndScrollOffsetDisabled(false); |
1084 resetScrollbarDamage(); | 1077 } |
1085 | 1078 |
1086 #if ENABLE(ASSERT) | 1079 #if ENABLE(ASSERT) |
1087 layoutView()->assertSubtreeClearedPaintInvalidationState(); | 1080 layoutView()->assertSubtreeClearedPaintInvalidationState(); |
1088 #endif | 1081 #endif |
1089 | 1082 |
1090 if (m_frame->selection().isCaretBoundsDirty()) | 1083 if (m_frame->selection().isCaretBoundsDirty()) |
1091 m_frame->selection().invalidateCaretRect(); | 1084 m_frame->selection().invalidateCaretRect(); |
1092 | 1085 |
1093 m_doFullPaintInvalidation = false; | 1086 m_doFullPaintInvalidation = false; |
1094 lifecycle().advanceTo(DocumentLifecycle::PaintInvalidationClean); | 1087 lifecycle().advanceTo(DocumentLifecycle::PaintInvalidationClean); |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1496 { | 1489 { |
1497 Page* page = frame().page(); | 1490 Page* page = frame().page(); |
1498 if (!page) | 1491 if (!page) |
1499 return; | 1492 return; |
1500 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll(); | 1493 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll(); |
1501 if (m_horizontalScrollbar) { | 1494 if (m_horizontalScrollbar) { |
1502 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic Overscroll(); | 1495 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic Overscroll(); |
1503 if (delta != 0) { | 1496 if (delta != 0) { |
1504 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width( )); | 1497 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width( )); |
1505 scrollAnimator()->notifyContentAreaScrolled(FloatSize(delta, 0)); | 1498 scrollAnimator()->notifyContentAreaScrolled(FloatSize(delta, 0)); |
1506 if (!m_scrollbarsSuppressed) | 1499 setScrollbarNeedsPaintInvalidation(m_horizontalScrollbar.get()); |
1507 m_horizontalScrollbar->invalidate(); | |
1508 } | 1500 } |
1509 } | 1501 } |
1510 if (m_verticalScrollbar) { | 1502 if (m_verticalScrollbar) { |
1511 float delta = elasticOverscroll.height() - m_verticalScrollbar->elasticO verscroll(); | 1503 float delta = elasticOverscroll.height() - m_verticalScrollbar->elasticO verscroll(); |
1512 if (delta != 0) { | 1504 if (delta != 0) { |
1513 m_verticalScrollbar->setElasticOverscroll(elasticOverscroll.height() ); | 1505 m_verticalScrollbar->setElasticOverscroll(elasticOverscroll.height() ); |
1514 scrollAnimator()->notifyContentAreaScrolled(FloatSize(0, delta)); | 1506 scrollAnimator()->notifyContentAreaScrolled(FloatSize(0, delta)); |
1515 if (!m_scrollbarsSuppressed) | 1507 setScrollbarNeedsPaintInvalidation(m_verticalScrollbar.get()); |
1516 m_verticalScrollbar->invalidate(); | |
1517 } | 1508 } |
1518 } | 1509 } |
1519 } | 1510 } |
1520 | 1511 |
1521 IntSize FrameView::layoutSize(IncludeScrollbarsInRect scrollbarInclusion) const | 1512 IntSize FrameView::layoutSize(IncludeScrollbarsInRect scrollbarInclusion) const |
1522 { | 1513 { |
1523 return scrollbarInclusion == ExcludeScrollbars ? excludeScrollbars(m_layoutS ize) : m_layoutSize; | 1514 return scrollbarInclusion == ExcludeScrollbars ? excludeScrollbars(m_layoutS ize) : m_layoutSize; |
1524 } | 1515 } |
1525 | 1516 |
1526 void FrameView::setLayoutSize(const IntSize& size) | 1517 void FrameView::setLayoutSize(const IntSize& size) |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2070 | 2061 |
2071 if (!scrollbarsSuppressed()) | 2062 if (!scrollbarsSuppressed()) |
2072 m_pendingScrollDelta += scrollDelta; | 2063 m_pendingScrollDelta += scrollDelta; |
2073 | 2064 |
2074 clearScrollAnchor(); | 2065 clearScrollAnchor(); |
2075 updateLayersAndCompositingAfterScrollIfNeeded(); | 2066 updateLayersAndCompositingAfterScrollIfNeeded(); |
2076 scrollPositionChanged(); | 2067 scrollPositionChanged(); |
2077 frame().loader().client()->didChangeScrollOffset(); | 2068 frame().loader().client()->didChangeScrollOffset(); |
2078 } | 2069 } |
2079 | 2070 |
2080 void FrameView::invalidatePaintForTickmarks() const | 2071 void FrameView::invalidatePaintForTickmarks() |
2081 { | 2072 { |
2082 if (Scrollbar* scrollbar = verticalScrollbar()) | 2073 if (Scrollbar* scrollbar = verticalScrollbar()) |
2083 scrollbar->invalidate(); | 2074 setScrollbarNeedsPaintInvalidation(scrollbar); |
2084 } | |
2085 | |
2086 void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rec t) | |
2087 { | |
2088 // Add in our offset within the FrameView. | |
2089 IntRect dirtyRect = rect; | |
2090 dirtyRect.moveBy(scrollbar->location()); | |
2091 | |
2092 layoutView()->invalidateDisplayItemClient(*scrollbar); | |
2093 | |
2094 if (isInPerformLayout()) | |
2095 addScrollbarDamage(scrollbar, rect); | |
2096 else | |
2097 invalidateRect(dirtyRect); | |
2098 } | 2075 } |
2099 | 2076 |
2100 void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const | 2077 void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const |
2101 { | 2078 { |
2102 if (!m_tickmarks.isEmpty()) | 2079 if (!m_tickmarks.isEmpty()) |
2103 tickmarks = m_tickmarks; | 2080 tickmarks = m_tickmarks; |
2104 else | 2081 else |
2105 tickmarks = frame().document()->markers().renderedRectsForMarkers(Docume ntMarker::TextMatch); | 2082 tickmarks = frame().document()->markers().renderedRectsForMarkers(Docume ntMarker::TextMatch); |
2106 } | 2083 } |
2107 | 2084 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2287 // If we have an owning ipage/LocalFrame element, then it can set th e custom scrollbar also. | 2264 // If we have an owning ipage/LocalFrame element, then it can set th e custom scrollbar also. |
2288 if (LayoutPart* layoutObject = m_frame->ownerLayoutObject()) | 2265 if (LayoutPart* layoutObject = m_frame->ownerLayoutObject()) |
2289 cornerStyle = layoutObject->getUncachedPseudoStyle(PseudoStyleRe quest(SCROLLBAR_CORNER), layoutObject->style()); | 2266 cornerStyle = layoutObject->getUncachedPseudoStyle(PseudoStyleRe quest(SCROLLBAR_CORNER), layoutObject->style()); |
2290 } | 2267 } |
2291 } | 2268 } |
2292 | 2269 |
2293 if (cornerStyle) { | 2270 if (cornerStyle) { |
2294 if (!m_scrollCorner) | 2271 if (!m_scrollCorner) |
2295 m_scrollCorner = LayoutScrollbarPart::createAnonymous(doc); | 2272 m_scrollCorner = LayoutScrollbarPart::createAnonymous(doc); |
2296 m_scrollCorner->setStyle(cornerStyle.release()); | 2273 m_scrollCorner->setStyle(cornerStyle.release()); |
2297 invalidateScrollCorner(cornerRect); | 2274 setScrollCornerNeedsPaintInvalidation(); |
2298 } else if (m_scrollCorner) { | 2275 } else if (m_scrollCorner) { |
2299 m_scrollCorner->destroy(); | 2276 m_scrollCorner->destroy(); |
2300 m_scrollCorner = nullptr; | 2277 m_scrollCorner = nullptr; |
2301 } | 2278 } |
2302 } | 2279 } |
2303 | 2280 |
2304 Color FrameView::documentBackgroundColor() const | 2281 Color FrameView::documentBackgroundColor() const |
2305 { | 2282 { |
2306 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c olor of | 2283 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c olor of |
2307 // the document and the body against the base background color of the frame view. | 2284 // the document and the body against the base background color of the frame view. |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2998 { | 2975 { |
2999 if (hasBar == !!m_horizontalScrollbar) | 2976 if (hasBar == !!m_horizontalScrollbar) |
3000 return; | 2977 return; |
3001 | 2978 |
3002 if (hasBar) { | 2979 if (hasBar) { |
3003 m_horizontalScrollbar = createScrollbar(HorizontalScrollbar); | 2980 m_horizontalScrollbar = createScrollbar(HorizontalScrollbar); |
3004 addChild(m_horizontalScrollbar.get()); | 2981 addChild(m_horizontalScrollbar.get()); |
3005 didAddScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar); | 2982 didAddScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar); |
3006 m_horizontalScrollbar->styleChanged(); | 2983 m_horizontalScrollbar->styleChanged(); |
3007 } else { | 2984 } else { |
3008 willRemoveScrollbar(m_horizontalScrollbar.get(), HorizontalScrollbar); | 2985 willRemoveScrollbar(*layoutView(), m_horizontalScrollbar.get(), Horizont alScrollbar); |
3009 if (AXObjectCache* cache = axObjectCache()) | 2986 if (AXObjectCache* cache = axObjectCache()) |
3010 cache->remove(m_horizontalScrollbar.get()); | 2987 cache->remove(m_horizontalScrollbar.get()); |
3011 // If the scrollbar has been marked as overlapping the window resizer, | 2988 // If the scrollbar has been marked as overlapping the window resizer, |
3012 // then its removal should reduce the count. | 2989 // then its removal should reduce the count. |
3013 if (m_horizontalScrollbar->overlapsResizer()) | 2990 if (m_horizontalScrollbar->overlapsResizer()) |
3014 adjustScrollbarsAvoidingResizerCount(-1); | 2991 adjustScrollbarsAvoidingResizerCount(-1); |
3015 removeChild(m_horizontalScrollbar.get()); | 2992 removeChild(m_horizontalScrollbar.get()); |
3016 m_horizontalScrollbar->disconnectFromScrollableArea(); | 2993 m_horizontalScrollbar->disconnectFromScrollableArea(); |
3017 m_horizontalScrollbar = nullptr; | 2994 m_horizontalScrollbar = nullptr; |
3018 if (AXObjectCache* cache = axObjectCache()) | 2995 if (AXObjectCache* cache = axObjectCache()) |
3019 cache->handleScrollbarUpdate(this); | 2996 cache->handleScrollbarUpdate(this); |
3020 } | 2997 } |
3021 | 2998 |
3022 invalidateScrollCorner(scrollCornerRect()); | 2999 setScrollCornerNeedsPaintInvalidation(); |
3023 } | 3000 } |
3024 | 3001 |
3025 void FrameView::setHasVerticalScrollbar(bool hasBar) | 3002 void FrameView::setHasVerticalScrollbar(bool hasBar) |
3026 { | 3003 { |
3027 if (hasBar == !!m_verticalScrollbar) | 3004 if (hasBar == !!m_verticalScrollbar) |
3028 return; | 3005 return; |
3029 | 3006 |
3030 if (hasBar) { | 3007 if (hasBar) { |
3031 m_verticalScrollbar = createScrollbar(VerticalScrollbar); | 3008 m_verticalScrollbar = createScrollbar(VerticalScrollbar); |
3032 addChild(m_verticalScrollbar.get()); | 3009 addChild(m_verticalScrollbar.get()); |
3033 didAddScrollbar(m_verticalScrollbar.get(), VerticalScrollbar); | 3010 didAddScrollbar(m_verticalScrollbar.get(), VerticalScrollbar); |
3034 m_verticalScrollbar->styleChanged(); | 3011 m_verticalScrollbar->styleChanged(); |
3035 } else { | 3012 } else { |
3036 willRemoveScrollbar(m_verticalScrollbar.get(), VerticalScrollbar); | 3013 willRemoveScrollbar(*layoutView(), m_verticalScrollbar.get(), VerticalSc rollbar); |
3037 if (AXObjectCache* cache = axObjectCache()) | 3014 if (AXObjectCache* cache = axObjectCache()) |
3038 cache->remove(m_verticalScrollbar.get()); | 3015 cache->remove(m_verticalScrollbar.get()); |
3039 // If the scrollbar has been marked as overlapping the window resizer, | 3016 // If the scrollbar has been marked as overlapping the window resizer, |
3040 // then its removal should reduce the count. | 3017 // then its removal should reduce the count. |
3041 if (m_verticalScrollbar->overlapsResizer()) | 3018 if (m_verticalScrollbar->overlapsResizer()) |
3042 adjustScrollbarsAvoidingResizerCount(-1); | 3019 adjustScrollbarsAvoidingResizerCount(-1); |
3043 removeChild(m_verticalScrollbar.get()); | 3020 removeChild(m_verticalScrollbar.get()); |
3044 m_verticalScrollbar->disconnectFromScrollableArea(); | 3021 m_verticalScrollbar->disconnectFromScrollableArea(); |
3045 m_verticalScrollbar = nullptr; | 3022 m_verticalScrollbar = nullptr; |
3046 if (AXObjectCache* cache = axObjectCache()) | 3023 if (AXObjectCache* cache = axObjectCache()) |
3047 cache->handleScrollbarUpdate(this); | 3024 cache->handleScrollbarUpdate(this); |
3048 } | 3025 } |
3049 | 3026 |
3050 invalidateScrollCorner(scrollCornerRect()); | 3027 setScrollCornerNeedsPaintInvalidation(); |
3051 } | 3028 } |
3052 | 3029 |
3053 void FrameView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode ve rticalMode, | 3030 void FrameView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode ve rticalMode, |
3054 bool horizontalLock, bool verticalLock) | 3031 bool horizontalLock, bool verticalLock) |
3055 { | 3032 { |
3056 bool needsUpdate = false; | 3033 bool needsUpdate = false; |
3057 | 3034 |
3058 // If the page's overflow setting has disabled scrolling, do not allow anyth ing to override that setting. | 3035 // If the page's overflow setting has disabled scrolling, do not allow anyth ing to override that setting. |
3059 // http://crbug.com/426447 | 3036 // http://crbug.com/426447 |
3060 LayoutObject* viewport = viewportLayoutObject(); | 3037 LayoutObject* viewport = viewportLayoutObject(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3207 void FrameView::updateScrollbarGeometry() | 3184 void FrameView::updateScrollbarGeometry() |
3208 { | 3185 { |
3209 if (m_horizontalScrollbar) { | 3186 if (m_horizontalScrollbar) { |
3210 int clientWidth = visibleWidth(); | 3187 int clientWidth = visibleWidth(); |
3211 IntRect oldRect(m_horizontalScrollbar->frameRect()); | 3188 IntRect oldRect(m_horizontalScrollbar->frameRect()); |
3212 IntRect hBarRect((shouldPlaceVerticalScrollbarOnLeft() && m_verticalScro llbar) ? m_verticalScrollbar->width() : 0, | 3189 IntRect hBarRect((shouldPlaceVerticalScrollbarOnLeft() && m_verticalScro llbar) ? m_verticalScrollbar->width() : 0, |
3213 height() - m_horizontalScrollbar->height(), | 3190 height() - m_horizontalScrollbar->height(), |
3214 width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0), | 3191 width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0), |
3215 m_horizontalScrollbar->height()); | 3192 m_horizontalScrollbar->height()); |
3216 m_horizontalScrollbar->setFrameRect(adjustScrollbarRectForResizer(hBarRe ct, m_horizontalScrollbar.get())); | 3193 m_horizontalScrollbar->setFrameRect(adjustScrollbarRectForResizer(hBarRe ct, m_horizontalScrollbar.get())); |
3217 if (!m_scrollbarsSuppressed && oldRect != m_horizontalScrollbar->frameRe ct()) | 3194 if (oldRect != m_horizontalScrollbar->frameRect()) |
3218 m_horizontalScrollbar->invalidate(); | 3195 setScrollbarNeedsPaintInvalidation(m_horizontalScrollbar.get()); |
3219 | 3196 |
3220 if (m_scrollbarsSuppressed) | |
3221 m_horizontalScrollbar->setSuppressInvalidation(true); | |
3222 m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth); | 3197 m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth); |
3223 m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); | 3198 m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); |
3224 m_horizontalScrollbar->offsetDidChange(); | 3199 m_horizontalScrollbar->offsetDidChange(); |
3225 if (m_scrollbarsSuppressed) | |
3226 m_horizontalScrollbar->setSuppressInvalidation(false); | |
3227 } | 3200 } |
3228 | 3201 |
3229 if (m_verticalScrollbar) { | 3202 if (m_verticalScrollbar) { |
3230 int clientHeight = visibleHeight(); | 3203 int clientHeight = visibleHeight(); |
3231 IntRect oldRect(m_verticalScrollbar->frameRect()); | 3204 IntRect oldRect(m_verticalScrollbar->frameRect()); |
3232 IntRect vBarRect(shouldPlaceVerticalScrollbarOnLeft() ? 0 : (width() - m _verticalScrollbar->width()), | 3205 IntRect vBarRect(shouldPlaceVerticalScrollbarOnLeft() ? 0 : (width() - m _verticalScrollbar->width()), |
3233 0, | 3206 0, |
3234 m_verticalScrollbar->width(), | 3207 m_verticalScrollbar->width(), |
3235 height() - (m_horizontalScrollbar ? m_horizontalScrollbar->height() : 0)); | 3208 height() - (m_horizontalScrollbar ? m_horizontalScrollbar->height() : 0)); |
3236 m_verticalScrollbar->setFrameRect(adjustScrollbarRectForResizer(vBarRect , m_verticalScrollbar.get())); | 3209 m_verticalScrollbar->setFrameRect(adjustScrollbarRectForResizer(vBarRect , m_verticalScrollbar.get())); |
3237 if (!m_scrollbarsSuppressed && oldRect != m_verticalScrollbar->frameRect ()) | 3210 if (oldRect != m_verticalScrollbar->frameRect()) |
3238 m_verticalScrollbar->invalidate(); | 3211 setScrollbarNeedsPaintInvalidation(m_verticalScrollbar.get()); |
3239 | 3212 |
3240 if (m_scrollbarsSuppressed) | |
3241 m_verticalScrollbar->setSuppressInvalidation(true); | |
3242 m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); | 3213 m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); |
3243 m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); | 3214 m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); |
3244 m_verticalScrollbar->offsetDidChange(); | 3215 m_verticalScrollbar->offsetDidChange(); |
3245 if (m_scrollbarsSuppressed) | |
3246 m_verticalScrollbar->setSuppressInvalidation(false); | |
3247 } | 3216 } |
3248 } | 3217 } |
3249 | 3218 |
3250 IntRect FrameView::adjustScrollbarRectForResizer(const IntRect& rect, Scrollbar* scrollbar) | 3219 IntRect FrameView::adjustScrollbarRectForResizer(const IntRect& rect, Scrollbar* scrollbar) |
3251 { | 3220 { |
3252 // Get our window resizer rect and see if we overlap. Adjust to avoid the ov erlap | 3221 // Get our window resizer rect and see if we overlap. Adjust to avoid the ov erlap |
3253 // if necessary. | 3222 // if necessary. |
3254 IntRect adjustedRect(rect); | 3223 IntRect adjustedRect(rect); |
3255 bool overlapsResizer = false; | 3224 bool overlapsResizer = false; |
3256 if (!rect.isEmpty() && !windowResizerRect().isEmpty()) { | 3225 if (!rect.isEmpty() && !windowResizerRect().isEmpty()) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3339 setHasHorizontalScrollbar(false); | 3308 setHasHorizontalScrollbar(false); |
3340 setHasVerticalScrollbar(false); | 3309 setHasVerticalScrollbar(false); |
3341 setScrollOffsetFromUpdateScrollbars(desiredOffset); | 3310 setScrollOffsetFromUpdateScrollbars(desiredOffset); |
3342 return; | 3311 return; |
3343 } | 3312 } |
3344 | 3313 |
3345 if (m_inUpdateScrollbars) | 3314 if (m_inUpdateScrollbars) |
3346 return; | 3315 return; |
3347 InUpdateScrollbarsScope inUpdateScrollbarsScope(this); | 3316 InUpdateScrollbarsScope inUpdateScrollbarsScope(this); |
3348 | 3317 |
3349 IntSize oldVisibleSize = visibleContentSize(); | |
3350 | |
3351 bool scrollbarExistenceChanged = false; | 3318 bool scrollbarExistenceChanged = false; |
3352 | 3319 |
3353 if (needsScrollbarReconstruction()) { | 3320 if (needsScrollbarReconstruction()) { |
3354 setHasHorizontalScrollbar(false); | 3321 setHasHorizontalScrollbar(false); |
3355 setHasVerticalScrollbar(false); | 3322 setHasVerticalScrollbar(false); |
3356 scrollbarExistenceChanged = true; | 3323 scrollbarExistenceChanged = true; |
3357 } | 3324 } |
3358 | 3325 |
3359 int maxUpdateScrollbarsPass = hasOverlayScrollbars() || m_scrollbarsSuppress ed ? 1 : 3; | 3326 int maxUpdateScrollbarsPass = hasOverlayScrollbars() || m_scrollbarsSuppress ed ? 1 : 3; |
3360 for (int updateScrollbarsPass = 0; updateScrollbarsPass < maxUpdateScrollbar sPass; updateScrollbarsPass++) { | 3327 for (int updateScrollbarsPass = 0; updateScrollbarsPass < maxUpdateScrollbar sPass; updateScrollbarsPass++) { |
3361 if (!adjustScrollbarExistence(updateScrollbarsPass ? Incremental : First Pass)) | 3328 if (!adjustScrollbarExistence(updateScrollbarsPass ? Incremental : First Pass)) |
3362 break; | 3329 break; |
3363 scrollbarExistenceChanged = true; | 3330 scrollbarExistenceChanged = true; |
3364 } | 3331 } |
3365 | 3332 |
3366 updateScrollbarGeometry(); | 3333 updateScrollbarGeometry(); |
3367 | 3334 |
3368 if (scrollbarExistenceChanged) { | 3335 if (scrollbarExistenceChanged) { |
3369 // FIXME: Is frameRectsChanged really necessary here? Have any frame rec ts changed? | 3336 // FIXME: Is frameRectsChanged really necessary here? Have any frame rec ts changed? |
3370 frameRectsChanged(); | 3337 frameRectsChanged(); |
3371 positionScrollbarLayers(); | 3338 positionScrollbarLayers(); |
3372 updateScrollCorner(); | 3339 updateScrollCorner(); |
3373 } | 3340 } |
3374 | 3341 |
3375 // FIXME: We don't need to do this if we are composited. | |
3376 IntSize newVisibleSize = visibleContentSize(); | |
3377 if (newVisibleSize.width() > oldVisibleSize.width()) { | |
3378 if (shouldPlaceVerticalScrollbarOnLeft()) | |
3379 invalidateRect(IntRect(0, 0, newVisibleSize.width() - oldVisibleSize .width(), newVisibleSize.height())); | |
3380 else | |
3381 invalidateRect(IntRect(oldVisibleSize.width(), 0, newVisibleSize.wid th() - oldVisibleSize.width(), newVisibleSize.height())); | |
3382 } | |
3383 if (newVisibleSize.height() > oldVisibleSize.height()) | |
3384 invalidateRect(IntRect(0, oldVisibleSize.height(), newVisibleSize.width( ), newVisibleSize.height() - oldVisibleSize.height())); | |
3385 | |
3386 setScrollOffsetFromUpdateScrollbars(desiredOffset); | 3342 setScrollOffsetFromUpdateScrollbars(desiredOffset); |
3387 } | 3343 } |
3388 | 3344 |
3389 void FrameView::setScrollOffsetFromUpdateScrollbars(const DoubleSize& offset) | 3345 void FrameView::setScrollOffsetFromUpdateScrollbars(const DoubleSize& offset) |
3390 { | 3346 { |
3391 DoublePoint adjustedScrollPosition = clampScrollPosition(DoublePoint(offset) ); | 3347 DoublePoint adjustedScrollPosition = clampScrollPosition(DoublePoint(offset) ); |
3392 | 3348 |
3393 if (adjustedScrollPosition != scrollPositionDouble() || scrollOriginChanged( )) { | 3349 if (adjustedScrollPosition != scrollPositionDouble() || scrollOriginChanged( )) { |
3394 ScrollableArea::setScrollPosition(adjustedScrollPosition, ProgrammaticSc roll); | 3350 ScrollableArea::setScrollPosition(adjustedScrollPosition, ProgrammaticSc roll); |
3395 resetScrollOriginChanged(); | 3351 resetScrollOriginChanged(); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3556 } else if (!scrollbarsSuppressed()) { | 3512 } else if (!scrollbarsSuppressed()) { |
3557 // If we went from n to 0 or from 0 to n and we're the outermost view, | 3513 // If we went from n to 0 or from 0 to n and we're the outermost view, |
3558 // we need to invalidate the windowResizerRect(), since it will now need to paint | 3514 // we need to invalidate the windowResizerRect(), since it will now need to paint |
3559 // differently. | 3515 // differently. |
3560 if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) | 3516 if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) |
3561 || (oldCount == 0 && m_scrollbarsAvoidingResizer > 0)) | 3517 || (oldCount == 0 && m_scrollbarsAvoidingResizer > 0)) |
3562 invalidateRect(windowResizerRect()); | 3518 invalidateRect(windowResizerRect()); |
3563 } | 3519 } |
3564 } | 3520 } |
3565 | 3521 |
3566 void FrameView::setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppres s) | |
3567 { | |
3568 if (suppressed == m_scrollbarsSuppressed) | |
3569 return; | |
3570 | |
3571 m_scrollbarsSuppressed = suppressed; | |
3572 | |
3573 if (repaintOnUnsuppress && !suppressed) { | |
3574 if (m_horizontalScrollbar) | |
3575 m_horizontalScrollbar->invalidate(); | |
3576 if (m_verticalScrollbar) | |
3577 m_verticalScrollbar->invalidate(); | |
3578 | |
3579 // Invalidate the scroll corner too on unsuppress. | |
3580 invalidateScrollCorner(scrollCornerRect()); | |
3581 } | |
3582 } | |
3583 | |
3584 Scrollbar* FrameView::scrollbarAtRootFramePoint(const IntPoint& pointInRootFrame ) | 3522 Scrollbar* FrameView::scrollbarAtRootFramePoint(const IntPoint& pointInRootFrame ) |
3585 { | 3523 { |
3586 IntPoint pointInFrame = convertFromContainingWindow(pointInRootFrame); | 3524 IntPoint pointInFrame = convertFromContainingWindow(pointInRootFrame); |
3587 return scrollbarAtFramePoint(pointInFrame); | 3525 return scrollbarAtFramePoint(pointInFrame); |
3588 } | 3526 } |
3589 | 3527 |
3590 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame) | 3528 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame) |
3591 { | 3529 { |
3592 if (m_horizontalScrollbar && m_horizontalScrollbar->shouldParticipateInHitTe sting() && m_horizontalScrollbar->frameRect().contains(pointInFrame)) | 3530 if (m_horizontalScrollbar && m_horizontalScrollbar->shouldParticipateInHitTe sting() && m_horizontalScrollbar->frameRect().contains(pointInFrame)) |
3593 return m_horizontalScrollbar.get(); | 3531 return m_horizontalScrollbar.get(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3693 } | 3631 } |
3694 | 3632 |
3695 return cornerRect; | 3633 return cornerRect; |
3696 } | 3634 } |
3697 | 3635 |
3698 bool FrameView::isScrollCornerVisible() const | 3636 bool FrameView::isScrollCornerVisible() const |
3699 { | 3637 { |
3700 return !scrollCornerRect().isEmpty(); | 3638 return !scrollCornerRect().isEmpty(); |
3701 } | 3639 } |
3702 | 3640 |
3703 void FrameView::invalidateScrollCornerRect(const IntRect& rect) | |
3704 { | |
3705 invalidateRect(rect); | |
3706 if (m_scrollCorner) | |
3707 layoutView()->invalidateDisplayItemClientForNonCompositingDescendantsOf( *m_scrollCorner); | |
3708 } | |
3709 | |
3710 ScrollBehavior FrameView::scrollBehaviorStyle() const | 3641 ScrollBehavior FrameView::scrollBehaviorStyle() const |
3711 { | 3642 { |
3712 Element* scrollElement = m_frame->document()->scrollingElement(); | 3643 Element* scrollElement = m_frame->document()->scrollingElement(); |
3713 LayoutObject* layoutObject = scrollElement ? scrollElement->layoutObject() : nullptr; | 3644 LayoutObject* layoutObject = scrollElement ? scrollElement->layoutObject() : nullptr; |
3714 if (layoutObject && layoutObject->style()->scrollBehavior() == ScrollBehavio rSmooth) | 3645 if (layoutObject && layoutObject->style()->scrollBehavior() == ScrollBehavio rSmooth) |
3715 return ScrollBehaviorSmooth; | 3646 return ScrollBehaviorSmooth; |
3716 | 3647 |
3717 return ScrollBehaviorInstant; | 3648 return ScrollBehaviorInstant; |
3718 } | 3649 } |
3719 | 3650 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4035 } | 3966 } |
4036 | 3967 |
4037 bool FrameView::canThrottleRendering() const | 3968 bool FrameView::canThrottleRendering() const |
4038 { | 3969 { |
4039 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) | 3970 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) |
4040 return false; | 3971 return false; |
4041 return m_hiddenForThrottling && m_crossOriginForThrottling; | 3972 return m_hiddenForThrottling && m_crossOriginForThrottling; |
4042 } | 3973 } |
4043 | 3974 |
4044 } // namespace blink | 3975 } // namespace blink |
OLD | NEW |