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 if (!m_frame->settings() || !m_frame->settings()->rootLayerScrolls()) { |
1080 if (hasVerticalBarDamage()) | 1073 paintInvalidationState.setViewClippingAndScrollOffsetDisabled(true); |
1081 invalidateRect(verticalBarDamage()); | 1074 invalidatePaintOfScrollControlsIfNeeded(paintInvalidationState, paintInv
alidationState.paintInvalidationContainer()); |
1082 if (hasHorizontalBarDamage()) | 1075 paintInvalidationState.setViewClippingAndScrollOffsetDisabled(false); |
1083 invalidateRect(horizontalBarDamage()); | 1076 } |
1084 resetScrollbarDamage(); | |
1085 | 1077 |
1086 #if ENABLE(ASSERT) | 1078 #if ENABLE(ASSERT) |
1087 layoutView()->assertSubtreeClearedPaintInvalidationState(); | 1079 layoutView()->assertSubtreeClearedPaintInvalidationState(); |
1088 #endif | 1080 #endif |
1089 | 1081 |
1090 if (m_frame->selection().isCaretBoundsDirty()) | 1082 if (m_frame->selection().isCaretBoundsDirty()) |
1091 m_frame->selection().invalidateCaretRect(); | 1083 m_frame->selection().invalidateCaretRect(); |
1092 | 1084 |
1093 m_doFullPaintInvalidation = false; | 1085 m_doFullPaintInvalidation = false; |
1094 lifecycle().advanceTo(DocumentLifecycle::PaintInvalidationClean); | 1086 lifecycle().advanceTo(DocumentLifecycle::PaintInvalidationClean); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 { | 1494 { |
1503 Page* page = frame().page(); | 1495 Page* page = frame().page(); |
1504 if (!page) | 1496 if (!page) |
1505 return; | 1497 return; |
1506 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll(); | 1498 FloatSize elasticOverscroll = page->chromeClient().elasticOverscroll(); |
1507 if (m_horizontalScrollbar) { | 1499 if (m_horizontalScrollbar) { |
1508 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic
Overscroll(); | 1500 float delta = elasticOverscroll.width() - m_horizontalScrollbar->elastic
Overscroll(); |
1509 if (delta != 0) { | 1501 if (delta != 0) { |
1510 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width(
)); | 1502 m_horizontalScrollbar->setElasticOverscroll(elasticOverscroll.width(
)); |
1511 scrollAnimator()->notifyContentAreaScrolled(FloatSize(delta, 0)); | 1503 scrollAnimator()->notifyContentAreaScrolled(FloatSize(delta, 0)); |
1512 if (!m_scrollbarsSuppressed) | 1504 setScrollbarNeedsPaintInvalidation(m_horizontalScrollbar.get()); |
1513 m_horizontalScrollbar->invalidate(); | |
1514 } | 1505 } |
1515 } | 1506 } |
1516 if (m_verticalScrollbar) { | 1507 if (m_verticalScrollbar) { |
1517 float delta = elasticOverscroll.height() - m_verticalScrollbar->elasticO
verscroll(); | 1508 float delta = elasticOverscroll.height() - m_verticalScrollbar->elasticO
verscroll(); |
1518 if (delta != 0) { | 1509 if (delta != 0) { |
1519 m_verticalScrollbar->setElasticOverscroll(elasticOverscroll.height()
); | 1510 m_verticalScrollbar->setElasticOverscroll(elasticOverscroll.height()
); |
1520 scrollAnimator()->notifyContentAreaScrolled(FloatSize(0, delta)); | 1511 scrollAnimator()->notifyContentAreaScrolled(FloatSize(0, delta)); |
1521 if (!m_scrollbarsSuppressed) | 1512 setScrollbarNeedsPaintInvalidation(m_verticalScrollbar.get()); |
1522 m_verticalScrollbar->invalidate(); | |
1523 } | 1513 } |
1524 } | 1514 } |
1525 } | 1515 } |
1526 | 1516 |
1527 IntSize FrameView::layoutSize(IncludeScrollbarsInRect scrollbarInclusion) const | 1517 IntSize FrameView::layoutSize(IncludeScrollbarsInRect scrollbarInclusion) const |
1528 { | 1518 { |
1529 return scrollbarInclusion == ExcludeScrollbars ? excludeScrollbars(m_layoutS
ize) : m_layoutSize; | 1519 return scrollbarInclusion == ExcludeScrollbars ? excludeScrollbars(m_layoutS
ize) : m_layoutSize; |
1530 } | 1520 } |
1531 | 1521 |
1532 void FrameView::setLayoutSize(const IntSize& size) | 1522 void FrameView::setLayoutSize(const IntSize& size) |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2076 | 2066 |
2077 if (!scrollbarsSuppressed()) | 2067 if (!scrollbarsSuppressed()) |
2078 m_pendingScrollDelta += scrollDelta; | 2068 m_pendingScrollDelta += scrollDelta; |
2079 | 2069 |
2080 clearScrollAnchor(); | 2070 clearScrollAnchor(); |
2081 updateLayersAndCompositingAfterScrollIfNeeded(); | 2071 updateLayersAndCompositingAfterScrollIfNeeded(); |
2082 scrollPositionChanged(); | 2072 scrollPositionChanged(); |
2083 frame().loader().client()->didChangeScrollOffset(); | 2073 frame().loader().client()->didChangeScrollOffset(); |
2084 } | 2074 } |
2085 | 2075 |
2086 void FrameView::invalidatePaintForTickmarks() const | 2076 void FrameView::invalidatePaintForTickmarks() |
2087 { | 2077 { |
2088 if (Scrollbar* scrollbar = verticalScrollbar()) | 2078 if (Scrollbar* scrollbar = verticalScrollbar()) |
2089 scrollbar->invalidate(); | 2079 setScrollbarNeedsPaintInvalidation(scrollbar); |
2090 } | |
2091 | |
2092 void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rec
t) | |
2093 { | |
2094 // Add in our offset within the FrameView. | |
2095 IntRect dirtyRect = rect; | |
2096 dirtyRect.moveBy(scrollbar->location()); | |
2097 | |
2098 layoutView()->invalidateDisplayItemClient(*scrollbar); | |
2099 | |
2100 if (isInPerformLayout()) | |
2101 addScrollbarDamage(scrollbar, rect); | |
2102 else | |
2103 invalidateRect(dirtyRect); | |
2104 } | 2080 } |
2105 | 2081 |
2106 void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const | 2082 void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const |
2107 { | 2083 { |
2108 if (!m_tickmarks.isEmpty()) | 2084 if (!m_tickmarks.isEmpty()) |
2109 tickmarks = m_tickmarks; | 2085 tickmarks = m_tickmarks; |
2110 else | 2086 else |
2111 tickmarks = frame().document()->markers().renderedRectsForMarkers(Docume
ntMarker::TextMatch); | 2087 tickmarks = frame().document()->markers().renderedRectsForMarkers(Docume
ntMarker::TextMatch); |
2112 } | 2088 } |
2113 | 2089 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2293 // If we have an owning ipage/LocalFrame element, then it can set th
e custom scrollbar also. | 2269 // If we have an owning ipage/LocalFrame element, then it can set th
e custom scrollbar also. |
2294 if (LayoutPart* layoutObject = m_frame->ownerLayoutObject()) | 2270 if (LayoutPart* layoutObject = m_frame->ownerLayoutObject()) |
2295 cornerStyle = layoutObject->getUncachedPseudoStyle(PseudoStyleRe
quest(SCROLLBAR_CORNER), layoutObject->style()); | 2271 cornerStyle = layoutObject->getUncachedPseudoStyle(PseudoStyleRe
quest(SCROLLBAR_CORNER), layoutObject->style()); |
2296 } | 2272 } |
2297 } | 2273 } |
2298 | 2274 |
2299 if (cornerStyle) { | 2275 if (cornerStyle) { |
2300 if (!m_scrollCorner) | 2276 if (!m_scrollCorner) |
2301 m_scrollCorner = LayoutScrollbarPart::createAnonymous(doc); | 2277 m_scrollCorner = LayoutScrollbarPart::createAnonymous(doc); |
2302 m_scrollCorner->setStyle(cornerStyle.release()); | 2278 m_scrollCorner->setStyle(cornerStyle.release()); |
2303 invalidateScrollCorner(cornerRect); | 2279 setScrollCornerNeedsPaintInvalidation(); |
2304 } else if (m_scrollCorner) { | 2280 } else if (m_scrollCorner) { |
2305 m_scrollCorner->destroy(); | 2281 m_scrollCorner->destroy(); |
2306 m_scrollCorner = nullptr; | 2282 m_scrollCorner = nullptr; |
2307 } | 2283 } |
2308 } | 2284 } |
2309 | 2285 |
2310 Color FrameView::documentBackgroundColor() const | 2286 Color FrameView::documentBackgroundColor() const |
2311 { | 2287 { |
2312 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c
olor of | 2288 // <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background c
olor of |
2313 // the document and the body against the base background color of the frame
view. | 2289 // the document and the body against the base background color of the frame
view. |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3018 // then its removal should reduce the count. | 2994 // then its removal should reduce the count. |
3019 if (m_horizontalScrollbar->overlapsResizer()) | 2995 if (m_horizontalScrollbar->overlapsResizer()) |
3020 adjustScrollbarsAvoidingResizerCount(-1); | 2996 adjustScrollbarsAvoidingResizerCount(-1); |
3021 removeChild(m_horizontalScrollbar.get()); | 2997 removeChild(m_horizontalScrollbar.get()); |
3022 m_horizontalScrollbar->disconnectFromScrollableArea(); | 2998 m_horizontalScrollbar->disconnectFromScrollableArea(); |
3023 m_horizontalScrollbar = nullptr; | 2999 m_horizontalScrollbar = nullptr; |
3024 if (AXObjectCache* cache = axObjectCache()) | 3000 if (AXObjectCache* cache = axObjectCache()) |
3025 cache->handleScrollbarUpdate(this); | 3001 cache->handleScrollbarUpdate(this); |
3026 } | 3002 } |
3027 | 3003 |
3028 invalidateScrollCorner(scrollCornerRect()); | 3004 setScrollCornerNeedsPaintInvalidation(); |
3029 } | 3005 } |
3030 | 3006 |
3031 void FrameView::setHasVerticalScrollbar(bool hasBar) | 3007 void FrameView::setHasVerticalScrollbar(bool hasBar) |
3032 { | 3008 { |
3033 if (hasBar == !!m_verticalScrollbar) | 3009 if (hasBar == !!m_verticalScrollbar) |
3034 return; | 3010 return; |
3035 | 3011 |
3036 if (hasBar) { | 3012 if (hasBar) { |
3037 m_verticalScrollbar = createScrollbar(VerticalScrollbar); | 3013 m_verticalScrollbar = createScrollbar(VerticalScrollbar); |
3038 addChild(m_verticalScrollbar.get()); | 3014 addChild(m_verticalScrollbar.get()); |
3039 didAddScrollbar(m_verticalScrollbar.get(), VerticalScrollbar); | 3015 didAddScrollbar(m_verticalScrollbar.get(), VerticalScrollbar); |
3040 m_verticalScrollbar->styleChanged(); | 3016 m_verticalScrollbar->styleChanged(); |
3041 } else { | 3017 } else { |
3042 willRemoveScrollbar(m_verticalScrollbar.get(), VerticalScrollbar); | 3018 willRemoveScrollbar(m_verticalScrollbar.get(), VerticalScrollbar); |
3043 if (AXObjectCache* cache = axObjectCache()) | 3019 if (AXObjectCache* cache = axObjectCache()) |
3044 cache->remove(m_verticalScrollbar.get()); | 3020 cache->remove(m_verticalScrollbar.get()); |
3045 // If the scrollbar has been marked as overlapping the window resizer, | 3021 // If the scrollbar has been marked as overlapping the window resizer, |
3046 // then its removal should reduce the count. | 3022 // then its removal should reduce the count. |
3047 if (m_verticalScrollbar->overlapsResizer()) | 3023 if (m_verticalScrollbar->overlapsResizer()) |
3048 adjustScrollbarsAvoidingResizerCount(-1); | 3024 adjustScrollbarsAvoidingResizerCount(-1); |
3049 removeChild(m_verticalScrollbar.get()); | 3025 removeChild(m_verticalScrollbar.get()); |
3050 m_verticalScrollbar->disconnectFromScrollableArea(); | 3026 m_verticalScrollbar->disconnectFromScrollableArea(); |
3051 m_verticalScrollbar = nullptr; | 3027 m_verticalScrollbar = nullptr; |
3052 if (AXObjectCache* cache = axObjectCache()) | 3028 if (AXObjectCache* cache = axObjectCache()) |
3053 cache->handleScrollbarUpdate(this); | 3029 cache->handleScrollbarUpdate(this); |
3054 } | 3030 } |
3055 | 3031 |
3056 invalidateScrollCorner(scrollCornerRect()); | 3032 setScrollCornerNeedsPaintInvalidation(); |
3057 } | 3033 } |
3058 | 3034 |
3059 void FrameView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode ve
rticalMode, | 3035 void FrameView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode ve
rticalMode, |
3060 bool horizontalLock, bool verticalLock) | 3036 bool horizontalLock, bool verticalLock) |
3061 { | 3037 { |
3062 bool needsUpdate = false; | 3038 bool needsUpdate = false; |
3063 | 3039 |
3064 // If the page's overflow setting has disabled scrolling, do not allow anyth
ing to override that setting. | 3040 // If the page's overflow setting has disabled scrolling, do not allow anyth
ing to override that setting. |
3065 // http://crbug.com/426447 | 3041 // http://crbug.com/426447 |
3066 LayoutObject* viewport = viewportLayoutObject(); | 3042 LayoutObject* viewport = viewportLayoutObject(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3213 void FrameView::updateScrollbarGeometry() | 3189 void FrameView::updateScrollbarGeometry() |
3214 { | 3190 { |
3215 if (m_horizontalScrollbar) { | 3191 if (m_horizontalScrollbar) { |
3216 int clientWidth = visibleWidth(); | 3192 int clientWidth = visibleWidth(); |
3217 IntRect oldRect(m_horizontalScrollbar->frameRect()); | 3193 IntRect oldRect(m_horizontalScrollbar->frameRect()); |
3218 IntRect hBarRect((shouldPlaceVerticalScrollbarOnLeft() && m_verticalScro
llbar) ? m_verticalScrollbar->width() : 0, | 3194 IntRect hBarRect((shouldPlaceVerticalScrollbarOnLeft() && m_verticalScro
llbar) ? m_verticalScrollbar->width() : 0, |
3219 height() - m_horizontalScrollbar->height(), | 3195 height() - m_horizontalScrollbar->height(), |
3220 width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0), | 3196 width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0), |
3221 m_horizontalScrollbar->height()); | 3197 m_horizontalScrollbar->height()); |
3222 m_horizontalScrollbar->setFrameRect(adjustScrollbarRectForResizer(hBarRe
ct, m_horizontalScrollbar.get())); | 3198 m_horizontalScrollbar->setFrameRect(adjustScrollbarRectForResizer(hBarRe
ct, m_horizontalScrollbar.get())); |
3223 if (!m_scrollbarsSuppressed && oldRect != m_horizontalScrollbar->frameRe
ct()) | 3199 if (oldRect != m_horizontalScrollbar->frameRect()) |
3224 m_horizontalScrollbar->invalidate(); | 3200 setScrollbarNeedsPaintInvalidation(m_horizontalScrollbar.get()); |
3225 | 3201 |
3226 if (m_scrollbarsSuppressed) | |
3227 m_horizontalScrollbar->setSuppressInvalidation(true); | |
3228 m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth); | 3202 m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth); |
3229 m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); | 3203 m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); |
3230 m_horizontalScrollbar->offsetDidChange(); | 3204 m_horizontalScrollbar->offsetDidChange(); |
3231 if (m_scrollbarsSuppressed) | |
3232 m_horizontalScrollbar->setSuppressInvalidation(false); | |
3233 } | 3205 } |
3234 | 3206 |
3235 if (m_verticalScrollbar) { | 3207 if (m_verticalScrollbar) { |
3236 int clientHeight = visibleHeight(); | 3208 int clientHeight = visibleHeight(); |
3237 IntRect oldRect(m_verticalScrollbar->frameRect()); | 3209 IntRect oldRect(m_verticalScrollbar->frameRect()); |
3238 IntRect vBarRect(shouldPlaceVerticalScrollbarOnLeft() ? 0 : (width() - m
_verticalScrollbar->width()), | 3210 IntRect vBarRect(shouldPlaceVerticalScrollbarOnLeft() ? 0 : (width() - m
_verticalScrollbar->width()), |
3239 0, | 3211 0, |
3240 m_verticalScrollbar->width(), | 3212 m_verticalScrollbar->width(), |
3241 height() - (m_horizontalScrollbar ? m_horizontalScrollbar->height()
: 0)); | 3213 height() - (m_horizontalScrollbar ? m_horizontalScrollbar->height()
: 0)); |
3242 m_verticalScrollbar->setFrameRect(adjustScrollbarRectForResizer(vBarRect
, m_verticalScrollbar.get())); | 3214 m_verticalScrollbar->setFrameRect(adjustScrollbarRectForResizer(vBarRect
, m_verticalScrollbar.get())); |
3243 if (!m_scrollbarsSuppressed && oldRect != m_verticalScrollbar->frameRect
()) | 3215 if (oldRect != m_verticalScrollbar->frameRect()) |
3244 m_verticalScrollbar->invalidate(); | 3216 setScrollbarNeedsPaintInvalidation(m_verticalScrollbar.get()); |
3245 | 3217 |
3246 if (m_scrollbarsSuppressed) | |
3247 m_verticalScrollbar->setSuppressInvalidation(true); | |
3248 m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); | 3218 m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight); |
3249 m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); | 3219 m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); |
3250 m_verticalScrollbar->offsetDidChange(); | 3220 m_verticalScrollbar->offsetDidChange(); |
3251 if (m_scrollbarsSuppressed) | |
3252 m_verticalScrollbar->setSuppressInvalidation(false); | |
3253 } | 3221 } |
3254 } | 3222 } |
3255 | 3223 |
3256 IntRect FrameView::adjustScrollbarRectForResizer(const IntRect& rect, Scrollbar*
scrollbar) | 3224 IntRect FrameView::adjustScrollbarRectForResizer(const IntRect& rect, Scrollbar*
scrollbar) |
3257 { | 3225 { |
3258 // Get our window resizer rect and see if we overlap. Adjust to avoid the ov
erlap | 3226 // Get our window resizer rect and see if we overlap. Adjust to avoid the ov
erlap |
3259 // if necessary. | 3227 // if necessary. |
3260 IntRect adjustedRect(rect); | 3228 IntRect adjustedRect(rect); |
3261 bool overlapsResizer = false; | 3229 bool overlapsResizer = false; |
3262 if (!rect.isEmpty() && !windowResizerRect().isEmpty()) { | 3230 if (!rect.isEmpty() && !windowResizerRect().isEmpty()) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3345 setHasHorizontalScrollbar(false); | 3313 setHasHorizontalScrollbar(false); |
3346 setHasVerticalScrollbar(false); | 3314 setHasVerticalScrollbar(false); |
3347 setScrollOffsetFromUpdateScrollbars(desiredOffset); | 3315 setScrollOffsetFromUpdateScrollbars(desiredOffset); |
3348 return; | 3316 return; |
3349 } | 3317 } |
3350 | 3318 |
3351 if (m_inUpdateScrollbars) | 3319 if (m_inUpdateScrollbars) |
3352 return; | 3320 return; |
3353 InUpdateScrollbarsScope inUpdateScrollbarsScope(this); | 3321 InUpdateScrollbarsScope inUpdateScrollbarsScope(this); |
3354 | 3322 |
3355 IntSize oldVisibleSize = visibleContentSize(); | |
3356 | |
3357 bool scrollbarExistenceChanged = false; | 3323 bool scrollbarExistenceChanged = false; |
3358 | 3324 |
3359 if (needsScrollbarReconstruction()) { | 3325 if (needsScrollbarReconstruction()) { |
3360 setHasHorizontalScrollbar(false); | 3326 setHasHorizontalScrollbar(false); |
3361 setHasVerticalScrollbar(false); | 3327 setHasVerticalScrollbar(false); |
3362 scrollbarExistenceChanged = true; | 3328 scrollbarExistenceChanged = true; |
3363 } | 3329 } |
3364 | 3330 |
3365 int maxUpdateScrollbarsPass = hasOverlayScrollbars() || m_scrollbarsSuppress
ed ? 1 : 3; | 3331 int maxUpdateScrollbarsPass = hasOverlayScrollbars() || m_scrollbarsSuppress
ed ? 1 : 3; |
3366 for (int updateScrollbarsPass = 0; updateScrollbarsPass < maxUpdateScrollbar
sPass; updateScrollbarsPass++) { | 3332 for (int updateScrollbarsPass = 0; updateScrollbarsPass < maxUpdateScrollbar
sPass; updateScrollbarsPass++) { |
3367 if (!adjustScrollbarExistence(updateScrollbarsPass ? Incremental : First
Pass)) | 3333 if (!adjustScrollbarExistence(updateScrollbarsPass ? Incremental : First
Pass)) |
3368 break; | 3334 break; |
3369 scrollbarExistenceChanged = true; | 3335 scrollbarExistenceChanged = true; |
3370 } | 3336 } |
3371 | 3337 |
3372 updateScrollbarGeometry(); | 3338 updateScrollbarGeometry(); |
3373 | 3339 |
3374 if (scrollbarExistenceChanged) { | 3340 if (scrollbarExistenceChanged) { |
3375 // FIXME: Is frameRectsChanged really necessary here? Have any frame rec
ts changed? | 3341 // FIXME: Is frameRectsChanged really necessary here? Have any frame rec
ts changed? |
3376 frameRectsChanged(); | 3342 frameRectsChanged(); |
3377 positionScrollbarLayers(); | 3343 positionScrollbarLayers(); |
3378 updateScrollCorner(); | 3344 updateScrollCorner(); |
3379 } | 3345 } |
3380 | 3346 |
3381 // FIXME: We don't need to do this if we are composited. | |
3382 IntSize newVisibleSize = visibleContentSize(); | |
3383 if (newVisibleSize.width() > oldVisibleSize.width()) { | |
3384 if (shouldPlaceVerticalScrollbarOnLeft()) | |
3385 invalidateRect(IntRect(0, 0, newVisibleSize.width() - oldVisibleSize
.width(), newVisibleSize.height())); | |
3386 else | |
3387 invalidateRect(IntRect(oldVisibleSize.width(), 0, newVisibleSize.wid
th() - oldVisibleSize.width(), newVisibleSize.height())); | |
3388 } | |
3389 if (newVisibleSize.height() > oldVisibleSize.height()) | |
3390 invalidateRect(IntRect(0, oldVisibleSize.height(), newVisibleSize.width(
), newVisibleSize.height() - oldVisibleSize.height())); | |
3391 | |
3392 setScrollOffsetFromUpdateScrollbars(desiredOffset); | 3347 setScrollOffsetFromUpdateScrollbars(desiredOffset); |
3393 } | 3348 } |
3394 | 3349 |
3395 void FrameView::setScrollOffsetFromUpdateScrollbars(const DoubleSize& offset) | 3350 void FrameView::setScrollOffsetFromUpdateScrollbars(const DoubleSize& offset) |
3396 { | 3351 { |
3397 DoublePoint adjustedScrollPosition = clampScrollPosition(DoublePoint(offset)
); | 3352 DoublePoint adjustedScrollPosition = clampScrollPosition(DoublePoint(offset)
); |
3398 | 3353 |
3399 if (adjustedScrollPosition != scrollPositionDouble() || scrollOriginChanged(
)) { | 3354 if (adjustedScrollPosition != scrollPositionDouble() || scrollOriginChanged(
)) { |
3400 ScrollableArea::setScrollPosition(adjustedScrollPosition, ProgrammaticSc
roll); | 3355 ScrollableArea::setScrollPosition(adjustedScrollPosition, ProgrammaticSc
roll); |
3401 resetScrollOriginChanged(); | 3356 resetScrollOriginChanged(); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3562 } else if (!scrollbarsSuppressed()) { | 3517 } else if (!scrollbarsSuppressed()) { |
3563 // If we went from n to 0 or from 0 to n and we're the outermost view, | 3518 // If we went from n to 0 or from 0 to n and we're the outermost view, |
3564 // we need to invalidate the windowResizerRect(), since it will now need
to paint | 3519 // we need to invalidate the windowResizerRect(), since it will now need
to paint |
3565 // differently. | 3520 // differently. |
3566 if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) | 3521 if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) |
3567 || (oldCount == 0 && m_scrollbarsAvoidingResizer > 0)) | 3522 || (oldCount == 0 && m_scrollbarsAvoidingResizer > 0)) |
3568 invalidateRect(windowResizerRect()); | 3523 invalidateRect(windowResizerRect()); |
3569 } | 3524 } |
3570 } | 3525 } |
3571 | 3526 |
3572 void FrameView::setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppres
s) | |
3573 { | |
3574 if (suppressed == m_scrollbarsSuppressed) | |
3575 return; | |
3576 | |
3577 m_scrollbarsSuppressed = suppressed; | |
3578 | |
3579 if (repaintOnUnsuppress && !suppressed) { | |
3580 if (m_horizontalScrollbar) | |
3581 m_horizontalScrollbar->invalidate(); | |
3582 if (m_verticalScrollbar) | |
3583 m_verticalScrollbar->invalidate(); | |
3584 | |
3585 // Invalidate the scroll corner too on unsuppress. | |
3586 invalidateScrollCorner(scrollCornerRect()); | |
3587 } | |
3588 } | |
3589 | |
3590 Scrollbar* FrameView::scrollbarAtRootFramePoint(const IntPoint& pointInRootFrame
) | 3527 Scrollbar* FrameView::scrollbarAtRootFramePoint(const IntPoint& pointInRootFrame
) |
3591 { | 3528 { |
3592 IntPoint pointInFrame = convertFromContainingWindow(pointInRootFrame); | 3529 IntPoint pointInFrame = convertFromContainingWindow(pointInRootFrame); |
3593 return scrollbarAtFramePoint(pointInFrame); | 3530 return scrollbarAtFramePoint(pointInFrame); |
3594 } | 3531 } |
3595 | 3532 |
3596 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame) | 3533 Scrollbar* FrameView::scrollbarAtFramePoint(const IntPoint& pointInFrame) |
3597 { | 3534 { |
3598 if (m_horizontalScrollbar && m_horizontalScrollbar->shouldParticipateInHitTe
sting() && m_horizontalScrollbar->frameRect().contains(pointInFrame)) | 3535 if (m_horizontalScrollbar && m_horizontalScrollbar->shouldParticipateInHitTe
sting() && m_horizontalScrollbar->frameRect().contains(pointInFrame)) |
3599 return m_horizontalScrollbar.get(); | 3536 return m_horizontalScrollbar.get(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3699 } | 3636 } |
3700 | 3637 |
3701 return cornerRect; | 3638 return cornerRect; |
3702 } | 3639 } |
3703 | 3640 |
3704 bool FrameView::isScrollCornerVisible() const | 3641 bool FrameView::isScrollCornerVisible() const |
3705 { | 3642 { |
3706 return !scrollCornerRect().isEmpty(); | 3643 return !scrollCornerRect().isEmpty(); |
3707 } | 3644 } |
3708 | 3645 |
3709 void FrameView::invalidateScrollCornerRect(const IntRect& rect) | |
3710 { | |
3711 invalidateRect(rect); | |
3712 if (m_scrollCorner) | |
3713 layoutView()->invalidateDisplayItemClientForNonCompositingDescendantsOf(
*m_scrollCorner); | |
3714 } | |
3715 | |
3716 ScrollBehavior FrameView::scrollBehaviorStyle() const | 3646 ScrollBehavior FrameView::scrollBehaviorStyle() const |
3717 { | 3647 { |
3718 Element* scrollElement = m_frame->document()->scrollingElement(); | 3648 Element* scrollElement = m_frame->document()->scrollingElement(); |
3719 LayoutObject* layoutObject = scrollElement ? scrollElement->layoutObject() :
nullptr; | 3649 LayoutObject* layoutObject = scrollElement ? scrollElement->layoutObject() :
nullptr; |
3720 if (layoutObject && layoutObject->style()->scrollBehavior() == ScrollBehavio
rSmooth) | 3650 if (layoutObject && layoutObject->style()->scrollBehavior() == ScrollBehavio
rSmooth) |
3721 return ScrollBehaviorSmooth; | 3651 return ScrollBehaviorSmooth; |
3722 | 3652 |
3723 return ScrollBehaviorInstant; | 3653 return ScrollBehaviorInstant; |
3724 } | 3654 } |
3725 | 3655 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4040 return canThrottleRendering() && lifecycle().throttlingAllowed(); | 3970 return canThrottleRendering() && lifecycle().throttlingAllowed(); |
4041 } | 3971 } |
4042 | 3972 |
4043 bool FrameView::canThrottleRendering() const | 3973 bool FrameView::canThrottleRendering() const |
4044 { | 3974 { |
4045 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) | 3975 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) |
4046 return false; | 3976 return false; |
4047 return m_hiddenForThrottling && m_crossOriginForThrottling; | 3977 return m_hiddenForThrottling && m_crossOriginForThrottling; |
4048 } | 3978 } |
4049 | 3979 |
| 3980 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const |
| 3981 { |
| 3982 ASSERT(layoutView()); |
| 3983 return *layoutView(); |
| 3984 } |
| 3985 |
4050 } // namespace blink | 3986 } // namespace blink |
OLD | NEW |