Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 #elif OS(ANDROID) | 233 #elif OS(ANDROID) |
| 234 static const bool platformSupportsCoordinatedScrollbar = true; | 234 static const bool platformSupportsCoordinatedScrollbar = true; |
| 235 static const bool platformSupportsMainFrameOnly = false; | 235 static const bool platformSupportsMainFrameOnly = false; |
| 236 #else | 236 #else |
| 237 static const bool platformSupportsCoordinatedScrollbar = true; | 237 static const bool platformSupportsCoordinatedScrollbar = true; |
| 238 static const bool platformSupportsMainFrameOnly = true; | 238 static const bool platformSupportsMainFrameOnly = true; |
| 239 #endif | 239 #endif |
| 240 if (!platformSupportsCoordinatedScrollbar) | 240 if (!platformSupportsCoordinatedScrollbar) |
| 241 return; | 241 return; |
| 242 | 242 |
| 243 bool isMainFrame = (scrollableArea == static_cast<ScrollableArea*>(m_page->m ainFrame()->view())); | 243 bool isMainFrame = isForMainFrame(scrollableArea); |
| 244 if (!isMainFrame && platformSupportsMainFrameOnly) | 244 if (!isMainFrame && platformSupportsMainFrameOnly) |
| 245 return; | 245 return; |
| 246 | 246 |
| 247 GraphicsLayer* scrollbarGraphicsLayer = orientation == HorizontalScrollbar ? horizontalScrollbarLayerForScrollableArea(scrollableArea) : verticalScrollbarLa yerForScrollableArea(scrollableArea); | 247 GraphicsLayer* scrollbarGraphicsLayer = orientation == HorizontalScrollbar ? horizontalScrollbarLayerForScrollableArea(scrollableArea) : verticalScrollbarLa yerForScrollableArea(scrollableArea); |
| 248 if (scrollbarGraphicsLayer) { | 248 if (scrollbarGraphicsLayer) { |
| 249 Scrollbar* scrollbar = orientation == HorizontalScrollbar ? scrollableAr ea->horizontalScrollbar() : scrollableArea->verticalScrollbar(); | 249 Scrollbar* scrollbar = orientation == HorizontalScrollbar ? scrollableAr ea->horizontalScrollbar() : scrollableArea->verticalScrollbar(); |
| 250 if (scrollbar->isCustomScrollbar()) { | 250 if (scrollbar->isCustomScrollbar()) { |
| 251 detachScrollbarLayer(scrollbarGraphicsLayer); | 251 detachScrollbarLayer(scrollbarGraphicsLayer); |
| 252 return; | 252 return; |
| 253 } | 253 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 264 scrollbarLayer->layer()->setOpaque(scrollbarGraphicsLayer->contentsOpaqu e()); | 264 scrollbarLayer->layer()->setOpaque(scrollbarGraphicsLayer->contentsOpaqu e()); |
| 265 | 265 |
| 266 setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollingWeb LayerForScrollableArea(scrollableArea)); | 266 setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollingWeb LayerForScrollableArea(scrollableArea)); |
| 267 } else | 267 } else |
| 268 removeWebScrollbarLayer(scrollableArea, orientation); | 268 removeWebScrollbarLayer(scrollableArea, orientation); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea* sc rollableArea) | 271 void ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea* sc rollableArea) |
| 272 { | 272 { |
| 273 GraphicsLayer* scrollLayer = scrollLayerForScrollableArea(scrollableArea); | 273 GraphicsLayer* scrollLayer = scrollLayerForScrollableArea(scrollableArea); |
| 274 if (scrollLayer) | 274 if (scrollLayer) { |
| 275 scrollLayer->setScrollableArea(scrollableArea); | 275 bool isMainFrame = isForMainFrame(scrollableArea); |
| 276 scrollLayer->setScrollableArea(scrollableArea, isMainFrame); | |
| 277 } | |
| 276 | 278 |
| 277 WebLayer* webLayer = scrollingWebLayerForScrollableArea(scrollableArea); | 279 WebLayer* webLayer = scrollingWebLayerForScrollableArea(scrollableArea); |
| 278 if (webLayer) { | 280 if (webLayer) { |
| 279 webLayer->setScrollable(true); | 281 webLayer->setScrollable(true); |
| 280 webLayer->setScrollPosition(IntPoint(scrollableArea->scrollPosition() - scrollableArea->minimumScrollPosition())); | 282 webLayer->setScrollPosition(IntPoint(scrollableArea->scrollPosition() - scrollableArea->minimumScrollPosition())); |
| 281 webLayer->setMaxScrollPosition(IntSize(scrollableArea->scrollSize(Horizo ntalScrollbar), scrollableArea->scrollSize(VerticalScrollbar))); | 283 webLayer->setMaxScrollPosition(IntSize(scrollableArea->scrollSize(Horizo ntalScrollbar), scrollableArea->scrollSize(VerticalScrollbar))); |
| 282 } | 284 } |
| 283 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, HorizontalScrollbar)) | 285 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, HorizontalScrollbar)) |
| 284 setupScrollbarLayer(horizontalScrollbarLayerForScrollableArea(scrollable Area), scrollbarLayer, webLayer); | 286 setupScrollbarLayer(horizontalScrollbarLayerForScrollableArea(scrollable Area), scrollbarLayer, webLayer); |
| 285 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, VerticalScrollbar)) | 287 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, VerticalScrollbar)) |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 GraphicsLayer* ScrollingCoordinator::horizontalScrollbarLayerForScrollableArea(S crollableArea* scrollableArea) | 528 GraphicsLayer* ScrollingCoordinator::horizontalScrollbarLayerForScrollableArea(S crollableArea* scrollableArea) |
| 527 { | 529 { |
| 528 return scrollableArea->layerForHorizontalScrollbar(); | 530 return scrollableArea->layerForHorizontalScrollbar(); |
| 529 } | 531 } |
| 530 | 532 |
| 531 GraphicsLayer* ScrollingCoordinator::verticalScrollbarLayerForScrollableArea(Scr ollableArea* scrollableArea) | 533 GraphicsLayer* ScrollingCoordinator::verticalScrollbarLayerForScrollableArea(Scr ollableArea* scrollableArea) |
| 532 { | 534 { |
| 533 return scrollableArea->layerForVerticalScrollbar(); | 535 return scrollableArea->layerForVerticalScrollbar(); |
| 534 } | 536 } |
| 535 | 537 |
| 538 bool ScrollingCoordinator::isForMainFrame(ScrollableArea* scrollableArea) const | |
| 539 { | |
| 540 return scrollableArea == static_cast<ScrollableArea*>(m_page->mainFrame()->v iew()); | |
|
jamesr
2013/07/04 00:37:37
do you need the static cast on the RHS of this for
enne (OOO)
2013/07/04 00:50:17
You're right. The compiler will do the right thin
| |
| 541 } | |
| 542 | |
| 536 GraphicsLayer* ScrollingCoordinator::scrollLayerForFrameView(FrameView* frameVie w) | 543 GraphicsLayer* ScrollingCoordinator::scrollLayerForFrameView(FrameView* frameVie w) |
| 537 { | 544 { |
| 538 Frame* frame = frameView->frame(); | 545 Frame* frame = frameView->frame(); |
| 539 if (!frame) | 546 if (!frame) |
| 540 return 0; | 547 return 0; |
| 541 | 548 |
| 542 RenderView* renderView = frame->contentRenderer(); | 549 RenderView* renderView = frame->contentRenderer(); |
| 543 if (!renderView) | 550 if (!renderView) |
| 544 return 0; | 551 return 0; |
| 545 return renderView->compositor()->scrollLayer(); | 552 return renderView->compositor()->scrollLayer(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 stringBuilder.resize(stringBuilder.length() - 2); | 640 stringBuilder.resize(stringBuilder.length() - 2); |
| 634 return stringBuilder.toString(); | 641 return stringBuilder.toString(); |
| 635 } | 642 } |
| 636 | 643 |
| 637 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const | 644 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const |
| 638 { | 645 { |
| 639 return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons()); | 646 return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons()); |
| 640 } | 647 } |
| 641 | 648 |
| 642 } // namespace WebCore | 649 } // namespace WebCore |
| OLD | NEW |