Title: [91406] branches/safari-534.51-branch
- Revision
- 91406
- Author
- lforsch...@apple.com
- Date
- 2011-07-20 14:27:20 -0700 (Wed, 20 Jul 2011)
Log Message
Merge r86976.
Modified Paths
Diff
Modified: branches/safari-534.51-branch/LayoutTests/ChangeLog (91405 => 91406)
--- branches/safari-534.51-branch/LayoutTests/ChangeLog 2011-07-20 21:17:13 UTC (rev 91405)
+++ branches/safari-534.51-branch/LayoutTests/ChangeLog 2011-07-20 21:27:20 UTC (rev 91406)
@@ -1,5 +1,19 @@
2011-06-20 Lucas Forschler <lforsch...@apple.com>
+ Merged 86976.
+
+ 2011-05-20 Abhishek Arya <infe...@chromium.org>
+
+ Reviewed by Kent Tamura.
+
+ Tests that we do not crash when auto-focus triggers a attach.
+ https://bugs.webkit.org/show_bug.cgi?id=32882
+
+ * fast/forms/input-element-attach-crash-expected.txt: Added.
+ * fast/forms/input-element-attach-crash.html: Added.
+
+2011-06-20 Lucas Forschler <lforsch...@apple.com>
+
Merged 89281.
2011-06-20 Oliver Hunt <oli...@apple.com>
Modified: branches/safari-534.51-branch/Source/WebCore/ChangeLog (91405 => 91406)
--- branches/safari-534.51-branch/Source/WebCore/ChangeLog 2011-07-20 21:17:13 UTC (rev 91405)
+++ branches/safari-534.51-branch/Source/WebCore/ChangeLog 2011-07-20 21:27:20 UTC (rev 91406)
@@ -1,3 +1,39 @@
+2011-07-27 Lucas Forschler <lforsch...@apple.com>
+
+ Merged 89748.
+
+ 2011-05-20 Abhishek Arya <infe...@chromium.org>
+
+ Reviewed by Kent Tamura.
+
+ Make auto-focus a post attach callback in
+ HTMLFormControlElement::attach().
+ https://bugs.webkit.org/show_bug.cgi?id=32882
+
+ Original patch by Darin Adler. This one uses a part of it.
+
+ Test: fast/forms/input-element-attach-crash.html
+
+ * dom/Document.cpp:
+ (WebCore::Document::recalcStyle): Make sure that m_inStyleRecalc is
+ already false by the time post-attach callbacks are done so that
+ layout triggered inside those callbacks can work properly.
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::shouldAutofocus): Helper function that expresses
+ the rule for which form control elements should auto-focus.
+ (WebCore::focusPostAttach): Called post-attach to focus an
+ element if we discover it should be focused during attach.
+ (WebCore::HTMLFormControlElement::attach): Refactored code for
+ which elements need auto-focus into a separate function. Instead
+ of focusing right away, use the focusPostAttach function to focus
+ after attach is done. Also added calls to suspendPostAttachCallbacks
+ and resumePostAttachCallbacks so post-attach callbacks happen late
+ enough. Before, they could run inside the base attach function.
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::attach): Added calls to
+ suspendPostAttachCallbacks and resumePostAttachCallbacks so
+ post-attach callbacks happen late enough
+
2011-06-27 Lucas Forschler <lforsch...@apple.com>
Merged 89748.
Modified: branches/safari-534.51-branch/Source/WebCore/dom/Document.cpp (91405 => 91406)
--- branches/safari-534.51-branch/Source/WebCore/dom/Document.cpp 2011-07-20 21:17:13 UTC (rev 91405)
+++ branches/safari-534.51-branch/Source/WebCore/dom/Document.cpp 2011-07-20 21:27:20 UTC (rev 91406)
@@ -1545,6 +1545,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) {
@@ -1560,7 +1562,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/safari-534.51-branch/Source/WebCore/html/HTMLFormControlElement.cpp (91405 => 91406)
--- branches/safari-534.51-branch/Source/WebCore/html/HTMLFormControlElement.cpp 2011-07-20 21:17:13 UTC (rev 91405)
+++ branches/safari-534.51-branch/Source/WebCore/html/HTMLFormControlElement.cpp 2011-07-20 21:27:20 UTC (rev 91406)
@@ -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/safari-534.51-branch/Source/WebCore/html/HTMLInputElement.cpp (91405 => 91406)
--- branches/safari-534.51-branch/Source/WebCore/html/HTMLInputElement.cpp 2011-07-20 21:17:13 UTC (rev 91405)
+++ branches/safari-534.51-branch/Source/WebCore/html/HTMLInputElement.cpp 2011-07-20 21:27:20 UTC (rev 91406)
@@ -732,6 +732,8 @@
void HTMLInputElement::attach()
{
+ suspendPostAttachCallbacks();
+
if (!m_hasType)
updateType();
@@ -741,6 +743,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