| 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@gmail.com> | 9 * Christian Biesinger <cbiesinger@gmail.com> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 827 |
| 828 // FIXME: Need to detect a swap from custom to native scrollbars (and vice v
ersa). | 828 // FIXME: Need to detect a swap from custom to native scrollbars (and vice v
ersa). |
| 829 if (horizontalScrollbar()) | 829 if (horizontalScrollbar()) |
| 830 horizontalScrollbar()->styleChanged(); | 830 horizontalScrollbar()->styleChanged(); |
| 831 if (verticalScrollbar()) | 831 if (verticalScrollbar()) |
| 832 verticalScrollbar()->styleChanged(); | 832 verticalScrollbar()->styleChanged(); |
| 833 | 833 |
| 834 updateScrollCornerStyle(); | 834 updateScrollCornerStyle(); |
| 835 updateResizerAreaSet(); | 835 updateResizerAreaSet(); |
| 836 updateResizerStyle(); | 836 updateResizerStyle(); |
| 837 |
| 838 // Whenever background changes on the scrollable element, the scroll bar |
| 839 // overlay style might need to be changed to have contrast against the |
| 840 // background. |
| 841 Color oldBackground; |
| 842 if (oldStyle) { |
| 843 oldBackground = oldStyle->visitedDependentColor(CSSPropertyBackgroundCol
or); |
| 844 } |
| 845 Color newBackground = box().style()->visitedDependentColor(CSSPropertyBackgr
oundColor); |
| 846 |
| 847 if (newBackground != oldBackground) { |
| 848 recalculateScrollbarOverlayStyle(newBackground); |
| 849 } |
| 837 } | 850 } |
| 838 | 851 |
| 839 bool PaintLayerScrollableArea::updateAfterCompositingChange() | 852 bool PaintLayerScrollableArea::updateAfterCompositingChange() |
| 840 { | 853 { |
| 841 layer()->updateScrollingStateAfterCompositingChange(); | 854 layer()->updateScrollingStateAfterCompositingChange(); |
| 842 const bool layersChanged = m_topmostScrollChild != m_nextTopmostScrollChild; | 855 const bool layersChanged = m_topmostScrollChild != m_nextTopmostScrollChild; |
| 843 m_topmostScrollChild = m_nextTopmostScrollChild; | 856 m_topmostScrollChild = m_nextTopmostScrollChild; |
| 844 m_nextTopmostScrollChild = nullptr; | 857 m_nextTopmostScrollChild = nullptr; |
| 845 return layersChanged; | 858 return layersChanged; |
| 846 } | 859 } |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 destroyScrollbar(VerticalScrollbar); | 1482 destroyScrollbar(VerticalScrollbar); |
| 1470 } | 1483 } |
| 1471 } | 1484 } |
| 1472 | 1485 |
| 1473 void PaintLayerScrollableArea::ScrollbarManager::setHasHorizontalScrollbar(bool
hasScrollbar) | 1486 void PaintLayerScrollableArea::ScrollbarManager::setHasHorizontalScrollbar(bool
hasScrollbar) |
| 1474 { | 1487 { |
| 1475 if (hasScrollbar) { | 1488 if (hasScrollbar) { |
| 1476 // This doesn't hit in any tests, but since the equivalent code in setHa
sVerticalScrollbar | 1489 // This doesn't hit in any tests, but since the equivalent code in setHa
sVerticalScrollbar |
| 1477 // does, presumably this code does as well. | 1490 // does, presumably this code does as well. |
| 1478 DisableCompositingQueryAsserts disabler; | 1491 DisableCompositingQueryAsserts disabler; |
| 1479 if (!m_hBar) | 1492 if (!m_hBar) { |
| 1480 m_hBar = createScrollbar(HorizontalScrollbar); | 1493 m_hBar = createScrollbar(HorizontalScrollbar); |
| 1481 m_hBarIsAttached = 1; | 1494 m_hBarIsAttached = 1; |
| 1495 if (!m_hBar->isCustomScrollbar()) |
| 1496 m_scrollableArea->didAddScrollbar(*m_hBar, HorizontalScrollbar); |
| 1497 } else { |
| 1498 m_hBarIsAttached = 1; |
| 1499 } |
| 1500 |
| 1482 } else { | 1501 } else { |
| 1483 m_hBarIsAttached = 0; | 1502 m_hBarIsAttached = 0; |
| 1484 if (!m_canDetachScrollbars) | 1503 if (!m_canDetachScrollbars) |
| 1485 destroyScrollbar(HorizontalScrollbar); | 1504 destroyScrollbar(HorizontalScrollbar); |
| 1486 } | 1505 } |
| 1487 } | 1506 } |
| 1488 | 1507 |
| 1489 void PaintLayerScrollableArea::ScrollbarManager::setHasVerticalScrollbar(bool ha
sScrollbar) | 1508 void PaintLayerScrollableArea::ScrollbarManager::setHasVerticalScrollbar(bool ha
sScrollbar) |
| 1490 { | 1509 { |
| 1491 if (hasScrollbar) { | 1510 if (hasScrollbar) { |
| 1492 DisableCompositingQueryAsserts disabler; | 1511 DisableCompositingQueryAsserts disabler; |
| 1493 if (!m_vBar) | 1512 if (!m_vBar) { |
| 1494 m_vBar = createScrollbar(VerticalScrollbar); | 1513 m_vBar = createScrollbar(VerticalScrollbar); |
| 1495 m_vBarIsAttached = 1; | 1514 m_vBarIsAttached = 1; |
| 1515 if (!m_vBar->isCustomScrollbar()) |
| 1516 m_scrollableArea->didAddScrollbar(*m_vBar, VerticalScrollbar); |
| 1517 } else { |
| 1518 m_vBarIsAttached = 1; |
| 1519 } |
| 1520 |
| 1496 } else { | 1521 } else { |
| 1497 m_vBarIsAttached = 0; | 1522 m_vBarIsAttached = 0; |
| 1498 if (!m_canDetachScrollbars) | 1523 if (!m_canDetachScrollbars) |
| 1499 destroyScrollbar(VerticalScrollbar); | 1524 destroyScrollbar(VerticalScrollbar); |
| 1500 } | 1525 } |
| 1501 } | 1526 } |
| 1502 | 1527 |
| 1503 PassRefPtrWillBeRawPtr<Scrollbar> PaintLayerScrollableArea::ScrollbarManager::cr
eateScrollbar(ScrollbarOrientation orientation) | 1528 PassRefPtrWillBeRawPtr<Scrollbar> PaintLayerScrollableArea::ScrollbarManager::cr
eateScrollbar(ScrollbarOrientation orientation) |
| 1504 { | 1529 { |
| 1505 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached : !m_vBarIsAtt
ached); | 1530 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached : !m_vBarIsAtt
ached); |
| 1506 RefPtrWillBeRawPtr<Scrollbar> scrollbar = nullptr; | 1531 RefPtrWillBeRawPtr<Scrollbar> scrollbar = nullptr; |
| 1507 const LayoutObject& actualLayoutObject = layoutObjectForScrollbar(m_scrollab
leArea->box()); | 1532 const LayoutObject& actualLayoutObject = layoutObjectForScrollbar(m_scrollab
leArea->box()); |
| 1508 bool hasCustomScrollbarStyle = actualLayoutObject.isBox() && actualLayoutObj
ect.styleRef().hasPseudoStyle(SCROLLBAR); | 1533 bool hasCustomScrollbarStyle = actualLayoutObject.isBox() && actualLayoutObj
ect.styleRef().hasPseudoStyle(SCROLLBAR); |
| 1509 if (hasCustomScrollbarStyle) { | 1534 if (hasCustomScrollbarStyle) { |
| 1510 scrollbar = LayoutScrollbar::createCustomScrollbar(m_scrollableArea.get(
), orientation, actualLayoutObject.node()); | 1535 scrollbar = LayoutScrollbar::createCustomScrollbar(m_scrollableArea.get(
), orientation, actualLayoutObject.node()); |
| 1511 } else { | 1536 } else { |
| 1512 ScrollbarControlSize scrollbarSize = RegularScrollbar; | 1537 ScrollbarControlSize scrollbarSize = RegularScrollbar; |
| 1513 if (actualLayoutObject.styleRef().hasAppearance()) | 1538 if (actualLayoutObject.styleRef().hasAppearance()) |
| 1514 scrollbarSize = LayoutTheme::theme().scrollbarControlSizeForPart(act
ualLayoutObject.styleRef().appearance()); | 1539 scrollbarSize = LayoutTheme::theme().scrollbarControlSizeForPart(act
ualLayoutObject.styleRef().appearance()); |
| 1515 scrollbar = Scrollbar::create(m_scrollableArea.get(), orientation, scrol
lbarSize, &m_scrollableArea->box().frame()->page()->chromeClient()); | 1540 scrollbar = Scrollbar::create(m_scrollableArea.get(), orientation, scrol
lbarSize, &m_scrollableArea->box().frame()->page()->chromeClient()); |
| 1516 if (orientation == HorizontalScrollbar) | |
| 1517 m_scrollableArea->didAddScrollbar(*scrollbar, HorizontalScrollbar); | |
| 1518 else | |
| 1519 m_scrollableArea->didAddScrollbar(*scrollbar, VerticalScrollbar); | |
| 1520 } | 1541 } |
| 1521 m_scrollableArea->box().document().view()->addChild(scrollbar.get()); | 1542 m_scrollableArea->box().document().view()->addChild(scrollbar.get()); |
| 1522 return scrollbar.release(); | 1543 return scrollbar.release(); |
| 1523 } | 1544 } |
| 1524 | 1545 |
| 1525 void PaintLayerScrollableArea::ScrollbarManager::destroyScrollbar(ScrollbarOrien
tation orientation) | 1546 void PaintLayerScrollableArea::ScrollbarManager::destroyScrollbar(ScrollbarOrien
tation orientation) |
| 1526 { | 1547 { |
| 1527 RefPtrWillBeMember<Scrollbar>& scrollbar = orientation == HorizontalScrollba
r ? m_hBar : m_vBar; | 1548 RefPtrWillBeMember<Scrollbar>& scrollbar = orientation == HorizontalScrollba
r ? m_hBar : m_vBar; |
| 1528 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached: !m_vBarIsAtta
ched); | 1549 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached: !m_vBarIsAtta
ched); |
| 1529 if (!scrollbar) | 1550 if (!scrollbar) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1544 } | 1565 } |
| 1545 | 1566 |
| 1546 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) | 1567 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) |
| 1547 { | 1568 { |
| 1548 visitor->trace(m_scrollableArea); | 1569 visitor->trace(m_scrollableArea); |
| 1549 visitor->trace(m_hBar); | 1570 visitor->trace(m_hBar); |
| 1550 visitor->trace(m_vBar); | 1571 visitor->trace(m_vBar); |
| 1551 } | 1572 } |
| 1552 | 1573 |
| 1553 } // namespace blink | 1574 } // namespace blink |
| OLD | NEW |