Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Unified Diff: third_party/WebKit/Source/core/frame/VisualViewport.cpp

Issue 1814013002: Visual viewport API initial implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make visualviewportchanged per frame + other review feedback Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..cc88f9ea3e6d59a30232119b9746a8cf5dfcbf72 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();
+ if (!document)
+ return;
+
+ document->updateLayoutIgnorePendingStylesheets();
esprehn 2016/03/31 05:15:37 we would normally write: if (Document* document =
ymalik 2016/04/01 17:15:37 Done.
+ return;
esprehn 2016/03/31 05:15:37 remove return
ymalik 2016/04/01 17:15:36 Done.
+}
+
+void VisualViewport::enqueueChangedEvent()
+{
+ if (RuntimeEnabledFeatures::visualViewportAPIEnabled()) {
esprehn 2016/03/31 05:15:37 early return instead of wrapping the whole functio
ymalik 2016/04/01 17:15:36 Done.
+ if (Document* document = mainFrame()->document())
+ document->enqueueVisualViewportChangedEvent();
+ }
+}
+
void VisualViewport::setSize(const IntSize& size)
{
if (m_size == size)
@@ -104,6 +125,8 @@ void VisualViewport::setSize(const IntSize& size)
if (!mainFrame())
return;
+ enqueueChangedEvent();
+
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();
+
+ 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;
+ enqueueChangedEvent();
+
InspectorInstrumentation::didUpdateLayout(mainFrame());
mainFrame()->loader().saveScrollState();

Powered by Google App Engine
This is Rietveld 408576698