OLD | NEW |
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 29 matching lines...) Expand all Loading... |
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* focusable_descendant = nullptr; | 45 Element* focusable_descendant = nullptr; |
46 Node* next = nullptr; | 46 Node* next = nullptr; |
47 | 47 |
48 // TODO(kochi): How to find focusable element inside Shadow DOM is not | 48 // TODO(kochi): How to find focusable element inside Shadow DOM is not |
49 // currently specified. This may change at any time. | 49 // currently specified. This may change at any time. |
50 // See crbug/383230 and https://github.com/whatwg/html/issue/2393 . | 50 // See crbug/383230 and https://github.com/whatwg/html/issues/2393 . |
51 for (Node* node = FlatTreeTraversal::FirstChild(*dialog); node; node = next) { | 51 for (Node* node = FlatTreeTraversal::FirstChild(*dialog); node; node = next) { |
52 next = isHTMLDialogElement(*node) | 52 next = isHTMLDialogElement(*node) |
53 ? FlatTreeTraversal::NextSkippingChildren(*node, dialog) | 53 ? FlatTreeTraversal::NextSkippingChildren(*node, dialog) |
54 : FlatTreeTraversal::Next(*node, dialog); | 54 : FlatTreeTraversal::Next(*node, dialog); |
55 | 55 |
56 if (!node->IsElementNode()) | 56 if (!node->IsElementNode()) |
57 continue; | 57 continue; |
58 Element* element = ToElement(node); | 58 Element* element = ToElement(node); |
59 if (element->IsFormControlElement()) { | 59 if (element->IsFormControlElement()) { |
60 HTMLFormControlElement* control = ToHTMLFormControlElement(node); | 60 HTMLFormControlElement* control = ToHTMLFormControlElement(node); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 void HTMLDialogElement::DefaultEventHandler(Event* event) { | 209 void HTMLDialogElement::DefaultEventHandler(Event* event) { |
210 if (event->type() == EventTypeNames::cancel) { | 210 if (event->type() == EventTypeNames::cancel) { |
211 CloseDialog(); | 211 CloseDialog(); |
212 event->SetDefaultHandled(); | 212 event->SetDefaultHandled(); |
213 return; | 213 return; |
214 } | 214 } |
215 HTMLElement::DefaultEventHandler(event); | 215 HTMLElement::DefaultEventHandler(event); |
216 } | 216 } |
217 | 217 |
218 } // namespace blink | 218 } // namespace blink |
OLD | NEW |