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

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

Issue 2769793002: Implement CSS: scroll-boundary-behavior (Closed)
Patch Set: Update WebScrollBoundaryBehavior. Created 3 years, 7 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. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
9 * (C) 2007 Eric Seidel (eric@webkit.org) 9 * (C) 2007 Eric Seidel (eric@webkit.org)
10 * 10 *
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 scroll_state.DeltaConsumedForScrollSequence() && 521 scroll_state.DeltaConsumedForScrollSequence() &&
522 scroll_state.CurrentNativeScrollingElement() != this) { 522 scroll_state.CurrentNativeScrollingElement() != this) {
523 return; 523 return;
524 } 524 }
525 525
526 const double delta_x = scroll_state.deltaX(); 526 const double delta_x = scroll_state.deltaX();
527 const double delta_y = scroll_state.deltaY(); 527 const double delta_y = scroll_state.deltaY();
528 528
529 CallApplyScroll(scroll_state); 529 CallApplyScroll(scroll_state);
530 530
531 if (delta_x != scroll_state.deltaX() || delta_y != scroll_state.deltaY()) 531 if (delta_x != scroll_state.deltaX() || delta_y != scroll_state.deltaY()) {
532 scroll_state.SetCurrentNativeScrollingElement(this); 532 scroll_state.SetCurrentNativeScrollingElement(this);
533 }
bokan 2017/05/19 19:35:57 Nit: no braces
sunyunjia 2017/05/25 20:07:10 Done.
533 } 534 }
534 535
535 void Element::CallDistributeScroll(ScrollState& scroll_state) { 536 void Element::CallDistributeScroll(ScrollState& scroll_state) {
536 ScrollStateCallback* callback = 537 ScrollStateCallback* callback =
537 GetScrollCustomizationCallbacks().GetDistributeScroll(this); 538 GetScrollCustomizationCallbacks().GetDistributeScroll(this);
538 539
539 // TODO(bokan): Need to add tests before we allow calling custom callbacks 540 // TODO(bokan): Need to add tests before we allow calling custom callbacks
540 // for non-touch modalities. For now, just call into the native callback but 541 // for non-touch modalities. For now, just call into the native callback but
541 // allow the viewport scroll callback so we don't disable overscroll. 542 // allow the viewport scroll callback so we don't disable overscroll.
542 // crbug.com/623079. 543 // crbug.com/623079.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 587
587 if (!box_to_scroll) 588 if (!box_to_scroll)
588 return; 589 return;
589 590
590 ScrollResult result = LayoutBoxItem(box_to_scroll) 591 ScrollResult result = LayoutBoxItem(box_to_scroll)
591 .EnclosingBox() 592 .EnclosingBox()
592 .Scroll(ScrollGranularity(static_cast<int>( 593 .Scroll(ScrollGranularity(static_cast<int>(
593 scroll_state.deltaGranularity())), 594 scroll_state.deltaGranularity())),
594 delta); 595 delta);
595 596
596 if (!result.DidScroll()) 597 if (!result.DidScroll()) {
598 if (GetComputedStyle()->ScrollBoundaryBehaviorX() !=
bokan 2017/05/19 19:35:57 Similarly, this should be done at the time that we
sunyunjia 2017/05/25 20:07:10 Done.
599 EScrollBoundaryBehavior::kAuto &&
600 std::abs(delta.Width()) > std::abs(delta.Height()))
601 scroll_state.ConsumeDeltaNative(delta.Width(), 0);
602 if (GetComputedStyle()->ScrollBoundaryBehaviorY() !=
603 EScrollBoundaryBehavior::kAuto &&
604 std::abs(delta.Height()) > std::abs(delta.Width()))
605 scroll_state.ConsumeDeltaNative(0, delta.Height());
597 return; 606 return;
607 }
598 608
599 // FIXME: Native scrollers should only consume the scroll they 609 // FIXME: Native scrollers should only consume the scroll they
600 // apply. See crbug.com/457765. 610 // apply. See crbug.com/457765.
601 scroll_state.ConsumeDeltaNative(delta.Width(), delta.Height()); 611 scroll_state.ConsumeDeltaNative(delta.Width(), delta.Height());
602 612
603 // We need to setCurrentNativeScrollingElement in both the 613 // We need to setCurrentNativeScrollingElement in both the
604 // distributeScroll and applyScroll default implementations so 614 // distributeScroll and applyScroll default implementations so
605 // that if JS overrides one of these methods, but not the 615 // that if JS overrides one of these methods, but not the
606 // other, this bookkeeping remains accurate. 616 // other, this bookkeeping remains accurate.
607 scroll_state.SetCurrentNativeScrollingElement(this); 617 scroll_state.SetCurrentNativeScrollingElement(this);
(...skipping 3740 matching lines...) Expand 10 before | Expand all | Expand 10 after
4348 } 4358 }
4349 4359
4350 DEFINE_TRACE_WRAPPERS(Element) { 4360 DEFINE_TRACE_WRAPPERS(Element) {
4351 if (HasRareData()) { 4361 if (HasRareData()) {
4352 visitor->TraceWrappers(GetElementRareData()); 4362 visitor->TraceWrappers(GetElementRareData());
4353 } 4363 }
4354 ContainerNode::TraceWrappers(visitor); 4364 ContainerNode::TraceWrappers(visitor);
4355 } 4365 }
4356 4366
4357 } // namespace blink 4367 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698