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

Side by Side Diff: third_party/WebKit/Source/core/page/FocusController.cpp

Issue 2153063003: Should not call FocusController::setFocusedFrame() for detached frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for comment #20 Created 4 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/Selection/selection-crash.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nuanti Ltd. 3 * Copyright (C) 2008 Nuanti Ltd.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 } 765 }
766 766
767 LocalFrame* newFocusedFrame = (frame && frame->isLocalFrame()) ? toLocalFram e(frame) : nullptr; 767 LocalFrame* newFocusedFrame = (frame && frame->isLocalFrame()) ? toLocalFram e(frame) : nullptr;
768 if (newFocusedFrame && newFocusedFrame->view()) { 768 if (newFocusedFrame && newFocusedFrame->view()) {
769 Document* document = newFocusedFrame->document(); 769 Document* document = newFocusedFrame->document();
770 Element* focusedElement = document ? document->focusedElement() : nullpt r; 770 Element* focusedElement = document ? document->focusedElement() : nullpt r;
771 if (focusedElement) 771 if (focusedElement)
772 dispatchFocusEvent(*document, *focusedElement); 772 dispatchFocusEvent(*document, *focusedElement);
773 } 773 }
774 774
775 // dispatchBlurEvent/dispatchFocusEvent could have changed the focused frame , or
776 // detached the frame.
777 if (newFocusedFrame && !newFocusedFrame->view())
778 return;
779
775 setFocusedFrame(frame, notifyEmbedder); 780 setFocusedFrame(frame, notifyEmbedder);
776 } 781 }
777 782
778 LocalFrame* FocusController::focusedFrame() const 783 LocalFrame* FocusController::focusedFrame() const
779 { 784 {
780 // TODO(alexmos): Strengthen this to DCHECK that whoever called this really 785 // TODO(alexmos): Strengthen this to DCHECK that whoever called this really
781 // expected a LocalFrame. Refactor call sites so that the rare cases that 786 // expected a LocalFrame. Refactor call sites so that the rare cases that
782 // need to know about focused RemoteFrames use a separate accessor (to be 787 // need to know about focused RemoteFrames use a separate accessor (to be
783 // added). 788 // added).
784 if (m_focusedFrame && m_focusedFrame->isRemoteFrame()) 789 if (m_focusedFrame && m_focusedFrame->isRemoteFrame())
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 if (m_isActive == active) 1113 if (m_isActive == active)
1109 return; 1114 return;
1110 1115
1111 m_isActive = active; 1116 m_isActive = active;
1112 1117
1113 Frame* frame = focusedOrMainFrame(); 1118 Frame* frame = focusedOrMainFrame();
1114 if (frame->isLocalFrame()) { 1119 if (frame->isLocalFrame()) {
1115 // Invalidate all custom scrollbars because they support the CSS 1120 // Invalidate all custom scrollbars because they support the CSS
1116 // window-active attribute. This should be applied to the entire page so 1121 // window-active attribute. This should be applied to the entire page so
1117 // we invalidate from the root FrameView instead of just the focused. 1122 // we invalidate from the root FrameView instead of just the focused.
1118 if (FrameView* view = toLocalFrame(frame)->localFrameRoot()->document()- >view()) 1123 LocalFrame* localFrame = toLocalFrame(frame);
1124 if (FrameView* view = localFrame->localFrameRoot()->document()->view()) {
1119 view->invalidateAllCustomScrollbarsOnActiveChanged(); 1125 view->invalidateAllCustomScrollbarsOnActiveChanged();
1120 toLocalFrame(frame)->selection().pageActivationChanged(); 1126 if (localFrame->selection().isAvailable())
yosin_UTC9 2016/07/21 07:22:36 This check should be parallel of |localFrame->loca
yosin_UTC9 2016/07/21 07:30:28 BTW, do we really need to change this for crbug.co
kochi 2016/07/21 09:00:33 Originally this was added for the case that appear
1127 localFrame->selection().pageActivationChanged();
1128 }
1121 } 1129 }
1122 } 1130 }
1123 1131
1124 static void updateFocusCandidateIfNeeded(WebFocusType type, const FocusCandidate & current, FocusCandidate& candidate, FocusCandidate& closest) 1132 static void updateFocusCandidateIfNeeded(WebFocusType type, const FocusCandidate & current, FocusCandidate& candidate, FocusCandidate& closest)
1125 { 1133 {
1126 DCHECK(candidate.visibleNode->isElementNode()); 1134 DCHECK(candidate.visibleNode->isElementNode());
1127 DCHECK(candidate.visibleNode->layoutObject()); 1135 DCHECK(candidate.visibleNode->layoutObject());
1128 1136
1129 // Ignore iframes that don't have a src attribute 1137 // Ignore iframes that don't have a src attribute
1130 if (frameOwnerElement(candidate) && (!frameOwnerElement(candidate)->contentF rame() || candidate.rect.isEmpty())) 1138 if (frameOwnerElement(candidate) && (!frameOwnerElement(candidate)->contentF rame() || candidate.rect.isEmpty()))
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 return consumed; 1316 return consumed;
1309 } 1317 }
1310 1318
1311 DEFINE_TRACE(FocusController) 1319 DEFINE_TRACE(FocusController)
1312 { 1320 {
1313 visitor->trace(m_page); 1321 visitor->trace(m_page);
1314 visitor->trace(m_focusedFrame); 1322 visitor->trace(m_focusedFrame);
1315 } 1323 }
1316 1324
1317 } // namespace blink 1325 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/Selection/selection-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698