| 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 16 matching lines...) Expand all Loading... |
| 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/Fullscreen.h" | 31 #include "core/dom/Fullscreen.h" |
| 32 #include "core/dom/shadow/FlatTreeTraversal.h" | 32 #include "core/dom/shadow/FlatTreeTraversal.h" |
| 33 #include "core/events/Event.h" | 33 #include "core/events/Event.h" |
| 34 #include "core/frame/LocalFrameView.h" | 34 #include "core/frame/LocalFrameView.h" |
| 35 #include "core/frame/UseCounter.h" | 35 #include "core/frame/UseCounter.h" |
| 36 #include "core/html/HTMLFormControlElement.h" | 36 #include "core/html/HTMLFormControlElement.h" |
| 37 #include "core/html/HTMLFrameOwnerElement.h" |
| 37 #include "core/style/ComputedStyle.h" | 38 #include "core/style/ComputedStyle.h" |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| 41 using namespace HTMLNames; | 42 using namespace HTMLNames; |
| 42 | 43 |
| 43 // This function chooses the focused element when show() or showModal() is | 44 // This function chooses the focused element when show() or showModal() is |
| 44 // invoked, as described in their spec. | 45 // invoked, as described in their spec. |
| 45 static void SetFocusForDialog(HTMLDialogElement* dialog) { | 46 static void SetFocusForDialog(HTMLDialogElement* dialog) { |
| 46 Element* focusable_descendant = nullptr; | 47 Element* focusable_descendant = nullptr; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 75 | 76 |
| 76 if (dialog->IsFocusable()) { | 77 if (dialog->IsFocusable()) { |
| 77 dialog->focus(); | 78 dialog->focus(); |
| 78 return; | 79 return; |
| 79 } | 80 } |
| 80 | 81 |
| 81 dialog->GetDocument().ClearFocusedElement(); | 82 dialog->GetDocument().ClearFocusedElement(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 static void InertSubtreesChanged(Document& document) { | 85 static void InertSubtreesChanged(Document& document) { |
| 86 if (document.GetFrame()) { |
| 87 // SetIsInert recurses through subframes to propagate the inert bit as |
| 88 // needed. |
| 89 document.GetFrame()->SetIsInert(document.LocalOwner() && |
| 90 document.LocalOwner()->IsInert()); |
| 91 } |
| 92 |
| 85 // When a modal dialog opens or closes, nodes all over the accessibility | 93 // When a modal dialog opens or closes, nodes all over the accessibility |
| 86 // tree can change inertness which means they must be added or removed from | 94 // tree can change inertness which means they must be added or removed from |
| 87 // the tree. The most foolproof way is to clear the entire tree and rebuild | 95 // the tree. The most foolproof way is to clear the entire tree and rebuild |
| 88 // it, though a more clever way is probably possible. | 96 // it, though a more clever way is probably possible. |
| 89 document.ClearAXObjectCache(); | 97 document.ClearAXObjectCache(); |
| 90 if (AXObjectCache* cache = document.AxObjectCache()) | 98 if (AXObjectCache* cache = document.AxObjectCache()) |
| 91 cache->ChildrenChanged(&document); | 99 cache->ChildrenChanged(&document); |
| 92 } | 100 } |
| 93 | 101 |
| 94 inline HTMLDialogElement::HTMLDialogElement(Document& document) | 102 inline HTMLDialogElement::HTMLDialogElement(Document& document) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // is thrown away. | 190 // is thrown away. |
| 183 InertSubtreesChanged(GetDocument()); | 191 InertSubtreesChanged(GetDocument()); |
| 184 | 192 |
| 185 ForceLayoutForCentering(); | 193 ForceLayoutForCentering(); |
| 186 SetFocusForDialog(this); | 194 SetFocusForDialog(this); |
| 187 } | 195 } |
| 188 | 196 |
| 189 void HTMLDialogElement::RemovedFrom(ContainerNode* insertion_point) { | 197 void HTMLDialogElement::RemovedFrom(ContainerNode* insertion_point) { |
| 190 HTMLElement::RemovedFrom(insertion_point); | 198 HTMLElement::RemovedFrom(insertion_point); |
| 191 SetNotCentered(); | 199 SetNotCentered(); |
| 192 // FIXME: We should call inertSubtreesChanged() here. | 200 InertSubtreesChanged(GetDocument()); |
| 193 } | 201 } |
| 194 | 202 |
| 195 void HTMLDialogElement::SetCentered(LayoutUnit centered_position) { | 203 void HTMLDialogElement::SetCentered(LayoutUnit centered_position) { |
| 196 DCHECK_EQ(centering_mode_, kNeedsCentering); | 204 DCHECK_EQ(centering_mode_, kNeedsCentering); |
| 197 centered_position_ = centered_position; | 205 centered_position_ = centered_position; |
| 198 centering_mode_ = kCentered; | 206 centering_mode_ = kCentered; |
| 199 } | 207 } |
| 200 | 208 |
| 201 void HTMLDialogElement::SetNotCentered() { | 209 void HTMLDialogElement::SetNotCentered() { |
| 202 centering_mode_ = kNotCentered; | 210 centering_mode_ = kNotCentered; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 216 void HTMLDialogElement::DefaultEventHandler(Event* event) { | 224 void HTMLDialogElement::DefaultEventHandler(Event* event) { |
| 217 if (event->type() == EventTypeNames::cancel) { | 225 if (event->type() == EventTypeNames::cancel) { |
| 218 CloseDialog(); | 226 CloseDialog(); |
| 219 event->SetDefaultHandled(); | 227 event->SetDefaultHandled(); |
| 220 return; | 228 return; |
| 221 } | 229 } |
| 222 HTMLElement::DefaultEventHandler(event); | 230 HTMLElement::DefaultEventHandler(event); |
| 223 } | 231 } |
| 224 | 232 |
| 225 } // namespace blink | 233 } // namespace blink |
| OLD | NEW |