Implement the figure element. r=jst+timeless+ehsan (Bug 573356)
authorMs2ger <ms2ger@gmail.com>
Wed, 23 Jun 2010 10:08:56 -0700
changeset 44193 40de8e1a9f13e192ab367fd3202ab23e4fc70ec8
parent 44192 b4149e2c40567006e4ad41e89fb2d22c5961e4c4
child 44194 bb28be604c9565662b0f1efbaa4c389ee9a25303
push idunknown
push userunknown
push dateunknown
reviewersjst
bugs573356
milestone1.9.3a6pre
Implement the figure element. r=jst+timeless+ehsan (Bug 573356)
content/base/src/nsGkAtomList.h
content/html/content/reftests/figure-ref.html
content/html/content/reftests/figure.html
content/html/content/reftests/reftest.list
content/html/content/test/test_bug389797.html
editor/libeditor/base/nsEditPropertyAtomList.h
editor/libeditor/html/nsHTMLEditUtils.cpp
layout/reftests/bugs/476063-4-ref.xhtml
layout/reftests/bugs/476063-4.xhtml
layout/style/html.css
parser/htmlparser/public/nsHTMLTagList.h
parser/htmlparser/src/nsElementTable.cpp
parser/htmlparser/src/nsHTMLTags.cpp
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -363,16 +363,18 @@ GK_ATOM(expr, "expr")
 GK_ATOM(extends, "extends")
 GK_ATOM(extensionElementPrefixes, "extension-element-prefixes")
 GK_ATOM(face, "face")
 GK_ATOM(fallback, "fallback")
 GK_ATOM(_false, "false")
 GK_ATOM(farthest, "farthest")
 GK_ATOM(field, "field")
 GK_ATOM(fieldset, "fieldset")
+GK_ATOM(figcaption, "figcaption")
+GK_ATOM(figure, "figure")
 GK_ATOM(fixed, "fixed")
 GK_ATOM(fixedList, "Fixed-list")
 GK_ATOM(flags, "flags")
 GK_ATOM(flex, "flex")
 GK_ATOM(flexgroup, "flexgroup")
 GK_ATOM(floatList, "Float-list")
 GK_ATOM(floor, "floor")
 GK_ATOM(focus, "focus")
new file mode 100644
--- /dev/null
+++ b/content/html/content/reftests/figure-ref.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<title>The figure element</title>
+<link rel=author title=Ms2ger href=ms2ger@gmail.com>
+<link rel=help href=http://www.whatwg.org/html5/#the-figure-element>
+<style>
+body > div { margin: 1em 40px; }
+</style>
+<div>
+<div>Caption</div>
+Figure
+</div>
new file mode 100644
--- /dev/null
+++ b/content/html/content/reftests/figure.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<title>The figure element</title>
+<link rel=author title=Ms2ger href=ms2ger@gmail.com>
+<link rel=help href=http://www.whatwg.org/html5/#the-figure-element>
+<figure>
+<figcaption>Caption</figcaption>
+Figure
+</figure>
--- a/content/html/content/reftests/reftest.list
+++ b/content/html/content/reftests/reftest.list
@@ -7,8 +7,9 @@
 != 468263-1d.html about:blank
 == 468263-2.html 468263-2-ref.html
 == 468263-2.html 468263-2-alternate-ref.html
 == 484200-1.html 484200-1-ref.html
 == 485377.html 485377-ref.html
 == 557840.html 557840-ref.html
 == 560059-video-dimensions.html 560059-video-dimensions-ref.html
 == href-attr-change-restyles.html href-attr-change-restyles-ref.html
+== figure.html figure-ref.html
--- a/content/html/content/test/test_bug389797.html
+++ b/content/html/content/test/test_bug389797.html
@@ -142,16 +142,18 @@ HTML_TAG("del", "Del", [ "nsIDOMHTMLModE
 HTML_TAG("dfn", "Span");
 HTML_TAG("dir", "Directory");
 HTML_TAG("div", "Div");
 HTML_TAG("dl", "DList");
 HTML_TAG("dt", "Span");
 HTML_TAG("em", "Span");
 HTML_TAG("embed", "Embed", [ "nsIDOMGetSVGDocument" ], objectIfaces);
 HTML_TAG("fieldset", "FieldSet");
+HTML_TAG("figcaption", "") // HTMLElement
+HTML_TAG("figure", "") // HTMLElement
 HTML_TAG("font", "Font");
 HTML_TAG("footer", "") // HTMLElement
 HTML_TAG("form", "Form", [], [ "nsIWebProgressListener" ]);
 HTML_TAG("frame", "Frame", [], [ "nsIFrameLoaderOwner" ]);
 HTML_TAG("frameset", "FrameSet");
 HTML_TAG("h1", "Heading");
 HTML_TAG("h2", "Heading");
 HTML_TAG("h3", "Heading");
--- a/editor/libeditor/base/nsEditPropertyAtomList.h
+++ b/editor/libeditor/base/nsEditPropertyAtomList.h
@@ -118,16 +118,18 @@ EDITOR_ATOM(cssZIndex, "z-index")
 EDITOR_ATOM(dd, "dd")
 EDITOR_ATOM(dfn, "dfn")
 EDITOR_ATOM(div, "div")
 EDITOR_ATOM(dl, "dl")
 EDITOR_ATOM(dt, "dt")
 EDITOR_ATOM(em, "em")
 EDITOR_ATOM(face, "face")
 EDITOR_ATOM(fieldset, "fieldset")
+EDITOR_ATOM(figcaption, "figcaption")
+EDITOR_ATOM(figure, "figure")
 EDITOR_ATOM(font, "font")
 EDITOR_ATOM(footer, "footer")
 EDITOR_ATOM(form, "form")
 EDITOR_ATOM(h1, "h1")
 EDITOR_ATOM(h2, "h2")
 EDITOR_ATOM(h3, "h3")
 EDITOR_ATOM(h4, "h4")
 EDITOR_ATOM(h5, "h5")
--- a/editor/libeditor/html/nsHTMLEditUtils.cpp
+++ b/editor/libeditor/html/nsHTMLEditUtils.cpp
@@ -485,19 +485,19 @@ nsHTMLEditUtils::SupportsAlignAttr(nsIDO
 // a, applet, basefont, bdo, br, font, iframe, img, map, object, output, q,
 // script, span, sub, sup
 #define GROUP_SPECIAL          (1 << 5)
 
 // button, form, input, label, select, textarea
 #define GROUP_FORMCONTROL      (1 << 6)
 
 // address, applet, article, aside, blockquote, button, center, del, dir, div,
-// dl, fieldset, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr,
-// iframe, ins, isindex, map, menu, nav, noframes, noscript, object, ol, p, pre,
-// table, section, ul
+// dl, fieldset, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup,
+// hr, iframe, ins, isindex, map, menu, nav, noframes, noscript, object, ol, p,
+// pre, table, section, ul
 #define GROUP_BLOCK            (1 << 7)
 
 // frame, frameset
 #define GROUP_FRAME            (1 << 8)
 
 // col, tbody
 #define GROUP_TABLE_CONTENT    (1 << 9)
 
@@ -536,16 +536,19 @@ nsHTMLEditUtils::SupportsAlignAttr(nsIDO
 
 // XXX This is because the editor does sublists illegally. 
 // ol, ul
 #define GROUP_OL_UL            (1 << 21)
 
 // h1, h2, h3, h4, h5, h6
 #define GROUP_HEADING          (1 << 22)
 
+// figcaption
+#define GROUP_FIGCAPTION       (1 << 23)
+
 #define GROUP_INLINE_ELEMENT \
   (GROUP_FONTSTYLE | GROUP_PHRASE | GROUP_SPECIAL | GROUP_FORMCONTROL | \
    GROUP_LEAF)
 
 #define GROUP_FLOW_ELEMENT (GROUP_INLINE_ELEMENT | GROUP_BLOCK)
 
 struct nsElementInfo
 {
@@ -605,16 +608,19 @@ static const nsElementInfo kElements[eHT
   ELEM(dfn, PR_TRUE, PR_TRUE, GROUP_PHRASE, GROUP_INLINE_ELEMENT),
   ELEM(dir, PR_TRUE, PR_FALSE, GROUP_BLOCK, GROUP_LI),
   ELEM(div, PR_TRUE, PR_TRUE, GROUP_BLOCK, GROUP_FLOW_ELEMENT),
   ELEM(dl, PR_TRUE, PR_FALSE, GROUP_BLOCK, GROUP_DL_CONTENT),
   ELEM(dt, PR_TRUE, PR_TRUE, GROUP_DL_CONTENT, GROUP_INLINE_ELEMENT),
   ELEM(em, PR_TRUE, PR_TRUE, GROUP_PHRASE, GROUP_INLINE_ELEMENT),
   ELEM(embed, PR_FALSE, PR_FALSE, GROUP_NONE, GROUP_NONE),
   ELEM(fieldset, PR_TRUE, PR_TRUE, GROUP_BLOCK, GROUP_FLOW_ELEMENT),
+  ELEM(figcaption, PR_TRUE, PR_FALSE, GROUP_FIGCAPTION, GROUP_FLOW_ELEMENT),
+  ELEM(figure, PR_TRUE, PR_TRUE, GROUP_BLOCK,
+       GROUP_FLOW_ELEMENT | GROUP_FIGCAPTION),
   ELEM(font, PR_TRUE, PR_TRUE, GROUP_SPECIAL, GROUP_INLINE_ELEMENT),
   ELEM(footer, PR_TRUE, PR_TRUE, GROUP_BLOCK, GROUP_FLOW_ELEMENT),
   ELEM(form, PR_TRUE, PR_TRUE, GROUP_BLOCK, GROUP_FLOW_ELEMENT),
   ELEM(frame, PR_FALSE, PR_FALSE, GROUP_FRAME, GROUP_NONE),
   ELEM(frameset, PR_TRUE, PR_TRUE, GROUP_FRAME, GROUP_FRAME),
   ELEM(h1, PR_TRUE, PR_FALSE, GROUP_BLOCK | GROUP_HEADING,
        GROUP_INLINE_ELEMENT),
   ELEM(h2, PR_TRUE, PR_FALSE, GROUP_BLOCK | GROUP_HEADING,
--- a/layout/reftests/bugs/476063-4-ref.xhtml
+++ b/layout/reftests/bugs/476063-4-ref.xhtml
@@ -2,13 +2,13 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 	<title>Test that legend is display:block by default when outside of fieldset (Bug 476063)</title>
 </head>
 <body>
 
 <div>
   <div>The legend</div>
-  The rest of the figure.
+  The rest of the div.
 </div>
 
 </body>
 </html>
--- a/layout/reftests/bugs/476063-4.xhtml
+++ b/layout/reftests/bugs/476063-4.xhtml
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 	<title>Test that legend is display:block by default when outside of fieldset (Bug 476063)</title>
 </head>
 <body>
 
-<figure>
+<div>
   <legend>The legend</legend>
-  The rest of the figure.
-</figure>
+  The rest of the div.
+</div>
 
 </body>
 </html>
--- a/layout/style/html.css
+++ b/layout/style/html.css
@@ -112,25 +112,26 @@ xmp {
   unicode-bidi: embed;
 }
 
 
 /* blocks */
 
 article,
 aside,
+div,
+dt,
+figcaption,
 footer,
+form,
 header,
 hgroup,
 html,
-div,
+isindex,
 map,
-dt,
-isindex,
-form,
 nav,
 section {
   display: block;
 }
 
 body {
   display: block;
   margin: 8px;
@@ -141,17 +142,17 @@ p, dl, multicol {
   margin: 1em 0;
 }
 
 dd {
   display: block;
   -moz-margin-start: 40px;
 }
 
-blockquote {
+blockquote, figure {
   display: block;
   margin: 1em 40px;
 }
 
 address {
   display: block;
   font-style: italic;
 }
--- a/parser/htmlparser/public/nsHTMLTagList.h
+++ b/parser/htmlparser/public/nsHTMLTagList.h
@@ -38,34 +38,36 @@
 /******
 
   This file contains the list of all HTML tags 
   See nsHTMLTags.h for access to the enum values for tags
 
   It is designed to be used as inline input to nsHTMLTags.cpp and
   nsHTMLContentSink *only* through the magic of C preprocessing.
 
-  All entires must be enclosed in the macro HTML_TAG which will have cruel
+  All entries must be enclosed in the macro HTML_TAG which will have cruel
   and unusual things done to it
 
   It is recommended (but not strictly necessary) to keep all entries
   in alphabetical order
 
   The first argument to HTML_TAG is both the enum identifier of the
   property and the string value. The second argument is the "creator"
   method of the form NS_New$TAGNAMEElement, that will be used by
   nsHTMLContentSink.cpp to create a content object for a tag of that
   type. Use NOTUSED, if the particular tag has a non-standard creator.
 
   The HTML_OTHER macro is for values in the nsHTMLTag enum that are
   not strictly tags.
 
   Entries *must* use only lowercase characters.
 
-  ** Break these invarient and bad things will happen. **    
+  Don't forget to update /editor/libeditor/html/nsHTMLEditUtils.cpp as well.
+
+  ** Break these invariants and bad things will happen. **
 
  ******/
 HTML_TAG(a, Anchor)
 HTML_TAG(abbr, Span)
 HTML_TAG(acronym, Span)
 HTML_TAG(address, Span)
 HTML_TAG(applet, SharedObject)
 HTML_TAG(area, Area)
@@ -97,16 +99,18 @@ HTML_TAG(del, Mod)
 HTML_TAG(dfn, Span)
 HTML_TAG(dir, Shared)
 HTML_TAG(div, Div)
 HTML_TAG(dl, SharedList)
 HTML_TAG(dt, Span)
 HTML_TAG(em, Span)
 HTML_TAG(embed, SharedObject)
 HTML_TAG(fieldset, FieldSet)
+HTML_TAG(figcaption, ) // HTMLElement instance
+HTML_TAG(figure, ) // HTMLElement instance
 HTML_TAG(font, Font)
 HTML_TAG(footer, ) // HTMLElement instance
 HTML_TAG(form, Form)
 HTML_TAG(frame, Frame)
 HTML_TAG(frameset, FrameSet)
 HTML_TAG(h1, Heading)
 HTML_TAG(h2, Heading)
 HTML_TAG(h3, Heading)
--- a/parser/htmlparser/src/nsElementTable.cpp
+++ b/parser/htmlparser/src/nsElementTable.cpp
@@ -527,16 +527,34 @@ const nsHTMLElement gHTMLElements[] = {
     /*requiredAncestor*/                eHTMLTag_unknown,eHTMLTag_unknown,
     /*rootnodes,endrootnodes*/          &gRootTags,&gRootTags,
     /*autoclose starttags and endtags*/ 0,0,0,0,
     /*parent,incl,exclgroups*/          kBlock, (kSelf|kFlowEntity), kNone,
     /*special props, prop-range*/       kNoPropagate,kDefaultPropRange,
     /*special parents,kids*/            0,&gFieldsetKids,
   },
   {
+    /*tag*/                             eHTMLTag_figcaption,
+    /*req-parent excl-parent*/          eHTMLTag_unknown,eHTMLTag_unknown,
+    /*rootnodes,endrootnodes*/          &gRootTags,&gRootTags,
+    /*autoclose starttags and endtags*/ 0,0,0,0,
+    /*parent,incl,exclgroups*/          kPhrase, (kSelf|kInlineEntity), kNone,
+    /*special props, prop-range*/       0,kDefaultPropRange,
+    /*special parents,kids*/            0,0,
+  },
+  {
+    /*tag*/                             eHTMLTag_figure,
+    /*req-parent excl-parent*/          eHTMLTag_unknown,eHTMLTag_unknown,
+    /*rootnodes,endrootnodes*/          &gRootTags,&gRootTags,
+    /*autoclose starttags and endtags*/ 0,0,0,0,
+    /*parent,incl,exclgroups*/          kBlock, (kSelf|kFlowEntity), kNone,
+    /*special props, prop-range*/       0,kDefaultPropRange,
+    /*special parents,kids*/            0,0,
+  },
+  {
     /*tag*/                             eHTMLTag_font,
     /*req-parent excl-parent*/          eHTMLTag_unknown,eHTMLTag_unknown,
     /*rootnodes,endrootnodes*/          &gRootTags,&gRootTags,
     /*autoclose starttags and endtags*/ 0,0,0,0,
     /*parent,incl,exclgroups*/          kFontStyle, (kSelf|kInlineEntity), kNone,
     /*special props, prop-range*/       0, kDefaultPropRange,
     /*special parents,kids*/            0,&gFontKids,
   },
--- a/parser/htmlparser/src/nsHTMLTags.cpp
+++ b/parser/htmlparser/src/nsHTMLTags.cpp
@@ -118,16 +118,20 @@ static const PRUnichar sHTMLTagUnicodeNa
 static const PRUnichar sHTMLTagUnicodeName_dt[] =
   {'d', 't', '\0'};
 static const PRUnichar sHTMLTagUnicodeName_em[] =
   {'e', 'm', '\0'};
 static const PRUnichar sHTMLTagUnicodeName_embed[] =
   {'e', 'm', 'b', 'e', 'd', '\0'};
 static const PRUnichar sHTMLTagUnicodeName_fieldset[] =
   {'f', 'i', 'e', 'l', 'd', 's', 'e', 't', '\0'};
+static const PRUnichar sHTMLTagUnicodeName_figcaption[] =
+  {'f', 'i', 'g', 'c', 'a', 'p', 't', 'i', 'o', 'n', '\0'};
+static const PRUnichar sHTMLTagUnicodeName_figure[] =
+  {'f', 'i', 'g', 'u', 'r', 'e', '\0'};
 static const PRUnichar sHTMLTagUnicodeName_font[] =
   {'f', 'o', 'n', 't', '\0'};
 static const PRUnichar sHTMLTagUnicodeName_footer[] =
   {'f', 'o', 'o', 't', 'e', 'r', '\0'};
 static const PRUnichar sHTMLTagUnicodeName_form[] =
   {'f', 'o', 'r', 'm', '\0'};
 static const PRUnichar sHTMLTagUnicodeName_frame[] =
   {'f', 'r', 'a', 'm', 'e', '\0'};