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

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

Issue 889453002: Add a WebLayer:setScrollCompensationAdjustment between Blink and CC (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add reftest Created 5 years, 10 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 WebLayer* webLayer = toWebLayer(scrollableArea->layerForScrolling()); 384 WebLayer* webLayer = toWebLayer(scrollableArea->layerForScrolling());
385 WebLayer* containerLayer = toWebLayer(scrollableArea->layerForContainer()); 385 WebLayer* containerLayer = toWebLayer(scrollableArea->layerForContainer());
386 if (webLayer) { 386 if (webLayer) {
387 webLayer->setScrollClipLayer(containerLayer); 387 webLayer->setScrollClipLayer(containerLayer);
388 // Non-layered Viewport constrained objects, e.g. fixed position element s, are 388 // Non-layered Viewport constrained objects, e.g. fixed position element s, are
389 // positioned in Blink using integer coordinates. In that case, we don't want 389 // positioned in Blink using integer coordinates. In that case, we don't want
390 // to set the WebLayer's scroll position at fractional precision otherwi se the 390 // to set the WebLayer's scroll position at fractional precision otherwi se the
391 // WebLayer's position after snapping to device pixel can be off with re gard to 391 // WebLayer's position after snapping to device pixel can be off with re gard to
392 // fixed position elements. 392 // fixed position elements.
393 if (m_lastMainThreadScrollingReasons & ScrollingCoordinator::HasNonLayer ViewportConstrainedObjects) 393 if (m_lastMainThreadScrollingReasons & ScrollingCoordinator::HasNonLayer ViewportConstrainedObjects) {
394 webLayer->setScrollPositionDouble(DoublePoint(scrollableArea->scroll Position() - scrollableArea->minimumScrollPosition())); 394 webLayer->setScrollPositionDouble(DoublePoint(scrollableArea->scroll Position() - scrollableArea->minimumScrollPosition()));
395 else 395 } else {
396 webLayer->setScrollPositionDouble(DoublePoint(scrollableArea->scroll PositionDouble() - scrollableArea->minimumScrollPosition())); 396 DoublePoint scrollPosition(scrollableArea->scrollPositionDouble() - scrollableArea->minimumScrollPosition());
397 IntPoint flooredScrollPosition(flooredIntPoint(scrollPosition));
398 DoublePoint fractionalPart(scrollPosition.x() - flooredScrollPositio n.x(), scrollPosition.y() - flooredScrollPosition.y());
399 webLayer->setScrollPositionDouble(scrollPosition);
400 // Blink can only use the integer part of the scroll offset to posit ion elements.
401 // Sends the fractional part of the scroll offset to CC as scroll ad justment for
402 // fixed-position layer.
403 webLayer->setScrollCompensationAdjustment(fractionalPart);
404 }
397 405
398 webLayer->setBounds(scrollableArea->contentsSize()); 406 webLayer->setBounds(scrollableArea->contentsSize());
399 bool canScrollX = scrollableArea->userInputScrollable(HorizontalScrollba r); 407 bool canScrollX = scrollableArea->userInputScrollable(HorizontalScrollba r);
400 bool canScrollY = scrollableArea->userInputScrollable(VerticalScrollbar) ; 408 bool canScrollY = scrollableArea->userInputScrollable(VerticalScrollbar) ;
401 webLayer->setUserScrollable(canScrollX, canScrollY); 409 webLayer->setUserScrollable(canScrollX, canScrollY);
402 } 410 }
403 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, HorizontalScrollbar)) { 411 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, HorizontalScrollbar)) {
404 GraphicsLayer* horizontalScrollbarLayer = scrollableArea->layerForHorizo ntalScrollbar(); 412 GraphicsLayer* horizontalScrollbarLayer = scrollableArea->layerForHorizo ntalScrollbar();
405 if (horizontalScrollbarLayer) 413 if (horizontalScrollbarLayer)
406 setupScrollbarLayer(horizontalScrollbarLayer, scrollbarLayer, webLay er, containerLayer); 414 setupScrollbarLayer(horizontalScrollbarLayer, scrollbarLayer, webLay er, containerLayer);
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 bool frameIsScrollable = frameView && frameView->isScrollable(); 1042 bool frameIsScrollable = frameView && frameView->isScrollable();
1035 if (frameIsScrollable != m_wasFrameScrollable) 1043 if (frameIsScrollable != m_wasFrameScrollable)
1036 return true; 1044 return true;
1037 1045
1038 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr) 1046 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : nullptr)
1039 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds( ); 1047 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds( );
1040 return false; 1048 return false;
1041 } 1049 }
1042 1050
1043 } // namespace blink 1051 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/scrolling/fractional-scroll-offset-fixed-position-expected.html ('k') | public/platform/WebLayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698