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::scrollControlWasSetNeedsPaintInvalidation() | 202 void PaintLayerScrollableArea::invalidateScrollbarRect(Scrollbar* scrollbar, con
st IntRect& rect) |
203 { | 203 { |
204 box().setMayNeedPaintInvalidation(); | 204 // See crbug.com/343132. |
| 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 } |
205 } | 257 } |
206 | 258 |
207 bool PaintLayerScrollableArea::shouldUseIntegerScrollOffset() const | 259 bool PaintLayerScrollableArea::shouldUseIntegerScrollOffset() const |
208 { | 260 { |
209 Frame* frame = box().frame(); | 261 Frame* frame = box().frame(); |
210 if (frame->settings() && !frame->settings()->preferCompositingToLCDTextEnabl
ed()) | 262 if (frame->settings() && !frame->settings()->preferCompositingToLCDTextEnabl
ed()) |
211 return true; | 263 return true; |
212 | 264 |
213 return ScrollableArea::shouldUseIntegerScrollOffset(); | 265 return ScrollableArea::shouldUseIntegerScrollOffset(); |
214 } | 266 } |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 } | 1029 } |
978 | 1030 |
979 return hasAnyScrollbar && ((shouldUseCustom != hasCustom) || (shouldUseCusto
m && didCustomScrollbarOwnerChanged)); | 1031 return hasAnyScrollbar && ((shouldUseCustom != hasCustom) || (shouldUseCusto
m && didCustomScrollbarOwnerChanged)); |
980 } | 1032 } |
981 | 1033 |
982 void PaintLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) | 1034 void PaintLayerScrollableArea::setHasHorizontalScrollbar(bool hasScrollbar) |
983 { | 1035 { |
984 if (hasScrollbar == hasHorizontalScrollbar()) | 1036 if (hasScrollbar == hasHorizontalScrollbar()) |
985 return; | 1037 return; |
986 | 1038 |
987 setScrollbarNeedsPaintInvalidation(horizontalScrollbar()); | 1039 if (!hasScrollbar && !layerForHorizontalScrollbar()) |
988 | 1040 horizontalScrollbar()->invalidate(); |
989 | 1041 |
990 m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); | 1042 m_scrollbarManager.setHasHorizontalScrollbar(hasScrollbar); |
991 | 1043 |
992 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. | 1044 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. |
993 if (hasHorizontalScrollbar()) | 1045 if (hasHorizontalScrollbar()) |
994 horizontalScrollbar()->styleChanged(); | 1046 horizontalScrollbar()->styleChanged(); |
995 if (hasVerticalScrollbar()) | 1047 if (hasVerticalScrollbar()) |
996 verticalScrollbar()->styleChanged(); | 1048 verticalScrollbar()->styleChanged(); |
997 | 1049 |
998 setScrollCornerNeedsPaintInvalidation(); | 1050 // These are valid because we want to invalidate display item clients on the
current backing. |
| 1051 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; |
| 1052 DisableCompositingQueryAsserts compositingAssertDisabler; |
| 1053 invalidateScrollCorner(scrollCornerRect()); |
999 | 1054 |
1000 // Force an update since we know the scrollbars have changed things. | 1055 // Force an update since we know the scrollbars have changed things. |
1001 if (box().document().hasAnnotatedRegions()) | 1056 if (box().document().hasAnnotatedRegions()) |
1002 box().document().setAnnotatedRegionsDirty(true); | 1057 box().document().setAnnotatedRegionsDirty(true); |
1003 } | 1058 } |
1004 | 1059 |
1005 void PaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) | 1060 void PaintLayerScrollableArea::setHasVerticalScrollbar(bool hasScrollbar) |
1006 { | 1061 { |
1007 if (hasScrollbar == hasVerticalScrollbar()) | 1062 if (hasScrollbar == hasVerticalScrollbar()) |
1008 return; | 1063 return; |
1009 | 1064 |
1010 setScrollbarNeedsPaintInvalidation(verticalScrollbar()); | 1065 if (!hasScrollbar && !layerForVerticalScrollbar()) |
| 1066 verticalScrollbar()->invalidate(); |
1011 | 1067 |
1012 m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); | 1068 m_scrollbarManager.setHasVerticalScrollbar(hasScrollbar); |
1013 | 1069 |
1014 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. | 1070 // Destroying or creating one bar can cause our scrollbar corner to come and
go. We need to update the opposite scrollbar's style. |
1015 if (hasHorizontalScrollbar()) | 1071 if (hasHorizontalScrollbar()) |
1016 horizontalScrollbar()->styleChanged(); | 1072 horizontalScrollbar()->styleChanged(); |
1017 if (hasVerticalScrollbar()) | 1073 if (hasVerticalScrollbar()) |
1018 verticalScrollbar()->styleChanged(); | 1074 verticalScrollbar()->styleChanged(); |
1019 | 1075 |
1020 setScrollCornerNeedsPaintInvalidation(); | 1076 // These are valid because we want to invalidate display item clients on the
current backing. |
| 1077 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; |
| 1078 DisableCompositingQueryAsserts compositingAssertDisabler; |
| 1079 invalidateScrollCorner(scrollCornerRect()); |
1021 | 1080 |
1022 // Force an update since we know the scrollbars have changed things. | 1081 // Force an update since we know the scrollbars have changed things. |
1023 if (box().document().hasAnnotatedRegions()) | 1082 if (box().document().hasAnnotatedRegions()) |
1024 box().document().setAnnotatedRegionsDirty(true); | 1083 box().document().setAnnotatedRegionsDirty(true); |
1025 } | 1084 } |
1026 | 1085 |
1027 int PaintLayerScrollableArea::verticalScrollbarWidth(OverlayScrollbarSizeRelevan
cy relevancy) const | 1086 int PaintLayerScrollableArea::verticalScrollbarWidth(OverlayScrollbarSizeRelevan
cy relevancy) const |
1028 { | 1087 { |
1029 if (!hasVerticalScrollbar() || (verticalScrollbar()->isOverlayScrollbar() &&
(relevancy == IgnoreOverlayScrollbarSize || !verticalScrollbar()->shouldPartici
pateInHitTesting()))) | 1088 if (!hasVerticalScrollbar() || (verticalScrollbar()->isOverlayScrollbar() &&
(relevancy == IgnoreOverlayScrollbarSize || !verticalScrollbar()->shouldPartici
pateInHitTesting()))) |
1030 return 0; | 1089 return 0; |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 destroyScrollbar(VerticalScrollbar); | 1491 destroyScrollbar(VerticalScrollbar); |
1433 } | 1492 } |
1434 | 1493 |
1435 void PaintLayerScrollableArea::ScrollbarManager::setCanDetachScrollbars(bool det
ach) | 1494 void PaintLayerScrollableArea::ScrollbarManager::setCanDetachScrollbars(bool det
ach) |
1436 { | 1495 { |
1437 ASSERT(!m_hBarIsAttached || m_hBar); | 1496 ASSERT(!m_hBarIsAttached || m_hBar); |
1438 ASSERT(!m_vBarIsAttached || m_vBar); | 1497 ASSERT(!m_vBarIsAttached || m_vBar); |
1439 m_canDetachScrollbars = detach ? 1 : 0; | 1498 m_canDetachScrollbars = detach ? 1 : 0; |
1440 if (!detach) { | 1499 if (!detach) { |
1441 if (m_hBar && !m_hBarIsAttached) | 1500 if (m_hBar && !m_hBarIsAttached) |
1442 destroyScrollbar(HorizontalScrollbar); | 1501 destroyScrollbar(HorizontalScrollbar, true); |
1443 if (m_vBar && !m_vBarIsAttached) | 1502 if (m_vBar && !m_vBarIsAttached) |
1444 destroyScrollbar(VerticalScrollbar); | 1503 destroyScrollbar(VerticalScrollbar, true); |
1445 } | 1504 } |
1446 } | 1505 } |
1447 | 1506 |
1448 void PaintLayerScrollableArea::ScrollbarManager::setHasHorizontalScrollbar(bool
hasScrollbar) | 1507 void PaintLayerScrollableArea::ScrollbarManager::setHasHorizontalScrollbar(bool
hasScrollbar) |
1449 { | 1508 { |
1450 if (hasScrollbar) { | 1509 if (hasScrollbar) { |
1451 // This doesn't hit in any tests, but since the equivalent code in setHa
sVerticalScrollbar | 1510 // This doesn't hit in any tests, but since the equivalent code in setHa
sVerticalScrollbar |
1452 // does, presumably this code does as well. | 1511 // does, presumably this code does as well. |
1453 DisableCompositingQueryAsserts disabler; | 1512 DisableCompositingQueryAsserts disabler; |
1454 if (!m_hBar) | 1513 if (!m_hBar) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 widget = Scrollbar::create(m_scrollableArea.get(), orientation, scrollba
rSize); | 1549 widget = Scrollbar::create(m_scrollableArea.get(), orientation, scrollba
rSize); |
1491 if (orientation == HorizontalScrollbar) | 1550 if (orientation == HorizontalScrollbar) |
1492 m_scrollableArea->didAddScrollbar(widget.get(), HorizontalScrollbar)
; | 1551 m_scrollableArea->didAddScrollbar(widget.get(), HorizontalScrollbar)
; |
1493 else | 1552 else |
1494 m_scrollableArea->didAddScrollbar(widget.get(), VerticalScrollbar); | 1553 m_scrollableArea->didAddScrollbar(widget.get(), VerticalScrollbar); |
1495 } | 1554 } |
1496 m_scrollableArea->box().document().view()->addChild(widget.get()); | 1555 m_scrollableArea->box().document().view()->addChild(widget.get()); |
1497 return widget.release(); | 1556 return widget.release(); |
1498 } | 1557 } |
1499 | 1558 |
1500 void PaintLayerScrollableArea::ScrollbarManager::destroyScrollbar(ScrollbarOrien
tation orientation) | 1559 void PaintLayerScrollableArea::ScrollbarManager::destroyScrollbar(ScrollbarOrien
tation orientation, bool invalidate) |
1501 { | 1560 { |
1502 RefPtrWillBeMember<Scrollbar>& scrollbar = orientation == HorizontalScrollba
r ? m_hBar : m_vBar; | 1561 RefPtrWillBeMember<Scrollbar>& scrollbar = orientation == HorizontalScrollba
r ? m_hBar : m_vBar; |
1503 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached: !m_vBarIsAtta
ched); | 1562 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached: !m_vBarIsAtta
ched); |
1504 if (!scrollbar) | 1563 if (!scrollbar) |
1505 return; | 1564 return; |
1506 | 1565 |
1507 m_scrollableArea->setScrollbarNeedsPaintInvalidation(scrollbar.get()); | 1566 if (invalidate) { |
1508 | 1567 m_scrollableArea->box().invalidateDisplayItemClient(*scrollbar); |
| 1568 scrollbar->invalidate(); |
| 1569 } |
1509 if (!scrollbar->isCustomScrollbar()) | 1570 if (!scrollbar->isCustomScrollbar()) |
1510 m_scrollableArea->willRemoveScrollbar(scrollbar.get(), orientation); | 1571 m_scrollableArea->willRemoveScrollbar(scrollbar.get(), orientation); |
1511 | 1572 |
1512 toFrameView(scrollbar->parent())->removeChild(scrollbar.get()); | 1573 toFrameView(scrollbar->parent())->removeChild(scrollbar.get()); |
1513 scrollbar->disconnectFromScrollableArea(); | 1574 scrollbar->disconnectFromScrollableArea(); |
1514 scrollbar = nullptr; | 1575 scrollbar = nullptr; |
1515 } | 1576 } |
1516 | 1577 |
1517 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) | 1578 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) |
1518 { | 1579 { |
1519 visitor->trace(m_scrollableArea); | 1580 visitor->trace(m_scrollableArea); |
1520 visitor->trace(m_hBar); | 1581 visitor->trace(m_hBar); |
1521 visitor->trace(m_vBar); | 1582 visitor->trace(m_vBar); |
1522 } | 1583 } |
1523 | 1584 |
1524 } // namespace blink | 1585 } // namespace blink |
OLD | NEW |