2 * Copyright (C) 2015 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #import "UIScriptController.h"
31 #import "DumpRenderTreeBrowserView.h"
32 #import "UIScriptContext.h"
33 #import <WebCore/FloatRect.h>
34 #import <wtf/MainThread.h>
36 extern DumpRenderTreeBrowserView *gWebBrowserView;
37 extern DumpRenderTreeWebScrollView *gWebScrollView;
41 void UIScriptController::doAsyncTask(JSValueRef callback)
43 unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
45 dispatch_async(dispatch_get_main_queue(), ^{
48 m_context->asyncTaskComplete(callbackID);
52 void UIScriptController::zoomToScale(double scale, JSValueRef callback)
54 RefPtr<UIScriptController> protectedThis(this);
55 unsigned callbackID = protectedThis->context()->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
57 dispatch_async(dispatch_get_main_queue(), ^{
58 [gWebScrollView zoomToScale:scale animated:YES completionHandler:^{
59 if (!protectedThis->context())
61 protectedThis->context()->asyncTaskComplete(callbackID);
66 void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef)
70 double UIScriptController::zoomScale() const
72 return gWebScrollView.zoomScale;
75 void UIScriptController::touchDownAtPoint(long x, long y, long touchCount, JSValueRef callback)
79 void UIScriptController::liftUpAtPoint(long x, long y, long touchCount, JSValueRef callback)
83 void UIScriptController::singleTapAtPoint(long x, long y, JSValueRef callback)
87 void UIScriptController::doubleTapAtPoint(long x, long y, JSValueRef callback)
91 void UIScriptController::dragFromPointToPoint(long startX, long startY, long endX, long endY, double durationSeconds, JSValueRef callback)
95 void UIScriptController::longPressAtPoint(long x, long y, JSValueRef)
99 void UIScriptController::stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback)
103 void UIScriptController::stylusMoveToPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback)
107 void UIScriptController::stylusUpAtPoint(long x, long y, JSValueRef callback)
111 void UIScriptController::stylusTapAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback)
115 void UIScriptController::sendEventStream(JSStringRef eventsJSON, JSValueRef callback)
119 void UIScriptController::typeCharacterUsingHardwareKeyboard(JSStringRef character, JSValueRef callback)
123 void UIScriptController::selectTextCandidateAtIndex(long, JSValueRef)
127 void UIScriptController::keyDownUsingHardwareKeyboard(JSStringRef character, JSValueRef callback)
131 void UIScriptController::keyUpUsingHardwareKeyboard(JSStringRef character, JSValueRef callback)
135 void UIScriptController::dismissFormAccessoryView()
139 void UIScriptController::selectFormAccessoryPickerRow(long rowIndex)
143 JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfaceItem) const
148 void UIScriptController::scrollToOffset(long, long)
152 void UIScriptController::keyboardAccessoryBarNext()
156 void UIScriptController::keyboardAccessoryBarPrevious()
160 double UIScriptController::minimumZoomScale() const
162 return gWebScrollView.minimumZoomScale;
165 double UIScriptController::maximumZoomScale() const
167 return gWebScrollView.maximumZoomScale;
170 JSObjectRef UIScriptController::contentVisibleRect() const
172 CGRect contentVisibleRect = [gWebBrowserView documentVisibleRect];
173 WebCore::FloatRect rect(contentVisibleRect.origin.x, contentVisibleRect.origin.y, contentVisibleRect.size.width, contentVisibleRect.size.height);
174 return m_context->objectFromRect(rect);
177 void UIScriptController::platformSetDidStartFormControlInteractionCallback()
181 void UIScriptController::platformSetDidEndFormControlInteractionCallback()
185 void UIScriptController::platformSetDidShowForcePressPreviewCallback()
189 void UIScriptController::platformSetDidDismissForcePressPreviewCallback()
193 void UIScriptController::platformSetWillBeginZoomingCallback()
197 void UIScriptController::platformSetDidEndZoomingCallback()
201 void UIScriptController::platformSetDidShowKeyboardCallback()
205 void UIScriptController::platformSetDidHideKeyboardCallback()
209 void UIScriptController::platformSetDidEndScrollingCallback()
213 void UIScriptController::platformClearAllCallbacks()
217 JSObjectRef UIScriptController::selectionRangeViewRects() const
222 void UIScriptController::removeAllDynamicDictionaries()
226 JSRetainPtr<JSStringRef> UIScriptController::scrollingTreeAsText() const
233 #endif // PLATFORM(IOS)