Implement the HTML <main> element.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jan 2013 17:10:34 +0000 (17:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jan 2013 17:10:34 +0000 (17:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=103172

Patch by Michael[tm] Smith <mike@w3.org> on 2013-01-21
Reviewed by Chris Fleizach.

Source/WebCore:

Authored by Steve Faulkner <faulkner.steve@gmail.com>

<main> should behave the same as <nav>, <section>, and <article>, and <aside>.
<main> should expose AXLandmarkMain correctly on each platform.

Tests: fast/html/main-element.html
       platform/chromium/accessibility/main-element.html
       platform/mac/accessibility/main-element.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::determineAccessibilityRole):
* css/html.css:
(article, aside, footer, header, hgroup, main, nav, section):
* editing/FormatBlockCommand.cpp:
(WebCore::isElementForFormatBlock):
* html/HTMLTagNames.in:
* html/parser/HTMLStackItem.h:
(WebCore::HTMLStackItem::isSpecialNode):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::processStartTagForInBody):
(WebCore::HTMLTreeBuilder::processEndTagForInBody):

LayoutTests:

<main> should behave the same as <nav>, <section>, <article>, and <aside>.
<main> has no specific parsing rules.
<main> should expose AXLandmarkMain correctly for each platform.

* editing/execCommand/query-format-block-expected.txt:
* editing/execCommand/remove-format-elements-expected.txt:
* editing/execCommand/remove-format-elements.html:
* editing/execCommand/script-tests/query-format-block.js:
* fast/block/child-not-removed-from-parent-lineboxes-crash.html:
* fast/dom/click-method-on-html-element-expected.txt:
* fast/dom/click-method-on-html-element.html:
* fast/dom/wrapper-classes-expected.txt:
* fast/dom/wrapper-classes.html:
* fast/forms/access-key-for-all-elements-expected.txt:
* fast/forms/access-key-for-all-elements.html:
* fast/html/main-element-expected.txt: Added.
* fast/html/main-element.html: Added.
* fast/html/script-tests/main-element.js: Added.
(getWeight):
* platform/chromium/accessibility/main-element-expected.txt: Added.
* platform/chromium/accessibility/main-element.html: Added.
* platform/chromium/fast/dom/wrapper-classes-expected.txt:
* platform/mac/accessibility/main-element-expected.txt: Added.
* platform/mac/accessibility/main-element.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140341 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/execCommand/query-format-block-expected.txt
LayoutTests/editing/execCommand/remove-format-elements-expected.txt
LayoutTests/editing/execCommand/remove-format-elements.html
LayoutTests/editing/execCommand/script-tests/query-format-block.js
LayoutTests/fast/block/child-not-removed-from-parent-lineboxes-crash.html
LayoutTests/fast/dom/click-method-on-html-element-expected.txt
LayoutTests/fast/dom/click-method-on-html-element.html
LayoutTests/fast/dom/wrapper-classes-expected.txt
LayoutTests/fast/dom/wrapper-classes.html
LayoutTests/fast/forms/access-key-for-all-elements-expected.txt
LayoutTests/fast/forms/access-key-for-all-elements.html
LayoutTests/fast/html/main-element-expected.txt [new file with mode: 0644]
LayoutTests/fast/html/main-element.html [new file with mode: 0644]
LayoutTests/fast/html/script-tests/main-element.js [new file with mode: 0644]
LayoutTests/platform/chromium/accessibility/main-element-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/accessibility/main-element.html [new file with mode: 0644]
LayoutTests/platform/chromium/fast/dom/wrapper-classes-expected.txt
LayoutTests/platform/mac/accessibility/main-element-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/main-element.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/css/html.css
Source/WebCore/editing/FormatBlockCommand.cpp
Source/WebCore/html/HTMLTagNames.in
Source/WebCore/html/parser/HTMLStackItem.h
Source/WebCore/html/parser/HTMLTreeBuilder.cpp

index 8d0384a..3ca4e12 100644 (file)
@@ -1,3 +1,35 @@
+2013-01-21  Michael[tm] Smith  <mike@w3.org>
+
+        Implement the HTML <main> element.
+        https://bugs.webkit.org/show_bug.cgi?id=103172
+
+        Reviewed by Chris Fleizach.
+
+        <main> should behave the same as <nav>, <section>, <article>, and <aside>.
+        <main> has no specific parsing rules.
+        <main> should expose AXLandmarkMain correctly for each platform.
+
+        * editing/execCommand/query-format-block-expected.txt:
+        * editing/execCommand/remove-format-elements-expected.txt:
+        * editing/execCommand/remove-format-elements.html:
+        * editing/execCommand/script-tests/query-format-block.js:
+        * fast/block/child-not-removed-from-parent-lineboxes-crash.html:
+        * fast/dom/click-method-on-html-element-expected.txt:
+        * fast/dom/click-method-on-html-element.html:
+        * fast/dom/wrapper-classes-expected.txt:
+        * fast/dom/wrapper-classes.html:
+        * fast/forms/access-key-for-all-elements-expected.txt:
+        * fast/forms/access-key-for-all-elements.html:
+        * fast/html/main-element-expected.txt: Added.
+        * fast/html/main-element.html: Added.
+        * fast/html/script-tests/main-element.js: Added.
+        (getWeight):
+        * platform/chromium/accessibility/main-element-expected.txt: Added.
+        * platform/chromium/accessibility/main-element.html: Added.
+        * platform/chromium/fast/dom/wrapper-classes-expected.txt:
+        * platform/mac/accessibility/main-element-expected.txt: Added.
+        * platform/mac/accessibility/main-element.html: Added.
+
 2013-01-21  Joanmarie Diggs  <jdiggs@igalia.com>
 
         Crash in AccessibilityTableCell::parentTable()
index 450850a..121a26c 100644 (file)
@@ -69,6 +69,7 @@ PASS queryCommand('formatBlock') returned "h5" selecting first position of "<h5>
 PASS queryCommand('formatBlock') returned "h6" selecting first position of "<h6>hello</h6>"
 PASS queryCommand('formatBlock') returned "header" selecting first position of "<header>hello</header>"
 PASS queryCommand('formatBlock') returned "hgroup" selecting first position of "<hgroup>hello</hgroup>"
+PASS queryCommand('formatBlock') returned "main" selecting first position of "<main>hello</main>"
 PASS queryCommand('formatBlock') returned "nav" selecting first position of "<nav>hello</nav>"
 PASS queryCommand('formatBlock') returned "p" selecting first position of "<p>hello</p>"
 PASS queryCommand('formatBlock') returned "pre" selecting first position of "<pre>hello</pre>"
index 745fbdd..e2afc97 100644 (file)
@@ -1,6 +1,6 @@
 Removed
 acronym, b, bdo, big, cite, code, dfn, em, font, i, ins, kbd, nobr, q, s, samp, small, strike, strong, sub, sup, tt, u, var
 Preserved
-noscript, a, abbr, address, applet, area, article, aside, audio, base, basefont, bgsound, blockquote, body, br, button, canvas, caption, center, col, colgroup, command, datagrid, datalist, dcell, dcol, dd, del, details, dir, div, dl, drow, dt, embed, fieldset, figcaption, figure, footer, form, frame, frameset, h1, h2, h3, h4, h5, h6, head, header, hgroup, hr, html, iframe, image, img, input, isindex, keygen, label, layer, legend, li, link, listing, map, mark, marquee, menu, meta, meter, nav, noembed, noframes, nolayer, noscript, object, ol, optgroup, option, p, param, plaintext, pre, progress, rp, rt, ruby, script, section, select, source, span, style, summary, table, tbody, td, textarea, tfoot, th, thead, title, tr, track, ul, video, wbr, xmp
+noscript, a, abbr, address, applet, area, article, aside, audio, base, basefont, bgsound, blockquote, body, br, button, canvas, caption, center, col, colgroup, command, datagrid, datalist, dcell, dcol, dd, del, details, dir, div, dl, drow, dt, embed, fieldset, figcaption, figure, footer, form, frame, frameset, h1, h2, h3, h4, h5, h6, head, header, hgroup, hr, html, iframe, image, img, input, isindex, keygen, label, layer, legend, li, link, listing, main, map, mark, marquee, menu, meta, meter, nav, noembed, noframes, nolayer, noscript, object, ol, optgroup, option, p, param, plaintext, pre, progress, rp, rt, ruby, script, section, select, source, span, style, summary, table, tbody, td, textarea, tfoot, th, thead, title, tr, track, ul, video, wbr, xmp
 Exceptions
 
index 6ffc188..f82f069 100644 (file)
@@ -22,7 +22,7 @@ var elements = [ "noscript", "a", "abbr", "acronym", "address", "applet", "area"
 "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset",
 "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html",
 "i", "iframe", "image", "img", "input", "ins", "isindex", "kbd", "keygen", "label", "layer", "legend", ["ul", "li"], "link", "listing",
-"map", "mark", "marquee", "menu", "meta", "meter", "nav", "nobr", "noembed", "noframes", "nolayer", "noscript",
+"main", "map", "mark", "marquee", "menu", "meta", "meter", "nav", "nobr", "noembed", "noframes", "nolayer", "noscript",
 "object", "ol", "optgroup", "option", "p", "param", "plaintext", "pre", "progress", "q", "rp", "rt", "ruby",
 "s", "samp", "script", "section", "select", "small", "source", "span", "strike", "strong", "style", "sub", "summary", "sup",
 "table", ["table", "tbody"], ["table", "td"], "textarea", ["table", "tfoot"], ["table", "th"], ["table", "thead"],
index 5adab66..62edf65 100644 (file)
@@ -101,6 +101,7 @@ queryFormatBlock(selectFirstPosition, '<h5>hello</h5>', 'h5');
 queryFormatBlock(selectFirstPosition, '<h6>hello</h6>', 'h6');
 queryFormatBlock(selectFirstPosition, '<header>hello</header>', 'header');
 queryFormatBlock(selectFirstPosition, '<hgroup>hello</hgroup>', 'hgroup');
+queryFormatBlock(selectFirstPosition, '<main>hello</main>', 'main');
 queryFormatBlock(selectFirstPosition, '<nav>hello</nav>', 'nav');
 queryFormatBlock(selectFirstPosition, '<p>hello</p>', 'p');
 queryFormatBlock(selectFirstPosition, '<pre>hello</pre>', 'pre');
index c548e6b..b4e7453 100644 (file)
@@ -5,7 +5,7 @@
 if (window.testRunner)
     testRunner.dumpAsText();
 
-var tags = ['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdo', 'bgsound', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'datagrid', 'datalist', 'dcell', 'dcol', 'drow', 'dd', 'del', 'details', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'child', 'image', 'img', 'input', 'ins', 'isindex', 'kbd', 'keygen', 'label', 'layer', 'legend', 'li', 'link', 'listing', 'map', 'mark', 'marquee', 'menu', 'meta', 'meter', 'nav', 'nobr', 'noembed', 'noframes', 'nolayer', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'plaintext', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr', 'xmp', 'noscript', 'noscript', 'math', 'mfrac', 'mfenced', 'msubsup', 'mrow', 'mover', 'munder', 'munderover', 'msqrt', 'mroot', 'mi', 'mn', 'mo', 'mtext', 'msub', 'msup', 'ms', 'mglyph', 'malignmark', 'annotation-xml', 'a', 'access', 'anchor', 'br', 'card', 'do', 'fieldset', 'go', 'head', 'img', 'input', 'insertedLegend', 'meta', 'noop', 'onevent', 'optgroup', 'option', 'p', 'postfield', 'prev', 'refresh', 'select', 'setvar', 'table', 'td', 'template', 'timer', 'tr', 'a', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform', 'set', 'circle', 'clipPath', 'color_profile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter', 'font', 'font_face', 'font_face_format', 'font_face_name', 'font_face_src', 'font_face_uri', 'foreignObject', 'g', 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing_glyph', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'script', 'stop', 'style', 'svg', 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern']
+var tags = ['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdo', 'bgsound', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'datagrid', 'datalist', 'dcell', 'dcol', 'drow', 'dd', 'del', 'details', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'child', 'image', 'img', 'input', 'ins', 'isindex', 'kbd', 'keygen', 'label', 'layer', 'legend', 'li', 'link', 'listing', 'main', 'map', 'mark', 'marquee', 'menu', 'meta', 'meter', 'nav', 'nobr', 'noembed', 'noframes', 'nolayer', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'plaintext', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr', 'xmp', 'noscript', 'noscript', 'math', 'mfrac', 'mfenced', 'msubsup', 'mrow', 'mover', 'munder', 'munderover', 'msqrt', 'mroot', 'mi', 'mn', 'mo', 'mtext', 'msub', 'msup', 'ms', 'mglyph', 'malignmark', 'annotation-xml', 'a', 'access', 'anchor', 'br', 'card', 'do', 'fieldset', 'go', 'head', 'img', 'input', 'insertedLegend', 'meta', 'noop', 'onevent', 'optgroup', 'option', 'p', 'postfield', 'prev', 'refresh', 'select', 'setvar', 'table', 'td', 'template', 'timer', 'tr', 'a', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform', 'set', 'circle', 'clipPath', 'color_profile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter', 'font', 'font_face', 'font_face_format', 'font_face_name', 'font_face_src', 'font_face_uri', 'foreignObject', 'g', 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing_glyph', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'script', 'stop', 'style', 'svg', 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern']
 
 for (i = 0; i < tags.length; i++)
 {
index 3b25ca5..23a334e 100644 (file)
@@ -71,6 +71,7 @@ Pass: Click event handler called for: legend
 Pass: Click event handler called for: li
 Pass: Click event handler called for: link
 Pass: Click event handler called for: listing
+Pass: Click event handler called for: main
 Pass: Click event handler called for: map
 Pass: Click event handler called for: mark
 Pass: Click event handler called for: marquee
index 0f282aa..047817a 100644 (file)
@@ -26,7 +26,7 @@ function runTests(tagName) {
 var tagNames = ["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdo","bgsound","big","blockquote",
     "body","br","button","canvas","caption","center","cite","code","col","colgroup","command","datalist","dd","del","details","dfn","dir","div","dl","dt",
     "em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html",
-    "i","iframe","img","input","ins","isindex","kbd","keygen","label","layer","legend","li","link","listing","map","mark","marquee","menu","meta","meter","nav",
+    "i","iframe","img","input","ins","isindex","kbd","keygen","label","layer","legend","li","link","listing","main","map","mark","marquee","menu","meta","meter","nav",
     "nobr","noembed","noframes","nolayer","noscript","object","ol","optgroup","option","output","p","param","plaintext","pre","progress","q","rp","rt","ruby","s",
     "samp","script","section","select","small","source","span","strike","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead",
     "title","tr","track","tt","u","ul","var","video","wbr","xmp"];
index 8cee24e..d2db4e2 100644 (file)
@@ -341,6 +341,9 @@ PASS tagJSWrapperConstructorClass('link') is 'HTMLLinkElementConstructor'
 PASS tagJSWrapperClass('listing') is 'HTMLPreElement'
 PASS tagJSWrapperPrototypeClass('listing') is 'HTMLPreElementPrototype'
 PASS tagJSWrapperConstructorClass('listing') is 'HTMLPreElementConstructor'
+PASS tagJSWrapperClass('main') is 'HTMLElement'
+PASS tagJSWrapperPrototypeClass('main') is 'HTMLElementPrototype'
+PASS tagJSWrapperConstructorClass('main') is 'HTMLElementConstructor'
 PASS tagJSWrapperClass('map') is 'HTMLMapElement'
 PASS tagJSWrapperPrototypeClass('map') is 'HTMLMapElementPrototype'
 PASS tagJSWrapperConstructorClass('map') is 'HTMLMapElementConstructor'
index 4da0309..b619fd4 100644 (file)
@@ -212,6 +212,7 @@ function runTest()
     testTag("li", "HTMLLIElement");
     testTag("link", "HTMLLinkElement");
     testTag("listing", "HTMLPreElement");
+    testTag("main", "HTMLElement");
     testTag("map", "HTMLMapElement");
     testTag("marquee", "HTMLMarqueeElement");
     testTag("menu", "HTMLMenuElement");
index e4b8856..c945384 100644 (file)
@@ -338,6 +338,11 @@ PASS testElement.accessKey is defined.
 PASS testElement.accessKey ='k'; testElement.accessKey == 'k' is true
 PASS pressKey(testElement.accessKey);[clicked, focused] is [true, false]
 
+Check for MAIN tag
+PASS testElement.accessKey is defined.
+PASS testElement.accessKey ='k'; testElement.accessKey == 'k' is true
+PASS pressKey(testElement.accessKey);[clicked, focused] is [true, false]
+
 Check for MAP tag
 PASS testElement.accessKey is defined.
 PASS testElement.accessKey ='k'; testElement.accessKey == 'k' is true
index 2353aad..77bb7ec 100644 (file)
@@ -19,7 +19,7 @@ function pressKey(key)
 var tagNames = ["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdo","bgsound","big","blockquote",
     "body","br","canvas","caption","center","cite","code","col","colgroup","command","datalist","dd","del","details","dfn","dir","div","dl","dt",
     "em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html",
-    "i","iframe","img","ins","kbd","keygen","label","layer","li","link","listing","map","mark","marquee","menu","meta","meter","nav",
+    "i","iframe","img","ins","kbd","keygen","label","layer","li","link","listing","main","map","mark","marquee","menu","meta","meter","nav",
     "nobr","noembed","noframes","nolayer","noscript","object","ol","output","p","param","plaintext","pre","progress","q","rp","rt","ruby","s",
     "samp","script","section","small","source","span","strike","strong","style","sub","summary","sup","table","tbody","td","tfoot","th","thead",
     "title","tr","track","tt","u","ul","var","video","wbr","xmp"];
diff --git a/LayoutTests/fast/html/main-element-expected.txt b/LayoutTests/fast/html/main-element-expected.txt
new file mode 100644 (file)
index 0000000..32e3e9f
--- /dev/null
@@ -0,0 +1,20 @@
+Various tests for the main element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+<main> closes <p>:
+PASS main1.parentNode.nodeName == "p" is false
+<p> does not close <main>:
+PASS p1.parentNode.nodeName is "MAIN"
+<main> can be nested inside <main>:
+PASS main3.parentNode.id is "main2"
+Residual style:
+PASS getWeight("main4") is "bold"
+PASS getWeight("span1") is "bold"
+FormatBlock:
+PASS document.getElementById("span2").parentNode.nodeName is "MAIN"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/html/main-element.html b/LayoutTests/fast/html/main-element.html
new file mode 100644 (file)
index 0000000..ec0376f
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/main-element.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/html/script-tests/main-element.js b/LayoutTests/fast/html/script-tests/main-element.js
new file mode 100644 (file)
index 0000000..6e467cf
--- /dev/null
@@ -0,0 +1,41 @@
+description('Various tests for the main element.');
+
+var testParent = document.createElement('div');
+document.body.appendChild(testParent);
+
+debug('&lt;main> closes &lt;p>:');
+testParent.innerHTML = '<p>Test that <main id="main1">an main element</main> closes &lt;p>.</p>';
+var main1 = document.getElementById('main1');
+shouldBeFalse('main1.parentNode.nodeName == "p"');
+
+debug('&lt;p> does not close &lt;main>:');
+testParent.innerHTML = '<main>Test that <p id="p1">a p element</p> does not close an main element.</main>';
+var p1 = document.getElementById('p1');
+shouldBe('p1.parentNode.nodeName', '"MAIN"');
+
+debug('&lt;main> can be nested inside &lt;main>:');
+testParent.innerHTML = '<main id="main2">Test that <main id="main3">an main element</main> can be nested inside another.</main>';
+var main3 = document.getElementById('main3');
+shouldBe('main3.parentNode.id', '"main2"');
+
+debug('Residual style:');
+testParent.innerHTML = '<b><main id="main4">This text should be bold.</main> <span id="span1">This is also bold.</span></b>';
+function getWeight(id) {
+    return document.defaultView.getComputedStyle(document.getElementById(id), null).getPropertyValue('font-weight');
+}
+shouldBe('getWeight("main4")', '"bold"');
+shouldBe('getWeight("span1")', '"bold"');
+document.body.removeChild(testParent);
+
+debug('FormatBlock:');
+var editable = document.createElement('div');
+editable.innerHTML = '[<span id="span2">The text will be a child of &lt;main>.</span>]';
+document.body.appendChild(editable);
+editable.contentEditable = true;
+var selection = window.getSelection();
+selection.selectAllChildren(editable);
+document.execCommand('FormatBlock', false, 'main');
+selection.collapse();
+shouldBe('document.getElementById("span2").parentNode.nodeName', '"MAIN"');
+document.body.removeChild(editable);
+
diff --git a/LayoutTests/platform/chromium/accessibility/main-element-expected.txt b/LayoutTests/platform/chromium/accessibility/main-element-expected.txt
new file mode 100644 (file)
index 0000000..a4c232b
--- /dev/null
@@ -0,0 +1,11 @@
+main
+This tests that the HTML5 main element correctly maps to AXLandmarkMain.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS main.role is 'AXRole: AXLandmarkMain'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/chromium/accessibility/main-element.html b/LayoutTests/platform/chromium/accessibility/main-element.html
new file mode 100644 (file)
index 0000000..46558f9
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<main id="main">main</main>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that the HTML5 main element correctly maps to AXLandmarkMain.");
+
+    if (window.accessibilityController) {
+
+          document.getElementById("body").focus();
+          var body = accessibilityController.focusedElement;
+          var main = accessibilityController.accessibleElementById("main");
+          shouldBe("main.role", "'AXRole: AXLandmarkMain'");
+
+    }
+
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 13eac24..172b902 100644 (file)
@@ -341,6 +341,9 @@ FAIL tagJSWrapperConstructorClass('link') should be HTMLLinkElementConstructor.
 PASS tagJSWrapperClass('listing') is 'HTMLPreElement'
 FAIL tagJSWrapperPrototypeClass('listing') should be HTMLPreElementPrototype. Was Object.
 FAIL tagJSWrapperConstructorClass('listing') should be HTMLPreElementConstructor. Was Function.
+PASS tagJSWrapperClass('main') is 'HTMLElement'
+FAIL tagJSWrapperPrototypeClass('main') should be HTMLElementPrototype. Was Object.
+FAIL tagJSWrapperConstructorClass('main') should be HTMLElementConstructor. Was Function.
 PASS tagJSWrapperClass('map') is 'HTMLMapElement'
 FAIL tagJSWrapperPrototypeClass('map') should be HTMLMapElementPrototype. Was Object.
 FAIL tagJSWrapperConstructorClass('map') should be HTMLMapElementConstructor. Was Function.
diff --git a/LayoutTests/platform/mac/accessibility/main-element-expected.txt b/LayoutTests/platform/mac/accessibility/main-element-expected.txt
new file mode 100644 (file)
index 0000000..1aa1e47
--- /dev/null
@@ -0,0 +1,12 @@
+main
+This tests that the HTML5 main element correctly maps to AXLandmarkMain.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS main.role is 'AXRole: AXGroup'
+PASS main.subrole is 'AXSubrole: AXLandmarkMain'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/main-element.html b/LayoutTests/platform/mac/accessibility/main-element.html
new file mode 100644 (file)
index 0000000..cb94d18
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<main id="main">main</main>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that the HTML5 main element correctly maps to AXLandmarkMain.");
+
+    if (window.accessibilityController) {
+
+          document.getElementById("body").focus();
+          var body = accessibilityController.focusedElement;
+          var main = accessibilityController.accessibleElementById("main");
+          shouldBe("main.role", "'AXRole: AXGroup'");
+          shouldBe("main.subrole", "'AXSubrole: AXLandmarkMain'");
+
+    }
+
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 4d9633b..409ba28 100644 (file)
@@ -1,3 +1,32 @@
+2013-01-21  Michael[tm] Smith  <mike@w3.org>
+
+        Implement the HTML <main> element.
+        https://bugs.webkit.org/show_bug.cgi?id=103172
+
+        Reviewed by Chris Fleizach.
+
+        Authored by Steve Faulkner <faulkner.steve@gmail.com>
+
+        <main> should behave the same as <nav>, <section>, and <article>, and <aside>.
+        <main> should expose AXLandmarkMain correctly on each platform.
+
+        Tests: fast/html/main-element.html
+               platform/chromium/accessibility/main-element.html
+               platform/mac/accessibility/main-element.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
+        * css/html.css:
+        (article, aside, footer, header, hgroup, main, nav, section):
+        * editing/FormatBlockCommand.cpp:
+        (WebCore::isElementForFormatBlock):
+        * html/HTMLTagNames.in:
+        * html/parser/HTMLStackItem.h:
+        (WebCore::HTMLStackItem::isSpecialNode):
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody):
+        (WebCore::HTMLTreeBuilder::processEndTagForInBody):
+
 2013-01-21  Joanmarie Diggs  <jdiggs@igalia.com>
 
         Crash in AccessibilityTableCell::parentTable()
index 32fb3df..6a9eb3f 100644 (file)
@@ -2537,6 +2537,9 @@ AccessibilityRole AccessibilityRenderObject::determineAccessibilityRole()
     if (node && node->hasTagName(articleTag))
         return DocumentArticleRole;
 
+    if (node && node->hasTagName(mainTag))
+        return LandmarkMainRole;
+
     if (node && node->hasTagName(navTag))
         return LandmarkNavigationRole;
 
index 8fdc5bc..1503be8 100644 (file)
@@ -81,7 +81,7 @@ layer {
     display: block
 }
 
-article, aside, footer, header, hgroup, nav, section {
+article, aside, footer, header, hgroup, main, nav, section {
     display: block
 }
 
index 142e36e..7c912d1 100644 (file)
@@ -136,6 +136,7 @@ bool isElementForFormatBlock(const QualifiedName& tagName)
         blockTags.add(h6Tag);
         blockTags.add(headerTag);
         blockTags.add(hgroupTag);
+        blockTags.add(mainTag);
         blockTags.add(navTag);
         blockTags.add(pTag);
         blockTags.add(preTag);
index 4d82ed1..2a796d6 100644 (file)
@@ -80,6 +80,7 @@ legend
 li interfaceName=HTMLLIElement
 link constructorNeedsCreatedByParser
 listing interfaceName=HTMLPreElement
+main interfaceName=HTMLElement
 map
 mark interfaceName=HTMLElement
 marquee
index 0a183bc..8a19cd3 100644 (file)
@@ -168,6 +168,7 @@ public:
             || tagName == HTMLNames::liTag
             || tagName == HTMLNames::linkTag
             || tagName == HTMLNames::listingTag
+            || tagName == HTMLNames::mainTag
             || tagName == HTMLNames::marqueeTag
             || tagName == HTMLNames::menuTag
             || tagName == HTMLNames::metaTag
index bc549ef..5e2062f 100644 (file)
@@ -691,6 +691,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken* token)
         || token->name() == footerTag
         || token->name() == headerTag
         || token->name() == hgroupTag
+        || token->name() == mainTag
         || token->name() == menuTag
         || token->name() == navTag
         || token->name() == olTag
@@ -1816,6 +1817,7 @@ void HTMLTreeBuilder::processEndTagForInBody(AtomicHTMLToken* token)
         || token->name() == headerTag
         || token->name() == hgroupTag
         || token->name() == listingTag
+        || token->name() == mainTag
         || token->name() == menuTag
         || token->name() == navTag
         || token->name() == olTag