| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); | 118 ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); |
| 119 | 119 |
| 120 m_graphicsLayer->setShouldFlattenTransform(true); | 120 m_graphicsLayer->setShouldFlattenTransform(true); |
| 121 | 121 |
| 122 m_platformLayer = m_graphicsLayer->platformLayer(); | 122 m_platformLayer = m_graphicsLayer->platformLayer(); |
| 123 ASSERT_TRUE(m_platformLayer); | 123 ASSERT_TRUE(m_platformLayer); |
| 124 | 124 |
| 125 ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); | 125 ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 class FakeScrollableArea : public ScrollableArea { | 128 class FakeScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<FakeScro
llableArea>, public ScrollableArea { |
| 129 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FakeScrollableArea); |
| 129 public: | 130 public: |
| 131 static PassOwnPtrWillBeRawPtr<FakeScrollableArea> create() |
| 132 { |
| 133 return adoptPtrWillBeNoop(new FakeScrollableArea); |
| 134 } |
| 135 |
| 130 bool isActive() const override { return false; } | 136 bool isActive() const override { return false; } |
| 131 int scrollSize(ScrollbarOrientation) const override { return 100; } | 137 int scrollSize(ScrollbarOrientation) const override { return 100; } |
| 132 bool isScrollCornerVisible() const override { return false; } | 138 bool isScrollCornerVisible() const override { return false; } |
| 133 IntRect scrollCornerRect() const override { return IntRect(); } | 139 IntRect scrollCornerRect() const override { return IntRect(); } |
| 134 int visibleWidth() const override { return 10; } | 140 int visibleWidth() const override { return 10; } |
| 135 int visibleHeight() const override { return 10; } | 141 int visibleHeight() const override { return 10; } |
| 136 IntSize contentsSize() const override { return IntSize(100, 100); } | 142 IntSize contentsSize() const override { return IntSize(100, 100); } |
| 137 bool scrollbarsCanBeActive() const override { return false; } | 143 bool scrollbarsCanBeActive() const override { return false; } |
| 138 IntRect scrollableAreaBoundingBox() const override { return IntRect(); } | 144 IntRect scrollableAreaBoundingBox() const override { return IntRect(); } |
| 139 void invalidateScrollbarRect(Scrollbar*, const IntRect&) override { } | 145 void invalidateScrollbarRect(Scrollbar*, const IntRect&) override { } |
| 140 void invalidateScrollCornerRect(const IntRect&) override { } | 146 void invalidateScrollCornerRect(const IntRect&) override { } |
| 141 bool userInputScrollable(ScrollbarOrientation) const override { return true;
} | 147 bool userInputScrollable(ScrollbarOrientation) const override { return true;
} |
| 142 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } | 148 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } |
| 143 int pageStep(ScrollbarOrientation) const override { return 0; } | 149 int pageStep(ScrollbarOrientation) const override { return 0; } |
| 144 IntPoint minimumScrollPosition() const override { return IntPoint(); } | 150 IntPoint minimumScrollPosition() const override { return IntPoint(); } |
| 145 IntPoint maximumScrollPosition() const override | 151 IntPoint maximumScrollPosition() const override |
| 146 { | 152 { |
| 147 return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().
height() - visibleHeight()); | 153 return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().
height() - visibleHeight()); |
| 148 } | 154 } |
| 149 | 155 |
| 150 void setScrollOffset(const IntPoint& scrollOffset, ScrollType) override { m_
scrollPosition = scrollOffset; } | 156 void setScrollOffset(const IntPoint& scrollOffset, ScrollType) override { m_
scrollPosition = scrollOffset; } |
| 151 void setScrollOffset(const DoublePoint& scrollOffset, ScrollType) override {
m_scrollPosition = scrollOffset; } | 157 void setScrollOffset(const DoublePoint& scrollOffset, ScrollType) override {
m_scrollPosition = scrollOffset; } |
| 152 DoublePoint scrollPositionDouble() const override { return m_scrollPosition;
} | 158 DoublePoint scrollPositionDouble() const override { return m_scrollPosition;
} |
| 153 IntPoint scrollPosition() const override { return flooredIntPoint(m_scrollPo
sition); } | 159 IntPoint scrollPosition() const override { return flooredIntPoint(m_scrollPo
sition); } |
| 154 | 160 |
| 161 DEFINE_INLINE_VIRTUAL_TRACE() |
| 162 { |
| 163 ScrollableArea::trace(visitor); |
| 164 } |
| 165 |
| 155 private: | 166 private: |
| 156 DoublePoint m_scrollPosition; | 167 DoublePoint m_scrollPosition; |
| 157 }; | 168 }; |
| 158 | 169 |
| 159 TEST_F(GraphicsLayerTest, applyScrollToScrollableArea) | 170 TEST_F(GraphicsLayerTest, applyScrollToScrollableArea) |
| 160 { | 171 { |
| 161 FakeScrollableArea scrollableArea; | 172 OwnPtrWillBeRawPtr<FakeScrollableArea> scrollableArea = FakeScrollableArea::
create(); |
| 162 m_graphicsLayer->setScrollableArea(&scrollableArea, false); | 173 m_graphicsLayer->setScrollableArea(scrollableArea.get(), false); |
| 163 | 174 |
| 164 WebDoublePoint scrollPosition(7, 9); | 175 WebDoublePoint scrollPosition(7, 9); |
| 165 m_platformLayer->setScrollPositionDouble(scrollPosition); | 176 m_platformLayer->setScrollPositionDouble(scrollPosition); |
| 166 m_graphicsLayer->didScroll(); | 177 m_graphicsLayer->didScroll(); |
| 167 | 178 |
| 168 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea.scrollPositionDouble().x())
; | 179 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x()
); |
| 169 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea.scrollPositionDouble().y())
; | 180 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y()
); |
| 170 } | 181 } |
| 171 | 182 |
| 172 } // namespace blink | 183 } // namespace blink |
| OLD | NEW |