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

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 the build break by replacing WebViewImpl object with WebViewBase Created 3 years, 7 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/FrameView.h" 44 #include "core/frame/FrameView.h"
45 #include "core/frame/LocalDOMWindow.h" 45 #include "core/frame/LocalDOMWindow.h"
46 #include "core/frame/LocalFrame.h" 46 #include "core/frame/LocalFrame.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 if (!element->IsFormControlElement() &&
1074 !ToHTMLElement(element)->isContentEditableForBinding())
1075 return nullptr;
1076
1077 HTMLFormElement* form_owner = nullptr;
1078 if (ToHTMLElement(element)->isContentEditableForBinding())
1079 form_owner = Traversal<HTMLFormElement>::FirstAncestor(*element);
1080 else
1081 form_owner = ToHTMLFormControlElement(element)->formOwner();
1082
1083 if (!form_owner)
1084 return nullptr;
1085
1086 Element* next_element = element;
1087 for (next_element = FindFocusableElement(focus_type, *next_element);
1088 next_element;
1089 next_element = FindFocusableElement(focus_type, *next_element)) {
1090 if (ToHTMLElement(next_element)->isContentEditableForBinding() &&
1091 next_element->IsDescendantOf(form_owner))
1092 return next_element;
1093 if (!next_element->IsFormControlElement())
1094 continue;
1095 HTMLFormControlElement* form_element =
1096 ToHTMLFormControlElement(next_element);
1097 if (form_element->formOwner() != form_owner ||
1098 form_element->IsDisabledOrReadOnly())
1099 continue;
1100 LayoutObject* layout = next_element->GetLayoutObject();
1101 if (layout && layout->IsTextControl()) {
1102 // TODO(ajith.v) Extend it for select elements, radio buttons and check
1103 // boxes
1104 return next_element;
1105 }
1106 }
1107 return nullptr;
1108 }
1109
1069 Element* FocusController::FindFocusableElementInShadowHost( 1110 Element* FocusController::FindFocusableElementInShadowHost(
1070 const Element& shadow_host) { 1111 const Element& shadow_host) {
1071 DCHECK(shadow_host.AuthorShadowRoot()); 1112 DCHECK(shadow_host.AuthorShadowRoot());
1072 ScopedFocusNavigation scope = 1113 ScopedFocusNavigation scope =
1073 ScopedFocusNavigation::OwnedByShadowHost(shadow_host); 1114 ScopedFocusNavigation::OwnedByShadowHost(shadow_host);
1074 return FindFocusableElementAcrossFocusScopes(kWebFocusTypeForward, scope); 1115 return FindFocusableElementAcrossFocusScopes(kWebFocusTypeForward, scope);
1075 } 1116 }
1076 1117
1077 static bool RelinquishesEditingFocus(const Element& element) { 1118 static bool RelinquishesEditingFocus(const Element& element) {
1078 DCHECK(HasEditableStyle(element)); 1119 DCHECK(HasEditableStyle(element));
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 it->FocusedFrameChanged(); 1451 it->FocusedFrameChanged();
1411 } 1452 }
1412 1453
1413 DEFINE_TRACE(FocusController) { 1454 DEFINE_TRACE(FocusController) {
1414 visitor->Trace(page_); 1455 visitor->Trace(page_);
1415 visitor->Trace(focused_frame_); 1456 visitor->Trace(focused_frame_);
1416 visitor->Trace(focus_changed_observers_); 1457 visitor->Trace(focus_changed_observers_);
1417 } 1458 }
1418 1459
1419 } // namespace blink 1460 } // 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