Modified: trunk/Source/WebKit/ChangeLog (106992 => 106993)
--- trunk/Source/WebKit/ChangeLog 2012-02-07 22:20:25 UTC (rev 106992)
+++ trunk/Source/WebKit/ChangeLog 2012-02-07 22:52:27 UTC (rev 106993)
@@ -1,3 +1,35 @@
+2012-02-07 Rob Buis <rb...@rim.com>
+
+ [BlackBerry] Upstream DumpRenderTreeSupport
+ https://bugs.webkit.org/show_bug.cgi?id=77991
+
+ Reviewed by Antonio Gomes.
+
+ No functionalities changed, no new tests.
+
+ * blackberry/WebKitSupport/DumpRenderTreeSupport.cpp: Added.
+ (toGeolocationClientMock):
+ (DumpRenderTreeSupport::DumpRenderTreeSupport):
+ (DumpRenderTreeSupport::~DumpRenderTreeSupport):
+ (DumpRenderTreeSupport::_javascript_ObjectsCount):
+ (DumpRenderTreeSupport::garbageCollectorCollect):
+ (DumpRenderTreeSupport::garbageCollectorCollectOnAlternateThread):
+ (DumpRenderTreeSupport::setLinksIncludedInFocusChain):
+ (DumpRenderTreeSupport::linksIncludedInFocusChain):
+ (DumpRenderTreeSupport::dumpConfigurationForViewport):
+ (DumpRenderTreeSupport::numberOfPendingGeolocationPermissionRequests):
+ (DumpRenderTreeSupport::resetGeolocationMock):
+ (DumpRenderTreeSupport::setMockGeolocationError):
+ (DumpRenderTreeSupport::setMockGeolocationPermission):
+ (DumpRenderTreeSupport::setMockGeolocationPosition):
+ (DumpRenderTreeSupport::scalePageBy):
+ (DumpRenderTreeSupport::computedStyleIncludingVisitedInfo):
+ * blackberry/WebKitSupport/DumpRenderTreeSupport.h: Added.
+ (WebKit):
+ (WebCore):
+ (WTF):
+ (DumpRenderTreeSupport):
+
2012-02-07 Jacky Jiang <zhaji...@rim.com>
[BlackBerry] Upstream BlackBerry WebCoreSupport DeviceOrientationClientBlackBerry and DeviceMotionClientBlackBerry classes
Added: trunk/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.cpp (0 => 106993)
--- trunk/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.cpp (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.cpp 2012-02-07 22:52:27 UTC (rev 106993)
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "DumpRenderTreeSupport.h"
+
+#include "CSSComputedStyleDeclaration.h"
+#include "Frame.h"
+#include "GeolocationClientMock.h"
+#include "GeolocationController.h"
+#include "GeolocationError.h"
+#include "GeolocationPosition.h"
+#include "JSCSSStyleDeclaration.h"
+#include "JSElement.h"
+#include "Page.h"
+#include "ViewportArguments.h"
+#include "WebPage.h"
+#include "bindings/js/GCController.h"
+#include <_javascript_Core/APICast.h>
+#include <wtf/CurrentTime.h>
+
+using namespace BlackBerry::WebKit;
+using namespace WebCore;
+using namespace JSC;
+
+bool DumpRenderTreeSupport::s_linksIncludedInTabChain = true;
+
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+GeolocationClientMock* toGeolocationClientMock(GeolocationClient* client)
+{
+ ASSERT(getenv("drtRun"));
+ return static_cast<GeolocationClientMock*>(client);
+}
+#endif
+
+DumpRenderTreeSupport::DumpRenderTreeSupport()
+{
+}
+
+DumpRenderTreeSupport::~DumpRenderTreeSupport()
+{
+}
+
+int DumpRenderTreeSupport::_javascript_ObjectsCount()
+{
+ return JSDOMWindowBase::commonJSGlobalData()->heap.globalObjectCount();
+}
+
+void DumpRenderTreeSupport::garbageCollectorCollect()
+{
+ gcController().garbageCollectNow();
+}
+
+void DumpRenderTreeSupport::garbageCollectorCollectOnAlternateThread(bool waitUntilDone)
+{
+ gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone);
+}
+
+void DumpRenderTreeSupport::setLinksIncludedInFocusChain(bool enabled)
+{
+ s_linksIncludedInTabChain = enabled;
+}
+
+bool DumpRenderTreeSupport::linksIncludedInFocusChain()
+{
+ return s_linksIncludedInTabChain;
+}
+
+void DumpRenderTreeSupport::dumpConfigurationForViewport(Frame* mainFrame, int deviceDPI, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight)
+{
+ ViewportArguments arguments = mainFrame->page()->viewportArguments();
+ ViewportAttributes attrs = computeViewportAttributes(arguments, /* default layout width for non-mobile pages */ 980, deviceWidth, deviceHeight, deviceDPI, IntSize(availableWidth, availableHeight));
+ restrictMinimumScaleFactorToViewportSize(attrs, IntSize(availableWidth, availableHeight));
+ restrictScaleFactorToInitialScaleIfNotUserScalable(attrs);
+
+ fprintf(stdout, "viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n", attrs.layoutSize.width(), attrs.layoutSize.height(), attrs.initialScale, attrs.minimumScale, attrs.maximumScale, attrs.userScalable);
+}
+
+int DumpRenderTreeSupport::numberOfPendingGeolocationPermissionRequests(WebPage* webPage)
+{
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+ GeolocationClientMock* mockClient = toGeolocationClientMock(webPage->mainFrame()->page()->geolocationController()->client());
+ return mockClient->numberOfPendingPermissionRequests();
+#else
+ UNUSED_PARAM(webPage);
+ return -1;
+#endif
+}
+
+void DumpRenderTreeSupport::resetGeolocationMock(WebPage* webPage)
+{
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+ GeolocationClientMock* mockClient = toGeolocationClientMock(webPage->mainFrame()->page()->geolocationController()->client());
+ mockClient->reset();
+#endif
+}
+
+void DumpRenderTreeSupport::setMockGeolocationError(WebPage* webPage, int errorCode, const String message)
+{
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+ GeolocationError::ErrorCode code = GeolocationError::PositionUnavailable;
+ switch (errorCode) {
+ case PositionError::PERMISSION_DENIED:
+ code = GeolocationError::PermissionDenied;
+ break;
+ case PositionError::POSITION_UNAVAILABLE:
+ code = GeolocationError::PositionUnavailable;
+ break;
+ }
+
+ GeolocationClientMock* mockClient = static_cast<GeolocationClientMock*>(webPage->mainFrame()->page()->geolocationController()->client());
+ mockClient->setError(GeolocationError::create(code, message));
+#endif
+}
+
+void DumpRenderTreeSupport::setMockGeolocationPermission(WebPage* webPage, bool allowed)
+{
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+ GeolocationClientMock* mockClient = toGeolocationClientMock(webPage->mainFrame()->page()->geolocationController()->client());
+ mockClient->setPermission(allowed);
+#endif
+}
+
+void DumpRenderTreeSupport::setMockGeolocationPosition(WebPage* webPage, double latitude, double longitude, double accuracy)
+{
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+ GeolocationClientMock* mockClient = toGeolocationClientMock(webPage->mainFrame()->page()->geolocationController()->client());
+ mockClient->setPosition(GeolocationPosition::create(currentTime(), latitude, longitude, accuracy));
+#endif
+}
+
+void DumpRenderTreeSupport::scalePageBy(WebPage* webPage, float scaleFactor, float x, float y)
+{
+ webPage->mainFrame()->page()->setPageScaleFactor(scaleFactor, IntPoint(x, y));
+}
+
+JSValueRef DumpRenderTreeSupport::computedStyleIncludingVisitedInfo(JSContextRef context, JSValueRef value)
+{
+ JSLock lock(SilenceAssertionsOnly);
+ ExecState* exec = toJS(context);
+ if (!value)
+ return JSValueMakeUndefined(context);
+ JSValue jsValue = toJS(exec, value);
+ if (!jsValue.inherits(&JSElement::s_info))
+ return JSValueMakeUndefined(context);
+ JSElement* jsElement = static_cast<JSElement*>(asObject(jsValue));
+ Element* element = jsElement->impl();
+ RefPtr<CSSComputedStyleDeclaration> style = computedStyle(element, true);
+ return toRef(exec, toJS(exec, jsElement->globalObject(), style.get()));
+}
+
Added: trunk/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.h (0 => 106993)
--- trunk/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.h (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/DumpRenderTreeSupport.h 2012-02-07 22:52:27 UTC (rev 106993)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef DumpRenderTreeSupport_h
+#define DumpRenderTreeSupport_h
+
+#include <_javascript_Core/JSObjectRef.h>
+
+namespace BlackBerry {
+namespace WebKit {
+class WebPage;
+}
+}
+
+namespace WebCore {
+class Frame;
+}
+
+namespace WTF {
+class String;
+}
+
+class DumpRenderTreeSupport {
+public:
+ DumpRenderTreeSupport();
+ ~DumpRenderTreeSupport();
+
+ static void setLinksIncludedInFocusChain(bool);
+ static bool linksIncludedInFocusChain();
+
+ static int _javascript_ObjectsCount();
+ static void garbageCollectorCollect();
+ static void garbageCollectorCollectOnAlternateThread(bool waitUntilDone);
+
+ static void dumpConfigurationForViewport(WebCore::Frame* mainFrame, int deviceDPI, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
+
+ static int numberOfPendingGeolocationPermissionRequests(BlackBerry::WebKit::WebPage*);
+ static void resetGeolocationMock(BlackBerry::WebKit::WebPage*);
+ static void setMockGeolocationError(BlackBerry::WebKit::WebPage*, int errorCode, const WTF::String message);
+ static void setMockGeolocationPermission(BlackBerry::WebKit::WebPage*, bool allowed);
+ static void setMockGeolocationPosition(BlackBerry::WebKit::WebPage*, double latitude, double longitude, double accuracy);
+ static void scalePageBy(BlackBerry::WebKit::WebPage*, float, float, float);
+ static JSValueRef computedStyleIncludingVisitedInfo(JSContextRef, JSValueRef);
+
+private:
+ static bool s_linksIncludedInTabChain;
+};
+
+#endif