Skip to content

Commit

Permalink
Merge branch 'main' into maxz-sb16-printfs
Browse files Browse the repository at this point in the history
Change-Id: I3c46ae6ee86bd60433ea15864bf799aa35205a63
  • Loading branch information
maxz-lab committed Nov 28, 2023
2 parents ee9f7ba + ee2f99f commit 79029cf
Show file tree
Hide file tree
Showing 70 changed files with 399 additions and 314 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/label-cherry-pick.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
REPOSITORY: ${{ github.repository }}
GITHUB_REF: ${{ github.ref }}
MERGE_COMMIT_SHA: ${{ github.event.pull_request.merge_commit_sha }}
CHERRY_PICK_BRANCH: cherry-pick-${{ matrix.target_branch }}-${{ github.event.pull_request.number }}
steps:
- name: Checkout repository
uses: kaidokert/[email protected]
Expand Down Expand Up @@ -101,7 +102,7 @@ jobs:
token: ${{ secrets.CHERRY_PICK_TOKEN }}
draft: ${{ steps.cherry-pick.outcome == 'failure' }}
base: ${{ matrix.target_branch }}
branch: "cherry-pick-${{ matrix.target_branch }}-${{ github.event.pull_request.number }}"
branch: ${{ env.CHERRY_PICK_BRANCH }}
committer: GitHub Release Automation <[email protected]>
reviewers: ${{ github.event.pull_request.user.login }}
title: "Cherry pick PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}"
Expand Down Expand Up @@ -129,6 +130,6 @@ jobs:
issue_number: '${{ steps.create-pr.outputs.pull-request-number }}',
owner: context.repo.owner,
repo: context.repo.repo,
body: '> [!IMPORTANT]\n> There were merge conflicts while cherry picking! Check out the PR branch (${{ matrix.target_branch }}-${{ github.event.pull_request.number }}) and fix the conflicts before proceeding. Check the log at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} for details.'
body: '> [!IMPORTANT]\n> There were merge conflicts while cherry picking! Check out [${{ env.CHERRY_PICK_BRANCH }}](${{ github.repository }}/tree/${{ env.CHERRY_PICK_BRANCH }}) and fix the conflicts before proceeding. Check the log at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} for details.'
});
}
2 changes: 1 addition & 1 deletion cobalt/browser/application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const int64_t kWatchdogTimeInterval = 10000000;
const int64_t kWatchdogTimeWait = 2000000;

bool IsStringNone(const std::string& str) {
return !base::strcasecmp(str.c_str(), "none");
return !strcasecmp(str.c_str(), "none");
}

#if defined(ENABLE_WEBDRIVER) || defined(ENABLE_DEBUGGER)
Expand Down
7 changes: 3 additions & 4 deletions cobalt/csp/source_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool IsSourceListNone(const char* begin, const char* end) {
const char* position = begin;
SkipWhile<IsSourceCharacter>(&position, end);
size_t len = static_cast<size_t>(position - begin);
if (base::strncasecmp("'none'", begin, len) != 0) {
if (strncasecmp("'none'", begin, len) != 0) {
return false;
}

Expand Down Expand Up @@ -400,7 +400,7 @@ bool SourceList::ParseNonce(const char* begin, const char* end,
const char* prefix = "'nonce-";

if (nonce_length <= strlen(prefix) ||
base::strncasecmp(prefix, begin, strlen(prefix)) != 0) {
strncasecmp(prefix, begin, strlen(prefix)) != 0) {
return true;
}

Expand Down Expand Up @@ -433,8 +433,7 @@ bool SourceList::ParseHash(const char* begin, const char* end,
for (size_t i = 0; i < arraysize(kSupportedPrefixes); ++i) {
const HashPrefix& algorithm = kSupportedPrefixes[i];
if (hash_length > strlen(algorithm.prefix) &&
base::strncasecmp(algorithm.prefix, begin, strlen(algorithm.prefix)) ==
0) {
strncasecmp(algorithm.prefix, begin, strlen(algorithm.prefix)) == 0) {
prefix = algorithm.prefix;
*hash_algorithm = algorithm.type;
break;
Expand Down
6 changes: 3 additions & 3 deletions cobalt/debug/console/command_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ ConsoleCommandManager::CommandHandler::~CommandHandler() {
// static
bool ConsoleCommandManager::CommandHandler::IsOnEnableOrTrue(
const std::string& message) {
return (SbStringCompareNoCase("on", message.c_str()) == 0) ||
(SbStringCompareNoCase("enable", message.c_str()) == 0) ||
(SbStringCompareNoCase("true", message.c_str()) == 0);
return (strcasecmp("on", message.c_str()) == 0) ||
(strcasecmp("enable", message.c_str()) == 0) ||
(strcasecmp("true", message.c_str()) == 0);
}


Expand Down
24 changes: 12 additions & 12 deletions cobalt/dom/document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,26 +235,26 @@ scoped_refptr<web::Event> Document::CreateEvent(
script::ExceptionState* exception_state) {
// https://www.w3.org/TR/dom/#dom-document-createevent
// The match of interface name is case-insensitive.
if (base::strcasecmp(interface_name.c_str(), "event") == 0 ||
base::strcasecmp(interface_name.c_str(), "events") == 0 ||
base::strcasecmp(interface_name.c_str(), "htmlevents") == 0) {
if (strcasecmp(interface_name.c_str(), "event") == 0 ||
strcasecmp(interface_name.c_str(), "events") == 0 ||
strcasecmp(interface_name.c_str(), "htmlevents") == 0) {
return new web::Event(web::Event::Uninitialized);
} else if (base::strcasecmp(interface_name.c_str(), "keyboardevent") == 0 ||
base::strcasecmp(interface_name.c_str(), "keyevents") == 0) {
} else if (strcasecmp(interface_name.c_str(), "keyboardevent") == 0 ||
strcasecmp(interface_name.c_str(), "keyevents") == 0) {
return new KeyboardEvent(web::Event::Uninitialized);
} else if (base::strcasecmp(interface_name.c_str(), "messageevent") == 0) {
} else if (strcasecmp(interface_name.c_str(), "messageevent") == 0) {
return new web::MessageEvent(web::Event::Uninitialized);
} else if (base::strcasecmp(interface_name.c_str(), "mouseevent") == 0 ||
base::strcasecmp(interface_name.c_str(), "mouseevents") == 0) {
} else if (strcasecmp(interface_name.c_str(), "mouseevent") == 0 ||
strcasecmp(interface_name.c_str(), "mouseevents") == 0) {
return new MouseEvent(web::Event::Uninitialized);
} else if (base::strcasecmp(interface_name.c_str(), "uievent") == 0 ||
base::strcasecmp(interface_name.c_str(), "uievents") == 0) {
} else if (strcasecmp(interface_name.c_str(), "uievent") == 0 ||
strcasecmp(interface_name.c_str(), "uievents") == 0) {
return new UIEvent(web::Event::Uninitialized);
} else if (base::strcasecmp(interface_name.c_str(), "wheelevent") == 0) {
} else if (strcasecmp(interface_name.c_str(), "wheelevent") == 0) {
// This not in the spec, but commonly implemented to create a WheelEvent.
// https://www.w3.org/TR/2016/WD-uievents-20160804/#interface-wheelevent
return new WheelEvent(web::Event::Uninitialized);
} else if (base::strcasecmp(interface_name.c_str(), "customevent") == 0) {
} else if (strcasecmp(interface_name.c_str(), "customevent") == 0) {
return new web::CustomEvent(web::Event::Uninitialized);
}

Expand Down
72 changes: 35 additions & 37 deletions cobalt/dom/html_media_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ HTMLMediaElement::HTMLMediaElement(Document* document, base::Token tag_name)
ready_state_(WebMediaPlayer::kReadyStateHaveNothing),
ready_state_maximum_(WebMediaPlayer::kReadyStateHaveNothing),
volume_(1.0f),
last_seek_time_(0),
last_seek_time_(0.0),
previous_progress_time_(std::numeric_limits<double>::max()),
duration_(std::numeric_limits<double>::quiet_NaN()),
playing_(false),
Expand All @@ -149,7 +149,7 @@ HTMLMediaElement::HTMLMediaElement(Document* document, base::Token tag_name)
resume_frozen_flag_(false),
seeking_(false),
controls_(false),
last_time_update_event_movie_time_(std::numeric_limits<float>::max()),
last_time_update_event_movie_time_(std::numeric_limits<double>::max()),
processing_media_player_callback_(0),
media_source_url_(std::string(kMediaSourceUrlProtocol) + ':' +
base::GenerateGUID()),
Expand Down Expand Up @@ -222,7 +222,7 @@ scoped_refptr<TimeRanges> HTMLMediaElement::buffered() const {
}

player_->UpdateBufferedTimeRanges(
[&](float start, float end) { buffered->Add(start, end); });
[&](double start, double end) { buffered->Add(start, end); });
return buffered;
}

Expand Down Expand Up @@ -344,27 +344,26 @@ bool HTMLMediaElement::seeking() const {
return seeking_;
}

float HTMLMediaElement::current_time(
double HTMLMediaElement::current_time(
script::ExceptionState* exception_state) const {
if (!player_) {
LOG(INFO) << 0 << " (because player is NULL)";
return 0;
return 0.0;
}

if (seeking_) {
MLOG() << last_seek_time_ << " (seeking)";
return last_seek_time_;
}

float time = player_->GetCurrentTime();
const double time = player_->GetCurrentTime();
MLOG() << time << " (from player)";
return time;
}

void HTMLMediaElement::set_current_time(
float time, script::ExceptionState* exception_state) {
double time, script::ExceptionState* exception_state) {
// 4.8.9.9 Seeking

// 1 - If the media element's readyState is
// WebMediaPlayer::kReadyStateHaveNothing, then raise an INVALID_STATE_ERR
// exception.
Expand All @@ -377,10 +376,9 @@ void HTMLMediaElement::set_current_time(
Seek(time);
}

float HTMLMediaElement::duration() const {
double HTMLMediaElement::duration() const {
MLOG() << duration_;
// TODO: Turn duration into double.
return static_cast<float>(duration_);
return duration_;
}

base::Time HTMLMediaElement::GetStartDate() const {
Expand Down Expand Up @@ -433,7 +431,7 @@ void HTMLMediaElement::set_playback_rate(float rate) {
const scoped_refptr<TimeRanges>& HTMLMediaElement::played() {
MLOG();
if (playing_) {
float time = current_time(NULL);
const double time = current_time(NULL);
if (time > last_seek_time_) {
AddPlayedRange(last_seek_time_, time);
}
Expand All @@ -447,8 +445,8 @@ const scoped_refptr<TimeRanges>& HTMLMediaElement::played() {
}

scoped_refptr<TimeRanges> HTMLMediaElement::seekable() const {
if (player_ && player_->GetMaxTimeSeekable() != 0) {
double max_time_seekable = player_->GetMaxTimeSeekable();
if (player_ && player_->GetMaxTimeSeekable() != 0.0) {
const double max_time_seekable = player_->GetMaxTimeSeekable();
MLOG() << "(0, " << max_time_seekable << ")";
return new TimeRanges(0, max_time_seekable);
}
Expand Down Expand Up @@ -632,7 +630,7 @@ void HTMLMediaElement::DurationChanged(double duration, bool request_seek) {
ScheduleOwnEvent(base::Tokens::durationchange());

if (request_seek) {
Seek(static_cast<float>(duration));
Seek(duration);
}
}

Expand Down Expand Up @@ -775,7 +773,7 @@ void HTMLMediaElement::PrepareForLoad() {

// 2 - Asynchronously await a stable state.
played_time_ranges_ = new TimeRanges;
last_seek_time_ = 0;
last_seek_time_ = 0.0;

ConfigureMediaControls();
}
Expand Down Expand Up @@ -1019,8 +1017,8 @@ void HTMLMediaElement::OnProgressEventTimer() {
return;
}

double time = base::Time::Now().ToDoubleT();
double time_delta = time - previous_progress_time_;
const double time = base::Time::Now().ToDoubleT();
const double time_delta = time - previous_progress_time_;

if (player_->DidLoadingProgress()) {
ScheduleOwnEvent(base::Tokens::progress());
Expand Down Expand Up @@ -1082,7 +1080,7 @@ void HTMLMediaElement::StopPeriodicTimers() {
void HTMLMediaElement::ScheduleTimeupdateEvent(bool periodic_event) {
// Some media engines make multiple "time changed" callbacks at the same time,
// but we only want one event at a given time so filter here
float movie_time = current_time(NULL);
const double movie_time = current_time(NULL);
if (movie_time != last_time_update_event_movie_time_) {
if (!periodic_event && playback_progress_timer_.IsRunning()) {
playback_progress_timer_.Reset();
Expand Down Expand Up @@ -1268,7 +1266,7 @@ void HTMLMediaElement::ChangeNetworkStateFromLoadingToIdle() {
network_state_ = kNetworkIdle;
}

void HTMLMediaElement::Seek(float time) {
void HTMLMediaElement::Seek(double time) {
LOG(INFO) << "Seek to " << time << ".";
// 4.8.9.9 Seeking - continued from set_current_time().

Expand All @@ -1279,7 +1277,7 @@ void HTMLMediaElement::Seek(float time) {

// Get the current time before setting seeking_, last_seek_time_ is returned
// once it is set.
float now = current_time(NULL);
const double now = current_time(NULL);

// 2 - If the element's seeking IDL attribute is true, then another instance
// of this algorithm is already running. Abort that other instance of the
Expand All @@ -1297,7 +1295,7 @@ void HTMLMediaElement::Seek(float time) {

// 6 - If the new playback position is less than the earliest possible
// position, let it be that position instead.
time = std::max(time, 0.f);
time = std::max(time, 0.0);

// 7 - If the (possibly now changed) new playback position is not in one of
// the ranges given in the seekable attribute, then let it be the position in
Expand Down Expand Up @@ -1329,7 +1327,7 @@ void HTMLMediaElement::Seek(float time) {
seeking_ = false;
return;
}
time = static_cast<float>(seekable_ranges->Nearest(time));
time = seekable_ranges->Nearest(time);

if (playing_) {
if (last_seek_time_ < now) {
Expand Down Expand Up @@ -1361,7 +1359,7 @@ void HTMLMediaElement::FinishSeek() {
ScheduleOwnEvent(base::Tokens::seeked());
}

void HTMLMediaElement::AddPlayedRange(float start, float end) {
void HTMLMediaElement::AddPlayedRange(double start, double end) {
if (!played_time_ranges_) {
played_time_ranges_ = new TimeRanges;
}
Expand Down Expand Up @@ -1411,7 +1409,7 @@ void HTMLMediaElement::UpdatePlayState() {

playback_progress_timer_.Stop();
playing_ = false;
float time = current_time(NULL);
const double time = current_time(NULL);
if (time > last_seek_time_) {
AddPlayedRange(last_seek_time_, time);
}
Expand All @@ -1431,7 +1429,7 @@ bool HTMLMediaElement::PotentiallyPlaying() const {
}

bool HTMLMediaElement::EndedPlayback() const {
float dur = duration();
const double dur = duration();
if (!player_ || std::isnan(dur)) {
return false;
}
Expand All @@ -1448,15 +1446,15 @@ bool HTMLMediaElement::EndedPlayback() const {
// direction of playback is forwards, Either the media element does not have a
// loop attribute specified, or the media element has a current media
// controller.
float now = current_time(NULL);
if (playback_rate_ > 0) {
return dur > 0 && now >= dur && !loop();
const double now = current_time(NULL);
if (playback_rate_ > 0.f) {
return dur > 0.0 && now >= dur && !loop();
}

// or the current playback position is the earliest possible position and the
// direction of playback is backwards
if (playback_rate_ < 0) {
return now <= 0;
if (playback_rate_ < 0.f) {
return now <= 0.0;
}

return false;
Expand Down Expand Up @@ -1557,14 +1555,14 @@ void HTMLMediaElement::TimeChanged(bool eos_played) {
// already posted one at the current movie time.
ScheduleTimeupdateEvent(false);

float now = current_time(NULL);
float dur = duration();
const double now = current_time(NULL);
const double dur = duration();

// When the current playback position reaches the end of the media resource
// when the direction of playback is forwards, then the user agent must follow
// these steps:
eos_played |=
!std::isnan(dur) && (0.0f != dur) && now >= dur && playback_rate_ > 0;
!std::isnan(dur) && (0.0 != dur) && now >= dur && playback_rate_ > 0.f;
if (eos_played) {
LOG(INFO) << "End of stream is played.";
// If the media element has a loop attribute specified and does not have a
Expand All @@ -1573,7 +1571,7 @@ void HTMLMediaElement::TimeChanged(bool eos_played) {
sent_end_event_ = false;
// then seek to the earliest possible position of the media resource and
// abort these steps.
Seek(0);
Seek(0.0);
} else {
// If the media element does not have a current media controller, and the
// media element has still ended playback, and the direction of playback
Expand Down Expand Up @@ -1603,15 +1601,15 @@ void HTMLMediaElement::DurationChanged() {

ScheduleOwnEvent(base::Tokens::durationchange());

double now = current_time(NULL);
const double now = current_time(NULL);
// Reset and update |duration_|.
duration_ = std::numeric_limits<double>::quiet_NaN();
if (player_ && ready_state_ >= WebMediaPlayer::kReadyStateHaveMetadata) {
duration_ = player_->GetDuration();
}

if (now > duration_) {
Seek(static_cast<float>(duration_));
Seek(duration_);
}

EndProcessingMediaPlayerCallback();
Expand Down
Loading

0 comments on commit 79029cf

Please sign in to comment.