[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 08:12:49 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 6ee3f9301a2b8f7b0ce5c63c86840519522f2b95
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 17 20:38:09 2003 +0000

    	Fix for 3415771, Safari should use mini form controls when necessary.  This patch adds heuristics for
    	swapping in mini form controls and also drops intrinsic margins when mini form controls are used.
    
    	Fix for 3486454, options/optgroups should strip leading/trailing space.
    
    	Together these two fixes solve 3486581, travelocity misrenders because form controls are too large.
    
    	Reviewed by Darin
    
    	Also fixing 3474994, alink needs to be restricted to actual links and not all <a> tags.
    
    	Reviewed by John
    
    	Finally, adding :active outlines around <input type=image> (covered by the old bug 3141767).
    
            * khtml/css/cssstyleselector.cpp:
            (khtml::CSSStyleSelector::CSSStyleSelector):
            (khtml::CSSStyleSelector::applyRule):
            (khtml::CSSStyleSelector::checkForGenericFamilyChange):
            (khtml::CSSStyleSelector::getComputedSizeFromSpecifiedSize):
            (khtml::):
            (khtml::CSSStyleSelector::fontSizeForKeyword):
            (khtml::CSSStyleSelector::largerFontSize):
            (khtml::CSSStyleSelector::smallerFontSize):
            * khtml/css/cssstyleselector.h:
            * khtml/css/html4.css:
            * khtml/html/html_baseimpl.cpp:
            (HTMLBodyElementImpl::parseAttribute):
            * khtml/khtml_part.cpp:
            (KHTMLPart::setZoomFactor):
            * khtml/rendering/render_form.cpp:
            (RenderFormElement::addIntrinsicMarginsIfAllowed):
            (RenderSelect::updateFromElement):
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::recalcStyle):
            (DocumentImpl::attach):
            * kwq/KWQButton.mm:
            (KWQNSControlSizeForFont):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5537 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 5192eaa..0092418 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,46 @@
 2003-11-17  David Hyatt  <hyatt at apple.com>
 
+	Fix for 3415771, Safari should use mini form controls when necessary.  This patch adds heuristics for
+	swapping in mini form controls and also drops intrinsic margins when mini form controls are used.
+
+	Fix for 3486454, options/optgroups should strip leading/trailing space.
+	
+	Together these two fixes solve 3486581, travelocity misrenders because form controls are too large.
+
+	Reviewed by Darin
+
+	Also fixing 3474994, alink needs to be restricted to actual links and not all <a> tags.
+
+	Reviewed by John
+
+	Finally, adding :active outlines around <input type=image> (covered by the old bug 3141767).
+
+        * khtml/css/cssstyleselector.cpp:
+        (khtml::CSSStyleSelector::CSSStyleSelector):
+        (khtml::CSSStyleSelector::applyRule):
+        (khtml::CSSStyleSelector::checkForGenericFamilyChange):
+        (khtml::CSSStyleSelector::getComputedSizeFromSpecifiedSize):
+        (khtml::):
+        (khtml::CSSStyleSelector::fontSizeForKeyword):
+        (khtml::CSSStyleSelector::largerFontSize):
+        (khtml::CSSStyleSelector::smallerFontSize):
+        * khtml/css/cssstyleselector.h:
+        * khtml/css/html4.css:
+        * khtml/html/html_baseimpl.cpp:
+        (HTMLBodyElementImpl::parseAttribute):
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::setZoomFactor):
+        * khtml/rendering/render_form.cpp:
+        (RenderFormElement::addIntrinsicMarginsIfAllowed):
+        (RenderSelect::updateFromElement):
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::recalcStyle):
+        (DocumentImpl::attach):
+        * kwq/KWQButton.mm:
+        (KWQNSControlSizeForFont):
+
+2003-11-17  David Hyatt  <hyatt at apple.com>
+
 	Back out my change to exclude text runs from getting a relayout on a style change.  I totally forgot about
 	text zooming.
 	
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index ed90989..e429bb7 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -138,9 +138,6 @@ CSSStyleSelector::CSSStyleSelector( DocumentImpl* doc, QString userStyleSheet, S
     userSheet = 0;
     paintDeviceMetrics = doc->paintDeviceMetrics();
 
-    if (paintDeviceMetrics) // this may be null, not everyone uses khtmlview (Niko)
-        computeFontSizes(paintDeviceMetrics);
-        
     if ( !userStyleSheet.isEmpty() ) {
         userSheet = new DOM::CSSStyleSheetImpl(doc);
         userSheet->parseString( DOMString( userStyleSheet ) );
@@ -287,44 +284,6 @@ void CSSStyleSelector::clear()
     styleNotYetAvailable = 0;
 }
 
-#define MAXFONTSIZES 15
-
-void CSSStyleSelector::computeFontSizes(QPaintDeviceMetrics* paintDeviceMetrics)
-{
-#if APPLE_CHANGES
-    // We don't want to scale the settings by the dpi.
-    const float toPix = 1;
-#else
-    // ### get rid of float / double
-    float toPix = paintDeviceMetrics->logicalDpiY()/72.;
-    if (toPix  < 96./72.) toPix = 96./72.;
-#endif
-
-    m_fontSizes.clear();
-    const float factor = 1.2;
-    float scale = 1.0 / (factor*factor*factor);
-    float mediumFontSize;
-    float minFontSize;
-    if (!khtml::printpainter) {
-        mediumFontSize = settings->mediumFontSize() * toPix;
-        minFontSize = toPix;
-        m_fixedScaleFactor = (settings->mediumFixedFontSize() * toPix) / mediumFontSize;
-    }
-    else {
-        // ## depending on something / configurable ?
-        mediumFontSize = 12;
-        minFontSize = 1;
-        m_fixedScaleFactor = 1.0;
-    }
-
-    for ( int i = 0; i < MAXFONTSIZES; i++ ) {
-        m_fontSizes << int(KMAX( mediumFontSize * scale + 0.5f, minFontSize));
-        scale *= factor;
-    }
-}
-
-#undef MAXFONTSIZES
-
 static inline void bubbleSort( CSSOrderedProperty **b, CSSOrderedProperty **e )
 {
     while( b < e ) {
@@ -2674,7 +2633,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
     case CSS_PROP_FONT_SIZE:
     {
         FontDef fontDef = style->htmlFont().fontDef;
-        float oldSize;
+        float oldSize = 0;
         float size = 0;
         
         bool parentIsAbsoluteSize = false;
@@ -2682,30 +2641,29 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
             oldSize = parentStyle->htmlFont().fontDef.specifiedSize;
             parentIsAbsoluteSize = parentStyle->htmlFont().fontDef.isAbsoluteSize;
         }
-        else
-            oldSize = m_fontSizes[3];
 
         if (isInherit)
             size = oldSize;
         else if (isInitial)
-            size = m_fontSizes[3];
+            size = fontSizeForKeyword(CSS_VAL_MEDIUM, style->htmlHacks());
         else if (primitiveValue->getIdent()) {
-            // keywords are being used.  Pick the correct default
-            // based off the font family.
+            // Keywords are being used.
             switch (primitiveValue->getIdent()) {
-            case CSS_VAL_XX_SMALL: size = m_fontSizes[0]; break;
-            case CSS_VAL_X_SMALL:  size = m_fontSizes[1]; break;
-            case CSS_VAL_SMALL:    size = m_fontSizes[2]; break;
-            case CSS_VAL_MEDIUM:   size = m_fontSizes[3]; break;
-            case CSS_VAL_LARGE:    size = m_fontSizes[4]; break;
-            case CSS_VAL_X_LARGE:  size = m_fontSizes[5]; break;
-            case CSS_VAL_XX_LARGE: size = m_fontSizes[6]; break;
-            case CSS_VAL__KHTML_XXX_LARGE:  size = ( m_fontSizes[6]*5 )/3; break;
+            case CSS_VAL_XX_SMALL:
+            case CSS_VAL_X_SMALL:
+            case CSS_VAL_SMALL:
+            case CSS_VAL_MEDIUM:
+            case CSS_VAL_LARGE:
+            case CSS_VAL_X_LARGE:
+            case CSS_VAL_XX_LARGE:
+            case CSS_VAL__KHTML_XXX_LARGE:
+                size = fontSizeForKeyword(primitiveValue->getIdent(), style->htmlHacks());
+                break;
             case CSS_VAL_LARGER:
-                size = oldSize * 1.2;
+                size = largerFontSize(oldSize, style->htmlHacks());
                 break;
             case CSS_VAL_SMALLER:
-                size = oldSize / 1.2;
+                size = smallerFontSize(oldSize, style->htmlHacks());
                 break;
             default:
                 return;
@@ -3513,9 +3471,10 @@ 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 scale our font size as appropriate.
+  float fixedScaleFactor = ((float)settings->mediumFixedFontSize())/settings->mediumFontSize();
   float size = (parentFont.genericFamily == FontDef::eMonospace) ? 
-      childFont.specifiedSize/m_fixedScaleFactor :
-      childFont.specifiedSize*m_fixedScaleFactor;
+      childFont.specifiedSize/fixedScaleFactor :
+      childFont.specifiedSize*fixedScaleFactor;
   
   FontDef newFontDef(childFont);
   setFontSize(newFontDef, size);
@@ -3559,4 +3518,79 @@ float CSSStyleSelector::getComputedSizeFromSpecifiedSize(bool isAbsoluteSize, fl
     return KMAX(zoomedSize, 1.0f);
 }
 
+const int fontSizeTableMax = 16;
+const int fontSizeTableMin = 9;
+const int totalKeywords = 8;
+
+// WinIE/Nav4 table for font sizes.  Designed to match the legacy font mapping system of HTML.
+static const int quirksFontSizeTable[fontSizeTableMax - fontSizeTableMin + 1][totalKeywords] =
+{
+      { 9,    9,     9,     9,    11,    14,    18,    28 },
+      { 9,    9,     9,    10,    12,    15,    20,    31 },
+      { 9,    9,     9,    11,    13,    17,    22,    34 },
+      { 9,    9,    10,    12,    14,    18,    24,    37 },
+      { 9,    9,    10,    13,    16,    20,    26,    40 }, // fixed font default (13)
+      { 9,    9,    11,    14,    17,    21,    28,    42 },
+      { 9,   10,    12,    15,    17,    23,    30,    45 },
+      { 9,   10,    13,    16,    18,    24,    32,    48 }  // proportional font default (16)
+};
+// HTML       1      2      3      4      5      6      7
+// CSS  xxs   xs     s      m      l     xl     xxl
+//                          |
+//                      user pref
+
+// Strict mode table matches MacIE and Mozilla's settings exactly.
+static const int strictFontSizeTable[fontSizeTableMax - fontSizeTableMin + 1][totalKeywords] =
+{
+      { 9,    9,     9,     9,    11,    14,    18,    27 },
+      { 9,    9,     9,    10,    12,    15,    20,    30 },
+      { 9,    9,    10,    11,    13,    17,    22,    33 },
+      { 9,    9,    10,    12,    14,    18,    24,    36 },
+      { 9,   10,    12,    13,    16,    20,    26,    39 }, // fixed font default (13)
+      { 9,   10,    12,    14,    17,    21,    28,    42 },
+      { 9,   10,    13,    15,    18,    23,    30,    45 },
+      { 9,   10,    13,    16,    18,    24,    32,    48 }  // proportional font default (16)
+};
+// HTML       1      2      3      4      5      6      7
+// CSS  xxs   xs     s      m      l     xl     xxl
+//                          |
+//                      user pref
+
+// For values outside the range of the table, we use Todd Fahrner's suggested scale
+// factors for each keyword value.
+static const float fontSizeFactors[totalKeywords] = { 0.60, 0.75, 0.89, 1.0, 1.2, 1.5, 2.0, 3.0 };
+
+float CSSStyleSelector::fontSizeForKeyword(int keyword, bool quirksMode) const
+{
+    // FIXME: One issue here is that we set up the fixed font size as a scale factor applied
+    // to the proportional pref.  This means that we won't get pixel-perfect size matching for
+    // the 13px default, since we actually use the 16px row in the table and apply the fixed size
+    // scale later.
+    int mediumSize = settings->mediumFontSize();
+    if (mediumSize >= fontSizeTableMin && mediumSize <= fontSizeTableMax) {
+        // Look up the entry in the table.
+        int row = mediumSize - fontSizeTableMin;
+        int col = (keyword - CSS_VAL_XX_SMALL);
+        return quirksMode ? quirksFontSizeTable[row][col] : strictFontSizeTable[row][col];
+    }
+    
+    // Value is outside the range of the table. Apply the scale factor instead.
+    float minLogicalSize = kMax(settings->minLogicalFontSize(), 1.0f);
+    return kMax(fontSizeFactors[keyword - CSS_VAL_XX_SMALL]*mediumSize, minLogicalSize);
+}
+
+float CSSStyleSelector::largerFontSize(float size, bool quirksMode) const
+{
+    // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale up to
+    // the next size level.  
+    return size*1.2;
+}
+
+float CSSStyleSelector::smallerFontSize(float size, bool quirksMode) const
+{
+    // FIXME: Figure out where we fall in the size ranges (xx-small to xxx-large) and scale down to
+    // the next size level. 
+    return size/1.2;
+}
+
 } // namespace khtml
diff --git a/WebCore/khtml/css/cssstyleselector.h b/WebCore/khtml/css/cssstyleselector.h
index c61061c..0246f06 100644
--- a/WebCore/khtml/css/cssstyleselector.h
+++ b/WebCore/khtml/css/cssstyleselector.h
@@ -129,9 +129,7 @@ namespace khtml
 	RenderStyle *styleForElement(DOM::ElementImpl* e, RenderStyle* parentStyle=0);
         RenderStyle* pseudoStyleForElement(RenderStyle::PseudoId pseudoStyle, 
                                            DOM::ElementImpl* e, RenderStyle* parentStyle=0);
-        
-        QValueList<int> fontSizes() const { return m_fontSizes; }
-	
+
 	bool strictParsing;
 	struct Encodedurl {
 	    QString host; //also contains protocol
@@ -139,7 +137,17 @@ namespace khtml
 	    QString file;
 	} encodedurl;
 
-        void computeFontSizes(QPaintDeviceMetrics* paintDeviceMetrics);
+        // Given a CSS keyword in the range (xx-small to -khtml-xxx-large), this function will return
+        // the correct font size scaled relative to the user's default (medium).
+        float fontSizeForKeyword(int keyword, bool quirksMode) const;
+        
+        // When the CSS keyword "larger" is used, this function will attempt to match within the keyword
+        // table, and failing that, will simply multiply by 1.2.
+        float largerFontSize(float size, bool quirksMode) const;
+        
+        // Like the previous function, but for the keyword "smaller".
+        float smallerFontSize(float size, bool quirksMode) const;
+        
         void setFontSize(FontDef& fontDef, float size);
         float getComputedSizeFromSpecifiedSize(bool isAbsoluteSize, float specifiedSize);
         
@@ -230,10 +238,7 @@ public:
 	KHTMLPart *part;
 	const KHTMLSettings *settings;
 	QPaintDeviceMetrics *paintDeviceMetrics;
-        QValueList<int>     m_fontSizes;
-        float m_fixedScaleFactor; // Used when converting from proportional to fixed and vice
-                                  // versa.
-	bool fontDirty;
+        bool fontDirty;
         bool isXMLDoc;
         
 	void applyRule(int id, DOM::CSSValueImpl *value);
diff --git a/WebCore/khtml/css/html4.css b/WebCore/khtml/css/html4.css
index 0d572e4..89607a5 100644
--- a/WebCore/khtml/css/html4.css
+++ b/WebCore/khtml/css/html4.css
@@ -332,9 +332,9 @@ BUTTON:active {
 
 /* XXX Need to implement support for CSS2 system fonts, so that I don't have to hard code this.
    -dwh */
-INPUT, TEXTAREA {
-	font: 11px 'Lucida Grande';
-        margin: 0__qem;
+INPUT, TEXTAREA, SELECT, BUTTON {
+    margin: 0__qem;
+    font: 11px 'Lucida Grande';
 }
 
 INPUT[type="hidden"] {
@@ -345,8 +345,8 @@ INPUT[type="radio"], INPUT[type="checkbox"] {
         margin: 3px 0.5ex;
 }
 
-SELECT {
-        margin: 0__qem;
+INPUT[type="image"]:active {
+  outline: -apple-aqua 3px 
 }
 
 OPTION, 
diff --git a/WebCore/khtml/html/html_baseimpl.cpp b/WebCore/khtml/html/html_baseimpl.cpp
index 952c915..c8a509c 100644
--- a/WebCore/khtml/html/html_baseimpl.cpp
+++ b/WebCore/khtml/html/html_baseimpl.cpp
@@ -120,7 +120,7 @@ void HTMLBodyElementImpl::parseAttribute(AttributeImpl *attr)
 	else if ( attr->id() == ATTR_VLINK )
 	    aStr = "a:visited";
 	else if ( attr->id() == ATTR_ALINK )
-	    aStr = "a:active";
+            aStr = "a:link:active, a:visited:active";
 	aStr += " { color: " + attr->value().string() + "; }";
         m_styleSheet->parseString(aStr, !getDocument()->inCompatMode());
         m_styleSheet->setNonCSSHints();
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index c2cb731..1f0844f 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -4133,8 +4133,6 @@ void KHTMLPart::setZoomFactor (int percent)
 #if !APPLE_CHANGES
       QApplication::setOverrideCursor( waitCursor );
 #endif
-    if (d->m_doc->styleSelector())
-      d->m_doc->styleSelector()->computeFontSizes(d->m_doc->paintDeviceMetrics());
     d->m_doc->recalcStyle( NodeImpl::Force );
 #if !APPLE_CHANGES
     QApplication::restoreOverrideCursor();
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index 995f5c4..f5a6d10 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -206,18 +206,23 @@ void RenderFormElement::slotClicked()
 
 void RenderFormElement::addIntrinsicMarginsIfAllowed(RenderStyle* _style)
 {
+    // Cut out the intrinsic margins completely if we end up using mini controls.
+    if (_style->font().pixelSize() < 11)
+        return;
+    
+    int m = intrinsicMargin();
     if (_style->width().isVariable()) {
         if (_style->marginLeft().quirk)
-            _style->setMarginLeft(Length(intrinsicMargin(), Fixed));
+            _style->setMarginLeft(Length(m, Fixed));
         if (_style->marginRight().quirk)
-            _style->setMarginRight(Length(intrinsicMargin(), Fixed));
+            _style->setMarginRight(Length(m, Fixed));
     }
 
     if (_style->height().isVariable()) {
         if (_style->marginTop().quirk)
-            _style->setMarginTop(Length(intrinsicMargin(), Fixed));
+            _style->setMarginTop(Length(m, Fixed));
         if (_style->marginBottom().quirk)
-            _style->setMarginBottom(Length(intrinsicMargin(), Fixed));
+            _style->setMarginBottom(Length(m, Fixed));
     }
 }
 
@@ -1067,6 +1072,10 @@ void RenderSelect::updateFromElement()
                 QString label = QString(text.implementation()->s, text.implementation()->l);
                 label.replace('\\', backslashAsCurrencySymbol());
 
+                // In WinIE, an optgroup can't start or end with whitespace (other than the indent
+                // we give it).  We match this behavior.
+                label = label.stripWhiteSpace();
+                
                 if(m_useListBox) {
 #if APPLE_CHANGES
                     static_cast<KListBox*>(m_widget)->insertGroupLabel(label, listIndex);
@@ -1089,6 +1098,9 @@ void RenderSelect::updateFromElement()
                 QString itemText = QString(text.implementation()->s, text.implementation()->l);
                 itemText.replace('\\', backslashAsCurrencySymbol());
 
+                // In WinIE, an option can't start or end with whitespace.  We match this behavior.
+                itemText = itemText.stripWhiteSpace();
+                
                 if(m_useListBox)
                     static_cast<KListBox*>(m_widget)->insertItem(itemText, listIndex);
                 else
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 3cb2fb8..f85d81a 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -68,6 +68,8 @@
 #include "html/html_tableimpl.h"
 #include "html/html_objectimpl.h"
 
+#include "cssvalues.h"
+
 #include <kio/job.h>
 
 #if APPLE_CHANGES
@@ -984,7 +986,7 @@ void DocumentImpl::recalcStyle( StyleChange change )
                 fontDef.family.setFamily(stdfont);
                 fontDef.family.appendFamily(0);
             }
-            m_styleSelector->setFontSize(fontDef, m_styleSelector->fontSizes()[3]);
+            m_styleSelector->setFontSize(fontDef, m_styleSelector->fontSizeForKeyword(CSS_VAL_MEDIUM, inCompatMode()));
         }
 
         //kdDebug() << "DocumentImpl::attach: setting to charset " << settings->charset() << endl;
@@ -1085,7 +1087,6 @@ void DocumentImpl::attach()
     
     // Create the rendering tree
     m_render = new (m_renderArena) RenderCanvas(this, m_view);
-    m_styleSelector->computeFontSizes(paintDeviceMetrics());
     recalcStyle( Force );
 
     RenderObject* render = m_render;
diff --git a/WebCore/kwq/KWQButton.mm b/WebCore/kwq/KWQButton.mm
index e1621d5..407e8d6 100644
--- a/WebCore/kwq/KWQButton.mm
+++ b/WebCore/kwq/KWQButton.mm
@@ -298,19 +298,14 @@ void QButton::setFont(const QFont &f)
 
 NSControlSize KWQNSControlSizeForFont(const QFont &f)
 {
-    return NSSmallControlSize;
-    // Dave is going to turn this on once he figures out what he wants to do
-    // about mini controls.
-#if 0
     const int fontSize = f.pixelSize();
-    if (fontSize >= 20) {
+    if (fontSize >= 16) {
         return NSRegularControlSize;
     }
-    if (fontSize >= 10) {
+    if (fontSize >= 11) {
         return NSSmallControlSize;
     }
     return NSMiniControlSize;
-#endif
 }
 
 QWidget::FocusPolicy QButton::focusPolicy() const

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list