OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/layout/ScrollAnchor.h" | 5 #include "core/layout/ScrollAnchor.h" |
6 | 6 |
7 #include "core/dom/ClientRect.h" | 7 #include "core/dom/ClientRect.h" |
8 #include "core/frame/VisualViewport.h" | 8 #include "core/frame/VisualViewport.h" |
9 #include "core/layout/LayoutBox.h" | 9 #include "core/layout/LayoutBox.h" |
10 #include "core/layout/LayoutTestHelper.h" | 10 #include "core/layout/LayoutTestHelper.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 VisualViewport& visualViewport() { | 44 VisualViewport& visualViewport() { |
45 return document().view()->page()->visualViewport(); | 45 return document().view()->page()->visualViewport(); |
46 } | 46 } |
47 | 47 |
48 ScrollableArea* scrollerForElement(Element* element) { | 48 ScrollableArea* scrollerForElement(Element* element) { |
49 return toLayoutBox(element->layoutObject())->getScrollableArea(); | 49 return toLayoutBox(element->layoutObject())->getScrollableArea(); |
50 } | 50 } |
51 | 51 |
52 ScrollAnchor& scrollAnchor(ScrollableArea* scroller) { | 52 ScrollAnchor& scrollAnchor(ScrollableArea* scroller) { |
53 ASSERT(scroller->isFrameView() || scroller->isPaintLayerScrollableArea()); | 53 DCHECK(scroller->isFrameView() || scroller->isPaintLayerScrollableArea()); |
54 return *(scroller->scrollAnchor()); | 54 return *(scroller->scrollAnchor()); |
55 } | 55 } |
56 | 56 |
57 void setHeight(Element* element, int height) { | 57 void setHeight(Element* element, int height) { |
58 element->setAttribute(HTMLNames::styleAttr, | 58 element->setAttribute(HTMLNames::styleAttr, |
59 AtomicString(String::format("height: %dpx", height))); | 59 AtomicString(String::format("height: %dpx", height))); |
60 update(); | 60 update(); |
61 } | 61 } |
62 | 62 |
63 void scrollLayoutViewport(ScrollOffset delta) { | 63 void scrollLayoutViewport(ScrollOffset delta) { |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 | 1167 |
1168 scrollLayoutViewport(ScrollOffset(-50, 0)); | 1168 scrollLayoutViewport(ScrollOffset(-50, 0)); |
1169 | 1169 |
1170 a->setAttribute(HTMLNames::styleAttr, "width: 200px"); | 1170 a->setAttribute(HTMLNames::styleAttr, "width: 200px"); |
1171 b->setAttribute(HTMLNames::styleAttr, "height: 150px"); | 1171 b->setAttribute(HTMLNames::styleAttr, "height: 150px"); |
1172 update(); | 1172 update(); |
1173 EXPECT_EQ(ScrollOffset(-100, 150), viewport->getScrollOffset()); | 1173 EXPECT_EQ(ScrollOffset(-100, 150), viewport->getScrollOffset()); |
1174 EXPECT_EQ(c->layoutObject(), scrollAnchor(viewport).anchorObject()); | 1174 EXPECT_EQ(c->layoutObject(), scrollAnchor(viewport).anchorObject()); |
1175 } | 1175 } |
1176 } | 1176 } |
OLD | NEW |