[webkit-dev] How to flatten frames?

Seo K zerocool.seo at gmail.com
Tue Jun 30 07:34:01 PDT 2009


Hi,

I want to flatten frames within a frameset so that no individual scrollbars
of frames would appear. This is the behavior of most mobile browsers
including iPhone and Android.

I found the patch from the Android WebKit source code with FLATTEN_FRAMESET.
I applied the patch to the latest version of WebKit and adjusted it the
latest changes, but it does not seem to work.

WebCore/rendering/RenderFrame.cpp

+#if USE(FLATTEN_FRAMESET)
+void RenderFrame::layout()
+{
+    if (widget() && widget()->isFrameView()) {
+        FrameView* view = static_cast<FrameView*>(widget());
+        RenderView* root = NULL;
+        if (view->frame() && view->frame()->document() &&
+            view->frame()->document()->renderer() &&
view->frame()->document()->renderer()->isRenderView())
+            root =
static_cast<RenderView*>(view->frame()->document()->renderer());
+        if (root) {
+            // Resize the widget so that the RenderView will layout
according to those dimensions.
+            view->resize(m_width, m_height);
+            view->layout();
+            // We can only grow in width and height because if
positionFrames gives us a width and we become smaller,
+            // then the fixup process of forcing the frame to fill extra
space will fail.
+            if (m_width > root->docWidth()) {
+                view->resize(root->docWidth(), 0);
+                view->layout();
+            }
+            // Honor the height set by RenderFrameSet::positionFrames
unless our document height is larger.
+            setHeight(max(root->docHeight(), height()));
+            setWidth(max(root->docWidth(), width()));
+        }
+    }
+    setNeedsLayout(false);
+}
+#endif
+


I tested it with http://java.sun.com/j2se/1.5.0/docs/api/ which has three
frames within a frameset.

GtkLauncher hangs when it loads the Java API page. However, after I remove
the following two lines from the patch, it seems to work and frames are
correctly flattened.

        if (root) {
            // Resize the widget so that the RenderView will layout
according to those dimensions.
-            view->resize(m_width, m_height);
-            view->layout();
            // We can only grow in width and height because if
positionFrames gives us a width and we become smaller,
            // then the fixup process of forcing the frame to fill extra
space will fail.


What's the problem here? I attached the whole patch.

Thanks,
K Seo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090630/c82d7280/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FlattenFrameSet.diff
Type: text/x-patch
Size: 10028 bytes
Desc: not available
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090630/c82d7280/attachment.bin>


More information about the webkit-dev mailing list