Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/frame/VisualViewport.h" | 31 #include "core/frame/VisualViewport.h" |
| 32 | 32 |
| 33 #include "core/dom/DOMNodeIds.h" | 33 #include "core/dom/DOMNodeIds.h" |
| 34 #include "core/frame/FrameHost.h" | 34 #include "core/frame/FrameHost.h" |
| 35 #include "core/frame/FrameView.h" | 35 #include "core/frame/FrameView.h" |
| 36 #include "core/frame/LocalFrame.h" | 36 #include "core/frame/LocalFrame.h" |
| 37 #include "core/frame/PageScaleConstraints.h" | 37 #include "core/frame/PageScaleConstraints.h" |
| 38 #include "core/frame/PageScaleConstraintsSet.h" | 38 #include "core/frame/PageScaleConstraintsSet.h" |
| 39 #include "core/frame/ScrollAndScaleEmulator.h" | |
| 39 #include "core/frame/Settings.h" | 40 #include "core/frame/Settings.h" |
| 40 #include "core/inspector/InspectorInstrumentation.h" | 41 #include "core/inspector/InspectorInstrumentation.h" |
| 41 #include "core/layout/TextAutosizer.h" | 42 #include "core/layout/TextAutosizer.h" |
| 42 #include "core/layout/compositing/PaintLayerCompositor.h" | 43 #include "core/layout/compositing/PaintLayerCompositor.h" |
| 43 #include "core/loader/FrameLoaderClient.h" | 44 #include "core/loader/FrameLoaderClient.h" |
| 44 #include "core/page/ChromeClient.h" | 45 #include "core/page/ChromeClient.h" |
| 45 #include "core/page/Page.h" | 46 #include "core/page/Page.h" |
| 46 #include "core/page/scrolling/ScrollingCoordinator.h" | 47 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 47 #include "platform/Histogram.h" | 48 #include "platform/Histogram.h" |
| 48 #include "platform/TraceEvent.h" | 49 #include "platform/TraceEvent.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 void VisualViewport::move(const FloatSize& delta) | 216 void VisualViewport::move(const FloatSize& delta) |
| 216 { | 217 { |
| 217 setLocation(m_offset + delta); | 218 setLocation(m_offset + delta); |
| 218 } | 219 } |
| 219 | 220 |
| 220 void VisualViewport::setScale(float scale) | 221 void VisualViewport::setScale(float scale) |
| 221 { | 222 { |
| 222 setScaleAndLocation(scale, m_offset); | 223 setScaleAndLocation(scale, m_offset); |
| 223 } | 224 } |
| 224 | 225 |
| 226 void VisualViewport::setScrollAndScaleEmulator(const RefPtr<ScrollAndScaleEmulat or>& emulator) | |
| 227 { | |
| 228 m_scrollAndScaleEmulator = emulator; | |
| 229 setScaleAndLocation(scale(), location()); | |
|
bokan
2016/07/01 21:05:12
We should call setScaleAndLocation to clamp the sc
Eric Seckler
2016/07/04 14:33:08
Done, using clampToBoundaries() now. (This boils d
| |
| 230 } | |
| 231 | |
| 225 double VisualViewport::scrollLeft() | 232 double VisualViewport::scrollLeft() |
| 226 { | 233 { |
| 227 if (!mainFrame()) | 234 if (!mainFrame()) |
| 228 return 0; | 235 return 0; |
| 229 | 236 |
| 230 updateStyleAndLayoutIgnorePendingStylesheets(); | 237 updateStyleAndLayoutIgnorePendingStylesheets(); |
| 231 | 238 |
| 232 return adjustScrollForAbsoluteZoom(visibleRect().x(), mainFrame()->pageZoomF actor()); | 239 return adjustScrollForAbsoluteZoom(visibleRect().x(), mainFrame()->pageZoomF actor()); |
| 233 } | 240 } |
| 234 | 241 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 } | 550 } |
| 544 | 551 |
| 545 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const | 552 int VisualViewport::scrollSize(ScrollbarOrientation orientation) const |
| 546 { | 553 { |
| 547 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition() ; | 554 IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition() ; |
| 548 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr ollDimensions.height(); | 555 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() : scr ollDimensions.height(); |
| 549 } | 556 } |
| 550 | 557 |
| 551 IntPoint VisualViewport::minimumScrollPosition() const | 558 IntPoint VisualViewport::minimumScrollPosition() const |
| 552 { | 559 { |
| 553 return IntPoint(); | 560 return flooredIntPoint(minimumScrollPositionDouble()); |
| 561 } | |
| 562 | |
| 563 DoublePoint VisualViewport::minimumScrollPositionDouble() const | |
| 564 { | |
| 565 if (m_scrollAndScaleEmulator) { | |
| 566 DoublePoint minimum = calculateMinimumScrollPositionDouble(); | |
| 567 DoublePoint maximum = calculateMaximumScrollPositionDouble(); | |
| 568 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(min imum, minimum, maximum); | |
| 569 } | |
| 570 | |
| 571 return calculateMinimumScrollPositionDouble(); | |
| 572 } | |
| 573 | |
| 574 DoublePoint VisualViewport::calculateMinimumScrollPositionDouble() const | |
| 575 { | |
| 576 return DoublePoint(); | |
| 554 } | 577 } |
| 555 | 578 |
| 556 IntPoint VisualViewport::maximumScrollPosition() const | 579 IntPoint VisualViewport::maximumScrollPosition() const |
| 557 { | 580 { |
| 558 return flooredIntPoint(maximumScrollPositionDouble()); | 581 return flooredIntPoint(maximumScrollPositionDouble()); |
| 559 } | 582 } |
| 560 | 583 |
| 561 DoublePoint VisualViewport::maximumScrollPositionDouble() const | 584 DoublePoint VisualViewport::maximumScrollPositionDouble() const |
| 562 { | 585 { |
| 586 if (m_scrollAndScaleEmulator) { | |
| 587 DoublePoint minimum = calculateMinimumScrollPositionDouble(); | |
| 588 DoublePoint maximum = calculateMaximumScrollPositionDouble(); | |
| 589 return m_scrollAndScaleEmulator->applyVisualViewportPositionOverride(max imum, minimum, maximum); | |
| 590 } | |
| 591 | |
| 592 return calculateMaximumScrollPositionDouble(); | |
| 593 } | |
| 594 | |
| 595 DoublePoint VisualViewport::calculateMaximumScrollPositionDouble() const | |
| 596 { | |
| 563 if (!mainFrame()) | 597 if (!mainFrame()) |
| 564 return IntPoint(); | 598 return IntPoint(); |
| 565 | 599 |
| 566 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu g.com/470718. | 600 // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbu g.com/470718. |
| 567 FloatSize frameViewSize(contentsSize()); | 601 FloatSize frameViewSize(contentsSize()); |
| 568 | 602 |
| 569 if (m_topControlsAdjustment) { | 603 if (m_topControlsAdjustment) { |
| 570 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints( ).minimumScale; | 604 float minScale = frameHost().pageScaleConstraintsSet().finalConstraints( ).minimumScale; |
| 571 frameViewSize.expand(0, m_topControlsAdjustment / minScale); | 605 frameViewSize.expand(0, m_topControlsAdjustment / minScale); |
| 572 } | 606 } |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 832 } else if (graphicsLayer == m_rootTransformLayer.get()) { | 866 } else if (graphicsLayer == m_rootTransformLayer.get()) { |
| 833 name = "Root Transform Layer"; | 867 name = "Root Transform Layer"; |
| 834 } else { | 868 } else { |
| 835 ASSERT_NOT_REACHED(); | 869 ASSERT_NOT_REACHED(); |
| 836 } | 870 } |
| 837 | 871 |
| 838 return name; | 872 return name; |
| 839 } | 873 } |
| 840 | 874 |
| 841 } // namespace blink | 875 } // namespace blink |
| OLD | NEW |