[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

hyatt hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:42:41 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 4214717a6af3896d1ca96ed593a34a958ca824c0
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed May 21 07:00:43 2003 +0000

            An implementation of fieldset and legend.  This is based off
    	some KHTML trunk code, but only loosely.  I had to rewrite
    	most of it in order to make fieldsets work properly with
    	padding and in order to match the fieldset style of other
    	browsers more closely.
    
    	This code also fixes HTML4 buttons so that they don't fill the
    	width of containing blocks.  This has been a long-standing
    	bug.  Since legends behave the same way as buttons and floats,
    	I made a new helper function, sizesToMaxWidth(), to denote an
    	element that just uses its max intrinsic width when sizing
    	instead of filling a containing block.
    
            This patch also fixes z-index so it properly only applies to the
    	root and to positioned/relpositioned elements.
    
            Reviewed by darin
    
            * ChangeLog:
            * ForwardingHeaders/rendering/render_block.h: Added.
            * khtml/css/html4.css:
            * khtml/html/html_formimpl.cpp:
            (HTMLFieldSetElementImpl::HTMLFieldSetElementImpl):
            (HTMLFieldSetElementImpl::attach):
            (HTMLFieldSetElementImpl::createRenderer):
            (HTMLLegendElementImpl::HTMLLegendElementImpl):
            (HTMLLegendElementImpl::id):
            (HTMLLegendElementImpl::attach):
            (HTMLLegendElementImpl::createRenderer):
            * khtml/html/html_formimpl.h:
            * khtml/rendering/render_block.cpp:
            * khtml/rendering/render_block.h:
            * khtml/rendering/render_box.cpp:
            (RenderBox::setStyle):
            (RenderBox::calcWidthUsing):
            * khtml/rendering/render_canvas.cpp:
            * khtml/rendering/render_form.cpp:
            (RenderFieldset::RenderFieldset):
            (RenderFieldset::layoutLegend):
            (RenderFieldset::findLegend):
            (RenderFieldset::paintBoxDecorations):
            (RenderFieldset::paintBorderMinusLegend):
            (RenderLegend::RenderLegend):
            * khtml/rendering/render_form.h:
            * khtml/rendering/render_object.cpp:
            (RenderObject::sizesToMaxWidth):
            * khtml/rendering/render_object.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4403 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index fe0c687..90b5a18 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,72 @@
+2003-05-20  David Hyatt  <hyatt at apple.com>
+
+        An implementation of fieldset and legend.  This is based off
+	some KHTML trunk code, but only loosely.  I had to rewrite
+	most of it in order to make fieldsets work properly with
+	padding and in order to match the fieldset style of other
+	browsers more closely.
+
+	This code also fixes HTML4 buttons so that they don't fill the
+	width of containing blocks.  This has been a long-standing
+	bug.  Since legends behave the same way as buttons and floats,
+	I made a new helper function, sizesToMaxWidth(), to denote an
+	element that just uses its max intrinsic width when sizing
+	instead of filling a containing block.
+
+        This patch also fixes z-index so it properly only applies to the 
+	root and to positioned/relpositioned elements.  
+        
+        Reviewed by darin
+
+        * ChangeLog:
+        * ForwardingHeaders/rendering/render_block.h: Added.
+        * khtml/css/html4.css:
+        * khtml/html/html_formimpl.cpp:
+        (HTMLFieldSetElementImpl::HTMLFieldSetElementImpl):
+        (HTMLFieldSetElementImpl::attach):
+        (HTMLFieldSetElementImpl::createRenderer):
+        (HTMLLegendElementImpl::HTMLLegendElementImpl):
+        (HTMLLegendElementImpl::id):
+        (HTMLLegendElementImpl::attach):
+        (HTMLLegendElementImpl::createRenderer):
+        * khtml/html/html_formimpl.h:
+        * khtml/rendering/render_block.cpp:
+        * khtml/rendering/render_block.h:
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::setStyle):
+        (RenderBox::calcWidthUsing):
+        * khtml/rendering/render_canvas.cpp:
+        * khtml/rendering/render_form.cpp:
+        (RenderFieldset::RenderFieldset):
+        (RenderFieldset::layoutLegend):
+        (RenderFieldset::findLegend):
+        (RenderFieldset::paintBoxDecorations):
+        (RenderFieldset::paintBorderMinusLegend):
+        (RenderLegend::RenderLegend):
+        * khtml/rendering/render_form.h:
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::sizesToMaxWidth):
+        * khtml/rendering/render_object.h:
+
+2003-05-19  David Hyatt  <hyatt at apple.com>
+
+	Fix for 3262890, logical font sizes (e.g., large) cannot be applied
+	to monospace tags like <pre> and <tt>.  The fix adds a notion of
+	the current logicalSize in effect for a given FontDef so that
+	shifts in family as you go down the style tree result in an
+	auto-correction of the size.
+
+	Note that with the addition of this cached logicalSize property,
+	it will be possible to eliminate the two separate logical size
+	tables and implement the monospace table as a "zoom factor" applied
+	to the normal table (an idea long ago suggested by darin).
+	
+        Reviewed by darin
+
+        * ChangeLog:
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/rendering/font.h:
+
 === Safari-80 ===
 
 2003-05-19  Maciej Stachowiak  <mjs at apple.com>
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index fe0c687..90b5a18 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,72 @@
+2003-05-20  David Hyatt  <hyatt at apple.com>
+
+        An implementation of fieldset and legend.  This is based off
+	some KHTML trunk code, but only loosely.  I had to rewrite
+	most of it in order to make fieldsets work properly with
+	padding and in order to match the fieldset style of other
+	browsers more closely.
+
+	This code also fixes HTML4 buttons so that they don't fill the
+	width of containing blocks.  This has been a long-standing
+	bug.  Since legends behave the same way as buttons and floats,
+	I made a new helper function, sizesToMaxWidth(), to denote an
+	element that just uses its max intrinsic width when sizing
+	instead of filling a containing block.
+
+        This patch also fixes z-index so it properly only applies to the 
+	root and to positioned/relpositioned elements.  
+        
+        Reviewed by darin
+
+        * ChangeLog:
+        * ForwardingHeaders/rendering/render_block.h: Added.
+        * khtml/css/html4.css:
+        * khtml/html/html_formimpl.cpp:
+        (HTMLFieldSetElementImpl::HTMLFieldSetElementImpl):
+        (HTMLFieldSetElementImpl::attach):
+        (HTMLFieldSetElementImpl::createRenderer):
+        (HTMLLegendElementImpl::HTMLLegendElementImpl):
+        (HTMLLegendElementImpl::id):
+        (HTMLLegendElementImpl::attach):
+        (HTMLLegendElementImpl::createRenderer):
+        * khtml/html/html_formimpl.h:
+        * khtml/rendering/render_block.cpp:
+        * khtml/rendering/render_block.h:
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::setStyle):
+        (RenderBox::calcWidthUsing):
+        * khtml/rendering/render_canvas.cpp:
+        * khtml/rendering/render_form.cpp:
+        (RenderFieldset::RenderFieldset):
+        (RenderFieldset::layoutLegend):
+        (RenderFieldset::findLegend):
+        (RenderFieldset::paintBoxDecorations):
+        (RenderFieldset::paintBorderMinusLegend):
+        (RenderLegend::RenderLegend):
+        * khtml/rendering/render_form.h:
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::sizesToMaxWidth):
+        * khtml/rendering/render_object.h:
+
+2003-05-19  David Hyatt  <hyatt at apple.com>
+
+	Fix for 3262890, logical font sizes (e.g., large) cannot be applied
+	to monospace tags like <pre> and <tt>.  The fix adds a notion of
+	the current logicalSize in effect for a given FontDef so that
+	shifts in family as you go down the style tree result in an
+	auto-correction of the size.
+
+	Note that with the addition of this cached logicalSize property,
+	it will be possible to eliminate the two separate logical size
+	tables and implement the monospace table as a "zoom factor" applied
+	to the normal table (an idea long ago suggested by darin).
+	
+        Reviewed by darin
+
+        * ChangeLog:
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/rendering/font.h:
+
 === Safari-80 ===
 
 2003-05-19  Maciej Stachowiak  <mjs at apple.com>
diff --git a/WebCore/ForwardingHeaders/rendering/render_block.h b/WebCore/ForwardingHeaders/rendering/render_block.h
new file mode 100644
index 0000000..9a47795
--- /dev/null
+++ b/WebCore/ForwardingHeaders/rendering/render_block.h
@@ -0,0 +1 @@
+#include <render_block.h>
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 6a35b84..fcbb766 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -2652,7 +2652,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
             case CSS_VAL_XX_LARGE: size = fontSizes[6]; break;
             case CSS_VAL__KONQ_XXX_LARGE:  size = ( fontSizes[6]*5 )/3; break;
             case CSS_VAL_LARGER:
-                // ### use the next bigger standardSize!!!
+                // FIXME: Larger/smaller should actually apply a scale to the logical size.  It 		// should not simply be transforming the current size.
                 size = oldSize * 1.2;
                 break;
             case CSS_VAL_SMALLER:
@@ -2665,7 +2665,17 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
             // This is a "logical" font size in the sense that it is relative to some UA default.
             // Since the UA default can vary depending on the font family (e.g., monospace could be 11pt
             // but serif could be 20pt), we don't set our size specified bit.
-            fontDef.sizeSpecified = false;
+            if (primitiveValue->getIdent() != CSS_VAL_LARGER &&
+                primitiveValue->getIdent() != CSS_VAL_SMALLER) {
+                // FIXME: Technically this should be logical too and apply a scale
+                // to logical sizes when no explicit size is specified,
+                // but until the above simplistic 1.2 mult/division calculation is
+                // improved, we have to ignore these cases. 
+                fontDef.sizeSpecified = false;
+                fontDef.logicalSize = primitiveValue->getIdent() - CSS_VAL_XX_SMALL;
+            }
+            else
+                fontDef.sizeSpecified = true;
 
         } else {
             fontDef.sizeSpecified = true;
@@ -3134,16 +3144,21 @@ void CSSStyleSelector::checkForGenericFamilyChange(RenderStyle* aStyle, RenderSt
 
   // We know the parent is monospace or the child is monospace, and that font
   // size was unspecified.  We want to alter our font size to use the correct
-  // "medium" font for our family.
-  float size = 0;
+  // logicalSize font for our family.
   int minFontSize = settings->minFontSize();
-  size = (childFont.genericFamily == FontDef::eMonospace) ? m_fixedFontSizes[3] : m_fontSizes[3];
-  int isize = (int)size;
-  if (isize < minFontSize)
-    isize = minFontSize;
+  const QValueList<int>& fontSizes = (childFont.genericFamily == FontDef::eMonospace) ? m_fixedFontSizes : m_fontSizes;
+  int size = 0;
+  if (childFont.logicalSize < 0 || childFont.logicalSize > 7) // Should never happen; I'm being paranoid.
+      size = fontSizes[3]; 
+  if (childFont.logicalSize == 7) // KONQ_XX_LARGE
+      size = (fontSizes[6]*5)/3;
+  else
+      size = fontSizes[childFont.logicalSize]; 
+  if (size < minFontSize)
+    size = minFontSize;
   
   FontDef newFontDef(childFont);
-  newFontDef.size = isize;
+  newFontDef.size = size;
   aStyle->setFontDef(newFontDef);
 }
 
diff --git a/WebCore/khtml/css/html4.css b/WebCore/khtml/css/html4.css
index ecaf98c..ce65b9e 100644
--- a/WebCore/khtml/css/html4.css
+++ b/WebCore/khtml/css/html4.css
@@ -7,11 +7,6 @@
  * what you are doing.
  */
 
-/* The root element establishes its own stacking context. */
-:root {
-    z-index: 0
-}
-
 html {
 	display: block;
 } 
@@ -318,10 +313,20 @@ FORM {
     margin: 0__qem 0 1em 0;
 }
 
+LEGEND {
+    display: block;
+    padding-left: 2px;
+    padding-right: 2px;
+    border: none;
+}
+
 FIELDSET {
-	display: block;
-	margin: 1.0em auto;
-} 
+    display: block;
+    margin-left: 2px;
+    margin-right: 2px;
+    padding: 0.75em 0.625em;
+    border: 2px groove ThreeDFace;
+}
 
 BUTTON {
         display: block;
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index 3e0dfd6..7dd7e27 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -1018,7 +1018,7 @@ bool HTMLButtonElementImpl::encoding(const QTextCodec* codec, khtml::encodingLis
 // -------------------------------------------------------------------------
 
 HTMLFieldSetElementImpl::HTMLFieldSetElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)
-    : HTMLGenericFormElementImpl(doc, f)
+   : HTMLGenericFormElementImpl(doc, f)
 {
 }
 
@@ -1038,11 +1038,13 @@ DOMString HTMLFieldSetElementImpl::type() const
 
 void HTMLFieldSetElementImpl::attach()
 {
-    // Fieldsets need to at least get a render object so that the
-    // children will be rendered. Eventually we need to create a
-    // custom object that can draw the label within the grooved
-    // border. -dwh
-    return HTMLElementImpl::attach();
+    createRendererIfNeeded();
+    HTMLGenericFormElementImpl::attach();
+}
+
+RenderObject* HTMLFieldSetElementImpl::createRenderer(RenderArena* arena, RenderStyle* style)
+{
+    return new (arena) RenderFieldset(this);
 }
 
 // -------------------------------------------------------------------------
@@ -1712,7 +1714,7 @@ ElementImpl *HTMLLabelElementImpl::formElement()
 // -------------------------------------------------------------------------
 
 HTMLLegendElementImpl::HTMLLegendElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)
-    : HTMLGenericFormElementImpl(doc, f)
+: HTMLGenericFormElementImpl(doc, f)
 {
 }
 
@@ -1725,6 +1727,17 @@ NodeImpl::Id HTMLLegendElementImpl::id() const
     return ID_LEGEND;
 }
 
+void HTMLLegendElementImpl::attach()
+{
+    createRendererIfNeeded();
+    HTMLGenericFormElementImpl::attach();
+}
+
+RenderObject* HTMLLegendElementImpl::createRenderer(RenderArena* arena, RenderStyle* style)
+{
+    return new (arena) RenderLegend(this);
+}
+
 DOMString HTMLLegendElementImpl::type() const
 {
     return "legend";
diff --git a/WebCore/khtml/html/html_formimpl.h b/WebCore/khtml/html/html_formimpl.h
index 14fcfdf..5843340 100644
--- a/WebCore/khtml/html/html_formimpl.h
+++ b/WebCore/khtml/html/html_formimpl.h
@@ -233,9 +233,11 @@ public:
     virtual ~HTMLFieldSetElementImpl();
 
     virtual Id id() const;
-    DOMString type() const;
-
     virtual void attach();
+    
+    virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
+
+    virtual DOMString type() const;
 };
 
 // -------------------------------------------------------------------------
@@ -365,9 +367,11 @@ public:
     virtual ~HTMLLegendElementImpl();
 
     virtual Id id() const;
-    DOMString type() const;
-};
+    virtual void attach();
+    virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
 
+    virtual DOMString type() const;
+};
 
 // -------------------------------------------------------------------------
 
diff --git a/WebCore/khtml/rendering/font.h b/WebCore/khtml/rendering/font.h
index c600a93..2bb2ea3 100644
--- a/WebCore/khtml/rendering/font.h
+++ b/WebCore/khtml/rendering/font.h
@@ -47,6 +47,7 @@ public:
 #if APPLE_CHANGES
           , usePrinterFont( false )
 #endif
+          , logicalSize(3)
           {}
     
     bool operator == ( const FontDef &other ) const {
@@ -59,6 +60,7 @@ public:
 #if APPLE_CHANGES
                  && usePrinterFont == other.usePrinterFont
 #endif
+                 && logicalSize == other.logicalSize
                  );
     }
 
@@ -72,14 +74,17 @@ public:
     short int size;
     bool italic 		: 1;
     bool smallCaps 		: 1;
-    bool sizeSpecified		: 1;  // Whether or not CSS specified the size or if we're using the
-                                      // default font size that the user specified via preferences.
+    bool sizeSpecified		: 1;  // Whether or not CSS specified an explicit size
+                                      // (logical sizes like "medium" don't count).
     unsigned int weight 	: 8;
     unsigned int genericFamily	: 3;
     mutable bool hasNbsp	: 1;
 #if APPLE_CHANGES
     bool usePrinterFont		: 1;
 #endif
+    short logicalSize;   	       // If a logical size is in effect, then we need to
+                                       // cache this value for family changes (e.g., medium
+                                       // monospace may be different than medium serif).
 };
 
 
diff --git a/WebCore/khtml/rendering/render_block.cpp b/WebCore/khtml/rendering/render_block.cpp
index aaa2f0d..c15065b 100644
--- a/WebCore/khtml/rendering/render_block.cpp
+++ b/WebCore/khtml/rendering/render_block.cpp
@@ -539,15 +539,19 @@ void RenderBlock::layoutBlockChildren( bool relayoutChildren )
 #endif
 
     int xPos = borderLeft() + paddingLeft();
-    int toAdd = borderBottom() + paddingBottom();
+    if( style()->direction() == RTL )
+        xPos = m_width - paddingRight() - borderRight();
 
+    int toAdd = borderBottom() + paddingBottom();
     m_height = borderTop() + paddingTop();
+
+    // Fieldsets need to find their legend and position it inside the border of the object.
+    // The legend then gets skipped during normal layout.
+    RenderObject* legend = layoutLegend(relayoutChildren);
+    
     int minHeight = m_height + toAdd;
     m_overflowHeight = m_height;
 
-    if( style()->direction() == RTL )
-        xPos = m_width - paddingRight() - borderRight();
-
     RenderObject *child = firstChild();
     RenderBlock *prevFlow = 0;
 
@@ -613,6 +617,11 @@ void RenderBlock::layoutBlockChildren( bool relayoutChildren )
 
     while( child != 0 )
     {
+        if (legend == child) {
+            child = child->nextSibling();
+            continue; // Skip the legend, since it has already been positioned up in the fieldset's border.
+        }
+        
         // make sure we relayout children if we need it.
         if ( relayoutChildren || floatBottom() > m_y ||
              (child->isReplaced() && (child->style()->width().isPercent() || child->style()->height().isPercent())))
@@ -929,7 +938,7 @@ void RenderBlock::layoutBlockChildren( bool relayoutChildren )
                 }
             }
         } else {
-            chPos -= child->width() + child->marginLeft() + child->marginRight();
+            chPos -= child->width() + child->marginRight();
             if (child->style()->hidesOverflow() ||
                 ((style()->htmlHacks() || child->isTable()) && child->style()->flowAroundFloats()))
                 chPos -= leftOffset(m_height);
diff --git a/WebCore/khtml/rendering/render_block.h b/WebCore/khtml/rendering/render_block.h
index c70ef90..6b735be 100644
--- a/WebCore/khtml/rendering/render_block.h
+++ b/WebCore/khtml/rendering/render_block.h
@@ -99,6 +99,9 @@ public:
     void layoutPositionedObjects( bool relayoutChildren );
     void insertPositionedObject(RenderObject *o);
     void removePositionedObject(RenderObject *o);
+
+    // Called to lay out the legend for a fieldset.
+    virtual RenderObject* layoutLegend(bool relayoutChildren) { return 0; };
     
     // the implementation of the following functions is in bidi.cpp
     void bidiReorderLine(const BidiIterator &start, const BidiIterator &end);
diff --git a/WebCore/khtml/rendering/render_box.cpp b/WebCore/khtml/rendering/render_box.cpp
index 25004b6..0286c07 100644
--- a/WebCore/khtml/rendering/render_box.cpp
+++ b/WebCore/khtml/rendering/render_box.cpp
@@ -108,6 +108,18 @@ void RenderBox::setStyle(RenderStyle *_style)
         m_layer->removeOnlyThisLayer();
         m_layer = 0;
     }
+
+    if (m_layer) {
+        // Make sure our z-index values are only applied if we're positioned or
+        // relpositioned.
+        if (!isPositioned() && !isRelPositioned()) {
+            // Set the auto z-index flag.
+            if (isRoot())
+                style()->setZIndex(0);
+            else
+                style()->setHasAutoZIndex();
+        }
+    }
 }
 
 RenderBox::~RenderBox()
@@ -710,7 +722,7 @@ int RenderBox::calcWidthUsing(WidthType widthType, int cw, LengthType& lengthTyp
         int marginRight = style()->marginRight().minWidth(cw);
         if (cw) width = cw - marginLeft - marginRight;
         
-        if (isFloating() || isCompact()) {
+        if (sizesToMaxWidth()) {
             if (width < m_minWidth) 
                 width = m_minWidth;
             if (width > m_maxWidth) 
diff --git a/WebCore/khtml/rendering/render_canvas.cpp b/WebCore/khtml/rendering/render_canvas.cpp
index 4813279..265f487 100644
--- a/WebCore/khtml/rendering/render_canvas.cpp
+++ b/WebCore/khtml/rendering/render_canvas.cpp
@@ -241,10 +241,10 @@ void RenderCanvas::paintObject(QPainter *p, int _x, int _y,
 void RenderCanvas::paintBoxDecorations(QPainter *p,int _x, int _y,
                                        int _w, int _h, int _tx, int _ty)
 {
-    if (firstChild() || !view())
+    if ((firstChild() && firstChild()->style()->visibility() == VISIBLE) || !view())
         return;
 
-    p->fillRect(_tx,_ty,_w,_h, view()->palette().active().color(QColorGroup::Base));
+    p->fillRect(_x,_y,_w,_h, view()->palette().active().color(QColorGroup::Base));
 }
 
 void RenderCanvas::repaintRectangle(int x, int y, int w, int h, bool immediate, bool f)
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index b915d64..c2a5b7f 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -575,8 +575,130 @@ void RenderLineEdit::select()
 // ---------------------------------------------------------------------------
 
 RenderFieldset::RenderFieldset(HTMLGenericFormElementImpl *element)
-    : RenderFormElement(element)
+: RenderBlock(element)
+{
+}
+
+RenderObject* RenderFieldset::layoutLegend(bool relayoutChildren)
+{
+    RenderObject* legend = findLegend();
+    if (legend) {
+        if (relayoutChildren)
+            legend->setNeedsLayout(true);
+        legend->layoutIfNeeded();
+
+        int xPos = borderLeft() + paddingLeft() + legend->marginLeft();
+        if (style()->direction() == RTL)
+            xPos = m_width - paddingRight() - borderRight() - legend->width() - legend->marginRight();
+        int b = borderTop();
+        int h = legend->height();
+        legend->setPos(xPos, QMAX((b-h)/2, 0));
+        m_height = QMAX(b,h) + paddingTop();
+    }
+    return legend;
+}
+
+RenderObject* RenderFieldset::findLegend()
+{
+    for (RenderObject* legend = firstChild(); legend; legend = legend->nextSibling()) {
+      if (!legend->isFloatingOrPositioned() && legend->element() &&
+          legend->element()->id() == ID_LEGEND)
+        return legend;
+    }
+    return 0;
+}
+
+void RenderFieldset::paintBoxDecorations(QPainter *p,int _x, int _y,
+                                         int _w, int _h, int _tx, int _ty)
+{
+    //kdDebug( 6040 ) << renderName() << "::paintDecorations()" << endl;
+
+    int w = width();
+    int h = height() + borderTopExtra() + borderBottomExtra();
+    RenderObject* legend = findLegend();
+    if (!legend)
+        return RenderBlock::paintBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
+
+    int yOff = (legend->yPos() > 0) ? 0 : (legend->height()-borderTop())/2;
+    h -= yOff;
+    _ty += yOff - borderTopExtra();
+
+    int my = QMAX(_ty,_y);
+    int end = QMIN( _y + _h,  _ty + h );
+    int mh = end - my;
+
+    paintBackground(p, style()->backgroundColor(), style()->backgroundImage(), my, mh, _tx, _ty, w, h);
+
+    if (style()->hasBorder())
+        paintBorderMinusLegend(p, _tx, _ty, w, h, style(), legend->xPos(), legend->width());
+}
+
+void RenderFieldset::paintBorderMinusLegend(QPainter *p, int _tx, int _ty, int w, int h,
+                                            const RenderStyle* style, int lx, int lw)
 {
+
+    const QColor& tc = style->borderTopColor();
+    const QColor& bc = style->borderBottomColor();
+
+    EBorderStyle ts = style->borderTopStyle();
+    EBorderStyle bs = style->borderBottomStyle();
+    EBorderStyle ls = style->borderLeftStyle();
+    EBorderStyle rs = style->borderRightStyle();
+
+    bool render_t = ts > BHIDDEN;
+    bool render_l = ls > BHIDDEN;
+    bool render_r = rs > BHIDDEN;
+    bool render_b = bs > BHIDDEN;
+
+    if(render_t) {
+        drawBorder(p, _tx, _ty, _tx + lx, _ty +  style->borderTopWidth(), BSTop, tc, style->color(), ts,
+                   (render_l && ls<=DOUBLE?style->borderLeftWidth():0), 0);
+        drawBorder(p, _tx+lx+lw, _ty, _tx + w, _ty +  style->borderTopWidth(), BSTop, tc, style->color(), ts,
+                   0, (render_r && rs<=DOUBLE?style->borderRightWidth():0));
+    }
+
+    if(render_b)
+        drawBorder(p, _tx, _ty + h - style->borderBottomWidth(), _tx + w, _ty + h, BSBottom, bc, style->color(), bs,
+                   (render_l && ls<=DOUBLE?style->borderLeftWidth():0),
+                   (render_r && rs<=DOUBLE?style->borderRightWidth():0));
+
+    if(render_l)
+    {
+        const QColor& lc = style->borderLeftColor();
+
+        bool ignore_top =
+            (tc == lc) &&
+            (ls <= OUTSET) &&
+            (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET);
+
+        bool ignore_bottom =
+            (bc == lc) &&
+            (ls <= OUTSET) &&
+            (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET);
+
+        drawBorder(p, _tx, _ty, _tx + style->borderLeftWidth(), _ty + h, BSLeft, lc, style->color(), ls,
+                   ignore_top?0:style->borderTopWidth(),
+                   ignore_bottom?0:style->borderBottomWidth());
+    }
+
+    if(render_r)
+    {
+        const QColor& rc = style->borderRightColor();
+
+        bool ignore_top =
+            (tc == rc) &&
+            (rs <= SOLID || rs == INSET) &&
+            (ts == DOTTED || ts == DASHED || ts == SOLID || ts == OUTSET);
+
+        bool ignore_bottom =
+            (bc == rc) &&
+            (rs <= SOLID || rs == INSET) &&
+            (bs == DOTTED || bs == DASHED || bs == SOLID || bs == INSET);
+
+        drawBorder(p, _tx + w - style->borderRightWidth(), _ty, _tx + w, _ty + h, BSRight, rc, style->color(), rs,
+                   ignore_top?0:style->borderTopWidth(),
+                   ignore_bottom?0:style->borderBottomWidth());
+    }
 }
 
 // -------------------------------------------------------------------------
@@ -705,7 +827,7 @@ RenderLabel::RenderLabel(HTMLGenericFormElementImpl *element)
 // -------------------------------------------------------------------------
 
 RenderLegend::RenderLegend(HTMLGenericFormElementImpl *element)
-    : RenderFormElement(element)
+: RenderBlock(element)
 {
 }
 
diff --git a/WebCore/khtml/rendering/render_form.h b/WebCore/khtml/rendering/render_form.h
index 570ec7f..97319b3 100644
--- a/WebCore/khtml/rendering/render_form.h
+++ b/WebCore/khtml/rendering/render_form.h
@@ -27,7 +27,7 @@
 
 #include "rendering/render_replaced.h"
 #include "rendering/render_image.h"
-#include "rendering/render_flow.h"
+#include "rendering/render_block.h"
 #include "html/html_formimpl.h"
 
 class QWidget;
@@ -278,14 +278,22 @@ protected:
 
 // -------------------------------------------------------------------------
 
-class RenderFieldset : public RenderFormElement
+class RenderFieldset : public RenderBlock
 {
 public:
     RenderFieldset(DOM::HTMLGenericFormElementImpl *element);
 
     virtual const char *renderName() const { return "RenderFieldSet"; }
-};
 
+    virtual RenderObject* layoutLegend(bool relayoutChildren);
+    
+protected:
+    virtual void paintBoxDecorations(QPainter *p,int, int _y,
+                                     int, int _h, int _tx, int _ty);
+    void paintBorderMinusLegend(QPainter *p, int _tx, int _ty, int w,
+                                int h, const RenderStyle *style, int lx, int lw);
+    RenderObject* findLegend();
+};
 
 // -------------------------------------------------------------------------
 
@@ -339,7 +347,7 @@ public:
 
 // -------------------------------------------------------------------------
 
-class RenderLegend : public RenderFormElement
+class RenderLegend : public RenderBlock
 {
 public:
     RenderLegend(DOM::HTMLGenericFormElementImpl *element);
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index 4abe353..0dfb43b 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -472,6 +472,12 @@ int RenderObject::containingBlockHeight() const
     return containingBlock()->contentHeight();
 }
 
+bool RenderObject::sizesToMaxWidth() const
+{
+    return isFloating() || isCompact() ||
+      (element() && (element()->id() == ID_BUTTON || element()->id() == ID_LEGEND));
+}
+
 void RenderObject::drawBorder(QPainter *p, int x1, int y1, int x2, int y2,
                               BorderSide s, QColor c, const QColor& textcolor, EBorderStyle style,
                               int adjbw1, int adjbw2, bool invalidisInvert)
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index 8b178e3..b499fd8 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -353,6 +353,10 @@ public:
     virtual void close() { }
 
     virtual int availableHeight() const { return 0; }
+
+    // Whether or not the element shrinks to its max width (rather than filling the width
+    // of a containing block).  HTML4 buttons, legends, and floating/compact elements do this.
+    bool sizesToMaxWidth() const;
     
     // does a query on the rendertree and finds the innernode
     // and overURL for the given position

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list