Title: [160771] trunk
Revision
160771
Author
[email protected]
Date
2013-12-18 10:02:14 -0800 (Wed, 18 Dec 2013)

Log Message

Additional refinement in MathMLSelectElement toggle implementation
https://bugs.webkit.org/show_bug.cgi?id=125785

Reviewed by Andreas Kling.

Source/WebCore:

* mathml/MathMLSelectElement.cpp:
(WebCore::MathMLSelectElement::defaultEventHandler): Call setDefaultHandled
so this will be handled by only one element.
(WebCore::MathMLSelectElement::willRespondToMouseClickEvents): Return true
only when action is set to toggle, since other select elements will not
respond to mouse click events.
(WebCore::MathMLSelectElement::toggle): Simplified code a bit and gave
local a clearer variable name.

LayoutTests:

* mathml/presentation/maction-toggle-expected.html: Updated incorrect expected
result, which expected an already-handled event to be re-handled by a parent
element during the bubbling process.
* mathml/presentation/maction-toggle.html: Ditto.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (160770 => 160771)


--- trunk/LayoutTests/ChangeLog	2013-12-18 17:27:58 UTC (rev 160770)
+++ trunk/LayoutTests/ChangeLog	2013-12-18 18:02:14 UTC (rev 160771)
@@ -1,3 +1,15 @@
+2013-12-18  Darin Adler  <[email protected]>
+
+        Additional refinement in MathMLSelectElement toggle implementation
+        https://bugs.webkit.org/show_bug.cgi?id=125785
+
+        Reviewed by Andreas Kling.
+
+        * mathml/presentation/maction-toggle-expected.html: Updated incorrect expected
+        result, which expected an already-handled event to be re-handled by a parent
+        element during the bubbling process.
+        * mathml/presentation/maction-toggle.html: Ditto.
+
 2013-12-18  Rob Buis  <[email protected]>
 
         [CSS Shapes] Implement interpolation between keywords in basic shapes

Modified: trunk/LayoutTests/mathml/presentation/maction-toggle-expected.html (160770 => 160771)


--- trunk/LayoutTests/mathml/presentation/maction-toggle-expected.html	2013-12-18 17:27:58 UTC (rev 160770)
+++ trunk/LayoutTests/mathml/presentation/maction-toggle-expected.html	2013-12-18 18:02:14 UTC (rev 160771)
@@ -96,7 +96,7 @@
     <!-- Nested <maction> elements ; bubble = true -->
     <math>
       <mrow>
-        <mn>4</mn>
+        <mn>2</mn>
       </mrow>
     </math>
 

Modified: trunk/LayoutTests/mathml/presentation/maction-toggle.html (160770 => 160771)


--- trunk/LayoutTests/mathml/presentation/maction-toggle.html	2013-12-18 17:27:58 UTC (rev 160770)
+++ trunk/LayoutTests/mathml/presentation/maction-toggle.html	2013-12-18 18:02:14 UTC (rev 160771)
@@ -33,7 +33,8 @@
         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)
+        // After one click on the inner maction: ([(1 [2] 3)] 4 5)
+        // Bubbling sends the event to outer maction handlers, but default handling is done only once.
         click('m5', true);
 
         // Prevent default ; ([1] 2 3)

Modified: trunk/Source/WebCore/ChangeLog (160770 => 160771)


--- trunk/Source/WebCore/ChangeLog	2013-12-18 17:27:58 UTC (rev 160770)
+++ trunk/Source/WebCore/ChangeLog	2013-12-18 18:02:14 UTC (rev 160771)
@@ -1,3 +1,19 @@
+2013-12-18  Darin Adler  <[email protected]>
+
+        Additional refinement in MathMLSelectElement toggle implementation
+        https://bugs.webkit.org/show_bug.cgi?id=125785
+
+        Reviewed by Andreas Kling.
+
+        * mathml/MathMLSelectElement.cpp:
+        (WebCore::MathMLSelectElement::defaultEventHandler): Call setDefaultHandled
+        so this will be handled by only one element.
+        (WebCore::MathMLSelectElement::willRespondToMouseClickEvents): Return true
+        only when action is set to toggle, since other select elements will not
+        respond to mouse click events.
+        (WebCore::MathMLSelectElement::toggle): Simplified code a bit and gave
+        local a clearer variable name.
+
 2013-12-18  Rob Buis  <[email protected]>
 
         [CSS Shapes] Implement interpolation between keywords in basic shapes

Modified: trunk/Source/WebCore/mathml/MathMLSelectElement.cpp (160770 => 160771)


--- trunk/Source/WebCore/mathml/MathMLSelectElement.cpp	2013-12-18 17:27:58 UTC (rev 160770)
+++ trunk/Source/WebCore/mathml/MathMLSelectElement.cpp	2013-12-18 18:02:14 UTC (rev 160771)
@@ -135,6 +135,7 @@
     if (event->type() == eventNames().clickEvent) {
         if (fastGetAttribute(MathMLNames::actiontypeAttr) == "toggle") {
             toggle();
+            event->setDefaultHandled();
             return;
         }
     }
@@ -144,23 +145,21 @@
 
 bool MathMLSelectElement::willRespondToMouseClickEvents()
 {
-    return true;
+    return fastGetAttribute(MathMLNames::actiontypeAttr) == "toggle";
 }
 
 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++;
+    // Select the successor of the currently selected child
+    // or the first child if the currently selected child is the last.
+    Element* selectedChild;
+    int newSelectedChildIndex = getSelectedChildAndIndex(selectedChild) + 1;
+    if (!selectedChild || !selectedChild->nextElementSibling())
+        newSelectedChildIndex = 1;
 
     // 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));
+    setAttribute(MathMLNames::selectionAttr, AtomicString::number(newSelectedChildIndex));
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to