From bbdf00cf0913dcdf900c541a2dbf418b7f23788f Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Thu, 21 Jan 2016 16:45:51 +0300 Subject: Improved documentation of evaluateJavaScript(). Change-Id: I47d8f4c0e392ffb70655db9725b035d22a7cad91 Reviewed-by: Allan Sandfeld Jensen --- Source/WebKit/qt/WidgetApi/qwebframe.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'Source/WebKit/qt/WidgetApi/qwebframe.cpp') diff --git a/Source/WebKit/qt/WidgetApi/qwebframe.cpp b/Source/WebKit/qt/WidgetApi/qwebframe.cpp index e8faab881..38c649887 100644 --- a/Source/WebKit/qt/WidgetApi/qwebframe.cpp +++ b/Source/WebKit/qt/WidgetApi/qwebframe.cpp @@ -910,7 +910,22 @@ void QWebFrame::print(QPrinter *printer) const Evaluates the JavaScript defined by \a scriptSource using this frame as context and returns the result of the last executed statement. - \sa addToJavaScriptWindowObject(), javaScriptWindowObjectCleared() + \note This method may be very inefficient if \a scriptSource returns + + For example, evaluation of the next innocuously looking code may take a lot + of CPU and memory to execute: + + \code + var img = document.createElement('img'); + document.getElementById(\"foo\").appendChild(img); + \endcode + + This code returns appended DOM element, which is converted to QVariantMap + containing all its properties. To avoid this issue you can add "true" after + the last statement. + + \sa addToJavaScriptWindowObject(), javaScriptWindowObjectCleared(), + QWebElement::evaluateJavaScript() */ QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource) { -- cgit v1.2.1