Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: Source/core/html/HTMLDialogElement.cpp

Issue 134753003: Reland r165710 "Replace RenderFullScreen with top layer" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: patch for landing Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 // FIXME: We should call inertSubtreesChanged if needed here.
119 m_modal = false;
120 HTMLElement::removedFrom(insertionPoint);
121 }
122
115 void HTMLDialogElement::closeDialog(const String& returnValue) 123 void HTMLDialogElement::closeDialog(const String& returnValue)
116 { 124 {
117 if (!fastHasAttribute(openAttr)) 125 if (!fastHasAttribute(openAttr))
118 return; 126 return;
119 setBooleanAttribute(openAttr, false); 127 setBooleanAttribute(openAttr, false);
120 128
121 HTMLDialogElement* activeModalDialog = document().activeModalDialog(); 129 HTMLDialogElement* activeModalDialog = document().activeModalDialog();
130 m_modal = false;
122 document().removeFromTopLayer(this); 131 document().removeFromTopLayer(this);
123 if (activeModalDialog == this) 132 if (activeModalDialog == this)
124 inertSubtreesChanged(document()); 133 inertSubtreesChanged(document());
125 134
126 if (!returnValue.isNull()) 135 if (!returnValue.isNull())
127 m_returnValue = returnValue; 136 m_returnValue = returnValue;
128 137
129 dispatchScopedEvent(Event::create(EventTypeNames::close)); 138 dispatchScopedEvent(Event::create(EventTypeNames::close));
130 } 139 }
131 140
(...skipping 17 matching lines...) Expand all
149 { 158 {
150 if (fastHasAttribute(openAttr)) { 159 if (fastHasAttribute(openAttr)) {
151 exceptionState.throwDOMException(InvalidStateError, "The element already has an 'open' attribute, and therefore cannot be opened modally."); 160 exceptionState.throwDOMException(InvalidStateError, "The element already has an 'open' attribute, and therefore cannot be opened modally.");
152 return; 161 return;
153 } 162 }
154 if (!inDocument()) { 163 if (!inDocument()) {
155 exceptionState.throwDOMException(InvalidStateError, "The element is not in a Document."); 164 exceptionState.throwDOMException(InvalidStateError, "The element is not in a Document.");
156 return; 165 return;
157 } 166 }
158 167
168 m_modal = true;
159 document().addToTopLayer(this); 169 document().addToTopLayer(this);
160 setBooleanAttribute(openAttr, true); 170 setBooleanAttribute(openAttr, true);
161 171
162 // Throw away the AX cache first, so the subsequent steps don't have a chanc e of queuing up 172 // 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. 173 // AX events on objects that would be invalidated when the cache is thrown a way.
164 inertSubtreesChanged(document()); 174 inertSubtreesChanged(document());
165 175
166 forceLayoutForCentering(); 176 forceLayoutForCentering();
167 setFocusForModalDialog(this); 177 setFocusForModalDialog(this);
168 } 178 }
(...skipping 25 matching lines...) Expand all
194 { 204 {
195 if (event->type() == EventTypeNames::cancel) { 205 if (event->type() == EventTypeNames::cancel) {
196 closeDialog(); 206 closeDialog();
197 event->setDefaultHandled(); 207 event->setDefaultHandled();
198 return; 208 return;
199 } 209 }
200 HTMLElement::defaultEventHandler(event); 210 HTMLElement::defaultEventHandler(event);
201 } 211 }
202 212
203 } // namespace WebCore 213 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698