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

Unified Diff: third_party/WebKit/Source/core/html/HTMLDialogElement.cpp

Issue 2560553002: Add DialogShowParams to <dialog>'s show() and showModal() (Closed)
Patch Set: merge & rename Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLDialogElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLDialogElement.cpp b/third_party/WebKit/Source/core/html/HTMLDialogElement.cpp
index 9edc5883e4ea38e02f6a61618fe0434fdac93113..879a68b005adda37887ff93d310843625317bc39 100644
--- a/third_party/WebKit/Source/core/html/HTMLDialogElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLDialogElement.cpp
@@ -32,6 +32,7 @@
#include "core/events/Event.h"
#include "core/frame/FrameView.h"
#include "core/frame/UseCounter.h"
+#include "core/html/DialogShowParams.h"
#include "core/html/HTMLFormControlElement.h"
#include "core/style/ComputedStyle.h"
@@ -138,19 +139,22 @@ void HTMLDialogElement::scheduleCloseEvent() {
document().enqueueAnimationFrameEvent(event);
}
-void HTMLDialogElement::show() {
+void HTMLDialogElement::show(const DialogShowParams& showParams) {
if (fastHasAttribute(openAttr))
return;
setBooleanAttribute(openAttr, true);
+ if (showParams.skipInitialFocus())
+ return;
+
// The layout must be updated here because setFocusForDialog calls
// Element::isFocusable, which requires an up-to-date layout.
document().updateStyleAndLayoutIgnorePendingStylesheets();
-
setFocusForDialog(this);
}
-void HTMLDialogElement::showModal(ExceptionState& exceptionState) {
+void HTMLDialogElement::showModal(const DialogShowParams& showParams,
+ ExceptionState& exceptionState) {
if (fastHasAttribute(openAttr)) {
exceptionState.throwDOMException(InvalidStateError,
"The element already has an 'open' "
@@ -173,6 +177,10 @@ void HTMLDialogElement::showModal(ExceptionState& exceptionState) {
inertSubtreesChanged(document());
forceLayoutForCentering();
+
+ if (showParams.skipInitialFocus())
+ return;
+
setFocusForDialog(this);
}
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLDialogElement.h ('k') | third_party/WebKit/Source/core/html/HTMLDialogElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698