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 4318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4329 baseURLFromParent = &parent->baseURL(); | 4329 baseURLFromParent = &parent->baseURL(); |
4330 } | 4330 } |
4331 const KURL& baseURL = baseURLFromParent ? *baseURLFromParent : baseURLOverri
de; | 4331 const KURL& baseURL = baseURLFromParent ? *baseURLFromParent : baseURLOverri
de; |
4332 if (!encoding().isValid()) | 4332 if (!encoding().isValid()) |
4333 return KURL(baseURL, url); | 4333 return KURL(baseURL, url); |
4334 return KURL(baseURL, url, encoding()); | 4334 return KURL(baseURL, url, encoding()); |
4335 } | 4335 } |
4336 | 4336 |
4337 // Support for Javascript execCommand, and related methods | 4337 // Support for Javascript execCommand, and related methods |
4338 | 4338 |
4339 static Editor::Command command(Document* document, const String& commandName, bo
ol userInterface = false) | 4339 static Editor::Command command(Document* document, const String& commandName) |
4340 { | 4340 { |
4341 LocalFrame* frame = document->frame(); | 4341 LocalFrame* frame = document->frame(); |
4342 if (!frame || frame->document() != document) | 4342 if (!frame || frame->document() != document) |
4343 return Editor::Command(); | 4343 return Editor::Command(); |
4344 | 4344 |
4345 document->updateRenderTreeIfNeeded(); | 4345 document->updateRenderTreeIfNeeded(); |
4346 return frame->editor().command(commandName, userInterface ? CommandFromDOMWi
thUserInterface : CommandFromDOM); | 4346 return frame->editor().command(commandName, CommandFromDOM); |
4347 } | 4347 } |
4348 | 4348 |
4349 bool Document::execCommand(const String& commandName, bool userInterface, const
String& value) | 4349 bool Document::execCommand(const String& commandName, bool, const String& value) |
4350 { | 4350 { |
4351 // We don't allow recusrive |execCommand()| to protect against attack code. | 4351 // We don't allow recursive |execCommand()| to protect against attack code. |
4352 // Recursive call of |execCommand()| could be happened by moving iframe | 4352 // Recursive call of |execCommand()| could be happened by moving iframe |
4353 // with script triggered by insertion, e.g. <iframe src="javascript:..."> | 4353 // with script triggered by insertion, e.g. <iframe src="javascript:..."> |
4354 // <iframe onload="...">. This usage is valid as of the specification | 4354 // <iframe onload="...">. This usage is valid as of the specification |
4355 // although, it isn't common use case, rather it is used as attack code. | 4355 // although, it isn't common use case, rather it is used as attack code. |
4356 static bool inExecCommand = false; | 4356 static bool inExecCommand = false; |
4357 if (inExecCommand) { | 4357 if (inExecCommand) { |
4358 String message = "We don't execute document.execCommand() this time, bec
ause it is called recursively."; | 4358 String message = "We don't execute document.execCommand() this time, bec
ause it is called recursively."; |
4359 addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessage
Level, message)); | 4359 addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessage
Level, message)); |
4360 return false; | 4360 return false; |
4361 } | 4361 } |
4362 TemporaryChange<bool> executeScope(inExecCommand, true); | 4362 TemporaryChange<bool> executeScope(inExecCommand, true); |
4363 | 4363 |
4364 // Postpone DOM mutation events, which can execute scripts and change | 4364 // Postpone DOM mutation events, which can execute scripts and change |
4365 // DOM tree against implementation assumption. | 4365 // DOM tree against implementation assumption. |
4366 EventQueueScope eventQueueScope; | 4366 EventQueueScope eventQueueScope; |
4367 Editor::Command editorCommand = command(this, commandName, userInterface); | 4367 Editor::Command editorCommand = command(this, commandName); |
4368 Platform::current()->histogramSparse("WebCore.Document.execCommand", editorC
ommand.idForHistogram()); | 4368 Platform::current()->histogramSparse("WebCore.Document.execCommand", editorC
ommand.idForHistogram()); |
4369 return editorCommand.execute(value); | 4369 return editorCommand.execute(value); |
4370 } | 4370 } |
4371 | 4371 |
4372 bool Document::queryCommandEnabled(const String& commandName) | 4372 bool Document::queryCommandEnabled(const String& commandName) |
4373 { | 4373 { |
4374 return command(this, commandName).isEnabled(); | 4374 return command(this, commandName).isEnabled(); |
4375 } | 4375 } |
4376 | 4376 |
4377 bool Document::queryCommandIndeterm(const String& commandName) | 4377 bool Document::queryCommandIndeterm(const String& commandName) |
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5847 #ifndef NDEBUG | 5847 #ifndef NDEBUG |
5848 using namespace blink; | 5848 using namespace blink; |
5849 void showLiveDocumentInstances() | 5849 void showLiveDocumentInstances() |
5850 { | 5850 { |
5851 WeakDocumentSet& set = liveDocumentSet(); | 5851 WeakDocumentSet& set = liveDocumentSet(); |
5852 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5852 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5853 for (Document* document : set) | 5853 for (Document* document : set) |
5854 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5854 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
5855 } | 5855 } |
5856 #endif | 5856 #endif |
OLD | NEW |