Chromium Code Reviews| Index: Source/core/dom/Document.cpp |
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
| index e3ff783900ca656fd499106a88c7daf2f48be5c4..1eeb7cb2c6fb94b4aee23bdb56b4cb09066f8f89 100644 |
| --- a/Source/core/dom/Document.cpp |
| +++ b/Source/core/dom/Document.cpp |
| @@ -384,6 +384,27 @@ static void printNavigationErrorMessage(Frame* frame, const KURL& activeURL, con |
| uint64_t Document::s_globalTreeVersion = 0; |
| +// This class should be passed only to Document::postTask. |
| +class FocusedNodeChecker: public ScriptExecutionContext::Task { |
|
esprehn
2013/05/20 22:03:44
Missing a space before : and this should be FINAL
tkent
2013/05/20 22:29:45
Done.
|
| +public: |
| + static PassOwnPtr<FocusedNodeChecker> create() |
| + { |
| + return adoptPtr(new FocusedNodeChecker()); |
| + } |
| + virtual ~FocusedNodeChecker() { } |
| + |
| +private: |
| + FocusedNodeChecker() { } |
|
esprehn
2013/05/20 22:03:44
It be nicer if this was called CheckFocusedNodeTas
tkent
2013/05/20 22:29:45
Done.
|
| + virtual void performTask(ScriptExecutionContext* context) OVERRIDE |
| + { |
| + ASSERT(context->isDocument()); |
| + Document* document = toDocument(context); |
| + document->didRunFocusedNodeCheker(); |
| + if (document->focusedNode() && !document->focusedNode()->isFocusable()) |
| + document->setFocusedNode(0); |
| + } |
| +}; |
| + |
| Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML) |
| : ContainerNode(0, CreateDocument) |
| , TreeScope(this) |
| @@ -393,6 +414,7 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML) |
| , m_contextFeatures(ContextFeatures::defaultSwitch()) |
| , m_compatibilityMode(NoQuirksMode) |
| , m_compatibilityModeLocked(false) |
| + , m_didPostFocusedNodeChecker(false) |
| , m_domTreeVersion(++s_globalTreeVersion) |
| , m_mutationObserverTypes(0) |
| , m_styleSheetCollection(DocumentStyleSheetCollection::create(this)) |
| @@ -1808,6 +1830,11 @@ void Document::updateLayout() |
| // Only do a layout if changes have occurred that make it necessary. |
| if (frameView && renderer() && (frameView->layoutPending() || renderer()->needsLayout())) |
| frameView->layout(); |
| + |
| + if (m_focusedNode && !m_didPostFocusedNodeChecker) { |
| + postTask(FocusedNodeChecker::create()); |
| + m_didPostFocusedNodeChecker = true; |
| + } |
| } |
| // FIXME: This is a bad idea and needs to be removed eventually. |