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