Chromium Code Reviews| 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...) Expand 10 before | Expand all | Expand 10 after 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) | |
| 97 { | 98 { |
| 98 ScriptWrappable::init(this); | 99 ScriptWrappable::init(this); |
| 99 } | 100 } |
| 100 | 101 |
| 101 PassRefPtr<HTMLDialogElement> HTMLDialogElement::create(Document& document) | 102 PassRefPtr<HTMLDialogElement> HTMLDialogElement::create(Document& document) |
| 102 { | 103 { |
| 103 return adoptRef(new HTMLDialogElement(document)); | 104 return adoptRef(new HTMLDialogElement(document)); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void HTMLDialogElement::close(const String& returnValue, ExceptionState& excepti onState) | 107 void HTMLDialogElement::close(const String& returnValue, ExceptionState& excepti onState) |
| 107 { | 108 { |
| 108 if (!fastHasAttribute(openAttr)) { | 109 if (!fastHasAttribute(openAttr)) { |
| 109 exceptionState.throwDOMException(InvalidStateError, "The element does no t have an 'open' attribute, and therefore cannot be closed."); | 110 exceptionState.throwDOMException(InvalidStateError, "The element does no t have an 'open' attribute, and therefore cannot be closed."); |
| 110 return; | 111 return; |
| 111 } | 112 } |
| 112 closeDialog(returnValue); | 113 closeDialog(returnValue); |
| 113 } | 114 } |
| 114 | 115 |
| 116 void HTMLDialogElement::removedFrom(ContainerNode* insertionPoint) | |
| 117 { | |
| 118 m_modal = false; | |
|
esprehn
2014/01/23 18:44:58
What calls inertSubtreesChanged(document()) when y
falken
2014/01/24 01:50:44
Oh great point. This is an existing bug, we won't
| |
| 119 HTMLElement::removedFrom(insertionPoint); | |
| 120 } | |
| 121 | |
| 115 void HTMLDialogElement::closeDialog(const String& returnValue) | 122 void HTMLDialogElement::closeDialog(const String& returnValue) |
| 116 { | 123 { |
| 117 if (!fastHasAttribute(openAttr)) | 124 if (!fastHasAttribute(openAttr)) |
| 118 return; | 125 return; |
| 119 setBooleanAttribute(openAttr, false); | 126 setBooleanAttribute(openAttr, false); |
| 120 | 127 |
| 121 HTMLDialogElement* activeModalDialog = document().activeModalDialog(); | 128 HTMLDialogElement* activeModalDialog = document().activeModalDialog(); |
| 129 m_modal = false; | |
| 122 document().removeFromTopLayer(this); | 130 document().removeFromTopLayer(this); |
| 123 if (activeModalDialog == this) | 131 if (activeModalDialog == this) |
| 124 inertSubtreesChanged(document()); | 132 inertSubtreesChanged(document()); |
| 125 | 133 |
| 126 if (!returnValue.isNull()) | 134 if (!returnValue.isNull()) |
| 127 m_returnValue = returnValue; | 135 m_returnValue = returnValue; |
| 128 | 136 |
| 129 dispatchScopedEvent(Event::create(EventTypeNames::close)); | 137 dispatchScopedEvent(Event::create(EventTypeNames::close)); |
| 130 } | 138 } |
| 131 | 139 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 149 { | 157 { |
| 150 if (fastHasAttribute(openAttr)) { | 158 if (fastHasAttribute(openAttr)) { |
| 151 exceptionState.throwDOMException(InvalidStateError, "The element already has an 'open' attribute, and therefore cannot be opened modally."); | 159 exceptionState.throwDOMException(InvalidStateError, "The element already has an 'open' attribute, and therefore cannot be opened modally."); |
| 152 return; | 160 return; |
| 153 } | 161 } |
| 154 if (!inDocument()) { | 162 if (!inDocument()) { |
| 155 exceptionState.throwDOMException(InvalidStateError, "The element is not in a Document."); | 163 exceptionState.throwDOMException(InvalidStateError, "The element is not in a Document."); |
| 156 return; | 164 return; |
| 157 } | 165 } |
| 158 | 166 |
| 167 m_modal = true; | |
| 159 document().addToTopLayer(this); | 168 document().addToTopLayer(this); |
| 160 setBooleanAttribute(openAttr, true); | 169 setBooleanAttribute(openAttr, true); |
| 161 | 170 |
| 162 // Throw away the AX cache first, so the subsequent steps don't have a chanc e of queuing up | 171 // Throw away the AX cache first, so the subsequent steps don't have a chanc e of queuing up |
| 163 // AX events on objects that would be invalidated when the cache is thrown a way. | 172 // AX events on objects that would be invalidated when the cache is thrown a way. |
| 164 inertSubtreesChanged(document()); | 173 inertSubtreesChanged(document()); |
| 165 | 174 |
| 166 forceLayoutForCentering(); | 175 forceLayoutForCentering(); |
| 167 setFocusForModalDialog(this); | 176 setFocusForModalDialog(this); |
| 168 } | 177 } |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 194 { | 203 { |
| 195 if (event->type() == EventTypeNames::cancel) { | 204 if (event->type() == EventTypeNames::cancel) { |
| 196 closeDialog(); | 205 closeDialog(); |
| 197 event->setDefaultHandled(); | 206 event->setDefaultHandled(); |
| 198 return; | 207 return; |
| 199 } | 208 } |
| 200 HTMLElement::defaultEventHandler(event); | 209 HTMLElement::defaultEventHandler(event); |
| 201 } | 210 } |
| 202 | 211 |
| 203 } // namespace WebCore | 212 } // namespace WebCore |
| OLD | NEW |