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

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: Rebased the patch from TOT 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) {
1073 element->GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
1074 if (!element->IsHTMLElement())
1075 return nullptr;
1076
1077 if (!element->IsFormControlElement() &&
1078 !ToHTMLElement(element)->isContentEditableForBinding())
1079 return nullptr;
1080
1081 HTMLFormElement* form_owner = nullptr;
1082 if (ToHTMLElement(element)->isContentEditableForBinding())
1083 form_owner = Traversal<HTMLFormElement>::FirstAncestor(*element);
1084 else
1085 form_owner = ToHTMLFormControlElement(element)->formOwner();
1086
1087 if (!form_owner)
1088 return nullptr;
1089
1090 Element* next_element = element;
1091 for (next_element = FindFocusableElement(focus_type, *next_element);
1092 next_element;
1093 next_element = FindFocusableElement(focus_type, *next_element)) {
1094 if (ToHTMLElement(next_element)->isContentEditableForBinding() &&
1095 next_element->IsDescendantOf(form_owner))
1096 return next_element;
1097 if (!next_element->IsFormControlElement())
1098 continue;
1099 HTMLFormControlElement* form_element =
1100 ToHTMLFormControlElement(next_element);
1101 if (form_element->formOwner() != form_owner ||
1102 form_element->IsDisabledOrReadOnly())
1103 continue;
1104 LayoutObject* layout = next_element->GetLayoutObject();
1105 if (layout && layout->IsTextControl()) {
1106 // TODO(ajith.v) Extend it for select elements, radio buttons and check
1107 // boxes
1108 return next_element;
1109 }
1110 }
1111 return nullptr;
1112 }
1113
1069 Element* FocusController::FindFocusableElementInShadowHost( 1114 Element* FocusController::FindFocusableElementInShadowHost(
1070 const Element& shadow_host) { 1115 const Element& shadow_host) {
1071 DCHECK(shadow_host.AuthorShadowRoot()); 1116 DCHECK(shadow_host.AuthorShadowRoot());
1072 ScopedFocusNavigation scope = 1117 ScopedFocusNavigation scope =
1073 ScopedFocusNavigation::OwnedByShadowHost(shadow_host); 1118 ScopedFocusNavigation::OwnedByShadowHost(shadow_host);
1074 return FindFocusableElementAcrossFocusScopes(kWebFocusTypeForward, scope); 1119 return FindFocusableElementAcrossFocusScopes(kWebFocusTypeForward, scope);
1075 } 1120 }
1076 1121
1077 static bool RelinquishesEditingFocus(const Element& element) { 1122 static bool RelinquishesEditingFocus(const Element& element) {
1078 DCHECK(HasEditableStyle(element)); 1123 DCHECK(HasEditableStyle(element));
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 it->FocusedFrameChanged(); 1455 it->FocusedFrameChanged();
1411 } 1456 }
1412 1457
1413 DEFINE_TRACE(FocusController) { 1458 DEFINE_TRACE(FocusController) {
1414 visitor->Trace(page_); 1459 visitor->Trace(page_);
1415 visitor->Trace(focused_frame_); 1460 visitor->Trace(focused_frame_);
1416 visitor->Trace(focus_changed_observers_); 1461 visitor->Trace(focus_changed_observers_);
1417 } 1462 }
1418 1463
1419 } // namespace blink 1464 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/FocusController.h ('k') | third_party/WebKit/Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698