Allow WebKit clients to specify a minimum effective width for layout.
[WebKit-https.git] / Tools / TestRunnerShared / UIScriptContext / UIScriptController.cpp
index 612c9e2..e2d0535 100644 (file)
 #include "JSUIScriptController.h"
 #include "UIScriptContext.h"
 #include <JavaScriptCore/JSValueRef.h>
+#include <JavaScriptCore/OpaqueJSString.h>
 
 namespace WTR {
 
+DeviceOrientation* toDeviceOrientation(JSContextRef context, JSValueRef value)
+{
+    static DeviceOrientation values[] = {
+        DeviceOrientation::Portrait,
+        DeviceOrientation::PortraitUpsideDown,
+        DeviceOrientation::LandscapeLeft,
+        DeviceOrientation::LandscapeRight
+    };
+
+    auto option = adopt(JSValueToStringCopy(context, value, nullptr));
+    if (option.get()->string() == "portrait")
+        return &values[0];
+        
+    if (option.get()->string() == "portrait-upsidedown")
+        return &values[1];
+        
+    if (option.get()->string() == "landscape-left")
+        return &values[2];
+        
+    if (option.get()->string() == "landscape-right")
+        return &values[3];
+        
+    return nullptr;
+}
+
 UIScriptController::UIScriptController(UIScriptContext& context)
     : m_context(&context)
 {
 }
 
-#if !PLATFORM(IOS)
+#if !PLATFORM(IOS_FAMILY)
 void UIScriptController::checkForOutstandingCallbacks()
 {
 }
@@ -180,10 +206,23 @@ JSValueRef UIScriptController::didHideKeyboardCallback() const
 }
 
 #if !PLATFORM(COCOA)
+
 void UIScriptController::zoomToScale(double, JSValueRef)
 {
 }
 
+void UIScriptController::setViewScale(double)
+{
+}
+
+void UIScriptController::setMinimumEffectiveWidth(double)
+{
+}
+
+void UIScriptController::resignFirstResponder()
+{
+}
+
 void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef)
 {
 }
@@ -192,14 +231,28 @@ JSObjectRef UIScriptController::contentsOfUserInterfaceItem(JSStringRef interfac
 {
     return nullptr;
 }
-#endif
+    
+void UIScriptController::setDefaultCalendarType(JSStringRef calendarIdentifier)
+{
+}
+
+JSObjectRef UIScriptController::calendarType() const
+{
+    return nullptr;
+}
+
+void UIScriptController::toggleCapsLock(JSValueRef)
+{
+}
+
+#endif // !PLATFORM(COCOA)
 
 void UIScriptController::playBackEventStream(JSStringRef stream, JSValueRef callback)
 {
     platformPlayBackEventStream(stream, callback);
 }
 
-#if !PLATFORM(IOS)
+#if !PLATFORM(IOS_FAMILY)
 void UIScriptController::touchDownAtPoint(long x, long y, long touchCount, JSValueRef)
 {
 }
@@ -244,32 +297,43 @@ void UIScriptController::sendEventStream(JSStringRef eventsJSON, JSValueRef call
 {
 }
 
+void UIScriptController::enterText(JSStringRef)
+{
+}
+
 void UIScriptController::typeCharacterUsingHardwareKeyboard(JSStringRef, JSValueRef)
 {
 }
 
-void UIScriptController::keyUpUsingHardwareKeyboard(JSStringRef, JSValueRef)
+void UIScriptController::keyDown(JSStringRef, JSValueRef)
 {
 }
 
-void UIScriptController::selectTextCandidateAtIndex(long, JSValueRef)
+void UIScriptController::dismissFormAccessoryView()
 {
 }
 
-void UIScriptController::waitForTextPredictionsViewAndSelectCandidateAtIndex(long, unsigned, float)
+void UIScriptController::setTimePickerValue(long, long)
 {
 }
 
-void UIScriptController::keyDownUsingHardwareKeyboard(JSStringRef, JSValueRef)
+void UIScriptController::selectFormAccessoryPickerRow(long)
 {
 }
 
-void UIScriptController::dismissFormAccessoryView()
+JSRetainPtr<JSStringRef> UIScriptController::textContentType() const
 {
+    return nullptr;
 }
 
-void UIScriptController::selectFormAccessoryPickerRow(long)
+JSRetainPtr<JSStringRef> UIScriptController::selectFormPopoverTitle() const
 {
+    return nullptr;
+}
+
+JSRetainPtr<JSStringRef> UIScriptController::formInputLabel() const
+{
+    return nullptr;
 }
 
 void UIScriptController::scrollToOffset(long x, long y)
@@ -292,6 +356,15 @@ void UIScriptController::keyboardAccessoryBarPrevious()
 {
 }
 
+void UIScriptController::applyAutocorrection(JSStringRef, JSStringRef, JSValueRef)
+{
+}
+
+bool UIScriptController::isShowingKeyboard() const
+{
+    return false;
+}
+
 double UIScriptController::zoomScale() const
 {
     return 1;
@@ -321,7 +394,7 @@ JSObjectRef UIScriptController::contentVisibleRect() const
     return nullptr;
 }
 
-JSObjectRef UIScriptController::selectionRangeViewRects() const
+JSObjectRef UIScriptController::textSelectionRangeRects() const
 {
     return nullptr;
 }
@@ -331,6 +404,26 @@ JSObjectRef UIScriptController::textSelectionCaretRect() const
     return nullptr;
 }
 
+JSObjectRef UIScriptController::selectionStartGrabberViewRect() const
+{
+    return nullptr;
+}
+
+JSObjectRef UIScriptController::selectionCaretViewRect() const
+{
+    return nullptr;
+}
+
+JSObjectRef UIScriptController::selectionRangeViewRects() const
+{
+    return nullptr;
+}
+
+JSObjectRef UIScriptController::selectionEndGrabberViewRect() const
+{
+    return nullptr;
+}
+
 JSObjectRef UIScriptController::inputViewBounds() const
 {
     return nullptr;
@@ -399,10 +492,40 @@ JSRetainPtr<JSStringRef> UIScriptController::accessibilitySpeakSelectionContent(
     return nullptr;
 }
 
+void UIScriptController::setSafeAreaInsets(double top, double right, double bottom, double left)
+{
+}
+
+void UIScriptController::drawSquareInEditableImage()
+{
+}
+
+long UIScriptController::numberOfStrokesInEditableImage()
+{
+    return 0;
+}
+
+JSObjectRef UIScriptController::attachmentInfo(JSStringRef)
+{
+    return nullptr;
+}
+
 #endif
 
 #if !PLATFORM(COCOA)
 
+void UIScriptController::simulateRotation(DeviceOrientation*, JSValueRef callback)
+{
+}
+
+void UIScriptController::simulateRotationLikeSafari(DeviceOrientation*, JSValueRef callback)
+{
+}
+
+void UIScriptController::findString(JSStringRef, unsigned long options, unsigned long maxCount)
+{
+}
+
 void UIScriptController::removeViewFromWindow(JSValueRef)
 {
 }
@@ -411,28 +534,50 @@ void UIScriptController::addViewToWindow(JSValueRef)
 {
 }
 
+void UIScriptController::beginBackSwipe(JSValueRef callback)
+{
+}
+
+void UIScriptController::completeBackSwipe(JSValueRef callback)
+{
+}
+
+void UIScriptController::setShareSheetCompletesImmediatelyWithResolution(bool)
+{
+}
+
+bool UIScriptController::isShowingDataListSuggestions() const
+{
+    return false;
+}
+
+void UIScriptController::overridePreference(JSStringRef, JSStringRef)
+{
+}
+
 #endif // !PLATFORM(COCOA)
 
 #if !PLATFORM(MAC)
 
-void UIScriptController::overridePreference(JSStringRef, JSStringRef)
+void UIScriptController::replaceTextAtRange(JSStringRef, int, int)
 {
 }
 
-void UIScriptController::insertText(JSStringRef, int, int)
+void UIScriptController::platformPlayBackEventStream(JSStringRef, JSValueRef)
 {
 }
 
-void UIScriptController::beginBackSwipe(JSValueRef callback)
+void UIScriptController::firstResponderSuppressionForWebView(bool)
 {
 }
 
-void UIScriptController::completeBackSwipe(JSValueRef callback)
+void UIScriptController::makeWindowContentViewFirstResponder()
 {
 }
 
-void UIScriptController::platformPlayBackEventStream(JSStringRef, JSValueRef)
+bool UIScriptController::isWindowContentViewFirstResponder() const
 {
+    return false;
 }
 
 #endif