Bug 487539. Don't use an <area>'s primary frame as a primary frame hint. r+sr=roc
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 09 Apr 2009 21:37:37 -0400
changeset 27152 683b00c3d1d1394ec6bb978a8baaf53dec3ce7d2
parent 27151 6e255383fe1e89f682dc0c6d0f452438c0692c87
child 27153 a5468a6bd7ee0ea95e5ca37c4af7969d6afd2285
push id6408
push userbzbarsky@mozilla.com
push dateFri, 10 Apr 2009 01:40:02 +0000
treeherdermozilla-central@683b00c3d1d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs487539
milestone1.9.2a1pre
Bug 487539. Don't use an <area>'s primary frame as a primary frame hint. r+sr=roc
layout/base/nsFrameManager.cpp
layout/reftests/bugs/487539-1.html
layout/reftests/bugs/reftest.list
--- a/layout/base/nsFrameManager.cpp
+++ b/layout/base/nsFrameManager.cpp
@@ -381,17 +381,20 @@ nsFrameManager::GetPrimaryFrameFor(nsICo
         } while (index &&
                  (prevSibling->IsNodeOfType(nsINode::eTEXT) ||
                   prevSibling->IsNodeOfType(nsINode::eCOMMENT) ||
                   prevSibling->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)));
         if (prevSibling) {
           entry = static_cast<PrimaryFrameMapEntry*>
                              (PL_DHashTableOperate(&mPrimaryFrameMap, prevSibling,
                                                PL_DHASH_LOOKUP));
-          if (PL_DHASH_ENTRY_IS_BUSY(entry))
+          // XXXbz the GetContent() == prevSibling check is needed due to bug
+          // 135040.  Remove it once that's fixed.
+          if (PL_DHASH_ENTRY_IS_BUSY(entry) && entry->frame &&
+              entry->frame->GetContent() == prevSibling)
             hint.mPrimaryFrameForPrevSibling = entry->frame;
         }
       }
     }
 
     // walk the frame tree to find the frame that maps aContent.  
     // Use the hint if we have it.
     nsIFrame *result;
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/487539-1.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+<script type="text/javascript">
+
+var img = document.createElement("img");
+img.setAttributeNS(null, "usemap", "#map");
+img.setAttributeNS(null, "src", "data:image/gif;base64,R0lGODlhEwATAKIAAP//AMzMADMzAP8AAAAAAP///wAAAAAAACH5BAEAAAUALAAAAAATABMAAANWWLrUTisyEoC1oUlFr8dQRHykFRad+Y0gdzlv86KVKdsskOUAjHu312rFK5FuxaMNIMgYe85GrVfKZVDAR7DHmVoG4IHn6vqEgZLU90xOq8OazUS7SQAAOw==");
+
+function boom()
+{
+  map = document.createElement("map");
+  map.setAttributeNS(null, "name", "map");
+  area = document.createElement("area");
+  map.appendChild(area);
+  span = document.createElement("span");
+  span.appendChild(img);
+  td = document.createElement("td");
+  span.appendChild(td);
+  map.appendChild(span);
+  document.body.appendChild(map);
+  boom2();
+}
+
+function boom2()
+{
+  // For reliable reproduction, need a flush here.
+  var x = document.body.offsetWidth;
+
+  // needs to be async, apparently.
+  setTimeout(boom3, 0);
+}
+
+function boom3()
+{
+  span.parentNode.removeChild(span); 
+  document.documentElement.removeAttribute("class");
+}
+
+</script>
+</head>
+
+<body onload="boom();"></body>
+
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1198,8 +1198,9 @@ fails == 472020-2.xul 472020-2-ref.xul
 == 486052-2a.html 486052-2-ref.html
 == 486052-2b.html 486052-2-ref.html
 == 486052-2c.html 486052-2-ref.html
 == 486052-2d.html 486052-2-ref.html
 == 486052-2e.html 486052-2-ref.html
 == 486052-2f.html 486052-2-ref.html
 == 486052-2g.html 486052-2-ref.html
 == 486848-1.xul 486848-1-ref.xul
+== 487539-1.html about:blank