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 |
11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
13 * | 13 * |
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
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 "config.h" | 26 #include "config.h" |
27 #include "core/html/HTMLDialogElement.h" | 27 #include "core/html/HTMLDialogElement.h" |
28 | 28 |
29 #include "bindings/v8/ExceptionState.h" | 29 #include "bindings/v8/ExceptionState.h" |
| 30 #include "core/accessibility/AXObjectCache.h" |
30 #include "core/dom/ExceptionCode.h" | 31 #include "core/dom/ExceptionCode.h" |
31 #include "core/dom/NodeTraversal.h" | 32 #include "core/dom/NodeTraversal.h" |
32 #include "core/html/HTMLFormControlElement.h" | 33 #include "core/html/HTMLFormControlElement.h" |
33 #include "core/frame/FrameView.h" | 34 #include "core/frame/FrameView.h" |
34 #include "core/rendering/RenderBlock.h" | 35 #include "core/rendering/RenderBlock.h" |
35 #include "core/rendering/style/RenderStyle.h" | 36 #include "core/rendering/style/RenderStyle.h" |
36 | 37 |
37 namespace WebCore { | 38 namespace WebCore { |
38 | 39 |
39 using namespace HTMLNames; | 40 using namespace HTMLNames; |
(...skipping 10 matching lines...) Expand all Loading... |
50 return; | 51 return; |
51 } | 52 } |
52 } | 53 } |
53 if (node->hasTagName(dialogTag)) | 54 if (node->hasTagName(dialogTag)) |
54 next = NodeTraversal::nextSkippingChildren(node, dialog); | 55 next = NodeTraversal::nextSkippingChildren(node, dialog); |
55 else | 56 else |
56 next = NodeTraversal::next(node, dialog); | 57 next = NodeTraversal::next(node, dialog); |
57 } | 58 } |
58 } | 59 } |
59 | 60 |
| 61 static void inertSubtreesChanged(Document& document) |
| 62 { |
| 63 if (AXObjectCache* cache = document.existingAXObjectCache()) |
| 64 cache->handleInertSubtreesChanged(); |
| 65 } |
| 66 |
60 HTMLDialogElement::HTMLDialogElement(const QualifiedName& tagName, Document& doc
ument) | 67 HTMLDialogElement::HTMLDialogElement(const QualifiedName& tagName, Document& doc
ument) |
61 : HTMLElement(tagName, document) | 68 : HTMLElement(tagName, document) |
62 , m_centeringMode(Uninitialized) | 69 , m_centeringMode(Uninitialized) |
63 , m_centeredPosition(0) | 70 , m_centeredPosition(0) |
64 , m_returnValue("") | 71 , m_returnValue("") |
65 { | 72 { |
66 ASSERT(hasTagName(dialogTag)); | 73 ASSERT(hasTagName(dialogTag)); |
67 ScriptWrappable::init(this); | 74 ScriptWrappable::init(this); |
68 } | 75 } |
69 | 76 |
70 PassRefPtr<HTMLDialogElement> HTMLDialogElement::create(const QualifiedName& tag
Name, Document& document) | 77 PassRefPtr<HTMLDialogElement> HTMLDialogElement::create(const QualifiedName& tag
Name, Document& document) |
71 { | 78 { |
72 return adoptRef(new HTMLDialogElement(tagName, document)); | 79 return adoptRef(new HTMLDialogElement(tagName, document)); |
73 } | 80 } |
74 | 81 |
75 void HTMLDialogElement::close(const String& returnValue, ExceptionState& es) | 82 void HTMLDialogElement::close(const String& returnValue, ExceptionState& es) |
76 { | 83 { |
77 if (!fastHasAttribute(openAttr)) { | 84 if (!fastHasAttribute(openAttr)) { |
78 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 85 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
79 return; | 86 return; |
80 } | 87 } |
81 closeDialog(returnValue); | 88 closeDialog(returnValue); |
82 } | 89 } |
83 | 90 |
84 void HTMLDialogElement::closeDialog(const String& returnValue) | 91 void HTMLDialogElement::closeDialog(const String& returnValue) |
85 { | 92 { |
86 if (!fastHasAttribute(openAttr)) | 93 if (!fastHasAttribute(openAttr)) |
87 return; | 94 return; |
88 setBooleanAttribute(openAttr, false); | 95 setBooleanAttribute(openAttr, false); |
| 96 |
| 97 HTMLDialogElement* activeModalDialog = document().activeModalDialog(); |
89 document().removeFromTopLayer(this); | 98 document().removeFromTopLayer(this); |
| 99 if (activeModalDialog == this) |
| 100 inertSubtreesChanged(document()); |
90 | 101 |
91 if (!returnValue.isNull()) | 102 if (!returnValue.isNull()) |
92 m_returnValue = returnValue; | 103 m_returnValue = returnValue; |
93 | 104 |
94 dispatchScopedEvent(Event::create(EventTypeNames::close)); | 105 dispatchScopedEvent(Event::create(EventTypeNames::close)); |
95 } | 106 } |
96 | 107 |
97 void HTMLDialogElement::forceLayoutForCentering() | 108 void HTMLDialogElement::forceLayoutForCentering() |
98 { | 109 { |
99 m_centeringMode = Uninitialized; | 110 m_centeringMode = Uninitialized; |
(...skipping 10 matching lines...) Expand all Loading... |
110 forceLayoutForCentering(); | 121 forceLayoutForCentering(); |
111 } | 122 } |
112 | 123 |
113 void HTMLDialogElement::showModal(ExceptionState& es) | 124 void HTMLDialogElement::showModal(ExceptionState& es) |
114 { | 125 { |
115 if (fastHasAttribute(openAttr) || !inDocument()) { | 126 if (fastHasAttribute(openAttr) || !inDocument()) { |
116 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 127 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
117 return; | 128 return; |
118 } | 129 } |
119 document().addToTopLayer(this); | 130 document().addToTopLayer(this); |
| 131 inertSubtreesChanged(document()); |
120 setBooleanAttribute(openAttr, true); | 132 setBooleanAttribute(openAttr, true); |
121 | 133 |
122 runAutofocus(this); | 134 runAutofocus(this); |
123 forceLayoutForCentering(); | 135 forceLayoutForCentering(); |
124 } | 136 } |
125 | 137 |
126 void HTMLDialogElement::setCentered(LayoutUnit centeredPosition) | 138 void HTMLDialogElement::setCentered(LayoutUnit centeredPosition) |
127 { | 139 { |
128 ASSERT(m_centeringMode == Uninitialized); | 140 ASSERT(m_centeringMode == Uninitialized); |
129 m_centeredPosition = centeredPosition; | 141 m_centeredPosition = centeredPosition; |
(...skipping 27 matching lines...) Expand all Loading... |
157 } | 169 } |
158 | 170 |
159 bool HTMLDialogElement::shouldBeReparentedUnderRenderView(const RenderStyle* sty
le) const | 171 bool HTMLDialogElement::shouldBeReparentedUnderRenderView(const RenderStyle* sty
le) const |
160 { | 172 { |
161 if (style && style->position() == AbsolutePosition) | 173 if (style && style->position() == AbsolutePosition) |
162 return true; | 174 return true; |
163 return Element::shouldBeReparentedUnderRenderView(style); | 175 return Element::shouldBeReparentedUnderRenderView(style); |
164 } | 176 } |
165 | 177 |
166 } // namespace WebCore | 178 } // namespace WebCore |
OLD | NEW |