Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1526)

Unified Diff: Source/core/page/FocusController.cpp

Issue 57813008: Clicking a non-focusable element in an inactive frame should clear focus in the frame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/events/frame-click-clear-focus-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/FocusController.cpp
diff --git a/Source/core/page/FocusController.cpp b/Source/core/page/FocusController.cpp
index 56871f6d5430d92440d4540bf8f0a7de13e10da7..e50606a52314b1f881a186e6deda7ea27aa6e13d 100644
--- a/Source/core/page/FocusController.cpp
+++ b/Source/core/page/FocusController.cpp
@@ -622,7 +622,7 @@ bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF
RefPtr<Document> oldDocument = oldFocusedFrame ? oldFocusedFrame->document() : 0;
Element* oldFocusedElement = oldDocument ? oldDocument->focusedElement() : 0;
- if (oldFocusedElement == element)
+ if (element && oldFocusedElement == element)
return true;
// FIXME: Might want to disable this check for caretBrowsing
@@ -631,19 +631,17 @@ bool FocusController::setFocusedElement(Element* element, PassRefPtr<Frame> newF
m_page->editorClient().willSetInputMethodState();
- clearSelectionIfNeeded(oldFocusedFrame.get(), newFocusedFrame.get(), element);
-
- if (!element) {
- if (oldDocument)
- oldDocument->setFocusedElement(0);
- return true;
- }
-
- RefPtr<Document> newDocument(element->document());
+ RefPtr<Document> newDocument;
+ if (element)
+ newDocument = &element->document();
+ else if (newFocusedFrame)
+ newDocument = newFocusedFrame->document();
if (newDocument && newDocument->focusedElement() == element)
return true;
+ clearSelectionIfNeeded(oldFocusedFrame.get(), newFocusedFrame.get(), element);
+
if (oldDocument && oldDocument != newDocument)
oldDocument->setFocusedElement(0);
« no previous file with comments | « LayoutTests/fast/events/frame-click-clear-focus-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698