Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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, don't scroll. | |
|
Rick Byers
2015/03/11 02:22:18
this comment says what (i.e. repeats the code belo
tdresser
2015/03/20 18:00:36
Done.
| |
| 495 if (!scrollState.shouldPropagate() | |
| 496 && scrollState.deltaConsumedForScrollSequence() | |
|
Rick Byers
2015/03/11 02:22:18
Can you add a comment to the declaration of deltaC
tdresser
2015/03/20 18:00:36
Can you clarify what about the comment doesn't mak
Rick Byers
2015/03/26 21:22:48
Ah, I was looking at the method declaration - didn
| |
| 497 && scrollState.currentNativeScrollingElement() != this) { | |
| 498 return; | |
| 499 } | |
| 500 | |
| 501 const double deltaX = scrollState.deltaX(); | |
| 502 const double deltaY = scrollState.deltaY(); | |
| 503 | |
| 504 applyScroll(scrollState); | |
| 505 | |
| 506 if (deltaX != scrollState.deltaX() || deltaY != scrollState.deltaY()) | |
| 507 scrollState.setCurrentNativeScrollingElement(this); | |
| 508 } | |
| 509 | |
| 510 void Element::applyScroll(ScrollState& scrollState) | |
| 511 { | |
| 512 ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled()); | |
| 513 if (scrollState.fullyConsumed()) | |
| 514 return; | |
| 515 | |
| 516 const double deltaX = scrollState.deltaX(); | |
| 517 const double deltaY = scrollState.deltaY(); | |
| 518 bool scrolled = false; | |
| 519 | |
| 520 // Handle the documentElement separately, as it scrolls the FrameView. | |
| 521 if (this == document().documentElement()) { | |
| 522 FloatSize delta(deltaX, deltaY); | |
| 523 if (document().frame()->applyScrollDelta(delta, scrollState.isBeginning( ))) | |
| 524 scrolled = true; | |
| 525 } else { | |
| 526 if (!layoutObject()) | |
| 527 return; | |
| 528 LayoutBox* curBox = layoutObject()->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()); | |
|
Rick Byers
2015/03/11 02:22:18
If curBox->scroll(ScrollLeft) returned true, but c
tdresser
2015/03/20 18:00:36
Done.
| |
| 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 2878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3372 { | 3437 { |
| 3373 #if ENABLE(OILPAN) | 3438 #if ENABLE(OILPAN) |
| 3374 if (hasRareData()) | 3439 if (hasRareData()) |
| 3375 visitor->trace(elementRareData()); | 3440 visitor->trace(elementRareData()); |
| 3376 visitor->trace(m_elementData); | 3441 visitor->trace(m_elementData); |
| 3377 #endif | 3442 #endif |
| 3378 ContainerNode::trace(visitor); | 3443 ContainerNode::trace(visitor); |
| 3379 } | 3444 } |
| 3380 | 3445 |
| 3381 } // namespace blink | 3446 } // namespace blink |
| OLD | NEW |