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

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: 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
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 #include "core/layout/Layer.h" 106 #include "core/layout/Layer.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/layout/compositing/LayerCompositor.h" 109 #include "core/layout/compositing/LayerCompositor.h"
110 #include "core/page/Chrome.h" 110 #include "core/page/Chrome.h"
111 #include "core/page/ChromeClient.h" 111 #include "core/page/ChromeClient.h"
112 #include "core/page/FocusController.h" 112 #include "core/page/FocusController.h"
113 #include "core/page/Page.h" 113 #include "core/page/Page.h"
114 #include "core/page/PointerLockController.h" 114 #include "core/page/PointerLockController.h"
115 #include "core/page/SpatialNavigation.h" 115 #include "core/page/SpatialNavigation.h"
116 #include "core/page/scrolling/ScrollState.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"
125 #include "wtf/text/StringBuilder.h" 126 #include "wtf/text/StringBuilder.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (!renderer()) 475 if (!renderer())
475 return; 476 return;
476 477
477 LayoutRect bounds = boundingBox(); 478 LayoutRect bounds = boundingBox();
478 if (centerIfNeeded) 479 if (centerIfNeeded)
479 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNe eded, ScrollAlignment::alignCenterIfNeeded); 480 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNe eded, ScrollAlignment::alignCenterIfNeeded);
480 else 481 else
481 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNe eded, ScrollAlignment::alignToEdgeIfNeeded); 482 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNe eded, ScrollAlignment::alignToEdgeIfNeeded);
482 } 483 }
483 484
485 void Element::distributeScroll(ScrollState* scrollState)
486 {
487 ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled());
488 ASSERT(scrollState);
489 if (!scrollState || scrollState->fullyConsumed())
490 return;
491
492 scrollState->distributeToScrollChainDescendant();
493
494 // If the scroll doesn't propagate, and we're currently scrolling
495 // an element other than this one, don't scroll.
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 ASSERT(scrollState);
515 if (!scrollState || scrollState->fullyConsumed())
516 return;
517
518 const double deltaX = scrollState->deltaX();
519 const double deltaY = scrollState->deltaY();
520 bool scrolled = false;
521
522 // Handle the documentElement separately, as it scrolls the FrameView.
523 if (this == document().documentElement()) {
524 FloatSize delta(deltaX, deltaY);
525 if (document().frame()->applyScrollDelta(delta, scrollState->isBeginning ()))
526 scrolled = true;
527 } else {
528 LayoutBox* curBox = renderer()->enclosingBox();
529 if (deltaX && curBox->scroll(ScrollLeft, ScrollByPrecisePixel, deltaX))
530 scrolled = true;
531
532 if (deltaY && curBox->scroll(ScrollUp, ScrollByPrecisePixel, deltaY))
533 scrolled = true;
534 }
535
536 if (!scrolled)
537 return;
538
539 // We need to setCurrentNativeScrollingElement in both the
540 // distributeScroll and applyScroll default implementations so
541 // that if JS overrides one of these methods, but not the
542 // other, this bookkeeping remains accurate.
543 scrollState->setCurrentNativeScrollingElement(this);
544 scrollState->consumeDeltaNative(scrollState->deltaX(), scrollState->deltaY() );
545 if (scrollState->fromUserInput())
546 document().frame()->view()->setWasScrolledByUser(true);
547 };
548
484 static float localZoomForRenderer(LayoutObject& renderer) 549 static float localZoomForRenderer(LayoutObject& renderer)
485 { 550 {
486 // FIXME: This does the wrong thing if two opposing zooms are in effect and canceled each 551 // 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 552 // 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). 553 // time (or store an additional bit in the LayoutStyle to indicate that a zo om was specified).
489 float zoomFactor = 1; 554 float zoomFactor = 1;
490 if (renderer.style()->effectiveZoom() != 1) { 555 if (renderer.style()->effectiveZoom() != 1) {
491 // Need to find the nearest enclosing LayoutObject that set up 556 // 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. 557 // a differing zoom, and then we divide our result by it to eliminate th e zoom.
493 LayoutObject* prev = &renderer; 558 LayoutObject* prev = &renderer;
(...skipping 2871 matching lines...) Expand 10 before | Expand all | Expand 10 after
3365 { 3430 {
3366 #if ENABLE(OILPAN) 3431 #if ENABLE(OILPAN)
3367 if (hasRareData()) 3432 if (hasRareData())
3368 visitor->trace(elementRareData()); 3433 visitor->trace(elementRareData());
3369 visitor->trace(m_elementData); 3434 visitor->trace(m_elementData);
3370 #endif 3435 #endif
3371 ContainerNode::trace(visitor); 3436 ContainerNode::trace(visitor);
3372 } 3437 }
3373 3438
3374 } // namespace blink 3439 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698