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/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/frame/UseCounter.h" |
8 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
9 #include "core/layout/line/InlineTextBox.h" | 10 #include "core/layout/line/InlineTextBox.h" |
10 #include "core/paint/PaintLayerScrollableArea.h" | 11 #include "core/paint/PaintLayerScrollableArea.h" |
| 12 #include "platform/Histogram.h" |
11 | 13 |
12 namespace blink { | 14 namespace blink { |
13 | 15 |
14 using Corner = ScrollAnchor::Corner; | 16 using Corner = ScrollAnchor::Corner; |
15 | 17 |
16 ScrollAnchor::ScrollAnchor(ScrollableArea* scroller) | 18 ScrollAnchor::ScrollAnchor(ScrollableArea* scroller) |
17 : m_scroller(scroller) | 19 : m_scroller(scroller) |
18 , m_anchorObject(nullptr) | 20 , m_anchorObject(nullptr) |
19 , m_corner(Corner::TopLeft) | 21 , m_corner(Corner::TopLeft) |
20 { | 22 { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 void ScrollAnchor::restore() | 168 void ScrollAnchor::restore() |
167 { | 169 { |
168 if (!m_anchorObject) | 170 if (!m_anchorObject) |
169 return; | 171 return; |
170 | 172 |
171 LayoutSize adjustment = computeRelativeOffset(m_anchorObject, m_scroller, m_
corner) - m_savedRelativeOffset; | 173 LayoutSize adjustment = computeRelativeOffset(m_anchorObject, m_scroller, m_
corner) - m_savedRelativeOffset; |
172 if (!adjustment.isZero()) { | 174 if (!adjustment.isZero()) { |
173 m_scroller->setScrollPosition( | 175 m_scroller->setScrollPosition( |
174 m_scroller->scrollPositionDouble() + DoubleSize(adjustment), | 176 m_scroller->scrollPositionDouble() + DoubleSize(adjustment), |
175 AnchoringScroll); | 177 AnchoringScroll); |
| 178 // Update UMA metric. |
| 179 DEFINE_STATIC_LOCAL(EnumerationHistogram, adjustedOffsetHistogram, |
| 180 ("Layout.ScrollAnchor.AdjustedScrollOffset", 2)); |
| 181 adjustedOffsetHistogram.count(1); |
| 182 UseCounter::count(scrollerLayoutBox(m_scroller)->document(), UseCounter:
:ScrollAnchored); |
176 } | 183 } |
177 } | 184 } |
178 | 185 |
179 void ScrollAnchor::clear() | 186 void ScrollAnchor::clear() |
180 { | 187 { |
181 LayoutObject* anchorObject = m_anchorObject; | 188 LayoutObject* anchorObject = m_anchorObject; |
182 m_anchorObject = nullptr; | 189 m_anchorObject = nullptr; |
183 | 190 |
184 if (anchorObject) | 191 if (anchorObject) |
185 anchorObject->maybeClearIsScrollAnchorObject(); | 192 anchorObject->maybeClearIsScrollAnchorObject(); |
186 } | 193 } |
187 | 194 |
188 } // namespace blink | 195 } // namespace blink |
OLD | NEW |