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

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

Issue 2695013010: HTMLDialogElement: actually traverse through shadow DOM when deciding which element to focus initia… (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | 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 = 0;
46 Node* next = 0; 46 Node* next = 0;
47 for (Node* node = dialog->firstChild(); node; node = next) { 47 for (Node* node = FlatTreeTraversal::firstChild(*dialog); node; node = next) {
48 if (isHTMLDialogElement(*node)) 48 next = isHTMLDialogElement(*node)
49 next = NodeTraversal::nextSkippingChildren(*node, dialog); 49 ? FlatTreeTraversal::nextSkippingChildren(*node, dialog)
50 else 50 : FlatTreeTraversal::next(*node, dialog);
51 next = NodeTraversal::next(*node, dialog);
52 51
53 if (!node->isElementNode()) 52 if (!node->isElementNode())
54 continue; 53 continue;
55 Element* element = toElement(node); 54 Element* element = toElement(node);
56 if (element->isFormControlElement()) { 55 if (element->isFormControlElement()) {
57 HTMLFormControlElement* control = toHTMLFormControlElement(node); 56 HTMLFormControlElement* control = toHTMLFormControlElement(node);
58 if (control->isAutofocusable() && control->isFocusable()) { 57 if (control->isAutofocusable() && control->isFocusable()) {
59 control->focus(); 58 control->focus();
60 return; 59 return;
61 } 60 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void HTMLDialogElement::defaultEventHandler(Event* event) { 205 void HTMLDialogElement::defaultEventHandler(Event* event) {
207 if (event->type() == EventTypeNames::cancel) { 206 if (event->type() == EventTypeNames::cancel) {
208 closeDialog(); 207 closeDialog();
209 event->setDefaultHandled(); 208 event->setDefaultHandled();
210 return; 209 return;
211 } 210 }
212 HTMLElement::defaultEventHandler(event); 211 HTMLElement::defaultEventHandler(event);
213 } 212 }
214 213
215 } // namespace blink 214 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698