Commit 2d134ca3 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

bindings: Use non-null APIs

This CL replaces some foo() and hasFoo() with fooNonNull() and
hasFooNonNull(), where it will be compile failure on IDL compiler
migration.


Bug: 839389
Change-Id: I4b51fe335af0c2555c702b03f0609d71d231b296
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2213655
Auto-Submit: Hitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772450}
parent 02922e8e
...@@ -315,10 +315,10 @@ StringKeyframeVector ConvertArrayForm(Element* element, ...@@ -315,10 +315,10 @@ StringKeyframeVector ConvertArrayForm(Element* element,
double previous_offset = -std::numeric_limits<double>::infinity(); double previous_offset = -std::numeric_limits<double>::infinity();
const wtf_size_t num_processed_keyframes = processed_base_keyframes.size(); const wtf_size_t num_processed_keyframes = processed_base_keyframes.size();
for (wtf_size_t i = 0; i < num_processed_keyframes; ++i) { for (wtf_size_t i = 0; i < num_processed_keyframes; ++i) {
if (!processed_base_keyframes[i]->hasOffset()) if (!processed_base_keyframes[i]->hasOffsetNonNull())
continue; continue;
double offset = processed_base_keyframes[i]->offset(); double offset = processed_base_keyframes[i]->offsetNonNull();
if (offset < previous_offset) { if (offset < previous_offset) {
exception_state.ThrowTypeError( exception_state.ThrowTypeError(
"Offsets must be montonically non-decreasing."); "Offsets must be montonically non-decreasing.");
...@@ -331,10 +331,10 @@ StringKeyframeVector ConvertArrayForm(Element* element, ...@@ -331,10 +331,10 @@ StringKeyframeVector ConvertArrayForm(Element* element,
// offset is non-null and less than zero or greater than one, throw a // offset is non-null and less than zero or greater than one, throw a
// TypeError and abort these steps. // TypeError and abort these steps.
for (wtf_size_t i = 0; i < num_processed_keyframes; ++i) { for (wtf_size_t i = 0; i < num_processed_keyframes; ++i) {
if (!processed_base_keyframes[i]->hasOffset()) if (!processed_base_keyframes[i]->hasOffsetNonNull())
continue; continue;
double offset = processed_base_keyframes[i]->offset(); double offset = processed_base_keyframes[i]->offsetNonNull();
if (offset < 0 || offset > 1) { if (offset < 0 || offset > 1) {
exception_state.ThrowTypeError( exception_state.ThrowTypeError(
"Offsets must be null or in the range [0,1]."); "Offsets must be null or in the range [0,1].");
......
...@@ -25,11 +25,12 @@ AnimationPlaybackEvent::AnimationPlaybackEvent( ...@@ -25,11 +25,12 @@ AnimationPlaybackEvent::AnimationPlaybackEvent(
const AtomicString& type, const AtomicString& type,
const AnimationPlaybackEventInit* initializer) const AnimationPlaybackEventInit* initializer)
: Event(type, initializer) { : Event(type, initializer) {
if (initializer->hasCurrentTime() && !std::isnan(initializer->currentTime())) if (initializer->hasCurrentTimeNonNull()) {
current_time_ = initializer->currentTime(); current_time_ = initializer->currentTimeNonNull();
if (initializer->hasTimelineTime() && }
!std::isnan(initializer->timelineTime())) if (initializer->hasTimelineTimeNonNull()) {
timeline_time_ = initializer->timelineTime(); timeline_time_ = initializer->timelineTime();
}
DCHECK(!current_time_ || !std::isnan(current_time_.value())); DCHECK(!current_time_ || !std::isnan(current_time_.value()));
DCHECK(!timeline_time_ || !std::isnan(timeline_time_.value())); DCHECK(!timeline_time_ || !std::isnan(timeline_time_.value()));
} }
......
...@@ -60,8 +60,8 @@ void ReportingObserver::QueueReport(Report* report) { ...@@ -60,8 +60,8 @@ void ReportingObserver::QueueReport(Report* report) {
} }
bool ReportingObserver::ObservedType(const String& type) { bool ReportingObserver::ObservedType(const String& type) {
return !options_->hasTypes() || options_->types().IsEmpty() || return !options_->hasTypesNonNull() || options_->typesNonNull().IsEmpty() ||
options_->types().Find(type) != kNotFound; options_->typesNonNull().Find(type) != kNotFound;
} }
bool ReportingObserver::Buffered() { bool ReportingObserver::Buffered() {
......
...@@ -79,8 +79,8 @@ base::Optional<CanonicalCookie> ToCanonicalCookie( ...@@ -79,8 +79,8 @@ base::Optional<CanonicalCookie> ToCanonicalCookie(
return base::nullopt; return base::nullopt;
} }
base::Time expires = options->hasExpires() base::Time expires = options->hasExpiresNonNull()
? base::Time::FromJavaTime(options->expires()) ? base::Time::FromJavaTime(options->expiresNonNull())
: base::Time(); : base::Time();
String cookie_url_host = cookie_url.Host(); String cookie_url_host = cookie_url.Host();
......
...@@ -36,9 +36,9 @@ DeviceMotionEventAcceleration* DeviceMotionEventAcceleration::Create(double x, ...@@ -36,9 +36,9 @@ DeviceMotionEventAcceleration* DeviceMotionEventAcceleration::Create(double x,
DeviceMotionEventAcceleration* DeviceMotionEventAcceleration::Create( DeviceMotionEventAcceleration* DeviceMotionEventAcceleration::Create(
const DeviceMotionEventAccelerationInit* init) { const DeviceMotionEventAccelerationInit* init) {
double x = init->hasX() ? init->x() : NAN; double x = init->hasXNonNull() ? init->xNonNull() : NAN;
double y = init->hasY() ? init->y() : NAN; double y = init->hasYNonNull() ? init->yNonNull() : NAN;
double z = init->hasZ() ? init->z() : NAN; double z = init->hasZNonNull() ? init->zNonNull() : NAN;
return DeviceMotionEventAcceleration::Create(x, y, z); return DeviceMotionEventAcceleration::Create(x, y, z);
} }
......
...@@ -36,9 +36,9 @@ DeviceMotionEventRotationRate::Create(double alpha, double beta, double gamma) { ...@@ -36,9 +36,9 @@ DeviceMotionEventRotationRate::Create(double alpha, double beta, double gamma) {
DeviceMotionEventRotationRate* DeviceMotionEventRotationRate::Create( DeviceMotionEventRotationRate* DeviceMotionEventRotationRate::Create(
const DeviceMotionEventRotationRateInit* init) { const DeviceMotionEventRotationRateInit* init) {
double alpha = init->hasAlpha() ? init->alpha() : NAN; double alpha = init->hasAlphaNonNull() ? init->alphaNonNull() : NAN;
double beta = init->hasBeta() ? init->beta() : NAN; double beta = init->hasBetaNonNull() ? init->betaNonNull() : NAN;
double gamma = init->hasGamma() ? init->gamma() : NAN; double gamma = init->hasGammaNonNull() ? init->gammaNonNull() : NAN;
return DeviceMotionEventRotationRate::Create(alpha, beta, gamma); return DeviceMotionEventRotationRate::Create(alpha, beta, gamma);
} }
......
...@@ -104,27 +104,28 @@ ScriptPromise NativeFileSystemUnderlyingSink::HandleParams( ...@@ -104,27 +104,28 @@ ScriptPromise NativeFileSystemUnderlyingSink::HandleParams(
const WriteParams& params, const WriteParams& params,
ExceptionState& exception_state) { ExceptionState& exception_state) {
if (params.type() == "truncate") { if (params.type() == "truncate") {
if (!params.hasSize()) { if (!params.hasSizeNonNull()) {
exception_state.ThrowDOMException( exception_state.ThrowDOMException(
DOMExceptionCode::kSyntaxError, DOMExceptionCode::kSyntaxError,
"Invalid params passed. truncate requires a size argument"); "Invalid params passed. truncate requires a size argument");
return ScriptPromise(); return ScriptPromise();
} }
return Truncate(script_state, params.size(), exception_state); return Truncate(script_state, params.sizeNonNull(), exception_state);
} }
if (params.type() == "seek") { if (params.type() == "seek") {
if (!params.hasPosition()) { if (!params.hasPositionNonNull()) {
exception_state.ThrowDOMException( exception_state.ThrowDOMException(
DOMExceptionCode::kSyntaxError, DOMExceptionCode::kSyntaxError,
"Invalid params passed. seek requires a position argument"); "Invalid params passed. seek requires a position argument");
return ScriptPromise(); return ScriptPromise();
} }
return Seek(script_state, params.position(), exception_state); return Seek(script_state, params.positionNonNull(), exception_state);
} }
if (params.type() == "write") { if (params.type() == "write") {
uint64_t position = params.hasPosition() ? params.position() : offset_; uint64_t position =
params.hasPositionNonNull() ? params.positionNonNull() : offset_;
if (!params.hasData()) { if (!params.hasData()) {
exception_state.ThrowDOMException( exception_state.ThrowDOMException(
DOMExceptionCode::kSyntaxError, DOMExceptionCode::kSyntaxError,
......
...@@ -49,7 +49,7 @@ RTCIceCandidate* RTCIceCandidate::Create( ...@@ -49,7 +49,7 @@ RTCIceCandidate* RTCIceCandidate::Create(
const RTCIceCandidateInit* candidate_init, const RTCIceCandidateInit* candidate_init,
ExceptionState& exception_state) { ExceptionState& exception_state) {
if (candidate_init->sdpMid().IsNull() && if (candidate_init->sdpMid().IsNull() &&
!candidate_init->hasSdpMLineIndex()) { !candidate_init->hasSdpMLineIndexNonNull()) {
exception_state.ThrowTypeError("sdpMid and sdpMLineIndex are both null."); exception_state.ThrowTypeError("sdpMid and sdpMLineIndex are both null.");
return nullptr; return nullptr;
} }
...@@ -57,8 +57,8 @@ RTCIceCandidate* RTCIceCandidate::Create( ...@@ -57,8 +57,8 @@ RTCIceCandidate* RTCIceCandidate::Create(
String sdp_mid = candidate_init->sdpMid(); String sdp_mid = candidate_init->sdpMid();
base::Optional<uint16_t> sdp_m_line_index; base::Optional<uint16_t> sdp_m_line_index;
if (candidate_init->hasSdpMLineIndex()) { if (candidate_init->hasSdpMLineIndexNonNull()) {
sdp_m_line_index = candidate_init->sdpMLineIndex(); sdp_m_line_index = candidate_init->sdpMLineIndexNonNull();
} else { } else {
UseCounter::Count(context, UseCounter::Count(context,
WebFeature::kRTCIceCandidateDefaultSdpMLineIndex); WebFeature::kRTCIceCandidateDefaultSdpMLineIndex);
......
...@@ -184,7 +184,7 @@ bool IsIceCandidateMissingSdp( ...@@ -184,7 +184,7 @@ bool IsIceCandidateMissingSdp(
const RTCIceCandidateInit* ice_candidate_init = const RTCIceCandidateInit* ice_candidate_init =
candidate.GetAsRTCIceCandidateInit(); candidate.GetAsRTCIceCandidateInit();
return ice_candidate_init->sdpMid().IsNull() && return ice_candidate_init->sdpMid().IsNull() &&
!ice_candidate_init->hasSdpMLineIndex(); !ice_candidate_init->hasSdpMLineIndexNonNull();
} }
DCHECK(candidate.IsRTCIceCandidate()); DCHECK(candidate.IsRTCIceCandidate());
...@@ -221,8 +221,8 @@ RTCIceCandidatePlatform* ConvertToRTCIceCandidatePlatform( ...@@ -221,8 +221,8 @@ RTCIceCandidatePlatform* ConvertToRTCIceCandidatePlatform(
candidate.GetAsRTCIceCandidateInit(); candidate.GetAsRTCIceCandidateInit();
// TODO(guidou): Change default value to -1. crbug.com/614958. // TODO(guidou): Change default value to -1. crbug.com/614958.
uint16_t sdp_m_line_index = 0; uint16_t sdp_m_line_index = 0;
if (ice_candidate_init->hasSdpMLineIndex()) { if (ice_candidate_init->hasSdpMLineIndexNonNull()) {
sdp_m_line_index = ice_candidate_init->sdpMLineIndex(); sdp_m_line_index = ice_candidate_init->sdpMLineIndexNonNull();
} else { } else {
UseCounter::Count(context, UseCounter::Count(context,
WebFeature::kRTCIceCandidateDefaultSdpMLineIndex); WebFeature::kRTCIceCandidateDefaultSdpMLineIndex);
......
...@@ -202,8 +202,8 @@ void VideoEncoder::ProcessEncode(Request* request) { ...@@ -202,8 +202,8 @@ void VideoEncoder::ProcessEncode(Request* request) {
self->ProcessRequests(); self->ProcessRequests();
}; };
bool keyframe = bool keyframe = request->encodeOpts->hasKeyFrameNonNull() &&
request->encodeOpts->hasKeyFrame() && request->encodeOpts->keyFrame(); request->encodeOpts->keyFrameNonNull();
media_encoder_->Encode(request->frame->frame(), keyframe, media_encoder_->Encode(request->frame->frame(), keyframe,
WTF::Bind(done_callback, WrapWeakPersistent(this), WTF::Bind(done_callback, WrapWeakPersistent(this),
WrapPersistentIfNeeded(request))); WrapPersistentIfNeeded(request)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment