| 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 4227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4238 static Editor::Command command(Document* document, const String& commandName) | 4238 static Editor::Command command(Document* document, const String& commandName) |
| 4239 { | 4239 { |
| 4240 LocalFrame* frame = document->frame(); | 4240 LocalFrame* frame = document->frame(); |
| 4241 if (!frame || frame->document() != document) | 4241 if (!frame || frame->document() != document) |
| 4242 return Editor::Command(); | 4242 return Editor::Command(); |
| 4243 | 4243 |
| 4244 document->updateLayoutTreeIfNeeded(); | 4244 document->updateLayoutTreeIfNeeded(); |
| 4245 return frame->editor().command(commandName, CommandFromDOM); | 4245 return frame->editor().command(commandName, CommandFromDOM); |
| 4246 } | 4246 } |
| 4247 | 4247 |
| 4248 bool Document::execCommand(const String& commandName, bool, const String& value) | 4248 bool Document::execCommand(const String& commandName, bool, const String& value,
ExceptionState& exceptionState) |
| 4249 { | 4249 { |
| 4250 if (!isHTMLDocument() && !isXHTMLDocument()) { |
| 4251 exceptionState.throwDOMException(InvalidStateError, "execCommand is only
supported on HTML documents."); |
| 4252 return false; |
| 4253 } |
| 4254 |
| 4250 // We don't allow recursive |execCommand()| to protect against attack code. | 4255 // We don't allow recursive |execCommand()| to protect against attack code. |
| 4251 // Recursive call of |execCommand()| could be happened by moving iframe | 4256 // Recursive call of |execCommand()| could be happened by moving iframe |
| 4252 // with script triggered by insertion, e.g. <iframe src="javascript:..."> | 4257 // with script triggered by insertion, e.g. <iframe src="javascript:..."> |
| 4253 // <iframe onload="...">. This usage is valid as of the specification | 4258 // <iframe onload="...">. This usage is valid as of the specification |
| 4254 // although, it isn't common use case, rather it is used as attack code. | 4259 // although, it isn't common use case, rather it is used as attack code. |
| 4255 static bool inExecCommand = false; | 4260 static bool inExecCommand = false; |
| 4256 if (inExecCommand) { | 4261 if (inExecCommand) { |
| 4257 String message = "We don't execute document.execCommand() this time, bec
ause it is called recursively."; | 4262 String message = "We don't execute document.execCommand() this time, bec
ause it is called recursively."; |
| 4258 addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessage
Level, message)); | 4263 addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessage
Level, message)); |
| 4259 return false; | 4264 return false; |
| 4260 } | 4265 } |
| 4261 TemporaryChange<bool> executeScope(inExecCommand, true); | 4266 TemporaryChange<bool> executeScope(inExecCommand, true); |
| 4262 | 4267 |
| 4263 // Postpone DOM mutation events, which can execute scripts and change | 4268 // Postpone DOM mutation events, which can execute scripts and change |
| 4264 // DOM tree against implementation assumption. | 4269 // DOM tree against implementation assumption. |
| 4265 EventQueueScope eventQueueScope; | 4270 EventQueueScope eventQueueScope; |
| 4266 Editor::Command editorCommand = command(this, commandName); | 4271 Editor::Command editorCommand = command(this, commandName); |
| 4267 Platform::current()->histogramSparse("WebCore.Document.execCommand", editorC
ommand.idForHistogram()); | 4272 Platform::current()->histogramSparse("WebCore.Document.execCommand", editorC
ommand.idForHistogram()); |
| 4268 return editorCommand.execute(value); | 4273 return editorCommand.execute(value); |
| 4269 } | 4274 } |
| 4270 | 4275 |
| 4271 bool Document::queryCommandEnabled(const String& commandName) | 4276 bool Document::queryCommandEnabled(const String& commandName, ExceptionState& ex
ceptionState) |
| 4272 { | 4277 { |
| 4278 if (!isHTMLDocument() && !isXHTMLDocument()) { |
| 4279 exceptionState.throwDOMException(InvalidStateError, "queryCommandEnabled
is only supported on HTML documents."); |
| 4280 return false; |
| 4281 } |
| 4282 |
| 4273 return command(this, commandName).isEnabled(); | 4283 return command(this, commandName).isEnabled(); |
| 4274 } | 4284 } |
| 4275 | 4285 |
| 4276 bool Document::queryCommandIndeterm(const String& commandName) | 4286 bool Document::queryCommandIndeterm(const String& commandName, ExceptionState& e
xceptionState) |
| 4277 { | 4287 { |
| 4288 if (!isHTMLDocument() && !isXHTMLDocument()) { |
| 4289 exceptionState.throwDOMException(InvalidStateError, "queryCommandIndeter
m is only supported on HTML documents."); |
| 4290 return false; |
| 4291 } |
| 4292 |
| 4278 return command(this, commandName).state() == MixedTriState; | 4293 return command(this, commandName).state() == MixedTriState; |
| 4279 } | 4294 } |
| 4280 | 4295 |
| 4281 bool Document::queryCommandState(const String& commandName) | 4296 bool Document::queryCommandState(const String& commandName, ExceptionState& exce
ptionState) |
| 4282 { | 4297 { |
| 4298 if (!isHTMLDocument() && !isXHTMLDocument()) { |
| 4299 exceptionState.throwDOMException(InvalidStateError, "queryCommandState i
s only supported on HTML documents."); |
| 4300 return false; |
| 4301 } |
| 4302 |
| 4283 return command(this, commandName).state() == TrueTriState; | 4303 return command(this, commandName).state() == TrueTriState; |
| 4284 } | 4304 } |
| 4285 | 4305 |
| 4286 bool Document::queryCommandSupported(const String& commandName) | 4306 bool Document::queryCommandSupported(const String& commandName, ExceptionState&
exceptionState) |
| 4287 { | 4307 { |
| 4308 if (!isHTMLDocument() && !isXHTMLDocument()) { |
| 4309 exceptionState.throwDOMException(InvalidStateError, "queryCommandSupport
ed is only supported on HTML documents."); |
| 4310 return false; |
| 4311 } |
| 4312 |
| 4288 return command(this, commandName).isSupported(); | 4313 return command(this, commandName).isSupported(); |
| 4289 } | 4314 } |
| 4290 | 4315 |
| 4291 String Document::queryCommandValue(const String& commandName) | 4316 String Document::queryCommandValue(const String& commandName, ExceptionState& ex
ceptionState) |
| 4292 { | 4317 { |
| 4318 if (!isHTMLDocument() && !isXHTMLDocument()) { |
| 4319 exceptionState.throwDOMException(InvalidStateError, "queryCommandValue i
s only supported on HTML documents."); |
| 4320 return ""; |
| 4321 } |
| 4322 |
| 4293 return command(this, commandName).value(); | 4323 return command(this, commandName).value(); |
| 4294 } | 4324 } |
| 4295 | 4325 |
| 4296 KURL Document::openSearchDescriptionURL() | 4326 KURL Document::openSearchDescriptionURL() |
| 4297 { | 4327 { |
| 4298 static const char openSearchMIMEType[] = "application/opensearchdescription+
xml"; | 4328 static const char openSearchMIMEType[] = "application/opensearchdescription+
xml"; |
| 4299 static const char openSearchRelation[] = "search"; | 4329 static const char openSearchRelation[] = "search"; |
| 4300 | 4330 |
| 4301 // FIXME: Why do only top-level frames have openSearchDescriptionURLs? | 4331 // FIXME: Why do only top-level frames have openSearchDescriptionURLs? |
| 4302 if (!frame() || frame()->tree().parent()) | 4332 if (!frame() || frame()->tree().parent()) |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5680 #ifndef NDEBUG | 5710 #ifndef NDEBUG |
| 5681 using namespace blink; | 5711 using namespace blink; |
| 5682 void showLiveDocumentInstances() | 5712 void showLiveDocumentInstances() |
| 5683 { | 5713 { |
| 5684 WeakDocumentSet& set = liveDocumentSet(); | 5714 WeakDocumentSet& set = liveDocumentSet(); |
| 5685 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5715 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 5686 for (Document* document : set) | 5716 for (Document* document : set) |
| 5687 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5717 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
| 5688 } | 5718 } |
| 5689 #endif | 5719 #endif |
| OLD | NEW |