diff options
Diffstat (limited to 'WebKitTools/DumpRenderTree/LayoutTestController.cpp')
-rw-r--r-- | WebKitTools/DumpRenderTree/LayoutTestController.cpp | 86 |
1 files changed, 64 insertions, 22 deletions
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp index 02c77a4..edab29e 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp @@ -555,10 +555,65 @@ static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, static bool parsePageNumber(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber) { pageNumber = 0; - if (argumentCount != 1) + switch (argumentCount) { + case 1: + pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception)); + if (*exception) + return false; + // Fall through. + case 0: + return true; + default: + return false; + } +} + +static bool parsePageNumberSizeMarings(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber, int& width, int& height, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft) +{ + pageNumber = 0; + width = height = 0; + marginTop = marginRight = marginBottom = marginLeft = 0; + + switch (argumentCount) { + case 7: + marginLeft = static_cast<int>(JSValueToNumber(context, arguments[6], exception)); + if (*exception) + return false; + // Fall through. + case 6: + marginBottom = static_cast<int>(JSValueToNumber(context, arguments[5], exception)); + if (*exception) + return false; + // Fall through. + case 5: + marginRight = static_cast<int>(JSValueToNumber(context, arguments[4], exception)); + if (*exception) + return false; + // Fall through. + case 4: + marginTop = static_cast<int>(JSValueToNumber(context, arguments[3], exception)); + if (*exception) + return false; + // Fall through. + case 3: + height = static_cast<int>(JSValueToNumber(context, arguments[2], exception)); + if (*exception) + return false; + // Fall through. + case 2: + width = static_cast<int>(JSValueToNumber(context, arguments[1], exception)); + if (*exception) + return false; + // Fall through. + case 1: + pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception)); + if (*exception) + return false; + // Fall through. + return true; + default: return false; - pageNumber = static_cast<int>(JSValueToNumber(context, arguments[0], exception)); - return !*exception; + } } static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) @@ -612,24 +667,16 @@ static JSValueRef isPageBoxVisibleCallback(JSContextRef context, JSObjectRef fun return JSValueMakeBoolean(context, controller->isPageBoxVisible(pageNumber)); } -static JSValueRef pageAreaRectInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) -{ - int pageNumber = 0; - if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber)) - return JSValueMakeUndefined(context); - - LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); - return JSValueMakeString(context, controller->pageAreaRectInPixels(pageNumber).get()); -} - -static JSValueRef preferredPageSizeInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +static JSValueRef pageSizeAndMarginsInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { int pageNumber = 0; - if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber)) + int width = 0, height = 0; + int marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0; + if (!parsePageNumberSizeMarings(context, argumentCount, arguments, exception, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft)) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); - return JSValueMakeString(context, controller->preferredPageSizeInPixels(pageNumber).get()); + return JSValueMakeString(context, controller->pageSizeAndMarginsInPixels(pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).get()); } static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) @@ -1513,14 +1560,12 @@ static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef f } -#if PLATFORM(MAC) static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); controller->abortModal(); return JSValueMakeUndefined(context); } -#endif static JSValueRef markerTextForListItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { @@ -1648,9 +1693,7 @@ JSStaticValue* LayoutTestController::staticValues() JSStaticFunction* LayoutTestController::staticFunctions() { static JSStaticFunction staticFunctions[] = { -#if PLATFORM(MAC) { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, -#endif { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -1699,12 +1742,11 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, - { "pageAreaRectInPixels", pageAreaRectInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "pageSizeAndMarginsInPixels", pageSizeAndMarginsInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pageProperty", pagePropertyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, - { "preferredPageSizeInPixels", preferredPageSizeInPixelsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "sampleSVGAnimationForElementAtTime", sampleSVGAnimationForElementAtTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "printToPDF", dumpAsPDFCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, |