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

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: Created 4 years, 8 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 b39222f68a33ff374b35c481d6e747f8e115d93d..972c3bd1f4798080d8e9668818e0a3fc4dbaf597 100644
--- a/third_party/WebKit/Source/core/frame/VisualViewport.cpp
+++ b/third_party/WebKit/Source/core/frame/VisualViewport.cpp
@@ -85,6 +85,24 @@ DEFINE_TRACE(VisualViewport)
ScrollableArea::trace(visitor);
}
+void VisualViewport::updateLayoutIgnorePendingStylesheets()
+{
+ if (!mainFrame())
+ return;
+
+ if (Document* document = mainFrame()->document())
+ document->updateLayoutIgnorePendingStylesheets();
+}
+
+void VisualViewport::enqueueChangedEvent()
+{
+ if (!RuntimeEnabledFeatures::visualViewportAPIEnabled())
+ return;
+
+ if (Document* document = mainFrame()->document())
+ document->enqueueVisualViewportChangedEvent();
+}
+
void VisualViewport::setSize(const IntSize& size)
{
if (m_size == size)
@@ -104,6 +122,8 @@ void VisualViewport::setSize(const IntSize& size)
if (!mainFrame())
return;
+ enqueueChangedEvent();
+
bool autosizerNeedsUpdating = widthDidChange
&& mainFrame()->settings()
&& mainFrame()->settings()->textAutosizingEnabled();
@@ -189,6 +209,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 +293,8 @@ void VisualViewport::setScaleAndLocation(float scale, const FloatPoint& location
if (!valuesChanged)
return;
+ enqueueChangedEvent();
+
InspectorInstrumentation::didUpdateLayout(mainFrame());
mainFrame()->loader().saveScrollState();
« no previous file with comments | « third_party/WebKit/Source/core/frame/VisualViewport.h ('k') | third_party/WebKit/Source/core/frame/VisualViewport.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698