Bug 118277 - css border of object element not painted
Summary: css border of object element not painted
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
: 126911 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-12-13 22:41 UTC by Rickard Närström
Modified: 2006-07-06 23:38 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Example file to demonstrate error (424 bytes, text/html)
2005-12-13 22:41 UTC, Rickard Närström
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rickard Närström 2005-12-13 22:41:08 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    Gentoo Packages
Compiler:          gcc (GCC) 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8) 
OS:                Linux

css borders for object elements are not painted at all - the renderar leavs room for the borders but the area there the border shuld be painted aren't painted.
Comment 1 Rickard Närström 2005-12-13 22:41:54 UTC
Created attachment 13900 [details]
Example file to demonstrate error
Comment 2 Germain Garand 2006-06-27 06:31:04 UTC
SVN commit 555345 by ggarand:

. Correct drawing of borders on iframes and objects (#118277/#56109)
. Frameborder attribute for iframes (http://www.w3.org/TR/html401/present/frames.html#adef-frameborder)
. Fix widget counter-mask not being updated in time, thus sometimes missing a repaint (e.g: http://lequipe.fr),
  which is a 3.5.2 regression

BUG: 56109, 118277



 M  +16 -0     ChangeLog  
 M  +25 -0     html/html_baseimpl.cpp  
 M  +4 -0      html/html_baseimpl.h  
 M  +9 -5      khtmlview.cpp  
 M  +0 -5      rendering/render_form.h  
 M  +8 -0      rendering/render_frames.h  
 M  +7 -3      rendering/render_object.cpp  
 M  +5 -0      rendering/render_replaced.h  


--- branches/KDE/3.5/kdelibs/khtml/ChangeLog #555344:555345
@@ -1,3 +1,19 @@
+2006-06-27  Germain Garand  <germain@ebooksfrance.org>
+
+        . Correct drawing of borders on iframes and objects (#118277/#56109)
+        . Frameborder attribute for iframes (http://www.w3.org/TR/html401/present/frames.html#adef-frameborder) 
+        . Fix widget counter-mask not being updated in time, thus sometimes missing a repaint (e.g: http://lequipe.fr)
+
+        * html/html_baseimpl.{h,cpp} (HTMLIFrameElementImpl::parseAttribute): parse frameborder attribute. Defaults to true as per specification.
+        (HTMLIFrameElementImpl::updateFrame/attach): apply/remove frameborder style at attachment time.
+        * khtmlview.cpp (drawContents): fix counter-mask problem. Widget geometry is not accurate before painting, so we must 
+        use the RenderObject's.
+        * rendering/render_frames.h (paddingTop/paddingBottom/paddingLeft/paddingRight): reimplement. Frames have no padding.
+        (RenderPartObject::canHaveBorder): reimplement. True.
+        * rendering/render_object.cpp (RenderObject::updateWidgetMasks): clip mask to correct width/height, though it doesn't matter much on X11.
+        * rendering/render_replaced.h (RenderWidget::borderTop/borderBottom/borderLeft/borderRight): percolated down from RenderForm. 
+        Frames/Iframes also need that reimplementation.
+
 2006-06-22  Germain Garand  <germain@ebooksfrance.org>
 
         Implement floating auto-width table quirk
--- branches/KDE/3.5/kdelibs/khtml/html/html_baseimpl.cpp #555344:555345
@@ -584,6 +584,7 @@
     marginWidth = 0;
     marginHeight = 0;
     needWidgetUpdate = false;
+    m_frame = true;
 }
 
 HTMLIFrameElementImpl::~HTMLIFrameElementImpl()
@@ -615,17 +616,41 @@
         needWidgetUpdate = true; // ### do this for scrolling, margins etc?
         HTMLFrameElementImpl::parseAttribute( attr );
         break;
+    case ATTR_FRAMEBORDER:
+    {
+        m_frame = (!attr->val() || attr->value().toInt() > 0);
+        if (attached()) updateFrame();
+    }
     default:
         HTMLFrameElementImpl::parseAttribute( attr );
     }
 }
 
+void HTMLIFrameElementImpl::updateFrame()
+{
+    if (m_frame) {
+        addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_OUTSET);
+        addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_OUTSET);
+        addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_OUTSET);
+        addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_OUTSET);
+        addCSSLength(CSS_PROP_BORDER_WIDTH, "2");
+    } else {
+        addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_NONE);
+        addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_NONE);
+        addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_NONE);
+        addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_NONE);
+        removeCSSProperty(CSS_PROP_BORDER_WIDTH);
+    }
+
+}
+
 void HTMLIFrameElementImpl::attach()
 {
     assert(!attached());
     assert(!m_render);
     assert(parentNode());
 
+    updateFrame();
     name = getAttribute(ATTR_NAME);
     if (name.isNull())
         name = getAttribute(ATTR_ID);
--- branches/KDE/3.5/kdelibs/khtml/html/html_baseimpl.h #555344:555345
@@ -190,7 +190,11 @@
     virtual void recalcStyle( StyleChange ch );
 
 protected:
+
+    void updateFrame();
+
     bool needWidgetUpdate;
+    bool m_frame;
 };
 
 
--- branches/KDE/3.5/kdelibs/khtml/khtmlview.cpp #555344:555345
@@ -660,7 +660,14 @@
 	QWidget *w = it.current();
 	RenderWidget* rw = static_cast<RenderWidget*>( it.currentKey() );
 	if (w && rw && !rw->isKHTMLWidget()) { 
-            QRect g = w->geometry();
+            int x, y;
+            rw->absolutePosition(x, y);
+            contentsToViewport(x, y, x, y);
+            int pbx = rw->borderLeft()+rw->paddingLeft();
+            int pby = rw->borderTop()+rw->paddingTop();
+            QRect g = QRect(x+pbx, y+pby, 
+                            rw->width()-pbx-rw->borderRight()-rw->paddingRight(), 
+                            rw->height()-pby-rw->borderBottom()-rw->paddingBottom());
             if ( !rw->isFrame() && ((g.top() > pt.y()+eh) || (g.bottom() <= pt.y()) ||
                                     (g.right() <= pt.x()) || (g.left() > pt.x()+ew) ))
                 continue;
@@ -673,10 +680,7 @@
                 mask = mask.intersect( QRect(g.x(),g.y(),g.width(),g.height()) );
                 cr -= mask;
             } else {
-                int x, y;
-                rw->absolutePosition(x,y);
-                contentsToViewport(x,y,x,y);
-                cr -= QRect(x,y,rw->width(),rw->height());
+                cr -= g;
             }
         }
     }
--- branches/KDE/3.5/kdelibs/khtml/rendering/render_form.h #555344:555345
@@ -78,11 +78,6 @@
 
     virtual bool isFormElement() const { return true; }
 
-    virtual int borderTop() const { return canHaveBorder() ? RenderWidget::borderTop() : 0; }
-    virtual int borderBottom() const { return canHaveBorder() ? RenderWidget::borderBottom() : 0; }
-    virtual int borderLeft() const { return canHaveBorder() ? RenderWidget::borderLeft() : 0; }
-    virtual int borderRight() const { return canHaveBorder() ? RenderWidget::borderRight() : 0; }
-
     // form elements never have padding
     virtual int paddingTop() const { return 0; }
     virtual int paddingBottom() const { return 0; }
--- branches/KDE/3.5/kdelibs/khtml/rendering/render_frames.h #555344:555345
@@ -130,6 +130,12 @@
     virtual const char *renderName() const { return "RenderFrame"; }
     virtual bool isFrame() const { return true; }
 
+    // frames never have padding
+    virtual int paddingTop() const { return 0; }
+    virtual int paddingBottom() const { return 0; }
+    virtual int paddingLeft() const { return 0; }
+    virtual int paddingRight() const { return 0; }
+
     DOM::HTMLFrameElementImpl *element() const
     { return static_cast<DOM::HTMLFrameElementImpl*>(RenderObject::element()); }
 
@@ -150,6 +156,8 @@
 
     virtual void layout( );
     virtual void updateWidget();
+    
+    virtual bool canHaveBorder() const { return true; }
 
     virtual bool partLoadingErrorNotify( khtml::ChildFrame *childFrame, const KURL& url, const QString& serviceType );
 
--- branches/KDE/3.5/kdelibs/khtml/rendering/render_object.cpp #555344:555345
@@ -2182,9 +2182,13 @@
             QRegion r = l ? l->getMask() : QRegion();
             int x,y;
             if (!r.isNull() && curr->absolutePosition(x,y)) {
-                x+= curr->borderLeft()+curr->paddingLeft();
-                y+= curr->borderBottom()+curr->paddingBottom();
-                r = r.intersect(QRect(x,y,curr->width(),curr->height()));
+                int pbx = curr->borderLeft()+curr->paddingLeft();
+                int pby = curr->borderTop()+curr->paddingTop();
+                x+= pbx;
+                y+= pby;
+                r = r.intersect(QRect(x,y,
+                                  curr->width()-pbx-curr->borderRight()-curr->paddingRight(),
+                                  curr->height()-pby-curr->borderBottom()-curr->paddingBottom()));
 #ifdef MASK_DEBUG
                 QMemArray<QRect> ar = r.rects();
                 kdDebug(6040) << "|| Setting widget mask for " << curr->information() << endl;
--- branches/KDE/3.5/kdelibs/khtml/rendering/render_replaced.h #555344:555345
@@ -146,6 +146,11 @@
     bool m_needsMask;
 
 public:
+    virtual int borderTop() const { return canHaveBorder() ? RenderReplaced::borderTop() : 0; }
+    virtual int borderBottom() const { return canHaveBorder() ? RenderReplaced::borderBottom() : 0; }
+    virtual int borderLeft() const { return canHaveBorder() ? RenderReplaced::borderLeft() : 0; }
+    virtual int borderRight() const { return canHaveBorder() ? RenderReplaced::borderRight() : 0; }
+
     class EventPropagator : public QWidget {
     public:
         void sendEvent(QEvent *e);
Comment 3 Germain Garand 2006-07-06 23:38:51 UTC
*** Bug 126911 has been marked as a duplicate of this bug. ***