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 9ca8b0c5e8bce9d61b99c3eac47a54ddb4c05d35..0d8a2695dfab58ad024be4e2a1a5575eb37d8c8f 100644 |
| --- a/third_party/WebKit/Source/core/frame/VisualViewport.cpp |
| +++ b/third_party/WebKit/Source/core/frame/VisualViewport.cpp |
| @@ -85,6 +85,27 @@ DEFINE_TRACE(VisualViewport) |
| ScrollableArea::trace(visitor); |
| } |
| +void VisualViewport::updateLayoutIgnorePendingStylesheets() |
| +{ |
| + if (!mainFrame()) |
| + return; |
| + |
| + Document* document = mainFrame()->document(); |
|
esprehn
2016/03/24 19:20:17
Can a frame really have a null document? When does
ymalik
2016/03/29 19:17:28
I am not sure. I see that LocalFrame::document() r
|
| + if (!document) |
| + return; |
| + |
| + document->updateLayoutIgnorePendingStylesheets(); |
| + return; |
| +} |
| + |
| +void VisualViewport::dispatchChangedEvent() |
| +{ |
| + if (RuntimeEnabledFeatures::visualViewportAPIEnabled()) { |
| + if (Document* document = mainFrame()->document()) |
| + document->dispatchVisualViewportChangedEvent(); |
| + } |
| +} |
| + |
| void VisualViewport::setSize(const IntSize& size) |
| { |
| if (m_size == size) |
| @@ -104,6 +125,8 @@ void VisualViewport::setSize(const IntSize& size) |
| if (!mainFrame()) |
| return; |
| + dispatchChangedEvent(); |
|
esprehn
2016/03/24 19:20:17
Did you really mean for this event to be sync? I t
ymalik
2016/03/29 19:17:28
You're right. This should be a per frame event. Fi
|
| + |
| bool autosizerNeedsUpdating = widthDidChange |
| && mainFrame()->settings() |
| && mainFrame()->settings()->textAutosizingEnabled(); |
| @@ -189,6 +212,55 @@ void VisualViewport::setScale(float scale) |
| setScaleAndLocation(scale, m_offset); |
| } |
| +double VisualViewport::scrollLeft() |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + return visibleRect().x(); |
| +} |
| + |
| +double VisualViewport::scrollTop() |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + return visibleRect().y(); |
| +} |
| + |
| +void VisualViewport::setScrollLeft(double x) |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + setLocation(FloatPoint(x, visibleRect().y())); |
| +} |
| + |
| +void VisualViewport::setScrollTop(double y) |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + setLocation(FloatPoint(visibleRect().x(), y)); |
| +} |
| + |
| +double VisualViewport::clientWidth() |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + return visibleRect().width(); |
| +} |
| + |
| +double VisualViewport::clientHeight() |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
|
esprehn
2016/03/24 19:20:17
This layout method should be private.
ymalik
2016/03/29 19:17:28
Done.
|
| + |
| + return visibleRect().height(); |
| +} |
| + |
| +double VisualViewport::pageScale() |
| +{ |
| + updateLayoutIgnorePendingStylesheets(); |
| + |
| + return m_scale; |
| +} |
| + |
| void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location) |
| { |
| if (!mainFrame()) |
| @@ -224,6 +296,8 @@ void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location |
| if (!valuesChanged) |
| return; |
| + dispatchChangedEvent(); |
| + |
| InspectorInstrumentation::didUpdateLayout(mainFrame()); |
| mainFrame()->loader().saveScrollState(); |