зеркало из https://github.com/mozilla/pjs.git
Added scrollByLines, scrollByPages methods to DOM window object. b=46858,r=valeski
This commit is contained in:
Родитель
939a715e0d
Коммит
4db0015fc1
|
@ -63,6 +63,10 @@ public:
|
|||
|
||||
NS_IMETHOD ScrollBy(PRInt32 aXScrollDif, PRInt32 aYScrollDif)=0;
|
||||
|
||||
NS_IMETHOD ScrollByLines(PRInt32 aNumLines)=0;
|
||||
|
||||
NS_IMETHOD ScrollByPages(PRInt32 aNumPages)=0;
|
||||
|
||||
NS_IMETHOD GetSelection(nsIDOMSelection** aReturn)=0;
|
||||
};
|
||||
|
||||
|
@ -79,6 +83,8 @@ public:
|
|||
NS_IMETHOD GetScrollY(PRInt32* aScrollY); \
|
||||
NS_IMETHOD ScrollTo(PRInt32 aXScroll, PRInt32 aYScroll); \
|
||||
NS_IMETHOD ScrollBy(PRInt32 aXScrollDif, PRInt32 aYScrollDif); \
|
||||
NS_IMETHOD ScrollByLines(PRInt32 aNumLines); \
|
||||
NS_IMETHOD ScrollByPages(PRInt32 aNumPages); \
|
||||
NS_IMETHOD GetSelection(nsIDOMSelection** aReturn); \
|
||||
|
||||
|
||||
|
@ -95,6 +101,8 @@ public:
|
|||
NS_IMETHOD GetScrollY(PRInt32* aScrollY) { return _to GetScrollY(aScrollY); } \
|
||||
NS_IMETHOD ScrollTo(PRInt32 aXScroll, PRInt32 aYScroll) { return _to ScrollTo(aXScroll, aYScroll); } \
|
||||
NS_IMETHOD ScrollBy(PRInt32 aXScrollDif, PRInt32 aYScrollDif) { return _to ScrollBy(aXScrollDif, aYScrollDif); } \
|
||||
NS_IMETHOD ScrollByLines(PRInt32 aNumLines) { return _to ScrollByLines(aNumLines); } \
|
||||
NS_IMETHOD ScrollByPages(PRInt32 aNumPages) { return _to ScrollByPages(aNumPages); } \
|
||||
NS_IMETHOD GetSelection(nsIDOMSelection** aReturn) { return _to GetSelection(aReturn); } \
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ interface Window {
|
|||
readonly attribute long scrollY;
|
||||
void scrollTo(in long xScroll, in long yScroll);
|
||||
void scrollBy(in long xScrollDif, in long yScrollDif);
|
||||
void scrollByLines(in long numLines);
|
||||
void scrollByPages(in long numPages);
|
||||
Selection getSelection();
|
||||
};
|
||||
|
||||
|
|
|
@ -946,6 +946,8 @@ enum nsDOMProp {
|
|||
NS_DOM_PROP_WINDOW_SCROLLBARS,
|
||||
NS_DOM_PROP_WINDOW_SCROLLBY,
|
||||
NS_DOM_PROP_WINDOW_SCROLLTO,
|
||||
NS_DOM_PROP_WINDOW_SCROLLBYLINES,
|
||||
NS_DOM_PROP_WINDOW_SCROLLBYPAGES,
|
||||
NS_DOM_PROP_WINDOW_SCROLLX,
|
||||
NS_DOM_PROP_WINDOW_SCROLLY,
|
||||
NS_DOM_PROP_WINDOW_TOP,
|
||||
|
|
|
@ -1780,6 +1780,36 @@ NS_IMETHODIMP GlobalWindowImpl::ScrollBy(PRInt32 aXScrollDif,
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP GlobalWindowImpl::ScrollByLines(PRInt32 numLines)
|
||||
{
|
||||
nsresult result;
|
||||
nsIScrollableView *view = nsnull; // no addref/release for views
|
||||
float p2t, t2p;
|
||||
|
||||
result = GetScrollInfo(&view, &p2t, &t2p);
|
||||
if (view)
|
||||
{
|
||||
result = view->ScrollByLines(0, numLines);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP GlobalWindowImpl::ScrollByPages(PRInt32 numPages)
|
||||
{
|
||||
nsresult result;
|
||||
nsIScrollableView *view = nsnull; // no addref/release for views
|
||||
float p2t, t2p;
|
||||
|
||||
result = GetScrollInfo(&view, &p2t, &t2p);
|
||||
if (view)
|
||||
{
|
||||
result = view->ScrollByPages(numPages);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP GlobalWindowImpl::ClearTimeout(PRInt32 aTimerID)
|
||||
{
|
||||
return ClearTimeoutOrInterval(aTimerID);
|
||||
|
|
|
@ -2726,6 +2726,92 @@ WindowScrollBy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ScrollByLines
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
WindowScrollByLines(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMWindow *nativeThis = (nsIDOMWindow*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 b0;
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
*rval = JSVAL_NULL;
|
||||
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
|
||||
if (!secMan)
|
||||
return PR_FALSE;
|
||||
result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOW_SCROLLBYLINES, PR_FALSE);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
if (argc < 1) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR);
|
||||
}
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_NUMBER_ERR);
|
||||
}
|
||||
|
||||
result = nativeThis->ScrollByLines(b0);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ScrollByPages
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
WindowScrollByPages(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMWindow *nativeThis = (nsIDOMWindow*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 b0;
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
*rval = JSVAL_NULL;
|
||||
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
|
||||
if (!secMan)
|
||||
return PR_FALSE;
|
||||
result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOW_SCROLLBYPAGES, PR_FALSE);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
if (argc < 1) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR);
|
||||
}
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_NUMBER_ERR);
|
||||
}
|
||||
|
||||
result = nativeThis->ScrollByPages(b0);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetSelection
|
||||
//
|
||||
|
@ -4586,6 +4672,8 @@ static JSFunctionSpec WindowMethods[] =
|
|||
{
|
||||
{"scrollTo", WindowScrollTo, 2},
|
||||
{"scrollBy", WindowScrollBy, 2},
|
||||
{"scrollByLines", WindowScrollByLines, 1},
|
||||
{"scrollByPages", WindowScrollByPages, 1},
|
||||
{"getSelection", WindowGetSelection, 0},
|
||||
{"dump", WindowInternalDump, 1},
|
||||
{"alert", WindowInternalAlert, 0},
|
||||
|
|
Загрузка…
Ссылка в новой задаче