OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. |
3 * | 3 * |
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
5 * | 5 * |
6 * Other contributors: | 6 * Other contributors: |
7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 192 } |
193 | 193 |
194 GraphicsLayer* PaintLayerScrollableArea::layerForScrollCorner() const | 194 GraphicsLayer* PaintLayerScrollableArea::layerForScrollCorner() const |
195 { | 195 { |
196 // See crbug.com/343132. | 196 // See crbug.com/343132. |
197 DisableCompositingQueryAsserts disabler; | 197 DisableCompositingQueryAsserts disabler; |
198 | 198 |
199 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin
g()->layerForScrollCorner() : 0; | 199 return layer()->hasCompositedLayerMapping() ? layer()->compositedLayerMappin
g()->layerForScrollCorner() : 0; |
200 } | 200 } |
201 | 201 |
202 void PaintLayerScrollableArea::invalidateScrollbarRect(Scrollbar* scrollbar, con
st IntRect& rect) | 202 void PaintLayerScrollableArea::scrollControlWasSetNeedsPaintInvalidation() |
203 { | 203 { |
204 // See crbug.com/343132. | 204 box().setMayNeedPaintInvalidation(); |
205 DisableCompositingQueryAsserts disabler; | |
206 | |
207 ASSERT(scrollbar == horizontalScrollbar() || scrollbar == verticalScrollbar(
)); | |
208 ASSERT(scrollbar == horizontalScrollbar() ? !layerForHorizontalScrollbar() :
!layerForVerticalScrollbar()); | |
209 | |
210 IntRect scrollRect = rect; | |
211 // If we are not yet inserted into the tree, there is no need to issue paint
invaldiations. | |
212 if (!box().isLayoutView() && !box().parent()) | |
213 return; | |
214 | |
215 if (scrollbar == verticalScrollbar()) | |
216 scrollRect.move(verticalScrollbarStart(0, box().size().width()), box().b
orderTop()); | |
217 else | |
218 scrollRect.move(horizontalScrollbarStart(0), box().size().height() - box
().borderBottom() - scrollbar->height()); | |
219 | |
220 if (scrollRect.isEmpty()) | |
221 return; | |
222 | |
223 LayoutRect paintInvalidationRect = LayoutRect(scrollRect); | |
224 box().flipForWritingMode(paintInvalidationRect); | |
225 | |
226 IntRect intRect = pixelSnappedIntRect(paintInvalidationRect); | |
227 | |
228 if (box().frameView()->isInPerformLayout()) { | |
229 addScrollbarDamage(scrollbar, intRect); | |
230 } else { | |
231 // FIXME: We should not allow paint invalidation out of paint invalidati
on state. crbug.com/457415 | |
232 DisablePaintInvalidationStateAsserts disabler; | |
233 // We have invalidated the displayItemClient of the scrollbar, but for n
ow we still need to | |
234 // invalidate the rectangles to trigger repaints. | |
235 box().invalidatePaintRectangleNotInvalidatingDisplayItemClients(LayoutRe
ct(intRect)); | |
236 box().invalidateDisplayItemClient(*scrollbar); | |
237 } | |
238 } | |
239 | |
240 void PaintLayerScrollableArea::invalidateScrollCornerRect(const IntRect& rect) | |
241 { | |
242 ASSERT(!layerForScrollCorner()); | |
243 | |
244 if (m_scrollCorner) { | |
245 // FIXME: We should not allow paint invalidation out of paint invalidati
on state. crbug.com/457415 | |
246 DisablePaintInvalidationStateAsserts disabler; | |
247 DisableCompositingQueryAsserts compositingDisabler; | |
248 m_scrollCorner->invalidatePaintRectangle(LayoutRect(rect)); | |
249 box().invalidateDisplayItemClientForNonCompositingDescendantsOf(*m_scrol
lCorner); | |
250 } else { | |
251 box().invalidateDisplayItemClient(box()); | |
252 } | |
253 if (m_resizer) { | |
254 m_resizer->invalidatePaintRectangle(LayoutRect(rect)); | |
255 box().invalidateDisplayItemClientForNonCompositingDescendantsOf(*m_resiz
er); | |
256 } | |
257 } | 205 } |
258 | 206 |
259 bool PaintLayerScrollableArea::shouldUseIntegerScrollOffset() const | 207 bool PaintLayerScrollableArea::shouldUseIntegerScrollOffset() const |
260 { | 208 { |
261 Frame* frame = box().frame(); | 209 Frame* frame = box().frame(); |
262 if (frame->settings() && !frame->settings()->preferCompositingToLCDTextEnabl
ed()) | 210 if (frame->settings() && !frame->settings()->preferCompositingToLCDTextEnabl
ed()) |
263 return true; | 211 return true; |
264 | 212 |
265 return ScrollableArea::shouldUseIntegerScrollOffset(); | 213 return ScrollableArea::shouldUseIntegerScrollOffset(); |
266 } | 214 } |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 } | 977 } |
1030 | 978 |
1031 return hasAnyScrollbar && ((shouldUseCustom != hasCustom) || (shouldUseCusto
m && didCustomScrollbarOwnerChanged)); | 979 return hasAnyScrollbar && ((shouldUseCustom != hasCustom) || (shouldUseCusto
m && didCustomScrollbarOwnerChanged)); |
1032 } | 980 } |
1033 | 981 |
1034 void PaintLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) | 982 void PaintLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) |
1035 { | 983 { |
1036 if (hasScrollbar == hasHorizontalScrollbar()) | 984 if (hasScrollbar == hasHorizontalScrollbar()) |
1037 return; | 985 return; |
1038 | 986 |
1039 if (!hasScrollbar && !layerForHorizontalScrollbar()) | 987 setScrollbarNeedsPaintInvalidation(horizontalScrollbar()); |
1040 horizontalScrollbar()->invalidate(); | 988 |
1041 | 989 |
1042 m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); | 990 m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); |
1043 | 991 |
1044 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. | 992 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. |
1045 if (hasHorizontalScrollbar()) | 993 if (hasHorizontalScrollbar()) |
1046 horizontalScrollbar()->styleChanged(); | 994 horizontalScrollbar()->styleChanged(); |
1047 if (hasVerticalScrollbar()) | 995 if (hasVerticalScrollbar()) |
1048 verticalScrollbar()->styleChanged(); | 996 verticalScrollbar()->styleChanged(); |
1049 | 997 |
1050 // These are valid because we want to invalidate display item clients on the
current backing. | 998 setScrollCornerNeedsPaintInvalidation(); |
1051 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; | |
1052 DisableCompositingQueryAsserts compositingAssertDisabler; | |
1053 invalidateScrollCorner(scrollCornerRect()); | |
1054 | 999 |
1055 // Force an update since we know the scrollbars have changed things. | 1000 // Force an update since we know the scrollbars have changed things. |
1056 if (box().document().hasAnnotatedRegions()) | 1001 if (box().document().hasAnnotatedRegions()) |
1057 box().document().setAnnotatedRegionsDirty(true); | 1002 box().document().setAnnotatedRegionsDirty(true); |
1058 } | 1003 } |
1059 | 1004 |
1060 void PaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) | 1005 void PaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) |
1061 { | 1006 { |
1062 if (hasScrollbar == hasVerticalScrollbar()) | 1007 if (hasScrollbar == hasVerticalScrollbar()) |
1063 return; | 1008 return; |
1064 | 1009 |
1065 if (!hasScrollbar && !layerForVerticalScrollbar()) | 1010 setScrollbarNeedsPaintInvalidation(verticalScrollbar()); |
1066 verticalScrollbar()->invalidate(); | |
1067 | 1011 |
1068 m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); | 1012 m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); |
1069 | 1013 |
1070 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. | 1014 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. |
1071 if (hasHorizontalScrollbar()) | 1015 if (hasHorizontalScrollbar()) |
1072 horizontalScrollbar()->styleChanged(); | 1016 horizontalScrollbar()->styleChanged(); |
1073 if (hasVerticalScrollbar()) | 1017 if (hasVerticalScrollbar()) |
1074 verticalScrollbar()->styleChanged(); | 1018 verticalScrollbar()->styleChanged(); |
1075 | 1019 |
1076 // These are valid because we want to invalidate display item clients on the
current backing. | 1020 setScrollCornerNeedsPaintInvalidation(); |
1077 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; | |
1078 DisableCompositingQueryAsserts compositingAssertDisabler; | |
1079 invalidateScrollCorner(scrollCornerRect()); | |
1080 | 1021 |
1081 // Force an update since we know the scrollbars have changed things. | 1022 // Force an update since we know the scrollbars have changed things. |
1082 if (box().document().hasAnnotatedRegions()) | 1023 if (box().document().hasAnnotatedRegions()) |
1083 box().document().setAnnotatedRegionsDirty(true); | 1024 box().document().setAnnotatedRegionsDirty(true); |
1084 } | 1025 } |
1085 | 1026 |
1086 int PaintLayerScrollableArea::verticalScrollbarWidth(OverlayScrollbarSizeRelevan
cy relevancy) const | 1027 int PaintLayerScrollableArea::verticalScrollbarWidth(OverlayScrollbarSizeRelevan
cy relevancy) const |
1087 { | 1028 { |
1088 if (!hasVerticalScrollbar() || (verticalScrollbar()->isOverlayScrollbar() &&
(relevancy == IgnoreOverlayScrollbarSize || !verticalScrollbar()->shouldPartici
pateInHitTesting()))) | 1029 if (!hasVerticalScrollbar() || (verticalScrollbar()->isOverlayScrollbar() &&
(relevancy == IgnoreOverlayScrollbarSize || !verticalScrollbar()->shouldPartici
pateInHitTesting()))) |
1089 return 0; | 1030 return 0; |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 destroyScrollbar(VerticalScrollbar); | 1432 destroyScrollbar(VerticalScrollbar); |
1492 } | 1433 } |
1493 | 1434 |
1494 void PaintLayerScrollableArea::ScrollbarManager::setCanDetachScrollbars(bool det
ach) | 1435 void PaintLayerScrollableArea::ScrollbarManager::setCanDetachScrollbars(bool det
ach) |
1495 { | 1436 { |
1496 ASSERT(!m_hBarIsAttached || m_hBar); | 1437 ASSERT(!m_hBarIsAttached || m_hBar); |
1497 ASSERT(!m_vBarIsAttached || m_vBar); | 1438 ASSERT(!m_vBarIsAttached || m_vBar); |
1498 m_canDetachScrollbars = detach ? 1 : 0; | 1439 m_canDetachScrollbars = detach ? 1 : 0; |
1499 if (!detach) { | 1440 if (!detach) { |
1500 if (m_hBar && !m_hBarIsAttached) | 1441 if (m_hBar && !m_hBarIsAttached) |
1501 destroyScrollbar(HorizontalScrollbar, true); | 1442 destroyScrollbar(HorizontalScrollbar); |
1502 if (m_vBar && !m_vBarIsAttached) | 1443 if (m_vBar && !m_vBarIsAttached) |
1503 destroyScrollbar(VerticalScrollbar, true); | 1444 destroyScrollbar(VerticalScrollbar); |
1504 } | 1445 } |
1505 } | 1446 } |
1506 | 1447 |
1507 void PaintLayerScrollableArea::ScrollbarManager::setHasHorizontalScrollbar(bool
hasScrollbar) | 1448 void PaintLayerScrollableArea::ScrollbarManager::setHasHorizontalScrollbar(bool
hasScrollbar) |
1508 { | 1449 { |
1509 if (hasScrollbar) { | 1450 if (hasScrollbar) { |
1510 // This doesn't hit in any tests, but since the equivalent code in setHa
sVerticalScrollbar | 1451 // This doesn't hit in any tests, but since the equivalent code in setHa
sVerticalScrollbar |
1511 // does, presumably this code does as well. | 1452 // does, presumably this code does as well. |
1512 DisableCompositingQueryAsserts disabler; | 1453 DisableCompositingQueryAsserts disabler; |
1513 if (!m_hBar) | 1454 if (!m_hBar) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 widget = Scrollbar::create(m_scrollableArea.get(), orientation, scrollba
rSize); | 1490 widget = Scrollbar::create(m_scrollableArea.get(), orientation, scrollba
rSize); |
1550 if (orientation == HorizontalScrollbar) | 1491 if (orientation == HorizontalScrollbar) |
1551 m_scrollableArea->didAddScrollbar(widget.get(), HorizontalScrollbar)
; | 1492 m_scrollableArea->didAddScrollbar(widget.get(), HorizontalScrollbar)
; |
1552 else | 1493 else |
1553 m_scrollableArea->didAddScrollbar(widget.get(), VerticalScrollbar); | 1494 m_scrollableArea->didAddScrollbar(widget.get(), VerticalScrollbar); |
1554 } | 1495 } |
1555 m_scrollableArea->box().document().view()->addChild(widget.get()); | 1496 m_scrollableArea->box().document().view()->addChild(widget.get()); |
1556 return widget.release(); | 1497 return widget.release(); |
1557 } | 1498 } |
1558 | 1499 |
1559 void PaintLayerScrollableArea::ScrollbarManager::destroyScrollbar(ScrollbarOrien
tation orientation, bool invalidate) | 1500 void PaintLayerScrollableArea::ScrollbarManager::destroyScrollbar(ScrollbarOrien
tation orientation) |
1560 { | 1501 { |
1561 RefPtrWillBeMember<Scrollbar>& scrollbar = orientation == HorizontalScrollba
r ? m_hBar : m_vBar; | 1502 RefPtrWillBeMember<Scrollbar>& scrollbar = orientation == HorizontalScrollba
r ? m_hBar : m_vBar; |
1562 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached: !m_vBarIsAtta
ched); | 1503 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached: !m_vBarIsAtta
ched); |
1563 if (!scrollbar) | 1504 if (!scrollbar) |
1564 return; | 1505 return; |
1565 | 1506 |
1566 if (invalidate) { | 1507 m_scrollableArea->setScrollbarNeedsPaintInvalidation(scrollbar.get()); |
1567 m_scrollableArea->box().invalidateDisplayItemClient(*scrollbar); | 1508 |
1568 scrollbar->invalidate(); | |
1569 } | |
1570 if (!scrollbar->isCustomScrollbar()) | 1509 if (!scrollbar->isCustomScrollbar()) |
1571 m_scrollableArea->willRemoveScrollbar(scrollbar.get(), orientation); | 1510 m_scrollableArea->willRemoveScrollbar(scrollbar.get(), orientation); |
1572 | 1511 |
1573 toFrameView(scrollbar->parent())->removeChild(scrollbar.get()); | 1512 toFrameView(scrollbar->parent())->removeChild(scrollbar.get()); |
1574 scrollbar->disconnectFromScrollableArea(); | 1513 scrollbar->disconnectFromScrollableArea(); |
1575 scrollbar = nullptr; | 1514 scrollbar = nullptr; |
1576 } | 1515 } |
1577 | 1516 |
1578 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) | 1517 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) |
1579 { | 1518 { |
1580 visitor->trace(m_scrollableArea); | 1519 visitor->trace(m_scrollableArea); |
1581 visitor->trace(m_hBar); | 1520 visitor->trace(m_hBar); |
1582 visitor->trace(m_vBar); | 1521 visitor->trace(m_vBar); |
1583 } | 1522 } |
1584 | 1523 |
1585 } // namespace blink | 1524 } // namespace blink |
OLD | NEW |