Bug 615781 - Don't attempt to display the caret when switching selections if we know that we're going to hide it immediately; r,a=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 01 Dec 2010 16:38:21 -0500
changeset 58616 c5e63ee001324785bbeab8a1422e9650c8c15911
parent 58615 445e8a8d79b2901826d1d400b176dae79b841d43
child 58617 1f2beffd84ff6e63451e0120c5b59bc88e95b9e5
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersroc
bugs615781
milestone2.0b8pre
Bug 615781 - Don't attempt to display the caret when switching selections if we know that we're going to hide it immediately; r,a=roc This prevents useless work which _could_ lead to visual artifacts, as well as assertions caused by us touching dirty frames,
dom/base/nsFocusManager.cpp
layout/base/crashtests/615781-1.xhtml
layout/base/crashtests/crashtests.list
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -2030,17 +2030,20 @@ nsFocusManager::SetCaretVisible(nsIPresS
 
   nsCOMPtr<nsFrameSelection> docFrameSelection = aPresShell->FrameSelection();
 
   if (docFrameSelection && caret &&
      (frameSelection == docFrameSelection || !aContent)) {
     nsISelection* domSelection = docFrameSelection->
       GetSelection(nsISelectionController::SELECTION_NORMAL);
     if (domSelection) {
-      // First, tell the caret which selection to use
+      // First, hide the caret to prevent attempting to show it in SetCaretDOMSelection
+      caret->SetCaretVisible(PR_FALSE);
+
+      // Tell the caret which selection to use
       caret->SetCaretDOMSelection(domSelection);
 
       // In content, we need to set the caret. The only special case is edit
       // fields, which have a different frame selection from the document.
       // They will take care of making the caret visible themselves.
 
       nsCOMPtr<nsISelectionController> selCon(do_QueryInterface(aPresShell));
       if (!selCon)
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/615781-1.xhtml
@@ -0,0 +1,22 @@
+<html xmlns="http://www.w3.org/1999/xhtml" class="reftest-wait">
+
+<input id="i"/>
+
+<script>
+<![CDATA[
+
+function boom()
+{
+  var i = document.getElementById("i");
+  i.select();
+  i.setAttribute("type", "radio");
+  i.blur();
+  document.documentElement.removeAttribute("class");
+}
+
+window.addEventListener("load", function() { setTimeout(boom, 100); }, false);
+
+]]>
+</script>
+
+</html>
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -310,9 +310,10 @@ load 567292-1.xhtml
 load 569018-1.html
 load 572003.xul
 load 572582-1.xhtml
 load 579655.html
 load 580494-1.html
 load 580834-1.xhtml
 load 606432-1.html
 load 609821-1.xhtml
+load 615781-1.xhtml
 load 616495-single-side-composite-color-border.html