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

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: Rebase only Created 3 years, 7 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()) {
dmazzoni 2017/05/19 18:58:19 Perhaps this deserves a comment saying that this i
kenrb 2017/05/31 18:32:00 Done.
86 document.GetFrame()->SetIsInert(document.LocalOwner() &&
87 document.LocalOwner()->IsInert());
88 }
89
84 // When a modal dialog opens or closes, nodes all over the accessibility 90 // 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 91 // 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 92 // the tree. The most foolproof way is to clear the entire tree and rebuild
87 // it, though a more clever way is probably possible. 93 // it, though a more clever way is probably possible.
88 document.ClearAXObjectCache(); 94 document.ClearAXObjectCache();
89 if (AXObjectCache* cache = document.AxObjectCache()) 95 if (AXObjectCache* cache = document.AxObjectCache())
90 cache->ChildrenChanged(&document); 96 cache->ChildrenChanged(&document);
91 } 97 }
92 98
93 inline HTMLDialogElement::HTMLDialogElement(Document& document) 99 inline HTMLDialogElement::HTMLDialogElement(Document& document)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // is thrown away. 181 // is thrown away.
176 InertSubtreesChanged(GetDocument()); 182 InertSubtreesChanged(GetDocument());
177 183
178 ForceLayoutForCentering(); 184 ForceLayoutForCentering();
179 SetFocusForDialog(this); 185 SetFocusForDialog(this);
180 } 186 }
181 187
182 void HTMLDialogElement::RemovedFrom(ContainerNode* insertion_point) { 188 void HTMLDialogElement::RemovedFrom(ContainerNode* insertion_point) {
183 HTMLElement::RemovedFrom(insertion_point); 189 HTMLElement::RemovedFrom(insertion_point);
184 SetNotCentered(); 190 SetNotCentered();
185 // FIXME: We should call inertSubtreesChanged() here. 191 InertSubtreesChanged(GetDocument());
186 } 192 }
187 193
188 void HTMLDialogElement::SetCentered(LayoutUnit centered_position) { 194 void HTMLDialogElement::SetCentered(LayoutUnit centered_position) {
189 DCHECK_EQ(centering_mode_, kNeedsCentering); 195 DCHECK_EQ(centering_mode_, kNeedsCentering);
190 centered_position_ = centered_position; 196 centered_position_ = centered_position;
191 centering_mode_ = kCentered; 197 centering_mode_ = kCentered;
192 } 198 }
193 199
194 void HTMLDialogElement::SetNotCentered() { 200 void HTMLDialogElement::SetNotCentered() {
195 centering_mode_ = kNotCentered; 201 centering_mode_ = kNotCentered;
(...skipping 13 matching lines...) Expand all
209 void HTMLDialogElement::DefaultEventHandler(Event* event) { 215 void HTMLDialogElement::DefaultEventHandler(Event* event) {
210 if (event->type() == EventTypeNames::cancel) { 216 if (event->type() == EventTypeNames::cancel) {
211 CloseDialog(); 217 CloseDialog();
212 event->SetDefaultHandled(); 218 event->SetDefaultHandled();
213 return; 219 return;
214 } 220 }
215 HTMLElement::DefaultEventHandler(event); 221 HTMLElement::DefaultEventHandler(event);
216 } 222 }
217 223
218 } // namespace blink 224 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698