Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/VisualViewport.cpp |
| diff --git a/third_party/WebKit/Source/core/frame/VisualViewport.cpp b/third_party/WebKit/Source/core/frame/VisualViewport.cpp |
| index 36f962068c3dd39c9ee25752b4aa7b901fa75685..06bf34f97786c519f17f3f3d758e1e6bebc5b96e 100644 |
| --- a/third_party/WebKit/Source/core/frame/VisualViewport.cpp |
| +++ b/third_party/WebKit/Source/core/frame/VisualViewport.cpp |
| @@ -87,6 +87,19 @@ DEFINE_TRACE(VisualViewport) |
| ScrollableArea::trace(visitor); |
| } |
| +void VisualViewport::updateLayoutIgnorePendingStylesheets() |
| +{ |
| + if (!mainFrame()) |
| + return; |
| + |
| + Document* document = mainFrame()->document(); |
| + if (!document) |
| + return; |
| + |
| + document->updateLayoutIgnorePendingStylesheets(); |
| + return; |
| +} |
| + |
| void VisualViewport::setSize(const IntSize& size) |
| { |
| if (m_size == size) |
| @@ -191,6 +204,57 @@ void VisualViewport::setScale(float scale) |
| setScaleAndLocation(scale, m_offset); |
| } |
| +double VisualViewport::scrollLeft() |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
|
ymalik
2016/03/18 13:30:57
@bokan, I am not sure whether we need to call upda
bokan
2016/03/18 16:05:07
I think we need it. The reason being that the visu
ymalik
2016/03/22 16:35:06
Acknowledged.
|
| + |
| + return visibleRect().x(); |
| +} |
| + |
| +double VisualViewport::scrollTop() |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + return visibleRect().y(); |
| +} |
| + |
| +void VisualViewport::setScrollLeft(double x) |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + DoublePoint layoutPos(x, visibleRect().y()); |
| + setScrollPosition(layoutPos, ProgrammaticScroll, ScrollBehaviorAuto); |
| +} |
| + |
| +void VisualViewport::setScrollTop(double y) |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + DoublePoint layoutPos(visibleRect().x(), y); |
| + setScrollPosition(layoutPos, ProgrammaticScroll, ScrollBehaviorAuto); |
| +} |
| + |
| +double VisualViewport::clientWidth() |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + return visibleRect().width(); |
| +} |
| + |
| +double VisualViewport::clientHeight() |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + return visibleRect().height(); |
| +} |
| + |
| +double VisualViewport::pageScale() |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + return m_scale; |
| +} |
| + |
| void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location) |
| { |
| if (!mainFrame()) |
| @@ -226,6 +290,13 @@ void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location |
| if (!valuesChanged) |
| return; |
| + if (RuntimeEnabledFeatures::visualViewportAPIEnabled()) { |
| + if (Document* document = mainFrame()->document()) { |
| + if (document->documentElement()) |
| + document->documentElement()->dispatchViewportChangedEvent(); |
| + } |
| + } |
| + |
| InspectorInstrumentation::didUpdateLayout(mainFrame()); |
| mainFrame()->loader().saveScrollState(); |