OLD | NEW |
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 4133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4144 Frame* frame = document->frame(); | 4144 Frame* frame = document->frame(); |
4145 if (!frame || frame->document() != document) | 4145 if (!frame || frame->document() != document) |
4146 return Editor::Command(); | 4146 return Editor::Command(); |
4147 | 4147 |
4148 document->updateStyleIfNeeded(); | 4148 document->updateStyleIfNeeded(); |
4149 return frame->editor().command(commandName, userInterface ? CommandFromDOMWi
thUserInterface : CommandFromDOM); | 4149 return frame->editor().command(commandName, userInterface ? CommandFromDOMWi
thUserInterface : CommandFromDOM); |
4150 } | 4150 } |
4151 | 4151 |
4152 bool Document::execCommand(const String& commandName, bool userInterface, const
String& value) | 4152 bool Document::execCommand(const String& commandName, bool userInterface, const
String& value) |
4153 { | 4153 { |
| 4154 // We don't allow recusrive |execCommand()| to protect against attack code. |
| 4155 // Recursive call of |execCommand()| could be happened by moving iframe |
| 4156 // with script triggered by insertion, e.g. <iframe src="javascript:..."> |
| 4157 // <iframe onload="...">. This usage is valid as of the specification |
| 4158 // although, it isn't common use case, rather it is used as attack code. |
| 4159 static bool inExecCommand = false; |
| 4160 if (inExecCommand) { |
| 4161 String message = "We don't execute document.execCommand() this time, bec
ause it is called recursively."; |
| 4162 addConsoleMessage(JSMessageSource, WarningMessageLevel, message); |
| 4163 return false; |
| 4164 } |
| 4165 TemporaryChange<bool> executeScope(inExecCommand, true); |
| 4166 |
| 4167 // Postpone DOM mutation events, which can execute scripts and change |
| 4168 // DOM tree against implementation assumption. |
| 4169 EventQueueScope eventQueueScope; |
4154 return command(this, commandName, userInterface).execute(value); | 4170 return command(this, commandName, userInterface).execute(value); |
4155 } | 4171 } |
4156 | 4172 |
4157 bool Document::queryCommandEnabled(const String& commandName) | 4173 bool Document::queryCommandEnabled(const String& commandName) |
4158 { | 4174 { |
4159 return command(this, commandName).isEnabled(); | 4175 return command(this, commandName).isEnabled(); |
4160 } | 4176 } |
4161 | 4177 |
4162 bool Document::queryCommandIndeterm(const String& commandName) | 4178 bool Document::queryCommandIndeterm(const String& commandName) |
4163 { | 4179 { |
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5366 if (!page->focusController().isActive() || !page->focusController().isFocuse
d()) | 5382 if (!page->focusController().isActive() || !page->focusController().isFocuse
d()) |
5367 return false; | 5383 return false; |
5368 if (Frame* focusedFrame = page->focusController().focusedFrame()) { | 5384 if (Frame* focusedFrame = page->focusController().focusedFrame()) { |
5369 if (focusedFrame->tree().isDescendantOf(frame())) | 5385 if (focusedFrame->tree().isDescendantOf(frame())) |
5370 return true; | 5386 return true; |
5371 } | 5387 } |
5372 return false; | 5388 return false; |
5373 } | 5389 } |
5374 | 5390 |
5375 } // namespace WebCore | 5391 } // namespace WebCore |
OLD | NEW |