summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
authorGrace Kloba <klobag@google.com>2010-05-26 12:27:41 -0700
committerGrace Kloba <klobag@google.com>2010-05-27 11:19:34 -0700
commita551d0e188b3b4a05e05cc70ff0838c3165c10f6 (patch)
tree2beaf6e70229eae75bbd9f467d7f9727aadcb807 /WebCore
parent619aaff8ae3a2b4614393bac582ef28cf2d7939b (diff)
downloadexternal_webkit-a551d0e188b3b4a05e05cc70ff0838c3165c10f6.zip
external_webkit-a551d0e188b3b4a05e05cc70ff0838c3165c10f6.tar.gz
external_webkit-a551d0e188b3b4a05e05cc70ff0838c3165c10f6.tar.bz2
Report correct window.innerWidth and window.innerHeight.
I agree with this article that we should have a way to report the visible viewport to the JavaScript. http://www.quirksmode.org/mobile/viewports2.html#link6 Fix http://b/issue?id=2717861 I will try to upstream the code to WebKit separately.
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/page/DOMWindow.cpp16
-rw-r--r--WebCore/platform/ScrollView.cpp30
-rw-r--r--WebCore/platform/ScrollView.h14
-rw-r--r--WebCore/platform/android/ScrollViewAndroid.cpp28
4 files changed, 88 insertions, 0 deletions
diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp
index 633feb6..a564cf4 100644
--- a/WebCore/page/DOMWindow.cpp
+++ b/WebCore/page/DOMWindow.cpp
@@ -954,7 +954,11 @@ int DOMWindow::innerHeight() const
if (!view)
return 0;
+#if PLATFORM(ANDROID)
+ return static_cast<int>(view->actualHeight() / m_frame->pageZoomFactor());
+#else
return static_cast<int>(view->height() / m_frame->pageZoomFactor());
+#endif
}
int DOMWindow::innerWidth() const
@@ -966,7 +970,11 @@ int DOMWindow::innerWidth() const
if (!view)
return 0;
+#if PLATFORM(ANDROID)
+ return static_cast<int>(view->actualWidth() / m_frame->pageZoomFactor());
+#else
return static_cast<int>(view->width() / m_frame->pageZoomFactor());
+#endif
}
int DOMWindow::screenX() const
@@ -1004,7 +1012,11 @@ int DOMWindow::scrollX() const
m_frame->document()->updateLayoutIgnorePendingStylesheets();
+#if PLATFORM(ANDROID)
+ return static_cast<int>(view->actualScrollX() / m_frame->pageZoomFactor());
+#else
return static_cast<int>(view->scrollX() / m_frame->pageZoomFactor());
+#endif
}
int DOMWindow::scrollY() const
@@ -1018,7 +1030,11 @@ int DOMWindow::scrollY() const
m_frame->document()->updateLayoutIgnorePendingStylesheets();
+#if PLATFORM(ANDROID)
+ return static_cast<int>(view->actualScrollY() / m_frame->pageZoomFactor());
+#else
return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor());
+#endif
}
bool DOMWindow::closed() const
diff --git a/WebCore/platform/ScrollView.cpp b/WebCore/platform/ScrollView.cpp
index 704f146..3fcb68d 100644
--- a/WebCore/platform/ScrollView.cpp
+++ b/WebCore/platform/ScrollView.cpp
@@ -266,6 +266,36 @@ void ScrollView::setContentsSize(const IntSize& newSize)
updateScrollbars(scrollOffset());
}
+#if PLATFORM(ANDROID)
+int ScrollView::actualWidth() const
+{
+ if (platformWidget())
+ return platformActualWidth();
+ return width();
+}
+
+int ScrollView::actualHeight() const
+{
+ if (platformWidget())
+ return platformActualHeight();
+ return height();
+}
+
+int ScrollView::actualScrollX() const
+{
+ if (platformWidget())
+ return platformActualScrollX();
+ return scrollX();
+}
+
+int ScrollView::actualScrollY() const
+{
+ if (platformWidget())
+ return platformActualScrollY();
+ return scrollY();
+}
+#endif
+
IntPoint ScrollView::maximumScrollPosition() const
{
IntSize maximumOffset = contentsSize() - visibleContentRect().size();
diff --git a/WebCore/platform/ScrollView.h b/WebCore/platform/ScrollView.h
index e0c50d3..27bdedd 100644
--- a/WebCore/platform/ScrollView.h
+++ b/WebCore/platform/ScrollView.h
@@ -142,6 +142,13 @@ public:
int contentsHeight() const { return contentsSize().height(); }
virtual void setContentsSize(const IntSize&);
+#if PLATFORM(ANDROID)
+ int actualWidth() const;
+ int actualHeight() const;
+ int actualScrollX() const;
+ int actualScrollY() const;
+#endif
+
// Functions for querying the current scrolled position (both as a point, a size, or as individual X and Y values).
IntPoint scrollPosition() const { return visibleContentRect().location(); }
IntSize scrollOffset() const { return visibleContentRect().location() - IntPoint(); } // Gets the scrolled position as an IntSize. Convenient for adding to other sizes.
@@ -319,6 +326,13 @@ private:
void platformRepaintContentRectangle(const IntRect&, bool now);
bool platformIsOffscreen() const;
+#if PLATFORM(ANDROID)
+ int platformActualWidth() const;
+ int platformActualHeight() const;
+ int platformActualScrollX() const;
+ int platformActualScrollY() const;
+#endif
+
#if PLATFORM(MAC) && defined __OBJC__
public:
NSView* documentView() const;
diff --git a/WebCore/platform/android/ScrollViewAndroid.cpp b/WebCore/platform/android/ScrollViewAndroid.cpp
index 7efc8c1..f5735ab 100644
--- a/WebCore/platform/android/ScrollViewAndroid.cpp
+++ b/WebCore/platform/android/ScrollViewAndroid.cpp
@@ -66,6 +66,34 @@ IntSize ScrollView::platformContentsSize() const
return m_contentsSize;
}
+int ScrollView::platformActualWidth() const
+{
+ if (parent())
+ return width();
+ return platformWidget()->visibleWidth();
+}
+
+int ScrollView::platformActualHeight() const
+{
+ if (parent())
+ return height();
+ return platformWidget()->visibleHeight();
+}
+
+int ScrollView::platformActualScrollX() const
+{
+ if (parent())
+ return scrollX();
+ return platformWidget()->visibleX();
+}
+
+int ScrollView::platformActualScrollY() const
+{
+ if (parent())
+ return scrollY();
+ return platformWidget()->visibleY();
+}
+
void ScrollView::platformSetScrollPosition(const WebCore::IntPoint& pt)
{
if (parent()) // don't attempt to scroll subframes; they're fully visible