Chromium Code Reviews| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 void ScrollAnchor::restore() | 158 void ScrollAnchor::restore() |
| 157 { | 159 { |
| 158 if (!m_anchorObject) | 160 if (!m_anchorObject) |
| 159 return; | 161 return; |
| 160 | 162 |
| 161 LayoutSize adjustment = computeRelativeOffset(m_anchorObject, m_scroller, m_ corner) - m_savedRelativeOffset; | 163 LayoutSize adjustment = computeRelativeOffset(m_anchorObject, m_scroller, m_ corner) - m_savedRelativeOffset; |
| 162 if (!adjustment.isZero()) { | 164 if (!adjustment.isZero()) { |
| 163 m_scroller->setScrollPosition( | 165 m_scroller->setScrollPosition( |
| 164 m_scroller->scrollPositionDouble() + DoubleSize(adjustment), | 166 m_scroller->scrollPositionDouble() + DoubleSize(adjustment), |
| 165 AnchoringScroll); | 167 AnchoringScroll); |
| 168 // Update UMA metric. | |
| 169 DEFINE_STATIC_LOCAL(EnumerationHistogram, adjustedOffsetHistogram, | |
| 170 ("Layout.ScrollAnchor.AdjustedScrollOffset", 2)); | |
| 171 adjustedOffsetHistogram.count(1); | |
| 172 if (m_scroller->isFrameView()) { | |
|
skobes
2016/03/24 18:59:11
You can do scrollerLayoutBox(m_scroller)->document
ymalik
2016/03/25 19:38:07
Done.
| |
| 173 UseCounter::count(toFrameView(m_scroller)->layoutView()->document(), UseCounter::ScrollAnchored); | |
| 174 } else { | |
| 175 ASSERT(m_scroller->isPaintLayerScrollableArea()); | |
| 176 UseCounter::count(toPaintLayerScrollableArea(m_scroller)->box().docu ment(), UseCounter::ScrollAnchored); | |
| 177 } | |
| 166 } | 178 } |
| 167 } | 179 } |
| 168 | 180 |
| 169 void ScrollAnchor::clear() | 181 void ScrollAnchor::clear() |
| 170 { | 182 { |
| 171 LayoutObject* anchorObject = m_anchorObject; | 183 LayoutObject* anchorObject = m_anchorObject; |
| 172 m_anchorObject = nullptr; | 184 m_anchorObject = nullptr; |
| 173 | 185 |
| 174 if (anchorObject) | 186 if (anchorObject) |
| 175 anchorObject->maybeClearIsScrollAnchorObject(); | 187 anchorObject->maybeClearIsScrollAnchorObject(); |
| 176 } | 188 } |
| 177 | 189 |
| 178 } // namespace blink | 190 } // namespace blink |
| OLD | NEW |