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

Side by Side Diff: sky/engine/core/dom/Document.cpp

Issue 713563003: Remove execCommand methods from Document. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/core/dom/Document.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #include "core/dom/ScriptedAnimationController.h" 71 #include "core/dom/ScriptedAnimationController.h"
72 #include "core/dom/SelectorQuery.h" 72 #include "core/dom/SelectorQuery.h"
73 #include "core/dom/StaticNodeList.h" 73 #include "core/dom/StaticNodeList.h"
74 #include "core/dom/StyleEngine.h" 74 #include "core/dom/StyleEngine.h"
75 #include "core/dom/Text.h" 75 #include "core/dom/Text.h"
76 #include "core/dom/TouchList.h" 76 #include "core/dom/TouchList.h"
77 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" 77 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h"
78 #include "core/dom/custom/CustomElementRegistrationContext.h" 78 #include "core/dom/custom/CustomElementRegistrationContext.h"
79 #include "core/dom/shadow/ElementShadow.h" 79 #include "core/dom/shadow/ElementShadow.h"
80 #include "core/dom/shadow/ShadowRoot.h" 80 #include "core/dom/shadow/ShadowRoot.h"
81 #include "core/editing/Editor.h"
82 #include "core/editing/FrameSelection.h" 81 #include "core/editing/FrameSelection.h"
83 #include "core/editing/SpellChecker.h" 82 #include "core/editing/SpellChecker.h"
84 #include "core/editing/markup.h" 83 #include "core/editing/markup.h"
85 #include "core/events/Event.h" 84 #include "core/events/Event.h"
86 #include "core/events/EventFactory.h" 85 #include "core/events/EventFactory.h"
87 #include "core/events/EventListener.h" 86 #include "core/events/EventListener.h"
88 #include "core/events/HashChangeEvent.h" 87 #include "core/events/HashChangeEvent.h"
89 #include "core/events/PageTransitionEvent.h" 88 #include "core/events/PageTransitionEvent.h"
90 #include "core/events/ScopedEventQueue.h" 89 #include "core/events/ScopedEventQueue.h"
91 #include "core/fetch/ResourceFetcher.h" 90 #include "core/fetch/ResourceFetcher.h"
(...skipping 2375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 KURL Document::completeURL(const String& url) const 2466 KURL Document::completeURL(const String& url) const
2468 { 2467 {
2469 // Always return a null URL when passed a null string. 2468 // Always return a null URL when passed a null string.
2470 // FIXME: Should we change the KURL constructor to have this behavior? 2469 // FIXME: Should we change the KURL constructor to have this behavior?
2471 // See also [CSS]StyleSheet::completeURL(const String&) 2470 // See also [CSS]StyleSheet::completeURL(const String&)
2472 if (url.isNull()) 2471 if (url.isNull())
2473 return KURL(); 2472 return KURL();
2474 return KURL(m_baseURL, url); 2473 return KURL(m_baseURL, url);
2475 } 2474 }
2476 2475
2477 // Support for Javascript execCommand, and related methods
2478
2479 static Editor::Command command(Document* document, const String& commandName, bo ol userInterface = false)
2480 {
2481 LocalFrame* frame = document->frame();
2482 if (!frame || frame->document() != document)
2483 return Editor::Command();
2484
2485 document->updateRenderTreeIfNeeded();
2486 return frame->editor().command(commandName, userInterface ? CommandFromDOMWi thUserInterface : CommandFromDOM);
2487 }
2488
2489 bool Document::execCommand(const String& commandName, bool userInterface, const String& value)
2490 {
2491 // We don't allow recusrive |execCommand()| to protect against attack code.
2492 // Recursive call of |execCommand()| could be happened by moving iframe
2493 // with script triggered by insertion, e.g. <iframe src="javascript:...">
2494 // <iframe onload="...">. This usage is valid as of the specification
2495 // although, it isn't common use case, rather it is used as attack code.
2496 static bool inExecCommand = false;
2497 if (inExecCommand) {
2498 String message = "We don't execute document.execCommand() this time, bec ause it is called recursively.";
2499 addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessage Level, message));
2500 return false;
2501 }
2502 TemporaryChange<bool> executeScope(inExecCommand, true);
2503
2504 // Postpone DOM mutation events, which can execute scripts and change
2505 // DOM tree against implementation assumption.
2506 EventQueueScope eventQueueScope;
2507 Editor::Command editorCommand = command(this, commandName, userInterface);
2508 Platform::current()->histogramSparse("WebCore.Document.execCommand", editorC ommand.idForHistogram());
2509 return editorCommand.execute(value);
2510 }
2511
2512 bool Document::queryCommandEnabled(const String& commandName)
2513 {
2514 return command(this, commandName).isEnabled();
2515 }
2516
2517 bool Document::queryCommandIndeterm(const String& commandName)
2518 {
2519 return command(this, commandName).state() == MixedTriState;
2520 }
2521
2522 bool Document::queryCommandState(const String& commandName)
2523 {
2524 return command(this, commandName).state() == TrueTriState;
2525 }
2526
2527 bool Document::queryCommandSupported(const String& commandName)
2528 {
2529 return command(this, commandName).isSupported();
2530 }
2531
2532 String Document::queryCommandValue(const String& commandName)
2533 {
2534 return command(this, commandName).value();
2535 }
2536
2537 KURL Document::openSearchDescriptionURL() 2476 KURL Document::openSearchDescriptionURL()
2538 { 2477 {
2539 return KURL(); 2478 return KURL();
2540 } 2479 }
2541 2480
2542 void Document::pushCurrentScript(PassRefPtr<HTMLScriptElement> newCurrentScript) 2481 void Document::pushCurrentScript(PassRefPtr<HTMLScriptElement> newCurrentScript)
2543 { 2482 {
2544 ASSERT(newCurrentScript); 2483 ASSERT(newCurrentScript);
2545 m_currentScriptStack.append(newCurrentScript); 2484 m_currentScriptStack.append(newCurrentScript);
2546 } 2485 }
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
3124 using namespace blink; 3063 using namespace blink;
3125 void showLiveDocumentInstances() 3064 void showLiveDocumentInstances()
3126 { 3065 {
3127 WeakDocumentSet& set = liveDocumentSet(); 3066 WeakDocumentSet& set = liveDocumentSet();
3128 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 3067 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
3129 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 3068 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
3130 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 3069 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
3131 } 3070 }
3132 } 3071 }
3133 #endif 3072 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Document.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698