| 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 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 if (Node* node = layoutObject.node()) { | 945 if (Node* node = layoutObject.node()) { |
| 946 if (layoutObject.isLayoutView()) { | 946 if (layoutObject.isLayoutView()) { |
| 947 Document& doc = node->document(); | 947 Document& doc = node->document(); |
| 948 if (Settings* settings = doc.settings()) { | 948 if (Settings* settings = doc.settings()) { |
| 949 if (!settings->allowCustomScrollbarInMainFrame() && layoutObject
.frame() && layoutObject.frame()->isMainFrame()) | 949 if (!settings->allowCustomScrollbarInMainFrame() && layoutObject
.frame() && layoutObject.frame()->isMainFrame()) |
| 950 return layoutObject; | 950 return layoutObject; |
| 951 } | 951 } |
| 952 | 952 |
| 953 // Try the <body> element first as a scrollbar source. | 953 // Try the <body> element first as a scrollbar source. |
| 954 Element* body = doc.body(); | 954 Element* body = doc.body(); |
| 955 if (body && body->layoutObject() && body->layoutObject()->style()->h
asPseudoStyle(SCROLLBAR)) | 955 if (body && body->layoutObject() && body->layoutObject()->style()->h
asPseudoStyle(PseudoIdScrollbar)) |
| 956 return *body->layoutObject(); | 956 return *body->layoutObject(); |
| 957 | 957 |
| 958 // If the <body> didn't have a custom style, then the root element m
ight. | 958 // If the <body> didn't have a custom style, then the root element m
ight. |
| 959 Element* docElement = doc.documentElement(); | 959 Element* docElement = doc.documentElement(); |
| 960 if (docElement && docElement->layoutObject() && docElement->layoutOb
ject()->style()->hasPseudoStyle(SCROLLBAR)) | 960 if (docElement && docElement->layoutObject() && docElement->layoutOb
ject()->style()->hasPseudoStyle(PseudoIdScrollbar)) |
| 961 return *docElement->layoutObject(); | 961 return *docElement->layoutObject(); |
| 962 | 962 |
| 963 // If we have an owning ipage/LocalFrame element, then it can set th
e custom scrollbar also. | 963 // If we have an owning ipage/LocalFrame element, then it can set th
e custom scrollbar also. |
| 964 LayoutPart* frameLayoutObject = node->document().frame()->ownerLayou
tObject(); | 964 LayoutPart* frameLayoutObject = node->document().frame()->ownerLayou
tObject(); |
| 965 if (frameLayoutObject && frameLayoutObject->style()->hasPseudoStyle(
SCROLLBAR)) | 965 if (frameLayoutObject && frameLayoutObject->style()->hasPseudoStyle(
PseudoIdScrollbar)) |
| 966 return *frameLayoutObject; | 966 return *frameLayoutObject; |
| 967 } | 967 } |
| 968 | 968 |
| 969 if (layoutObject.styleRef().hasPseudoStyle(SCROLLBAR)) | 969 if (layoutObject.styleRef().hasPseudoStyle(PseudoIdScrollbar)) |
| 970 return layoutObject; | 970 return layoutObject; |
| 971 | 971 |
| 972 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { | 972 if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { |
| 973 if (shadowRoot->type() == ShadowRootType::UserAgent) | 973 if (shadowRoot->type() == ShadowRootType::UserAgent) |
| 974 return *shadowRoot->host()->layoutObject(); | 974 return *shadowRoot->host()->layoutObject(); |
| 975 } | 975 } |
| 976 } | 976 } |
| 977 | 977 |
| 978 return layoutObject; | 978 return layoutObject; |
| 979 } | 979 } |
| 980 | 980 |
| 981 bool PaintLayerScrollableArea::needsScrollbarReconstruction() const | 981 bool PaintLayerScrollableArea::needsScrollbarReconstruction() const |
| 982 { | 982 { |
| 983 const LayoutObject& actualLayoutObject = layoutObjectForScrollbar(box()); | 983 const LayoutObject& actualLayoutObject = layoutObjectForScrollbar(box()); |
| 984 bool shouldUseCustom = actualLayoutObject.isBox() && actualLayoutObject.styl
eRef().hasPseudoStyle(SCROLLBAR); | 984 bool shouldUseCustom = actualLayoutObject.isBox() && actualLayoutObject.styl
eRef().hasPseudoStyle(PseudoIdScrollbar); |
| 985 bool hasAnyScrollbar = hasScrollbar(); | 985 bool hasAnyScrollbar = hasScrollbar(); |
| 986 bool hasCustom = (hasHorizontalScrollbar() && horizontalScrollbar()->isCusto
mScrollbar()) || (hasVerticalScrollbar() && verticalScrollbar()->isCustomScrollb
ar()); | 986 bool hasCustom = (hasHorizontalScrollbar() && horizontalScrollbar()->isCusto
mScrollbar()) || (hasVerticalScrollbar() && verticalScrollbar()->isCustomScrollb
ar()); |
| 987 bool didCustomScrollbarOwnerChanged = false; | 987 bool didCustomScrollbarOwnerChanged = false; |
| 988 | 988 |
| 989 if (hasHorizontalScrollbar() && horizontalScrollbar()->isCustomScrollbar())
{ | 989 if (hasHorizontalScrollbar() && horizontalScrollbar()->isCustomScrollbar())
{ |
| 990 if (actualLayoutObject != toLayoutScrollbar(horizontalScrollbar())->owni
ngLayoutObject()) | 990 if (actualLayoutObject != toLayoutScrollbar(horizontalScrollbar())->owni
ngLayoutObject()) |
| 991 didCustomScrollbarOwnerChanged = true; | 991 didCustomScrollbarOwnerChanged = true; |
| 992 } | 992 } |
| 993 | 993 |
| 994 if (hasVerticalScrollbar() && verticalScrollbar()->isCustomScrollbar()) { | 994 if (hasVerticalScrollbar() && verticalScrollbar()->isCustomScrollbar()) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 } | 1084 } |
| 1085 | 1085 |
| 1086 void PaintLayerScrollableArea::updateScrollCornerStyle() | 1086 void PaintLayerScrollableArea::updateScrollCornerStyle() |
| 1087 { | 1087 { |
| 1088 if (!m_scrollCorner && !hasScrollbar()) | 1088 if (!m_scrollCorner && !hasScrollbar()) |
| 1089 return; | 1089 return; |
| 1090 if (!m_scrollCorner && hasOverlayScrollbars()) | 1090 if (!m_scrollCorner && hasOverlayScrollbars()) |
| 1091 return; | 1091 return; |
| 1092 | 1092 |
| 1093 const LayoutObject& actualLayoutObject = layoutObjectForScrollbar(box()); | 1093 const LayoutObject& actualLayoutObject = layoutObjectForScrollbar(box()); |
| 1094 RefPtr<ComputedStyle> corner = box().hasOverflowClip() ? actualLayoutObject.
getUncachedPseudoStyle(PseudoStyleRequest(SCROLLBAR_CORNER), actualLayoutObject.
style()) : PassRefPtr<ComputedStyle>(nullptr); | 1094 RefPtr<ComputedStyle> corner = box().hasOverflowClip() ? actualLayoutObject.
getUncachedPseudoStyle(PseudoStyleRequest(PseudoIdScrollbarCorner), actualLayout
Object.style()) : PassRefPtr<ComputedStyle>(nullptr); |
| 1095 if (corner) { | 1095 if (corner) { |
| 1096 if (!m_scrollCorner) { | 1096 if (!m_scrollCorner) { |
| 1097 m_scrollCorner = LayoutScrollbarPart::createAnonymous(&box().documen
t()); | 1097 m_scrollCorner = LayoutScrollbarPart::createAnonymous(&box().documen
t()); |
| 1098 m_scrollCorner->setDangerousOneWayParent(&box()); | 1098 m_scrollCorner->setDangerousOneWayParent(&box()); |
| 1099 } | 1099 } |
| 1100 m_scrollCorner->setStyleWithWritingModeOfParent(corner.release()); | 1100 m_scrollCorner->setStyleWithWritingModeOfParent(corner.release()); |
| 1101 } else if (m_scrollCorner) { | 1101 } else if (m_scrollCorner) { |
| 1102 m_scrollCorner->destroy(); | 1102 m_scrollCorner->destroy(); |
| 1103 m_scrollCorner = nullptr; | 1103 m_scrollCorner = nullptr; |
| 1104 } | 1104 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 else | 1212 else |
| 1213 frameView->removeResizerArea(box()); | 1213 frameView->removeResizerArea(box()); |
| 1214 } | 1214 } |
| 1215 | 1215 |
| 1216 void PaintLayerScrollableArea::updateResizerStyle() | 1216 void PaintLayerScrollableArea::updateResizerStyle() |
| 1217 { | 1217 { |
| 1218 if (!m_resizer && !box().canResize()) | 1218 if (!m_resizer && !box().canResize()) |
| 1219 return; | 1219 return; |
| 1220 | 1220 |
| 1221 const LayoutObject& actualLayoutObject = layoutObjectForScrollbar(box()); | 1221 const LayoutObject& actualLayoutObject = layoutObjectForScrollbar(box()); |
| 1222 RefPtr<ComputedStyle> resizer = box().hasOverflowClip() ? actualLayoutObject
.getUncachedPseudoStyle(PseudoStyleRequest(RESIZER), actualLayoutObject.style())
: PassRefPtr<ComputedStyle>(nullptr); | 1222 RefPtr<ComputedStyle> resizer = box().hasOverflowClip() ? actualLayoutObject
.getUncachedPseudoStyle(PseudoStyleRequest(PseudoIdResizer), actualLayoutObject.
style()) : PassRefPtr<ComputedStyle>(nullptr); |
| 1223 if (resizer) { | 1223 if (resizer) { |
| 1224 if (!m_resizer) { | 1224 if (!m_resizer) { |
| 1225 m_resizer = LayoutScrollbarPart::createAnonymous(&box().document()); | 1225 m_resizer = LayoutScrollbarPart::createAnonymous(&box().document()); |
| 1226 m_resizer->setDangerousOneWayParent(&box()); | 1226 m_resizer->setDangerousOneWayParent(&box()); |
| 1227 } | 1227 } |
| 1228 m_resizer->setStyleWithWritingModeOfParent(resizer.release()); | 1228 m_resizer->setStyleWithWritingModeOfParent(resizer.release()); |
| 1229 } else if (m_resizer) { | 1229 } else if (m_resizer) { |
| 1230 m_resizer->destroy(); | 1230 m_resizer->destroy(); |
| 1231 m_resizer = nullptr; | 1231 m_resizer = nullptr; |
| 1232 } | 1232 } |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 if (!m_canDetachScrollbars) | 1532 if (!m_canDetachScrollbars) |
| 1533 destroyScrollbar(VerticalScrollbar); | 1533 destroyScrollbar(VerticalScrollbar); |
| 1534 } | 1534 } |
| 1535 } | 1535 } |
| 1536 | 1536 |
| 1537 PassRefPtrWillBeRawPtr<Scrollbar> PaintLayerScrollableArea::ScrollbarManager::cr
eateScrollbar(ScrollbarOrientation orientation) | 1537 PassRefPtrWillBeRawPtr<Scrollbar> PaintLayerScrollableArea::ScrollbarManager::cr
eateScrollbar(ScrollbarOrientation orientation) |
| 1538 { | 1538 { |
| 1539 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached : !m_vBarIsAtt
ached); | 1539 ASSERT(orientation == HorizontalScrollbar ? !m_hBarIsAttached : !m_vBarIsAtt
ached); |
| 1540 RefPtrWillBeRawPtr<Scrollbar> scrollbar = nullptr; | 1540 RefPtrWillBeRawPtr<Scrollbar> scrollbar = nullptr; |
| 1541 const LayoutObject& actualLayoutObject = layoutObjectForScrollbar(m_scrollab
leArea->box()); | 1541 const LayoutObject& actualLayoutObject = layoutObjectForScrollbar(m_scrollab
leArea->box()); |
| 1542 bool hasCustomScrollbarStyle = actualLayoutObject.isBox() && actualLayoutObj
ect.styleRef().hasPseudoStyle(SCROLLBAR); | 1542 bool hasCustomScrollbarStyle = actualLayoutObject.isBox() && actualLayoutObj
ect.styleRef().hasPseudoStyle(PseudoIdScrollbar); |
| 1543 if (hasCustomScrollbarStyle) { | 1543 if (hasCustomScrollbarStyle) { |
| 1544 scrollbar = LayoutScrollbar::createCustomScrollbar(m_scrollableArea.get(
), orientation, actualLayoutObject.node()); | 1544 scrollbar = LayoutScrollbar::createCustomScrollbar(m_scrollableArea.get(
), orientation, actualLayoutObject.node()); |
| 1545 } else { | 1545 } else { |
| 1546 ScrollbarControlSize scrollbarSize = RegularScrollbar; | 1546 ScrollbarControlSize scrollbarSize = RegularScrollbar; |
| 1547 if (actualLayoutObject.styleRef().hasAppearance()) | 1547 if (actualLayoutObject.styleRef().hasAppearance()) |
| 1548 scrollbarSize = LayoutTheme::theme().scrollbarControlSizeForPart(act
ualLayoutObject.styleRef().appearance()); | 1548 scrollbarSize = LayoutTheme::theme().scrollbarControlSizeForPart(act
ualLayoutObject.styleRef().appearance()); |
| 1549 scrollbar = Scrollbar::create(m_scrollableArea.get(), orientation, scrol
lbarSize, &m_scrollableArea->box().frame()->page()->chromeClient()); | 1549 scrollbar = Scrollbar::create(m_scrollableArea.get(), orientation, scrol
lbarSize, &m_scrollableArea->box().frame()->page()->chromeClient()); |
| 1550 } | 1550 } |
| 1551 m_scrollableArea->box().document().view()->addChild(scrollbar.get()); | 1551 m_scrollableArea->box().document().view()->addChild(scrollbar.get()); |
| 1552 return scrollbar.release(); | 1552 return scrollbar.release(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1574 } | 1574 } |
| 1575 | 1575 |
| 1576 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) | 1576 DEFINE_TRACE(PaintLayerScrollableArea::ScrollbarManager) |
| 1577 { | 1577 { |
| 1578 visitor->trace(m_scrollableArea); | 1578 visitor->trace(m_scrollableArea); |
| 1579 visitor->trace(m_hBar); | 1579 visitor->trace(m_hBar); |
| 1580 visitor->trace(m_vBar); | 1580 visitor->trace(m_vBar); |
| 1581 } | 1581 } |
| 1582 | 1582 |
| 1583 } // namespace blink | 1583 } // namespace blink |
| OLD | NEW |