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

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2628753002: Move Document::execCommand() and queryCommand*() to "DocumentExecCommand.cpp" (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/editing/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 43482a85797474481f9e2cccc4cb3732c79ab7c2..aa4990c4951324816d5bc3f19558d0330efb3597 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -121,7 +121,6 @@
#include "core/dom/shadow/FlatTreeTraversal.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/editing/EditingUtilities.h"
-#include "core/editing/Editor.h"
#include "core/editing/FrameSelection.h"
#include "core/editing/markers/DocumentMarkerController.h"
#include "core/editing/serializers/Serialization.h"
@@ -4959,116 +4958,6 @@ const KURL& Document::baseURLForOverride(const KURL& baseURLOverride) const {
return baseURLFromParent ? *baseURLFromParent : baseURLOverride;
}
-// Support for Javascript execCommand, and related methods
-
-static Editor::Command command(Document* document, const String& commandName) {
- LocalFrame* frame = document->frame();
- if (!frame || frame->document() != document)
- return Editor::Command();
-
- document->updateStyleAndLayoutTree();
- return frame->editor().createCommandFromDOM(commandName);
-}
-
-bool Document::execCommand(const String& commandName,
- bool,
- const String& value,
- ExceptionState& exceptionState) {
- if (!isHTMLDocument() && !isXHTMLDocument()) {
- exceptionState.throwDOMException(
- InvalidStateError, "execCommand is only supported on HTML documents.");
- return false;
- }
- if (focusedElement() && isTextControlElement(*focusedElement()))
- UseCounter::count(*this, UseCounter::ExecCommandOnInputOrTextarea);
-
- // We don't allow recursive |execCommand()| to protect against attack code.
- // Recursive call of |execCommand()| could be happened by moving iframe
- // with script triggered by insertion, e.g. <iframe src="javascript:...">
- // <iframe onload="...">. This usage is valid as of the specification
- // although, it isn't common use case, rather it is used as attack code.
- if (m_isRunningExecCommand) {
- String message =
- "We don't execute document.execCommand() this time, because it is "
- "called recursively.";
- addConsoleMessage(
- ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message));
- return false;
- }
- AutoReset<bool> executeScope(&m_isRunningExecCommand, true);
-
- // Postpone DOM mutation events, which can execute scripts and change
- // DOM tree against implementation assumption.
- EventQueueScope eventQueueScope;
- Editor::tidyUpHTMLStructure(*this);
- Editor::Command editorCommand = command(this, commandName);
-
- DEFINE_STATIC_LOCAL(SparseHistogram, editorCommandHistogram,
- ("WebCore.Document.execCommand"));
- editorCommandHistogram.sample(editorCommand.idForHistogram());
- return editorCommand.execute(value);
-}
-
-bool Document::queryCommandEnabled(const String& commandName,
- ExceptionState& exceptionState) {
- if (!isHTMLDocument() && !isXHTMLDocument()) {
- exceptionState.throwDOMException(
- InvalidStateError,
- "queryCommandEnabled is only supported on HTML documents.");
- return false;
- }
-
- return command(this, commandName).isEnabled();
-}
-
-bool Document::queryCommandIndeterm(const String& commandName,
- ExceptionState& exceptionState) {
- if (!isHTMLDocument() && !isXHTMLDocument()) {
- exceptionState.throwDOMException(
- InvalidStateError,
- "queryCommandIndeterm is only supported on HTML documents.");
- return false;
- }
-
- return command(this, commandName).state() == MixedTriState;
-}
-
-bool Document::queryCommandState(const String& commandName,
- ExceptionState& exceptionState) {
- if (!isHTMLDocument() && !isXHTMLDocument()) {
- exceptionState.throwDOMException(
- InvalidStateError,
- "queryCommandState is only supported on HTML documents.");
- return false;
- }
-
- return command(this, commandName).state() == TrueTriState;
-}
-
-bool Document::queryCommandSupported(const String& commandName,
- ExceptionState& exceptionState) {
- if (!isHTMLDocument() && !isXHTMLDocument()) {
- exceptionState.throwDOMException(
- InvalidStateError,
- "queryCommandSupported is only supported on HTML documents.");
- return false;
- }
-
- return command(this, commandName).isSupported();
-}
-
-String Document::queryCommandValue(const String& commandName,
- ExceptionState& exceptionState) {
- if (!isHTMLDocument() && !isXHTMLDocument()) {
- exceptionState.throwDOMException(
- InvalidStateError,
- "queryCommandValue is only supported on HTML documents.");
- return "";
- }
-
- return command(this, commandName).value();
-}
-
KURL Document::openSearchDescriptionURL() {
static const char openSearchMIMEType[] =
"application/opensearchdescription+xml";
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/editing/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698