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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 clampedOffset = clampedOffset.shrunkTo(FloatPoint(maximumScrollPositionDoubl
e())); | 585 clampedOffset = clampedOffset.shrunkTo(FloatPoint(maximumScrollPositionDoubl
e())); |
586 clampedOffset = clampedOffset.expandedTo(FloatPoint(minimumScrollPositionDou
ble())); | 586 clampedOffset = clampedOffset.expandedTo(FloatPoint(minimumScrollPositionDou
ble())); |
587 return clampedOffset; | 587 return clampedOffset; |
588 } | 588 } |
589 | 589 |
590 void PinchViewport::clampToBoundaries() | 590 void PinchViewport::clampToBoundaries() |
591 { | 591 { |
592 setLocation(m_offset); | 592 setLocation(m_offset); |
593 } | 593 } |
594 | 594 |
| 595 FloatRect PinchViewport::viewportToRootFrame(const FloatRect& rectInViewport) co
nst |
| 596 { |
| 597 FloatRect rectInRootFrame = rectInViewport; |
| 598 rectInRootFrame.scale(1 / scale()); |
| 599 rectInRootFrame.moveBy(location()); |
| 600 return rectInRootFrame; |
| 601 } |
| 602 |
| 603 IntRect PinchViewport::viewportToRootFrame(const IntRect& rectInViewport) const |
| 604 { |
| 605 // FIXME: How to snap to pixels? |
| 606 return enclosingIntRect(viewportToRootFrame(FloatRect(rectInViewport))); |
| 607 } |
| 608 |
| 609 FloatRect PinchViewport::rootFrameToViewport(const FloatRect& rectInRootFrame) c
onst |
| 610 { |
| 611 FloatRect rectInViewport = rectInRootFrame; |
| 612 rectInViewport.moveBy(-location()); |
| 613 rectInViewport.scale(scale()); |
| 614 return rectInViewport; |
| 615 } |
| 616 |
| 617 IntRect PinchViewport::rootFrameToViewport(const IntRect& rectInRootFrame) const |
| 618 { |
| 619 // FIXME: How to snap to pixels? |
| 620 return enclosingIntRect(rootFrameToViewport(FloatRect(rectInRootFrame))); |
| 621 } |
| 622 |
| 623 FloatPoint PinchViewport::viewportToRootFrame(const FloatPoint& pointInViewport)
const |
| 624 { |
| 625 FloatPoint pointInRootFrame = pointInViewport; |
| 626 pointInRootFrame.scale(1 / scale(), 1 / scale()); |
| 627 pointInRootFrame.moveBy(location()); |
| 628 return pointInRootFrame; |
| 629 } |
| 630 |
| 631 FloatPoint PinchViewport::rootFrameToViewport(const FloatPoint& pointInRootFrame
) const |
| 632 { |
| 633 FloatPoint pointInViewport = pointInRootFrame; |
| 634 pointInViewport.moveBy(-location()); |
| 635 pointInViewport.scale(scale(), scale()); |
| 636 return pointInViewport; |
| 637 } |
| 638 |
| 639 IntPoint PinchViewport::viewportToRootFrame(const IntPoint& pointInViewport) con
st |
| 640 { |
| 641 // FIXME: How to snap to pixels? |
| 642 return flooredIntPoint(FloatPoint(viewportToRootFrame(FloatPoint(pointInView
port)))); |
| 643 } |
| 644 |
| 645 IntPoint PinchViewport::rootFrameToViewport(const IntPoint& pointInRootFrame) co
nst |
| 646 { |
| 647 // FIXME: How to snap to pixels? |
| 648 return flooredIntPoint(FloatPoint(rootFrameToViewport(FloatPoint(pointInRoot
Frame)))); |
| 649 } |
| 650 |
595 String PinchViewport::debugName(const GraphicsLayer* graphicsLayer) | 651 String PinchViewport::debugName(const GraphicsLayer* graphicsLayer) |
596 { | 652 { |
597 String name; | 653 String name; |
598 if (graphicsLayer == m_innerViewportContainerLayer.get()) { | 654 if (graphicsLayer == m_innerViewportContainerLayer.get()) { |
599 name = "Inner Viewport Container Layer"; | 655 name = "Inner Viewport Container Layer"; |
600 } else if (graphicsLayer == m_overscrollElasticityLayer.get()) { | 656 } else if (graphicsLayer == m_overscrollElasticityLayer.get()) { |
601 name = "Overscroll Elasticity Layer"; | 657 name = "Overscroll Elasticity Layer"; |
602 } else if (graphicsLayer == m_pageScaleLayer.get()) { | 658 } else if (graphicsLayer == m_pageScaleLayer.get()) { |
603 name = "Page Scale Layer"; | 659 name = "Page Scale Layer"; |
604 } else if (graphicsLayer == m_innerViewportScrollLayer.get()) { | 660 } else if (graphicsLayer == m_innerViewportScrollLayer.get()) { |
605 name = "Inner Viewport Scroll Layer"; | 661 name = "Inner Viewport Scroll Layer"; |
606 } else if (graphicsLayer == m_overlayScrollbarHorizontal.get()) { | 662 } else if (graphicsLayer == m_overlayScrollbarHorizontal.get()) { |
607 name = "Overlay Scrollbar Horizontal Layer"; | 663 name = "Overlay Scrollbar Horizontal Layer"; |
608 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { | 664 } else if (graphicsLayer == m_overlayScrollbarVertical.get()) { |
609 name = "Overlay Scrollbar Vertical Layer"; | 665 name = "Overlay Scrollbar Vertical Layer"; |
610 } else if (graphicsLayer == m_rootTransformLayer) { | 666 } else if (graphicsLayer == m_rootTransformLayer) { |
611 name = "Root Transform Layer"; | 667 name = "Root Transform Layer"; |
612 } else { | 668 } else { |
613 ASSERT_NOT_REACHED(); | 669 ASSERT_NOT_REACHED(); |
614 } | 670 } |
615 | 671 |
616 return name; | 672 return name; |
617 } | 673 } |
618 | 674 |
619 } // namespace blink | 675 } // namespace blink |
OLD | NEW |