summaryrefslogtreecommitdiff
path: root/fxjs/cjs_event.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-20 16:10:13 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-20 16:10:13 +0000
commitb6b01cb2cbaf6b38736f4dfebb9b6cdc243960f9 (patch)
tree3219404f5dbafe19205ce85d19acaf3b1178f977 /fxjs/cjs_event.cpp
parentb3345feca2741cef2073d18da414237589528dd0 (diff)
downloadpdfium-b6b01cb2cbaf6b38736f4dfebb9b6cdc243960f9.tar.xz
Re-work some more c_str() usage.
Many of these are converting ByteString => c_str => ByteStringView, since the ByteStringView ctor is implicit. This is unfortunate, since that involves a strlen() which the ByteString already knows if we use AsStringView() instead. This changed one test result where we can now return the string "\0" instead of "" -- since strlen no longer eats the NUL. This seems consistent, say, with String.fromCharCode(). Change-Id: I17f68d1a1f4b352960208f9148e68ab4c4d78bd2 Reviewed-on: https://pdfium-review.googlesource.com/35590 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/cjs_event.cpp')
-rw-r--r--fxjs/cjs_event.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp
index 397d8b890c..c10f8858a9 100644
--- a/fxjs/cjs_event.cpp
+++ b/fxjs/cjs_event.cpp
@@ -51,10 +51,9 @@ CJS_Event::~CJS_Event() = default;
CJS_Return CJS_Event::get_change(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->Change().c_str()));
+ return CJS_Return(pRuntime->NewString(pEvent->Change().AsStringView()));
}
CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime,
@@ -73,11 +72,10 @@ CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime,
CJS_Return CJS_Event::get_change_ex(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->ChangeEx().c_str()));
+ return CJS_Return(pRuntime->NewString(pEvent->ChangeEx().AsStringView()));
}
CJS_Return CJS_Event::set_change_ex(CJS_Runtime* pRuntime,
@@ -256,7 +254,6 @@ CJS_Return CJS_Event::set_source(CJS_Runtime* pRuntime,
CJS_Return CJS_Event::get_target(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pEvent->Target_Field()->ToV8Object());
@@ -269,10 +266,9 @@ CJS_Return CJS_Event::set_target(CJS_Runtime* pRuntime,
CJS_Return CJS_Event::get_target_name(CJS_Runtime* pRuntime) {
ASSERT(pRuntime->GetCurrentEventContext());
-
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pRuntime->NewString(pEvent->TargetName().c_str()));
+ return CJS_Return(pRuntime->NewString(pEvent->TargetName().AsStringView()));
}
CJS_Return CJS_Event::set_target_name(CJS_Runtime* pRuntime,
@@ -304,7 +300,7 @@ CJS_Return CJS_Event::get_value(CJS_Runtime* pRuntime) {
if (!pEvent->m_pValue)
return CJS_Return(JSMessage::kBadObjectError);
- return CJS_Return(pRuntime->NewString(pEvent->Value().c_str()));
+ return CJS_Return(pRuntime->NewString(pEvent->Value().AsStringView()));
}
CJS_Return CJS_Event::set_value(CJS_Runtime* pRuntime,