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

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

Issue 2839993002: [Android] Adding Smart GO/NEXT feature in Chrome (Closed)
Patch Set: Fixed ImeTest#testSelectActionBarClearedOnTappingOutsideInput flaky failure Created 3 years, 6 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
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 29 matching lines...) Expand all
40 #include "core/editing/FrameSelection.h" 40 #include "core/editing/FrameSelection.h"
41 #include "core/editing/InputMethodController.h" 41 #include "core/editing/InputMethodController.h"
42 #include "core/events/Event.h" 42 #include "core/events/Event.h"
43 #include "core/frame/FrameClient.h" 43 #include "core/frame/FrameClient.h"
44 #include "core/frame/LocalDOMWindow.h" 44 #include "core/frame/LocalDOMWindow.h"
45 #include "core/frame/LocalFrame.h" 45 #include "core/frame/LocalFrame.h"
46 #include "core/frame/LocalFrameView.h" 46 #include "core/frame/LocalFrameView.h"
47 #include "core/frame/RemoteFrame.h" 47 #include "core/frame/RemoteFrame.h"
48 #include "core/frame/Settings.h" 48 #include "core/frame/Settings.h"
49 #include "core/html/HTMLAreaElement.h" 49 #include "core/html/HTMLAreaElement.h"
50 #include "core/html/HTMLFormElement.h"
50 #include "core/html/HTMLImageElement.h" 51 #include "core/html/HTMLImageElement.h"
51 #include "core/html/HTMLPlugInElement.h" 52 #include "core/html/HTMLPlugInElement.h"
52 #include "core/html/HTMLShadowElement.h" 53 #include "core/html/HTMLShadowElement.h"
53 #include "core/html/HTMLSlotElement.h" 54 #include "core/html/HTMLSlotElement.h"
54 #include "core/html/TextControlElement.h" 55 #include "core/html/TextControlElement.h"
55 #include "core/input/EventHandler.h" 56 #include "core/input/EventHandler.h"
56 #include "core/layout/HitTestResult.h" 57 #include "core/layout/HitTestResult.h"
58 #include "core/layout/LayoutObject.h"
57 #include "core/page/ChromeClient.h" 59 #include "core/page/ChromeClient.h"
58 #include "core/page/FocusChangedObserver.h" 60 #include "core/page/FocusChangedObserver.h"
59 #include "core/page/FrameTree.h" 61 #include "core/page/FrameTree.h"
60 #include "core/page/Page.h" 62 #include "core/page/Page.h"
61 #include "core/page/SpatialNavigation.h" 63 #include "core/page/SpatialNavigation.h"
62 64
63 #include <limits> 65 #include <limits>
64 66
65 namespace blink { 67 namespace blink {
66 68
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 } 1061 }
1060 1062
1061 Element* FocusController::FindFocusableElement(WebFocusType type, 1063 Element* FocusController::FindFocusableElement(WebFocusType type,
1062 Element& element) { 1064 Element& element) {
1063 // FIXME: No spacial navigation code yet. 1065 // FIXME: No spacial navigation code yet.
1064 DCHECK(type == kWebFocusTypeForward || type == kWebFocusTypeBackward); 1066 DCHECK(type == kWebFocusTypeForward || type == kWebFocusTypeBackward);
1065 ScopedFocusNavigation scope = ScopedFocusNavigation::CreateFor(element); 1067 ScopedFocusNavigation scope = ScopedFocusNavigation::CreateFor(element);
1066 return FindFocusableElementAcrossFocusScopes(type, scope); 1068 return FindFocusableElementAcrossFocusScopes(type, scope);
1067 } 1069 }
1068 1070
1071 Element* FocusController::NextFocusableElementInForm(Element* element,
1072 WebFocusType focus_type) {
Changwan Ryu 2017/06/09 19:34:30 could you try adding element->GetDocument().Update
AKVT 2017/06/10 03:37:56 I had tried to call NeedsLayoutTreeUpdateForNode e
AKVT 2017/06/12 12:21:24 Done. Thank you.
1073 if (!element->IsHTMLElement())
1074 return nullptr;
1075
1076 if (!element->IsFormControlElement() &&
1077 !ToHTMLElement(element)->isContentEditableForBinding())
1078 return nullptr;
1079
1080 HTMLFormElement* form_owner = nullptr;
1081 if (ToHTMLElement(element)->isContentEditableForBinding())
1082 form_owner = Traversal<HTMLFormElement>::FirstAncestor(*element);
1083 else
1084 form_owner = ToHTMLFormControlElement(element)->formOwner();
1085
1086 if (!form_owner)
1087 return nullptr;
1088
1089 Element* next_element = element;
1090 for (next_element = FindFocusableElement(focus_type, *next_element);
1091 next_element;
1092 next_element = FindFocusableElement(focus_type, *next_element)) {
1093 if (ToHTMLElement(next_element)->isContentEditableForBinding() &&
1094 next_element->IsDescendantOf(form_owner))
1095 return next_element;
1096 if (!next_element->IsFormControlElement())
1097 continue;
1098 HTMLFormControlElement* form_element =
1099 ToHTMLFormControlElement(next_element);
1100 if (form_element->formOwner() != form_owner ||
1101 form_element->IsDisabledOrReadOnly())
1102 continue;
1103 LayoutObject* layout = next_element->GetLayoutObject();
1104 if (layout && layout->IsTextControl()) {
1105 // TODO(ajith.v) Extend it for select elements, radio buttons and check
1106 // boxes
1107 return next_element;
1108 }
1109 }
1110 return nullptr;
1111 }
1112
1069 Element* FocusController::FindFocusableElementInShadowHost( 1113 Element* FocusController::FindFocusableElementInShadowHost(
1070 const Element& shadow_host) { 1114 const Element& shadow_host) {
1071 DCHECK(shadow_host.AuthorShadowRoot()); 1115 DCHECK(shadow_host.AuthorShadowRoot());
1072 ScopedFocusNavigation scope = 1116 ScopedFocusNavigation scope =
1073 ScopedFocusNavigation::OwnedByShadowHost(shadow_host); 1117 ScopedFocusNavigation::OwnedByShadowHost(shadow_host);
1074 return FindFocusableElementAcrossFocusScopes(kWebFocusTypeForward, scope); 1118 return FindFocusableElementAcrossFocusScopes(kWebFocusTypeForward, scope);
1075 } 1119 }
1076 1120
1077 static bool RelinquishesEditingFocus(const Element& element) { 1121 static bool RelinquishesEditingFocus(const Element& element) {
1078 DCHECK(HasEditableStyle(element)); 1122 DCHECK(HasEditableStyle(element));
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 it->FocusedFrameChanged(); 1454 it->FocusedFrameChanged();
1411 } 1455 }
1412 1456
1413 DEFINE_TRACE(FocusController) { 1457 DEFINE_TRACE(FocusController) {
1414 visitor->Trace(page_); 1458 visitor->Trace(page_);
1415 visitor->Trace(focused_frame_); 1459 visitor->Trace(focused_frame_);
1416 visitor->Trace(focus_changed_observers_); 1460 visitor->Trace(focus_changed_observers_);
1417 } 1461 }
1418 1462
1419 } // namespace blink 1463 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698