Bug 431520. Don't do first-line styling on fieldsets, because it confuses the legend code, and it's not clear what it should even do. r+sr=dbaron
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 28 Jul 2008 23:08:57 -0700
changeset 16270 5c485aa25f16ae1835214362ac4222065e1477d2
parent 16269 034c981d323f1994806c05da00b242fa35e15760
child 16271 27ebd6f0ae2568a55036b6953f20c9f9bf046566
push id885
push userbzbarsky@mozilla.com
push dateTue, 29 Jul 2008 06:10:26 +0000
treeherdermozilla-central@27ebd6f0ae25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs431520
milestone1.9.1a2pre
Bug 431520. Don't do first-line styling on fieldsets, because it confuses the legend code, and it's not clear what it should even do. r+sr=dbaron
layout/base/nsCSSFrameConstructor.cpp
layout/reftests/bugs/431520-1-ref.html
layout/reftests/bugs/431520-1.html
layout/reftests/bugs/reftest.list
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -5309,17 +5309,18 @@ nsCSSFrameConstructor::ConstructHTMLFram
                                           nsIFrame*                aParentFrame,
                                           nsIAtom*                 aTag,
                                           PRInt32                  aNameSpaceID,
                                           nsStyleContext*          aStyleContext,
                                           nsFrameItems&            aFrameItems,
                                           PRBool                   aHasPseudoParent)
 {
   // Ignore the tag if it's not HTML content and if it doesn't extend (via XBL)
-  // a valid HTML namespace.
+  // a valid HTML namespace.  This check must match the one in
+  // ShouldHaveFirstLineStyle.
   if (!aContent->IsNodeOfType(nsINode::eHTML) &&
       aNameSpaceID != kNameSpaceID_XHTML) {
     return NS_OK;
   }
 
   PRBool    frameHasBeenInitialized = PR_FALSE;
   nsIFrame* newFrame = nsnull;  // the frame we construct
   PRBool    addToHashTable = PR_TRUE;
@@ -11148,19 +11149,30 @@ nsCSSFrameConstructor::HasFirstLetterSty
 
   return (aBlockFrame->GetStateBits() & NS_BLOCK_HAS_FIRST_LETTER_STYLE) != 0;
 }
 
 PRBool
 nsCSSFrameConstructor::ShouldHaveFirstLineStyle(nsIContent* aContent,
                                                 nsStyleContext* aStyleContext)
 {
-  return nsLayoutUtils::HasPseudoStyle(aContent, aStyleContext,
-                                       nsCSSPseudoElements::firstLine,
-                                       mPresShell->GetPresContext());
+  PRBool hasFirstLine =
+    nsLayoutUtils::HasPseudoStyle(aContent, aStyleContext,
+                                  nsCSSPseudoElements::firstLine,
+                                  mPresShell->GetPresContext());
+  if (hasFirstLine) {
+    // But disable for fieldsets
+    PRInt32 namespaceID;
+    nsIAtom* tag = mDocument->BindingManager()->ResolveTag(aContent,
+                                                           &namespaceID);
+    // This check must match the one in ConstructHTMLFrame.
+    hasFirstLine = tag != nsGkAtoms::fieldset ||
+      (namespaceID != kNameSpaceID_XHTML &&
+       !aContent->IsNodeOfType(nsINode::eHTML));
+  }
 }
 
 void
 nsCSSFrameConstructor::ShouldHaveSpecialBlockStyle(nsIContent* aContent,
                                                    nsStyleContext* aStyleContext,
                                                    PRBool* aHaveFirstLetterStyle,
                                                    PRBool* aHaveFirstLineStyle)
 {
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/431520-1-ref.html
@@ -0,0 +1,7 @@
+<html>
+<head>
+<title>Testcase, bug 431520</title>
+<body>
+<fieldset><legend>Legend</legend>contents of fieldset</fieldset>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/431520-1.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+<title>Testcase, bug 431520</title>
+<style type="text/css">
+fieldset:first-line { color: red }
+</style>
+<body>
+<fieldset><legend>Legend</legend>contents of fieldset</fieldset>
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -843,16 +843,17 @@ fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 
 == 428521-1a.html 428521-1-ref.html
 == 428521-1b.html 428521-1-ref.html
 == 428521-1c.html 428521-1-ref.html
 random == 429849-1.html 429849-1-ref.html # bug 432288
 == 430412-1.html 430412-1-ref.html
 == 430813-1.html 430813-1-ref.html
 == 430813-2.html 430813-2-ref.html
 == 430813-3.html 430813-3-ref.html
+== 431520-1.html 431520-1-ref.html
 == 440112.html 440112-ref.html
 == 433640-1.html 433640-1-ref.html
 == 433700.html 433700-ref.html
 == 436356-1.html 436356-1-ref.html
 == 436356-2.html 436356-2-ref.html
 == 438981-1.xhtml about:blank
 == 439004-1.html 439004-1-ref.html
 == 439910.html 439910-ref.html