branches/KDE/4.3/kdelibs/khtml/rendering

View: New views
1 Messages — Rating Filter:   Alert me  

branches/KDE/4.3/kdelibs/khtml/rendering

by Bugzilla from maksim@kde.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

SVN commit 1042752 by orlovich:

Implement custom scrollHeight for RenderTextArea --- it needs to be
able to look inside its scrollbar usage, so normal RenderObject/RenderLayer
stuff is insufficient.

Fixes growing suggestion box on reviewboard.

(Though, I really do wonder why the test scrollHeight and height for inequality ---
it'd make perfect sense for scrollHeight to be smaller than element height when one
has enough room, and at least some Opera versions behave that way, too; so testing
for scrollHeight > height would be better. Not that it'd help us before... but, well,
brittle code...)

BUG:199986


 M  +28 -17    render_form.cpp  
 M  +3 -0      render_form.h  
 M  +9 -9      render_object.h  


--- branches/KDE/4.3/kdelibs/khtml/rendering/render_form.cpp #1042751:1042752
@@ -127,13 +127,13 @@
         {
             // Make sure we give combo popup's enough room to display contents;
             // Qt doesn't do this by default
-            
+
             if (cc == QStyle::CC_ComboBox && sc == SC_ComboBoxListBoxPopup) {
                 const QComboBox* cb = qobject_cast<const QComboBox*>(widget);
                 const QStyleOptionComboBox* cbOpt = qstyleoption_cast<const QStyleOptionComboBox*>(opt);
-                
+
                 QFontMetrics fm = cb->fontMetrics();
-                
+
                 if (cb && cbOpt) {
                     // Compute content width; Qt uses the usual +4 magic number for icon/text margin
                     int maxW = 0;
@@ -143,19 +143,19 @@
                             iw += 4 + cb->iconSize().width();
                         maxW = qMax(maxW, iw);
                     }
-                    
+
                     // Now let sizeFromContent add in extra stuff.
                     maxW = proxy()->sizeFromContents(QStyle::CT_ComboBox, opt, QSize(maxW, 1), widget).width();
-                    
+
                     // How much more room do we need for the text?
                     int extraW = maxW > cbOpt->rect.width() ? maxW - cbOpt->rect.width() : 0;
-                    
+
                     QRect r = proxy()->subControlRect(cc, opt, sc, widget);
                     r.setWidth(r.width() + extraW);
                     return r;
                 }
             }
-            
+
             return proxy()->subControlRect(cc, opt, sc, widget);
         }
 
@@ -194,7 +194,7 @@
 {
     // Some form widgets apply the padding internally (i.e. as if they were
     // some kind of inline-block). Thus we only want to expose that padding
-    // while layouting (so that width/height calculations are correct), and
+    // while layouting (so that width/height calculations are correct), and
     // then pretend it does not exist, as it is beyond the replaced edge and
     // thus should not affect other calculations.
     m_exposeInternalPadding = true;
@@ -510,7 +510,7 @@
 
 bool RenderSubmitButton::canHaveBorder() const
 {
-    // ### TODO would be nice to be able to
+    // ### TODO would be nice to be able to
     // return style()->hasBackgroundImage() here,
     // depending on a config option (e.g. 'favour usability/integration over aspect')
     // so that only buttons with both a custom border
@@ -748,7 +748,7 @@
                         }
                         if ( s == t ) {
                             KMessageBox::sorry( 0, i18n( "%1 is already assigned to %2", s, provider->name() ), i18n( "Error" ) );
-                            isOk = false;
+                            isOk = false;
                         }
                     }
                 }
@@ -833,7 +833,7 @@
     for( unsigned long i = 0; ( node = form->elements()->item( i ) ); i++ ) {
         inputNode = dynamic_cast<HTMLInputElementImpl*>( node );
         if ( inputNode ) {
-            if ( ( !inputNode->name().string().size() ) ||
+            if ( ( !inputNode->name().string().size() ) ||
                  (inputNode->name().string() == queryName) ) {
                 continue;
             } else {
@@ -910,7 +910,7 @@
         QPainter p(this);
         p.fillRect(pe->rect(), palette().brush(QPalette::Base));
         p.end();
-    }  
+    }
     KLineEdit::paintEvent( pe );
 }
 
@@ -1794,7 +1794,7 @@
         // FIXME BASELINE: the 3 lines below could be removed.
         int lhs = m_widget->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
         if (lhs>0)
-           width += lhs;        
+           width += lhs;
         height = size*height + vfw;
 
         assert( includesPadding() );
@@ -2108,15 +2108,14 @@
 
     QSize size( qMax(element()->cols(), 1L)*m.width('x') + hfw + llm+lrm +
                 w->verticalScrollBar()->sizeHint().width()+lhs,
-                qMax(element()->rows(), 1L)*m.lineSpacing() + 2*vfw + lbm+ltm +
+                qMax(element()->rows(), 1L)*m.lineSpacing() + vfw + lbm+ltm +
                 (w->lineWrapMode() == QTextEdit::NoWrap ?
                  w->horizontalScrollBar()->sizeHint().height()+lvs : 0)
         );
 
     assert( includesPadding() );
     size.rwidth() -= RenderWidget::paddingLeft() + RenderWidget::paddingRight();
-    // ### FIXME BASELINE: would like to remove that 2* (and the 2* in '2*vfw' above).
-    size.rheight() -= 2*(RenderWidget::paddingTop() + RenderWidget::paddingBottom());
+    size.rheight() -= RenderWidget::paddingTop() + RenderWidget::paddingBottom();
 
     setIntrinsicWidth( size.width() );
     setIntrinsicHeight( size.height() );
@@ -2154,6 +2153,18 @@
     }
 }
 
+short RenderTextArea::scrollWidth() const
+{
+    return RenderObject::scrollWidth();
+}
+
+int RenderTextArea::scrollHeight() const
+{
+    TextAreaWidget* w = static_cast<TextAreaWidget*>(m_widget);
+    int contentHeight = qRound(w->document()->size().height());
+    return qMax(contentHeight, RenderObject::clientHeight());
+}
+
 void RenderTextArea::setText(const QString& newText)
 {
     TextAreaWidget* w = static_cast<TextAreaWidget*>(m_widget);
@@ -2177,7 +2188,7 @@
             tc.setPosition( ex, QTextCursor::MoveAnchor );
             tc.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
             tc.insertText(newText.right( newText.length()-ex ));
-        } else {                            
+        } else {
             w->setPlainText( newText );
         }
         w->setTextCursor(tc);
--- branches/KDE/4.3/kdelibs/khtml/rendering/render_form.h #1042751:1042752
@@ -517,6 +517,9 @@
     virtual void layout();
     virtual void setStyle(RenderStyle *style);
 
+    virtual short scrollWidth() const;
+    virtual int scrollHeight() const;
+
     virtual void updateFromElement();
 
     // don't even think about making this method virtual!
--- branches/KDE/4.3/kdelibs/khtml/rendering/render_object.h #1042751:1042752
@@ -156,8 +156,8 @@
     virtual RenderObject *firstChild() const { return 0; }
     virtual RenderObject *lastChild() const { return 0; }
 
-    RenderObject *nextRenderer() const;
-    RenderObject *previousRenderer() const;
+    RenderObject *nextRenderer() const;
+    RenderObject *previousRenderer() const;
 
     RenderObject *nextEditable() const;
     RenderObject *previousEditable() const;
@@ -346,7 +346,7 @@
     DOM::DocumentImpl* document() const;
     DOM::NodeImpl* element() const { return isAnonymous() ? 0L : m_node; }
     DOM::NodeImpl* node() const { return m_node; }
-    
+
     virtual bool handleEvent(const DOM::EventImpl&) { return false; }
 
    /**
@@ -644,12 +644,12 @@
     // how much goes over the left hand side (0 or a negative number)
     virtual int overflowTop() const { return 0; }
     virtual int overflowLeft() const { return 0; }
-    
+
     /**
      * Returns the height that is effectively considered when contemplating the
      * object as a whole -- usually the overflow height, or the height if clipped.
      */
-    int effectiveHeight() const { return hasOverflowClip() ? height() + borderTopExtra() + borderBottomExtra() :
+    int effectiveHeight() const { return hasOverflowClip() ? height() + borderTopExtra() + borderBottomExtra() :
                                          qMax(overflowHeight() - overflowTop(),  height() + borderTopExtra() + borderBottomExtra()); }
     /**
      * Returns the width that is effectively considered when contemplating the
@@ -667,8 +667,8 @@
     int clientTop() const;
     short clientWidth() const;
     int clientHeight() const;
-    short scrollWidth() const;
-    int scrollHeight() const;
+    virtual short scrollWidth() const;
+    virtual int scrollHeight() const;
 
     virtual bool isSelfCollapsingBlock() const { return false; }
     short collapsedMarginTop() const { return maxTopMargin(true)-maxTopMargin(false);  }
@@ -807,7 +807,7 @@
     virtual void detach( );
 
     bool documentBeingDestroyed() const { return !document()->renderer(); }
-    
+
     void setDoNotDelete(bool b) { m_doNotDelete = b; }
     bool doNotDelete() const { return m_doNotDelete; }
 
@@ -892,7 +892,7 @@
 
     bool m_needsPageClear            : 1;
     bool m_containsPageBreak         : 1;
-    
+
     bool m_hasOverflowClip           : 1;
     bool m_inPosObjectList           : 1;
 
_______________________________________________
Khtml-cvs mailing list
Khtml-cvs@...
https://mail.kde.org/mailman/listinfo/khtml-cvs