summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/color.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-02-16 17:01:00 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-02-21 15:18:27 +0000
commitb1670b5cca9a59dfb612ef9eb891a70dd716bf9c (patch)
treee624b1ca93721894ff29a14bb52443bf4f952cf6 /fpdfsdk/javascript/color.cpp
parent026f3d306d339585612d63a9f6ac5ed8839a3179 (diff)
downloadpdfium-b1670b5cca9a59dfb612ef9eb891a70dd716bf9c.tar.xz
Pass CJS_Runtime to JS callbacks.
This is much more convenient, since only a fraction of them need an IJS_EventContext, which can be obtained from the CJS_Runtime. Make GetCurrentEventContext() specific to CJS_Runtime, and return the concrete type. This saves a lot of casting. Change-Id: If79a3bcbf44de513f3caace153099234cc313d47 Reviewed-on: https://pdfium-review.googlesource.com/2793 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/color.cpp')
-rw-r--r--fpdfsdk/javascript/color.cpp33
1 files changed, 15 insertions, 18 deletions
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index be26987ff7..90a8495b86 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -133,20 +133,19 @@ void color::ConvertArrayToPWLColor(CJS_Runtime* pRuntime,
}
}
-#define JS_IMPLEMENT_COLORPROP(prop, var) \
- bool color::prop(IJS_EventContext* cc, CJS_PropValue& vp, \
- CFX_WideString& sError) { \
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); \
- CJS_Array array; \
- if (vp.IsGetting()) { \
- ConvertPWLColorToArray(pRuntime, var, &array); \
- vp << array; \
- } else { \
- if (!vp.GetJSValue()->ConvertToArray(pRuntime, array)) \
- return false; \
- ConvertArrayToPWLColor(pRuntime, array, &var); \
- } \
- return true; \
+#define JS_IMPLEMENT_COLORPROP(prop, var) \
+ bool color::prop(CJS_Runtime* pRuntime, CJS_PropValue& vp, \
+ CFX_WideString& sError) { \
+ CJS_Array array; \
+ if (vp.IsGetting()) { \
+ ConvertPWLColorToArray(pRuntime, var, &array); \
+ vp << array; \
+ } else { \
+ if (!vp.GetJSValue()->ConvertToArray(pRuntime, array)) \
+ return false; \
+ ConvertArrayToPWLColor(pRuntime, array, &var); \
+ } \
+ return true; \
}
JS_IMPLEMENT_COLORPROP(transparent, m_crTransparent)
@@ -162,7 +161,7 @@ JS_IMPLEMENT_COLORPROP(dkGray, m_crDKGray)
JS_IMPLEMENT_COLORPROP(gray, m_crGray)
JS_IMPLEMENT_COLORPROP(ltGray, m_crLTGray)
-bool color::convert(IJS_EventContext* cc,
+bool color::convert(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -170,7 +169,6 @@ bool color::convert(IJS_EventContext* cc,
if (iSize < 2)
return false;
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
CJS_Array aSource;
if (!params[0].ConvertToArray(pRuntime, aSource))
return false;
@@ -200,14 +198,13 @@ bool color::convert(IJS_EventContext* cc,
return true;
}
-bool color::equal(IJS_EventContext* cc,
+bool color::equal(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
if (params.size() < 2)
return false;
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
CJS_Array array1;
CJS_Array array2;
if (!params[0].ConvertToArray(pRuntime, array1))