| 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 10 matching lines...) Expand all Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |