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

List:       kde-commits
Subject:    kdelibs/khtml
From:       Germain Garand <germain () ebooksfrance ! com>
Date:       2005-03-28 23:55:42
Message-ID: 20050328235542.57986631 () office ! kde ! org
[Download RAW message or body]

CVS commit by ggarand: 

offsetLeft/Top/width/Height/Parent improvements

BUG: 102127


  M +10 -0     ChangeLog   1.412
  M +10 -4     rendering/render_object.cpp   1.284
  M +53 -0     rendering/render_table.cpp   1.278
  M +7 -0      rendering/render_table.h   1.114


--- kdelibs/khtml/ChangeLog  #1.411:1.412
@@ -1,2 +1,12 @@
+2005-03-29  Germain Garand  <germain@ebooksfrance.org>
+
+        offsetLeft/Top/width/Height/Parent improvements
+
+        * rendering/render_object.cpp (offsetLeft/offsetTop/offsetParent):
+        match IE behaviour in strict mode.
+
+        * rendering/render_table.{h,cpp} \
(RenderTableRow::offsetLeft/offsetTop/offsetHeight/offsetWidth): +        \
reimplemented to return meaningful values (#102127) +
 2005-03-22  Allan Sandfeld Jensen <kde@carewolf.com>
 

--- kdelibs/khtml/rendering/render_object.cpp  #1.283:1.284
@@ -387,5 +387,5 @@ int RenderObject::offsetLeft() const
         return xPos();
 
-    if ( isBody() )
+    if ( isBody() && style()->htmlHacks() )
         return 0;
 
@@ -402,5 +402,5 @@ int RenderObject::offsetLeft() const
         x += curr->xPos();
 
-    if ( offsetPar && offsetPar->isBody() )
+    if ( offsetPar && offsetPar->isBody() && style()->htmlHacks() )
         x += offsetPar->xPos();
 
@@ -413,5 +413,5 @@ int RenderObject::offsetTop() const
         return yPos();
 
-    if ( isBody() )
+    if ( isBody() && style()->htmlHacks() )
         return 0;
 
@@ -427,5 +427,5 @@ int RenderObject::offsetTop() const
         y += curr->yPos();
 
-    if ( offsetPar && offsetPar->isBody() )
+    if ( offsetPar && offsetPar->isBody() && style()->htmlHacks() )
         y += offsetPar->yPos();
 
@@ -435,4 +435,10 @@ int RenderObject::offsetTop() const
 RenderObject* RenderObject::offsetParent() const
 {
+    if (!style()->htmlHacks()) {
+        // match IE in strict mode
+        if (isRoot()||isBody())
+            return 0;
+        return containingBlock();   
+    }
     bool skipTables = isPositioned() || isRelPositioned();
     RenderObject* curr = parent();

--- kdelibs/khtml/rendering/render_table.cpp  #1.277:1.278
@@ -1810,4 +1810,57 @@ void RenderTableRow::layout()
 }
 
+int RenderTableRow::offsetLeft() const
+{
+    RenderObject *child = firstChild();
+    while (child && !child->isTableCell())
+        child = child->nextSibling();
+    
+    if (!child)
+        return 0;    
+
+    return child->offsetLeft();
+}
+
+int RenderTableRow::offsetTop() const
+{
+    RenderObject *child = firstChild();
+    while (child && !child->isTableCell())
+        child = child->nextSibling();
+    
+    if (!child)
+        return 0;
+
+    return child->offsetTop() - 
+                  static_cast<RenderTableCell*>(child)->cellTopExtra();
+}
+
+int RenderTableRow::offsetHeight() const
+{
+    RenderObject *child = firstChild();
+    while (child && !child->isTableCell())
+        child = child->nextSibling();
+    
+    if (!child)
+        return 0;
+
+    return child->offsetHeight() + 
+                  static_cast<RenderTableCell*>(child)->cellTopExtra() + 
+                  static_cast<RenderTableCell*>(child)->cellBottomExtra();
+}
+
+short RenderTableRow::offsetWidth() const
+{
+    RenderObject *fc = firstChild();
+    RenderObject *lc = lastChild();
+    while (fc && !fc->isTableCell())
+        fc = fc->nextSibling();
+    while (lc && !lc->isTableCell())
+        lc = lc->previousSibling();
+    if (!lc || !fc)
+        return 0;
+
+    return lc->xPos()+lc->width()-fc->xPos();
+}
+
 void RenderTableRow::paintRow( PaintInfo& pI, int tx, int ty, int w, int h )
 {

--- kdelibs/khtml/rendering/render_table.h  #1.113:1.114
@@ -310,4 +310,9 @@ public:
     virtual RenderObject* removeChildNode(RenderObject* child);
 
+    virtual short offsetWidth() const;
+    virtual int offsetHeight() const;
+    virtual int offsetLeft() const;
+    virtual int offsetTop() const;
+
     virtual short lineHeight( bool ) const { return 0; }
     virtual void position(InlineBox*, int, int, bool) {}
@@ -374,4 +379,6 @@ public:
     void setCellTopExtra(int p) { _topExtra = p; }
     void setCellBottomExtra(int p) { _bottomExtra = p; }
+    int cellTopExtra() const { return _topExtra; }
+    int cellBottomExtra() const { return _bottomExtra; }
 
     virtual void paint( PaintInfo& i, int tx, int ty);


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

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