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

Unified Diff: Source/WebKit/chromium/src/WebViewImpl.cpp

Issue 8714006: Add autoresize capability for Chromium. (Closed) Base URL: http://git.chromium.org/external/WebKit_trimmed.git@master
Patch Set: Current patch Created 9 years, 1 month 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: Source/WebKit/chromium/src/WebViewImpl.cpp
diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp
index ba403eb26d34f16de3458e3e6545636b9ddd2dd1..94ba6bee05cdb6d0002989b2f1b97a60e30a0efe 100644
--- a/Source/WebKit/chromium/src/WebViewImpl.cpp
+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp
@@ -56,6 +56,7 @@
#include "Extensions3D.h"
#include "FocusController.h"
#include "FontDescription.h"
+#include "Frame.h"
#include "FrameLoader.h"
#include "FrameSelection.h"
#include "FrameTree.h"
@@ -334,6 +335,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
, m_dragClientImpl(this)
, m_editorClientImpl(this)
, m_inspectorClientImpl(this)
+ , m_shouldAutoSize(false)
, m_observedNewNavigation(false)
#ifndef NDEBUG
, m_newNavigationLoader(0)
@@ -1041,6 +1043,7 @@ void WebViewImpl::willStartLiveResize()
void WebViewImpl::resize(const WebSize& newSize)
{
+ ASSERT(!m_shouldAutoSize);
if (m_size == newSize)
return;
m_size = newSize;
@@ -2050,6 +2053,17 @@ void WebViewImpl::enableFixedLayoutMode(bool enable)
#endif
}
+void WebViewImpl::enableAutoSizeMode(bool enable, const WebSize& minSize, const WebSize& maxSize)
+{
+ m_shouldAutoSize = enable;
+ m_minAutoSize = minSize;
+ m_maxAutoSize = maxSize;
+ if (!mainFrameImpl() || !mainFrameImpl()->frame() || !mainFrameImpl()->frame()->view())
+ return;
+
+ mainFrameImpl()->frame()->view()->enableAutoSizeMode(m_shouldAutoSize, m_minAutoSize, m_maxAutoSize);
+}
+
void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScale)
{
m_minimumPageScaleFactor = min(max(minPageScale, minPageScaleFactor), maxPageScaleFactor) * deviceScaleFactor();
@@ -2548,6 +2562,28 @@ void WebViewImpl::layoutUpdated(WebFrameImpl* webframe)
if (!m_client || webframe != mainFrameImpl())
return;
+ if (m_shouldAutoSize && mainFrameImpl()->frame() && mainFrameImpl()->frame()->view()) {
+ WebSize frameSize = mainFrameImpl()->frame()->view()->frameRect().size();
+ if (frameSize != m_size) {
+ m_size = frameSize;
+ m_client->setSize(m_size);
+ // TODO: move to higher level?? this is sync in after the layout code??
darin (slow to review) 2011/11/30 23:29:05 making this async could also introduce problems as
levin 2011/12/01 20:23:45 After looking at this code further, I realized tha
+ // TODO: Before checking in make this async (to avoid unexpected recursion in js code)
levin 2011/11/30 12:03:47 This needs to be fixed up still and possibly conso
+ // and don't allow this resize event to trigger another resize event.
+ mainFrameImpl()->frame()->eventHandler()->sendResizeEvent();
+
+ // Should this just call void WebViewImpl::resize(const WebSize& newSize)?
darin (slow to review) 2011/11/30 23:29:05 probably should factor out some common code into a
levin 2011/12/01 20:23:45 Done.
+ if (isAcceleratedCompositingActive()) {
+#if USE(ACCELERATED_COMPOSITING)
+ updateLayerTreeViewport();
+#endif
+ } else {
+ WebRect damagedRect(0, 0, m_size.width, m_size.height);
+ m_client->didInvalidateRect(damagedRect);
+ }
+ }
+ }
+
m_client->didUpdateLayout();
}
« Source/WebKit/chromium/public/WebWidgetClient.h ('K') | « Source/WebKit/chromium/src/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698