Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: Source/core/page/scrolling/ScrollingCoordinator.cpp

Issue 1318603005: Revert of Replace pinch scrollbars with regular scrollbars. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (settings->useSolidColorScrollbars()) { 374 if (settings->useSolidColorScrollbars()) {
375 ASSERT(RuntimeEnabledFeatures::overlayScrollbarsEnabled()); 375 ASSERT(RuntimeEnabledFeatures::overlayScrollbarsEnabled());
376 webScrollbarLayer = createSolidColorScrollbarLayer(orientation, scrollbar->theme()->thumbThickness(scrollbar), scrollbar->theme()->trackPosition (scrollbar), scrollableArea->shouldPlaceVerticalScrollbarOnLeft()); 376 webScrollbarLayer = createSolidColorScrollbarLayer(orientation, scrollbar->theme()->thumbThickness(scrollbar), scrollbar->theme()->trackPosition (scrollbar), scrollableArea->shouldPlaceVerticalScrollbarOnLeft());
377 } else { 377 } else {
378 webScrollbarLayer = createScrollbarLayer(scrollbar); 378 webScrollbarLayer = createScrollbarLayer(scrollbar);
379 } 379 }
380 scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, w ebScrollbarLayer.release()); 380 scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, w ebScrollbarLayer.release());
381 } 381 }
382 382
383 WebLayer* scrollLayer = toWebLayer(scrollableArea->layerForScrolling()); 383 WebLayer* scrollLayer = toWebLayer(scrollableArea->layerForScrolling());
384 WebLayer* scrollbarContainerLayer = toWebLayer(scrollableArea->layerForS crollbarContainer()); 384 WebLayer* containerLayer = toWebLayer(scrollableArea->layerForContainer( ));
385 setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollLayer, scrollbarContainerLayer); 385 setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollLayer, containerLayer);
386 386
387 // Root layer non-overlay scrollbars should be marked opaque to disable 387 // Root layer non-overlay scrollbars should be marked opaque to disable
388 // blending. 388 // blending.
389 bool isOpaqueScrollbar = !scrollbar->isOverlayScrollbar(); 389 bool isOpaqueScrollbar = !scrollbar->isOverlayScrollbar();
390 scrollbarGraphicsLayer->setContentsOpaque(isMainFrame && isOpaqueScrollb ar); 390 scrollbarGraphicsLayer->setContentsOpaque(isMainFrame && isOpaqueScrollb ar);
391 } else 391 } else
392 removeWebScrollbarLayer(scrollableArea, orientation); 392 removeWebScrollbarLayer(scrollableArea, orientation);
393 } 393 }
394 394
395 bool ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea* sc rollableArea) 395 bool ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea* sc rollableArea)
396 { 396 {
397 GraphicsLayer* scrollLayer = scrollableArea->layerForScrolling(); 397 GraphicsLayer* scrollLayer = scrollableArea->layerForScrolling();
398 398
399 if (scrollLayer) { 399 if (scrollLayer) {
400 ASSERT(m_page); 400 ASSERT(m_page);
401 scrollLayer->setScrollableArea(scrollableArea, isForViewport(scrollableA rea)); 401 scrollLayer->setScrollableArea(scrollableArea, isForViewport(scrollableA rea));
402 } 402 }
403 403
404 WebLayer* webLayer = toWebLayer(scrollableArea->layerForScrolling()); 404 WebLayer* webLayer = toWebLayer(scrollableArea->layerForScrolling());
405 WebLayer* containerLayer = toWebLayer(scrollableArea->layerForContainer()); 405 WebLayer* containerLayer = toWebLayer(scrollableArea->layerForContainer());
406 WebLayer* scrollbarContainerLayer = toWebLayer(scrollableArea->layerForScrol lbarContainer());
407 if (webLayer) { 406 if (webLayer) {
408 webLayer->setScrollClipLayer(containerLayer); 407 webLayer->setScrollClipLayer(containerLayer);
409 // Non-layered Viewport constrained objects, e.g. fixed position element s, are 408 // Non-layered Viewport constrained objects, e.g. fixed position element s, are
410 // positioned in Blink using integer coordinates. In that case, we don't want 409 // positioned in Blink using integer coordinates. In that case, we don't want
411 // to set the WebLayer's scroll position at fractional precision otherwi se the 410 // to set the WebLayer's scroll position at fractional precision otherwi se the
412 // WebLayer's position after snapping to device pixel can be off with re gard to 411 // WebLayer's position after snapping to device pixel can be off with re gard to
413 // fixed position elements. 412 // fixed position elements.
414 if (m_lastMainThreadScrollingReasons & ScrollingCoordinator::HasNonLayer ViewportConstrainedObjects) { 413 if (m_lastMainThreadScrollingReasons & ScrollingCoordinator::HasNonLayer ViewportConstrainedObjects) {
415 webLayer->setScrollPositionDouble(DoublePoint(scrollableArea->scroll Position() - scrollableArea->minimumScrollPosition())); 414 webLayer->setScrollPositionDouble(DoublePoint(scrollableArea->scroll Position() - scrollableArea->minimumScrollPosition()));
416 } else { 415 } else {
417 DoublePoint scrollPosition(scrollableArea->scrollPositionDouble() - scrollableArea->minimumScrollPositionDouble()); 416 DoublePoint scrollPosition(scrollableArea->scrollPositionDouble() - scrollableArea->minimumScrollPositionDouble());
418 IntPoint flooredScrollPosition(flooredIntPoint(scrollPosition)); 417 IntPoint flooredScrollPosition(flooredIntPoint(scrollPosition));
419 DoublePoint fractionalPart(scrollPosition.x() - flooredScrollPositio n.x(), scrollPosition.y() - flooredScrollPosition.y()); 418 DoublePoint fractionalPart(scrollPosition.x() - flooredScrollPositio n.x(), scrollPosition.y() - flooredScrollPosition.y());
420 webLayer->setScrollPositionDouble(scrollPosition); 419 webLayer->setScrollPositionDouble(scrollPosition);
421 // Blink can only use the integer part of the scroll offset to posit ion elements. 420 // Blink can only use the integer part of the scroll offset to posit ion elements.
422 // Sends the fractional part of the scroll offset to CC as scroll ad justment for 421 // Sends the fractional part of the scroll offset to CC as scroll ad justment for
423 // fixed-position layer. 422 // fixed-position layer.
424 webLayer->setScrollCompensationAdjustment(fractionalPart); 423 webLayer->setScrollCompensationAdjustment(fractionalPart);
425 } 424 }
426 425
427 webLayer->setBounds(scrollableArea->contentsSize()); 426 webLayer->setBounds(scrollableArea->contentsSize());
428 bool canScrollX = scrollableArea->userInputScrollable(HorizontalScrollba r); 427 bool canScrollX = scrollableArea->userInputScrollable(HorizontalScrollba r);
429 bool canScrollY = scrollableArea->userInputScrollable(VerticalScrollbar) ; 428 bool canScrollY = scrollableArea->userInputScrollable(VerticalScrollbar) ;
430 webLayer->setUserScrollable(canScrollX, canScrollY); 429 webLayer->setUserScrollable(canScrollX, canScrollY);
431 } 430 }
432 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, HorizontalScrollbar)) { 431 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, HorizontalScrollbar)) {
433 GraphicsLayer* horizontalScrollbarLayer = scrollableArea->layerForHorizo ntalScrollbar(); 432 GraphicsLayer* horizontalScrollbarLayer = scrollableArea->layerForHorizo ntalScrollbar();
434 if (horizontalScrollbarLayer) 433 if (horizontalScrollbarLayer)
435 setupScrollbarLayer(horizontalScrollbarLayer, scrollbarLayer, webLay er, scrollbarContainerLayer); 434 setupScrollbarLayer(horizontalScrollbarLayer, scrollbarLayer, webLay er, containerLayer);
436 } 435 }
437 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, VerticalScrollbar)) { 436 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, VerticalScrollbar)) {
438 GraphicsLayer* verticalScrollbarLayer = scrollableArea->layerForVertical Scrollbar(); 437 GraphicsLayer* verticalScrollbarLayer = scrollableArea->layerForVertical Scrollbar();
439
440 if (verticalScrollbarLayer) 438 if (verticalScrollbarLayer)
441 setupScrollbarLayer(verticalScrollbarLayer, scrollbarLayer, webLayer , scrollbarContainerLayer); 439 setupScrollbarLayer(verticalScrollbarLayer, scrollbarLayer, webLayer , containerLayer);
442 } 440 }
443 441
444 // Update the viewport layer registration if the outer viewport may have cha nged. 442 // Update the viewport layer registration if the outer viewport may have cha nged.
445 if (m_page->settings().rootLayerScrolls() && isForRootLayer(scrollableArea)) 443 if (m_page->settings().rootLayerScrolls() && isForRootLayer(scrollableArea))
446 m_page->chromeClient().registerViewportLayers(); 444 m_page->chromeClient().registerViewportLayers();
447 445
448 scrollableArea->layerForScrollingDidChange(m_programmaticScrollAnimatorTimel ine.get()); 446 scrollableArea->layerForScrollingDidChange(m_programmaticScrollAnimatorTimel ine.get());
449 447
450 return !!webLayer; 448 return !!webLayer;
451 } 449 }
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 bool frameIsScrollable = frameView && frameView->isScrollable(); 1076 bool frameIsScrollable = frameView && frameView->isScrollable();
1079 if (frameIsScrollable != m_wasFrameScrollable) 1077 if (frameIsScrollable != m_wasFrameScrollable)
1080 return true; 1078 return true;
1081 1079
1082 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr) 1080 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr)
1083 return WebSize(frameView->contentsSize()) != scrollLayer->bounds(); 1081 return WebSize(frameView->contentsSize()) != scrollLayer->bounds();
1084 return false; 1082 return false;
1085 } 1083 }
1086 1084
1087 } // namespace blink 1085 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698