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

Side by Side Diff: Source/core/dom/Element.cpp

Issue 988823003: Use scroll customization primitives for touch scrolling (behind REF). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address rbyers' nit. Created 5 years, 9 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
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/frame/LocalFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 #include "core/html/parser/HTMLParserIdioms.h" 105 #include "core/html/parser/HTMLParserIdioms.h"
106 #include "core/inspector/InspectorInstrumentation.h" 106 #include "core/inspector/InspectorInstrumentation.h"
107 #include "core/layout/LayoutTextFragment.h" 107 #include "core/layout/LayoutTextFragment.h"
108 #include "core/layout/LayoutView.h" 108 #include "core/layout/LayoutView.h"
109 #include "core/page/Chrome.h" 109 #include "core/page/Chrome.h"
110 #include "core/page/ChromeClient.h" 110 #include "core/page/ChromeClient.h"
111 #include "core/page/FocusController.h" 111 #include "core/page/FocusController.h"
112 #include "core/page/Page.h" 112 #include "core/page/Page.h"
113 #include "core/page/PointerLockController.h" 113 #include "core/page/PointerLockController.h"
114 #include "core/page/SpatialNavigation.h" 114 #include "core/page/SpatialNavigation.h"
115 #include "core/page/scrolling/ScrollState.h"
115 #include "core/paint/DeprecatedPaintLayer.h" 116 #include "core/paint/DeprecatedPaintLayer.h"
116 #include "core/svg/SVGDocumentExtensions.h" 117 #include "core/svg/SVGDocumentExtensions.h"
117 #include "core/svg/SVGElement.h" 118 #include "core/svg/SVGElement.h"
118 #include "platform/EventDispatchForbiddenScope.h" 119 #include "platform/EventDispatchForbiddenScope.h"
119 #include "platform/RuntimeEnabledFeatures.h" 120 #include "platform/RuntimeEnabledFeatures.h"
120 #include "platform/UserGestureIndicator.h" 121 #include "platform/UserGestureIndicator.h"
121 #include "platform/scroll/ScrollableArea.h" 122 #include "platform/scroll/ScrollableArea.h"
122 #include "wtf/BitVector.h" 123 #include "wtf/BitVector.h"
123 #include "wtf/HashFunctions.h" 124 #include "wtf/HashFunctions.h"
124 #include "wtf/text/CString.h" 125 #include "wtf/text/CString.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (!layoutObject()) 475 if (!layoutObject())
475 return; 476 return;
476 477
477 LayoutRect bounds = boundingBox(); 478 LayoutRect bounds = boundingBox();
478 if (centerIfNeeded) 479 if (centerIfNeeded)
479 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenter IfNeeded, ScrollAlignment::alignCenterIfNeeded); 480 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenter IfNeeded, ScrollAlignment::alignCenterIfNeeded);
480 else 481 else
481 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignToEdgeIfNeeded); 482 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
482 } 483 }
483 484
485 void Element::distributeScroll(ScrollState& scrollState)
486 {
487 ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled());
488 if (scrollState.fullyConsumed())
489 return;
490
491 scrollState.distributeToScrollChainDescendant();
492
493 // If the scroll doesn't propagate, and we're currently scrolling
494 // an element other than this one, prevent the scroll from
495 // propagating to this element.
496 if (!scrollState.shouldPropagate()
497 && scrollState.deltaConsumedForScrollSequence()
498 && scrollState.currentNativeScrollingElement() != this) {
499 return;
500 }
501
502 const double deltaX = scrollState.deltaX();
503 const double deltaY = scrollState.deltaY();
504
505 applyScroll(scrollState);
506
507 if (deltaX != scrollState.deltaX() || deltaY != scrollState.deltaY())
508 scrollState.setCurrentNativeScrollingElement(this);
509 }
510
511 void Element::applyScroll(ScrollState& scrollState)
512 {
513 ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled());
514 if (scrollState.fullyConsumed())
515 return;
516
517 const double deltaX = scrollState.deltaX();
518 const double deltaY = scrollState.deltaY();
519 bool scrolled = false;
520
521 // Handle the documentElement separately, as it scrolls the FrameView.
522 if (this == document().documentElement()) {
523 FloatSize delta(deltaX, deltaY);
524 if (document().frame()->applyScrollDelta(delta, scrollState.isBeginning( ))) {
525 scrolled = true;
526 scrollState.consumeDeltaNative(scrollState.deltaX(), scrollState.del taY());
527 }
528 } else {
529 if (!layoutObject())
530 return;
531 LayoutBox* curBox = layoutObject()->enclosingBox();
532 // FIXME: Native scrollers should only consume the scroll they
533 // apply. See crbug.com/457765.
534 if (deltaX && curBox->scroll(ScrollLeft, ScrollByPrecisePixel, deltaX)) {
535 scrollState.consumeDeltaNative(scrollState.deltaX(), 0);
536 scrolled = true;
537 }
538
539 if (deltaY && curBox->scroll(ScrollUp, ScrollByPrecisePixel, deltaY)) {
540 scrollState.consumeDeltaNative(0, scrollState.deltaY());
541 scrolled = true;
542 }
543 }
544
545 if (!scrolled)
546 return;
547
548 // We need to setCurrentNativeScrollingElement in both the
549 // distributeScroll and applyScroll default implementations so
550 // that if JS overrides one of these methods, but not the
551 // other, this bookkeeping remains accurate.
552 scrollState.setCurrentNativeScrollingElement(this);
553 if (scrollState.fromUserInput())
554 document().frame()->view()->setWasScrolledByUser(true);
555 };
556
484 static float localZoomForRenderer(LayoutObject& renderer) 557 static float localZoomForRenderer(LayoutObject& renderer)
485 { 558 {
486 // FIXME: This does the wrong thing if two opposing zooms are in effect and canceled each 559 // FIXME: This does the wrong thing if two opposing zooms are in effect and canceled each
487 // other out, but the alternative is that we'd have to crawl up the whole re nder tree every 560 // other out, but the alternative is that we'd have to crawl up the whole re nder tree every
488 // time (or store an additional bit in the LayoutStyle to indicate that a zo om was specified). 561 // time (or store an additional bit in the LayoutStyle to indicate that a zo om was specified).
489 float zoomFactor = 1; 562 float zoomFactor = 1;
490 if (renderer.style()->effectiveZoom() != 1) { 563 if (renderer.style()->effectiveZoom() != 1) {
491 // Need to find the nearest enclosing LayoutObject that set up 564 // Need to find the nearest enclosing LayoutObject that set up
492 // a differing zoom, and then we divide our result by it to eliminate th e zoom. 565 // a differing zoom, and then we divide our result by it to eliminate th e zoom.
493 LayoutObject* prev = &renderer; 566 LayoutObject* prev = &renderer;
(...skipping 2892 matching lines...) Expand 10 before | Expand all | Expand 10 after
3386 { 3459 {
3387 #if ENABLE(OILPAN) 3460 #if ENABLE(OILPAN)
3388 if (hasRareData()) 3461 if (hasRareData())
3389 visitor->trace(elementRareData()); 3462 visitor->trace(elementRareData());
3390 visitor->trace(m_elementData); 3463 visitor->trace(m_elementData);
3391 #endif 3464 #endif
3392 ContainerNode::trace(visitor); 3465 ContainerNode::trace(visitor);
3393 } 3466 }
3394 3467
3395 } // namespace blink 3468 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/frame/LocalFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698