Bug 128024

Summary: Alignment issues with generated content (:before and :after CSS pseudo-elements) in XHTML Strict mode
Product: [Applications] konqueror Reporter: Laurent Pinchart <laurent.pinchart>
Component: khtmlAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Test case
patch... Qt does not support setting a QFont to size zero (be it pixels or points, though it's only explicitly said in documentation for the latter)

Description Laurent Pinchart 2006-05-25 17:12:39 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    Gentoo Packages
Compiler:          gcc 3.3.5 
OS:                Linux

:before and :after CSS pseudo-elements' content is incorrectly aligned in XHTML 1.0 Strict mode. XHTML 1.0 Transitional mode works fine.

See the attached test case: good.html is XHTML 1.0 Transitional, bad.html is XHTML 1.0 Strict. Notice the alignment issue in upper-left and lower-left corners.
Comment 1 Laurent Pinchart 2006-05-25 17:13:12 UTC
Created attachment 16267 [details]
Test case
Comment 2 Allan Sandfeld 2006-05-25 20:22:18 UTC
Confirmed. 

Notice however that there a several invalid statements in your CSS, which are ignored in both modes.
Comment 3 Germain Garand 2006-05-27 17:39:13 UTC
mmh, using font-size > 0 makes testcase work.
Investigating that...

Comment 4 Germain Garand 2006-05-27 17:58:55 UTC
Created attachment 16299 [details]
patch... Qt does not support setting a QFont to size zero (be it pixels or points, though it's only explicitly said in documentation for the latter)
Comment 5 Germain Garand 2006-06-18 15:27:01 UTC
SVN commit 552597 by ggarand:

QFont does not support setting a zero pixel size.

BUG:128024


 M  +3 -2      css/cssstyleselector.cpp  
 M  +3 -2      rendering/font.cpp  


--- branches/KDE/3.5/kdelibs/khtml/css/cssstyleselector.cpp #552596:552597
@@ -3167,10 +3167,11 @@
                 return;
         }
 
-        if(size < 1) return;
+        if (size < 0) return;
 
         // we never want to get smaller than the minimum font size to keep fonts readable
-        if(size < minFontSize ) size = minFontSize;
+        // do not however maximize zero as that is commonly used for fancy layouting purposes
+        if (size && size < minFontSize) size = minFontSize;
 
         //kdDebug( 6080 ) << "computed raw font size: " << size << endl;
 
--- branches/KDE/3.5/kdelibs/khtml/rendering/font.cpp #552596:552597
@@ -459,7 +459,8 @@
     }
 
     // make sure we don't bust up X11
-    size = KMAX(0, KMIN(255, size));
+    // Also, Qt does not support sizing a QFont to zero.
+    size = kMax(1, kMin(255, size));
 
 //       qDebug("setting font to %s, italic=%d, weight=%d, size=%d", fontDef.family.latin1(), fontDef.italic,
 //    	   fontDef.weight, size );
@@ -475,7 +476,7 @@
 
     if ( fontDef.smallCaps ) {
 	scFont = new QFont( f );
-	scFont->setPixelSize( f.pixelSize()*7/10 );
+	scFont->setPixelSize( kMax(1, f.pixelSize()*7/10) );
     }
 }