Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: fpdfsdk/javascript/JS_Value.cpp

Issue 1799773002: Move fpdfsdk/src up to fpdfsdk/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/javascript/JS_Value.h ('k') | fpdfsdk/javascript/PublicMethods.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/src/javascript/JS_Value.h" 7 #include "fpdfsdk/javascript/JS_Value.h"
8 8
9 #include <time.h> 9 #include <time.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <cmath> 12 #include <cmath>
13 #include <limits> 13 #include <limits>
14 #include <vector> 14 #include <vector>
15 15
16 #include "fpdfsdk/src/javascript/Document.h" 16 #include "fpdfsdk/javascript/Document.h"
17 #include "fpdfsdk/src/javascript/JS_Define.h" 17 #include "fpdfsdk/javascript/JS_Define.h"
18 #include "fpdfsdk/src/javascript/JS_Object.h" 18 #include "fpdfsdk/javascript/JS_Object.h"
19 19
20 static const FX_DWORD g_nan[2] = {0, 0x7FF80000}; 20 static const FX_DWORD g_nan[2] = {0, 0x7FF80000};
21 static double GetNan() { 21 static double GetNan() {
22 return *(double*)g_nan; 22 return *(double*)g_nan;
23 } 23 }
24 24
25 CJS_Value::CJS_Value(CJS_Runtime* pRuntime) 25 CJS_Value::CJS_Value(CJS_Runtime* pRuntime)
26 : m_eType(VT_unknown), m_pJSRuntime(pRuntime) { 26 : m_eType(VT_unknown), m_pJSRuntime(pRuntime) {}
27 }
28 27
29 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue, Type t) 28 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue, Type t)
30 : m_eType(t), m_pValue(pValue), m_pJSRuntime(pRuntime) { 29 : m_eType(t), m_pValue(pValue), m_pJSRuntime(pRuntime) {}
31 }
32 30
33 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const int& iValue) 31 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const int& iValue)
34 : m_pJSRuntime(pRuntime) { 32 : m_pJSRuntime(pRuntime) {
35 operator=(iValue); 33 operator=(iValue);
36 } 34 }
37 35
38 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const bool& bValue) 36 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const bool& bValue)
39 : m_pJSRuntime(pRuntime) { 37 : m_pJSRuntime(pRuntime) {
40 operator=(bValue); 38 operator=(bValue);
41 } 39 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 281
284 return FALSE; 282 return FALSE;
285 } 283 }
286 284
287 /* ---------------------------- CJS_PropValue ---------------------------- */ 285 /* ---------------------------- CJS_PropValue ---------------------------- */
288 286
289 CJS_PropValue::CJS_PropValue(const CJS_Value& value) 287 CJS_PropValue::CJS_PropValue(const CJS_Value& value)
290 : CJS_Value(value), m_bIsSetting(0) {} 288 : CJS_Value(value), m_bIsSetting(0) {}
291 289
292 CJS_PropValue::CJS_PropValue(CJS_Runtime* pRuntime) 290 CJS_PropValue::CJS_PropValue(CJS_Runtime* pRuntime)
293 : CJS_Value(pRuntime), m_bIsSetting(0) { 291 : CJS_Value(pRuntime), m_bIsSetting(0) {}
294 }
295 292
296 CJS_PropValue::~CJS_PropValue() { 293 CJS_PropValue::~CJS_PropValue() {}
297 }
298 294
299 void CJS_PropValue::operator<<(int iValue) { 295 void CJS_PropValue::operator<<(int iValue) {
300 ASSERT(!m_bIsSetting); 296 ASSERT(!m_bIsSetting);
301 CJS_Value::operator=(iValue); 297 CJS_Value::operator=(iValue);
302 } 298 }
303 299
304 void CJS_PropValue::operator>>(int& iValue) const { 300 void CJS_PropValue::operator>>(int& iValue) const {
305 ASSERT(m_bIsSetting); 301 ASSERT(m_bIsSetting);
306 iValue = CJS_Value::ToInt(); 302 iValue = CJS_Value::ToInt();
307 } 303 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 401
406 void CJS_PropValue::operator<<(CJS_Date& date) { 402 void CJS_PropValue::operator<<(CJS_Date& date) {
407 ASSERT(!m_bIsSetting); 403 ASSERT(!m_bIsSetting);
408 CJS_Value::operator=(date); 404 CJS_Value::operator=(date);
409 } 405 }
410 406
411 CJS_PropValue::operator v8::Local<v8::Value>() const { 407 CJS_PropValue::operator v8::Local<v8::Value>() const {
412 return m_pValue; 408 return m_pValue;
413 } 409 }
414 410
415 CJS_Array::CJS_Array(CJS_Runtime* pRuntime) : m_pJSRuntime(pRuntime) { 411 CJS_Array::CJS_Array(CJS_Runtime* pRuntime) : m_pJSRuntime(pRuntime) {}
416 }
417 412
418 CJS_Array::~CJS_Array() {} 413 CJS_Array::~CJS_Array() {}
419 414
420 void CJS_Array::Attach(v8::Local<v8::Array> pArray) { 415 void CJS_Array::Attach(v8::Local<v8::Array> pArray) {
421 m_pArray = pArray; 416 m_pArray = pArray;
422 } 417 }
423 418
424 FX_BOOL CJS_Array::IsAttached() { 419 FX_BOOL CJS_Array::IsAttached() {
425 return FALSE; 420 return FALSE;
426 } 421 }
(...skipping 20 matching lines...) Expand all
447 return FXJS_GetArrayLength(m_pArray); 442 return FXJS_GetArrayLength(m_pArray);
448 } 443 }
449 444
450 CJS_Array::operator v8::Local<v8::Array>() { 445 CJS_Array::operator v8::Local<v8::Array>() {
451 if (m_pArray.IsEmpty()) 446 if (m_pArray.IsEmpty())
452 m_pArray = FXJS_NewArray(m_pJSRuntime->GetIsolate()); 447 m_pArray = FXJS_NewArray(m_pJSRuntime->GetIsolate());
453 448
454 return m_pArray; 449 return m_pArray;
455 } 450 }
456 451
457 CJS_Date::CJS_Date(CJS_Runtime* pRuntime) : m_pJSRuntime(pRuntime) { 452 CJS_Date::CJS_Date(CJS_Runtime* pRuntime) : m_pJSRuntime(pRuntime) {}
458 }
459 453
460 CJS_Date::CJS_Date(CJS_Runtime* pRuntime, double dMsecTime) 454 CJS_Date::CJS_Date(CJS_Runtime* pRuntime, double dMsecTime)
461 : m_pJSRuntime(pRuntime) { 455 : m_pJSRuntime(pRuntime) {
462 m_pDate = FXJS_NewDate(pRuntime->GetIsolate(), dMsecTime); 456 m_pDate = FXJS_NewDate(pRuntime->GetIsolate(), dMsecTime);
463 } 457 }
464 458
465 CJS_Date::CJS_Date(CJS_Runtime* pRuntime, 459 CJS_Date::CJS_Date(CJS_Runtime* pRuntime,
466 int year, 460 int year,
467 int mon, 461 int mon,
468 int day, 462 int day,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 return (int)(365 * (y - 1970.0) + FXSYS_floor((y - 1969.0) / 4) - 647 return (int)(365 * (y - 1970.0) + FXSYS_floor((y - 1969.0) / 4) -
654 FXSYS_floor((y - 1901.0) / 100) + 648 FXSYS_floor((y - 1901.0) / 100) +
655 FXSYS_floor((y - 1601.0) / 400)); 649 FXSYS_floor((y - 1601.0) / 400));
656 } 650 }
657 651
658 double _TimeFromYear(int y) { 652 double _TimeFromYear(int y) {
659 return 86400000.0 * _DayFromYear(y); 653 return 86400000.0 * _DayFromYear(y);
660 } 654 }
661 655
662 double _TimeFromYearMonth(int y, int m) { 656 double _TimeFromYearMonth(int y, int m) {
663 static int daysMonth[12] = { 657 static int daysMonth[12] = {0, 31, 59, 90, 120, 151,
664 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; 658 181, 212, 243, 273, 304, 334};
665 static int leapDaysMonth[12] = { 659 static int leapDaysMonth[12] = {0, 31, 60, 91, 121, 152,
666 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; 660 182, 213, 244, 274, 305, 335};
667 int* pMonth = daysMonth; 661 int* pMonth = daysMonth;
668 if (_isLeapYear(y)) 662 if (_isLeapYear(y))
669 pMonth = leapDaysMonth; 663 pMonth = leapDaysMonth;
670 return _TimeFromYear(y) + ((double)pMonth[m]) * 86400000; 664 return _TimeFromYear(y) + ((double)pMonth[m]) * 86400000;
671 } 665 }
672 666
673 int _Day(double t) { 667 int _Day(double t) {
674 return (int)FXSYS_floor(t / 86400000); 668 return (int)FXSYS_floor(t / 86400000);
675 } 669 }
676 670
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 v8::Local<v8::Value> v = 801 v8::Local<v8::Value> v =
808 context->Global() 802 context->Global()
809 ->Get(context, v8::String::NewFromUtf8(pIsolate, "Date", 803 ->Get(context, v8::String::NewFromUtf8(pIsolate, "Date",
810 v8::NewStringType::kNormal) 804 v8::NewStringType::kNormal)
811 .ToLocalChecked()) 805 .ToLocalChecked())
812 .ToLocalChecked(); 806 .ToLocalChecked();
813 if (v->IsObject()) { 807 if (v->IsObject()) {
814 v8::Local<v8::Object> o = v->ToObject(context).ToLocalChecked(); 808 v8::Local<v8::Object> o = v->ToObject(context).ToLocalChecked();
815 v = o->Get(context, v8::String::NewFromUtf8(pIsolate, "parse", 809 v = o->Get(context, v8::String::NewFromUtf8(pIsolate, "parse",
816 v8::NewStringType::kNormal) 810 v8::NewStringType::kNormal)
817 .ToLocalChecked()).ToLocalChecked(); 811 .ToLocalChecked())
812 .ToLocalChecked();
818 if (v->IsFunction()) { 813 if (v->IsFunction()) {
819 v8::Local<v8::Function> funC = v8::Local<v8::Function>::Cast(v); 814 v8::Local<v8::Function> funC = v8::Local<v8::Function>::Cast(v);
820 815
821 const int argc = 1; 816 const int argc = 1;
822 v8::Local<v8::String> timeStr = FXJS_WSToJSString(pIsolate, str); 817 v8::Local<v8::String> timeStr = FXJS_WSToJSString(pIsolate, str);
823 v8::Local<v8::Value> argv[argc] = {timeStr}; 818 v8::Local<v8::Value> argv[argc] = {timeStr};
824 v = funC->Call(context, context->Global(), argc, argv).ToLocalChecked(); 819 v = funC->Call(context, context->Global(), argc, argv).ToLocalChecked();
825 if (v->IsNumber()) { 820 if (v->IsNumber()) {
826 double date = v->ToNumber(context).ToLocalChecked()->Value(); 821 double date = v->ToNumber(context).ToLocalChecked()->Value();
827 if (!_isfinite(date)) 822 if (!_isfinite(date))
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 for (int i = 0; i < nKeywords; ++i) { 897 for (int i = 0; i < nKeywords; ++i) {
903 const wchar_t* property = va_arg(ap, const wchar_t*); 898 const wchar_t* property = va_arg(ap, const wchar_t*);
904 v8::Local<v8::Value> v8Value = 899 v8::Local<v8::Value> v8Value =
905 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); 900 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property);
906 if (!v8Value->IsUndefined()) 901 if (!v8Value->IsUndefined())
907 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); 902 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown);
908 } 903 }
909 va_end(ap); 904 va_end(ap);
910 return result; 905 return result;
911 } 906 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/JS_Value.h ('k') | fpdfsdk/javascript/PublicMethods.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698