[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
darin at apple.com
darin at apple.com
Wed Jan 6 00:21:07 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit e12c16cfbd1633fc51ed5ba43ee8dffacae35850
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 5 01:35:59 2010 +0000
Selection-related code needs stricter rules about how it relates to layout
https://bugs.webkit.org/show_bug.cgi?id=32882
Reviewed by Maciej Stachowiak.
Covered by existing tests along with the new assertions.
* 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.
* editing/SelectionController.cpp:
(WebCore::SelectionController::layout): Added code to trigger a
layout when it's needed.
(WebCore::SelectionController::recomputeCaretRect): Removed unneeded
code to do nothing when FrameView is 0. Added an assertion that layout
is not needed at the time the function is called.
(WebCore::SelectionController::invalidateCaretRect): Added code to
trigger a layout when it's needed.
(WebCore::SelectionController::paintCaret): Added an assertion that
layout is not needed at the time the function is called.
* html/HTMLFormControlElement.cpp:
(WebCore::shouldAutofocus): Added. Helper function that expresses
the rule for which form control elements should auto-focus.
(WebCore::focusPostAttach): Added. 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
* page/Frame.cpp:
(WebCore::Frame::revealSelection): Added code to trigger a layout
when it's needed.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52778 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 980cd70..019a25c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,49 @@
+2010-01-04 Darin Adler <darin at apple.com>
+
+ Reviewed by Maciej Stachowiak.
+
+ Selection-related code needs stricter rules about how it relates to layout
+ https://bugs.webkit.org/show_bug.cgi?id=32882
+
+ Covered by existing tests along with the new assertions.
+
+ * 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.
+
+ * editing/SelectionController.cpp:
+ (WebCore::SelectionController::layout): Added code to trigger a
+ layout when it's needed.
+ (WebCore::SelectionController::recomputeCaretRect): Removed unneeded
+ code to do nothing when FrameView is 0. Added an assertion that layout
+ is not needed at the time the function is called.
+ (WebCore::SelectionController::invalidateCaretRect): Added code to
+ trigger a layout when it's needed.
+ (WebCore::SelectionController::paintCaret): Added an assertion that
+ layout is not needed at the time the function is called.
+
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::shouldAutofocus): Added. Helper function that expresses
+ the rule for which form control elements should auto-focus.
+ (WebCore::focusPostAttach): Added. 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
+
+ * page/Frame.cpp:
+ (WebCore::Frame::revealSelection): Added code to trigger a layout
+ when it's needed.
+
2010-01-04 Gavin Barraclough <barraclough at apple.com>
Reviewed by Sam Weinig.
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index fd5f118..c080340 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -1294,11 +1294,12 @@ bail_out:
setChildNeedsStyleRecalc(false);
unscheduleStyleRecalc();
+ m_inStyleRecalc = false;
+
if (view())
view()->resumeScheduledEvents();
RenderWidget::resumeWidgetHierarchyUpdates();
resumePostAttachCallbacks();
- m_inStyleRecalc = false;
// If we wanted to call implicitClose() during recalcStyle, do so now that we're finished.
if (m_closeAfterStyleRecalc) {
diff --git a/WebCore/editing/SelectionController.cpp b/WebCore/editing/SelectionController.cpp
index 13699d7..f184bfa 100644
--- a/WebCore/editing/SelectionController.cpp
+++ b/WebCore/editing/SelectionController.cpp
@@ -819,11 +819,17 @@ void SelectionController::layout()
return;
}
- m_selection.start().node()->document()->updateStyleIfNeeded();
-
m_caretRect = IntRect();
if (isCaret()) {
+ Document* document = m_selection.start().node()->document();
+
+ document->updateStyleIfNeeded();
+ if (FrameView* view = document->view()) {
+ if (view->needsLayout())
+ view->layout();
+ }
+
VisiblePosition pos(m_selection.start(), m_selection.affinity());
if (pos.isNotNull()) {
ASSERT(pos.deepEquivalent().node()->renderer());
@@ -920,9 +926,7 @@ bool SelectionController::recomputeCaretRect()
if (!m_frame)
return false;
- FrameView* v = m_frame->document()->view();
- if (!v)
- return false;
+ ASSERT(!m_frame->view() || !m_frame->view()->needsLayout());
if (!m_needsLayout)
return false;
@@ -958,7 +962,12 @@ void SelectionController::invalidateCaretRect()
if (!isCaret())
return;
- Document* d = m_selection.start().node()->document();
+ Document* document = m_selection.start().node()->document();
+
+ if (FrameView* frameView = document->view()) {
+ if (frameView->needsLayout())
+ frameView->layout();
+ }
// recomputeCaretRect will always return false for the drag caret,
// because its m_frame is always 0.
@@ -978,14 +987,16 @@ void SelectionController::invalidateCaretRect()
m_needsLayout = true;
if (!caretRectChanged) {
- if (RenderView* view = toRenderView(d->renderer()))
+ if (RenderView* view = toRenderView(document->renderer()))
view->repaintRectangleInViewAndCompositedLayers(caretRepaintRect(), false);
}
}
void SelectionController::paintCaret(GraphicsContext* p, int tx, int ty, const IntRect& clipRect)
{
- if (! m_selection.isCaret())
+ ASSERT(!m_frame || !m_frame->view() || !m_frame->view()->needsLayout());
+
+ if (!isCaret())
return;
if (m_needsLayout)
diff --git a/WebCore/html/HTMLFormControlElement.cpp b/WebCore/html/HTMLFormControlElement.cpp
index eb25c40..5f53a3a 100644
--- a/WebCore/html/HTMLFormControlElement.cpp
+++ b/WebCore/html/HTMLFormControlElement.cpp
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll at kde.org)
* (C) 1999 Antti Koivisto (koivisto at kde.org)
* (C) 2001 Dirk Mueller (mueller at kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
* (C) 2006 Alexey Proskuryakov (ap at nypop.com)
*
* This library is free software; you can redistribute it and/or
@@ -116,10 +116,43 @@ void HTMLFormControlElement::parseMappedAttribute(MappedAttribute *attr)
HTMLElement::parseMappedAttribute(attr);
}
+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(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
@@ -127,18 +160,13 @@ void HTMLFormControlElement::attach()
// on the renderer.
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 (autofocus() && renderer() && !document()->ignoreAutofocus() && !isReadOnlyFormControl() &&
- ((hasTagName(inputTag) && !isInputTypeHidden) || hasTagName(selectTag) ||
- hasTagName(buttonTag) || hasTagName(textareaTag)))
- focus();
+
+ if (shouldAutofocus(this)) {
+ ref();
+ queuePostAttachCallback(focusPostAttach, this);
+ }
+
+ resumePostAttachCallbacks();
}
void HTMLFormControlElement::insertedIntoTree(bool deep)
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index b2c88c5..6e23382 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll at kde.org)
* (C) 1999 Antti Koivisto (koivisto at kde.org)
* (C) 2001 Dirk Mueller (mueller at kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
* (C) 2006 Alexey Proskuryakov (ap at nypop.com)
* Copyright (C) 2007 Samuel Weinig (sam at webkit.org)
*
@@ -987,6 +987,8 @@ RenderObject *HTMLInputElement::createRenderer(RenderArena *arena, RenderStyle *
void HTMLInputElement::attach()
{
+ suspendPostAttachCallbacks();
+
if (!m_inited) {
if (!m_haveType)
setInputType(getAttribute(typeAttr));
@@ -1009,6 +1011,8 @@ void HTMLInputElement::attach()
imageObj->setImageSizeForAltText();
}
}
+
+ resumePostAttachCallbacks();
}
void HTMLInputElement::detach()
diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp
index 5902e8e..4c370a6 100644
--- a/WebCore/page/Frame.cpp
+++ b/WebCore/page/Frame.cpp
@@ -1351,6 +1351,9 @@ HTMLFormElement *Frame::currentForm() const
void Frame::revealSelection(const ScrollAlignment& alignment, bool revealExtent)
{
+ if (view()->needsLayout())
+ view()->layout();
+
IntRect rect;
switch (selection()->selectionType()) {
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list