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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 ScrollbarMap& scrollbars = orientation == HorizontalScrollbar | 332 ScrollbarMap& scrollbars = orientation == HorizontalScrollbar |
333 ? m_horizontalScrollbars | 333 ? m_horizontalScrollbars |
334 : m_verticalScrollbars; | 334 : m_verticalScrollbars; |
335 if (std::unique_ptr<WebScrollbarLayer> scrollbarLayer = | 335 if (std::unique_ptr<WebScrollbarLayer> scrollbarLayer = |
336 scrollbars.take(scrollableArea)) | 336 scrollbars.take(scrollableArea)) |
337 GraphicsLayer::unregisterContentsLayer(scrollbarLayer->layer()); | 337 GraphicsLayer::unregisterContentsLayer(scrollbarLayer->layer()); |
338 } | 338 } |
339 | 339 |
340 static std::unique_ptr<WebScrollbarLayer> createScrollbarLayer( | 340 static std::unique_ptr<WebScrollbarLayer> createScrollbarLayer( |
341 Scrollbar& scrollbar, | 341 Scrollbar& scrollbar, |
342 float deviceScaleFactor, | 342 float deviceScaleFactor) { |
343 WebLayer* scrollLayer) { | |
344 ScrollbarTheme& theme = scrollbar.theme(); | 343 ScrollbarTheme& theme = scrollbar.theme(); |
345 WebScrollbarThemePainter painter(theme, scrollbar, deviceScaleFactor); | 344 WebScrollbarThemePainter painter(theme, scrollbar, deviceScaleFactor); |
346 std::unique_ptr<WebScrollbarThemeGeometry> geometry( | 345 std::unique_ptr<WebScrollbarThemeGeometry> geometry( |
347 WebScrollbarThemeGeometryNative::create(theme)); | 346 WebScrollbarThemeGeometryNative::create(theme)); |
348 | 347 |
349 std::unique_ptr<WebScrollbarLayer> scrollbarLayer; | 348 std::unique_ptr<WebScrollbarLayer> scrollbarLayer; |
350 if (theme.usesOverlayScrollbars() && theme.usesNinePatchThumbResource()) { | 349 if (theme.usesOverlayScrollbars() && theme.usesNinePatchThumbResource()) { |
351 scrollbarLayer = | 350 scrollbarLayer = |
352 Platform::current()->compositorSupport()->createOverlayScrollbarLayer( | 351 Platform::current()->compositorSupport()->createOverlayScrollbarLayer( |
353 WebScrollbarImpl::create(&scrollbar), painter, std::move(geometry), | 352 WebScrollbarImpl::create(&scrollbar), painter, std::move(geometry)); |
354 scrollLayer); | |
355 } else { | 353 } else { |
356 scrollbarLayer = | 354 scrollbarLayer = |
357 Platform::current()->compositorSupport()->createScrollbarLayer( | 355 Platform::current()->compositorSupport()->createScrollbarLayer( |
358 WebScrollbarImpl::create(&scrollbar), painter, std::move(geometry), | 356 WebScrollbarImpl::create(&scrollbar), painter, std::move(geometry)); |
359 scrollLayer); | |
360 } | 357 } |
361 GraphicsLayer::registerContentsLayer(scrollbarLayer->layer()); | 358 GraphicsLayer::registerContentsLayer(scrollbarLayer->layer()); |
362 return scrollbarLayer; | 359 return scrollbarLayer; |
363 } | 360 } |
364 | 361 |
365 std::unique_ptr<WebScrollbarLayer> | 362 std::unique_ptr<WebScrollbarLayer> |
366 ScrollingCoordinator::createSolidColorScrollbarLayer( | 363 ScrollingCoordinator::createSolidColorScrollbarLayer( |
367 ScrollbarOrientation orientation, | 364 ScrollbarOrientation orientation, |
368 int thumbThickness, | 365 int thumbThickness, |
369 int trackStart, | 366 int trackStart, |
370 bool isLeftSideVerticalScrollbar, | 367 bool isLeftSideVerticalScrollbar) { |
371 WebLayer* scrollLayer) { | |
372 WebScrollbar::Orientation webOrientation = | 368 WebScrollbar::Orientation webOrientation = |
373 (orientation == HorizontalScrollbar) ? WebScrollbar::Horizontal | 369 (orientation == HorizontalScrollbar) ? WebScrollbar::Horizontal |
374 : WebScrollbar::Vertical; | 370 : WebScrollbar::Vertical; |
375 std::unique_ptr<WebScrollbarLayer> scrollbarLayer = | 371 std::unique_ptr<WebScrollbarLayer> scrollbarLayer = |
376 Platform::current()->compositorSupport()->createSolidColorScrollbarLayer( | 372 Platform::current()->compositorSupport()->createSolidColorScrollbarLayer( |
377 webOrientation, thumbThickness, trackStart, | 373 webOrientation, thumbThickness, trackStart, |
378 isLeftSideVerticalScrollbar, scrollLayer); | 374 isLeftSideVerticalScrollbar); |
379 GraphicsLayer::registerContentsLayer(scrollbarLayer->layer()); | 375 GraphicsLayer::registerContentsLayer(scrollbarLayer->layer()); |
380 return scrollbarLayer; | 376 return scrollbarLayer; |
381 } | 377 } |
382 | 378 |
383 static void detachScrollbarLayer(GraphicsLayer* scrollbarGraphicsLayer) { | 379 static void detachScrollbarLayer(GraphicsLayer* scrollbarGraphicsLayer) { |
384 DCHECK(scrollbarGraphicsLayer); | 380 DCHECK(scrollbarGraphicsLayer); |
385 | 381 |
386 scrollbarGraphicsLayer->setContentsToPlatformLayer(nullptr); | 382 scrollbarGraphicsLayer->setContentsToPlatformLayer(nullptr); |
387 scrollbarGraphicsLayer->setDrawsContent(true); | 383 scrollbarGraphicsLayer->setDrawsContent(true); |
388 } | 384 } |
389 | 385 |
390 static void setupScrollbarLayer(GraphicsLayer* scrollbarGraphicsLayer, | 386 static void setupScrollbarLayer(GraphicsLayer* scrollbarGraphicsLayer, |
391 WebScrollbarLayer* scrollbarLayer, | 387 WebScrollbarLayer* scrollbarLayer, |
392 WebLayer* scrollLayer) { | 388 WebLayer* scrollLayer) { |
393 DCHECK(scrollbarGraphicsLayer); | 389 DCHECK(scrollbarGraphicsLayer); |
394 DCHECK(scrollbarLayer); | 390 DCHECK(scrollbarLayer); |
395 | 391 |
396 if (!scrollLayer) { | 392 if (!scrollLayer) { |
397 detachScrollbarLayer(scrollbarGraphicsLayer); | 393 detachScrollbarLayer(scrollbarGraphicsLayer); |
398 return; | 394 return; |
399 } | 395 } |
| 396 scrollbarLayer->setScrollLayer(scrollLayer); |
400 scrollbarGraphicsLayer->setContentsToPlatformLayer(scrollbarLayer->layer()); | 397 scrollbarGraphicsLayer->setContentsToPlatformLayer(scrollbarLayer->layer()); |
401 scrollbarGraphicsLayer->setDrawsContent(false); | 398 scrollbarGraphicsLayer->setDrawsContent(false); |
402 } | 399 } |
403 | 400 |
404 WebScrollbarLayer* ScrollingCoordinator::addWebScrollbarLayer( | 401 WebScrollbarLayer* ScrollingCoordinator::addWebScrollbarLayer( |
405 ScrollableArea* scrollableArea, | 402 ScrollableArea* scrollableArea, |
406 ScrollbarOrientation orientation, | 403 ScrollbarOrientation orientation, |
407 std::unique_ptr<WebScrollbarLayer> scrollbarLayer) { | 404 std::unique_ptr<WebScrollbarLayer> scrollbarLayer) { |
408 ScrollbarMap& scrollbars = orientation == HorizontalScrollbar | 405 ScrollbarMap& scrollbars = orientation == HorizontalScrollbar |
409 ? m_horizontalScrollbars | 406 ? m_horizontalScrollbars |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 detachScrollbarLayer(scrollbarGraphicsLayer); | 438 detachScrollbarLayer(scrollbarGraphicsLayer); |
442 scrollbarGraphicsLayer->platformLayer()->addMainThreadScrollingReasons( | 439 scrollbarGraphicsLayer->platformLayer()->addMainThreadScrollingReasons( |
443 MainThreadScrollingReason::kCustomScrollbarScrolling); | 440 MainThreadScrollingReason::kCustomScrollbarScrolling); |
444 return; | 441 return; |
445 } | 442 } |
446 | 443 |
447 // Invalidate custom scrollbar scrolling reason in case a custom | 444 // Invalidate custom scrollbar scrolling reason in case a custom |
448 // scrollbar becomes a non-custom one. | 445 // scrollbar becomes a non-custom one. |
449 scrollbarGraphicsLayer->platformLayer()->clearMainThreadScrollingReasons( | 446 scrollbarGraphicsLayer->platformLayer()->clearMainThreadScrollingReasons( |
450 MainThreadScrollingReason::kCustomScrollbarScrolling); | 447 MainThreadScrollingReason::kCustomScrollbarScrolling); |
451 | |
452 WebLayer* scrollLayer = toWebLayer(scrollableArea->layerForScrolling()); | |
453 if (!scrollLayer) { | |
454 detachScrollbarLayer(scrollbarGraphicsLayer); | |
455 return; | |
456 } | |
457 | |
458 WebScrollbarLayer* scrollbarLayer = | 448 WebScrollbarLayer* scrollbarLayer = |
459 getWebScrollbarLayer(scrollableArea, orientation); | 449 getWebScrollbarLayer(scrollableArea, orientation); |
460 if (!scrollbarLayer) { | 450 if (!scrollbarLayer) { |
461 Settings* settings = m_page->mainFrame()->settings(); | 451 Settings* settings = m_page->mainFrame()->settings(); |
462 | 452 |
463 std::unique_ptr<WebScrollbarLayer> webScrollbarLayer; | 453 std::unique_ptr<WebScrollbarLayer> webScrollbarLayer; |
464 if (settings->getUseSolidColorScrollbars()) { | 454 if (settings->getUseSolidColorScrollbars()) { |
465 DCHECK(RuntimeEnabledFeatures::overlayScrollbarsEnabled()); | 455 DCHECK(RuntimeEnabledFeatures::overlayScrollbarsEnabled()); |
466 webScrollbarLayer = createSolidColorScrollbarLayer( | 456 webScrollbarLayer = createSolidColorScrollbarLayer( |
467 orientation, scrollbar.theme().thumbThickness(scrollbar), | 457 orientation, scrollbar.theme().thumbThickness(scrollbar), |
468 scrollbar.theme().trackPosition(scrollbar), | 458 scrollbar.theme().trackPosition(scrollbar), |
469 scrollableArea->shouldPlaceVerticalScrollbarOnLeft(), scrollLayer); | 459 scrollableArea->shouldPlaceVerticalScrollbarOnLeft()); |
470 } else { | 460 } else { |
471 webScrollbarLayer = createScrollbarLayer( | 461 webScrollbarLayer = createScrollbarLayer( |
472 scrollbar, m_page->deviceScaleFactorDeprecated(), scrollLayer); | 462 scrollbar, m_page->deviceScaleFactorDeprecated()); |
473 } | 463 } |
474 scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, | 464 scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, |
475 std::move(webScrollbarLayer)); | 465 std::move(webScrollbarLayer)); |
476 } | 466 } |
477 | 467 |
| 468 WebLayer* scrollLayer = toWebLayer(scrollableArea->layerForScrolling()); |
478 setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollLayer); | 469 setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollLayer); |
479 | 470 |
480 // Root layer non-overlay scrollbars should be marked opaque to disable | 471 // Root layer non-overlay scrollbars should be marked opaque to disable |
481 // blending. | 472 // blending. |
482 bool isOpaqueScrollbar = !scrollbar.isOverlayScrollbar(); | 473 bool isOpaqueScrollbar = !scrollbar.isOverlayScrollbar(); |
483 scrollbarGraphicsLayer->setContentsOpaque(isMainFrame && isOpaqueScrollbar); | 474 scrollbarGraphicsLayer->setContentsOpaque(isMainFrame && isOpaqueScrollbar); |
484 } else { | 475 } else { |
485 removeWebScrollbarLayer(scrollableArea, orientation); | 476 removeWebScrollbarLayer(scrollableArea, orientation); |
486 } | 477 } |
487 } | 478 } |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 frameView ? toWebLayer(frameView->layoutViewportScrollableArea() | 1195 frameView ? toWebLayer(frameView->layoutViewportScrollableArea() |
1205 ->layerForScrolling()) | 1196 ->layerForScrolling()) |
1206 : nullptr) { | 1197 : nullptr) { |
1207 return WebSize(frameView->layoutViewportScrollableArea()->contentsSize()) != | 1198 return WebSize(frameView->layoutViewportScrollableArea()->contentsSize()) != |
1208 scrollLayer->bounds(); | 1199 scrollLayer->bounds(); |
1209 } | 1200 } |
1210 return false; | 1201 return false; |
1211 } | 1202 } |
1212 | 1203 |
1213 } // namespace blink | 1204 } // namespace blink |
OLD | NEW |