Bug 1376158: Don't let non-primary frames affect the mIncrementScriptLevel of the content. r?xidorn draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 25 Jun 2017 21:26:49 +0200
changeset 600315 d4769905c56f5dfc99125cce5b867879da21e34e
parent 600314 9ba453694a72976b70102debb5fb73e55d663f42
child 634953 e1d930ebf8b4f04d3685677f53567f3ce5630a2b
push id65715
push userbmo:emilio+bugs@crisal.io
push dateSun, 25 Jun 2017 21:22:54 +0000
reviewersxidorn
bugs1376158
milestone56.0a1
Bug 1376158: Don't let non-primary frames affect the mIncrementScriptLevel of the content. r?xidorn In the test-case we have a munderoverFrame setting the script-level of the content through a frame which is an anonymous block, and another one setting the script level to the opposite for the same content, via its primary frame. That's somewhat silly, and with the previous patches the non-primary one happened to be ignored because the IncrementScriptLevel flag was set on the fly. The whole situation is somewhat silly, because as far as I can tell MathML tries to map one frame to one element, and this doesn't hold. This patch makes the behavior consistent and makes the test-case render as "invalid markup", which is what should happen anyway. MozReview-Commit-ID: 5ugxVwX3sMa
layout/mathml/crashtests/1376158.html
layout/mathml/crashtests/crashtests.list
layout/mathml/nsMathMLmunderoverFrame.cpp
new file mode 100644
--- /dev/null
+++ b/layout/mathml/crashtests/1376158.html
@@ -0,0 +1,6 @@
+<math>
+<munderover>
+></ms>
+<munder accentunder="true">
+<mo>)</mo>
+<mscarry>
--- a/layout/mathml/crashtests/crashtests.list
+++ b/layout/mathml/crashtests/crashtests.list
@@ -60,8 +60,9 @@ load 713606-1.html
 load 716349-1.html
 load 767251.xhtml
 load 848725-1.html
 load 848725-2.html
 load 947557-1.html
 load 973322-1.xhtml
 load 1028521-1.xhtml
 load 1061027.html
+load 1376158.html
--- a/layout/mathml/nsMathMLmunderoverFrame.cpp
+++ b/layout/mathml/nsMathMLmunderoverFrame.cpp
@@ -102,17 +102,18 @@ nsMathMLmunderoverFrame::ScriptIncrement
   return 0;  // frame not found
 }
 
 void
 nsMathMLmunderoverFrame::SetIncrementScriptLevel(uint32_t aChildIndex,
                                                  bool aIncrement)
 {
   nsIFrame* child = PrincipalChildList().FrameAt(aChildIndex);
-  if (!child || !child->GetContent()->IsMathMLElement()) {
+  if (!child || !child->GetContent()->IsMathMLElement() ||
+      child->GetContent()->GetPrimaryFrame() != child) {
     return;
   }
 
   auto element = static_cast<nsMathMLElement*>(child->GetContent());
   if (element->GetIncrementScriptLevel() == aIncrement) {
     return;
   }