| 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/ExceptionMessages.h" | |
| 30 #include "bindings/v8/ExceptionState.h" | 29 #include "bindings/v8/ExceptionState.h" |
| 31 #include "core/accessibility/AXObjectCache.h" | 30 #include "core/accessibility/AXObjectCache.h" |
| 32 #include "core/dom/ExceptionCode.h" | 31 #include "core/dom/ExceptionCode.h" |
| 33 #include "core/dom/NodeTraversal.h" | 32 #include "core/dom/NodeTraversal.h" |
| 34 #include "core/html/HTMLFormControlElement.h" | 33 #include "core/html/HTMLFormControlElement.h" |
| 35 #include "core/frame/FrameView.h" | 34 #include "core/frame/FrameView.h" |
| 36 #include "core/rendering/RenderBlock.h" | 35 #include "core/rendering/RenderBlock.h" |
| 37 #include "core/rendering/style/RenderStyle.h" | 36 #include "core/rendering/style/RenderStyle.h" |
| 38 | 37 |
| 39 namespace WebCore { | 38 namespace WebCore { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 80 } |
| 82 | 81 |
| 83 PassRefPtr<HTMLDialogElement> HTMLDialogElement::create(Document& document) | 82 PassRefPtr<HTMLDialogElement> HTMLDialogElement::create(Document& document) |
| 84 { | 83 { |
| 85 return adoptRef(new HTMLDialogElement(document)); | 84 return adoptRef(new HTMLDialogElement(document)); |
| 86 } | 85 } |
| 87 | 86 |
| 88 void HTMLDialogElement::close(const String& returnValue, ExceptionState& excepti
onState) | 87 void HTMLDialogElement::close(const String& returnValue, ExceptionState& excepti
onState) |
| 89 { | 88 { |
| 90 if (!fastHasAttribute(openAttr)) { | 89 if (!fastHasAttribute(openAttr)) { |
| 91 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToExecute("close", "HTMLDialogElement", "The element does not have an 'open
' attribute, and therefore cannot be closed.")); | 90 exceptionState.throwDOMException(InvalidStateError, "The element does no
t have an 'open' attribute, and therefore cannot be closed."); |
| 92 return; | 91 return; |
| 93 } | 92 } |
| 94 closeDialog(returnValue); | 93 closeDialog(returnValue); |
| 95 } | 94 } |
| 96 | 95 |
| 97 void HTMLDialogElement::closeDialog(const String& returnValue) | 96 void HTMLDialogElement::closeDialog(const String& returnValue) |
| 98 { | 97 { |
| 99 if (!fastHasAttribute(openAttr)) | 98 if (!fastHasAttribute(openAttr)) |
| 100 return; | 99 return; |
| 101 setBooleanAttribute(openAttr, false); | 100 setBooleanAttribute(openAttr, false); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 123 { | 122 { |
| 124 if (fastHasAttribute(openAttr)) | 123 if (fastHasAttribute(openAttr)) |
| 125 return; | 124 return; |
| 126 setBooleanAttribute(openAttr, true); | 125 setBooleanAttribute(openAttr, true); |
| 127 forceLayoutForCentering(); | 126 forceLayoutForCentering(); |
| 128 } | 127 } |
| 129 | 128 |
| 130 void HTMLDialogElement::showModal(ExceptionState& exceptionState) | 129 void HTMLDialogElement::showModal(ExceptionState& exceptionState) |
| 131 { | 130 { |
| 132 if (fastHasAttribute(openAttr)) { | 131 if (fastHasAttribute(openAttr)) { |
| 133 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToExecute("showModal", "HTMLDialogElement", "The element already has an 'op
en' attribute, and therefore cannot be opened modally.")); | 132 exceptionState.throwDOMException(InvalidStateError, "The element already
has an 'open' attribute, and therefore cannot be opened modally."); |
| 134 return; | 133 return; |
| 135 } | 134 } |
| 136 if (!inDocument()) { | 135 if (!inDocument()) { |
| 137 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToExecute("showModal", "HTMLDialogElement", "The element is not in a Docume
nt.")); | 136 exceptionState.throwDOMException(InvalidStateError, "The element is not
in a Document."); |
| 138 return; | 137 return; |
| 139 } | 138 } |
| 140 | 139 |
| 141 document().addToTopLayer(this); | 140 document().addToTopLayer(this); |
| 142 setBooleanAttribute(openAttr, true); | 141 setBooleanAttribute(openAttr, true); |
| 143 | 142 |
| 144 runAutofocus(this); | 143 runAutofocus(this); |
| 145 forceLayoutForCentering(); | 144 forceLayoutForCentering(); |
| 146 inertSubtreesChanged(document()); | 145 inertSubtreesChanged(document()); |
| 147 } | 146 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 179 } |
| 181 | 180 |
| 182 bool HTMLDialogElement::shouldBeReparentedUnderRenderView(const RenderStyle* sty
le) const | 181 bool HTMLDialogElement::shouldBeReparentedUnderRenderView(const RenderStyle* sty
le) const |
| 183 { | 182 { |
| 184 if (style && style->position() == AbsolutePosition) | 183 if (style && style->position() == AbsolutePosition) |
| 185 return true; | 184 return true; |
| 186 return Element::shouldBeReparentedUnderRenderView(style); | 185 return Element::shouldBeReparentedUnderRenderView(style); |
| 187 } | 186 } |
| 188 | 187 |
| 189 } // namespace WebCore | 188 } // namespace WebCore |
| OLD | NEW |