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

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

Issue 2883033003: Propagate inert state to OOPIFs when a modal dialog is active (Closed)
Patch Set: Fix test crash Created 3 years, 6 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
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 15 matching lines...) Expand all
26 #include "core/html/HTMLDialogElement.h" 26 #include "core/html/HTMLDialogElement.h"
27 27
28 #include "bindings/core/v8/ExceptionState.h" 28 #include "bindings/core/v8/ExceptionState.h"
29 #include "core/dom/AXObjectCache.h" 29 #include "core/dom/AXObjectCache.h"
30 #include "core/dom/ExceptionCode.h" 30 #include "core/dom/ExceptionCode.h"
31 #include "core/dom/shadow/FlatTreeTraversal.h" 31 #include "core/dom/shadow/FlatTreeTraversal.h"
32 #include "core/events/Event.h" 32 #include "core/events/Event.h"
33 #include "core/frame/FrameView.h" 33 #include "core/frame/FrameView.h"
34 #include "core/frame/UseCounter.h" 34 #include "core/frame/UseCounter.h"
35 #include "core/html/HTMLFormControlElement.h" 35 #include "core/html/HTMLFormControlElement.h"
36 #include "core/html/HTMLFrameOwnerElement.h"
36 #include "core/style/ComputedStyle.h" 37 #include "core/style/ComputedStyle.h"
37 38
38 namespace blink { 39 namespace blink {
39 40
40 using namespace HTMLNames; 41 using namespace HTMLNames;
41 42
42 // This function chooses the focused element when show() or showModal() is 43 // This function chooses the focused element when show() or showModal() is
43 // invoked, as described in their spec. 44 // invoked, as described in their spec.
44 static void SetFocusForDialog(HTMLDialogElement* dialog) { 45 static void SetFocusForDialog(HTMLDialogElement* dialog) {
45 Element* focusable_descendant = nullptr; 46 Element* focusable_descendant = nullptr;
(...skipping 28 matching lines...) Expand all
74 75
75 if (dialog->IsFocusable()) { 76 if (dialog->IsFocusable()) {
76 dialog->focus(); 77 dialog->focus();
77 return; 78 return;
78 } 79 }
79 80
80 dialog->GetDocument().ClearFocusedElement(); 81 dialog->GetDocument().ClearFocusedElement();
81 } 82 }
82 83
83 static void InertSubtreesChanged(Document& document) { 84 static void InertSubtreesChanged(Document& document) {
85 if (document.GetFrame()) {
86 // SetIsInert recurses through subframes to propagate the inert bit as
87 // needed.
88 document.GetFrame()->SetIsInert(document.LocalOwner() &&
89 document.LocalOwner()->IsInert());
90 }
91
84 // When a modal dialog opens or closes, nodes all over the accessibility 92 // When a modal dialog opens or closes, nodes all over the accessibility
85 // tree can change inertness which means they must be added or removed from 93 // tree can change inertness which means they must be added or removed from
86 // the tree. The most foolproof way is to clear the entire tree and rebuild 94 // the tree. The most foolproof way is to clear the entire tree and rebuild
87 // it, though a more clever way is probably possible. 95 // it, though a more clever way is probably possible.
88 document.ClearAXObjectCache(); 96 document.ClearAXObjectCache();
89 if (AXObjectCache* cache = document.AxObjectCache()) 97 if (AXObjectCache* cache = document.AxObjectCache())
90 cache->ChildrenChanged(&document); 98 cache->ChildrenChanged(&document);
91 } 99 }
92 100
93 inline HTMLDialogElement::HTMLDialogElement(Document& document) 101 inline HTMLDialogElement::HTMLDialogElement(Document& document)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // is thrown away. 183 // is thrown away.
176 InertSubtreesChanged(GetDocument()); 184 InertSubtreesChanged(GetDocument());
177 185
178 ForceLayoutForCentering(); 186 ForceLayoutForCentering();
179 SetFocusForDialog(this); 187 SetFocusForDialog(this);
180 } 188 }
181 189
182 void HTMLDialogElement::RemovedFrom(ContainerNode* insertion_point) { 190 void HTMLDialogElement::RemovedFrom(ContainerNode* insertion_point) {
183 HTMLElement::RemovedFrom(insertion_point); 191 HTMLElement::RemovedFrom(insertion_point);
184 SetNotCentered(); 192 SetNotCentered();
185 // FIXME: We should call inertSubtreesChanged() here. 193 InertSubtreesChanged(GetDocument());
186 } 194 }
187 195
188 void HTMLDialogElement::SetCentered(LayoutUnit centered_position) { 196 void HTMLDialogElement::SetCentered(LayoutUnit centered_position) {
189 DCHECK_EQ(centering_mode_, kNeedsCentering); 197 DCHECK_EQ(centering_mode_, kNeedsCentering);
190 centered_position_ = centered_position; 198 centered_position_ = centered_position;
191 centering_mode_ = kCentered; 199 centering_mode_ = kCentered;
192 } 200 }
193 201
194 void HTMLDialogElement::SetNotCentered() { 202 void HTMLDialogElement::SetNotCentered() {
195 centering_mode_ = kNotCentered; 203 centering_mode_ = kNotCentered;
(...skipping 13 matching lines...) Expand all
209 void HTMLDialogElement::DefaultEventHandler(Event* event) { 217 void HTMLDialogElement::DefaultEventHandler(Event* event) {
210 if (event->type() == EventTypeNames::cancel) { 218 if (event->type() == EventTypeNames::cancel) {
211 CloseDialog(); 219 CloseDialog();
212 event->SetDefaultHandled(); 220 event->SetDefaultHandled();
213 return; 221 return;
214 } 222 }
215 HTMLElement::DefaultEventHandler(event); 223 HTMLElement::DefaultEventHandler(event);
216 } 224 }
217 225
218 } // namespace blink 226 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698