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 76 matching lines...) Loading... |
87 topDocument->clearAXObjectCache(); | 87 topDocument->clearAXObjectCache(); |
88 if (AXObjectCache* cache = topDocument->axObjectCache()) | 88 if (AXObjectCache* cache = topDocument->axObjectCache()) |
89 cache->childrenChanged(cache->getOrCreate(topDocument)); | 89 cache->childrenChanged(cache->getOrCreate(topDocument)); |
90 } | 90 } |
91 | 91 |
92 HTMLDialogElement::HTMLDialogElement(Document& document) | 92 HTMLDialogElement::HTMLDialogElement(Document& document) |
93 : HTMLElement(dialogTag, document) | 93 : HTMLElement(dialogTag, document) |
94 , m_centeringMode(Uninitialized) | 94 , m_centeringMode(Uninitialized) |
95 , m_centeredPosition(0) | 95 , m_centeredPosition(0) |
96 , m_returnValue("") | 96 , m_returnValue("") |
97 , m_modal(false) | |
98 { | 97 { |
99 ScriptWrappable::init(this); | 98 ScriptWrappable::init(this); |
100 } | 99 } |
101 | 100 |
102 PassRefPtr<HTMLDialogElement> HTMLDialogElement::create(Document& document) | 101 PassRefPtr<HTMLDialogElement> HTMLDialogElement::create(Document& document) |
103 { | 102 { |
104 return adoptRef(new HTMLDialogElement(document)); | 103 return adoptRef(new HTMLDialogElement(document)); |
105 } | 104 } |
106 | 105 |
107 void HTMLDialogElement::close(const String& returnValue, ExceptionState& excepti
onState) | 106 void HTMLDialogElement::close(const String& returnValue, ExceptionState& excepti
onState) |
108 { | 107 { |
109 if (!fastHasAttribute(openAttr)) { | 108 if (!fastHasAttribute(openAttr)) { |
110 exceptionState.throwDOMException(InvalidStateError, "The element does no
t have an 'open' attribute, and therefore cannot be closed."); | 109 exceptionState.throwDOMException(InvalidStateError, "The element does no
t have an 'open' attribute, and therefore cannot be closed."); |
111 return; | 110 return; |
112 } | 111 } |
113 closeDialog(returnValue); | 112 closeDialog(returnValue); |
114 } | 113 } |
115 | 114 |
116 void HTMLDialogElement::removedFrom(ContainerNode* insertionPoint) | |
117 { | |
118 // FIXME: We should call inertSubtreesChanged if needed here. | |
119 m_modal = false; | |
120 HTMLElement::removedFrom(insertionPoint); | |
121 } | |
122 | |
123 void HTMLDialogElement::closeDialog(const String& returnValue) | 115 void HTMLDialogElement::closeDialog(const String& returnValue) |
124 { | 116 { |
125 if (!fastHasAttribute(openAttr)) | 117 if (!fastHasAttribute(openAttr)) |
126 return; | 118 return; |
127 setBooleanAttribute(openAttr, false); | 119 setBooleanAttribute(openAttr, false); |
128 | 120 |
129 HTMLDialogElement* activeModalDialog = document().activeModalDialog(); | 121 HTMLDialogElement* activeModalDialog = document().activeModalDialog(); |
130 m_modal = false; | |
131 document().removeFromTopLayer(this); | 122 document().removeFromTopLayer(this); |
132 if (activeModalDialog == this) | 123 if (activeModalDialog == this) |
133 inertSubtreesChanged(document()); | 124 inertSubtreesChanged(document()); |
134 | 125 |
135 if (!returnValue.isNull()) | 126 if (!returnValue.isNull()) |
136 m_returnValue = returnValue; | 127 m_returnValue = returnValue; |
137 | 128 |
138 dispatchScopedEvent(Event::create(EventTypeNames::close)); | 129 dispatchScopedEvent(Event::create(EventTypeNames::close)); |
139 } | 130 } |
140 | 131 |
(...skipping 17 matching lines...) Loading... |
158 { | 149 { |
159 if (fastHasAttribute(openAttr)) { | 150 if (fastHasAttribute(openAttr)) { |
160 exceptionState.throwDOMException(InvalidStateError, "The element already
has an 'open' attribute, and therefore cannot be opened modally."); | 151 exceptionState.throwDOMException(InvalidStateError, "The element already
has an 'open' attribute, and therefore cannot be opened modally."); |
161 return; | 152 return; |
162 } | 153 } |
163 if (!inDocument()) { | 154 if (!inDocument()) { |
164 exceptionState.throwDOMException(InvalidStateError, "The element is not
in a Document."); | 155 exceptionState.throwDOMException(InvalidStateError, "The element is not
in a Document."); |
165 return; | 156 return; |
166 } | 157 } |
167 | 158 |
168 m_modal = true; | |
169 document().addToTopLayer(this); | 159 document().addToTopLayer(this); |
170 setBooleanAttribute(openAttr, true); | 160 setBooleanAttribute(openAttr, true); |
171 | 161 |
172 // Throw away the AX cache first, so the subsequent steps don't have a chanc
e of queuing up | 162 // Throw away the AX cache first, so the subsequent steps don't have a chanc
e of queuing up |
173 // AX events on objects that would be invalidated when the cache is thrown a
way. | 163 // AX events on objects that would be invalidated when the cache is thrown a
way. |
174 inertSubtreesChanged(document()); | 164 inertSubtreesChanged(document()); |
175 | 165 |
176 forceLayoutForCentering(); | 166 forceLayoutForCentering(); |
177 setFocusForModalDialog(this); | 167 setFocusForModalDialog(this); |
178 } | 168 } |
(...skipping 25 matching lines...) Loading... |
204 { | 194 { |
205 if (event->type() == EventTypeNames::cancel) { | 195 if (event->type() == EventTypeNames::cancel) { |
206 closeDialog(); | 196 closeDialog(); |
207 event->setDefaultHandled(); | 197 event->setDefaultHandled(); |
208 return; | 198 return; |
209 } | 199 } |
210 HTMLElement::defaultEventHandler(event); | 200 HTMLElement::defaultEventHandler(event); |
211 } | 201 } |
212 | 202 |
213 } // namespace WebCore | 203 } // namespace WebCore |
OLD | NEW |