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

List:       kfm-devel
Subject:    PATCH: doc height w/positioned elements
From:       Peter Kelly <pmkelly () dingoblue ! net ! au>
Date:       2001-02-01 12:58:11
[Download RAW message or body]

Here is a revised version of my patch for document height calculations
(see bug #17931). It now also gives the correct document width where
positioned
elements are used. Have checked with Antti about the m_marginBottom
stuff and he
says my change there was correct.

May I commit?

--
Peter Kelly
pmk@post.com
["17931_new.patch" (text/plain)]

? khtml.kdevprj
Index: rendering/render_box.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_box.cpp,v
retrieving revision 1.103
diff -u -p -r1.103 render_box.cpp
--- rendering/render_box.cpp	2001/01/28 17:05:22	1.103
+++ rendering/render_box.cpp	2001/02/01 12:38:12
@@ -857,8 +857,8 @@ void RenderBox::calcAbsoluteHorizontal()
     }
 
     m_width = w + pab;
-    m_marginLeft = ml+l;
-    m_marginRight = mr+r;
+    m_marginLeft = ml;
+    m_marginRight = mr;
     m_x = l + ml + containingBlock()->borderLeft();
 
 //    printf("h: w=%d, l=%d, r=%d, ml=%d, mr=%d\n",w,l,r,ml,mr);
@@ -947,12 +947,8 @@ void RenderBox::calcAbsoluteVertical()
     if (m_height<h+pab)
         m_height = h+pab;
 
-    // add the top and bottom distance to the value of margin.
-    // in principle this is incorrect, but no one (except
-    // the document height code, where it is useful) should
-    // care about it anyway
-    m_marginTop = mt+t;
-    m_marginBottom = mb+b;
+    m_marginTop = mt;
+    m_marginBottom = mb;
     m_y = t + mt + containingBlock()->borderTop();
 
 //    printf("v: h=%d, t=%d, b=%d, mt=%d, mb=%d, m_y=%d\n",h,t,b,mt,mb,m_y);
@@ -963,6 +959,11 @@ void RenderBox::calcAbsoluteVertical()
 int RenderBox::lowestPosition() const
 {
     return m_height + marginBottom();
+}
+
+int RenderBox::rightmostPosition() const
+{
+    return m_width + marginLeft();
 }
 
 #undef DEBUG_LAYOUT
Index: rendering/render_box.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_box.h,v
retrieving revision 1.29
diff -u -p -r1.29 render_box.h
--- rendering/render_box.h	2001/01/20 17:13:17	1.29
+++ rendering/render_box.h	2001/02/01 12:38:30
@@ -92,6 +92,7 @@ public:
     virtual unsigned int width( int, int) const { return width(); }
 
     virtual int lowestPosition() const;
+    virtual int rightmostPosition() const;
 
     void repaint();
 
Index: rendering/render_flow.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_flow.cpp,v
retrieving revision 1.168
diff -u -p -r1.168 render_flow.cpp
--- rendering/render_flow.cpp	2001/01/28 18:29:36	1.168
+++ rendering/render_flow.cpp	2001/02/01 12:38:46
@@ -784,7 +784,7 @@ RenderFlow::floatBottom() const
 int
 RenderFlow::lowestPosition() const
 {
-    int bottom = m_height + marginBottom();
+    int bottom = RenderBox::lowestPosition();
     int lp = 0;
     if ( !m_childrenInline ) {
         RenderObject *last = lastChild();
@@ -804,10 +804,10 @@ RenderFlow::lowestPosition() const
         QListIterator<SpecialObject> it(*specialObjects);
         for ( ; (r = it.current()); ++it ) {
             lp = 0;
-            if ( r->type < SpecialObject::Positioned ) {
+            if ( r->type == SpecialObject::FloatLeft || r->type == \
SpecialObject::FloatRight ){  lp = r->startY + r->node->lowestPosition();
                 //kdDebug(0) << r->node->renderName() << " lp = " << lp << "startY=" \
                << r->startY << endl;
-            } else if ( r->type <= SpecialObject::Positioned ) {
+            } else if ( r->type == SpecialObject::Positioned ) {
                 lp = r->node->yPos() + r->node->lowestPosition();
             }
             if( lp > bottom)
@@ -817,6 +817,37 @@ RenderFlow::lowestPosition() const
     //kdDebug(0) << renderName() << " bottom = " << bottom << endl;
     return bottom;
 }
+
+int RenderFlow::rightmostPosition() const
+{
+    int right = RenderBox::rightmostPosition();
+
+    if ( !m_childrenInline ) {
+        RenderObject *c;
+        for (c = firstChild(); c; c = c->nextSibling()) {
+	    if (!c->isPositioned() && !c->isFloating()) {
+		int childRight = xPos() + c->rightmostPosition();
+		if (childRight > right)
+		    right = childRight;
+	    }
+	}
+    }
+
+    if (specialObjects) {
+        SpecialObject* r;
+        QListIterator<SpecialObject> it(*specialObjects);
+        for ( ; (r = it.current()); ++it ) {
+            if ( r->type == SpecialObject::Positioned ) {
+                int specialRight = r->node->xPos() + r->node->rightmostPosition();
+                if (specialRight > right)
+		    right = specialRight;
+            }
+        }
+    }
+
+    return right;
+}
+
 
 int
 RenderFlow::leftBottom()
Index: rendering/render_flow.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_flow.h,v
retrieving revision 1.43
diff -u -p -r1.43 render_flow.h
--- rendering/render_flow.h	2001/01/10 14:41:38	1.43
+++ rendering/render_flow.h	2001/02/01 12:38:47
@@ -82,6 +82,7 @@ public:
     virtual unsigned short lineWidth(int y) const;
 
     virtual int lowestPosition() const;
+    virtual int rightmostPosition() const;
 
     int rightOffset() const;
     int rightRelOffset(int y, int fixedOffset, int *heightRemaining = 0) const;
Index: rendering/render_object.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_object.h,v
retrieving revision 1.73
diff -u -p -r1.73 render_object.h
--- rendering/render_object.h	2001/01/28 18:29:36	1.73
+++ rendering/render_object.h	2001/02/01 12:39:01
@@ -459,6 +459,10 @@ public:
      * absolute lowest position (highest y-value) the object covers
      */
     virtual int lowestPosition() const {return 0;}
+    /**
+     * absolute rightmost position (highest x-value) the object covers
+     */
+    virtual int rightmostPosition() const {return 0;}
 
     CachedImage *backgroundImage() const { return m_bgImage; }
 
Index: rendering/render_root.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_root.cpp,v
retrieving revision 1.62
diff -u -p -r1.62 render_root.cpp
--- rendering/render_root.cpp	2001/01/05 01:14:25	1.62
+++ rendering/render_root.cpp	2001/02/01 12:39:03
@@ -352,10 +352,12 @@ int RenderRoot::docHeight() const
     else
         h = m_view->visibleHeight();
 
-    if(firstChild()) {
-        int dh = firstChild()->height() + firstChild()->marginTop() + \
                firstChild()->marginBottom();
-        if( firstChild()->lowestPosition() > dh )
-            dh = firstChild()->lowestPosition();
+    RenderObject *fc = firstChild();
+    if(fc) {
+        int dh = fc->height() + fc->marginTop() + fc->marginBottom();
+        int lowestPos = firstChild()->lowestPosition();
+        if( lowestPos > dh )
+            dh = lowestPos;
         if( dh > h )
             h = dh;
     }
@@ -370,9 +372,12 @@ int RenderRoot::docWidth() const
     else
         w = m_view->visibleWidth();
 
-    RenderObject* h = firstChild();
-    if(h) {
-        int dw = h->width() + h->marginLeft() + h->marginRight();
+    RenderObject *fc = firstChild();
+    if(fc) {
+        int dw = fc->width() + fc->marginLeft() + fc->marginRight();
+        int rightmostPos = firstChild()->rightmostPosition();
+        if( rightmostPos > dw )
+            dw = rightmostPos;
         if( dw > w )
             w = dw;
     }



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

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