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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLDialogElement.cpp

Issue 2715793003: Allow an element in shadow tree in <dialog> to be initially focused. (Closed)
Patch Set: Update the comment. Created 3 years, 9 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/html/dialog/shadowdom-in-dialog.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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
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 10 matching lines...) Expand all
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "core/html/HTMLDialogElement.h" 26 #include "core/html/HTMLDialogElement.h"
27 27
28 #include "bindings/core/v8/ExceptionState.h" 28 #include "bindings/core/v8/ExceptionState.h"
29 #include "core/dom/AXObjectCache.h" 29 #include "core/dom/AXObjectCache.h"
30 #include "core/dom/ExceptionCode.h" 30 #include "core/dom/ExceptionCode.h"
31 #include "core/dom/NodeTraversal.h" 31 #include "core/dom/shadow/FlatTreeTraversal.h"
32 #include "core/events/Event.h" 32 #include "core/events/Event.h"
33 #include "core/frame/FrameView.h" 33 #include "core/frame/FrameView.h"
34 #include "core/frame/UseCounter.h" 34 #include "core/frame/UseCounter.h"
35 #include "core/html/HTMLFormControlElement.h" 35 #include "core/html/HTMLFormControlElement.h"
36 #include "core/style/ComputedStyle.h" 36 #include "core/style/ComputedStyle.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 using namespace HTMLNames; 40 using namespace HTMLNames;
41 41
42 // This function chooses the focused element when show() or showModal() is 42 // This function chooses the focused element when show() or showModal() is
43 // invoked, as described in their spec. 43 // invoked, as described in their spec.
44 static void setFocusForDialog(HTMLDialogElement* dialog) { 44 static void setFocusForDialog(HTMLDialogElement* dialog) {
45 Element* focusableDescendant = 0; 45 Element* focusableDescendant = nullptr;
46 Node* next = 0; 46 Node* next = nullptr;
47 for (Node* node = dialog->firstChild(); node; node = next) { 47
48 if (isHTMLDialogElement(*node)) 48 // TODO(kochi): How to find focusable element inside Shadow DOM is not
49 next = NodeTraversal::nextSkippingChildren(*node, dialog); 49 // currently specified. This may change at any time.
50 else 50 // See crbug/383230 and https://github.com/whatwg/html/issue/2393 .
51 next = NodeTraversal::next(*node, dialog); 51 for (Node* node = FlatTreeTraversal::firstChild(*dialog); node; node = next) {
52 next = isHTMLDialogElement(*node)
53 ? FlatTreeTraversal::nextSkippingChildren(*node, dialog)
54 : FlatTreeTraversal::next(*node, dialog);
52 55
53 if (!node->isElementNode()) 56 if (!node->isElementNode())
54 continue; 57 continue;
55 Element* element = toElement(node); 58 Element* element = toElement(node);
56 if (element->isFormControlElement()) { 59 if (element->isFormControlElement()) {
57 HTMLFormControlElement* control = toHTMLFormControlElement(node); 60 HTMLFormControlElement* control = toHTMLFormControlElement(node);
58 if (control->isAutofocusable() && control->isFocusable()) { 61 if (control->isAutofocusable() && control->isFocusable()) {
59 control->focus(); 62 control->focus();
60 return; 63 return;
61 } 64 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void HTMLDialogElement::defaultEventHandler(Event* event) { 209 void HTMLDialogElement::defaultEventHandler(Event* event) {
207 if (event->type() == EventTypeNames::cancel) { 210 if (event->type() == EventTypeNames::cancel) {
208 closeDialog(); 211 closeDialog();
209 event->setDefaultHandled(); 212 event->setDefaultHandled();
210 return; 213 return;
211 } 214 }
212 HTMLElement::defaultEventHandler(event); 215 HTMLElement::defaultEventHandler(event);
213 } 216 }
214 217
215 } // namespace blink 218 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/html/dialog/shadowdom-in-dialog.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698