K. Moon | 832a694 | 2022-10-31 20:11:31 +0000 | [diff] [blame] | 1 | // Copyright 2014 The PDFium Authors |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | e0345a4 | 2017-10-30 20:20:42 +0000 | [diff] [blame] | 7 | #include "fxjs/cjs_console.h" |
Tom Sepez | 3745841 | 2015-10-06 11:33:46 -0700 | [diff] [blame] | 8 | |
Lei Zhang | 3793595 | 2024-02-16 04:39:56 +0000 | [diff] [blame] | 9 | #include "core/fxcrt/span.h" |
Dan Sinclair | e0345a4 | 2017-10-30 20:20:42 +0000 | [diff] [blame] | 10 | #include "fxjs/cjs_event_context.h" |
Dan Sinclair | e0345a4 | 2017-10-30 20:20:42 +0000 | [diff] [blame] | 11 | #include "fxjs/cjs_object.h" |
Tom Sepez | 221f0b3 | 2018-06-04 22:11:27 +0000 | [diff] [blame] | 12 | #include "fxjs/js_define.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 13 | |
Dan Sinclair | c94a793 | 2017-10-26 16:48:57 -0400 | [diff] [blame] | 14 | const JSMethodSpec CJS_Console::MethodSpecs[] = {{"clear", clear_static}, |
| 15 | {"hide", hide_static}, |
| 16 | {"println", println_static}, |
Dan Sinclair | 909fa2d | 2017-12-12 01:53:28 +0000 | [diff] [blame] | 17 | {"show", show_static}}; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 18 | |
Tom Sepez | b495871 | 2020-10-13 20:30:43 +0000 | [diff] [blame] | 19 | uint32_t CJS_Console::ObjDefnID = 0; |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 20 | const char CJS_Console::kName[] = "console"; |
Dan Sinclair | 89d26c8 | 2017-10-26 12:21:28 -0400 | [diff] [blame] | 21 | |
Dan Sinclair | ef29953 | 2017-10-26 16:48:30 -0400 | [diff] [blame] | 22 | // static |
Tom Sepez | b495871 | 2020-10-13 20:30:43 +0000 | [diff] [blame] | 23 | uint32_t CJS_Console::GetObjDefnID() { |
Lei Zhang | ad1f7b4 | 2018-07-11 13:04:43 +0000 | [diff] [blame] | 24 | return ObjDefnID; |
| 25 | } |
| 26 | |
| 27 | // static |
Dan Sinclair | bef4d3e | 2017-10-26 16:49:38 -0400 | [diff] [blame] | 28 | void CJS_Console::DefineJSObjects(CFXJS_Engine* pEngine) { |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 29 | ObjDefnID = pEngine->DefineObj(CJS_Console::kName, FXJSOBJTYPE_STATIC, |
Dan Sinclair | 998fee3 | 2018-02-05 21:43:19 +0000 | [diff] [blame] | 30 | JSConstructor<CJS_Console>, JSDestructor); |
Tom Sepez | 8b4ddeb | 2018-06-11 15:55:17 +0000 | [diff] [blame] | 31 | DefineMethods(pEngine, ObjDefnID, MethodSpecs); |
Dan Sinclair | 89d26c8 | 2017-10-26 12:21:28 -0400 | [diff] [blame] | 32 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 33 | |
Tom Sepez | 36aae4f | 2018-06-04 19:44:37 +0000 | [diff] [blame] | 34 | CJS_Console::CJS_Console(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime) |
| 35 | : CJS_Object(pObject, pRuntime) {} |
Dan Sinclair | 998fee3 | 2018-02-05 21:43:19 +0000 | [diff] [blame] | 36 | |
Dan Sinclair | f743552 | 2018-02-05 22:27:22 +0000 | [diff] [blame] | 37 | CJS_Console::~CJS_Console() = default; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 38 | |
Tom Sepez | 3a6d058 | 2018-08-17 19:28:52 +0000 | [diff] [blame] | 39 | CJS_Result CJS_Console::clear(CJS_Runtime* pRuntime, |
Tom Sepez | 90589d4 | 2023-11-01 18:24:30 +0000 | [diff] [blame] | 40 | pdfium::span<v8::Local<v8::Value>> params) { |
Tom Sepez | 3a6d058 | 2018-08-17 19:28:52 +0000 | [diff] [blame] | 41 | return CJS_Result::Success(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 42 | } |
| 43 | |
Tom Sepez | 3a6d058 | 2018-08-17 19:28:52 +0000 | [diff] [blame] | 44 | CJS_Result CJS_Console::hide(CJS_Runtime* pRuntime, |
Tom Sepez | 90589d4 | 2023-11-01 18:24:30 +0000 | [diff] [blame] | 45 | pdfium::span<v8::Local<v8::Value>> params) { |
Tom Sepez | 3a6d058 | 2018-08-17 19:28:52 +0000 | [diff] [blame] | 46 | return CJS_Result::Success(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Tom Sepez | 90589d4 | 2023-11-01 18:24:30 +0000 | [diff] [blame] | 49 | CJS_Result CJS_Console::println(CJS_Runtime* pRuntime, |
| 50 | pdfium::span<v8::Local<v8::Value>> params) { |
Tom Sepez | 3a6d058 | 2018-08-17 19:28:52 +0000 | [diff] [blame] | 51 | return CJS_Result::Success(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Tom Sepez | 3a6d058 | 2018-08-17 19:28:52 +0000 | [diff] [blame] | 54 | CJS_Result CJS_Console::show(CJS_Runtime* pRuntime, |
Tom Sepez | 90589d4 | 2023-11-01 18:24:30 +0000 | [diff] [blame] | 55 | pdfium::span<v8::Local<v8::Value>> params) { |
Tom Sepez | 3a6d058 | 2018-08-17 19:28:52 +0000 | [diff] [blame] | 56 | return CJS_Result::Success(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 57 | } |