Title: [87085] branches/chromium/742

Diff

Copied: branches/chromium/742/LayoutTests/fast/forms/input-element-attach-crash-expected.txt (from rev 86976, trunk/LayoutTests/fast/forms/input-element-attach-crash-expected.txt) (0 => 87085)


--- branches/chromium/742/LayoutTests/fast/forms/input-element-attach-crash-expected.txt	                        (rev 0)
+++ branches/chromium/742/LayoutTests/fast/forms/input-element-attach-crash-expected.txt	2011-05-23 18:44:48 UTC (rev 87085)
@@ -0,0 +1,2 @@
+ 
+PASS  

Copied: branches/chromium/742/LayoutTests/fast/forms/input-element-attach-crash.html (from rev 86976, trunk/LayoutTests/fast/forms/input-element-attach-crash.html) (0 => 87085)


--- branches/chromium/742/LayoutTests/fast/forms/input-element-attach-crash.html	                        (rev 0)
+++ branches/chromium/742/LayoutTests/fast/forms/input-element-attach-crash.html	2011-05-23 18:44:48 UTC (rev 87085)
@@ -0,0 +1,20 @@
+<html>
+    <head>
+        <script>
+            if (window.layoutTestController)
+                layoutTestController.dumpAsText();
+        </script>
+    </head>
+    <body>
+        <button autofocus>
+            <object>
+                <select autofocus>
+                <input>
+                <span>
+                <div></div>
+                PASS
+            </object>
+            <object></object>
+        </button>
+    </body>
+</html>

Modified: branches/chromium/742/Source/WebCore/dom/Document.cpp (87084 => 87085)


--- branches/chromium/742/Source/WebCore/dom/Document.cpp	2011-05-23 18:41:52 UTC (rev 87084)
+++ branches/chromium/742/Source/WebCore/dom/Document.cpp	2011-05-23 18:44:48 UTC (rev 87085)
@@ -1489,6 +1489,8 @@
     clearNeedsStyleRecalc();
     clearChildNeedsStyleRecalc();
     unscheduleStyleRecalc();
+
+    m_inStyleRecalc = false;
     
     // Pseudo element removal and similar may only work with these flags still set. Reset them after the style recalc.
     if (m_styleSelector) {
@@ -1504,7 +1506,6 @@
     }
     RenderWidget::resumeWidgetHierarchyUpdates();
     resumePostAttachCallbacks();
-    m_inStyleRecalc = false;
 
     // If we wanted to call implicitClose() during recalcStyle, do so now that we're finished.
     if (m_closeAfterStyleRecalc) {

Modified: branches/chromium/742/Source/WebCore/html/HTMLFormControlElement.cpp (87084 => 87085)


--- branches/chromium/742/Source/WebCore/html/HTMLFormControlElement.cpp	2011-05-23 18:41:52 UTC (rev 87084)
+++ branches/chromium/742/Source/WebCore/html/HTMLFormControlElement.cpp	2011-05-23 18:44:48 UTC (rev 87085)
@@ -120,10 +120,45 @@
     setNeedsWillValidateCheck();
 }
 
+static bool shouldAutofocus(HTMLFormControlElement* element)
+{
+    if (!element->autofocus())
+        return false;
+    if (!element->renderer())
+        return false;
+    if (element->document()->ignoreAutofocus())
+        return false;
+    if (element->isReadOnlyFormControl())
+        return false;
+
+    // FIXME: Should this set of hasTagName checks be replaced by a
+    // virtual member function?
+    if (element->hasTagName(inputTag))
+        return !static_cast<HTMLInputElement*>(element)->isInputTypeHidden();
+    if (element->hasTagName(selectTag))
+        return true;
+    if (element->hasTagName(keygenTag))
+        return true;
+    if (element->hasTagName(buttonTag))
+        return true;
+    if (element->hasTagName(textareaTag))
+        return true;
+
+    return false;
+}
+
+static void focusPostAttach(Node* element) 
+{ 
+    static_cast<Element*>(element)->focus(); 
+    element->deref(); 
+}
+
 void HTMLFormControlElement::attach()
 {
     ASSERT(!attached());
 
+    suspendPostAttachCallbacks();
+
     HTMLElement::attach();
 
     // The call to updateFromElement() needs to go after the call through
@@ -132,17 +167,12 @@
     if (renderer())
         renderer()->updateFromElement();
 
-    // Focus the element if it should honour its autofocus attribute.
-    // We have to determine if the element is a TextArea/Input/Button/Select,
-    // if input type hidden ignore autofocus. So if disabled or readonly.
-    bool isInputTypeHidden = false;
-    if (hasTagName(inputTag))
-        isInputTypeHidden = static_cast<HTMLInputElement*>(this)->isInputTypeHidden();
+    if (shouldAutofocus(this)) {
+        ref();
+        queuePostAttachCallback(focusPostAttach, this);
+    }
 
-    if (autofocus() && renderer() && !document()->ignoreAutofocus() && !isReadOnlyFormControl() &&
-            ((hasTagName(inputTag) && !isInputTypeHidden) || hasTagName(selectTag) ||
-              hasTagName(keygenTag) || hasTagName(buttonTag) || hasTagName(textareaTag)))
-         focus();
+    resumePostAttachCallbacks();
 }
 
 void HTMLFormControlElement::willMoveToNewOwnerDocument()

Modified: branches/chromium/742/Source/WebCore/html/HTMLInputElement.cpp (87084 => 87085)


--- branches/chromium/742/Source/WebCore/html/HTMLInputElement.cpp	2011-05-23 18:41:52 UTC (rev 87084)
+++ branches/chromium/742/Source/WebCore/html/HTMLInputElement.cpp	2011-05-23 18:44:48 UTC (rev 87085)
@@ -687,6 +687,8 @@
 
 void HTMLInputElement::attach()
 {
+    suspendPostAttachCallbacks();
+
     if (!m_hasType)
         updateType();
 
@@ -696,6 +698,8 @@
 
     if (document()->focusedNode() == this)
         document()->updateFocusAppearanceSoon(true /* restore selection */);
+
+    resumePostAttachCallbacks();
 }
 
 void HTMLInputElement::detach()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to