Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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->selection().isAvailable()) | |
|
yosin_UTC9
2016/07/21 06:10:10
It is better to use |newFocusedFrame && newFocused
kochi
2016/07/21 06:55:26
Done.
| |
| 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 Loading... | |
| 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 if (FrameView* view = toLocalFrame(frame)->localFrameRoot()->document()- >view()) { |
| 1119 view->invalidateAllCustomScrollbarsOnActiveChanged(); | 1124 view->invalidateAllCustomScrollbarsOnActiveChanged(); |
| 1120 toLocalFrame(frame)->selection().pageActivationChanged(); | 1125 toLocalFrame(frame)->selection().pageActivationChanged(); |
|
yosin_UTC9
2016/07/21 06:10:10
Can we assume that |localFrameRoot()->view() != nu
kochi
2016/07/21 06:55:26
Agree that |->view()| doesn't imply |selection().i
| |
| 1126 } | |
| 1121 } | 1127 } |
| 1122 } | 1128 } |
| 1123 | 1129 |
| 1124 static void updateFocusCandidateIfNeeded(WebFocusType type, const FocusCandidate & current, FocusCandidate& candidate, FocusCandidate& closest) | 1130 static void updateFocusCandidateIfNeeded(WebFocusType type, const FocusCandidate & current, FocusCandidate& candidate, FocusCandidate& closest) |
| 1125 { | 1131 { |
| 1126 DCHECK(candidate.visibleNode->isElementNode()); | 1132 DCHECK(candidate.visibleNode->isElementNode()); |
| 1127 DCHECK(candidate.visibleNode->layoutObject()); | 1133 DCHECK(candidate.visibleNode->layoutObject()); |
| 1128 | 1134 |
| 1129 // Ignore iframes that don't have a src attribute | 1135 // Ignore iframes that don't have a src attribute |
| 1130 if (frameOwnerElement(candidate) && (!frameOwnerElement(candidate)->contentF rame() || candidate.rect.isEmpty())) | 1136 if (frameOwnerElement(candidate) && (!frameOwnerElement(candidate)->contentF rame() || candidate.rect.isEmpty())) |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1308 return consumed; | 1314 return consumed; |
| 1309 } | 1315 } |
| 1310 | 1316 |
| 1311 DEFINE_TRACE(FocusController) | 1317 DEFINE_TRACE(FocusController) |
| 1312 { | 1318 { |
| 1313 visitor->trace(m_page); | 1319 visitor->trace(m_page); |
| 1314 visitor->trace(m_focusedFrame); | 1320 visitor->trace(m_focusedFrame); |
| 1315 } | 1321 } |
| 1316 | 1322 |
| 1317 } // namespace blink | 1323 } // namespace blink |
| OLD | NEW |