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

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

Issue 2069713002: Make all gesture scrolls use customization path internally (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + Fix test Created 4 years, 5 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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 518
519 callApplyScroll(scrollState); 519 callApplyScroll(scrollState);
520 520
521 if (deltaX != scrollState.deltaX() || deltaY != scrollState.deltaY()) 521 if (deltaX != scrollState.deltaX() || deltaY != scrollState.deltaY())
522 scrollState.setCurrentNativeScrollingElement(this); 522 scrollState.setCurrentNativeScrollingElement(this);
523 } 523 }
524 524
525 void Element::callDistributeScroll(ScrollState& scrollState) 525 void Element::callDistributeScroll(ScrollState& scrollState)
526 { 526 {
527 ScrollStateCallback* callback = scrollCustomizationCallbacks().getDistribute Scroll(this); 527 ScrollStateCallback* callback = scrollCustomizationCallbacks().getDistribute Scroll(this);
528 if (!callback) { 528
529 // TODO(bokan): Need to add tests before we allow calling custom callbacks
530 // for non-touch modalities. For now, just call into the native callback but
531 // allow the viewport scroll callback so we don't disable overscroll.
532 // crbug.com/623079.
533 bool disableCustomCallbacks = !scrollState.isDirectManipulation()
534 && !document().isViewportScrollCallback(callback);
535
536 if (!callback || disableCustomCallbacks) {
529 nativeDistributeScroll(scrollState); 537 nativeDistributeScroll(scrollState);
530 return; 538 return;
531 } 539 }
532 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::PerformAfte rNativeScroll) 540 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::PerformAfte rNativeScroll)
533 callback->handleEvent(&scrollState); 541 callback->handleEvent(&scrollState);
534 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati veScroll) 542 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati veScroll)
535 nativeDistributeScroll(scrollState); 543 nativeDistributeScroll(scrollState);
536 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte rNativeScroll) 544 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte rNativeScroll)
537 callback->handleEvent(&scrollState); 545 callback->handleEvent(&scrollState);
538 }; 546 };
539 547
540 void Element::nativeApplyScroll(ScrollState& scrollState) 548 void Element::nativeApplyScroll(ScrollState& scrollState)
541 { 549 {
542 DCHECK(RuntimeEnabledFeatures::scrollCustomizationEnabled());
543
544 // All elements in the scroll chain should be boxes. 550 // All elements in the scroll chain should be boxes.
545 DCHECK(!layoutObject() || layoutObject()->isBox()); 551 DCHECK(!layoutObject() || layoutObject()->isBox());
546 552
547 if (scrollState.fullyConsumed()) 553 if (scrollState.fullyConsumed())
548 return; 554 return;
549 555
550 FloatSize delta(scrollState.deltaX(), scrollState.deltaY()); 556 FloatSize delta(scrollState.deltaX(), scrollState.deltaY());
551 557
552 if (delta.isZero()) 558 if (delta.isZero())
553 return; 559 return;
554 560
555 // TODO(esprehn): This should use updateStyleAndLayoutIgnorePendingStyleshee tsForNode. 561 // TODO(esprehn): This should use updateStyleAndLayoutIgnorePendingStyleshee tsForNode.
556 document().updateStyleAndLayoutIgnorePendingStylesheets(); 562 document().updateStyleAndLayoutIgnorePendingStylesheets();
557 563
558 LayoutBox* boxToScroll = nullptr; 564 LayoutBox* boxToScroll = nullptr;
559 565
560 // Handle the scrollingElement separately, as it should scroll the viewport. 566 // We should only ever scroll the effective root scroller this way when the
561 if (this == document().scrollingElement()) 567 // page removes the default applyScroll (ViewportScrollCallback).
568 if (document().effectiveRootScroller() == this)
562 boxToScroll = document().layoutView(); 569 boxToScroll = document().layoutView();
563 else if (layoutObject()) 570 else if (layoutObject())
564 boxToScroll = toLayoutBox(layoutObject()); 571 boxToScroll = toLayoutBox(layoutObject());
565 572
566 if (!boxToScroll) 573 if (!boxToScroll)
567 return; 574 return;
568 575
569 ScrollResult result = 576 ScrollResult result =
570 LayoutBoxItem(boxToScroll).enclosingBox().scroll( 577 LayoutBoxItem(boxToScroll).enclosingBox().scroll(
571 ScrollByPrecisePixel, 578 ScrollGranularity(static_cast<int>(scrollState.deltaGranularity())),
572 delta); 579 delta);
573 580
574 if (!result.didScroll()) 581 if (!result.didScroll())
575 return; 582 return;
576 583
577 // FIXME: Native scrollers should only consume the scroll they 584 // FIXME: Native scrollers should only consume the scroll they
578 // apply. See crbug.com/457765. 585 // apply. See crbug.com/457765.
579 scrollState.consumeDeltaNative(delta.width(), delta.height()); 586 scrollState.consumeDeltaNative(delta.width(), delta.height());
580 587
581 // We need to setCurrentNativeScrollingElement in both the 588 // We need to setCurrentNativeScrollingElement in both the
582 // distributeScroll and applyScroll default implementations so 589 // distributeScroll and applyScroll default implementations so
583 // that if JS overrides one of these methods, but not the 590 // that if JS overrides one of these methods, but not the
584 // other, this bookkeeping remains accurate. 591 // other, this bookkeeping remains accurate.
585 scrollState.setCurrentNativeScrollingElement(this); 592 scrollState.setCurrentNativeScrollingElement(this);
586 if (scrollState.fromUserInput()) { 593 if (scrollState.fromUserInput()) {
587 if (DocumentLoader* documentLoader = document().loader()) 594 if (DocumentLoader* documentLoader = document().loader())
588 documentLoader->initialScrollState().wasScrolledByUser = true; 595 documentLoader->initialScrollState().wasScrolledByUser = true;
589 } 596 }
590 }; 597 };
591 598
592 void Element::callApplyScroll(ScrollState& scrollState) 599 void Element::callApplyScroll(ScrollState& scrollState)
593 { 600 {
594 ScrollStateCallback* callback = scrollCustomizationCallbacks().getApplyScrol l(this); 601 ScrollStateCallback* callback = scrollCustomizationCallbacks().getApplyScrol l(this);
595 if (!callback) { 602
603 // TODO(bokan): Need to add tests before we allow calling custom callbacks
604 // for non-touch modalities. For now, just call into the native callback but
605 // allow the viewport scroll callback so we don't disable overscroll.
606 // crbug.com/623079.
607 bool disableCustomCallbacks = !scrollState.isDirectManipulation()
608 && !document().isViewportScrollCallback(callback);
609
610 if (!callback || disableCustomCallbacks) {
596 nativeApplyScroll(scrollState); 611 nativeApplyScroll(scrollState);
597 return; 612 return;
598 } 613 }
599 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::PerformAfte rNativeScroll) 614 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::PerformAfte rNativeScroll)
600 callback->handleEvent(&scrollState); 615 callback->handleEvent(&scrollState);
601 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati veScroll) 616 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati veScroll)
602 nativeApplyScroll(scrollState); 617 nativeApplyScroll(scrollState);
603 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte rNativeScroll) 618 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte rNativeScroll)
604 callback->handleEvent(&scrollState); 619 callback->handleEvent(&scrollState);
605 }; 620 };
(...skipping 3117 matching lines...) Expand 10 before | Expand all | Expand 10 after
3723 3738
3724 DEFINE_TRACE_WRAPPERS(Element) 3739 DEFINE_TRACE_WRAPPERS(Element)
3725 { 3740 {
3726 if (hasRareData()) { 3741 if (hasRareData()) {
3727 visitor->traceWrappers(elementRareData()); 3742 visitor->traceWrappers(elementRareData());
3728 } 3743 }
3729 ContainerNode::traceWrappers(visitor); 3744 ContainerNode::traceWrappers(visitor);
3730 } 3745 }
3731 3746
3732 } // namespace blink 3747 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698