[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 06:30:12 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit f162036c236d9a1434589a7e4352ac56e4e20ea7
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Aug 8 01:15:46 2002 +0000

    	Adding support for a separate fixed font size to WebCore.
    	Your fixed font size pref will now be honored when the
    	generic monospace family is used.
    
            * khtml/css/cssstyleselector.cpp:
            * khtml/css/cssstyleselector.h:
            * khtml/rendering/font.h:
            * khtml/rendering/render_flow.cpp:
            (RenderFlow::layoutBlockChildren):
            * kwq/KWQKHTMLSettings.mm:
            (KHTMLSettings::mediumFixedFontSize):
            * kwq/WebCoreSettings.h:
            * kwq/WebCoreSettings.m:
            (-[WebCoreSettings setFixedFontSize:]):
            (-[WebCoreSettings fixedFontSize]):
            * kwq/khtml/khtml_settings.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1772 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index d2bd846..2d10201 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,22 @@
+2002-08-07  David Hyatt  <hyatt at apple.com>
+
+	Adding support for a separate fixed font size to WebCore.
+	Your fixed font size pref will now be honored when the
+	generic monospace family is used.
+	
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/cssstyleselector.h:
+        * khtml/rendering/font.h:
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::layoutBlockChildren):
+        * kwq/KWQKHTMLSettings.mm:
+        (KHTMLSettings::mediumFixedFontSize):
+        * kwq/WebCoreSettings.h:
+        * kwq/WebCoreSettings.m:
+        (-[WebCoreSettings setFixedFontSize:]):
+        (-[WebCoreSettings fixedFontSize]):
+        * kwq/khtml/khtml_settings.h:
+
 2002-08-07  Darin Adler  <darin at apple.com>
 
 	- fixed 3017499 -- One-click crasher at hondamotorcycle.com
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index d2bd846..2d10201 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,22 @@
+2002-08-07  David Hyatt  <hyatt at apple.com>
+
+	Adding support for a separate fixed font size to WebCore.
+	Your fixed font size pref will now be honored when the
+	generic monospace family is used.
+	
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/cssstyleselector.h:
+        * khtml/rendering/font.h:
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::layoutBlockChildren):
+        * kwq/KWQKHTMLSettings.mm:
+        (KHTMLSettings::mediumFixedFontSize):
+        * kwq/WebCoreSettings.h:
+        * kwq/WebCoreSettings.m:
+        (-[WebCoreSettings setFixedFontSize:]):
+        (-[WebCoreSettings fixedFontSize]):
+        * kwq/khtml/khtml_settings.h:
+
 2002-08-07  Darin Adler  <darin at apple.com>
 
 	- fixed 3017499 -- One-click crasher at hondamotorcycle.com
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index d2bd846..2d10201 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,22 @@
+2002-08-07  David Hyatt  <hyatt at apple.com>
+
+	Adding support for a separate fixed font size to WebCore.
+	Your fixed font size pref will now be honored when the
+	generic monospace family is used.
+	
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/cssstyleselector.h:
+        * khtml/rendering/font.h:
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::layoutBlockChildren):
+        * kwq/KWQKHTMLSettings.mm:
+        (KHTMLSettings::mediumFixedFontSize):
+        * kwq/WebCoreSettings.h:
+        * kwq/WebCoreSettings.m:
+        (-[WebCoreSettings setFixedFontSize:]):
+        (-[WebCoreSettings fixedFontSize]):
+        * kwq/khtml/khtml_settings.h:
+
 2002-08-07  Darin Adler  <darin at apple.com>
 
 	- fixed 3017499 -- One-click crasher at hondamotorcycle.com
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 448dec3..e1cf492 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -231,6 +231,12 @@ void CSSStyleSelector::clear()
 
 void CSSStyleSelector::computeFontSizes(QPaintDeviceMetrics* paintDeviceMetrics,  int zoomFactor)
 {
+    computeFontSizesFor(paintDeviceMetrics, zoomFactor, m_fontSizes, false);
+    computeFontSizesFor(paintDeviceMetrics, zoomFactor, m_fixedFontSizes, true);
+}
+
+void CSSStyleSelector::computeFontSizesFor(QPaintDeviceMetrics* paintDeviceMetrics, int zoomFactor, QValueList<int>& fontSizes, bool isFixed)
+{
 #ifdef APPLE_CHANGES
     // We don't want to scale the settings by the dpi.
     const float toPix = 1;
@@ -240,14 +246,17 @@ void CSSStyleSelector::computeFontSizes(QPaintDeviceMetrics* paintDeviceMetrics,
     if (toPix  < 96./72.) toPix = 96./72.;
 #endif
 
-    m_fontSizes.clear();
+    fontSizes.clear();
     const float factor = 1.2;
     float scale = 1.0 / (factor*factor*factor);
     float mediumFontSize;
     float minFontSize;
     if (!khtml::printpainter) {
         scale *= zoomFactor / 100.0;
-        mediumFontSize = settings->mediumFontSize() * toPix;
+	if (isFixed)
+	    mediumFontSize = settings->mediumFixedFontSize() * toPix;
+	else
+	    mediumFontSize = settings->mediumFontSize() * toPix;
         minFontSize = settings->minFontSize() * toPix;
     }
     else {
@@ -257,7 +266,7 @@ void CSSStyleSelector::computeFontSizes(QPaintDeviceMetrics* paintDeviceMetrics,
     }
 
     for ( int i = 0; i < MAXFONTSIZES; i++ ) {
-        m_fontSizes << int(KMAX( mediumFontSize * scale + 0.5f, minFontSize));
+        fontSizes << int(KMAX( mediumFontSize * scale + 0.5f, minFontSize));
         scale *= factor;
     }
 }
@@ -373,6 +382,11 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
     else
 	parentStyle = style;
 
+    // This member will be set to true if a rule specifies a font size
+    // explicitly.  If they do this, then we don't need to check for a shift
+    // in default size caused by a change in generic family. -dwh
+    m_fontSizeSpecified = false;
+
     //qDebug("applying properties, count=%d", propsToApply->count() );
 
     // we can't apply style rules without a view() and a part. This
@@ -386,13 +400,16 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
 		if ( fontDirty && propsToApply[i]->priority >= (1 << 30) ) {
 		    // we are past the font properties, time to update to the
 		    // correct font
+		    checkForGenericFamilyChange(style, parentStyle);
 		    CSSStyleSelector::style->htmlFont().update( paintDeviceMetrics );
 		    fontDirty = false;
 		}
                 applyRule( propsToApply[i]->prop );
 	    }
-	    if ( fontDirty )
+	    if ( fontDirty ) {
+	        checkForGenericFamilyChange(style, parentStyle);
 		CSSStyleSelector::style->htmlFont().update( paintDeviceMetrics );
+	    }
         }
 
         if ( numPseudoProps ) {
@@ -2236,6 +2253,10 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
         float size = 0;
         int minFontSize = settings->minFontSize();
 
+	// Set this boolean flag to indicate that the font size was specified
+	// during the course of rule application for this element. -dwh
+	m_fontSizeSpecified = true;
+
         if(parentNode) {
             oldSize = parentStyle->font().pixelSize();
         } else
@@ -2244,6 +2265,11 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
         if(value->cssValueType() == CSSValue::CSS_INHERIT) {
             size = oldSize;
         } else if(primitiveValue->getIdent()) {
+	    // keywords are being used.  Pick the correct default
+	    // based off the font family.
+	    QValueList<int>* fontSizes = (fontDef.genericFamily == FontDef::eMonospace) ?
+					 &m_fixedFontSizes : &m_fontSizes;
+	   
             switch(primitiveValue->getIdent())
             {
             case CSS_VAL_XX_SMALL: size = m_fontSizes[0]; break;
@@ -2288,7 +2314,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
 
 	fontDef.size = int(size);
         if (style->setFontDef( fontDef ))
-	fontDirty = true;
+	    fontDirty = true;
         return;
     }
 
@@ -2457,28 +2483,39 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
             if(!val->primitiveType() == CSSPrimitiveValue::CSS_STRING) return;
             QString face = static_cast<FontFamilyValueImpl *>(val)->fontName();
 	    if ( !face.isEmpty() ) {
-		if(face == "serif") {
+	        if(face == "serif") {
 		    face = settings->serifFontName();
+		    fontDef.setGenericFamily(FontDef::eSerif);
 		}
 		else if(face == "sans-serif") {
 		    face = settings->sansSerifFontName();
+		    fontDef.setGenericFamily(FontDef::eSansSerif);
 		}
 		else if( face == "cursive") {
 		    face = settings->cursiveFontName();
+		    fontDef.setGenericFamily(FontDef::eCursive);
 		}
 		else if( face == "fantasy") {
 		    face = settings->fantasyFontName();
+		    fontDef.setGenericFamily(FontDef::eFantasy);
 		}
 		else if( face == "monospace") {
 		    face = settings->fixedFontName();
+		    fontDef.setGenericFamily(FontDef::eMonospace);
 		}
 		else if( face == "konq_default") {
+		    // Treat this as though it's a generic family, since we will want
+		    // to reset to default sizes when we encounter this (and inherit
+		    // from an enclosing different family like monospace.
 		    face = settings->stdFontName();
+		    fontDef.setGenericFamily(FontDef::eStandard);
 		}
+
 		if ( !face.isEmpty() ) {
 		    fontDef.family = face;
-		    if (style->setFontDef( fontDef ))
-			fontDirty = true;
+		    if (style->setFontDef( fontDef )) {
+		      fontDirty = true;
+		    }
 		}
                 return;
 	    }
@@ -2648,4 +2685,38 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
     }
 }
 
+
+void CSSStyleSelector::checkForGenericFamilyChange(RenderStyle* aStyle, RenderStyle* aParentStyle)
+{
+  if (m_fontSizeSpecified || !aParentStyle) {
+    m_fontSizeSpecified = false;
+    return;
+  }
+
+  const FontDef& childFont = aStyle->htmlFont().fontDef;
+  const FontDef& parentFont = aParentStyle->htmlFont().fontDef;
+
+  if (childFont.genericFamily == parentFont.genericFamily)
+    return;
+
+  // For now, lump all families but monospace together.
+  if (childFont.genericFamily != FontDef::eMonospace &&
+      parentFont.genericFamily != FontDef::eMonospace)
+    return;
+
+  // 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;
+  int minFontSize = settings->minFontSize();
+  size = (childFont.genericFamily == FontDef::eMonospace) ? m_fixedFontSizes[3] : m_fontSizes[3];
+  int isize = (int)size;
+  if (isize < minFontSize)
+    isize = minFontSize;
+  
+  FontDef newFontDef(childFont);
+  newFontDef.size = isize;
+  aStyle->setFontDef(newFontDef);
+}
+
 } // namespace khtml
diff --git a/WebCore/khtml/css/cssstyleselector.h b/WebCore/khtml/css/cssstyleselector.h
index 3c4cd13..533d335 100644
--- a/WebCore/khtml/css/cssstyleselector.h
+++ b/WebCore/khtml/css/cssstyleselector.h
@@ -126,6 +126,7 @@ namespace khtml
 	RenderStyle *styleForElement(DOM::ElementImpl *e, int state = None );
 
         QValueList<int> fontSizes() const { return m_fontSizes; }
+	QValueList<int> fixedFontSizes() const { return m_fixedFontSizes; }
 
 	bool strictParsing;
 	struct Encodedurl {
@@ -135,6 +136,8 @@ namespace khtml
 	} encodedurl;
 
         void computeFontSizes(QPaintDeviceMetrics* paintDeviceMetrics, int zoomFactor);
+	void computeFontSizesFor(QPaintDeviceMetrics* paintDeviceMetrics, int zoomFactor, QValueList<int>& fontSizes, bool isFixed);
+
     protected:
 
 	/* checks if the complete selector (which can be build up from a few CSSSelector's
@@ -143,6 +146,10 @@ namespace khtml
 	/* checks if the selector matches the given Element */
 	bool checkOneSelector(DOM::CSSSelector *selector, DOM::ElementImpl *e);
 
+	/* This function fixes up the default font size if it detects that the
+	   current generic font family has changed. -dwh */
+	void checkForGenericFamilyChange(RenderStyle* aStyle, RenderStyle* aParentStyle);
+
 	/* builds up the selectors and properties lists from the CSSStyleSelectorList's */
 	void buildLists();
 	void clearLists();
@@ -216,8 +223,10 @@ namespace khtml
 	const KHTMLSettings *settings;
 	QPaintDeviceMetrics *paintDeviceMetrics;
         QValueList<int>     m_fontSizes;
+	QValueList<int>     m_fixedFontSizes;
 
 	bool fontDirty;
+	bool m_fontSizeSpecified;
 
 	void applyRule(DOM::CSSProperty *prop);
     };
diff --git a/WebCore/khtml/rendering/font.h b/WebCore/khtml/rendering/font.h
index 973b86c..7dab2bd 100644
--- a/WebCore/khtml/rendering/font.h
+++ b/WebCore/khtml/rendering/font.h
@@ -41,7 +41,8 @@ class FontDef
 {
 public:
     FontDef()
-        : size( 0 ), italic( false ), smallCaps( false ), weight( 50 ), hasNbsp( true ) {}
+        : size( 0 ), italic( false ), smallCaps( false ), weight( 50 ), 
+          genericFamily(0), hasNbsp( true ) {}
     bool operator == ( const FontDef &other ) const {
         return ( family == other.family &&
                  size == other.size &&
@@ -50,11 +51,16 @@ public:
                  weight == other.weight );
     }
 
+    enum GenericFamilyType { eNone, eStandard, eSerif, eSansSerif, eMonospace, eCursive, eFantasy };
+
+    void setGenericFamily(unsigned int aGenericFamily) { genericFamily = aGenericFamily; }
+    
     QString family;
     short int size;
     bool italic 		: 1;
     bool smallCaps 		: 1;
     unsigned int weight 		: 8;
+    unsigned int genericFamily  : 3;
     mutable bool hasNbsp : 1;
 };
 
diff --git a/WebCore/khtml/rendering/render_flow.cpp b/WebCore/khtml/rendering/render_flow.cpp
index 61217b9..67123af 100644
--- a/WebCore/khtml/rendering/render_flow.cpp
+++ b/WebCore/khtml/rendering/render_flow.cpp
@@ -488,7 +488,7 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
         child = child->nextSibling();
     }
 
-    if( !isTableCell() && toAdd != 0 )
+    if( isTableCell() || toAdd != 0)
 	m_height += prevMargin;
     m_height += toAdd;
 
diff --git a/WebCore/kwq/KWQKHTMLSettings.h b/WebCore/kwq/KWQKHTMLSettings.h
index b3e712b..7b96a5d 100644
--- a/WebCore/kwq/KWQKHTMLSettings.h
+++ b/WebCore/kwq/KWQKHTMLSettings.h
@@ -59,6 +59,7 @@ public:
 
     int minFontSize() const;
     int mediumFontSize() const;
+    int mediumFixedFontSize() const;
 
     bool changeCursor() const;
 
diff --git a/WebCore/kwq/KWQKHTMLSettings.mm b/WebCore/kwq/KWQKHTMLSettings.mm
index 65f1ea4..cc7fbe3 100644
--- a/WebCore/kwq/KWQKHTMLSettings.mm
+++ b/WebCore/kwq/KWQKHTMLSettings.mm
@@ -80,6 +80,11 @@ int KHTMLSettings::mediumFontSize() const
     return [[NSUserDefaults standardUserDefaults] integerForKey:@"WebKitDefaultFontSize"];
 }
 
+int KHTMLSettings::mediumFixedFontSize() const
+{
+    return [[NSUserDefaults standardUserDefaults] integerForKey:@"WebKitFixedFontSize"];
+}
+
 bool KHTMLSettings::changeCursor() const
 {
     return true;
diff --git a/WebCore/kwq/WebCoreSettings.h b/WebCore/kwq/WebCoreSettings.h
index ac116a1..3bc31c9 100644
--- a/WebCore/kwq/WebCoreSettings.h
+++ b/WebCore/kwq/WebCoreSettings.h
@@ -35,6 +35,7 @@
     NSString *fantasyFontFamily;
     float minimumFontSize;
     float defaultFontSize;
+    float fixedFontSize;
     BOOL JavaEnabled;
     BOOL pluginsEnabled;
     BOOL JavaScriptEnabled;
@@ -67,6 +68,9 @@
 - (void)setDefaultFontSize:(float)size;
 - (float)defaultFontSize;
 
+- (void)setFixedFontSize:(float)size;
+- (float)fixedFontSize;
+
 - (void)setJavaEnabled:(BOOL)enabled;
 - (BOOL)JavaEnabled;
 
diff --git a/WebCore/kwq/WebCoreSettings.m b/WebCore/kwq/WebCoreSettings.m
index 49692a4..ddfaabd 100644
--- a/WebCore/kwq/WebCoreSettings.m
+++ b/WebCore/kwq/WebCoreSettings.m
@@ -140,6 +140,16 @@
     return defaultFontSize;
 }
 
+- (void)setFixedFontSize:(float)size
+{
+  fixedFontSize = size;
+}
+
+- (float)fixedFontSize
+{
+  return fixedFontSize;
+}
+
 - (void)setJavaEnabled:(BOOL)enabled
 {
     JavaEnabled = enabled;
diff --git a/WebCore/kwq/khtml/khtml_settings.h b/WebCore/kwq/khtml/khtml_settings.h
index b3e712b..7b96a5d 100644
--- a/WebCore/kwq/khtml/khtml_settings.h
+++ b/WebCore/kwq/khtml/khtml_settings.h
@@ -59,6 +59,7 @@ public:
 
     int minFontSize() const;
     int mediumFontSize() const;
+    int mediumFixedFontSize() const;
 
     bool changeCursor() const;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list