<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160631] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160631">160631</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2013-12-15 22:53:38 -0800 (Sun, 15 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add support for maction@toggle
https://bugs.webkit.org/show_bug.cgi?id=120059
Patch by Frédéric Wang <fred.wang@free.fr> on 2013-12-15
Reviewed by Chris Fleizach.
Source/WebCore:
Test: mathml/presentation/maction-toggle.html
* mathml/MathMLSelectElement.cpp:
(WebCore::MathMLSelectElement::getSelectedChildAndIndex):
(WebCore::MathMLSelectElement::updateSelectedChild):
(WebCore::MathMLSelectElement::defaultEventHandler):
(WebCore::MathMLSelectElement::willRespondToMouseClickEvents):
(WebCore::MathMLSelectElement::toggle):
* mathml/MathMLSelectElement.h:
LayoutTests:
* mathml/presentation/maction-toggle-expected.html: Added.
* mathml/presentation/maction-toggle.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLSelectElementcpp">trunk/Source/WebCore/mathml/MathMLSelectElement.cpp</a></li>
<li><a href="#trunkSourceWebCoremathmlMathMLSelectElementh">trunk/Source/WebCore/mathml/MathMLSelectElement.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmathmlpresentationmactiontoggleexpectedhtml">trunk/LayoutTests/mathml/presentation/maction-toggle-expected.html</a></li>
<li><a href="#trunkLayoutTestsmathmlpresentationmactiontogglehtml">trunk/LayoutTests/mathml/presentation/maction-toggle.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (160630 => 160631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2013-12-16 06:39:18 UTC (rev 160630)
+++ trunk/LayoutTests/ChangeLog        2013-12-16 06:53:38 UTC (rev 160631)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2013-12-15 Frédéric Wang <fred.wang@free.fr>
+
+ Add support for maction@toggle
+ https://bugs.webkit.org/show_bug.cgi?id=120059
+
+ Reviewed by Chris Fleizach.
+
+ * mathml/presentation/maction-toggle-expected.html: Added.
+ * mathml/presentation/maction-toggle.html: Added.
+
</ins><span class="cx"> 2013-12-15 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> REGRESSION: 2x regression on Dromaeo DOM query tests
</span></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationmactiontoggleexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/maction-toggle-expected.html (0 => 160631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/maction-toggle-expected.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/maction-toggle-expected.html        2013-12-16 06:53:38 UTC (rev 160631)
</span><span class="lines">@@ -0,0 +1,111 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>maction toggle</title>
+ </head>
+ <body>
+
+ <!-- selection="1" (default) ; three clicks -->
+ <math>
+ <mrow>
+ <mn>4</mn>
+ </mrow>
+ </math>
+
+ <!-- selection="2" ; one click -->
+ <math>
+ <mrow>
+ <mn>3</mn>
+ </mrow>
+ </math>
+
+ <!-- selection="4" (last child) ; one click -->
+ <math>
+ <mrow>
+ <mn>1</mn>
+ </mrow>
+ </math>
+
+ <!-- Other edge cases -->
+ <math>
+ <mrow>
+ </mrow>
+ </math>
+ <math>
+ <mrow>
+ <mn>1</mn>
+ </mrow>
+ </math>
+ <math>
+ <mrow>
+ <mn>2</mn>
+ </mrow>
+ </math>
+ <math>
+ <mrow>
+ <mn>2</mn>
+ </mrow>
+ </math>
+ <math>
+ <mrow>
+ <mn>2</mn>
+ </mrow>
+ </math>
+ <math>
+ <mrow>
+ <mn>1</mn>
+ </mrow>
+ </math>
+ <math>
+ <mrow>
+ <mn>1</mn>
+ </mrow>
+ </math>
+ <math>
+ <mrow>
+ <mn>3</mn>
+ </mrow>
+ </math>
+ <math>
+ <mrow>
+ <mn>2</mn>
+ </mrow>
+ </math>
+ <math>
+ <mrow>
+ <mn>2</mn>
+ </mrow>
+ <mrow>
+ <mn>1</mn>
+ </mrow>
+ <mrow>
+ <mn>2</mn>
+ </mrow>
+ <mrow>
+ <mn>2</mn>
+ </mrow>
+ </math>
+
+ <!-- Nested <maction> elements ; bubble = false -->
+ <math>
+ <mrow>
+ <mn>2</mn>
+ </mrow>
+ </math>
+
+ <!-- Nested <maction> elements ; bubble = true -->
+ <math>
+ <mrow>
+ <mn>4</mn>
+ </mrow>
+ </math>
+
+ <!-- Prevent default -->
+ <math>
+ <mrow>
+ <mn>1</mn>
+ </mrow>
+ </math>
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsmathmlpresentationmactiontogglehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/mathml/presentation/maction-toggle.html (0 => 160631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/mathml/presentation/maction-toggle.html         (rev 0)
+++ trunk/LayoutTests/mathml/presentation/maction-toggle.html        2013-12-16 06:53:38 UTC (rev 160631)
</span><span class="lines">@@ -0,0 +1,202 @@
</span><ins>+<!doctype html>
+<html>
+ <head>
+ <title>maction toggle</title>
+ <script type="text/javascript">
+ function click(id, bubble, preventDefault)
+ {
+ var event = new MouseEvent('click', {bubbles: bubble, cancelable: true});
+ if (preventDefault)
+ event.preventDefault();
+ document.getElementById(id).dispatchEvent(event);
+ }
+ function test()
+ {
+ // selection=1 ; ([1] 2 3 4)
+ // After three clicks, selection=4: (1 2 3 [4])
+ click('m1'); click('m1'); click('m1');
+
+ // selection=2 ; (1 [2] 3 4)
+ // After one click, selection=3: (1 2 [3] 4)
+ click('m2');
+
+ // selection=4 ; (1 2 3 [4])
+ // After one click, selection=1: ([1] 2 3 4)
+ click('m3');
+
+ // Other edge cases
+ for (var i = 1; i <= 13; i++)
+ click('e'+i);
+
+ // Nested maction elements, bubble = false ; ([([1] 2 3)] 4 5)
+ // After one click on the inner maction: ([(1 [2] 3)] 4 5)
+ click('m4', false);
+
+ // Nested maction elements, bubble = true ; ([([1] 2 3)] 4 5)
+ // After one click on the inner maction: ((1 [2] 3) [4] 5)
+ click('m5', true);
+
+ // Prevent default ; ([1] 2 3)
+ // After one click on the inner maction: ([1] 2 3)
+ click('m6', false, true);
+ }
+ </script>
+ </head>
+ <body onload="test()">
+
+ <!-- This test verifies the effect of mouse clicks on <maction actiontype="toggle"> elements. -->
+
+ <!-- selection="1" (default) ; three clicks -->
+ <math>
+ <maction actiontype="toggle" id="m1">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ <mn>4</mn>
+ </maction>
+ </math>
+
+ <!-- selection="2" ; one click -->
+ <math>
+ <maction actiontype="toggle" selection="2" id="m2">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ <mn>4</mn>
+ </maction>
+ </math>
+
+ <!-- selection="4" (last child) ; one click -->
+ <math>
+ <maction actiontype="toggle" selection="4" id="m3">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ <mn>4</mn>
+ </maction>
+ </math>
+
+ <!-- Other edge cases -->
+ <math>
+ <maction actiontype="toggle" id="e1">
+ </maction>
+ </math>
+ <math>
+ <maction actiontype="toggle" id="e2">
+ <mn>1</mn>
+ </maction>
+ </math>
+ <math>
+ <maction actiontype="toggle" selection="-10" id="e3">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ </math>
+ <math>
+ <maction actiontype="toggle" selection="-1" id="e4">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ </math>
+ <math>
+ <maction actiontype="toggle" selection="0" id="e5">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ </math>
+ <math>
+ <maction actiontype="toggle" selection="4" id="e6">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ </math>
+ <math>
+ <maction actiontype="toggle" selection="10" id="e7">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ </math>
+ <math>
+ <maction actiontype="toggle" selection="&#x20;&#x9;&#xD;&#xA;2&#x20;&#x9;&#xD;&#xA;" id="e8">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ </math>
+ <math>
+ <maction actiontype="toggle" selection="TWO" id="e9">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ </math>
+ <math>
+ <!-- These values are limits for 32 bits signed integers.
+ The maction element will convert them to 1 and 3 respectively. -->
+ <maction actiontype="toggle" selection="-65536" id="e10">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ <maction actiontype="toggle" selection="65535" id="e11">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ <!-- These values are -1 and +1 for 32 or 64 bits signed integers.
+ The maction element will convert both of them to 1. -->
+ <maction actiontype="toggle" selection="-18446744073709551617" id="e12">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ <maction actiontype="toggle" selection="18446744073709551617" id="e13">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ </math>
+
+ <!-- Nested <maction> elements ; bubble = false -->
+ <math>
+ <maction actiontype="toggle">
+ <maction actiontype="toggle" id="m4">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ <mn>4</mn>
+ <mn>5</mn>
+ </maction>
+ </math>
+
+ <!-- Nested <maction> elements ; bubble = true -->
+ <math>
+ <maction actiontype="toggle">
+ <maction actiontype="toggle" id="m5">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ <mn>4</mn>
+ <mn>5</mn>
+ </maction>
+ </math>
+
+ <!-- Prevent default -->
+ <math>
+ <maction actiontype="toggle" id="m6">
+ <mn>1</mn>
+ <mn>2</mn>
+ <mn>3</mn>
+ </maction>
+ </math>
+
+
+ </body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (160630 => 160631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-16 06:39:18 UTC (rev 160630)
+++ trunk/Source/WebCore/ChangeLog        2013-12-16 06:53:38 UTC (rev 160631)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2013-12-15 Frédéric Wang <fred.wang@free.fr>
+
+ Add support for maction@toggle
+ https://bugs.webkit.org/show_bug.cgi?id=120059
+
+ Reviewed by Chris Fleizach.
+
+ Test: mathml/presentation/maction-toggle.html
+
+ * mathml/MathMLSelectElement.cpp:
+ (WebCore::MathMLSelectElement::getSelectedChildAndIndex):
+ (WebCore::MathMLSelectElement::updateSelectedChild):
+ (WebCore::MathMLSelectElement::defaultEventHandler):
+ (WebCore::MathMLSelectElement::willRespondToMouseClickEvents):
+ (WebCore::MathMLSelectElement::toggle):
+ * mathml/MathMLSelectElement.h:
+
</ins><span class="cx"> 2013-12-15 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> More nullptr in RenderElement
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLSelectElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLSelectElement.cpp (160630 => 160631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLSelectElement.cpp        2013-12-16 06:39:18 UTC (rev 160630)
+++ trunk/Source/WebCore/mathml/MathMLSelectElement.cpp        2013-12-16 06:53:38 UTC (rev 160631)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(MATHML)
</span><span class="cx">
</span><ins>+#include "Event.h"
</ins><span class="cx"> #include "MathMLNames.h"
</span><span class="cx"> #include "RenderMathMLRow.h"
</span><span class="cx">
</span><span class="lines">@@ -76,6 +77,25 @@
</span><span class="cx"> MathMLInlineContainerElement::attributeChanged(name, newValue, reason);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+int MathMLSelectElement::getSelectedChildAndIndex(Element*& selectedChild)
+{
+ // We "round up or down to the closest allowable value" of the selection attribute, as suggested by the MathML specification.
+ selectedChild = firstElementChild();
+ if (!selectedChild)
+ return 1;
+
+ int selection = fastGetAttribute(MathMLNames::selectionAttr).toInt();
+ int i;
+ for (i = 1; i < selection; i++) {
+ Element* nextChild = selectedChild->nextElementSibling();
+ if (!nextChild)
+ break;
+ selectedChild = nextChild;
+ }
+
+ return i;
+}
+
</ins><span class="cx"> void MathMLSelectElement::updateSelectedChild()
</span><span class="cx"> {
</span><span class="cx"> Element* newSelectedChild = firstElementChild();
</span><span class="lines">@@ -91,15 +111,8 @@
</span><span class="cx"> // FIXME: implement user interaction for the "tooltip" action type (http://wkbug/124921).
</span><span class="cx"> { }
</span><span class="cx"> else {
</span><del>- // FIXME: implement user interaction for the "toggle" action type (http://wkbug/120059).
</del><span class="cx"> // For the "toggle" action type or any unknown action type, we rely on the value of the selection attribute to determine the visible child.
</span><del>- int selection = fastGetAttribute(MathMLNames::selectionAttr).toInt();
- for (int i = 1; i < selection; i++) {
- Element* nextChild = newSelectedChild->nextElementSibling();
- if (!nextChild)
- break;
- newSelectedChild = nextChild;
- }
</del><ins>+ getSelectedChildAndIndex(newSelectedChild);
</ins><span class="cx"> }
</span><span class="cx"> } else {
</span><span class="cx"> ASSERT(hasLocalName(semanticsTag));
</span><span class="lines">@@ -117,6 +130,39 @@
</span><span class="cx"> setNeedsStyleRecalc();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void MathMLSelectElement::defaultEventHandler(Event* event)
+{
+ if (event->type() == eventNames().clickEvent) {
+ if (fastGetAttribute(MathMLNames::actiontypeAttr) == "toggle") {
+ toggle();
+ return;
+ }
+ }
+
+ MathMLInlineContainerElement::defaultEventHandler(event);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+bool MathMLSelectElement::willRespondToMouseClickEvents()
+{
+ return true;
+}
+
+void MathMLSelectElement::toggle()
+{
+ // We determine the successor of the selected child.
+ // If we reach the end of the child list, we go back to the first child.
+ Element* child = nullptr;
+ int selection = getSelectedChildAndIndex(child);
+ if (!child || !child->nextElementSibling())
+ selection = 1;
+ else
+ selection++;
+
+ // We update the attribute value of the selection attribute.
+ // This will also call MathMLSelectElement::attributeChanged to update the selected child.
+ setAttribute(MathMLNames::selectionAttr, AtomicString::number(selection));
+}
+
+}
+
</ins><span class="cx"> #endif // ENABLE(MATHML)
</span></span></pre></div>
<a id="trunkSourceWebCoremathmlMathMLSelectElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/mathml/MathMLSelectElement.h (160630 => 160631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/mathml/MathMLSelectElement.h        2013-12-16 06:39:18 UTC (rev 160630)
+++ trunk/Source/WebCore/mathml/MathMLSelectElement.h        2013-12-16 06:53:38 UTC (rev 160631)
</span><span class="lines">@@ -44,7 +44,12 @@
</span><span class="cx"> virtual void finishParsingChildren() OVERRIDE;
</span><span class="cx"> virtual void childrenChanged(const ChildChange&) OVERRIDE;
</span><span class="cx"> virtual void attributeChanged(const QualifiedName&, const AtomicString&, AttributeModificationReason = ModifiedDirectly) OVERRIDE;
</span><ins>+ virtual void defaultEventHandler(Event*) OVERRIDE;
+ virtual bool willRespondToMouseClickEvents() OVERRIDE;
</ins><span class="cx">
</span><ins>+ void toggle();
+ int getSelectedChildAndIndex(Element*& selectedChild);
+
</ins><span class="cx"> void updateSelectedChild();
</span><span class="cx"> Element* m_selectedChild;
</span><span class="cx"> };
</span></span></pre>
</div>
</div>
</body>
</html>