| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 for (Node* node = dialog->firstChild(); node; node = next) { | 47 for (Node* node = dialog->firstChild(); node; node = next) { |
| 48 if (isHTMLDialogElement(*node)) | 48 if (isHTMLDialogElement(*node)) |
| 49 next = NodeTraversal::nextSkippingChildren(*node, dialog); | 49 next = NodeTraversal::nextSkippingChildren(*node, dialog); |
| 50 else | 50 else |
| 51 next = NodeTraversal::next(*node, dialog); | 51 next = NodeTraversal::next(*node, dialog); |
| 52 | 52 |
| 53 if (!node->isElementNode()) | 53 if (!node->isElementNode()) |
| 54 continue; | 54 continue; |
| 55 Element* element = toElement(node); | 55 Element* element = toElement(node); |
| 56 if (element->isFormControlElement()) { | 56 if (element->isFormControlElement()) { |
| 57 // TODO(dbeam): <button tabindex="-1"> or <a href="..." tabindex="-1"> |
| 58 // should not have precedence over <div tabindex="0"> but currently do. |
| 57 HTMLFormControlElement* control = toHTMLFormControlElement(node); | 59 HTMLFormControlElement* control = toHTMLFormControlElement(node); |
| 58 if (control->isAutofocusable() && control->isFocusable()) { | 60 if (control->isAutofocusable() && control->isFocusable()) { |
| 59 control->focus(); | 61 control->focus(); |
| 60 return; | 62 return; |
| 61 } | 63 } |
| 62 } | 64 } |
| 63 if (!focusableDescendant && element->isFocusable()) | 65 if (!focusableDescendant && element->isKeyboardFocusable()) |
| 64 focusableDescendant = element; | 66 focusableDescendant = element; |
| 65 } | 67 } |
| 66 | 68 |
| 67 if (focusableDescendant) { | 69 if (focusableDescendant) { |
| 68 focusableDescendant->focus(); | 70 focusableDescendant->focus(); |
| 69 return; | 71 return; |
| 70 } | 72 } |
| 71 | 73 |
| 74 // TODO(dbeam): should this be isKeyboardFocusable() instead? |
| 72 if (dialog->isFocusable()) { | 75 if (dialog->isFocusable()) { |
| 73 dialog->focus(); | 76 dialog->focus(); |
| 74 return; | 77 return; |
| 75 } | 78 } |
| 76 | 79 |
| 77 dialog->document().clearFocusedElement(); | 80 dialog->document().clearFocusedElement(); |
| 78 } | 81 } |
| 79 | 82 |
| 80 static void inertSubtreesChanged(Document& document) { | 83 static void inertSubtreesChanged(Document& document) { |
| 81 // When a modal dialog opens or closes, nodes all over the accessibility | 84 // When a modal dialog opens or closes, nodes all over the accessibility |
| (...skipping 124 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 |