[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    patch + examples, change frameset.rows from js
From:       <koos.vriezen () xs4all ! nl>
Date:       2001-12-18 14:58:53
[Download RAW message or body]

Hi,

I didn't get any response on my previous posting, so I want to motivate
this patch more. I build a web application for a customer with JS and PHP.
It doesn't work in konqueror, because I can't resize frames from JS (also
document.open/write/close from event functions doesn't work, but I believe
its being worked on).

The js code:
index.html:
 <HTML><HEAD> </HEAD>
  <FRAMESET ROWS="200,*" ID='OUTERFRAME'>
   <FRAME SRC="topframe.html">
   <FRAME SRC="http://www.kde.org">
  </FRAMESET>
 </HTML>

topframe.html
 <HTML><HEAD><SCRIPT>
    function resizeFrame() {
        top.document.getElementById("OUTERFRAME").rows = "300,*";
    }
   </SCRIPT></HEAD>
  <BODY onClick='resizeFrame()'></BODY>
 </HTML>
doesn' work in the current CVS. Actually it causes a memory leak
(a QList<khtml::Length> object is created and the previous one is not
deleted).

I've attached the patch and two examples. Try frameset.html and
frameset2.html, its runs fine with this patch.
It works in IE. In Mozilla only the code above seems to work, and it stops
working after the frameborder is dragged.

What remains:
Dragging a frame border, doesn't update HTMLFrameSetElementImpl::m_rows.
Should that be fixed?

Regards,

Koos Vriezen





["frameset2.html" (TEXT/html)]

<HTML><HEAD><SCRIPT>
function resizeFrame(framename) {
        var fs = top.document.getElementById("TABFRAME");
	var rows = "";
	var sep = "";
	for (var i = 0; i < fs.childNodes.length; i++) {
		rows += sep + (fs.childNodes.item(i).firstChild.name == framename ? "*" : "15");
		sep = ",";
	}
        fs.rows = rows;
}
</SCRIPT></HEAD>
<FRAMESET ROWS="*,15,15" ID='TABFRAME'>
  <FRAMESET ROWS="15,*">
    <FRAME SRC="tabframe.html" NAME="M1" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING='NO'>
    <FRAME SRC="http://www.kde.org" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING='NO'>
  </FRAMESET>
  <FRAMESET ROWS="15,*">
    <FRAME SRC="tabframe.html" NAME="M2" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING='NO'>
    <FRAME SRC="http://slashdot.org" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING='NO'>
  </FRAMESET>
  <FRAMESET ROWS="15,*">
    <FRAME SRC="tabframe.html" NAME="M3" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING='NO'>
    <FRAME SRC="http://freshmeat.net" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING='NO'>
  </FRAMESET>
</FRAMESET>
</HTML>

["menuframe.html" (TEXT/html)]

<HTML><BODY>
<TABLE WIDTH='100%' BORDER=0 CELLSPACING=0 CELLPADDING=0>
  <TR><TD BGCOLOR='#8080ff' HEIGHT=15>
         <A HREF='JavaScript:top.resizeFrame(window.name)'>click me</A>
      </TD>
  <TR><TD><A HREF='http://slashdot.org' TARGET='mainframe'>Slashdot</A>
</TABLE>
</BODY></HTML>

["tabframe.html" (TEXT/html)]

<HTML><BODY BGCOLOR='#ff8080' onClick='top.resizeFrame(window.name)'>
</BODY></HTML>

["frameset.html" (TEXT/html)]

<HTML><HEAD><SCRIPT>
function resizeFrame(framename) {
        var fs = top.document.getElementById("MENUFRAME");
	var rows = "";
	var sep = "";
	for (var i = 0; i < fs.childNodes.length; i++) {
		rows += sep + (fs.childNodes.item(i).name == framename ? "*" : "15");
		sep = ",";
	}
        fs.rows = rows;
}
</SCRIPT></HEAD>
<FRAMESET COLS="200,*" ID='OUTERFRAME'>
  <FRAMESET ROWS="*,15,15,15" ID='MENUFRAME'>
    <FRAME SRC="menuframe.html" NAME="M1" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING='NO'>
    <FRAME SRC="menuframe.html" NAME="M2" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING='NO'>
    <FRAME SRC="menuframe.html" NAME="M3" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING='NO'>
    <FRAME SRC="menuframe.html" NAME="M4" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING='NO'>
  </FRAMESET>
  <FRAME NAME='mainframe' SRC="http://www.kde.org">
</FRAMESET>
</HTML>

["patch-kdelibs" (TEXT/PLAIN)]

--- kdelibs/khtml/html/html_baseimpl.cpp.orig	Sun Dec 16 19:15:35 2001
+++ kdelibs/khtml/html/html_baseimpl.cpp	Tue Dec 18 12:49:30 2001
@@ -385,12 +385,18 @@
     switch(attr->attrId)
     {
     case ATTR_ROWS:
+	delete m_rows;
         m_rows = attr->val()->toLengthList();
         m_totalRows = m_rows->count();
+	if (m_render)
+	    m_render->layout();
         break;
     case ATTR_COLS:
+	delete m_cols;
         m_cols = attr->val()->toLengthList();
         m_totalCols = m_cols->count();
+	if (m_render)
+	    m_render->layout();
         break;
     case ATTR_FRAMEBORDER:
         // false or "no" or "0"..
@@ -446,7 +452,7 @@
     if ( !r )
       return;
 
-    khtml::RenderFrameSet *renderFrameSet = new khtml::RenderFrameSet( this, w, \
m_rows, m_cols ); +    khtml::RenderFrameSet *renderFrameSet = new \
khtml::RenderFrameSet( this, w );  m_render = renderFrameSet;
     m_render->setStyle(m_style);
     r->addChild( m_render, nextRenderer() );
--- kdelibs/khtml/rendering/render_frames.cpp.orig	Mon Dec 17 14:03:09 2001
+++ kdelibs/khtml/rendering/render_frames.cpp	Tue Dec 18 12:48:51 2001
@@ -52,8 +52,7 @@
 using namespace khtml;
 using namespace DOM;
 
-RenderFrameSet::RenderFrameSet( HTMLFrameSetElementImpl *frameSet, KHTMLView *view,
-                                QPtrList<khtml::Length> *rows, \
QPtrList<khtml::Length> *cols ) +RenderFrameSet::RenderFrameSet( \
HTMLFrameSetElementImpl *frameSet, KHTMLView *view)  : RenderBox()
 {
   // init RenderObject attributes
@@ -61,19 +60,6 @@
 
   m_frameset = frameSet;
 
-  m_rows = rows;
-  m_cols = cols;
-
-  // another one for bad html
-  // handle <frameset cols="*" rows="100, ...">
-  if ( m_rows && m_cols ) {
-      // lets see if one of them is relative
-      if ( m_rows->count() == 1 && m_rows->at( 0 )->isRelative() )
-            m_rows = 0;
-      if ( m_cols->count() == 1 && m_cols->at( 0 )->isRelative() )
-          m_cols = 0;
-  }
-
   m_rowHeight = 0;
   m_colWidth = 0;
 
@@ -109,6 +95,17 @@
         m_width = m_view->visibleWidth();
         m_height = m_view->visibleHeight();
     }
+    QList<khtml::Length> *m_rows = m_frameset->m_rows;
+    QList<khtml::Length> *m_cols = m_frameset->m_cols;
+    // another one for bad html
+    // handle <frameset cols="*" rows="100, ...">
+    if ( m_rows && m_cols ) {
+	// lets see if one of them is relative
+	if ( m_rows->count() == 1 && m_rows->at( 0 )->isRelative() )
+	    m_rows = 0;
+	if ( m_cols->count() == 1 && m_cols->at( 0 )->isRelative() )
+	    m_cols = 0;
+    }
 
 #ifdef DEBUG_LAYOUT
     kdDebug( 6040 ) << renderName() << "(FrameSet)::layout( ) width=" << width() << \
", height=" << height() << endl; @@ -144,6 +141,7 @@
 		allFixed = false;
 	    else
 		totalFixed += m_rows->at(i)->value;
+	    kdDebug( 6040 ) << "RenderFrameSet::layout" << m_rows->at(i)->value << endl;
 	}
 	if ( allFixed && totalFixed ) {
 	    for(i = 0; i< m_frameset->totalRows(); i++) {
--- kdelibs/khtml/rendering/render_frames.h.orig	Mon Dec 17 21:38:54 2001
+++ kdelibs/khtml/rendering/render_frames.h	Tue Dec 18 12:48:13 2001
@@ -45,12 +45,7 @@
 {
   friend class DOM::HTMLFrameSetElementImpl;
 public:
-  RenderFrameSet( DOM::HTMLFrameSetElementImpl *frameSet, KHTMLView *view,
-#if QT_VERSION < 300
-                  QList<khtml::Length> *rows, QList<khtml::Length> *cols );
-#else
-                  QPtrList<khtml::Length> *rows, QPtrList<khtml::Length> *cols );
-#endif
+  RenderFrameSet( DOM::HTMLFrameSetElementImpl *frameSet, KHTMLView *view );
 
   virtual ~RenderFrameSet();
 
@@ -72,13 +67,6 @@
 
 private:
   DOM::HTMLFrameSetElementImpl *m_frameset;
-#if QT_VERSION < 300
-  QList<khtml::Length> *m_rows;
-  QList<khtml::Length> *m_cols;
-#else
-  QPtrList<khtml::Length> *m_rows;
-  QPtrList<khtml::Length> *m_cols;
-#endif
   KHTMLView *m_view;
   int *m_rowHeight;
   int *m_colWidth;



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic