diff --git a/DEPS b/DEPS index 0cca1ab..96a350b 100644 --- a/DEPS +++ b/DEPS
@@ -43,7 +43,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. - 'v8_revision': '83018bb9ba0f12bca5489a2190828604a66ad37e', + 'v8_revision': '8d71398059ea2ee560b8dcffef37cac17730126f', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling swarming_client # and whatever else without interference from each other.
diff --git a/build/mac_toolchain.py b/build/mac_toolchain.py index 4de6e05..28cbd84 100755 --- a/build/mac_toolchain.py +++ b/build/mac_toolchain.py
@@ -109,7 +109,7 @@ os.unlink(name) -def AcceptLicense(directory): +def AcceptLicense(): """Use xcodebuild to accept new toolchain license if necessary. Don't accept the license if a newer license has already been accepted. This only works if xcodebuild and xcode-select are passwordless in sudoers.""" @@ -135,7 +135,7 @@ # Don't accept the license of older toolchain builds, this will break the # license of newer builds. return - except (subprocess.CalledProcessError, KeyError) as e: + except (subprocess.CalledProcessError, KeyError): # If there's never been a license of type |build_type| accepted, # |target_license_plist_path| or |agreed_to_key| may not exist. pass @@ -176,7 +176,7 @@ TOOLCHAIN_VERSION) if ReadStampFile() == toolchain_revision: print 'Toolchain (%s) is already up to date.' % toolchain_revision - AcceptLicense(TOOLCHAIN_BUILD_DIR) + AcceptLicense() return 0 if not CanAccessToolchainBucket(): @@ -194,13 +194,14 @@ toolchain_file = 'toolchain-%s.tgz' % toolchain_revision toolchain_full_url = TOOLCHAIN_URL + toolchain_file DownloadAndUnpack(toolchain_full_url, TOOLCHAIN_BUILD_DIR) - AcceptLicense(TOOLCHAIN_BUILD_DIR) + AcceptLicense() print 'Toolchain %s unpacked.' % toolchain_revision WriteStampFile(toolchain_revision) return 0 - except: + except Exception as e: print 'Failed to download toolchain %s.' % toolchain_file + print 'Exception %s' % e print 'Exiting.' return 1
diff --git a/chrome/VERSION b/chrome/VERSION index bad3316..6d1b0377 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=52 MINOR=0 -BUILD=2738 +BUILD=2739 PATCH=0
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 4346326b..d68cd204 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd
@@ -12615,9 +12615,11 @@ <message name="IDS_FULLSCREEN_ENTERED_MOUSELOCK" desc="Text displayed in the bubble to inform the user that the page has locked the mouse. (No domain to be shown, e.g. from filesystem page)"> This page has disabled your mouse cursor. </message> - <message name="IDS_FULLSCREEN_PRESS_ESC_TO_EXIT_SENTENCE" desc="Text displayed in the bubble to tell users how to return to normal mode."> - Press <ph name="ACCELERATOR">$1<ex>Esc</ex></ph> to exit. - </message> + <if expr="is_macosx"> + <message name="IDS_FULLSCREEN_PRESS_ESC_TO_EXIT_SENTENCE" desc="Text displayed in the bubble to tell users how to return to normal mode."> + Press <ph name="ACCELERATOR">$1<ex>Esc</ex></ph> to exit. + </message> + </if> <message name="IDS_FULLSCREEN_PRESS_ESC_TO_EXIT_FULLSCREEN" desc="Text displayed in the bubble to tell users how to return from fullscreen mode (where the web page occupies the entire screen) to normal mode. Please surround the name of the key (e.g. 'Esc') in pipe characters so it can be rendered as a key."> Press |<ph name="ACCELERATOR">$1<ex>Esc</ex></ph>| to exit full screen </message>
diff --git a/chrome/browser/android/preferences/important_sites_util_unittest.cc b/chrome/browser/android/preferences/important_sites_util_unittest.cc index d982c98f..f2be975f 100644 --- a/chrome/browser/android/preferences/important_sites_util_unittest.cc +++ b/chrome/browser/android/preferences/important_sites_util_unittest.cc
@@ -10,10 +10,8 @@ #include "base/files/scoped_temp_dir.h" #include "base/macros.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" -#include "chrome/browser/engagement/site_engagement_helper.h" -#include "chrome/browser/engagement/site_engagement_metrics.h" +#include "chrome/browser/engagement/site_engagement_score.h" #include "chrome/browser/engagement/site_engagement_service.h" -#include "chrome/browser/engagement/site_engagement_service_factory.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" @@ -78,8 +76,7 @@ } TEST_F(ImportantSitesUtilTest, NotificationsThenEngagement) { - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService* service = SiteEngagementService::Get(profile()); ASSERT_TRUE(service); GURL url1("http://www.google.com/");
diff --git a/chrome/browser/banners/app_banner_settings_helper_unittest.cc b/chrome/browser/banners/app_banner_settings_helper_unittest.cc index 1c8d10b..5a4b802 100644 --- a/chrome/browser/banners/app_banner_settings_helper_unittest.cc +++ b/chrome/browser/banners/app_banner_settings_helper_unittest.cc
@@ -8,7 +8,6 @@ #include "chrome/browser/banners/app_banner_metrics.h" #include "chrome/browser/banners/app_banner_settings_helper.h" #include "chrome/browser/engagement/site_engagement_service.h" -#include "chrome/browser/engagement/site_engagement_service_factory.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" @@ -783,8 +782,7 @@ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); command_line->AppendSwitch(switches::kEnableSiteEngagementAppBanner); - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService* service = SiteEngagementService::Get(profile()); DCHECK(service); // Not used, but needed for method call.
diff --git a/chrome/browser/engagement/site_engagement_eviction_policy.cc b/chrome/browser/engagement/site_engagement_eviction_policy.cc index 314500c..869e072 100644 --- a/chrome/browser/engagement/site_engagement_eviction_policy.cc +++ b/chrome/browser/engagement/site_engagement_eviction_policy.cc
@@ -25,7 +25,7 @@ int64_t global_quota) { double quota_per_point = global_quota / - std::max(kExpectedEngagementSites * SiteEngagementScore::kMaxPoints, + std::max(kExpectedEngagementSites * SiteEngagementService::GetMaxPoints(), static_cast<double>(total_engagement_points)); return score * quota_per_point;
diff --git a/chrome/browser/engagement/site_engagement_helper.cc b/chrome/browser/engagement/site_engagement_helper.cc index 7324fc5..6e5f940 100644 --- a/chrome/browser/engagement/site_engagement_helper.cc +++ b/chrome/browser/engagement/site_engagement_helper.cc
@@ -9,7 +9,6 @@ #include "base/time/time.h" #include "base/trace_event/trace_event.h" #include "chrome/browser/engagement/site_engagement_service.h" -#include "chrome/browser/engagement/site_engagement_service_factory.h" #include "chrome/browser/prerender/prerender_contents.h" #include "chrome/browser/profiles/profile.h" #include "content/public/browser/navigation_handle.h" @@ -24,66 +23,67 @@ } // anonymous namespace -DEFINE_WEB_CONTENTS_USER_DATA_KEY(SiteEngagementHelper); +DEFINE_WEB_CONTENTS_USER_DATA_KEY(SiteEngagementService::Helper); -SiteEngagementHelper::PeriodicTracker::PeriodicTracker( - SiteEngagementHelper* helper) +SiteEngagementService::Helper::PeriodicTracker::PeriodicTracker( + SiteEngagementService::Helper* helper) : helper_(helper), pause_timer_(new base::Timer(true, false)) {} -SiteEngagementHelper::PeriodicTracker::~PeriodicTracker() {} +SiteEngagementService::Helper::PeriodicTracker::~PeriodicTracker() {} -void SiteEngagementHelper::PeriodicTracker::Start( +void SiteEngagementService::Helper::PeriodicTracker::Start( base::TimeDelta initial_delay) { StartTimer(initial_delay); } -void SiteEngagementHelper::PeriodicTracker::Pause() { +void SiteEngagementService::Helper::PeriodicTracker::Pause() { TrackingStopped(); StartTimer( base::TimeDelta::FromSeconds(g_seconds_to_pause_engagement_detection)); } -void SiteEngagementHelper::PeriodicTracker::Stop() { +void SiteEngagementService::Helper::PeriodicTracker::Stop() { TrackingStopped(); pause_timer_->Stop(); } -bool SiteEngagementHelper::PeriodicTracker::IsTimerRunning() { +bool SiteEngagementService::Helper::PeriodicTracker::IsTimerRunning() { return pause_timer_->IsRunning(); } -void SiteEngagementHelper::PeriodicTracker::SetPauseTimerForTesting( +void SiteEngagementService::Helper::PeriodicTracker::SetPauseTimerForTesting( std::unique_ptr<base::Timer> timer) { pause_timer_ = std::move(timer); } -void SiteEngagementHelper::PeriodicTracker::StartTimer( +void SiteEngagementService::Helper::PeriodicTracker::StartTimer( base::TimeDelta delay) { pause_timer_->Start( FROM_HERE, delay, - base::Bind(&SiteEngagementHelper::PeriodicTracker::TrackingStarted, - base::Unretained(this))); + base::Bind( + &SiteEngagementService::Helper::PeriodicTracker::TrackingStarted, + base::Unretained(this))); } -SiteEngagementHelper::InputTracker::InputTracker( - SiteEngagementHelper* helper, +SiteEngagementService::Helper::InputTracker::InputTracker( + SiteEngagementService::Helper* helper, content::WebContents* web_contents) : PeriodicTracker(helper), content::WebContentsObserver(web_contents), is_tracking_(false) {} -void SiteEngagementHelper::InputTracker::TrackingStarted() { +void SiteEngagementService::Helper::InputTracker::TrackingStarted() { is_tracking_ = true; } -void SiteEngagementHelper::InputTracker::TrackingStopped() { +void SiteEngagementService::Helper::InputTracker::TrackingStopped() { is_tracking_ = false; } // Record that there was some user input, and defer handling of the input event. // Once the timer finishes running, the callbacks detecting user input will be // registered again. -void SiteEngagementHelper::InputTracker::DidGetUserInteraction( +void SiteEngagementService::Helper::InputTracker::DidGetUserInteraction( const blink::WebInputEvent::Type type) { // Only respond to raw key down to avoid multiple triggering on a single input // (e.g. keypress is a key down then key up). @@ -116,23 +116,23 @@ Pause(); } -SiteEngagementHelper::MediaTracker::MediaTracker( - SiteEngagementHelper* helper, +SiteEngagementService::Helper::MediaTracker::MediaTracker( + SiteEngagementService::Helper* helper, content::WebContents* web_contents) : PeriodicTracker(helper), content::WebContentsObserver(web_contents), is_hidden_(false) {} -SiteEngagementHelper::MediaTracker::~MediaTracker() {} +SiteEngagementService::Helper::MediaTracker::~MediaTracker() {} -void SiteEngagementHelper::MediaTracker::TrackingStarted() { +void SiteEngagementService::Helper::MediaTracker::TrackingStarted() { if (!active_media_players_.empty()) helper()->RecordMediaPlaying(is_hidden_); Pause(); } -void SiteEngagementHelper::MediaTracker::MediaStartedPlaying( +void SiteEngagementService::Helper::MediaTracker::MediaStartedPlaying( const MediaPlayerId& id) { // Only begin engagement detection when media actually starts playing. active_media_players_.push_back(id); @@ -140,43 +140,42 @@ Start(base::TimeDelta::FromSeconds(g_seconds_delay_after_media_starts)); } -void SiteEngagementHelper::MediaTracker::MediaStoppedPlaying( +void SiteEngagementService::Helper::MediaTracker::MediaStoppedPlaying( const MediaPlayerId& id) { active_media_players_.erase(std::remove(active_media_players_.begin(), active_media_players_.end(), id), active_media_players_.end()); } -void SiteEngagementHelper::MediaTracker::WasShown() { +void SiteEngagementService::Helper::MediaTracker::WasShown() { is_hidden_ = false; } -void SiteEngagementHelper::MediaTracker::WasHidden() { +void SiteEngagementService::Helper::MediaTracker::WasHidden() { is_hidden_ = true; } -SiteEngagementHelper::~SiteEngagementHelper() { +SiteEngagementService::Helper::~Helper() { if (web_contents()) { input_tracker_.Stop(); media_tracker_.Stop(); } } -SiteEngagementHelper::SiteEngagementHelper(content::WebContents* web_contents) +SiteEngagementService::Helper::Helper(content::WebContents* web_contents) : content::WebContentsObserver(web_contents), input_tracker_(this, web_contents), media_tracker_(this, web_contents), record_engagement_(false) {} -void SiteEngagementHelper::RecordUserInput( +void SiteEngagementService::Helper::RecordUserInput( SiteEngagementMetrics::EngagementType type) { TRACE_EVENT0("SiteEngagement", "RecordUserInput"); content::WebContents* contents = web_contents(); if (contents) { Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile); + SiteEngagementService* service = SiteEngagementService::Get(profile); // Service is null in incognito. if (service) @@ -184,20 +183,19 @@ } } -void SiteEngagementHelper::RecordMediaPlaying(bool is_hidden) { +void SiteEngagementService::Helper::RecordMediaPlaying(bool is_hidden) { content::WebContents* contents = web_contents(); if (contents) { Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile); + SiteEngagementService* service = SiteEngagementService::Get(profile); if (service) service->HandleMediaPlaying(contents->GetVisibleURL(), is_hidden); } } -void SiteEngagementHelper::DidFinishNavigation( +void SiteEngagementService::Helper::DidFinishNavigation( content::NavigationHandle* handle) { input_tracker_.Stop(); media_tracker_.Stop(); @@ -228,8 +226,7 @@ Profile* profile = Profile::FromBrowserContext(web_contents()->GetBrowserContext()); - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile); + SiteEngagementService* service = SiteEngagementService::Get(profile); if (service) service->HandleNavigation(handle->GetURL(), handle->GetPageTransition()); @@ -238,31 +235,33 @@ base::TimeDelta::FromSeconds(g_seconds_delay_after_navigation)); } -void SiteEngagementHelper::WasShown() { - // Ensure that the input callbacks are registered when we come into view. This - // occurs when switching tabs, or when prerendered pages are swapped in. +void SiteEngagementService::Helper::WasShown() { + // Ensure that the input callbacks are registered when we come into view. if (record_engagement_) { input_tracker_.Start( base::TimeDelta::FromSeconds(g_seconds_delay_after_show)); } } -void SiteEngagementHelper::WasHidden() { +void SiteEngagementService::Helper::WasHidden() { // Ensure that the input callbacks are not registered when hidden. input_tracker_.Stop(); } // static -void SiteEngagementHelper::SetSecondsBetweenUserInputCheck(int seconds) { +void SiteEngagementService::Helper::SetSecondsBetweenUserInputCheck( + int seconds) { g_seconds_to_pause_engagement_detection = seconds; } // static -void SiteEngagementHelper::SetSecondsTrackingDelayAfterNavigation(int seconds) { +void SiteEngagementService::Helper::SetSecondsTrackingDelayAfterNavigation( + int seconds) { g_seconds_delay_after_navigation = seconds; } // static -void SiteEngagementHelper::SetSecondsTrackingDelayAfterShow(int seconds) { +void SiteEngagementService::Helper::SetSecondsTrackingDelayAfterShow( + int seconds) { g_seconds_delay_after_show = seconds; }
diff --git a/chrome/browser/engagement/site_engagement_helper.h b/chrome/browser/engagement/site_engagement_helper.h index 4a331af..f55ab586 100644 --- a/chrome/browser/engagement/site_engagement_helper.h +++ b/chrome/browser/engagement/site_engagement_helper.h
@@ -8,6 +8,7 @@ #include "base/macros.h" #include "base/timer/timer.h" #include "chrome/browser/engagement/site_engagement_metrics.h" +#include "chrome/browser/engagement/site_engagement_service.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" @@ -16,15 +17,13 @@ class WebContents; } -class GURL; - // Per-WebContents class to handle updating the site engagement scores for // origins. -class SiteEngagementHelper +class SiteEngagementService::Helper : public content::WebContentsObserver, - public content::WebContentsUserData<SiteEngagementHelper> { + public content::WebContentsUserData<SiteEngagementService::Helper> { public: - ~SiteEngagementHelper() override; + ~Helper() override; static void SetSecondsBetweenUserInputCheck(int seconds); static void SetSecondsTrackingDelayAfterNavigation(int seconds); @@ -42,7 +41,7 @@ // 2. continual engagement over a non-trivial duration of time class PeriodicTracker { public: - explicit PeriodicTracker(SiteEngagementHelper* helper); + explicit PeriodicTracker(SiteEngagementService::Helper* helper); virtual ~PeriodicTracker(); // Begin tracking after |initial_delay|. @@ -60,7 +59,7 @@ // Set the timer object for testing. void SetPauseTimerForTesting(std::unique_ptr<base::Timer> timer); - SiteEngagementHelper* helper() { return helper_; } + SiteEngagementService::Helper* helper() { return helper_; } protected: friend class SiteEngagementHelperTest; @@ -76,8 +75,10 @@ virtual void TrackingStopped() {} private: - SiteEngagementHelper* helper_; + SiteEngagementService::Helper* helper_; std::unique_ptr<base::Timer> pause_timer_; + + DISALLOW_COPY_AND_ASSIGN(PeriodicTracker); }; // Class to encapsulate time-on-site engagement detection. Time-on-site is @@ -90,7 +91,7 @@ class InputTracker : public PeriodicTracker, public content::WebContentsObserver { public: - InputTracker(SiteEngagementHelper* helper, + InputTracker(SiteEngagementService::Helper* helper, content::WebContents* web_contents); bool is_tracking() const { return is_tracking_; } @@ -107,6 +108,8 @@ // content::WebContentsObserver overrides. void DidGetUserInteraction(const blink::WebInputEvent::Type type) override; + + DISALLOW_COPY_AND_ASSIGN(InputTracker); }; // Class to encapsulate media detection. Any media playing in a WebContents @@ -122,7 +125,7 @@ class MediaTracker : public PeriodicTracker, public content::WebContentsObserver { public: - MediaTracker(SiteEngagementHelper* helper, + MediaTracker(SiteEngagementService::Helper* helper, content::WebContents* web_contents); ~MediaTracker() override; @@ -139,10 +142,12 @@ bool is_hidden_; std::vector<MediaPlayerId> active_media_players_; + + DISALLOW_COPY_AND_ASSIGN(MediaTracker); }; - explicit SiteEngagementHelper(content::WebContents* web_contents); - friend class content::WebContentsUserData<SiteEngagementHelper>; + explicit Helper(content::WebContents* web_contents); + friend class content::WebContentsUserData<SiteEngagementService::Helper>; friend class SiteEngagementHelperTest; // Ask the SiteEngagementService to record engagement via user input at the @@ -162,7 +167,7 @@ MediaTracker media_tracker_; bool record_engagement_; - DISALLOW_COPY_AND_ASSIGN(SiteEngagementHelper); + DISALLOW_COPY_AND_ASSIGN(Helper); }; #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_HELPER_H_
diff --git a/chrome/browser/engagement/site_engagement_helper_unittest.cc b/chrome/browser/engagement/site_engagement_helper_unittest.cc index 919837f9..6f92ab32 100644 --- a/chrome/browser/engagement/site_engagement_helper_unittest.cc +++ b/chrome/browser/engagement/site_engagement_helper_unittest.cc
@@ -8,8 +8,8 @@ #include "base/test/histogram_tester.h" #include "base/timer/mock_timer.h" #include "base/values.h" +#include "chrome/browser/engagement/site_engagement_score.h" #include "chrome/browser/engagement/site_engagement_service.h" -#include "chrome/browser/engagement/site_engagement_service_factory.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" @@ -26,61 +26,62 @@ SiteEngagementScore::SetParamValuesForTesting(); } - SiteEngagementHelper* GetHelper(content::WebContents* web_contents) { - SiteEngagementHelper::CreateForWebContents(web_contents); - SiteEngagementHelper* helper = - SiteEngagementHelper::FromWebContents(web_contents); + SiteEngagementService::Helper* GetHelper(content::WebContents* web_contents) { + SiteEngagementService::Helper::CreateForWebContents(web_contents); + SiteEngagementService::Helper* helper = + SiteEngagementService::Helper::FromWebContents(web_contents); DCHECK(helper); return helper; } - void TrackingStarted(SiteEngagementHelper* helper) { + void TrackingStarted(SiteEngagementService::Helper* helper) { helper->input_tracker_.TrackingStarted(); helper->media_tracker_.TrackingStarted(); } // Simulate a user interaction event and handle it. - void HandleUserInput(SiteEngagementHelper* helper, + void HandleUserInput(SiteEngagementService::Helper* helper, blink::WebInputEvent::Type type) { helper->input_tracker_.DidGetUserInteraction(type); } // Simulate a user interaction event and handle it. Reactivates tracking // immediately. - void HandleUserInputAndRestartTracking(SiteEngagementHelper* helper, + void HandleUserInputAndRestartTracking(SiteEngagementService::Helper* helper, blink::WebInputEvent::Type type) { helper->input_tracker_.DidGetUserInteraction(type); helper->input_tracker_.TrackingStarted(); } - void HandleMediaPlaying(SiteEngagementHelper* helper, bool is_hidden) { + void HandleMediaPlaying(SiteEngagementService::Helper* helper, + bool is_hidden) { helper->RecordMediaPlaying(is_hidden); } - void MediaStartedPlaying(SiteEngagementHelper* helper) { + void MediaStartedPlaying(SiteEngagementService::Helper* helper) { helper->media_tracker_.MediaStartedPlaying( content::WebContentsObserver::MediaPlayerId(nullptr, 1)); } - void MediaStoppedPlaying(SiteEngagementHelper* helper) { + void MediaStoppedPlaying(SiteEngagementService::Helper* helper) { helper->media_tracker_.MediaStoppedPlaying( content::WebContentsObserver::MediaPlayerId(nullptr, 1)); } // Set a pause timer on the input tracker for test purposes. - void SetInputTrackerPauseTimer(SiteEngagementHelper* helper, + void SetInputTrackerPauseTimer(SiteEngagementService::Helper* helper, std::unique_ptr<base::Timer> timer) { helper->input_tracker_.SetPauseTimerForTesting(std::move(timer)); } // Set a pause timer on the input tracker for test purposes. - void SetMediaTrackerPauseTimer(SiteEngagementHelper* helper, + void SetMediaTrackerPauseTimer(SiteEngagementService::Helper* helper, std::unique_ptr<base::Timer> timer) { helper->media_tracker_.SetPauseTimerForTesting(std::move(timer)); } - bool IsTrackingInput(SiteEngagementHelper* helper) { + bool IsTrackingInput(SiteEngagementService::Helper* helper) { return helper->input_tracker_.is_tracking(); } @@ -98,9 +99,8 @@ GURL url2("http://www.google.com/"); content::WebContents* contents = web_contents(); - SiteEngagementHelper* helper = GetHelper(contents); - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService::Helper* helper = GetHelper(contents); + SiteEngagementService* service = SiteEngagementService::Get(profile()); DCHECK(service); // Check that navigation triggers engagement. @@ -160,9 +160,8 @@ GURL url2("http://www.google.com/"); content::WebContents* contents = web_contents(); - SiteEngagementHelper* helper = GetHelper(contents); - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService::Helper* helper = GetHelper(contents); + SiteEngagementService* service = SiteEngagementService::Get(profile()); DCHECK(service); Navigate(url1); @@ -213,10 +212,9 @@ content::WebContents* contents = web_contents(); base::MockTimer* media_tracker_timer = new base::MockTimer(true, false); - SiteEngagementHelper* helper = GetHelper(contents); + SiteEngagementService::Helper* helper = GetHelper(contents); SetMediaTrackerPauseTimer(helper, base::WrapUnique(media_tracker_timer)); - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService* service = SiteEngagementService::Get(profile()); DCHECK(service); Navigate(url1); @@ -285,9 +283,8 @@ GURL url2("http://www.google.com/"); content::WebContents* contents = web_contents(); - SiteEngagementHelper* helper = GetHelper(contents); - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService::Helper* helper = GetHelper(contents); + SiteEngagementService* service = SiteEngagementService::Get(profile()); DCHECK(service); base::HistogramTester histograms; @@ -398,12 +395,11 @@ base::MockTimer* input_tracker_timer = new base::MockTimer(true, false); base::MockTimer* media_tracker_timer = new base::MockTimer(true, false); - SiteEngagementHelper* helper = GetHelper(contents); + SiteEngagementService::Helper* helper = GetHelper(contents); SetInputTrackerPauseTimer(helper, base::WrapUnique(input_tracker_timer)); SetMediaTrackerPauseTimer(helper, base::WrapUnique(media_tracker_timer)); - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService* service = SiteEngagementService::Get(profile()); DCHECK(service); Navigate(url1); @@ -506,7 +502,7 @@ base::MockTimer* input_tracker_timer = new base::MockTimer(true, false); base::MockTimer* media_tracker_timer = new base::MockTimer(true, false); - SiteEngagementHelper* helper = GetHelper(contents); + SiteEngagementService::Helper* helper = GetHelper(contents); SetInputTrackerPauseTimer(helper, base::WrapUnique(input_tracker_timer)); SetMediaTrackerPauseTimer(helper, base::WrapUnique(media_tracker_timer)); @@ -557,7 +553,7 @@ content::WebContents* contents = web_contents(); base::MockTimer* input_tracker_timer = new base::MockTimer(true, false); - SiteEngagementHelper* helper = GetHelper(contents); + SiteEngagementService::Helper* helper = GetHelper(contents); SetInputTrackerPauseTimer(helper, base::WrapUnique(input_tracker_timer)); // Navigation should start the initial delay timer.
diff --git a/chrome/browser/engagement/site_engagement_score.cc b/chrome/browser/engagement/site_engagement_score.cc new file mode 100644 index 0000000..140cd01b --- /dev/null +++ b/chrome/browser/engagement/site_engagement_score.cc
@@ -0,0 +1,305 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/engagement/site_engagement_score.h" + +#include <cmath> + +#include "base/strings/string_number_conversions.h" +#include "base/time/clock.h" +#include "base/time/time.h" +#include "base/values.h" +#include "chrome/browser/engagement/site_engagement_metrics.h" +#include "components/variations/variations_associated_data.h" + +namespace { + +// Delta within which to consider scores equal. +const double kScoreDelta = 0.001; + +// Delta within which to consider internal time values equal. Internal time +// values are in microseconds, so this delta comes out at one second. +const double kTimeDelta = 1000000; + +// Number of days after the last launch of an origin from an installed shortcut +// for which WEB_APP_INSTALLED_POINTS will be added to the engagement score. +const int kMaxDaysSinceShortcutLaunch = 10; + +// Keys used in the variations params. Order matches +// SiteEngagementScore::Variation enum. +const char* kVariationNames[] = { + "max_points_per_day", + "decay_period_in_days", + "decay_points", + "navigation_points", + "user_input_points", + "visible_media_playing_points", + "hidden_media_playing_points", + "web_app_installed_points", + "first_daily_engagement_points", + "medium_engagement_boundary", + "high_engagement_boundary", +}; + +bool DoublesConsideredDifferent(double value1, double value2, double delta) { + double abs_difference = fabs(value1 - value2); + return abs_difference > delta; +} + +} // namespace + +const double SiteEngagementScore::kMaxPoints = 100; +double SiteEngagementScore::param_values[] = { + 5, // MAX_POINTS_PER_DAY + 7, // DECAY_PERIOD_IN_DAYS + 5, // DECAY_POINTS + 0.5, // NAVIGATION_POINTS + 0.2, // USER_INPUT_POINTS + 0.02, // VISIBLE_MEDIA_POINTS + 0.01, // HIDDEN_MEDIA_POINTS + 5, // WEB_APP_INSTALLED_POINTS + 0.5, // FIRST_DAILY_ENGAGEMENT + 8, // BOOTSTRAP_POINTS + 5, // MEDIUM_ENGAGEMENT_BOUNDARY + 50, // HIGH_ENGAGEMENT_BOUNDARY +}; + +const char* SiteEngagementScore::kRawScoreKey = "rawScore"; +const char* SiteEngagementScore::kPointsAddedTodayKey = "pointsAddedToday"; +const char* SiteEngagementScore::kLastEngagementTimeKey = "lastEngagementTime"; +const char* SiteEngagementScore::kLastShortcutLaunchTimeKey = + "lastShortcutLaunchTime"; + +double SiteEngagementScore::GetMaxPointsPerDay() { + return param_values[MAX_POINTS_PER_DAY]; +} + +double SiteEngagementScore::GetDecayPeriodInDays() { + return param_values[DECAY_PERIOD_IN_DAYS]; +} + +double SiteEngagementScore::GetDecayPoints() { + return param_values[DECAY_POINTS]; +} + +double SiteEngagementScore::GetNavigationPoints() { + return param_values[NAVIGATION_POINTS]; +} + +double SiteEngagementScore::GetUserInputPoints() { + return param_values[USER_INPUT_POINTS]; +} + +double SiteEngagementScore::GetVisibleMediaPoints() { + return param_values[VISIBLE_MEDIA_POINTS]; +} + +double SiteEngagementScore::GetHiddenMediaPoints() { + return param_values[HIDDEN_MEDIA_POINTS]; +} + +double SiteEngagementScore::GetWebAppInstalledPoints() { + return param_values[WEB_APP_INSTALLED_POINTS]; +} + +double SiteEngagementScore::GetFirstDailyEngagementPoints() { + return param_values[FIRST_DAILY_ENGAGEMENT]; +} + +double SiteEngagementScore::GetBootstrapPoints() { + return param_values[BOOTSTRAP_POINTS]; +} + +double SiteEngagementScore::GetMediumEngagementBoundary() { + return param_values[MEDIUM_ENGAGEMENT_BOUNDARY]; +} + +double SiteEngagementScore::GetHighEngagementBoundary() { + return param_values[HIGH_ENGAGEMENT_BOUNDARY]; +} + +// static +void SiteEngagementScore::UpdateFromVariations(const char* param_name) { + double param_vals[MAX_VARIATION]; + + for (int i = 0; i < MAX_VARIATION; ++i) { + std::string param_string = + variations::GetVariationParamValue(param_name, kVariationNames[i]); + + // Bail out if we didn't get a param string for the key, or if we couldn't + // convert the param string to a double, or if we get a negative value. + if (param_string.empty() || + !base::StringToDouble(param_string, ¶m_vals[i]) || + param_vals[i] < 0) { + return; + } + } + + // Once we're sure everything is valid, assign the variation to the param + // values array. + for (int i = 0; i < MAX_VARIATION; ++i) + SiteEngagementScore::param_values[i] = param_vals[i]; +} + +SiteEngagementScore::SiteEngagementScore(base::Clock* clock, + const base::DictionaryValue& score_dict) + : SiteEngagementScore(clock) { + score_dict.GetDouble(kRawScoreKey, &raw_score_); + score_dict.GetDouble(kPointsAddedTodayKey, &points_added_today_); + + double internal_time; + if (score_dict.GetDouble(kLastEngagementTimeKey, &internal_time)) + last_engagement_time_ = base::Time::FromInternalValue(internal_time); + if (score_dict.GetDouble(kLastShortcutLaunchTimeKey, &internal_time)) + last_shortcut_launch_time_ = base::Time::FromInternalValue(internal_time); +} + +SiteEngagementScore::~SiteEngagementScore() {} + +void SiteEngagementScore::AddPoints(double points) { + DCHECK_NE(0, points); + double decayed_score = DecayedScore(); + + // Record the original and decayed scores after a decay event. + if (decayed_score < raw_score_) { + SiteEngagementMetrics::RecordScoreDecayedFrom(raw_score_); + SiteEngagementMetrics::RecordScoreDecayedTo(decayed_score); + } + + // As the score is about to be updated, commit any decay that has happened + // since the last update. + raw_score_ = decayed_score; + + base::Time now = clock_->Now(); + if (!last_engagement_time_.is_null() && + now.LocalMidnight() != last_engagement_time_.LocalMidnight()) { + points_added_today_ = 0; + } + + if (points_added_today_ == 0) { + // Award bonus engagement for the first engagement of the day for a site. + points += GetFirstDailyEngagementPoints(); + SiteEngagementMetrics::RecordEngagement( + SiteEngagementMetrics::ENGAGEMENT_FIRST_DAILY_ENGAGEMENT); + } + + double to_add = std::min(kMaxPoints - raw_score_, + GetMaxPointsPerDay() - points_added_today_); + to_add = std::min(to_add, points); + + points_added_today_ += to_add; + raw_score_ += to_add; + + last_engagement_time_ = now; +} + +double SiteEngagementScore::GetScore() const { + return std::min(DecayedScore() + BonusScore(), kMaxPoints); +} + +bool SiteEngagementScore::MaxPointsPerDayAdded() const { + if (!last_engagement_time_.is_null() && + clock_->Now().LocalMidnight() != last_engagement_time_.LocalMidnight()) { + return false; + } + + return points_added_today_ == GetMaxPointsPerDay(); +} + +void SiteEngagementScore::Reset(double points, const base::Time* updated_time) { + raw_score_ = points; + points_added_today_ = 0; + + // This must be set in order to prevent the score from decaying when read. + if (updated_time) { + last_engagement_time_ = *updated_time; + if (!last_shortcut_launch_time_.is_null()) + last_shortcut_launch_time_ = *updated_time; + } else { + last_engagement_time_ = clock_->Now(); + } +} + +bool SiteEngagementScore::UpdateScoreDict(base::DictionaryValue* score_dict) { + double raw_score_orig = 0; + double points_added_today_orig = 0; + double last_engagement_time_internal_orig = 0; + double last_shortcut_launch_time_internal_orig = 0; + + score_dict->GetDouble(kRawScoreKey, &raw_score_orig); + score_dict->GetDouble(kPointsAddedTodayKey, &points_added_today_orig); + score_dict->GetDouble(kLastEngagementTimeKey, + &last_engagement_time_internal_orig); + score_dict->GetDouble(kLastShortcutLaunchTimeKey, + &last_shortcut_launch_time_internal_orig); + bool changed = + DoublesConsideredDifferent(raw_score_orig, raw_score_, kScoreDelta) || + DoublesConsideredDifferent(points_added_today_orig, points_added_today_, + kScoreDelta) || + DoublesConsideredDifferent(last_engagement_time_internal_orig, + last_engagement_time_.ToInternalValue(), + kTimeDelta) || + DoublesConsideredDifferent(last_shortcut_launch_time_internal_orig, + last_shortcut_launch_time_.ToInternalValue(), + kTimeDelta); + + if (!changed) + return false; + + score_dict->SetDouble(kRawScoreKey, raw_score_); + score_dict->SetDouble(kPointsAddedTodayKey, points_added_today_); + score_dict->SetDouble(kLastEngagementTimeKey, + last_engagement_time_.ToInternalValue()); + score_dict->SetDouble(kLastShortcutLaunchTimeKey, + last_shortcut_launch_time_.ToInternalValue()); + + return true; +} + +SiteEngagementScore::SiteEngagementScore(base::Clock* clock) + : clock_(clock), + raw_score_(0), + points_added_today_(0), + last_engagement_time_(), + last_shortcut_launch_time_() {} + +double SiteEngagementScore::DecayedScore() const { + // Note that users can change their clock, so from this system's perspective + // time can go backwards. If that does happen and the system detects that the + // current day is earlier than the last engagement, no decay (or growth) is + // applied. + int days_since_engagement = (clock_->Now() - last_engagement_time_).InDays(); + if (days_since_engagement < 0) + return raw_score_; + + int periods = days_since_engagement / GetDecayPeriodInDays(); + return std::max(0.0, raw_score_ - periods * GetDecayPoints()); +} + +double SiteEngagementScore::BonusScore() const { + int days_since_shortcut_launch = + (clock_->Now() - last_shortcut_launch_time_).InDays(); + if (days_since_shortcut_launch <= kMaxDaysSinceShortcutLaunch) + return GetWebAppInstalledPoints(); + + return 0; +} + +void SiteEngagementScore::SetParamValuesForTesting() { + param_values[MAX_POINTS_PER_DAY] = 5; + param_values[DECAY_PERIOD_IN_DAYS] = 7; + param_values[DECAY_POINTS] = 5; + param_values[NAVIGATION_POINTS] = 0.5; + param_values[USER_INPUT_POINTS] = 0.05; + param_values[VISIBLE_MEDIA_POINTS] = 0.02; + param_values[HIDDEN_MEDIA_POINTS] = 0.01; + param_values[WEB_APP_INSTALLED_POINTS] = 5; + param_values[BOOTSTRAP_POINTS] = 8; + param_values[MEDIUM_ENGAGEMENT_BOUNDARY] = 5; + param_values[HIGH_ENGAGEMENT_BOUNDARY] = 50; + + // This is set to zero to avoid interference with tests and is set when + // testing this functionality. + param_values[FIRST_DAILY_ENGAGEMENT] = 0; +}
diff --git a/chrome/browser/engagement/site_engagement_score.h b/chrome/browser/engagement/site_engagement_score.h new file mode 100644 index 0000000..7bebca7 --- /dev/null +++ b/chrome/browser/engagement/site_engagement_score.h
@@ -0,0 +1,177 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ +#define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ + +#include "base/gtest_prod_util.h" +#include "base/macros.h" +#include "base/time/time.h" +#include "base/values.h" + +namespace base { +class Clock; +} + +class SiteEngagementScore { + public: + // The parameters which can be varied via field trial. All "points" values + // should be appended to the end of the enum prior to MAX_VARIATION. + enum Variation { + // The maximum number of points that can be accrued in one day. + MAX_POINTS_PER_DAY = 0, + + // The period over which site engagement decays. + DECAY_PERIOD_IN_DAYS, + + // The number of points to decay per period. + DECAY_POINTS, + + // The number of points given for navigations. + NAVIGATION_POINTS, + + // The number of points given for user input. + USER_INPUT_POINTS, + + // The number of points given for media playing. Initially calibrated such + // that at least 30 minutes of foreground media would be required to allow a + // site to reach the daily engagement maximum. + VISIBLE_MEDIA_POINTS, + HIDDEN_MEDIA_POINTS, + + // The number of points added to engagement when a site is launched from + // homescreen or added as a bookmark app. This bonus will apply for ten days + // following a launch; each new launch resets the ten days. + WEB_APP_INSTALLED_POINTS, + + // The number of points given for the first engagement event of the day for + // each site. + FIRST_DAILY_ENGAGEMENT, + + // The number of points that the engagement service must accumulate to be + // considered 'useful'. + BOOTSTRAP_POINTS, + + // The boundaries between low/medium and medium/high engagement as returned + // by GetEngagementLevel(). + MEDIUM_ENGAGEMENT_BOUNDARY, + HIGH_ENGAGEMENT_BOUNDARY, + + MAX_VARIATION + }; + + // The maximum number of points that are allowed. + static const double kMaxPoints; + + static double GetMaxPointsPerDay(); + static double GetDecayPeriodInDays(); + static double GetDecayPoints(); + static double GetNavigationPoints(); + static double GetUserInputPoints(); + static double GetVisibleMediaPoints(); + static double GetHiddenMediaPoints(); + static double GetWebAppInstalledPoints(); + static double GetFirstDailyEngagementPoints(); + static double GetBootstrapPoints(); + static double GetMediumEngagementBoundary(); + static double GetHighEngagementBoundary(); + + // Update the default engagement settings via variations. + static void UpdateFromVariations(const char* param_name); + + // The SiteEngagementScore does not take ownership of |clock|. It is the + // responsibility of the caller to make sure |clock| outlives this + // SiteEngagementScore. + SiteEngagementScore(base::Clock* clock, + const base::DictionaryValue& score_dict); + ~SiteEngagementScore(); + + // Adds |points| to this score, respecting daily limits and the maximum + // possible score. Decays the score if it has not been updated recently + // enough. + void AddPoints(double points); + double GetScore() const; + + // Returns true if the maximum number of points today has been added. + bool MaxPointsPerDayAdded() const; + + // Resets the score to |points| and resets the daily point limit. If + // |updated_time| is non-null, sets the last engagement time and last + // shortcut launch time (if it is non-null) to |updated_time|. Otherwise, last + // engagement time is set to the current time and last shortcut launch time is + // left unchanged. + // TODO(calamity): Ideally, all SiteEngagementScore methods should take a + // base::Time argument like this one does rather than each SiteEngagementScore + // hold a pointer to a base::Clock. Then SiteEngagementScore doesn't need to + // worry about clock vending. See crbug.com/604305. + void Reset(double points, const base::Time* updated_time); + + // Updates the content settings dictionary |score_dict| with the current score + // fields. Returns true if |score_dict| changed, otherwise return false. + bool UpdateScoreDict(base::DictionaryValue* score_dict); + + // Get/set the last time this origin was launched from an installed shortcut. + base::Time last_shortcut_launch_time() const { + return last_shortcut_launch_time_; + } + void set_last_shortcut_launch_time(const base::Time& time) { + last_shortcut_launch_time_ = time; + } + + private: + FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PartiallyEmptyDictionary); + FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PopulatedDictionary); + FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, Reset); + FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, FirstDailyEngagementBonus); + friend class ImportantSitesUtilTest; + friend class SiteEngagementHelperTest; + friend class SiteEngagementScoreTest; + friend class SiteEngagementServiceTest; + + // Array holding the values corresponding to each item in Variation array. + static double param_values[]; + + // Keys used in the content settings dictionary. + static const char* kRawScoreKey; + static const char* kPointsAddedTodayKey; + static const char* kLastEngagementTimeKey; + static const char* kLastShortcutLaunchTimeKey; + + // This version of the constructor is used in unit tests. + explicit SiteEngagementScore(base::Clock* clock); + + // Determine the score, accounting for any decay. + double DecayedScore() const; + + // Determine any score bonus from having installed shortcuts. + double BonusScore() const; + + // Sets fixed parameter values for testing site engagement. Ensure that any + // newly added parameters receive a fixed value here. + static void SetParamValuesForTesting(); + + // The clock used to vend times. Enables time travelling in tests. Owned by + // the SiteEngagementService. + base::Clock* clock_; + + // |raw_score_| is the score before any decay is applied. + double raw_score_; + + // The points added 'today' are tracked to avoid adding more than + // kMaxPointsPerDay on any one day. 'Today' is defined in local time. + double points_added_today_; + + // The last time the score was updated for engagement. Used in conjunction + // with |points_added_today_| to avoid adding more than kMaxPointsPerDay on + // any one day. + base::Time last_engagement_time_; + + // The last time the site with this score was launched from an installed + // shortcut. + base::Time last_shortcut_launch_time_; + + DISALLOW_COPY_AND_ASSIGN(SiteEngagementScore); +}; + +#endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_
diff --git a/chrome/browser/engagement/site_engagement_score_unittest.cc b/chrome/browser/engagement/site_engagement_score_unittest.cc new file mode 100644 index 0000000..a536f927 --- /dev/null +++ b/chrome/browser/engagement/site_engagement_score_unittest.cc
@@ -0,0 +1,411 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/engagement/site_engagement_score.h" + +#include <utility> + +#include "base/macros.h" +#include "base/test/simple_test_clock.h" +#include "base/values.h" +#include "chrome/browser/engagement/site_engagement_service.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +const int kLessAccumulationsThanNeededToMaxDailyEngagement = 2; +const int kMoreAccumulationsThanNeededToMaxDailyEngagement = 40; +const int kMoreAccumulationsThanNeededToMaxTotalEngagement = 200; +const int kLessDaysThanNeededToMaxTotalEngagement = 4; +const int kMoreDaysThanNeededToMaxTotalEngagement = 40; +const int kLessPeriodsThanNeededToDecayMaxScore = 2; +const int kMorePeriodsThanNeededToDecayMaxScore = 40; + +base::Time GetReferenceTime() { + base::Time::Exploded exploded_reference_time; + exploded_reference_time.year = 2015; + exploded_reference_time.month = 1; + exploded_reference_time.day_of_month = 30; + exploded_reference_time.day_of_week = 5; + exploded_reference_time.hour = 11; + exploded_reference_time.minute = 0; + exploded_reference_time.second = 0; + exploded_reference_time.millisecond = 0; + + return base::Time::FromLocalExploded(exploded_reference_time); +} + +} // namespace + +class SiteEngagementScoreTest : public testing::Test { + public: + SiteEngagementScoreTest() : score_(&test_clock_) {} + + void SetUp() override { + testing::Test::SetUp(); + // Disable the first engagement bonus for tests. + SiteEngagementScore::SetParamValuesForTesting(); + } + + protected: + void VerifyScore(const SiteEngagementScore& score, + double expected_raw_score, + double expected_points_added_today, + base::Time expected_last_engagement_time) { + EXPECT_EQ(expected_raw_score, score.raw_score_); + EXPECT_EQ(expected_points_added_today, score.points_added_today_); + EXPECT_EQ(expected_last_engagement_time, score.last_engagement_time_); + } + + void UpdateScore(SiteEngagementScore* score, + double raw_score, + double points_added_today, + base::Time last_engagement_time) { + score->raw_score_ = raw_score; + score->points_added_today_ = points_added_today; + score->last_engagement_time_ = last_engagement_time; + } + + void TestScoreInitializesAndUpdates( + base::DictionaryValue* score_dict, + double expected_raw_score, + double expected_points_added_today, + base::Time expected_last_engagement_time) { + SiteEngagementScore initial_score(&test_clock_, *score_dict); + VerifyScore(initial_score, expected_raw_score, expected_points_added_today, + expected_last_engagement_time); + + // Updating the score dict should return false, as the score shouldn't + // have changed at this point. + EXPECT_FALSE(initial_score.UpdateScoreDict(score_dict)); + + // Update the score to new values and verify it updates the score dict + // correctly. + base::Time different_day = + GetReferenceTime() + base::TimeDelta::FromDays(1); + UpdateScore(&initial_score, 5, 10, different_day); + EXPECT_TRUE(initial_score.UpdateScoreDict(score_dict)); + SiteEngagementScore updated_score(&test_clock_, *score_dict); + VerifyScore(updated_score, 5, 10, different_day); + } + + void SetFirstDailyEngagementPointsForTesting(double points) { + SiteEngagementScore::param_values + [SiteEngagementScore::FIRST_DAILY_ENGAGEMENT] = points; + } + + base::SimpleTestClock test_clock_; + SiteEngagementScore score_; +}; + +// Accumulate score many times on the same day. Ensure each time the score goes +// up, but not more than the maximum per day. +TEST_F(SiteEngagementScoreTest, AccumulateOnSameDay) { + base::Time reference_time = GetReferenceTime(); + + test_clock_.SetNow(reference_time); + for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { + score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); + EXPECT_EQ(std::min(SiteEngagementScore::GetMaxPointsPerDay(), + (i + 1) * SiteEngagementScore::GetNavigationPoints()), + score_.GetScore()); + } + + EXPECT_EQ(SiteEngagementScore::GetMaxPointsPerDay(), score_.GetScore()); +} + +// Accumulate on the first day to max that day's engagement, then accumulate on +// a different day. +TEST_F(SiteEngagementScoreTest, AccumulateOnTwoDays) { + base::Time reference_time = GetReferenceTime(); + base::Time later_date = reference_time + base::TimeDelta::FromDays(2); + + test_clock_.SetNow(reference_time); + for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) + score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); + + EXPECT_EQ(SiteEngagementScore::GetMaxPointsPerDay(), score_.GetScore()); + + test_clock_.SetNow(later_date); + for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { + score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); + double day_score = + std::min(SiteEngagementScore::GetMaxPointsPerDay(), + (i + 1) * SiteEngagementScore::GetNavigationPoints()); + EXPECT_EQ(day_score + SiteEngagementScore::GetMaxPointsPerDay(), + score_.GetScore()); + } + + EXPECT_EQ(2 * SiteEngagementScore::GetMaxPointsPerDay(), score_.GetScore()); +} + +// Accumulate score on many consecutive days and ensure the score doesn't exceed +// the maximum allowed. +TEST_F(SiteEngagementScoreTest, AccumulateALotOnManyDays) { + base::Time current_day = GetReferenceTime(); + + for (int i = 0; i < kMoreDaysThanNeededToMaxTotalEngagement; ++i) { + current_day += base::TimeDelta::FromDays(1); + test_clock_.SetNow(current_day); + for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) + score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); + + EXPECT_EQ(std::min(SiteEngagementScore::kMaxPoints, + (i + 1) * SiteEngagementScore::GetMaxPointsPerDay()), + score_.GetScore()); + } + + EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.GetScore()); +} + +// Accumulate a little on many consecutive days and ensure the score doesn't +// exceed the maximum allowed. +TEST_F(SiteEngagementScoreTest, AccumulateALittleOnManyDays) { + base::Time current_day = GetReferenceTime(); + + for (int i = 0; i < kMoreAccumulationsThanNeededToMaxTotalEngagement; ++i) { + current_day += base::TimeDelta::FromDays(1); + test_clock_.SetNow(current_day); + + for (int j = 0; j < kLessAccumulationsThanNeededToMaxDailyEngagement; ++j) + score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); + + EXPECT_EQ( + std::min(SiteEngagementScore::kMaxPoints, + (i + 1) * kLessAccumulationsThanNeededToMaxDailyEngagement * + SiteEngagementScore::GetNavigationPoints()), + score_.GetScore()); + } + + EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.GetScore()); +} + +// Accumulate a bit, then check the score decays properly for a range of times. +TEST_F(SiteEngagementScoreTest, ScoresDecayOverTime) { + base::Time current_day = GetReferenceTime(); + + // First max the score. + for (int i = 0; i < kMoreDaysThanNeededToMaxTotalEngagement; ++i) { + current_day += base::TimeDelta::FromDays(1); + test_clock_.SetNow(current_day); + + for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) + score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); + } + + EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.GetScore()); + + // The score should not have decayed before the first decay period has + // elapsed. + test_clock_.SetNow(current_day + + base::TimeDelta::FromDays( + SiteEngagementScore::GetDecayPeriodInDays() - 1)); + EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.GetScore()); + + // The score should have decayed by one chunk after one decay period has + // elapsed. + test_clock_.SetNow( + current_day + + base::TimeDelta::FromDays(SiteEngagementScore::GetDecayPeriodInDays())); + EXPECT_EQ( + SiteEngagementScore::kMaxPoints - SiteEngagementScore::GetDecayPoints(), + score_.GetScore()); + + // The score should have decayed by the right number of chunks after a few + // decay periods have elapsed. + test_clock_.SetNow( + current_day + + base::TimeDelta::FromDays(kLessPeriodsThanNeededToDecayMaxScore * + SiteEngagementScore::GetDecayPeriodInDays())); + EXPECT_EQ(SiteEngagementScore::kMaxPoints - + kLessPeriodsThanNeededToDecayMaxScore * + SiteEngagementScore::GetDecayPoints(), + score_.GetScore()); + + // The score should not decay below zero. + test_clock_.SetNow( + current_day + + base::TimeDelta::FromDays(kMorePeriodsThanNeededToDecayMaxScore * + SiteEngagementScore::GetDecayPeriodInDays())); + EXPECT_EQ(0, score_.GetScore()); +} + +// Test that any expected decays are applied before adding points. +TEST_F(SiteEngagementScoreTest, DecaysAppliedBeforeAdd) { + base::Time current_day = GetReferenceTime(); + + // Get the score up to something that can handle a bit of decay before + for (int i = 0; i < kLessDaysThanNeededToMaxTotalEngagement; ++i) { + current_day += base::TimeDelta::FromDays(1); + test_clock_.SetNow(current_day); + + for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) + score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); + } + + double initial_score = kLessDaysThanNeededToMaxTotalEngagement * + SiteEngagementScore::GetMaxPointsPerDay(); + EXPECT_EQ(initial_score, score_.GetScore()); + + // Go forward a few decay periods. + test_clock_.SetNow( + current_day + + base::TimeDelta::FromDays(kLessPeriodsThanNeededToDecayMaxScore * + SiteEngagementScore::GetDecayPeriodInDays())); + + double decayed_score = initial_score - + kLessPeriodsThanNeededToDecayMaxScore * + SiteEngagementScore::GetDecayPoints(); + EXPECT_EQ(decayed_score, score_.GetScore()); + + // Now add some points. + score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); + EXPECT_EQ(decayed_score + SiteEngagementScore::GetNavigationPoints(), + score_.GetScore()); +} + +// Test that going back in time is handled properly. +TEST_F(SiteEngagementScoreTest, GoBackInTime) { + base::Time current_day = GetReferenceTime(); + + test_clock_.SetNow(current_day); + for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) + score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); + + EXPECT_EQ(SiteEngagementScore::GetMaxPointsPerDay(), score_.GetScore()); + + // Adding to the score on an earlier date should be treated like another day, + // and should not cause any decay. + test_clock_.SetNow(current_day - base::TimeDelta::FromDays( + kMorePeriodsThanNeededToDecayMaxScore * + SiteEngagementScore::GetDecayPoints())); + for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { + score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); + double day_score = + std::min(SiteEngagementScore::GetMaxPointsPerDay(), + (i + 1) * SiteEngagementScore::GetNavigationPoints()); + EXPECT_EQ(day_score + SiteEngagementScore::GetMaxPointsPerDay(), + score_.GetScore()); + } + + EXPECT_EQ(2 * SiteEngagementScore::GetMaxPointsPerDay(), score_.GetScore()); +} + +// Test that scores are read / written correctly from / to empty score +// dictionaries. +TEST_F(SiteEngagementScoreTest, EmptyDictionary) { + base::DictionaryValue dict; + TestScoreInitializesAndUpdates(&dict, 0, 0, base::Time()); +} + +// Test that scores are read / written correctly from / to partially empty +// score dictionaries. +TEST_F(SiteEngagementScoreTest, PartiallyEmptyDictionary) { + base::DictionaryValue dict; + dict.SetDouble(SiteEngagementScore::kPointsAddedTodayKey, 2); + + TestScoreInitializesAndUpdates(&dict, 0, 2, base::Time()); +} + +// Test that scores are read / written correctly from / to populated score +// dictionaries. +TEST_F(SiteEngagementScoreTest, PopulatedDictionary) { + base::DictionaryValue dict; + dict.SetDouble(SiteEngagementScore::kRawScoreKey, 1); + dict.SetDouble(SiteEngagementScore::kPointsAddedTodayKey, 2); + dict.SetDouble(SiteEngagementScore::kLastEngagementTimeKey, + GetReferenceTime().ToInternalValue()); + + TestScoreInitializesAndUpdates(&dict, 1, 2, GetReferenceTime()); +} + +// Ensure bonus engagement is awarded for the first engagement of a day. +TEST_F(SiteEngagementScoreTest, FirstDailyEngagementBonus) { + SetFirstDailyEngagementPointsForTesting(0.5); + + SiteEngagementScore score1(&test_clock_); + SiteEngagementScore score2(&test_clock_); + base::Time current_day = GetReferenceTime(); + + test_clock_.SetNow(current_day); + + // The first engagement event gets the bonus. + score1.AddPoints(0.5); + EXPECT_EQ(1.0, score1.GetScore()); + + // Subsequent events do not. + score1.AddPoints(0.5); + EXPECT_EQ(1.5, score1.GetScore()); + + // Bonuses are awarded independently between scores. + score2.AddPoints(1.0); + EXPECT_EQ(1.5, score2.GetScore()); + score2.AddPoints(1.0); + EXPECT_EQ(2.5, score2.GetScore()); + + test_clock_.SetNow(current_day + base::TimeDelta::FromDays(1)); + + // The first event for the next day gets the bonus. + score1.AddPoints(0.5); + EXPECT_EQ(2.5, score1.GetScore()); + + // Subsequent events do not. + score1.AddPoints(0.5); + EXPECT_EQ(3.0, score1.GetScore()); + + score2.AddPoints(1.0); + EXPECT_EQ(4.0, score2.GetScore()); + score2.AddPoints(1.0); + EXPECT_EQ(5.0, score2.GetScore()); +} + +// Test that resetting a score has the correct properties. +TEST_F(SiteEngagementScoreTest, Reset) { + base::Time current_day = GetReferenceTime(); + + test_clock_.SetNow(current_day); + score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); + EXPECT_EQ(SiteEngagementScore::GetNavigationPoints(), score_.GetScore()); + + current_day += base::TimeDelta::FromDays(7); + test_clock_.SetNow(current_day); + + score_.Reset(20.0, nullptr); + EXPECT_DOUBLE_EQ(20.0, score_.GetScore()); + EXPECT_DOUBLE_EQ(0, score_.points_added_today_); + EXPECT_EQ(current_day, score_.last_engagement_time_); + EXPECT_TRUE(score_.last_shortcut_launch_time_.is_null()); + + // Adding points after the reset should work as normal. + score_.AddPoints(5); + EXPECT_EQ(25.0, score_.GetScore()); + + // The decay should happen one decay period from the current time. + test_clock_.SetNow(current_day + + base::TimeDelta::FromDays( + SiteEngagementScore::GetDecayPeriodInDays() + 1)); + EXPECT_EQ(25.0 - SiteEngagementScore::GetDecayPoints(), score_.GetScore()); + + // Ensure that manually setting a time works as expected. + score_.AddPoints(5); + test_clock_.SetNow(GetReferenceTime()); + base::Time now = test_clock_.Now(); + score_.Reset(10.0, &now); + + EXPECT_DOUBLE_EQ(10.0, score_.GetScore()); + EXPECT_DOUBLE_EQ(0, score_.points_added_today_); + EXPECT_EQ(now, score_.last_engagement_time_); + EXPECT_TRUE(score_.last_shortcut_launch_time_.is_null()); + + score_.set_last_shortcut_launch_time(test_clock_.Now()); + test_clock_.SetNow(GetReferenceTime() + base::TimeDelta::FromDays(3)); + now = test_clock_.Now(); + score_.Reset(15.0, &now); + + // 5 bonus from the last shortcut launch. + EXPECT_DOUBLE_EQ(20.0, score_.GetScore()); + EXPECT_DOUBLE_EQ(0, score_.points_added_today_); + EXPECT_EQ(now, score_.last_engagement_time_); + EXPECT_EQ(now, score_.last_shortcut_launch_time_); +}
diff --git a/chrome/browser/engagement/site_engagement_service.cc b/chrome/browser/engagement/site_engagement_service.cc index df709189e..fa8f699 100644 --- a/chrome/browser/engagement/site_engagement_service.cc +++ b/chrome/browser/engagement/site_engagement_service.cc
@@ -7,14 +7,12 @@ #include <stddef.h> #include <algorithm> -#include <cmath> #include <utility> #include <vector> #include "base/command_line.h" #include "base/memory/ptr_util.h" #include "base/metrics/field_trial.h" -#include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/time/clock.h" #include "base/time/default_clock.h" @@ -23,14 +21,14 @@ #include "chrome/browser/banners/app_banner_settings_helper.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/engagement/site_engagement_eviction_policy.h" -#include "chrome/browser/engagement/site_engagement_helper.h" +#include "chrome/browser/engagement/site_engagement_metrics.h" +#include "chrome/browser/engagement/site_engagement_score.h" #include "chrome/browser/engagement/site_engagement_service_factory.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/common/chrome_switches.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/common/content_settings_pattern.h" #include "components/history/core/browser/history_service.h" -#include "components/variations/variations_associated_data.h" #include "content/public/browser/browser_thread.h" #include "url/gurl.h" @@ -41,36 +39,9 @@ // Global bool to ensure we only update the parameters from variations once. bool g_updated_from_variations = false; -// Keys used in the variations params. Order matches -// SiteEngagementScore::Variation enum. -const char* kVariationNames[] = { - "max_points_per_day", - "decay_period_in_days", - "decay_points", - "navigation_points", - "user_input_points", - "visible_media_playing_points", - "hidden_media_playing_points", - "web_app_installed_points", - "first_daily_engagement_points", - "medium_engagement_boundary", - "high_engagement_boundary", -}; - // Length of time between metrics logging. const int kMetricsIntervalInMinutes = 60; -// Delta within which to consider scores equal. -const double kScoreDelta = 0.001; - -// Delta within which to consider internal time values equal. Internal time -// values are in microseconds, so this delta comes out at one second. -const double kTimeDelta = 1000000; - -// Number of days after the last launch of an origin from an installed shortcut -// for which WEB_APP_INSTALLED_POINTS will be added to the engagement score. -const int kMaxDaysSinceShortcutLaunch = 10; - std::unique_ptr<ContentSettingsForOneType> GetEngagementContentSettings( HostContentSettingsMap* settings_map) { std::unique_ptr<ContentSettingsForOneType> engagement_settings( @@ -80,27 +51,6 @@ return engagement_settings; } -bool DoublesConsideredDifferent(double value1, double value2, double delta) { - double abs_difference = fabs(value1 - value2); - return abs_difference > delta; -} - -// Only accept a navigation event for engagement if it is one of: -// a. direct typed navigation -// b. clicking on an omnibox suggestion brought up by typing a keyword -// c. clicking on a bookmark or opening a bookmark app -// d. a custom search engine keyword search (e.g. Wikipedia search box added as -// search engine). -bool IsEngagementNavigation(ui::PageTransition transition) { - return ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED) || - ui::PageTransitionCoreTypeIs(transition, - ui::PAGE_TRANSITION_GENERATED) || - ui::PageTransitionCoreTypeIs(transition, - ui::PAGE_TRANSITION_AUTO_BOOKMARK) || - ui::PageTransitionCoreTypeIs(transition, - ui::PAGE_TRANSITION_KEYWORD_GENERATED); -} - std::unique_ptr<base::DictionaryValue> GetScoreDictForOrigin( HostContentSettingsMap* settings, const GURL& origin_url) { @@ -119,264 +69,24 @@ return base::WrapUnique(static_cast<base::DictionaryValue*>(value.release())); } +// Only accept a navigation event for engagement if it is one of: +// a. direct typed navigation +// b. clicking on an omnibox suggestion brought up by typing a keyword +// c. clicking on a bookmark or opening a bookmark app +// d. a custom search engine keyword search (e.g. Wikipedia search box added as +// search engine). +bool IsEngagementNavigation(ui::PageTransition transition) { + return ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_TYPED) || + ui::PageTransitionCoreTypeIs(transition, + ui::PAGE_TRANSITION_GENERATED) || + ui::PageTransitionCoreTypeIs(transition, + ui::PAGE_TRANSITION_AUTO_BOOKMARK) || + ui::PageTransitionCoreTypeIs(transition, + ui::PAGE_TRANSITION_KEYWORD_GENERATED); +} + } // namespace -const double SiteEngagementScore::kMaxPoints = 100; -double SiteEngagementScore::param_values[] = { - 5, // MAX_POINTS_PER_DAY - 7, // DECAY_PERIOD_IN_DAYS - 5, // DECAY_POINTS - 0.5, // NAVIGATION_POINTS - 0.2, // USER_INPUT_POINTS - 0.02, // VISIBLE_MEDIA_POINTS - 0.01, // HIDDEN_MEDIA_POINTS - 5, // WEB_APP_INSTALLED_POINTS - 0.5, // FIRST_DAILY_ENGAGEMENT - 8, // BOOTSTRAP_POINTS - 5, // MEDIUM_ENGAGEMENT_BOUNDARY - 50, // HIGH_ENGAGEMENT_BOUNDARY -}; - -const char* SiteEngagementScore::kRawScoreKey = "rawScore"; -const char* SiteEngagementScore::kPointsAddedTodayKey = "pointsAddedToday"; -const char* SiteEngagementScore::kLastEngagementTimeKey = "lastEngagementTime"; -const char* SiteEngagementScore::kLastShortcutLaunchTimeKey = - "lastShortcutLaunchTime"; - -double SiteEngagementScore::GetMaxPointsPerDay() { - return param_values[MAX_POINTS_PER_DAY]; -} - -double SiteEngagementScore::GetDecayPeriodInDays() { - return param_values[DECAY_PERIOD_IN_DAYS]; -} - -double SiteEngagementScore::GetDecayPoints() { - return param_values[DECAY_POINTS]; -} - -double SiteEngagementScore::GetNavigationPoints() { - return param_values[NAVIGATION_POINTS]; -} - -double SiteEngagementScore::GetUserInputPoints() { - return param_values[USER_INPUT_POINTS]; -} - -double SiteEngagementScore::GetVisibleMediaPoints() { - return param_values[VISIBLE_MEDIA_POINTS]; -} - -double SiteEngagementScore::GetHiddenMediaPoints() { - return param_values[HIDDEN_MEDIA_POINTS]; -} - -double SiteEngagementScore::GetWebAppInstalledPoints() { - return param_values[WEB_APP_INSTALLED_POINTS]; -} - -double SiteEngagementScore::GetFirstDailyEngagementPoints() { - return param_values[FIRST_DAILY_ENGAGEMENT]; -} - -double SiteEngagementScore::GetBootstrapPoints() { - return param_values[BOOTSTRAP_POINTS]; -} - -double SiteEngagementScore::GetMediumEngagementBoundary() { - return param_values[MEDIUM_ENGAGEMENT_BOUNDARY]; -} - -double SiteEngagementScore::GetHighEngagementBoundary() { - return param_values[HIGH_ENGAGEMENT_BOUNDARY]; -} - -void SiteEngagementScore::UpdateFromVariations() { - double param_vals[MAX_VARIATION]; - - for (int i = 0; i < MAX_VARIATION; ++i) { - std::string param_string = variations::GetVariationParamValue( - SiteEngagementService::kEngagementParams, kVariationNames[i]); - - // Bail out if we didn't get a param string for the key, or if we couldn't - // convert the param string to a double, or if we get a negative value. - if (param_string.empty() || - !base::StringToDouble(param_string, ¶m_vals[i]) || - param_vals[i] < 0) { - return; - } - } - - // Once we're sure everything is valid, assign the variation to the param - // values array. - for (int i = 0; i < MAX_VARIATION; ++i) - SiteEngagementScore::param_values[i] = param_vals[i]; -} - -SiteEngagementScore::SiteEngagementScore( - base::Clock* clock, - const base::DictionaryValue& score_dict) - : SiteEngagementScore(clock) { - score_dict.GetDouble(kRawScoreKey, &raw_score_); - score_dict.GetDouble(kPointsAddedTodayKey, &points_added_today_); - - double internal_time; - if (score_dict.GetDouble(kLastEngagementTimeKey, &internal_time)) - last_engagement_time_ = base::Time::FromInternalValue(internal_time); - if (score_dict.GetDouble(kLastShortcutLaunchTimeKey, &internal_time)) - last_shortcut_launch_time_ = base::Time::FromInternalValue(internal_time); -} - -SiteEngagementScore::~SiteEngagementScore() { -} - -double SiteEngagementScore::Score() const { - return std::min(DecayedScore() + BonusScore(), kMaxPoints); -} - -void SiteEngagementScore::AddPoints(double points) { - DCHECK_NE(0, points); - double decayed_score = DecayedScore(); - - // Record the original and decayed scores after a decay event. - if (decayed_score < raw_score_) { - SiteEngagementMetrics::RecordScoreDecayedFrom(raw_score_); - SiteEngagementMetrics::RecordScoreDecayedTo(decayed_score); - } - - // As the score is about to be updated, commit any decay that has happened - // since the last update. - raw_score_ = decayed_score; - - base::Time now = clock_->Now(); - if (!last_engagement_time_.is_null() && - now.LocalMidnight() != last_engagement_time_.LocalMidnight()) { - points_added_today_ = 0; - } - - if (points_added_today_ == 0) { - // Award bonus engagement for the first engagement of the day for a site. - points += GetFirstDailyEngagementPoints(); - SiteEngagementMetrics::RecordEngagement( - SiteEngagementMetrics::ENGAGEMENT_FIRST_DAILY_ENGAGEMENT); - } - - double to_add = std::min(kMaxPoints - raw_score_, - GetMaxPointsPerDay() - points_added_today_); - to_add = std::min(to_add, points); - - points_added_today_ += to_add; - raw_score_ += to_add; - - last_engagement_time_ = now; -} - -void SiteEngagementScore::Reset(double points, const base::Time* updated_time) { - raw_score_ = points; - points_added_today_ = 0; - - // This must be set in order to prevent the score from decaying when read. - if (updated_time) { - last_engagement_time_ = *updated_time; - if (!last_shortcut_launch_time_.is_null()) - last_shortcut_launch_time_ = *updated_time; - } else { - last_engagement_time_ = clock_->Now(); - } -} - -bool SiteEngagementScore::MaxPointsPerDayAdded() const { - if (!last_engagement_time_.is_null() && - clock_->Now().LocalMidnight() != last_engagement_time_.LocalMidnight()) { - return false; - } - - return points_added_today_ == GetMaxPointsPerDay(); -} - -bool SiteEngagementScore::UpdateScoreDict(base::DictionaryValue* score_dict) { - double raw_score_orig = 0; - double points_added_today_orig = 0; - double last_engagement_time_internal_orig = 0; - double last_shortcut_launch_time_internal_orig = 0; - - score_dict->GetDouble(kRawScoreKey, &raw_score_orig); - score_dict->GetDouble(kPointsAddedTodayKey, &points_added_today_orig); - score_dict->GetDouble(kLastEngagementTimeKey, - &last_engagement_time_internal_orig); - score_dict->GetDouble(kLastShortcutLaunchTimeKey, - &last_shortcut_launch_time_internal_orig); - bool changed = - DoublesConsideredDifferent(raw_score_orig, raw_score_, kScoreDelta) || - DoublesConsideredDifferent(points_added_today_orig, points_added_today_, - kScoreDelta) || - DoublesConsideredDifferent(last_engagement_time_internal_orig, - last_engagement_time_.ToInternalValue(), - kTimeDelta) || - DoublesConsideredDifferent(last_shortcut_launch_time_internal_orig, - last_shortcut_launch_time_.ToInternalValue(), - kTimeDelta); - - if (!changed) - return false; - - score_dict->SetDouble(kRawScoreKey, raw_score_); - score_dict->SetDouble(kPointsAddedTodayKey, points_added_today_); - score_dict->SetDouble(kLastEngagementTimeKey, - last_engagement_time_.ToInternalValue()); - score_dict->SetDouble(kLastShortcutLaunchTimeKey, - last_shortcut_launch_time_.ToInternalValue()); - - return true; -} - -SiteEngagementScore::SiteEngagementScore(base::Clock* clock) - : clock_(clock), - raw_score_(0), - points_added_today_(0), - last_engagement_time_(), - last_shortcut_launch_time_() {} - -double SiteEngagementScore::DecayedScore() const { - // Note that users can change their clock, so from this system's perspective - // time can go backwards. If that does happen and the system detects that the - // current day is earlier than the last engagement, no decay (or growth) is - // applied. - int days_since_engagement = (clock_->Now() - last_engagement_time_).InDays(); - if (days_since_engagement < 0) - return raw_score_; - - int periods = days_since_engagement / GetDecayPeriodInDays(); - return std::max(0.0, raw_score_ - periods * GetDecayPoints()); -} - -double SiteEngagementScore::BonusScore() const { - int days_since_shortcut_launch = - (clock_->Now() - last_shortcut_launch_time_).InDays(); - if (days_since_shortcut_launch <= kMaxDaysSinceShortcutLaunch) - return GetWebAppInstalledPoints(); - - return 0; -} - -void SiteEngagementScore::SetParamValuesForTesting() { - param_values[MAX_POINTS_PER_DAY] = 5; - param_values[DECAY_PERIOD_IN_DAYS] = 7; - param_values[DECAY_POINTS] = 5; - param_values[NAVIGATION_POINTS] = 0.5; - param_values[USER_INPUT_POINTS] = 0.05; - param_values[VISIBLE_MEDIA_POINTS] = 0.02; - param_values[HIDDEN_MEDIA_POINTS] = 0.01; - param_values[WEB_APP_INSTALLED_POINTS] = 5; - param_values[BOOTSTRAP_POINTS] = 8; - param_values[MEDIUM_ENGAGEMENT_BOUNDARY] = 5; - param_values[HIGH_ENGAGEMENT_BOUNDARY] = 50; - - // This is set to zero to avoid interference with tests and is set when - // testing this functionality. - param_values[FIRST_DAILY_ENGAGEMENT] = 0; -} - const char SiteEngagementService::kEngagementParams[] = "SiteEngagement"; // static @@ -385,6 +95,11 @@ } // static +double SiteEngagementService::GetMaxPoints() { + return SiteEngagementScore::kMaxPoints; +} + +// static bool SiteEngagementService::IsEnabled() { // If the engagement service or any of its dependencies are force-enabled, // return true immediately. @@ -414,7 +129,7 @@ weak_factory_.GetWeakPtr())); if (!g_updated_from_variations) { - SiteEngagementScore::UpdateFromVariations(); + SiteEngagementScore::UpdateFromVariations(kEngagementParams); g_updated_from_variations = true; } } @@ -426,57 +141,78 @@ history->RemoveObserver(this); } -void SiteEngagementService::HandleNavigation(const GURL& url, - ui::PageTransition transition) { - if (IsEngagementNavigation(transition)) { - SiteEngagementMetrics::RecordEngagement( - SiteEngagementMetrics::ENGAGEMENT_NAVIGATION); - AddPoints(url, SiteEngagementScore::GetNavigationPoints()); - RecordMetrics(); +SiteEngagementService::EngagementLevel +SiteEngagementService::GetEngagementLevel(const GURL& url) const { + DCHECK_LT(SiteEngagementScore::GetMediumEngagementBoundary(), + SiteEngagementScore::GetHighEngagementBoundary()); + double score = GetScore(url); + if (score == 0) + return ENGAGEMENT_LEVEL_NONE; + + if (score < SiteEngagementScore::GetMediumEngagementBoundary()) + return ENGAGEMENT_LEVEL_LOW; + + if (score < SiteEngagementScore::GetHighEngagementBoundary()) + return ENGAGEMENT_LEVEL_MEDIUM; + + if (score < SiteEngagementScore::kMaxPoints) + return ENGAGEMENT_LEVEL_HIGH; + + return ENGAGEMENT_LEVEL_MAX; +} + +std::map<GURL, double> SiteEngagementService::GetScoreMap() const { + HostContentSettingsMap* settings_map = + HostContentSettingsMapFactory::GetForProfile(profile_); + std::unique_ptr<ContentSettingsForOneType> engagement_settings = + GetEngagementContentSettings(settings_map); + + std::map<GURL, double> score_map; + for (const auto& site : *engagement_settings) { + GURL origin(site.primary_pattern.ToString()); + if (!origin.is_valid()) + continue; + + std::unique_ptr<base::DictionaryValue> score_dict = + GetScoreDictForOrigin(settings_map, origin); + SiteEngagementScore score(clock_.get(), *score_dict); + score_map[origin] = score.GetScore(); } + + return score_map; } -void SiteEngagementService::HandleUserInput( +bool SiteEngagementService::IsBootstrapped() { + return GetTotalEngagementPoints() >= + SiteEngagementScore::GetBootstrapPoints(); +} + +bool SiteEngagementService::IsEngagementAtLeast( const GURL& url, - SiteEngagementMetrics::EngagementType type) { - SiteEngagementMetrics::RecordEngagement(type); - AddPoints(url, SiteEngagementScore::GetUserInputPoints()); - RecordMetrics(); -} - -void SiteEngagementService::HandleMediaPlaying(const GURL& url, - bool is_hidden) { - SiteEngagementMetrics::RecordEngagement( - is_hidden ? SiteEngagementMetrics::ENGAGEMENT_MEDIA_HIDDEN - : SiteEngagementMetrics::ENGAGEMENT_MEDIA_VISIBLE); - AddPoints(url, is_hidden ? SiteEngagementScore::GetHiddenMediaPoints() - : SiteEngagementScore::GetVisibleMediaPoints()); - RecordMetrics(); + EngagementLevel level) const { + DCHECK_LT(SiteEngagementScore::GetMediumEngagementBoundary(), + SiteEngagementScore::GetHighEngagementBoundary()); + double score = GetScore(url); + switch (level) { + case ENGAGEMENT_LEVEL_NONE: + return true; + case ENGAGEMENT_LEVEL_LOW: + return score > 0; + case ENGAGEMENT_LEVEL_MEDIUM: + return score >= SiteEngagementScore::GetMediumEngagementBoundary(); + case ENGAGEMENT_LEVEL_HIGH: + return score >= SiteEngagementScore::GetHighEngagementBoundary(); + case ENGAGEMENT_LEVEL_MAX: + return score == SiteEngagementScore::kMaxPoints; + } + NOTREACHED(); + return false; } void SiteEngagementService::ResetScoreForURL(const GURL& url, double score) { ResetScoreAndAccessTimesForURL(url, score, nullptr); } -void SiteEngagementService::OnURLsDeleted( - history::HistoryService* history_service, - bool all_history, - bool expired, - const history::URLRows& deleted_rows, - const std::set<GURL>& favicon_urls) { - std::multiset<GURL> origins; - for (const history::URLRow& row : deleted_rows) - origins.insert(row.url().GetOrigin()); - - history::HistoryService* hs = HistoryServiceFactory::GetForProfile( - profile_, ServiceAccessType::EXPLICIT_ACCESS); - hs->GetCountsAndLastVisitForOrigins( - std::set<GURL>(origins.begin(), origins.end()), - base::Bind( - &SiteEngagementService::GetCountsAndLastVisitForOriginsComplete, - weak_factory_.GetWeakPtr(), hs, origins, expired)); -} - void SiteEngagementService::SetLastShortcutLaunchTime(const GURL& url) { HostContentSettingsMap* settings_map = HostContentSettingsMapFactory::GetForProfile(profile_); @@ -510,7 +246,7 @@ GetScoreDictForOrigin(settings_map, url); SiteEngagementScore score(clock_.get(), *score_dict); - return score.Score(); + return score.GetScore(); } double SiteEngagementService::GetTotalEngagementPoints() const { @@ -523,74 +259,6 @@ return total_score; } -std::map<GURL, double> SiteEngagementService::GetScoreMap() const { - HostContentSettingsMap* settings_map = - HostContentSettingsMapFactory::GetForProfile(profile_); - std::unique_ptr<ContentSettingsForOneType> engagement_settings = - GetEngagementContentSettings(settings_map); - - std::map<GURL, double> score_map; - for (const auto& site : *engagement_settings) { - GURL origin(site.primary_pattern.ToString()); - if (!origin.is_valid()) - continue; - - std::unique_ptr<base::DictionaryValue> score_dict = - GetScoreDictForOrigin(settings_map, origin); - SiteEngagementScore score(clock_.get(), *score_dict); - score_map[origin] = score.Score(); - } - - return score_map; -} - -bool SiteEngagementService::IsBootstrapped() { - return GetTotalEngagementPoints() >= - SiteEngagementScore::GetBootstrapPoints(); -} - -SiteEngagementService::EngagementLevel -SiteEngagementService::GetEngagementLevel(const GURL& url) const { - DCHECK_LT(SiteEngagementScore::GetMediumEngagementBoundary(), - SiteEngagementScore::GetHighEngagementBoundary()); - double score = GetScore(url); - if (score == 0) - return ENGAGEMENT_LEVEL_NONE; - - if (score < SiteEngagementScore::GetMediumEngagementBoundary()) - return ENGAGEMENT_LEVEL_LOW; - - if (score < SiteEngagementScore::GetHighEngagementBoundary()) - return ENGAGEMENT_LEVEL_MEDIUM; - - if (score < SiteEngagementScore::kMaxPoints) - return ENGAGEMENT_LEVEL_HIGH; - - return ENGAGEMENT_LEVEL_MAX; -} - -bool SiteEngagementService::IsEngagementAtLeast( - const GURL& url, - EngagementLevel level) const { - DCHECK_LT(SiteEngagementScore::GetMediumEngagementBoundary(), - SiteEngagementScore::GetHighEngagementBoundary()); - double score = GetScore(url); - switch (level) { - case ENGAGEMENT_LEVEL_NONE: - return true; - case ENGAGEMENT_LEVEL_LOW: - return score > 0; - case ENGAGEMENT_LEVEL_MEDIUM: - return score >= SiteEngagementScore::GetMediumEngagementBoundary(); - case ENGAGEMENT_LEVEL_HIGH: - return score >= SiteEngagementScore::GetHighEngagementBoundary(); - case ENGAGEMENT_LEVEL_MAX: - return score == SiteEngagementScore::kMaxPoints; - } - NOTREACHED(); - return false; -} - SiteEngagementService::SiteEngagementService(Profile* profile, std::unique_ptr<base::Clock> clock) : profile_(profile), clock_(std::move(clock)), weak_factory_(this) { @@ -633,7 +301,7 @@ std::unique_ptr<base::DictionaryValue> score_dict = GetScoreDictForOrigin(settings_map, origin); SiteEngagementScore score(clock_.get(), *score_dict); - if (score.Score() != 0) + if (score.GetScore() != 0) continue; } @@ -697,6 +365,53 @@ return (scores[mid - 1] + scores[mid]) / 2; } +void SiteEngagementService::HandleMediaPlaying(const GURL& url, + bool is_hidden) { + SiteEngagementMetrics::RecordEngagement( + is_hidden ? SiteEngagementMetrics::ENGAGEMENT_MEDIA_HIDDEN + : SiteEngagementMetrics::ENGAGEMENT_MEDIA_VISIBLE); + AddPoints(url, is_hidden ? SiteEngagementScore::GetHiddenMediaPoints() + : SiteEngagementScore::GetVisibleMediaPoints()); + RecordMetrics(); +} + +void SiteEngagementService::HandleNavigation(const GURL& url, + ui::PageTransition transition) { + if (IsEngagementNavigation(transition)) { + SiteEngagementMetrics::RecordEngagement( + SiteEngagementMetrics::ENGAGEMENT_NAVIGATION); + AddPoints(url, SiteEngagementScore::GetNavigationPoints()); + RecordMetrics(); + } +} + +void SiteEngagementService::HandleUserInput( + const GURL& url, + SiteEngagementMetrics::EngagementType type) { + SiteEngagementMetrics::RecordEngagement(type); + AddPoints(url, SiteEngagementScore::GetUserInputPoints()); + RecordMetrics(); +} + +void SiteEngagementService::OnURLsDeleted( + history::HistoryService* history_service, + bool all_history, + bool expired, + const history::URLRows& deleted_rows, + const std::set<GURL>& favicon_urls) { + std::multiset<GURL> origins; + for (const history::URLRow& row : deleted_rows) + origins.insert(row.url().GetOrigin()); + + history::HistoryService* hs = HistoryServiceFactory::GetForProfile( + profile_, ServiceAccessType::EXPLICIT_ACCESS); + hs->GetCountsAndLastVisitForOrigins( + std::set<GURL>(origins.begin(), origins.end()), + base::Bind( + &SiteEngagementService::GetCountsAndLastVisitForOriginsComplete, + weak_factory_.GetWeakPtr(), hs, origins, expired)); +} + int SiteEngagementService::OriginsWithMaxDailyEngagement() const { HostContentSettingsMap* settings_map = HostContentSettingsMapFactory::GetForProfile(profile_);
diff --git a/chrome/browser/engagement/site_engagement_service.h b/chrome/browser/engagement/site_engagement_service.h index 77a1c5f..1d733322 100644 --- a/chrome/browser/engagement/site_engagement_service.h +++ b/chrome/browser/engagement/site_engagement_service.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ #include <map> +#include <memory> #include <set> #include "base/gtest_prod_util.h" @@ -29,163 +30,6 @@ class GURL; class Profile; -class SiteEngagementScore { - public: - // The parameters which can be varied via field trial. All "points" values - // should be appended to the end of the enum prior to MAX_VARIATION. - enum Variation { - // The maximum number of points that can be accrued in one day. - MAX_POINTS_PER_DAY = 0, - - // The period over which site engagement decays. - DECAY_PERIOD_IN_DAYS, - - // The number of points to decay per period. - DECAY_POINTS, - - // The number of points given for navigations. - NAVIGATION_POINTS, - - // The number of points given for user input. - USER_INPUT_POINTS, - - // The number of points given for media playing. Initially calibrated such - // that at least 30 minutes of foreground media would be required to allow a - // site to reach the daily engagement maximum. - VISIBLE_MEDIA_POINTS, - HIDDEN_MEDIA_POINTS, - - // The number of points added to engagement when a site is launched from - // homescreen or added as a bookmark app. This bonus will apply for ten days - // following a launch; each new launch resets the ten days. - WEB_APP_INSTALLED_POINTS, - - // The number of points given for the first engagement event of the day for - // each site. - FIRST_DAILY_ENGAGEMENT, - - // The number of points that the engagement service must accumulate to be - // considered 'useful'. - BOOTSTRAP_POINTS, - - // The boundaries between low/medium and medium/high engagement as returned - // by GetEngagementLevel(). - MEDIUM_ENGAGEMENT_BOUNDARY, - HIGH_ENGAGEMENT_BOUNDARY, - - MAX_VARIATION - }; - - // The maximum number of points that are allowed. - static const double kMaxPoints; - - static double GetMaxPointsPerDay(); - static double GetDecayPeriodInDays(); - static double GetDecayPoints(); - static double GetNavigationPoints(); - static double GetUserInputPoints(); - static double GetVisibleMediaPoints(); - static double GetHiddenMediaPoints(); - static double GetWebAppInstalledPoints(); - static double GetFirstDailyEngagementPoints(); - static double GetBootstrapPoints(); - static double GetMediumEngagementBoundary(); - static double GetHighEngagementBoundary(); - - // Update the default engagement settings via variations. - static void UpdateFromVariations(); - - // The SiteEngagementService does not take ownership of |clock|. It is the - // responsibility of the caller to make sure |clock| outlives this - // SiteEngagementScore. - SiteEngagementScore(base::Clock* clock, - const base::DictionaryValue& score_dict); - ~SiteEngagementScore(); - - double Score() const; - void AddPoints(double points); - - // Resets the score to |points| and resets the daily point limit. If - // |updated_time| is non-null, sets the last engagement time and last - // shortcut launch time (if it is non-null) to |updated_time|. Otherwise, last - // engagement time is set to the current time and last shortcut launch time is - // left unchanged. - // TODO(calamity): Ideally, all SiteEngagementScore methods should take a - // base::Time argument like this one does rather than each Score hold a - // pointer to a base::Clock. Then SiteEngagementScore doesn't need to worry - // about clock vending. See crbug.com/604305 - void Reset(double points, const base::Time* updated_time); - - // Returns true if the maximum number of points today has been added. - bool MaxPointsPerDayAdded() const; - - // Get/set the last time this origin was launched from an installed shortcut. - base::Time last_shortcut_launch_time() const { - return last_shortcut_launch_time_; - } - void set_last_shortcut_launch_time(const base::Time& time) { - last_shortcut_launch_time_ = time; - } - - // Updates the content settings dictionary |score_dict| with the current score - // fields. Returns true if |score_dict| changed, otherwise return false. - bool UpdateScoreDict(base::DictionaryValue* score_dict); - - private: - FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PartiallyEmptyDictionary); - FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, PopulatedDictionary); - FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, Reset); - FRIEND_TEST_ALL_PREFIXES(SiteEngagementScoreTest, FirstDailyEngagementBonus); - friend class SiteEngagementHelperTest; - friend class SiteEngagementScoreTest; - friend class SiteEngagementServiceTest; - friend class ImportantSitesUtilTest; - - // Array holding the values corresponding to each item in Variation array. - static double param_values[]; - - // Keys used in the content settings dictionary. - static const char* kRawScoreKey; - static const char* kPointsAddedTodayKey; - static const char* kLastEngagementTimeKey; - static const char* kLastShortcutLaunchTimeKey; - - // This version of the constructor is used in unit tests. - explicit SiteEngagementScore(base::Clock* clock); - - // Determine the score, accounting for any decay. - double DecayedScore() const; - - // Determine any score bonus from having installed shortcuts. - double BonusScore() const; - - // Sets fixed parameter values for testing site engagement. Ensure that any - // newly added parameters receive a fixed value here. - static void SetParamValuesForTesting(); - - // The clock used to vend times. Enables time travelling in tests. Owned by - // the SiteEngagementService. - base::Clock* clock_; - - // |raw_score_| is the score before any decay is applied. - double raw_score_; - - // The points added 'today' are tracked to avoid adding more than - // kMaxPointsPerDay on any one day. 'Today' is defined in local time. - double points_added_today_; - - // The last time the score was updated for engagement. Used in conjunction - // with |points_added_today_| to avoid adding more than kMaxPointsPerDay on - // any one day. - base::Time last_engagement_time_; - - // The last time the site with this score was launched from an installed - // shortcut. - base::Time last_shortcut_launch_time_; - - DISALLOW_COPY_AND_ASSIGN(SiteEngagementScore); -}; - class SiteEngagementScoreProvider { public: // Returns a non-negative integer representing the engagement score of the @@ -210,6 +54,10 @@ public history::HistoryServiceObserver, public SiteEngagementScoreProvider { public: + // WebContentsObserver that detects engagement triggering events and notifies + // the service of them. + class Helper; + enum EngagementLevel { ENGAGEMENT_LEVEL_NONE, ENGAGEMENT_LEVEL_LOW, @@ -221,14 +69,23 @@ // The name of the site engagement variation field trial. static const char kEngagementParams[]; + // Returns the site engagement service attached to this profile. May return + // null if the service does not exist (e.g. the user is in incognito). static SiteEngagementService* Get(Profile* profile); - // Returns whether or not the SiteEngagementService is enabled. + // Returns the maximum possible amount of engagement that a site can accrue. + static double GetMaxPoints(); + + // Returns whether or not the site engagement service is enabled. static bool IsEnabled(); explicit SiteEngagementService(Profile* profile); ~SiteEngagementService() override; + // Returns the engagement level of |url|. This is the recommended API for + // clients + EngagementLevel GetEngagementLevel(const GURL& url) const; + // Returns a map of all stored origins and their engagement scores. std::map<GURL, double> GetScoreMap() const; @@ -237,41 +94,17 @@ // this is true. bool IsBootstrapped(); - // Returns the engagement level of |url|. This is the recommended API for - // clients - EngagementLevel GetEngagementLevel(const GURL& url) const; - // Returns whether |url| has at least the given |level| of engagement. bool IsEngagementAtLeast(const GURL& url, EngagementLevel level) const; - // Update the engagement score of the origin matching |url| for navigation. - void HandleNavigation(const GURL& url, ui::PageTransition transition); - - // Update the engagement score of the origin matching |url| for time-on-site, - // based on user input. - void HandleUserInput(const GURL& url, - SiteEngagementMetrics::EngagementType type); - - // Update the engagement score of the origin matching |url| for media playing. - // The points awarded are discounted if the media is being played in a non- - // visible tab. - void HandleMediaPlaying(const GURL& url, bool is_hidden); - // Resets the engagement score |url| to |score|, clearing daily limits. void ResetScoreForURL(const GURL& url, double score); - // Overridden from history::HistoryServiceObserver: - void OnURLsDeleted(history::HistoryService* history_service, - bool all_history, - bool expired, - const history::URLRows& deleted_rows, - const std::set<GURL>& favicon_urls) override; - // Update the last time |url| was opened from an installed shortcut to be // clock_->Now(). void SetLastShortcutLaunchTime(const GURL& url); - // Overridden from SiteEngagementScoreProvider: + // Overridden from SiteEngagementScoreProvider. double GetScore(const GURL& url) const override; double GetTotalEngagementPoints() const override; @@ -289,7 +122,6 @@ FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, EngagementLevel); FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, ScoreDecayHistograms); FRIEND_TEST_ALL_PREFIXES(AppBannerSettingsHelperTest, SiteEngagementTrigger); - FRIEND_TEST_ALL_PREFIXES(ImportantSitesUtilTest, NotificationsThenEngagement); // Only used in tests. SiteEngagementService(Profile* profile, std::unique_ptr<base::Clock> clock); @@ -307,11 +139,33 @@ // Returns the median engagement score of all recorded origins. double GetMedianEngagement(const std::map<GURL, double>& score_map) const; + // Update the engagement score of the origin matching |url| for media playing. + // The points awarded are discounted if the media is being played in a non- + // visible tab. + void HandleMediaPlaying(const GURL& url, bool is_hidden); + + // Update the engagement score of the origin matching |url| for navigation. + void HandleNavigation(const GURL& url, ui::PageTransition transition); + + // Update the engagement score of the origin matching |url| for time-on-site, + // based on user input. + void HandleUserInput(const GURL& url, + SiteEngagementMetrics::EngagementType type); + + // Overridden from history::HistoryServiceObserver: + void OnURLsDeleted(history::HistoryService* history_service, + bool all_history, + bool expired, + const history::URLRows& deleted_rows, + const std::set<GURL>& favicon_urls) override; + // Returns the number of origins with maximum daily and total engagement // respectively. int OriginsWithMaxDailyEngagement() const; int OriginsWithMaxEngagement(const std::map<GURL, double>& score_map) const; + // Callback for the history service when it is asked for a map of origins to + // how many URLs corresponding to that origin remain in history. void GetCountsAndLastVisitForOriginsComplete( history::HistoryService* history_service, const std::multiset<GURL>& deleted_url_origins,
diff --git a/chrome/browser/engagement/site_engagement_service_unittest.cc b/chrome/browser/engagement/site_engagement_service_unittest.cc index f88fbf1e..e43d6d6 100644 --- a/chrome/browser/engagement/site_engagement_service_unittest.cc +++ b/chrome/browser/engagement/site_engagement_service_unittest.cc
@@ -16,7 +16,7 @@ #include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/engagement/site_engagement_helper.h" #include "chrome/browser/engagement/site_engagement_metrics.h" -#include "chrome/browser/engagement/site_engagement_service_factory.h" +#include "chrome/browser/engagement/site_engagement_score.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" @@ -37,10 +37,7 @@ base::FilePath g_temp_history_dir; -const int kLessAccumulationsThanNeededToMaxDailyEngagement = 2; const int kMoreAccumulationsThanNeededToMaxDailyEngagement = 40; -const int kMoreAccumulationsThanNeededToMaxTotalEngagement = 200; -const int kLessDaysThanNeededToMaxTotalEngagement = 4; const int kMoreDaysThanNeededToMaxTotalEngagement = 40; const int kLessPeriodsThanNeededToDecayMaxScore = 2; const int kMorePeriodsThanNeededToDecayMaxScore = 40; @@ -52,8 +49,8 @@ HostContentSettingsMapFactory::GetForProfile(profile)->AddObserver(this); } ~SiteEngagementChangeWaiter() override { - HostContentSettingsMapFactory::GetForProfile(profile_) - ->RemoveObserver(this); + HostContentSettingsMapFactory::GetForProfile(profile_)->RemoveObserver( + this); } // Overridden from content_settings::Observer: @@ -100,378 +97,6 @@ } // namespace -class SiteEngagementScoreTest : public testing::Test { - public: - SiteEngagementScoreTest() : score_(&test_clock_) {} - - void SetUp() override { - testing::Test::SetUp(); - // Disable the first engagement bonus for tests. - SiteEngagementScore::SetParamValuesForTesting(); - } - - protected: - void VerifyScore(const SiteEngagementScore& score, - double expected_raw_score, - double expected_points_added_today, - base::Time expected_last_engagement_time) { - EXPECT_EQ(expected_raw_score, score.raw_score_); - EXPECT_EQ(expected_points_added_today, score.points_added_today_); - EXPECT_EQ(expected_last_engagement_time, score.last_engagement_time_); - } - - void UpdateScore(SiteEngagementScore* score, - double raw_score, - double points_added_today, - base::Time last_engagement_time) { - score->raw_score_ = raw_score; - score->points_added_today_ = points_added_today; - score->last_engagement_time_ = last_engagement_time; - } - - void TestScoreInitializesAndUpdates( - base::DictionaryValue* score_dict, - double expected_raw_score, - double expected_points_added_today, - base::Time expected_last_engagement_time) { - SiteEngagementScore initial_score(&test_clock_, *score_dict); - VerifyScore(initial_score, expected_raw_score, expected_points_added_today, - expected_last_engagement_time); - - // Updating the score dict should return false, as the score shouldn't - // have changed at this point. - EXPECT_FALSE(initial_score.UpdateScoreDict(score_dict)); - - // Update the score to new values and verify it updates the score dict - // correctly. - base::Time different_day = - GetReferenceTime() + base::TimeDelta::FromDays(1); - UpdateScore(&initial_score, 5, 10, different_day); - EXPECT_TRUE(initial_score.UpdateScoreDict(score_dict)); - SiteEngagementScore updated_score(&test_clock_, *score_dict); - VerifyScore(updated_score, 5, 10, different_day); - } - - void SetFirstDailyEngagementPointsForTesting(double points) { - SiteEngagementScore::param_values - [SiteEngagementScore::FIRST_DAILY_ENGAGEMENT] = points; - } - - base::SimpleTestClock test_clock_; - SiteEngagementScore score_; -}; - -// Accumulate score many times on the same day. Ensure each time the score goes -// up, but not more than the maximum per day. -TEST_F(SiteEngagementScoreTest, AccumulateOnSameDay) { - base::Time reference_time = GetReferenceTime(); - - test_clock_.SetNow(reference_time); - for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { - score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); - EXPECT_EQ(std::min(SiteEngagementScore::GetMaxPointsPerDay(), - (i + 1) * SiteEngagementScore::GetNavigationPoints()), - score_.Score()); - } - - EXPECT_EQ(SiteEngagementScore::GetMaxPointsPerDay(), score_.Score()); -} - -// Accumulate on the first day to max that day's engagement, then accumulate on -// a different day. -TEST_F(SiteEngagementScoreTest, AccumulateOnTwoDays) { - base::Time reference_time = GetReferenceTime(); - base::Time later_date = reference_time + base::TimeDelta::FromDays(2); - - test_clock_.SetNow(reference_time); - for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) - score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); - - EXPECT_EQ(SiteEngagementScore::GetMaxPointsPerDay(), score_.Score()); - - test_clock_.SetNow(later_date); - for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { - score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); - double day_score = - std::min(SiteEngagementScore::GetMaxPointsPerDay(), - (i + 1) * SiteEngagementScore::GetNavigationPoints()); - EXPECT_EQ(day_score + SiteEngagementScore::GetMaxPointsPerDay(), - score_.Score()); - } - - EXPECT_EQ(2 * SiteEngagementScore::GetMaxPointsPerDay(), score_.Score()); -} - -// Accumulate score on many consecutive days and ensure the score doesn't exceed -// the maximum allowed. -TEST_F(SiteEngagementScoreTest, AccumulateALotOnManyDays) { - base::Time current_day = GetReferenceTime(); - - for (int i = 0; i < kMoreDaysThanNeededToMaxTotalEngagement; ++i) { - current_day += base::TimeDelta::FromDays(1); - test_clock_.SetNow(current_day); - for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) - score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); - - EXPECT_EQ(std::min(SiteEngagementScore::kMaxPoints, - (i + 1) * SiteEngagementScore::GetMaxPointsPerDay()), - score_.Score()); - } - - EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); -} - -// Accumulate a little on many consecutive days and ensure the score doesn't -// exceed the maximum allowed. -TEST_F(SiteEngagementScoreTest, AccumulateALittleOnManyDays) { - base::Time current_day = GetReferenceTime(); - - for (int i = 0; i < kMoreAccumulationsThanNeededToMaxTotalEngagement; ++i) { - current_day += base::TimeDelta::FromDays(1); - test_clock_.SetNow(current_day); - - for (int j = 0; j < kLessAccumulationsThanNeededToMaxDailyEngagement; ++j) - score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); - - EXPECT_EQ( - std::min(SiteEngagementScore::kMaxPoints, - (i + 1) * kLessAccumulationsThanNeededToMaxDailyEngagement * - SiteEngagementScore::GetNavigationPoints()), - score_.Score()); - } - - EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); -} - -// Accumulate a bit, then check the score decays properly for a range of times. -TEST_F(SiteEngagementScoreTest, ScoresDecayOverTime) { - base::Time current_day = GetReferenceTime(); - - // First max the score. - for (int i = 0; i < kMoreDaysThanNeededToMaxTotalEngagement; ++i) { - current_day += base::TimeDelta::FromDays(1); - test_clock_.SetNow(current_day); - - for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) - score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); - } - - EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); - - // The score should not have decayed before the first decay period has - // elapsed. - test_clock_.SetNow(current_day + - base::TimeDelta::FromDays( - SiteEngagementScore::GetDecayPeriodInDays() - 1)); - EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); - - // The score should have decayed by one chunk after one decay period has - // elapsed. - test_clock_.SetNow( - current_day + - base::TimeDelta::FromDays(SiteEngagementScore::GetDecayPeriodInDays())); - EXPECT_EQ( - SiteEngagementScore::kMaxPoints - SiteEngagementScore::GetDecayPoints(), - score_.Score()); - - // The score should have decayed by the right number of chunks after a few - // decay periods have elapsed. - test_clock_.SetNow( - current_day + - base::TimeDelta::FromDays(kLessPeriodsThanNeededToDecayMaxScore * - SiteEngagementScore::GetDecayPeriodInDays())); - EXPECT_EQ(SiteEngagementScore::kMaxPoints - - kLessPeriodsThanNeededToDecayMaxScore * - SiteEngagementScore::GetDecayPoints(), - score_.Score()); - - // The score should not decay below zero. - test_clock_.SetNow( - current_day + - base::TimeDelta::FromDays(kMorePeriodsThanNeededToDecayMaxScore * - SiteEngagementScore::GetDecayPeriodInDays())); - EXPECT_EQ(0, score_.Score()); -} - -// Test that any expected decays are applied before adding points. -TEST_F(SiteEngagementScoreTest, DecaysAppliedBeforeAdd) { - base::Time current_day = GetReferenceTime(); - - // Get the score up to something that can handle a bit of decay before - for (int i = 0; i < kLessDaysThanNeededToMaxTotalEngagement; ++i) { - current_day += base::TimeDelta::FromDays(1); - test_clock_.SetNow(current_day); - - for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) - score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); - } - - double initial_score = kLessDaysThanNeededToMaxTotalEngagement * - SiteEngagementScore::GetMaxPointsPerDay(); - EXPECT_EQ(initial_score, score_.Score()); - - // Go forward a few decay periods. - test_clock_.SetNow( - current_day + - base::TimeDelta::FromDays(kLessPeriodsThanNeededToDecayMaxScore * - SiteEngagementScore::GetDecayPeriodInDays())); - - double decayed_score = initial_score - - kLessPeriodsThanNeededToDecayMaxScore * - SiteEngagementScore::GetDecayPoints(); - EXPECT_EQ(decayed_score, score_.Score()); - - // Now add some points. - score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); - EXPECT_EQ(decayed_score + SiteEngagementScore::GetNavigationPoints(), - score_.Score()); -} - -// Test that going back in time is handled properly. -TEST_F(SiteEngagementScoreTest, GoBackInTime) { - base::Time current_day = GetReferenceTime(); - - test_clock_.SetNow(current_day); - for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) - score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); - - EXPECT_EQ(SiteEngagementScore::GetMaxPointsPerDay(), score_.Score()); - - // Adding to the score on an earlier date should be treated like another day, - // and should not cause any decay. - test_clock_.SetNow(current_day - base::TimeDelta::FromDays( - kMorePeriodsThanNeededToDecayMaxScore * - SiteEngagementScore::GetDecayPoints())); - for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { - score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); - double day_score = - std::min(SiteEngagementScore::GetMaxPointsPerDay(), - (i + 1) * SiteEngagementScore::GetNavigationPoints()); - EXPECT_EQ(day_score + SiteEngagementScore::GetMaxPointsPerDay(), - score_.Score()); - } - - EXPECT_EQ(2 * SiteEngagementScore::GetMaxPointsPerDay(), score_.Score()); -} - -// Test that scores are read / written correctly from / to empty score -// dictionaries. -TEST_F(SiteEngagementScoreTest, EmptyDictionary) { - base::DictionaryValue dict; - TestScoreInitializesAndUpdates(&dict, 0, 0, base::Time()); -} - -// Test that scores are read / written correctly from / to partially empty -// score dictionaries. -TEST_F(SiteEngagementScoreTest, PartiallyEmptyDictionary) { - base::DictionaryValue dict; - dict.SetDouble(SiteEngagementScore::kPointsAddedTodayKey, 2); - - TestScoreInitializesAndUpdates(&dict, 0, 2, base::Time()); -} - -// Test that scores are read / written correctly from / to populated score -// dictionaries. -TEST_F(SiteEngagementScoreTest, PopulatedDictionary) { - base::DictionaryValue dict; - dict.SetDouble(SiteEngagementScore::kRawScoreKey, 1); - dict.SetDouble(SiteEngagementScore::kPointsAddedTodayKey, 2); - dict.SetDouble(SiteEngagementScore::kLastEngagementTimeKey, - GetReferenceTime().ToInternalValue()); - - TestScoreInitializesAndUpdates(&dict, 1, 2, GetReferenceTime()); -} - -// Ensure bonus engagement is awarded for the first engagement of a day. -TEST_F(SiteEngagementScoreTest, FirstDailyEngagementBonus) { - SetFirstDailyEngagementPointsForTesting(0.5); - - SiteEngagementScore score1(&test_clock_); - SiteEngagementScore score2(&test_clock_); - base::Time current_day = GetReferenceTime(); - - test_clock_.SetNow(current_day); - - // The first engagement event gets the bonus. - score1.AddPoints(0.5); - EXPECT_EQ(1.0, score1.Score()); - - // Subsequent events do not. - score1.AddPoints(0.5); - EXPECT_EQ(1.5, score1.Score()); - - // Bonuses are awarded independently between scores. - score2.AddPoints(1.0); - EXPECT_EQ(1.5, score2.Score()); - score2.AddPoints(1.0); - EXPECT_EQ(2.5, score2.Score()); - - test_clock_.SetNow(current_day + base::TimeDelta::FromDays(1)); - - // The first event for the next day gets the bonus. - score1.AddPoints(0.5); - EXPECT_EQ(2.5, score1.Score()); - - // Subsequent events do not. - score1.AddPoints(0.5); - EXPECT_EQ(3.0, score1.Score()); - - score2.AddPoints(1.0); - EXPECT_EQ(4.0, score2.Score()); - score2.AddPoints(1.0); - EXPECT_EQ(5.0, score2.Score()); -} - -// Test that resetting a score has the correct properties. -TEST_F(SiteEngagementScoreTest, Reset) { - base::Time current_day = GetReferenceTime(); - - test_clock_.SetNow(current_day); - score_.AddPoints(SiteEngagementScore::GetNavigationPoints()); - EXPECT_EQ(SiteEngagementScore::GetNavigationPoints(), score_.Score()); - - current_day += base::TimeDelta::FromDays(7); - test_clock_.SetNow(current_day); - - score_.Reset(20.0, nullptr); - EXPECT_DOUBLE_EQ(20.0, score_.Score()); - EXPECT_DOUBLE_EQ(0, score_.points_added_today_); - EXPECT_EQ(current_day, score_.last_engagement_time_); - EXPECT_TRUE(score_.last_shortcut_launch_time_.is_null()); - - // Adding points after the reset should work as normal. - score_.AddPoints(5); - EXPECT_EQ(25.0, score_.Score()); - - // The decay should happen one decay period from the current time. - test_clock_.SetNow(current_day + - base::TimeDelta::FromDays( - SiteEngagementScore::GetDecayPeriodInDays() + 1)); - EXPECT_EQ(25.0 - SiteEngagementScore::GetDecayPoints(), score_.Score()); - - // Ensure that manually setting a time works as expected. - score_.AddPoints(5); - test_clock_.SetNow(GetReferenceTime()); - base::Time now = test_clock_.Now(); - score_.Reset(10.0, &now); - - EXPECT_DOUBLE_EQ(10.0, score_.Score()); - EXPECT_DOUBLE_EQ(0, score_.points_added_today_); - EXPECT_EQ(now, score_.last_engagement_time_); - EXPECT_TRUE(score_.last_shortcut_launch_time_.is_null()); - - score_.set_last_shortcut_launch_time(test_clock_.Now()); - test_clock_.SetNow(GetReferenceTime() + base::TimeDelta::FromDays(3)); - now = test_clock_.Now(); - score_.Reset(15.0, &now); - - // 5 bonus from the last shortcut launch. - EXPECT_DOUBLE_EQ(20.0, score_.Score()); - EXPECT_DOUBLE_EQ(0, score_.points_added_today_); - EXPECT_EQ(now, score_.last_engagement_time_); - EXPECT_EQ(now, score_.last_shortcut_launch_time_); -} - class SiteEngagementServiceTest : public ChromeRenderViewHostTestHarness { public: void SetUp() override { @@ -514,8 +139,7 @@ }; TEST_F(SiteEngagementServiceTest, GetMedianEngagement) { - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService* service = SiteEngagementService::Get(profile()); ASSERT_TRUE(service); GURL url1("http://www.google.com/"); @@ -581,12 +205,11 @@ // by performing two navigations and checking the engagement score increases // both times. TEST_F(SiteEngagementServiceTest, ScoreIncrementsOnPageRequest) { - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService* service = SiteEngagementService::Get(profile()); ASSERT_TRUE(service); // Create the helper manually since it isn't present when a tab isn't created. - SiteEngagementHelper::CreateForWebContents(web_contents()); + SiteEngagementService::Helper::CreateForWebContents(web_contents()); GURL url("http://www.google.com/"); EXPECT_EQ(0, service->GetScore(url)); @@ -599,8 +222,7 @@ // Expect that site engagement scores for several sites are correctly // aggregated during navigation events. TEST_F(SiteEngagementServiceTest, GetTotalNavigationPoints) { - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService* service = SiteEngagementService::Get(profile()); ASSERT_TRUE(service); // The https and http versions of www.google.com should be separate. @@ -636,8 +258,7 @@ } TEST_F(SiteEngagementServiceTest, GetTotalUserInputPoints) { - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService* service = SiteEngagementService::Get(profile()); ASSERT_TRUE(service); // The https and http versions of www.google.com should be separate. @@ -709,8 +330,8 @@ histograms.ExpectTotalCount( SiteEngagementMetrics::kDaysSinceLastShortcutLaunchHistogram, 1); - histograms.ExpectTotalCount( - SiteEngagementMetrics::kEngagementTypeHistogram, 4); + histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram, + 4); histograms.ExpectBucketCount( SiteEngagementMetrics::kEngagementTypeHistogram, SiteEngagementMetrics::ENGAGEMENT_WEBAPP_SHORTCUT_LAUNCH, 2); @@ -1083,12 +704,11 @@ TEST_F(SiteEngagementServiceTest, NavigationAccumulation) { GURL url("https://www.google.com/"); - SiteEngagementService* service = - SiteEngagementServiceFactory::GetForProfile(profile()); + SiteEngagementService* service = SiteEngagementService::Get(profile()); ASSERT_TRUE(service); // Create the helper manually since it isn't present when a tab isn't created. - SiteEngagementHelper::CreateForWebContents(web_contents()); + SiteEngagementService::Helper::CreateForWebContents(web_contents()); // Only direct navigation should trigger engagement. NavigateWithTransitionAndExpectHigherScore(service, url,
diff --git a/chrome/browser/push_messaging/background_budget_service.cc b/chrome/browser/push_messaging/background_budget_service.cc index 5963bc2..f6f4931 100644 --- a/chrome/browser/push_messaging/background_budget_service.cc +++ b/chrome/browser/push_messaging/background_budget_service.cc
@@ -142,7 +142,7 @@ void BackgroundBudgetService::StoreBudget(const GURL& origin, double budget) { DCHECK_EQ(origin, origin.GetOrigin()); DCHECK_GE(budget, 0.0); - DCHECK_LE(budget, SiteEngagementScore::kMaxPoints); + DCHECK_LE(budget, SiteEngagementService::GetMaxPoints()); // Get the current SES score to write into the prefs with the new budget. SiteEngagementService* service = SiteEngagementService::Get(profile_);
diff --git a/chrome/browser/resources/component_extension_resources.grd b/chrome/browser/resources/component_extension_resources.grd index 6a84d8e..fe834dd 100644 --- a/chrome/browser/resources/component_extension_resources.grd +++ b/chrome/browser/resources/component_extension_resources.grd
@@ -170,6 +170,7 @@ <include name="IDR_PDF_CONTENT_SCRIPT_JS" file="pdf/content_script.js" type="BINDATA" /> <include name="IDR_PDF_SHARED_ICON_STYLE_CSS" file="pdf/elements/shared-icon-style.css" type="BINDATA" /> + <include name="IDR_PDF_ICONS_HTML" file="pdf/elements/icons.html" type="BINDATA" /> <include name="IDR_PDF_VIEWER_BOOKMARK_CSS" file="pdf/elements/viewer-bookmark/viewer-bookmark.css" type="BINDATA" /> <include name="IDR_PDF_VIEWER_BOOKMARK_HTML" file="pdf/elements/viewer-bookmark/viewer-bookmark.html" type="BINDATA" /> <include name="IDR_PDF_VIEWER_BOOKMARK_JS" file="pdf/elements/viewer-bookmark/viewer-bookmark.js" type="BINDATA" />
diff --git a/chrome/browser/resources/md_history/app.html b/chrome/browser/resources/md_history/app.html index f824579..3f42a73 100644 --- a/chrome/browser/resources/md_history/app.html +++ b/chrome/browser/resources/md_history/app.html
@@ -24,10 +24,6 @@ overflow: hidden; } - #toolbar { - flex: 0 0 56px; - } - history-list, #history-synced-device-manager { flex: 1 0 0; @@ -42,7 +38,7 @@ background: var(--md-toolbar-color); } </style> - <history-toolbar class="paper-header" id="toolbar"></history-toolbar> + <history-toolbar id="toolbar"></history-toolbar> <div id="main-container"> <history-side-bar id="history-side-bar" selected-page="{{selectedPage}}">
diff --git a/chrome/browser/resources/md_history/app.js b/chrome/browser/resources/md_history/app.js index 61a0be6..98a5f64 100644 --- a/chrome/browser/resources/md_history/app.js +++ b/chrome/browser/resources/md_history/app.js
@@ -21,6 +21,10 @@ 'search-changed': 'searchChanged', }, + ready: function() { + this.$.toolbar.isGroupedMode = loadTimeData.getBoolean('groupByDomain'); + }, + /** * Listens for history-item being selected or deselected (through checkbox) * and changes the view of the top toolbar. @@ -79,6 +83,10 @@ /** @type {HistoryToolbarElement} */(this.$.toolbar).searching = false; if (info.finished) list.disableResultLoading(); + + var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); + toolbar.queryStartTime = info.queryStartTime; + toolbar.queryEndTime = info.queryEndTime; }, /**
diff --git a/chrome/browser/resources/md_history/compiled_resources2.gyp b/chrome/browser/resources/md_history/compiled_resources2.gyp index 4b6503f..bc683df 100644 --- a/chrome/browser/resources/md_history/compiled_resources2.gyp +++ b/chrome/browser/resources/md_history/compiled_resources2.gyp
@@ -44,6 +44,7 @@ 'dependencies': [ '<(DEPTH)/ui/webui/resources/cr_elements/cr_search_field/compiled_resources2.gyp:cr_search_field', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util', ], 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'], },
diff --git a/chrome/browser/resources/md_history/history_toolbar.html b/chrome/browser/resources/md_history/history_toolbar.html index 3830193..2544856 100644 --- a/chrome/browser/resources/md_history/history_toolbar.html +++ b/chrome/browser/resources/md_history/history_toolbar.html
@@ -3,7 +3,10 @@ <link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button.html"> +<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/hardware-icons.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner.html"> +<link rel="import" href="chrome://resources/polymer/v1_0/paper-tabs/paper-tab.html"> +<link rel="import" href="chrome://resources/polymer/v1_0/paper-tabs/paper-tabs.html"> <link rel="import" href="chrome://resources/cr_elements/cr_search_field/cr_search_field.html"> <link rel="import" href="chrome://history/shared_style.html"> @@ -12,11 +15,10 @@ <style include="shared-style"> :host { color: #fff; - height: 56px; transition: background-color 150ms; + width: 100%; } - :host, #overlay-buttons, #overlay-wrapper, #main-content, @@ -38,6 +40,10 @@ font-weight: 400; } + #toolbar-container { + height: 56px; + } + #right-content { flex: 1 0 0; } @@ -84,7 +90,7 @@ @apply(--layout-flex); } - paper-icon-button { + #cancel-icon-button { -webkit-margin-end: 24px; -webkit-margin-start: 2px; height: 36px; @@ -92,8 +98,60 @@ width: 36px; } - paper-button { - pointer-events: auto; + #grouped-nav-container paper-icon-button { + --paper-icon-button-ink-color: rgba(255, 255, 255, 0.4); + -webkit-margin-start: 24px; + flex: 0 0 auto; + } + + paper-tab { + --paper-tab-ink: rgba(255, 255, 255, 0.4); + font-size: 13px; + text-transform: uppercase; + } + + paper-tabs { + --paper-tabs-selection-bar-color: var(--google-blue-500); + height: 45px; + min-width: 300px; + } + + #grouped-buttons-container { + @apply(--layout-center); + @apply(--layout-horizontal); + -webkit-margin-start: var(--side-bar-width); + } + + #grouped-range-buttons { + -webkit-margin-start: 32px; + } + + #grouped-nav-container { + @apply(--layout-center); + @apply(--layout-end-justified); + @apply(--layout-flex); + @apply(--layout-horizontal); + -webkit-margin-end: 24px; + overflow: hidden; + transition: opacity 150ms; + } + + :host([grouped-range=0]) #grouped-nav-container { + opacity: 0; + pointer-events: none; + } + + #grouped-date { + flex: 0 1 auto; + opacity: 0.7; + overflow: hidden; + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; + } + + :host-context([dir=rtl]) .rtl-reversible { + transform: rotate(180deg); } </style> <div id="toolbar-container"> @@ -126,6 +184,29 @@ </div> </div> </div> + <template is="dom-if" if="[[isGroupedMode]]"> + <div id="grouped-buttons-container"> + <paper-tabs attr-for-selected="value" selected="{{groupedRange}}" + id="grouped-range-buttons"> + <paper-tab value="0">$i18n{rangeAllTime}</paper-tab> + <paper-tab value="1">$i18n{rangeWeek}</paper-tab> + <paper-tab value="2">$i18n{rangeMonth}</paper-tab> + </paper-tabs> + <div id="grouped-nav-container"> + <span id="grouped-date"> + {{getHistoryInterval_(queryStartTime, queryEndTime)}} + </span> + <paper-icon-button icon="today" alt="$i18n{rangeToday}" + title="$i18n{rangeToday}"></paper-icon-button> + <paper-icon-button icon="hardware:keyboard-arrow-left" + alt="$i18n{rangePrevious}" title="$i18n{rangePrevious}" + class="rtl-reversible"></paper-icon-button> + <paper-icon-button icon="hardware:keyboard-arrow-right" + alt="$i18n{rangeNext}" title="$i18n{rangeNext}" + class="rtl-reversible"></paper-icon-button> + </div> + </div> + </template> </template> <script src="chrome://history/history_toolbar.js"></script> </dom-module>
diff --git a/chrome/browser/resources/md_history/history_toolbar.js b/chrome/browser/resources/md_history/history_toolbar.js index db33f9c..d534186 100644 --- a/chrome/browser/resources/md_history/history_toolbar.js +++ b/chrome/browser/resources/md_history/history_toolbar.js
@@ -43,11 +43,30 @@ value: '' }, - // True if it's searching at the backend. + // True if waiting on the search backend. searching: { type: Boolean, value: false }, + + // Whether domain-grouped history is enabled. + isGroupedMode: { + type: Boolean, + reflectToAttribute: true, + }, + + // The period to search over. Matches BrowsingHistoryHandler::Range. + groupedRange: { + type: Number, + value: 0, + reflectToAttribute: true + }, + + // The start time of the query range. + queryStartTime: String, + + // The end time of the query range. + queryEndTime: String, }, /** @@ -108,5 +127,11 @@ numberOfItemsSelected_: function(count) { return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; + }, + + getHistoryInterval_: function(queryStartTime, queryEndTime) { + // TODO(calamity): Fix the format of these dates. + return loadTimeData.getStringF( + 'historyInterval', queryStartTime, queryEndTime); } });
diff --git a/chrome/browser/resources/pdf/elements/icons.html b/chrome/browser/resources/pdf/elements/icons.html new file mode 100644 index 0000000..a458cb5 --- /dev/null +++ b/chrome/browser/resources/pdf/elements/icons.html
@@ -0,0 +1,20 @@ +<link rel="import" href="chrome://resources/html/polymer.html"> +<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html"> + +<iron-iconset-svg size="24" name="pdf"> + <svg> + <defs> + <!-- + These icons are from iron-icons in third_party/polymer, but were curated + here via the following URL and then sorted: + https://poly-icon.appspot.com/?name=pdf&size=24&icon=icons:add&icon=icons:bookmark&icon=icons:bookmark-border&icon=icons:fullscreen-exit&icon=icons:remove&icon=image:rotate-right + --> + <g id="add"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"></path></g> + <g id="bookmark"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2z"></path></g> + <g id="bookmark-border"><path d="M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2zm0 15l-5-2.18L7 18V5h10v13z"></path></g> + <g id="fullscreen-exit"><path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"></path></g> + <g id="remove"><path d="M19 13H5v-2h14v2z"></path></g> + <g id="rotate-right"><path d="M15.55 5.55L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45zM19.93 11c-.17-1.39-.72-2.73-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47h2.02zM13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03zm3.89-2.42l1.42 1.41c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.48z"></path></g> + </defs> + </svg> +</iron-iconset-svg>
diff --git a/chrome/browser/resources/pdf/elements/viewer-bookmark/viewer-bookmark.html b/chrome/browser/resources/pdf/elements/viewer-bookmark/viewer-bookmark.html index 008eef63..8195f0e 100644 --- a/chrome/browser/resources/pdf/elements/viewer-bookmark/viewer-bookmark.html +++ b/chrome/browser/resources/pdf/elements/viewer-bookmark/viewer-bookmark.html
@@ -1,13 +1,14 @@ <link rel="import" href="chrome://resources/polymer/v1_0/polymer/polymer.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-ripple/paper-ripple.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/paper-styles.html"> +<link rel="import" href="chrome://resources/cr_elements/icons.html"> <dom-module id="viewer-bookmark" attributes="bookmark"> <link rel="import" type="css" href="viewer-bookmark.css"> <template> <div id="item" on-click="onClick"> <paper-ripple></paper-ripple> - <paper-icon-button id="expand" icon="chevron-right" + <paper-icon-button id="expand" icon="cr:chevron-right" on-click="toggleChildren"> </paper-icon-button> <span id="title" tabindex="0">{{bookmark.title}}</span>
diff --git a/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html b/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html index dfe225d..63024e0 100644 --- a/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html +++ b/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html
@@ -1,13 +1,13 @@ <link rel="import" href="chrome://resources/polymer/v1_0/polymer/polymer.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/image-icons.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/iron-icons.html"> <link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/animations/slide-up-animation.html"> <link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/animations/transform-animation.html"> <link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animation-runner-behavior.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-progress/paper-progress.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-toolbar/paper-toolbar.html"> +<link rel="import" href="chrome://resources/cr_elements/icons.html"> +<link rel="import" href="../icons.html"> <link rel="import" href="../viewer-bookmarks-content/viewer-bookmarks-content.html"> <link rel="import" href="../viewer-page-selector/viewer-page-selector.html"> <link rel="import" href="../viewer-toolbar-dropdown/viewer-toolbar-dropdown.html"> @@ -30,25 +30,25 @@ </div> <div id="buttons" class="invisible"> - <paper-icon-button id="rotate-right" icon="image:rotate-right" + <paper-icon-button id="rotate-right" icon="pdf:rotate-right" on-click="rotateRight" i18n-values="aria-label:tooltipRotateCW;title:tooltipRotateCW"> </paper-icon-button> - <paper-icon-button id="download" icon="file-download" + <paper-icon-button id="download" icon="cr:file-download" on-click="download" i18n-values="aria-label:tooltipDownload;title:tooltipDownload"> </paper-icon-button> - <paper-icon-button id="print" icon="print" + <paper-icon-button id="print" icon="cr:print" on-click="print" i18n-values="aria-label:tooltipPrint;title:tooltipPrint"> </paper-icon-button> <viewer-toolbar-dropdown id="bookmarks" hidden$="[[!bookmarks.length]]" - open-icon="bookmark" - closed-icon="bookmark-border" + open-icon="pdf:bookmark" + closed-icon="pdf:bookmark-border" i18n-values="header:bookmarks"> <viewer-bookmarks-content bookmarks="{{bookmarks}}"> </viewer-bookmarks-content>
diff --git a/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.html b/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.html index d07bfc82..a2c9359f 100644 --- a/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.html +++ b/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.html
@@ -2,6 +2,7 @@ <link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/web-animations.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-material/paper-material.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button.html"> +<link rel="import" href="chrome://resources/cr_elements/icons.html"> <dom-module id="viewer-toolbar-dropdown"> <link rel="import" type="css" href="../shared-icon-style.css"> @@ -11,7 +12,7 @@ <paper-icon-button id="main-icon" icon="[[dropdownIcon]]" aria-label="{{header}}" title="{{header}}"> </paper-icon-button> - <iron-icon icon="arrow-drop-down" id="arrow"></iron-icon> + <iron-icon icon="cr:arrow-drop-down" id="arrow"></iron-icon> </div> <div id="container">
diff --git a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.html b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.html index fbc51b5..a1dfb54 100644 --- a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.html +++ b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-button.html
@@ -1,5 +1,4 @@ <link rel="import" href="chrome://resources/polymer/v1_0/polymer/polymer.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/iron-icons.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-fab/paper-fab.html"> <dom-module id="viewer-zoom-button">
diff --git a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html index b1ee0d99..94dcd3b 100644 --- a/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html +++ b/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html
@@ -1,5 +1,6 @@ <link rel="import" href="chrome://resources/polymer/v1_0/polymer/polymer.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/iron-icons.html"> +<link rel="import" href="chrome://resources/cr_elements/icons.html"> +<link rel="import" href="../icons.html"> <link rel="import" href="viewer-zoom-button.html"> <dom-module id="viewer-zoom-toolbar"> @@ -7,12 +8,12 @@ <template> <div id="zoom-buttons"> - <viewer-zoom-button id="fit-button" icons="fullscreen-exit fullscreen" - on-fabclick="fitToggle" delay="100"> + <viewer-zoom-button id="fit-button" on-fabclick="fitToggle" delay="100" + icons="pdf:fullscreen-exit cr:fullscreen"> </viewer-zoom-button> - <viewer-zoom-button id="zoom-in-button" icons="add" + <viewer-zoom-button id="zoom-in-button" icons="pdf:add" on-fabclick="zoomIn" delay="50"></viewer-zoom-button> - <viewer-zoom-button id="zoom-out-button" icons="remove" + <viewer-zoom-button id="zoom-out-button" icons="pdf:remove" on-fabclick="zoomOut" delay="0"></viewer-zoom-button> </div> </template>
diff --git a/chrome/browser/resources/settings/icons.html b/chrome/browser/resources/settings/icons.html index f7891e3..a3bcccd 100644 --- a/chrome/browser/resources/settings/icons.html +++ b/chrome/browser/resources/settings/icons.html
@@ -21,7 +21,7 @@ <!-- These icons are from iron-icons in third_party/polymer, but were curated here via the following URL and then sorted: - https://poly-icon.appspot.com/?name=settings&size=24&icon=av:mic&icon=av:videocam&icon=av:volume-up&icon=av:web&icon=communication:location-on&icon=device:access-time&icon=device:battery-charging-full&icon=device:bluetooth&icon=device:network-wifi&icon=device:wallpaper&icon=hardware:desktop-windows&icon=hardware:keyboard&icon=hardware:laptop-chromebook&icon=hardware:security&icon=icons:accessibility&icon=icons:apps&icon=icons:arrow-back&icon=icons:arrow-drop-down&icon=icons:arrow-drop-up&icon=icons:assignment&icon=icons:build&icon=icons:chevron-right&icon=icons:clear&icon=icons:close&icon=icons:cloud&icon=icons:content-copy&icon=icons:delete&icon=icons:done&icon=icons:error&icon=icons:file-download&icon=icons:folder&icon=icons:fullscreen&icon=icons:info&icon=icons:input&icon=icons:language&icon=icons:list&icon=icons:lock&icon=icons:menu&icon=icons:open-in-new&icon=icons:power-settings-new&icon=icons:print&icon=icons:refresh&icon=icons:restore&icon=icons:settings&icon=icons:supervisor-account&icon=icons:visibility&icon=icons:warning&icon=image:brightness-1&icon=image:camera-alt&icon=image:flip&icon=image:palette&icon=image:photo&icon=image:rotate-right&icon=notification:sim-card-alert&icon=social:notifications&icon=social:people + https://poly-icon.appspot.com/?name=settings&size=24&icon=av:mic&icon=av:videocam&icon=av:volume-up&icon=av:web&icon=communication:location-on&icon=device:access-time&icon=device:battery-charging-full&icon=device:bluetooth&icon=device:network-wifi&icon=device:wallpaper&icon=hardware:desktop-windows&icon=hardware:keyboard&icon=hardware:laptop-chromebook&icon=hardware:security&icon=icons:accessibility&icon=icons:apps&icon=icons:arrow-back&icon=icons:arrow-drop-up&icon=icons:assignment&icon=icons:build&icon=icons:clear&icon=icons:close&icon=icons:cloud&icon=icons:content-copy&icon=icons:delete&icon=icons:done&icon=icons:error&icon=icons:folder&icon=icons:info&icon=icons:input&icon=icons:language&icon=icons:list&icon=icons:lock&icon=icons:menu&icon=icons:open-in-new&icon=icons:power-settings-new&icon=icons:refresh&icon=icons:restore&icon=icons:settings&icon=icons:supervisor-account&icon=icons:visibility&icon=icons:warning&icon=image:brightness-1&icon=image:camera-alt&icon=image:flip&icon=image:palette&icon=image:photo&icon=image:rotate-right&icon=notification:sim-card-alert&icon=social:notifications&icon=social:people --> <if expr="chromeos"> <g id="access-time"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z"></path></g> @@ -29,7 +29,6 @@ <g id="accessibility"><path d="M12 2c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm9 7h-6v13h-2v-6h-2v6H9V9H3V7h18v2z"></path></g> <g id="apps"><path d="M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"></path></g> <g id="arrow-back"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"></path></g> - <g id="arrow-drop-down"><path d="M7 10l5 5 5-5z"></path></g> <g id="arrow-drop-up"><path d="M7 14l5-5 5 5z"></path></g> <g id="assignment"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm2 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"></path></g> <if expr="chromeos"> @@ -43,7 +42,6 @@ <if expr="chromeos"> <g id="camera-alt"><circle cx="12" cy="12" r="3.2"></circle><path d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"></path></g> </if> - <g id="chevron-right"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></g> <g id="close"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></g> <g id="cloud"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z"></path></g> <g id="content-copy"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></g> @@ -53,12 +51,10 @@ </if> <g id="done"><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"></path></g> <g id="error"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"></path></g> - <g id="file-download"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"></path></g> <if expr="chromeos"> <g id="flip"><path d="M15 21h2v-2h-2v2zm4-12h2V7h-2v2zM3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2zm16-2v2h2c0-1.1-.9-2-2-2zm-8 20h2V1h-2v22zm8-6h2v-2h-2v2zM15 5h2V3h-2v2zm4 8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2z"></path></g> <g id="folder"><path d="M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"></path></g> </if> - <g id="fullscreen"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"></path></g> <g id="info"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"></path></g> <g id="input"><path d="M21 3.01H3c-1.1 0-2 .9-2 2V9h2V4.99h18v14.03H3V15H1v4.01c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98v-14c0-1.11-.9-2-2-2zM11 16l4-4-4-4v3H1v2h10v3z"></path></g> <if expr="chromeos"> @@ -84,7 +80,6 @@ <g id="people"><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"></path></g> <g id="photo"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"></path></g> <g id="power-settings-new"><path d="M13 3h-2v10h2V3zm4.83 2.17l-1.42 1.42C17.99 7.86 19 9.81 19 12c0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.19 1.01-4.14 2.58-5.42L6.17 5.17C4.23 6.82 3 9.26 3 12c0 4.97 4.03 9 9 9s9-4.03 9-9c0-2.74-1.23-5.18-3.17-6.83z"></path></g> - <g id="print"><path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"></path></g> <g id="refresh"><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"></path></g> <g id="restore"><path d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"></path></g> <g id="rotate-right"><path d="M15.55 5.55L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45zM19.93 11c-.17-1.39-.72-2.73-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47h2.02zM13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03zm3.89-2.42l1.42 1.41c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.48z"></path></g>
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc b/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc index 142e304..a185044 100644 --- a/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc +++ b/chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc
@@ -181,10 +181,15 @@ base::string16 ExclusiveAccessBubble::GetInstructionText( const base::string16& accelerator) const { +#if defined(OS_MACOSX) + // On Mac, if simplified-fullscreen is disabled, the Cocoa code is unable to + // deal with the special formatting returned by GetInstructionTextForType, so + // just return the old string. if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT_SENTENCE, accelerator); } +#endif return exclusive_access_bubble::GetInstructionTextForType(bubble_type_, accelerator);
diff --git a/chrome/browser/ui/tab_helpers.cc b/chrome/browser/ui/tab_helpers.cc index 2c8de2f..6398c77 100644 --- a/chrome/browser/ui/tab_helpers.cc +++ b/chrome/browser/ui/tab_helpers.cc
@@ -172,7 +172,7 @@ SearchTabHelper::CreateForWebContents(web_contents); ChromeSecurityStateModelClient::CreateForWebContents(web_contents); if (SiteEngagementService::IsEnabled()) - SiteEngagementHelper::CreateForWebContents(web_contents); + SiteEngagementService::Helper::CreateForWebContents(web_contents); // TODO(vabr): Remove TabSpecificContentSettings from here once their function // is taken over by ChromeContentSettingsClient. http://crbug.com/387075 TabSpecificContentSettings::CreateForWebContents(web_contents);
diff --git a/chrome/browser/ui/views/exclusive_access_bubble_views.cc b/chrome/browser/ui/views/exclusive_access_bubble_views.cc index 5c29216..7e4346e 100644 --- a/chrome/browser/ui/views/exclusive_access_bubble_views.cc +++ b/chrome/browser/ui/views/exclusive_access_bubble_views.cc
@@ -50,8 +50,7 @@ const int kOuterPaddingHorizPx = 40; const int kOuterPaddingVertPx = 8; -// Partially-transparent background color. Only used with -// IsSimplifiedFullscreenUIEnabled. +// Partially-transparent background color. const SkColor kBackgroundColor = SkColorSetARGB(0xcc, 0x28, 0x2c, 0x32); class ButtonView : public views::View { @@ -211,6 +210,7 @@ // mode only.) views::Label* message_label_; // Clickable buttons to exit fullscreen. (Non-simplified mode only.) + // TODO(mgiuca): Delete this; it is no longer used on any code path. ButtonView* button_view_; // Instruction for exiting fullscreen / mouse lock. Only present if there is // no link or button (always present in simplified mode). @@ -231,29 +231,11 @@ button_view_(nullptr), exit_instruction_(nullptr), browser_fullscreen_exit_accelerator_(accelerator) { - views::BubbleBorder::Shadow shadow_type = views::BubbleBorder::BIG_SHADOW; -#if defined(OS_LINUX) - // Use a smaller shadow on Linux (including ChromeOS) as the shadow assets can - // overlap each other in a fullscreen notification bubble. - // See http://crbug.com/462983. - shadow_type = views::BubbleBorder::SMALL_SHADOW; -#endif - if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) - shadow_type = views::BubbleBorder::NO_ASSETS; - - // TODO(estade): don't use this static instance. See http://crbug.com/558162 - ui::NativeTheme* theme = ui::NativeTheme::GetInstanceForWeb(); - SkColor background_color = - ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() - ? kBackgroundColor - : theme->GetSystemColor(ui::NativeTheme::kColorId_BubbleBackground); - SkColor foreground_color = - ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() - ? SK_ColorWHITE - : theme->GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor); + const SkColor kForegroundColor = SK_ColorWHITE; std::unique_ptr<views::BubbleBorder> bubble_border(new views::BubbleBorder( - views::BubbleBorder::NONE, shadow_type, background_color)); + views::BubbleBorder::NONE, views::BubbleBorder::NO_ASSETS, + kBackgroundColor)); set_background(new views::BubbleBackground(bubble_border.get())); SetBorder(std::move(bubble_border)); @@ -263,12 +245,12 @@ if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { message_label_ = new views::Label(base::string16(), font_list); - message_label_->SetEnabledColor(foreground_color); - message_label_->SetBackgroundColor(background_color); + message_label_->SetEnabledColor(kForegroundColor); + message_label_->SetBackgroundColor(kBackgroundColor); } exit_instruction_ = new InstructionView(base::string16(), font_list, - foreground_color, background_color); + kForegroundColor, kBackgroundColor); link_ = new views::Link(); link_->SetFocusBehavior(FocusBehavior::NEVER); @@ -278,9 +260,9 @@ #endif link_->set_listener(this); link_->SetFontList(font_list); - link_->SetPressedColor(foreground_color); - link_->SetEnabledColor(foreground_color); - link_->SetBackgroundColor(background_color); + link_->SetPressedColor(kForegroundColor); + link_->SetEnabledColor(kForegroundColor); + link_->SetBackgroundColor(kBackgroundColor); link_->SetVisible(false); button_view_ = new ButtonView(this, kPaddingPx); @@ -290,9 +272,6 @@ if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { DCHECK(message_label_); AddChildView(message_label_); - - outer_padding_horiz = kPaddingPx; - outer_padding_vert = kPaddingPx; } AddChildView(button_view_); AddChildView(exit_instruction_); @@ -329,49 +308,33 @@ ExclusiveAccessBubbleType bubble_type) { DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type); - if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { - DCHECK(message_label_); - message_label_->SetText(bubble_->GetCurrentMessageText()); - } - - if (exclusive_access_bubble::ShowButtonsForType(bubble_type)) { - link_->SetVisible(false); - exit_instruction_->SetVisible(false); - button_view_->SetVisible(true); - button_view_->deny_button()->SetText(bubble_->GetCurrentDenyButtonText()); - button_view_->deny_button()->SetMinSize(gfx::Size()); - button_view_->accept_button()->SetText( - bubble_->GetCurrentAllowButtonText()); - button_view_->accept_button()->SetMinSize(gfx::Size()); + bool link_visible = + !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled(); + base::string16 accelerator; + if (bubble_type == + EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION || + bubble_type == + EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION) { + accelerator = browser_fullscreen_exit_accelerator_; } else { - bool link_visible = - !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled(); - base::string16 accelerator; - if (bubble_type == - EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION || - bubble_type == - EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION) { - accelerator = browser_fullscreen_exit_accelerator_; - } else { - accelerator = l10n_util::GetStringUTF16(IDS_APP_ESC_KEY); - if (bubble_type != - EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION) { - link_visible = false; - } + accelerator = l10n_util::GetStringUTF16(IDS_APP_ESC_KEY); + if (bubble_type != + EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION) { + link_visible = false; } -#if !defined(OS_CHROMEOS) - if (link_visible) { - link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE) + - base::UTF8ToUTF16(" ") + - l10n_util::GetStringFUTF16( - IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, accelerator)); - } -#endif - link_->SetVisible(link_visible); - exit_instruction_->SetText(bubble_->GetInstructionText(accelerator)); - exit_instruction_->SetVisible(!link_visible); - button_view_->SetVisible(false); } +#if !defined(OS_CHROMEOS) + if (link_visible) { + link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE) + + base::UTF8ToUTF16(" ") + + l10n_util::GetStringFUTF16( + IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, accelerator)); + } +#endif + link_->SetVisible(link_visible); + exit_instruction_->SetText(bubble_->GetInstructionText(accelerator)); + exit_instruction_->SetVisible(!link_visible); + button_view_->SetVisible(false); } // ExclusiveAccessBubbleViews -------------------------------------------------- @@ -490,10 +453,8 @@ ExclusiveAccessBubbleViews::AnimatedAttribute ExclusiveAccessBubbleViews::ExpectedAnimationAttribute() { - return ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() || - bubble_view_context_->IsImmersiveModeEnabled() - ? ANIMATED_ATTRIBUTE_OPACITY - : ANIMATED_ATTRIBUTE_BOUNDS; + // TODO(mgiuca): Delete this function. + return ANIMATED_ATTRIBUTE_OPACITY; } void ExclusiveAccessBubbleViews::UpdateMouseWatcher() { @@ -593,10 +554,7 @@ bubble_view_context_->GetTopContainerBoundsInScreen().bottom(); } // |desired_top| is the top of the bubble area including the shadow. - int popup_top = ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() - ? kSimplifiedPopupTopPx - : kPopupTopPx; - int desired_top = popup_top - view_->border()->GetInsets().top(); + int desired_top = kSimplifiedPopupTopPx - view_->border()->GetInsets().top(); int y = top_container_bottom + desired_top; if (!ignore_animation_state &&
diff --git a/chrome/browser/ui/webui/engagement/site_engagement_ui.cc b/chrome/browser/ui/webui/engagement/site_engagement_ui.cc index 1413222..1a24fed 100644 --- a/chrome/browser/ui/webui/engagement/site_engagement_ui.cc +++ b/chrome/browser/ui/webui/engagement/site_engagement_ui.cc
@@ -57,7 +57,7 @@ double score) override { GURL origin_gurl(origin.get()); if (!origin_gurl.is_valid() || score < 0 || - score > SiteEngagementScore::kMaxPoints || std::isnan(score)) { + score > SiteEngagementService::GetMaxPoints() || std::isnan(score)) { return; }
diff --git a/chrome/browser/ui/webui/md_history_ui.cc b/chrome/browser/ui/webui/md_history_ui.cc index cb04189..4b3e1a4 100644 --- a/chrome/browser/ui/webui/md_history_ui.cc +++ b/chrome/browser/ui/webui/md_history_ui.cc
@@ -4,12 +4,14 @@ #include "chrome/browser/ui/webui/md_history_ui.h" +#include "base/command_line.h" #include "build/build_config.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/browsing_history_handler.h" #include "chrome/browser/ui/webui/foreign_session_handler.h" #include "chrome/browser/ui/webui/history_login_handler.h" #include "chrome/browser/ui/webui/metrics_handler.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "components/prefs/pref_service.h" @@ -39,6 +41,7 @@ source->AddLocalizedString("delete", IDS_MD_HISTORY_DELETE); source->AddLocalizedString("foundSearchResults", IDS_HISTORY_FOUND_SEARCH_RESULTS); + source->AddLocalizedString("historyInterval", IDS_HISTORY_INTERVAL); source->AddLocalizedString("historyMenuItem", IDS_MD_HISTORY_HISTORY_MENU_ITEM); source->AddLocalizedString("itemsSelected", IDS_MD_HISTORY_ITEMS_SELECTED); @@ -49,6 +52,12 @@ IDS_MD_HISTORY_OPEN_TABS_MENU_ITEM); source->AddLocalizedString("noResults", IDS_HISTORY_NO_RESULTS); source->AddLocalizedString("noSearchResults", IDS_HISTORY_NO_SEARCH_RESULTS); + source->AddLocalizedString("rangeAllTime", IDS_HISTORY_RANGE_ALL_TIME); + source->AddLocalizedString("rangeWeek", IDS_HISTORY_RANGE_WEEK); + source->AddLocalizedString("rangeMonth", IDS_HISTORY_RANGE_MONTH); + source->AddLocalizedString("rangeToday", IDS_HISTORY_RANGE_TODAY); + source->AddLocalizedString("rangeNext", IDS_HISTORY_RANGE_NEXT); + source->AddLocalizedString("rangePrevious", IDS_HISTORY_RANGE_PREVIOUS); source->AddLocalizedString("removeFromHistory", IDS_HISTORY_REMOVE_PAGE); source->AddLocalizedString("search", IDS_MD_HISTORY_SEARCH); source->AddLocalizedString("searchResult", IDS_HISTORY_SEARCH_RESULT); @@ -58,6 +67,11 @@ bool allow_deleting_history = prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory); source->AddBoolean("allowDeletingHistory", allow_deleting_history); + + bool group_by_domain = base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kHistoryEnableGroupByDomain); + source->AddBoolean("groupByDomain", group_by_domain); + source->AddResourcePath("app.html", IDR_MD_HISTORY_APP_HTML); source->AddResourcePath("app.js", IDR_MD_HISTORY_APP_JS); source->AddResourcePath("browser_service.html",
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index cef9e89..36627062 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi
@@ -1638,6 +1638,8 @@ 'browser/engagement/site_engagement_helper.h', 'browser/engagement/site_engagement_metrics.cc', 'browser/engagement/site_engagement_metrics.h', + 'browser/engagement/site_engagement_score.cc', + 'browser/engagement/site_engagement_score.h', 'browser/engagement/site_engagement_service.cc', 'browser/engagement/site_engagement_service.h', 'browser/engagement/site_engagement_service_factory.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 3fa600e..c9039c2 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi
@@ -102,6 +102,7 @@ 'browser/download/download_ui_controller_unittest.cc', 'browser/engagement/site_engagement_eviction_policy_unittest.cc', 'browser/engagement/site_engagement_helper_unittest.cc', + 'browser/engagement/site_engagement_score_unittest.cc', 'browser/engagement/site_engagement_service_unittest.cc', 'browser/enumerate_modules_model_unittest_win.cc', 'browser/external_protocol/external_protocol_handler_unittest.cc',
diff --git a/chrome/gpu/arc_gpu_video_decode_accelerator.cc b/chrome/gpu/arc_gpu_video_decode_accelerator.cc index b4b46b0..ce07adc 100644 --- a/chrome/gpu/arc_gpu_video_decode_accelerator.cc +++ b/chrome/gpu/arc_gpu_video_decode_accelerator.cc
@@ -254,6 +254,9 @@ // CrCb) as well as planar and semi-planar layouts. video_format.pixel_format = HAL_PIXEL_FORMAT_YCbCr_420_888; break; + case media::PIXEL_FORMAT_ARGB: + video_format.pixel_format = HAL_PIXEL_FORMAT_BGRA_8888; + break; default: DLOG(ERROR) << "Format not supported: " << output_format; arc_client_->OnError(PLATFORM_FAILURE);
diff --git a/chrome/gpu/arc_video_accelerator.h b/chrome/gpu/arc_video_accelerator.h index bb7fa622..95bf81b 100644 --- a/chrome/gpu/arc_video_accelerator.h +++ b/chrome/gpu/arc_video_accelerator.h
@@ -13,6 +13,7 @@ enum HalPixelFormatExtension { // The pixel formats defined in Android but are used here. They are defined // in "system/core/include/system/graphics.h" + HAL_PIXEL_FORMAT_BGRA_8888 = 5, HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, // The following formats are not defined in Android, but used in
diff --git a/chrome/test/data/pdf/material_elements_test.js b/chrome/test/data/pdf/material_elements_test.js index 8ec88b2..60bc2298 100644 --- a/chrome/test/data/pdf/material_elements_test.js +++ b/chrome/test/data/pdf/material_elements_test.js
@@ -160,17 +160,20 @@ zoomToolbar.addEventListener('fit-to-page', logEvent); // Initial: Show fit-to-page. - chrome.test.assertEq(fitPageIcon, fab.icon); + // TODO(tsergeant): This assertion attempts to be resilient to iconset + // changes. A better solution is something like + // https://github.com/PolymerElements/iron-icon/issues/68. + chrome.test.assertTrue(fab.icon.endsWith(fitPageIcon)); // Tap 1: Fire fit-to-page, show fit-to-width. MockInteractions.tap(fab); assertEvent('fit-to-page'); - chrome.test.assertEq(fitWidthIcon, fab.icon); + chrome.test.assertTrue(fab.icon.endsWith(fitWidthIcon)); // Tap 2: Fire fit-to-width, show fit-to-page. MockInteractions.tap(fab); assertEvent('fit-to-width'); - chrome.test.assertEq(fitPageIcon, fab.icon); + chrome.test.assertTrue(fab.icon.endsWith(fitPageIcon)); // Tap 3: Fire fit-to-page again. MockInteractions.tap(fab);
diff --git a/chromeos/CHROMEOS_LKGM b/chromeos/CHROMEOS_LKGM index 43e8744..53c6872 100644 --- a/chromeos/CHROMEOS_LKGM +++ b/chromeos/CHROMEOS_LKGM
@@ -1 +1 @@ -8325.0.0 \ No newline at end of file +8329.0.0 \ No newline at end of file
diff --git a/components/history/core/browser/download_database.cc b/components/history/core/browser/download_database.cc index e4d294e..cf90813 100644 --- a/components/history/core/browser/download_database.cc +++ b/components/history/core/browser/download_database.cc
@@ -4,6 +4,8 @@ #include "components/history/core/browser/download_database.h" +#include <inttypes.h> + #include <limits> #include <memory> #include <string> @@ -12,6 +14,7 @@ #include "base/debug/alias.h" #include "base/files/file_path.h" #include "base/metrics/histogram.h" +#include "base/rand_util.h" #include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -238,16 +241,26 @@ // have an elevated risk of collision with GUIDs generated via // base::GenerateGUID() and are considered valid by all known consumers. Hence // no additional migration logic is being introduced to fix those GUIDs. - const char kMigrateGuidsQuery[] = - "UPDATE downloads SET guid = printf" - "(\"%08X-%s-4%s-%01X%s-%s\"," - " id," - " hex(randomblob(2))," - " substr(hex(randomblob(2)),2)," - " (8 | (random() & 3))," - " substr(hex(randomblob(2)),2)," - " hex(randomblob(6)))"; - return GetDB().Execute(kMigrateGuidsQuery); + sql::Statement select(GetDB().GetUniqueStatement("SELECT id FROM downloads")); + sql::Statement update( + GetDB().GetUniqueStatement("UPDATE downloads SET guid = ? WHERE id = ?")); + while (select.Step()) { + uint32_t id = select.ColumnInt(0); + uint64_t r1 = base::RandUint64(); + uint64_t r2 = base::RandUint64(); + std::string guid = base::StringPrintf( + "%08" PRIX32 "-%04" PRIX64 "-4%03" PRIX64 "-%04" PRIX64 "-%012" PRIX64, + id, r1 >> 48, + (r1 >> 36) & 0xfff, + ((8 | ((r1 >> 34) & 3)) << 12) | ((r1 >> 22) & 0xfff), + r2 & 0xffffffffffff); + update.BindString(0, guid); + update.BindInt(1, id); + if (!update.Run()) + return false; + update.Reset(true); + } + return true; } bool DownloadDatabase::MigrateDownloadTabUrl() {
diff --git a/components/history/core/browser/history_backend_db_unittest.cc b/components/history/core/browser/history_backend_db_unittest.cc index 3083ca0..bab0f87d 100644 --- a/components/history/core/browser/history_backend_db_unittest.cc +++ b/components/history/core/browser/history_backend_db_unittest.cc
@@ -601,12 +601,15 @@ EXPECT_EQ(cur_version, s.ColumnInt(0)); } { - sql::Statement s(db.GetUniqueStatement("SELECT guid from downloads")); + sql::Statement s(db.GetUniqueStatement("SELECT guid, id from downloads")); std::unordered_set<std::string> guids; while (s.Step()) { std::string guid = s.ColumnString(0); + uint32_t id = static_cast<uint32_t>(s.ColumnInt64(1)); EXPECT_TRUE(IsValidRFC4122Ver4GUID(guid)); EXPECT_EQ(guid, base::ToUpperASCII(guid)); + // Id is used as time_low in RFC 4122 to guarantee unique GUIDs + EXPECT_EQ(guid.substr(0, 8), base::StringPrintf("%08" PRIX32, id)); guids.insert(guid); } EXPECT_TRUE(s.Succeeded());
diff --git a/components/safe_browsing_db/util.h b/components/safe_browsing_db/util.h index f6239fa7..6748976 100644 --- a/components/safe_browsing_db/util.h +++ b/components/safe_browsing_db/util.h
@@ -101,9 +101,9 @@ // TODO(shess): Refactor to allow ListType here. int list_id; ThreatMetadata metadata; - // Used only for V4 results. The cache lifetime for this result. The response - // must not be cached for more than this duration to avoid false positives. - base::TimeDelta cache_duration; + // Used only for V4 results. The cache expire time for this result. The + // response must not be cached after this time to avoid false positives. + base::Time cache_expire_after; }; // Caches individual response from GETHASH request.
diff --git a/components/safe_browsing_db/v4_get_hash_protocol_manager.cc b/components/safe_browsing_db/v4_get_hash_protocol_manager.cc index 98a4fbc..139dc38 100644 --- a/components/safe_browsing_db/v4_get_hash_protocol_manager.cc +++ b/components/safe_browsing_db/v4_get_hash_protocol_manager.cc
@@ -115,7 +115,8 @@ next_gethash_time_(Time::FromDoubleT(0)), config_(config), request_context_getter_(request_context_getter), - url_fetcher_id_(0) { + url_fetcher_id_(0), + clock_(new base::DefaultClock()) { } V4GetHashProtocolManager::~V4GetHashProtocolManager() { @@ -179,7 +180,7 @@ if (response.has_minimum_wait_duration()) { // Seconds resolution is good enough so we ignore the nanos field. next_gethash_time_ = - Time::Now() + base::TimeDelta::FromSeconds( + clock_->Now() + base::TimeDelta::FromSeconds( response.minimum_wait_duration().seconds()); } @@ -214,8 +215,10 @@ if (match.has_cache_duration()) { // Seconds resolution is good enough so we ignore the nanos field. - result.cache_duration = + result.cache_expire_after = clock_->Now() + base::TimeDelta::FromSeconds(match.cache_duration().seconds()); + } else { + result.cache_expire_after = clock_->Now(); } // Different threat types will handle the metadata differently. @@ -303,7 +306,7 @@ // we need to check if we're past the next allowed time. If we are, we can // proceed with the request. If not, we are required to return empty results // (i.e. treat the page as safe). - if (Time::Now() <= next_gethash_time_) { + if (clock_->Now() <= next_gethash_time_) { if (gethash_error_count_) { RecordGetHashResult(V4OperationResult::BACKOFF_ERROR); } else { @@ -335,6 +338,11 @@ GetFullHashes(prefixes, platform, API_ABUSE, callback); } +void V4GetHashProtocolManager::SetClockForTests( + std::unique_ptr<base::Clock> clock) { + clock_ = std::move(clock); +} + // net::URLFetcherDelegate implementation ---------------------------------- // SafeBrowsing request responses are handled here. @@ -367,7 +375,7 @@ RecordGetHashResult(V4OperationResult::PARSE_ERROR); } } else { - HandleGetHashError(Time::Now()); + HandleGetHashError(clock_->Now()); DVLOG(1) << "SafeBrowsing GetEncodedFullHashes request for: " << source->GetURL() << " failed with error: " << status.error()
diff --git a/components/safe_browsing_db/v4_get_hash_protocol_manager.h b/components/safe_browsing_db/v4_get_hash_protocol_manager.h index 4ed3345..6e14ef63 100644 --- a/components/safe_browsing_db/v4_get_hash_protocol_manager.h +++ b/components/safe_browsing_db/v4_get_hash_protocol_manager.h
@@ -19,6 +19,7 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/threading/non_thread_safe.h" +#include "base/time/default_clock.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "components/safe_browsing_db/safebrowsing.pb.h" @@ -77,6 +78,9 @@ virtual void GetFullHashesWithApis(const std::vector<SBPrefix>& prefixes, FullHashCallback callback); + // Overrides the clock used to check the time. + void SetClockForTests(std::unique_ptr<base::Clock> clock); + protected: // Constructs a V4GetHashProtocolManager that issues // network requests using |request_context_getter|. @@ -165,6 +169,9 @@ // ID for URLFetchers for testing. int url_fetcher_id_; + // The clock used to vend times. + std::unique_ptr<base::Clock> clock_; + DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManager); };
diff --git a/components/safe_browsing_db/v4_get_hash_protocol_manager_unittest.cc b/components/safe_browsing_db/v4_get_hash_protocol_manager_unittest.cc index 105f43e..2820ed4 100644 --- a/components/safe_browsing_db/v4_get_hash_protocol_manager_unittest.cc +++ b/components/safe_browsing_db/v4_get_hash_protocol_manager_unittest.cc
@@ -8,7 +8,9 @@ #include <vector> #include "base/base64.h" +#include "base/memory/ptr_util.h" #include "base/strings/stringprintf.h" +#include "base/test/simple_test_clock.h" #include "base/time/time.h" #include "components/safe_browsing_db/safebrowsing.pb.h" #include "components/safe_browsing_db/testing_util.h" @@ -79,7 +81,7 @@ const SBFullHashResult& actual = full_hashes[i]; EXPECT_TRUE(SBFullHashEqual(expected.hash, actual.hash)); EXPECT_EQ(expected.metadata, actual.metadata); - EXPECT_EQ(expected.cache_duration, actual.cache_duration); + EXPECT_EQ(expected.cache_expire_after, actual.cache_expire_after); } } @@ -140,12 +142,17 @@ net::TestURLFetcherFactory factory; std::unique_ptr<V4GetHashProtocolManager> pm(CreateProtocolManager()); + base::Time now = base::Time::UnixEpoch(); + base::SimpleTestClock* clock = new base::SimpleTestClock(); + clock->SetNow(now); + pm->SetClockForTests(base::WrapUnique(clock)); + std::vector<SBPrefix> prefixes; std::vector<SBFullHashResult> expected_full_hashes; SBFullHashResult hash_result; hash_result.hash = SBFullHashForString("Everything's shiny, Cap'n."); hash_result.metadata.api_permissions.push_back("NOTIFICATIONS"); - hash_result.cache_duration = base::TimeDelta::FromSeconds(300); + hash_result.cache_expire_after = now + base::TimeDelta::FromSeconds(300); expected_full_hashes.push_back(hash_result); base::TimeDelta expected_cache_duration = base::TimeDelta::FromSeconds(600); @@ -203,6 +210,11 @@ TEST_F(SafeBrowsingV4GetHashProtocolManagerTest, TestParseHashResponse) { std::unique_ptr<V4GetHashProtocolManager> pm(CreateProtocolManager()); + base::Time now = base::Time::UnixEpoch(); + base::SimpleTestClock* clock = new base::SimpleTestClock(); + clock->SetNow(now); + pm->SetClockForTests(base::WrapUnique(clock)); + FindFullHashesResponse res; res.mutable_negative_cache_duration()->set_seconds(600); res.mutable_minimum_wait_duration()->set_seconds(400); @@ -222,7 +234,6 @@ std::string res_data; res.SerializeToString(&res_data); - Time now = Time::Now(); std::vector<SBFullHashResult> full_hashes; base::TimeDelta cache_lifetime; EXPECT_TRUE(pm->ParseHashResponse(res_data, &full_hashes, &cache_lifetime)); @@ -233,8 +244,9 @@ full_hashes[0].hash)); EXPECT_EQ(1ul, full_hashes[0].metadata.api_permissions.size()); EXPECT_EQ("NOTIFICATIONS", full_hashes[0].metadata.api_permissions[0]); - EXPECT_EQ(base::TimeDelta::FromSeconds(300), full_hashes[0].cache_duration); - EXPECT_LE(now + base::TimeDelta::FromSeconds(400), pm->next_gethash_time_); + EXPECT_EQ(now + + base::TimeDelta::FromSeconds(300), full_hashes[0].cache_expire_after); + EXPECT_EQ(now + base::TimeDelta::FromSeconds(400), pm->next_gethash_time_); } // Adds an entry with an ignored ThreatEntryType.
diff --git a/content/child/service_worker/service_worker_provider_context.cc b/content/child/service_worker/service_worker_provider_context.cc index dc3e2d2..b0c0e9d 100644 --- a/content/child/service_worker/service_worker_provider_context.cc +++ b/content/child/service_worker/service_worker_provider_context.cc
@@ -19,7 +19,7 @@ class ServiceWorkerProviderContext::Delegate { public: - virtual ~Delegate(){}; + virtual ~Delegate() {} virtual void AssociateRegistration( std::unique_ptr<ServiceWorkerRegistrationHandleReference> registration, std::unique_ptr<ServiceWorkerHandleReference> installing, @@ -29,6 +29,7 @@ virtual void GetAssociatedRegistration( ServiceWorkerRegistrationObjectInfo* info, ServiceWorkerVersionAttributes* attrs) = 0; + virtual bool HasAssociatedRegistration() = 0; virtual void SetController( std::unique_ptr<ServiceWorkerHandleReference> controller) = 0; virtual ServiceWorkerHandleReference* controller() = 0; @@ -65,6 +66,8 @@ controller_ = std::move(controller); } + bool HasAssociatedRegistration() override { return !!registration_; } + void GetAssociatedRegistration( ServiceWorkerRegistrationObjectInfo* info, ServiceWorkerVersionAttributes* attrs) override { @@ -112,10 +115,12 @@ NOTREACHED(); } + bool HasAssociatedRegistration() override { return !!registration_; } + void GetAssociatedRegistration( ServiceWorkerRegistrationObjectInfo* info, ServiceWorkerVersionAttributes* attrs) override { - DCHECK(registration_); + DCHECK(HasAssociatedRegistration()); *info = registration_->info(); if (installing_) attrs->installing = installing_->info(); @@ -194,6 +199,10 @@ delegate_->GetAssociatedRegistration(info, attrs); } +bool ServiceWorkerProviderContext::HasAssociatedRegistration() { + return delegate_->HasAssociatedRegistration(); +} + ServiceWorkerHandleReference* ServiceWorkerProviderContext::controller() { DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); return delegate_->controller();
diff --git a/content/child/service_worker/service_worker_provider_context.h b/content/child/service_worker/service_worker_provider_context.h index 85e259a..b005e22f 100644 --- a/content/child/service_worker/service_worker_provider_context.h +++ b/content/child/service_worker/service_worker_provider_context.h
@@ -65,6 +65,9 @@ void GetAssociatedRegistration(ServiceWorkerRegistrationObjectInfo* info, ServiceWorkerVersionAttributes* attrs); + // May be called on the main or worker thread. + bool HasAssociatedRegistration(); + int provider_id() const { return provider_id_; } ServiceWorkerHandleReference* controller();
diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc index a193d898..5ba7f08f 100644 --- a/content/renderer/service_worker/service_worker_context_client.cc +++ b/content/renderer/service_worker/service_worker_context_client.cc
@@ -347,6 +347,10 @@ Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded(embedded_worker_id_)); } +bool ServiceWorkerContextClient::hasAssociatedRegistration() { + return provider_context_ && provider_context_->HasAssociatedRegistration(); +} + void ServiceWorkerContextClient::workerContextStarted( blink::WebServiceWorkerContextProxy* proxy) { DCHECK(!worker_task_runner_.get());
diff --git a/content/renderer/service_worker/service_worker_context_client.h b/content/renderer/service_worker/service_worker_context_client.h index e2c04ac..e32a081 100644 --- a/content/renderer/service_worker/service_worker_context_client.h +++ b/content/renderer/service_worker/service_worker_context_client.h
@@ -105,6 +105,7 @@ // Called on the main thread. void workerContextFailedToStart() override; void workerScriptLoaded() override; + bool hasAssociatedRegistration() override; void workerContextStarted( blink::WebServiceWorkerContextProxy* proxy) override;
diff --git a/media/gpu/vaapi_drm_picture.cc b/media/gpu/vaapi_drm_picture.cc index 30539df5..dc57dc9 100644 --- a/media/gpu/vaapi_drm_picture.cc +++ b/media/gpu/vaapi_drm_picture.cc
@@ -16,24 +16,23 @@ #include "ui/ozone/public/ozone_platform.h" #include "ui/ozone/public/surface_factory_ozone.h" -namespace { -// We decode video into YUV420, but for usage with GLImages we have to convert -// to BGRX_8888. -const gfx::BufferFormat kPictureForGLImageFormat = gfx::BufferFormat::BGRX_8888; - -} // namespace - namespace media { VaapiDrmPicture::VaapiDrmPicture( const scoped_refptr<VaapiWrapper>& vaapi_wrapper, const MakeGLContextCurrentCallback& make_context_current_cb, + const BindGLImageCallback& bind_image_cb, int32_t picture_buffer_id, + const gfx::Size& size, uint32_t texture_id, - const gfx::Size& size) - : VaapiPicture(picture_buffer_id, texture_id, size), - vaapi_wrapper_(vaapi_wrapper), - make_context_current_cb_(make_context_current_cb) {} + uint32_t client_texture_id) + : VaapiPicture(vaapi_wrapper, + make_context_current_cb, + bind_image_cb, + picture_buffer_id, + size, + texture_id, + client_texture_id) {} VaapiDrmPicture::~VaapiDrmPicture() { if (gl_image_ && make_context_current_cb_.Run()) { @@ -45,18 +44,7 @@ } bool VaapiDrmPicture::Initialize() { - // We want to create a VASurface and an EGLImage out of the same - // memory buffer, so we can output decoded pictures to it using - // VAAPI and also use it to paint with GL. - ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); - ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); - pixmap_ = factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size(), - kPictureForGLImageFormat, - gfx::BufferUsage::SCANOUT); - if (!pixmap_) { - LOG(ERROR) << "Failed creating an Ozone NativePixmap"; - return false; - } + DCHECK(pixmap_); va_surface_ = vaapi_wrapper_->CreateVASurfaceForPixmap(pixmap_); if (!va_surface_) { @@ -67,37 +55,72 @@ pixmap_->SetProcessingCallback( base::Bind(&VaapiWrapper::ProcessPixmap, vaapi_wrapper_)); - if (!make_context_current_cb_.Run()) - return false; + if (texture_id_ != 0 && !make_context_current_cb_.is_null()) { + if (!make_context_current_cb_.Run()) + return false; - gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_EXTERNAL_OES, - texture_id()); - scoped_refptr<gfx::GLImageOzoneNativePixmap> image( - new gfx::GLImageOzoneNativePixmap(size(), GL_BGRA_EXT)); - if (!image->Initialize(pixmap_.get(), pixmap_->GetBufferFormat())) { - LOG(ERROR) << "Failed to create GLImage"; - return false; + gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_EXTERNAL_OES, + texture_id_); + scoped_refptr<gfx::GLImageOzoneNativePixmap> image( + new gfx::GLImageOzoneNativePixmap(size_, GL_BGRA_EXT)); + if (!image->Initialize(pixmap_.get(), pixmap_->GetBufferFormat())) { + LOG(ERROR) << "Failed to create GLImage"; + return false; + } + gl_image_ = image; + if (!gl_image_->BindTexImage(GL_TEXTURE_EXTERNAL_OES)) { + LOG(ERROR) << "Failed to bind texture to GLImage"; + return false; + } } - gl_image_ = image; - if (!gl_image_->BindTexImage(GL_TEXTURE_EXTERNAL_OES)) { - LOG(ERROR) << "Failed to bind texture to GLImage"; - return false; + + if (client_texture_id_ != 0 && !bind_image_cb_.is_null()) { + if (!bind_image_cb_.Run(client_texture_id_, GL_TEXTURE_EXTERNAL_OES, + gl_image_, true)) { + LOG(ERROR) << "Failed to bind client_texture_id"; + return false; + } } return true; } +bool VaapiDrmPicture::Allocate(gfx::BufferFormat format) { + ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); + ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); + pixmap_ = factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size_, + format, gfx::BufferUsage::SCANOUT); + if (!pixmap_) { + DVLOG(1) << "Failed allocating a pixmap"; + return false; + } + + return Initialize(); +} + +bool VaapiDrmPicture::ImportGpuMemoryBufferHandle( + gfx::BufferFormat format, + const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handle) { + ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); + ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); + // CreateNativePixmapFromHandle() will take ownership of the handle. + pixmap_ = factory->CreateNativePixmapFromHandle( + size_, format, gpu_memory_buffer_handle.native_pixmap_handle); + if (!pixmap_) { + DVLOG(1) << "Failed creating a pixmap from a native handle"; + return false; + } + + return Initialize(); +} + bool VaapiDrmPicture::DownloadFromSurface( const scoped_refptr<VASurface>& va_surface) { return vaapi_wrapper_->BlitSurface(va_surface, va_surface_); } -scoped_refptr<gl::GLImage> VaapiDrmPicture::GetImageToBind() { - return gl_image_; -} - bool VaapiDrmPicture::AllowOverlay() const { return true; } -} // namespace +} // namespace media
diff --git a/media/gpu/vaapi_drm_picture.h b/media/gpu/vaapi_drm_picture.h index b23811f4..a1ba6615 100644 --- a/media/gpu/vaapi_drm_picture.h +++ b/media/gpu/vaapi_drm_picture.h
@@ -35,23 +35,25 @@ public: VaapiDrmPicture(const scoped_refptr<VaapiWrapper>& vaapi_wrapper, const MakeGLContextCurrentCallback& make_context_current_cb, + const BindGLImageCallback& bind_image_cb_, int32_t picture_buffer_id, + const gfx::Size& size, uint32_t texture_id, - const gfx::Size& size); + uint32_t client_texture_id); ~VaapiDrmPicture() override; - bool Initialize() override; + bool Allocate(gfx::BufferFormat format) override; + bool ImportGpuMemoryBufferHandle( + gfx::BufferFormat format, + const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handle) override; bool DownloadFromSurface(const scoped_refptr<VASurface>& va_surface) override; - scoped_refptr<gl::GLImage> GetImageToBind() override; - bool AllowOverlay() const override; private: - scoped_refptr<VaapiWrapper> vaapi_wrapper_; - MakeGLContextCurrentCallback make_context_current_cb_; + bool Initialize(); // Ozone buffer, the storage of the EGLImage and the VASurface. scoped_refptr<ui::NativePixmap> pixmap_;
diff --git a/media/gpu/vaapi_picture.cc b/media/gpu/vaapi_picture.cc index 9e20590..921a4249 100644 --- a/media/gpu/vaapi_picture.cc +++ b/media/gpu/vaapi_picture.cc
@@ -15,25 +15,44 @@ namespace media { +VaapiPicture::VaapiPicture( + const scoped_refptr<VaapiWrapper>& vaapi_wrapper, + const MakeGLContextCurrentCallback& make_context_current_cb, + const BindGLImageCallback& bind_image_cb, + int32_t picture_buffer_id, + const gfx::Size& size, + uint32_t texture_id, + uint32_t client_texture_id) + : vaapi_wrapper_(vaapi_wrapper), + make_context_current_cb_(make_context_current_cb), + bind_image_cb_(bind_image_cb), + size_(size), + texture_id_(texture_id), + client_texture_id_(client_texture_id), + picture_buffer_id_(picture_buffer_id) {} + +VaapiPicture::~VaapiPicture() {} + // static linked_ptr<VaapiPicture> VaapiPicture::CreatePicture( const scoped_refptr<VaapiWrapper>& vaapi_wrapper, const MakeGLContextCurrentCallback& make_context_current_cb, + const BindGLImageCallback& bind_image_cb, int32_t picture_buffer_id, + const gfx::Size& size, uint32_t texture_id, - const gfx::Size& size) { + uint32_t client_texture_id) { linked_ptr<VaapiPicture> picture; #if defined(USE_X11) picture.reset(new VaapiTFPPicture(vaapi_wrapper, make_context_current_cb, - picture_buffer_id, texture_id, size)); + bind_image_cb, picture_buffer_id, size, + texture_id, client_texture_id)); #elif defined(USE_OZONE) picture.reset(new VaapiDrmPicture(vaapi_wrapper, make_context_current_cb, - picture_buffer_id, texture_id, size)); + bind_image_cb, picture_buffer_id, size, + texture_id, client_texture_id)); #endif // USE_X11 - if (picture.get() && !picture->Initialize()) - picture.reset(); - return picture; }
diff --git a/media/gpu/vaapi_picture.h b/media/gpu/vaapi_picture.h index 53b4fa4..dfb1e2a 100644 --- a/media/gpu/vaapi_picture.h +++ b/media/gpu/vaapi_picture.h
@@ -18,6 +18,7 @@ #include "base/threading/non_thread_safe.h" #include "media/gpu/gpu_video_decode_accelerator_helpers.h" #include "ui/gfx/geometry/size.h" +#include "ui/gfx/gpu_memory_buffer.h" namespace gl { class GLImage; @@ -31,51 +32,64 @@ // Picture is native pixmap abstraction (X11/Ozone). class VaapiPicture : public base::NonThreadSafe { public: - virtual ~VaapiPicture() {} + // Create a VaapiPicture of |size| to be associated with |picture_buffer_id|. + // If provided, bind it to |texture_id|, as well as to |client_texture_id| + // using |bind_image_cb|. + static linked_ptr<VaapiPicture> CreatePicture( + const scoped_refptr<VaapiWrapper>& vaapi_wrapper, + const MakeGLContextCurrentCallback& make_context_current_cb, + const BindGLImageCallback& bind_image_cb, + int32_t picture_buffer_id, + const gfx::Size& size, + uint32_t texture_id, + uint32_t client_texture_id); - // Try to allocate the underlying resources for the picture. - virtual bool Initialize() = 0; + virtual ~VaapiPicture(); + + // Use the buffer of |format|, pointed to by |gpu_memory_buffer_handle| as the + // backing storage for this picture. This takes ownership of the handle and + // will close it even on failure. Return true on success, false otherwise. + virtual bool ImportGpuMemoryBufferHandle( + gfx::BufferFormat format, + const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handle) = 0; + + // Allocate a buffer of |format| to use as backing storage for this picture. + // Return true on success. + virtual bool Allocate(gfx::BufferFormat format) = 0; int32_t picture_buffer_id() const { return picture_buffer_id_; } - uint32_t texture_id() const { return texture_id_; } - const gfx::Size& size() const { return size_; } virtual bool AllowOverlay() const; - // Returns the |GLImage|, if any, to bind to the texture. - virtual scoped_refptr<gl::GLImage> GetImageToBind() = 0; - // Downloads the |va_surface| into the picture, potentially scaling // it if needed. virtual bool DownloadFromSurface( const scoped_refptr<VASurface>& va_surface) = 0; - // Create a VaapiPicture of |size| to be associated with - // |picture_buffer_id| and bound to |texture_id|. - // |make_context_current_cb| is provided for the GL operations. - static linked_ptr<VaapiPicture> CreatePicture( - const scoped_refptr<VaapiWrapper>& vaapi_wrapper, - const MakeGLContextCurrentCallback& make_context_current_cb, - int32_t picture_buffer_id, - uint32_t texture_id, - const gfx::Size& size); - // Get the texture target used to bind EGLImages (either // GL_TEXTURE_2D on X11 or GL_TEXTURE_EXTERNAL_OES on DRM). static uint32_t GetGLTextureTarget(); protected: - VaapiPicture(int32_t picture_buffer_id, + VaapiPicture(const scoped_refptr<VaapiWrapper>& vaapi_wrapper, + const MakeGLContextCurrentCallback& make_context_current_cb, + const BindGLImageCallback& bind_image_cb, + int32_t picture_buffer_id, + const gfx::Size& size, uint32_t texture_id, - const gfx::Size& size) - : picture_buffer_id_(picture_buffer_id), - texture_id_(texture_id), - size_(size) {} + uint32_t client_texture_id); + + scoped_refptr<VaapiWrapper> vaapi_wrapper_; + + const MakeGLContextCurrentCallback make_context_current_cb_; + const BindGLImageCallback bind_image_cb_; + + const gfx::Size size_; + const uint32_t texture_id_; + const uint32_t client_texture_id_; private: int32_t picture_buffer_id_; - uint32_t texture_id_; - gfx::Size size_; DISALLOW_COPY_AND_ASSIGN(VaapiPicture); };
diff --git a/media/gpu/vaapi_tfp_picture.cc b/media/gpu/vaapi_tfp_picture.cc index 508fd0db..71a6dca50 100644 --- a/media/gpu/vaapi_tfp_picture.cc +++ b/media/gpu/vaapi_tfp_picture.cc
@@ -18,12 +18,18 @@ VaapiTFPPicture::VaapiTFPPicture( const scoped_refptr<VaapiWrapper>& vaapi_wrapper, const MakeGLContextCurrentCallback& make_context_current_cb, + const BindGLImageCallback& bind_image_cb, int32_t picture_buffer_id, + const gfx::Size& size, uint32_t texture_id, - const gfx::Size& size) - : VaapiPicture(picture_buffer_id, texture_id, size), - vaapi_wrapper_(vaapi_wrapper), - make_context_current_cb_(make_context_current_cb), + uint32_t client_texture_id) + : VaapiPicture(vaapi_wrapper, + make_context_current_cb, + bind_image_cb, + picture_buffer_id, + size, + texture_id, + client_texture_id), x_display_(gfx::GetXDisplay()), x_pixmap_(0) {} @@ -39,8 +45,35 @@ } bool VaapiTFPPicture::Initialize() { - if (!make_context_current_cb_.Run()) + DCHECK(x_pixmap_); + + if (texture_id_ != 0 && !make_context_current_cb_.is_null()) { + if (!make_context_current_cb_.Run()) + return false; + + glx_image_ = new gl::GLImageGLX(size_, GL_RGB); + if (!glx_image_->Initialize(x_pixmap_)) { + // x_pixmap_ will be freed in the destructor. + LOG(ERROR) << "Failed creating a GLX Pixmap for TFP"; + return false; + } + + gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id_); + if (!glx_image_->BindTexImage(GL_TEXTURE_2D)) { + LOG(ERROR) << "Failed to bind texture to glx image"; + return false; + } + } + + return true; +} + +bool VaapiTFPPicture::Allocate(gfx::BufferFormat format) { + if (format != gfx::BufferFormat::BGRX_8888 && + format != gfx::BufferFormat::BGRA_8888) { + LOG(ERROR) << "Unsupported format"; return false; + } XWindowAttributes win_attr; int screen = DefaultScreen(x_display_); @@ -48,26 +81,20 @@ // TODO(posciak): pass the depth required by libva, not the RootWindow's // depth x_pixmap_ = XCreatePixmap(x_display_, RootWindow(x_display_, screen), - size().width(), size().height(), win_attr.depth); + size_.width(), size_.height(), win_attr.depth); if (!x_pixmap_) { LOG(ERROR) << "Failed creating an X Pixmap for TFP"; return false; } - glx_image_ = new gl::GLImageGLX(size(), GL_RGB); - if (!glx_image_->Initialize(x_pixmap_)) { - // x_pixmap_ will be freed in the destructor. - LOG(ERROR) << "Failed creating a GLX Pixmap for TFP"; - return false; - } + return Initialize(); +} - gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id()); - if (!glx_image_->BindTexImage(GL_TEXTURE_2D)) { - LOG(ERROR) << "Failed to bind texture to glx image"; - return false; - } - - return true; +bool VaapiTFPPicture::ImportGpuMemoryBufferHandle( + gfx::BufferFormat format, + const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handle) { + NOTIMPLEMENTED() << "GpuMemoryBufferHandle import not implemented"; + return false; } bool VaapiTFPPicture::DownloadFromSurface( @@ -76,8 +103,4 @@ va_surface->size()); } -scoped_refptr<gl::GLImage> VaapiTFPPicture::GetImageToBind() { - return nullptr; -} - } // namespace media
diff --git a/media/gpu/vaapi_tfp_picture.h b/media/gpu/vaapi_tfp_picture.h index 1c9cdeb..1189c3be 100644 --- a/media/gpu/vaapi_tfp_picture.h +++ b/media/gpu/vaapi_tfp_picture.h
@@ -34,22 +34,24 @@ public: VaapiTFPPicture(const scoped_refptr<VaapiWrapper>& vaapi_wrapper, const MakeGLContextCurrentCallback& make_context_current_cb, + const BindGLImageCallback& bind_image_cb, int32_t picture_buffer_id, + const gfx::Size& size, uint32_t texture_id, - const gfx::Size& size); + uint32_t client_texture_id); ~VaapiTFPPicture() override; - bool Initialize() override; + bool Allocate(gfx::BufferFormat format) override; + bool ImportGpuMemoryBufferHandle( + gfx::BufferFormat format, + const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handle) override; bool DownloadFromSurface(const scoped_refptr<VASurface>& va_surface) override; - scoped_refptr<gl::GLImage> GetImageToBind() override; - private: - scoped_refptr<VaapiWrapper> vaapi_wrapper_; + bool Initialize(); - MakeGLContextCurrentCallback make_context_current_cb_; Display* x_display_; Pixmap x_pixmap_;
diff --git a/media/gpu/vaapi_video_decode_accelerator.cc b/media/gpu/vaapi_video_decode_accelerator.cc index 8f1c2bc..e07b4a5 100644 --- a/media/gpu/vaapi_video_decode_accelerator.cc +++ b/media/gpu/vaapi_video_decode_accelerator.cc
@@ -9,6 +9,7 @@ #include <memory> #include "base/bind.h" +#include "base/files/scoped_file.h" #include "base/logging.h" #include "base/macros.h" #include "base/metrics/histogram.h" @@ -36,6 +37,10 @@ VAAPI_ERROR = 0, VAVDA_DECODER_FAILURES_MAX, }; + +// Buffer format to use for output buffers backing PictureBuffers. This is the +// format decoded frames in VASurfaces are converted into. +const gfx::BufferFormat kOutputPictureFormat = gfx::BufferFormat::BGRA_8888; } static void ReportToUMA(VAVDADecoderFailure failure) { @@ -320,19 +325,14 @@ Client* client) { DCHECK_EQ(message_loop_, base::MessageLoop::current()); - if (make_context_current_cb_.is_null() || bind_image_cb_.is_null()) { - NOTREACHED() << "GL callbacks are required for this VDA"; - return false; - } - if (config.is_encrypted) { NOTREACHED() << "Encrypted streams are not supported for this VDA"; return false; } - if (config.output_mode != Config::OutputMode::ALLOCATE) { - NOTREACHED() << "Only ALLOCATE OutputMode is supported by this VDA"; - return false; + if (config.output_mode != Config::OutputMode::ALLOCATE && + config.output_mode != Config::OutputMode::IMPORT) { + NOTREACHED() << "Only ALLOCATE and IMPORT OutputModes are supported"; } client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); @@ -387,6 +387,7 @@ decoder_thread_task_runner_ = decoder_thread_.task_runner(); state_ = kIdle; + output_mode_ = config.output_mode; return true; } @@ -758,32 +759,29 @@ DCHECK_EQ(va_surface_ids.size(), buffers.size()); for (size_t i = 0; i < buffers.size(); ++i) { - DCHECK_LE(1u, buffers[i].texture_ids().size()); - DVLOG(2) << "Assigning picture id: " << buffers[i].id() - << " to texture id: " << buffers[i].texture_ids()[0] - << " VASurfaceID: " << va_surface_ids[i]; + uint32_t texture_id = + buffers[i].texture_ids().size() > 0 ? buffers[i].texture_ids()[0] : 0; + uint32_t internal_texture_id = buffers[i].internal_texture_ids().size() > 0 + ? buffers[i].internal_texture_ids()[0] + : 0; linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture( - vaapi_wrapper_, make_context_current_cb_, buffers[i].id(), - buffers[i].texture_ids()[0], requested_pic_size_)); - - scoped_refptr<gl::GLImage> image = picture->GetImageToBind(); - if (image && buffers[i].internal_texture_ids().size() > 0) { - RETURN_AND_NOTIFY_ON_FAILURE( - bind_image_cb_.Run(buffers[i].internal_texture_ids()[0], - VaapiPicture::GetGLTextureTarget(), image, true), - "Failed to bind image", PLATFORM_FAILURE, ); - } - + vaapi_wrapper_, make_context_current_cb_, bind_image_cb_, + buffers[i].id(), requested_pic_size_, texture_id, internal_texture_id)); RETURN_AND_NOTIFY_ON_FAILURE( - picture.get(), "Failed assigning picture buffer to a texture.", - PLATFORM_FAILURE, ); + picture.get(), "Failed creating a VaapiPicture", PLATFORM_FAILURE, ); bool inserted = pictures_.insert(std::make_pair(buffers[i].id(), picture)).second; DCHECK(inserted); - output_buffers_.push(buffers[i].id()); + if (output_mode_ == Config::OutputMode::ALLOCATE) { + RETURN_AND_NOTIFY_ON_FAILURE( + picture->Allocate(kOutputPictureFormat), + "Failed to allocate memory for a VaapiPicture", PLATFORM_FAILURE, ); + output_buffers_.push(buffers[i].id()); + } + available_va_surfaces_.push_back(va_surface_ids[i]); surfaces_available_.Signal(); } @@ -794,6 +792,57 @@ base::Unretained(this))); } +#if defined(USE_OZONE) +static void CloseGpuMemoryBuferHandles( + const std::vector<gfx::GpuMemoryBufferHandle>& handles) { + for (const auto& handle : handles) { + // Close the fd by wrapping it in a ScopedFD and letting + // it fall out of scope. + base::ScopedFD fd(handle.native_pixmap_handle.fd.fd); + } +} + +void VaapiVideoDecodeAccelerator::ImportBufferForPicture( + int32_t picture_buffer_id, + const std::vector<gfx::GpuMemoryBufferHandle>& gpu_memory_buffer_handles) { + DCHECK_EQ(message_loop_, base::MessageLoop::current()); + DVLOG(2) << "Importing picture id: " << picture_buffer_id; + + if (output_mode_ != Config::OutputMode::IMPORT) { + CloseGpuMemoryBuferHandles(gpu_memory_buffer_handles); + LOG(ERROR) << "Cannot import in non-import mode"; + NotifyError(INVALID_ARGUMENT); + return; + } + + if (gpu_memory_buffer_handles.size() != 1) { + CloseGpuMemoryBuferHandles(gpu_memory_buffer_handles); + LOG(ERROR) << "Buffers backed by multiple handles unsupported"; + NotifyError(INVALID_ARGUMENT); + return; + } + + VaapiPicture* picture = PictureById(picture_buffer_id); + if (!picture) { + CloseGpuMemoryBuferHandles(gpu_memory_buffer_handles); + LOG(ERROR) << "Invalid picture_buffer_id"; + NotifyError(INVALID_ARGUMENT); + return; + } + + if (!picture->ImportGpuMemoryBufferHandle(kOutputPictureFormat, + gpu_memory_buffer_handles[0])) { + // ImportGpuMemoryBufferHandle will close the handles even on failure, so + // we don't need to do this ourselves. + LOG(ERROR) << "Failed to import GpuMemoryBufferHandles"; + NotifyError(PLATFORM_FAILURE); + return; + } + + ReusePictureBuffer(picture_buffer_id); +} +#endif + void VaapiVideoDecodeAccelerator::ReusePictureBuffer( int32_t picture_buffer_id) { DCHECK_EQ(message_loop_, base::MessageLoop::current()); @@ -996,6 +1045,22 @@ return false; } +static VideoPixelFormat BufferFormatToVideoPixelFormat( + gfx::BufferFormat format) { + switch (format) { + case gfx::BufferFormat::BGRA_8888: + return PIXEL_FORMAT_ARGB; + + default: + LOG(FATAL) << "Add more cases as needed"; + return PIXEL_FORMAT_UNKNOWN; + } +} + +VideoPixelFormat VaapiVideoDecodeAccelerator::GetOutputFormat() const { + return BufferFormatToVideoPixelFormat(kOutputPictureFormat); +} + bool VaapiVideoDecodeAccelerator::DecodeSurface( const scoped_refptr<VaapiDecodeSurface>& dec_surface) { if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers(
diff --git a/media/gpu/vaapi_video_decode_accelerator.h b/media/gpu/vaapi_video_decode_accelerator.h index f2db989..7185de3 100644 --- a/media/gpu/vaapi_video_decode_accelerator.h +++ b/media/gpu/vaapi_video_decode_accelerator.h
@@ -67,6 +67,11 @@ void Decode(const media::BitstreamBuffer& bitstream_buffer) override; void AssignPictureBuffers( const std::vector<media::PictureBuffer>& buffers) override; +#if defined(USE_OZONE) + void ImportBufferForPicture(int32_t picture_buffer_id, + const std::vector<gfx::GpuMemoryBufferHandle>& + gpu_memory_buffer_handles) override; +#endif void ReusePictureBuffer(int32_t picture_buffer_id) override; void Flush() override; void Reset() override; @@ -75,6 +80,7 @@ const base::WeakPtr<Client>& decode_client, const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) override; + VideoPixelFormat GetOutputFormat() const override; static media::VideoDecodeAccelerator::SupportedProfiles GetSupportedProfiles(); @@ -204,6 +210,7 @@ // Protects input buffer and surface queues and state_. base::Lock lock_; State state_; + Config::OutputMode output_mode_; // An input buffer awaiting consumption, provided by the client. struct InputBuffer { @@ -214,7 +221,7 @@ std::unique_ptr<SharedMemoryRegion> shm; }; - // Queue for incoming input buffers. + // Queue for available PictureBuffers (picture_buffer_ids). typedef std::queue<linked_ptr<InputBuffer>> InputBuffers; InputBuffers input_buffers_; // Signalled when input buffers are queued onto the input_buffers_ queue.
diff --git a/media/gpu/vaapi_wrapper.cc b/media/gpu/vaapi_wrapper.cc index c40f8bc..72edc67e 100644 --- a/media/gpu/vaapi_wrapper.cc +++ b/media/gpu/vaapi_wrapper.cc
@@ -67,6 +67,8 @@ switch (fmt) { case gfx::BufferFormat::BGRX_8888: return VA_FOURCC_BGRX; + case gfx::BufferFormat::BGRA_8888: + return VA_FOURCC_BGRA; case gfx::BufferFormat::UYVY_422: return VA_FOURCC_UYVY; default: @@ -80,6 +82,7 @@ case gfx::BufferFormat::UYVY_422: return VA_RT_FORMAT_YUV422; case gfx::BufferFormat::BGRX_8888: + case gfx::BufferFormat::BGRA_8888: return VA_RT_FORMAT_RGB32; default: NOTREACHED();
diff --git a/media/gpu/video_decode_accelerator_unittest.cc b/media/gpu/video_decode_accelerator_unittest.cc index 6f177c5..2b9d46c3 100644 --- a/media/gpu/video_decode_accelerator_unittest.cc +++ b/media/gpu/video_decode_accelerator_unittest.cc
@@ -370,6 +370,7 @@ gfx::GpuMemoryBufferHandle handle; handle.type = gfx::OZONE_NATIVE_PIXMAP; handle.native_pixmap_handle.fd = base::FileDescriptor(duped_fd, true); + handle.native_pixmap_handle.stride = pixmap_->GetDmaBufPitch(); handles.push_back(handle); #endif return handles;
diff --git a/mojo/edk/system/node_controller.h b/mojo/edk/system/node_controller.h index 18739d4..4e12e14 100644 --- a/mojo/edk/system/node_controller.h +++ b/mojo/edk/system/node_controller.h
@@ -21,7 +21,6 @@ #include "mojo/edk/embedder/scoped_platform_handle.h" #include "mojo/edk/system/atomic_flag.h" #include "mojo/edk/system/node_channel.h" -#include "mojo/edk/system/ports/hash_functions.h" #include "mojo/edk/system/ports/name.h" #include "mojo/edk/system/ports/node.h" #include "mojo/edk/system/ports/node_delegate.h"
diff --git a/mojo/edk/system/ports/BUILD.gn b/mojo/edk/system/ports/BUILD.gn index 1782372..239b3a4 100644 --- a/mojo/edk/system/ports/BUILD.gn +++ b/mojo/edk/system/ports/BUILD.gn
@@ -8,7 +8,6 @@ sources = [ "event.cc", "event.h", - "hash_functions.h", "message.cc", "message.h", "message_queue.cc",
diff --git a/mojo/edk/system/ports/hash_functions.h b/mojo/edk/system/ports/hash_functions.h deleted file mode 100644 index 3c91cb35..0000000 --- a/mojo/edk/system/ports/hash_functions.h +++ /dev/null
@@ -1,34 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MOJO_EDK_SYSTEM_PORTS_HASH_FUNCTIONS_H_ -#define MOJO_EDK_SYSTEM_PORTS_HASH_FUNCTIONS_H_ - -#include <functional> - -#include "mojo/edk/system/ports/name.h" - -namespace std { - -template <> -struct hash<mojo::edk::ports::PortName> { - std::size_t operator()(const mojo::edk::ports::PortName& name) const { - size_t h1 = hash<uint64_t>()(name.v1); - size_t h2 = hash<uint64_t>()(name.v2); - return h1 ^ (h2 << 1); - } -}; - -template <> -struct hash<mojo::edk::ports::NodeName> { - std::size_t operator()(const mojo::edk::ports::NodeName& name) const { - size_t h1 = hash<uint64_t>()(name.v1); - size_t h2 = hash<uint64_t>()(name.v2); - return h1 ^ (h2 << 1); - } -}; - -} // namespace std - -#endif // MOJO_EDK_SYSTEM_PORTS_HASH_FUNCTIONS_H_
diff --git a/mojo/edk/system/ports/name.h b/mojo/edk/system/ports/name.h index 8a9307d..1082719 100644 --- a/mojo/edk/system/ports/name.h +++ b/mojo/edk/system/ports/name.h
@@ -10,6 +10,8 @@ #include <ostream> #include <tuple> +#include "base/hash.h" + namespace mojo { namespace edk { namespace ports { @@ -51,4 +53,22 @@ } // namespace edk } // namespace mojo +namespace std { + +template <> +struct hash<mojo::edk::ports::PortName> { + std::size_t operator()(const mojo::edk::ports::PortName& name) const { + return base::HashInts64(name.v1, name.v2); + } +}; + +template <> +struct hash<mojo::edk::ports::NodeName> { + std::size_t operator()(const mojo::edk::ports::NodeName& name) const { + return base::HashInts64(name.v1, name.v2); + } +}; + +} // namespace std + #endif // MOJO_EDK_SYSTEM_PORTS_NAME_H_
diff --git a/mojo/edk/system/ports/node.h b/mojo/edk/system/ports/node.h index 656e2a4e..44179b8 100644 --- a/mojo/edk/system/ports/node.h +++ b/mojo/edk/system/ports/node.h
@@ -15,7 +15,6 @@ #include "base/memory/ref_counted.h" #include "base/synchronization/lock.h" #include "mojo/edk/system/ports/event.h" -#include "mojo/edk/system/ports/hash_functions.h" #include "mojo/edk/system/ports/message.h" #include "mojo/edk/system/ports/name.h" #include "mojo/edk/system/ports/port.h"
diff --git a/mojo/mojo_edk.gyp b/mojo/mojo_edk.gyp index 5982cfe..b0002a5 100644 --- a/mojo/mojo_edk.gyp +++ b/mojo/mojo_edk.gyp
@@ -29,7 +29,6 @@ 'sources': [ 'edk/system/ports/event.cc', 'edk/system/ports/event.h', - 'edk/system/ports/hash_functions.h', 'edk/system/ports/message.cc', 'edk/system/ports/message.h', 'edk/system/ports/message_queue.cc',
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/data.py b/mojo/public/tools/bindings/pylib/mojom/generate/data.py index 331d218..8c15cc944 100644 --- a/mojo/public/tools/bindings/pylib/mojom/generate/data.py +++ b/mojo/public/tools/bindings/pylib/mojom/generate/data.py
@@ -500,6 +500,14 @@ return module def OrderedModuleFromData(data): + """Convert Mojom IR to a module. + + Args: + data: The Mojom IR as a dict. + + Returns: + A mojom.generate.module.Module object. + """ module = ModuleFromData(data) for interface in module.interfaces: next_ordinal = 0
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/module.py b/mojo/public/tools/bindings/pylib/mojom/generate/module.py index 5a80a05..16bdf27e 100644 --- a/mojo/public/tools/bindings/pylib/mojom/generate/module.py +++ b/mojo/public/tools/bindings/pylib/mojom/generate/module.py
@@ -13,16 +13,98 @@ # method.AddParameter('baz', 0, mojom.INT32) +# We use our own version of __repr__ when displaying the AST, as the +# AST currently doesn't capture which nodes are reference (e.g. to +# types) and which nodes are definitions. This allows us to e.g. print +# the definition of a struct when it's defined inside a module, but +# only print its name when it's referenced in e.g. a method parameter. +def Repr(obj, as_ref=True): + """A version of __repr__ that can distinguish references. + + Sometimes we like to print an object's full representation + (e.g. with its fields) and sometimes we just want to reference an + object that was printed in full elsewhere. This function allows us + to make that distinction. + + Args: + obj: The object whose string representation we compute. + as_ref: If True, use the short reference representation. + + Returns: + A str representation of |obj|. + """ + if hasattr(obj, 'Repr'): + return obj.Repr(as_ref=as_ref) + # Since we cannot implement Repr for existing container types, we + # handle them here. + elif isinstance(obj, list): + if not obj: + return '[]' + else: + return ('[\n%s\n]' % (',\n'.join(' %s' % Repr(elem, as_ref).replace( + '\n', '\n ') for elem in obj))) + elif isinstance(obj, dict): + if not obj: + return '{}' + else: + return ('{\n%s\n}' % (',\n'.join(' %s: %s' % ( + Repr(key, as_ref).replace('\n', '\n '), + Repr(val, as_ref).replace('\n', '\n ')) + for key, val in obj.iteritems()))) + else: + return repr(obj) + + +def GenericRepr(obj, names): + """Compute generic Repr for |obj| based on the attributes in |names|. + + Args: + obj: The object to compute a Repr for. + names: A dict from attribute names to include, to booleans + specifying whether those attributes should be shown as + references or not. + + Returns: + A str representation of |obj|. + """ + def ReprIndent(name, as_ref): + return ' %s=%s' % (name, Repr(getattr(obj, name), as_ref).replace( + '\n', '\n ')) + + return '%s(\n%s\n)' % ( + obj.__class__.__name__, + ',\n'.join(ReprIndent(name, as_ref) + for (name, as_ref) in names.iteritems())) + + class Kind(object): + """Kind represents a type (e.g. int8, string). + + Attributes: + spec: A string uniquely identifying the type. May be None. + parent_kind: The enclosing type. For example, a struct defined + inside an interface has that interface as its parent. May be None. + """ def __init__(self, spec=None): self.spec = spec self.parent_kind = None + def Repr(self, as_ref=True): + return '<%s spec=%r>' % (self.__class__.__name__, self.spec) + + def __repr__(self): + # Gives us a decent __repr__ for all kinds. + return self.Repr() + class ReferenceKind(Kind): - """ReferenceKind represents pointer types and handle types. + """ReferenceKind represents pointer and handle types. + A type is nullable if null (for pointer types) or invalid handle (for handle types) is a legal value for the type. + + Attributes: + is_nullable: True if the type is nullable. """ def __init__(self, spec=None, is_nullable=False): @@ -31,6 +113,10 @@ self.is_nullable = is_nullable self.shared_definition = {} + def Repr(self, as_ref=True): + return '<%s spec=%r is_nullable=%r>' % (self.__class__.__name__, self.spec, + self.is_nullable) + def MakeNullableKind(self): assert not self.is_nullable @@ -190,6 +276,11 @@ self.default = default self.attributes = attributes + def Repr(self, as_ref=True): + # Fields are only referenced by objects which define them and thus + # they are always displayed as non-references. + return GenericRepr(self, {'name': False, 'kind': True}) + @property def min_version(self): return self.attributes.get(ATTRIBUTE_MIN_VERSION) \ @@ -223,6 +314,15 @@ self.fields = [] self.attributes = attributes + def Repr(self, as_ref=True): + if as_ref: + return '<%s name=%r imported_from=%s>' % ( + self.__class__.__name__, self.name, + Repr(self.imported_from, as_ref=True)) + else: + return GenericRepr(self, {'name': False, 'fields': False, + 'imported_from': True}) + def AddField(self, name, kind, ordinal=None, default=None, attributes=None): field = StructField(name, kind, ordinal, default, attributes) self.fields.append(field) @@ -230,6 +330,18 @@ class Union(ReferenceKind): + """A union of several kinds. + + Attributes: + name: {str} The name of the union type. + module: {Module} The defining module. + imported_from: {dict} Information about where this union was + imported from. + fields: {List[UnionField]} The members of the union. + attributes: {dict} Additional information about the union, such as + which Java class name to use to represent it in the generated + bindings. + """ ReferenceKind.AddSharedProperty('name') ReferenceKind.AddSharedProperty('module') ReferenceKind.AddSharedProperty('imported_from') @@ -248,6 +360,14 @@ self.fields = [] self.attributes = attributes + def Repr(self, as_ref=True): + if as_ref: + return '<%s spec=%r is_nullable=%r fields=%s>' % ( + self.__class__.__name__, self.spec, self.is_nullable, + Repr(self.fields)) + else: + return GenericRepr(self, {'fields': True, 'is_nullable': False}) + def AddField(self, name, kind, ordinal=None, attributes=None): field = UnionField(name, kind, ordinal, None, attributes) self.fields.append(field) @@ -255,6 +375,13 @@ class Array(ReferenceKind): + """An array. + + Attributes: + kind: {Kind} The type of the elements. May be None. + length: The number of elements. None if unknown. + """ + ReferenceKind.AddSharedProperty('kind') ReferenceKind.AddSharedProperty('length') @@ -271,8 +398,23 @@ self.kind = kind self.length = length + def Repr(self, as_ref=True): + if as_ref: + return '<%s spec=%r is_nullable=%r kind=%s length=%r>' % ( + self.__class__.__name__, self.spec, self.is_nullable, Repr(self.kind), + self.length) + else: + return GenericRepr(self, {'kind': True, 'length': False, + 'is_nullable': False}) + class Map(ReferenceKind): + """A map. + + Attributes: + key_kind: {Kind} The type of the keys. May be None. + value_kind: {Kind} The type of the elements. May be None. + """ ReferenceKind.AddSharedProperty('key_kind') ReferenceKind.AddSharedProperty('value_kind') @@ -300,6 +442,14 @@ self.key_kind = key_kind self.value_kind = value_kind + def Repr(self, as_ref=True): + if as_ref: + return '<%s spec=%r is_nullable=%r key_kind=%s value_kind=%s>' % ( + self.__class__.__name__, self.spec, self.is_nullable, + Repr(self.key_kind), Repr(self.value_kind)) + else: + return GenericRepr(self, {'key_kind': True, 'value_kind': True}) + class InterfaceRequest(ReferenceKind): ReferenceKind.AddSharedProperty('kind') @@ -340,6 +490,10 @@ self.default = default self.attributes = attributes + def Repr(self, as_ref=True): + return '<%s name=%r kind=%s>' % (self.__class__.__name__, self.name, + self.kind.Repr(as_ref=True)) + @property def min_version(self): return self.attributes.get(ATTRIBUTE_MIN_VERSION) \ @@ -355,6 +509,13 @@ self.response_parameters = None self.attributes = attributes + def Repr(self, as_ref=True): + if as_ref: + return '<%s name=%r>' % (self.__class__.__name__, self.name) + else: + return GenericRepr(self, {'name': False, 'parameters': True, + 'response_parameters': True}) + def AddParameter(self, name, kind, ordinal=None, default=None, attributes=None): parameter = Parameter(name, kind, ordinal, default, attributes) @@ -399,6 +560,13 @@ self.methods = [] self.attributes = attributes + def Repr(self, as_ref=True): + if as_ref: + return '<%s name=%r>' % (self.__class__.__name__, self.name) + else: + return GenericRepr(self, {'name': False, 'attributes': False, + 'methods': False}) + def AddMethod(self, name, ordinal=None, attributes=None): method = Method(self, name, ordinal, attributes) self.methods.append(method) @@ -452,6 +620,12 @@ self.fields = [] self.attributes = attributes + def Repr(self, as_ref=True): + if as_ref: + return '<%s name=%r>' % (self.__class__.__name__, self.name) + else: + return GenericRepr(self, {'name': False, 'fields': False}) + @property def extensible(self): return self.attributes.get(ATTRIBUTE_EXTENSIBLE, False) \ @@ -469,6 +643,19 @@ self.kinds = {} self.attributes = attributes + def __repr__(self): + # Gives us a decent __repr__ for modules. + return self.Repr() + + def Repr(self, as_ref=True): + if as_ref: + return '<%s name=%r namespace=%r>' % ( + self.__class__.__name__, self.name, self.namespace) + else: + return GenericRepr(self, {'name': False, 'namespace': False, + 'attributes': False, 'structs': False, + 'interfaces': False, 'unions': False}) + def AddInterface(self, name, attributes=None): interface = Interface(name, self, attributes) self.interfaces.append(interface)
diff --git a/mojo/public/tools/bindings/pylib/mojom/parse/parser.py b/mojo/public/tools/bindings/pylib/mojom/parse/parser.py index 996c98b0..66c1c2d0 100644 --- a/mojo/public/tools/bindings/pylib/mojom/parse/parser.py +++ b/mojo/public/tools/bindings/pylib/mojom/parse/parser.py
@@ -429,6 +429,15 @@ def Parse(source, filename): + """Parse source file to AST. + + Args: + source: The source text as a str. + filename: The filename that |source| originates from. + + Returns: + The AST as a mojom.parse.ast.Mojom object. + """ lexer = Lexer(filename) parser = Parser(lexer, source, filename)
diff --git a/mojo/public/tools/bindings/pylib/mojom/parse/translate.py b/mojo/public/tools/bindings/pylib/mojom/parse/translate.py index e457f99..8d53d25 100644 --- a/mojo/public/tools/bindings/pylib/mojom/parse/translate.py +++ b/mojo/public/tools/bindings/pylib/mojom/parse/translate.py
@@ -222,4 +222,13 @@ def Translate(tree, name): + """Translate AST to Mojom IR. + + Args: + tree: The AST as a mojom.parse.ast.Mojom object. + name: The filename as a str. + + Returns: + The Mojom IR as a dict. + """ return _MojomBuilder().Build(tree, name)
diff --git a/testing/buildbot/chromium.android.json b/testing/buildbot/chromium.android.json index c04a810..a68d8e3b0 100644 --- a/testing/buildbot/chromium.android.json +++ b/testing/buildbot/chromium.android.json
@@ -9,6 +9,408 @@ "system_webview_apk" ] }, + "Android N5X Swarm Builder": { + "gtest_tests": [ + { + "override_compile_targets": [ + "android_webview_test_apk" + ], + "override_isolate_target": "android_webview_test_apk", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ], + "hard_timeout": 960 + }, + "test": "android_webview_test_apk" + }, + { + "override_isolate_target": "android_webview_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "android_webview_unittests" + }, + { + "override_isolate_target": "base_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "base_unittests" + }, + { + "override_compile_targets": [ + "blimp_test_apk" + ], + "override_isolate_target": "blimp_test_apk", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ], + "hard_timeout": 960 + }, + "test": "blimp_test_apk" + }, + { + "override_isolate_target": "blimp_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "blimp_unittests" + }, + { + "override_isolate_target": "breakpad_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "breakpad_unittests" + }, + { + "override_isolate_target": "cc_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "cc_unittests" + }, + { + "override_compile_targets": [ + "chrome_public_test_apk" + ], + "override_isolate_target": "chrome_public_test_apk", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ], + "hard_timeout": 1200 + }, + "test": "chrome_public_test_apk" + }, + { + "override_compile_targets": [ + "chrome_sync_shell_test_apk" + ], + "override_isolate_target": "chrome_sync_shell_test_apk", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ], + "hard_timeout": 960 + }, + "test": "chrome_sync_shell_test_apk" + }, + { + "override_isolate_target": "components_browsertests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "components_browsertests" + }, + { + "override_isolate_target": "components_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "components_unittests" + }, + { + "override_isolate_target": "content_browsertests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ], + "hard_timeout": 960 + }, + "test": "content_browsertests" + }, + { + "override_compile_targets": [ + "content_shell_test_apk" + ], + "override_isolate_target": "content_shell_test_apk", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ], + "hard_timeout": 960 + }, + "test": "content_shell_test_apk" + }, + { + "override_isolate_target": "content_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "content_unittests" + }, + { + "override_isolate_target": "device_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "device_unittests" + }, + { + "override_isolate_target": "events_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "events_unittests" + }, + { + "override_isolate_target": "gl_tests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "gl_tests" + }, + { + "override_isolate_target": "gpu_ipc_service_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "gpu_ipc_service_unittests" + }, + { + "override_isolate_target": "gpu_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "gpu_unittests" + }, + { + "override_isolate_target": "ipc_tests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "ipc_tests" + }, + { + "override_isolate_target": "media_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "media_unittests" + }, + { + "override_isolate_target": "net_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "net_unittests" + }, + { + "override_isolate_target": "sandbox_linux_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "sandbox_linux_unittests" + }, + { + "override_isolate_target": "sql_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "sql_unittests" + }, + { + "override_isolate_target": "sync_unit_tests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "sync_unit_tests" + }, + { + "override_isolate_target": "ui_android_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "ui_android_unittests" + }, + { + "override_isolate_target": "ui_base_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "ui_base_unittests" + }, + { + "override_isolate_target": "ui_touch_selection_unittests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "ui_touch_selection_unittests" + }, + { + "override_isolate_target": "unit_tests", + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "device_os": "MMB29Q", + "device_type": "bullhead" + } + ] + }, + "test": "unit_tests" + } + ] + }, "Android Swarm Builder": { "gtest_tests": [ {
diff --git a/third_party/WebKit/Source/build/scripts/templates/StylePropertyShorthand.h.tmpl b/third_party/WebKit/Source/build/scripts/templates/StylePropertyShorthand.h.tmpl index 0549484..40c81bc 100644 --- a/third_party/WebKit/Source/build/scripts/templates/StylePropertyShorthand.h.tmpl +++ b/third_party/WebKit/Source/build/scripts/templates/StylePropertyShorthand.h.tmpl
@@ -58,7 +58,6 @@ const StylePropertyShorthand& {{property.lower_camel_name}}Shorthand(); {% endfor %} -const StylePropertyShorthand& borderShorthandForParsing(); const StylePropertyShorthand& animationShorthandForParsing(); const StylePropertyShorthand& transitionShorthandForParsing();
diff --git a/third_party/WebKit/Source/core/animation/Animation.cpp b/third_party/WebKit/Source/core/animation/Animation.cpp index 863087a..cb61588 100644 --- a/third_party/WebKit/Source/core/animation/Animation.cpp +++ b/third_party/WebKit/Source/core/animation/Animation.cpp
@@ -762,7 +762,7 @@ // FIXME: KeyframeEffect could notify this directly? if (!hasActiveAnimationsOnCompositor()) { destroyCompositorPlayer(); - m_compositorState.release(); + m_compositorState.clear(); } if (effectChanged && m_compositorState) { m_compositorState->effectChanged = true;
diff --git a/third_party/WebKit/Source/core/animation/BasicShapeInterpolationFunctions.cpp b/third_party/WebKit/Source/core/animation/BasicShapeInterpolationFunctions.cpp index 79084ea..8a1975bf 100644 --- a/third_party/WebKit/Source/core/animation/BasicShapeInterpolationFunctions.cpp +++ b/third_party/WebKit/Source/core/animation/BasicShapeInterpolationFunctions.cpp
@@ -75,7 +75,7 @@ PassOwnPtr<InterpolableValue> unwrap(InterpolationValue&& value) { ASSERT(value.interpolableValue); - return value.interpolableValue.release(); + return std::move(value.interpolableValue); } PassOwnPtr<InterpolableValue> convertCSSCoordinate(const CSSValue* coordinate) @@ -173,9 +173,9 @@ OwnPtr<InterpolableValue> radius; if (!(radius = convertCSSRadius(circle.radius()))) return nullptr; - list->set(CircleRadiusIndex, radius.release()); + list->set(CircleRadiusIndex, std::move(radius)); - return InterpolationValue(list.release(), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeCircleType)); + return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeCircleType)); } InterpolationValue convertBasicShape(const BasicShapeCircle& circle, double zoom) @@ -187,9 +187,9 @@ OwnPtr<InterpolableValue> radius; if (!(radius = convertRadius(circle.radius(), zoom))) return nullptr; - list->set(CircleRadiusIndex, radius.release()); + list->set(CircleRadiusIndex, std::move(radius)); - return InterpolationValue(list.release(), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeCircleType)); + return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeCircleType)); } PassOwnPtr<InterpolableValue> createNeutralValue() @@ -198,7 +198,7 @@ list->set(CircleCenterXIndex, createNeutralInterpolableCoordinate()); list->set(CircleCenterYIndex, createNeutralInterpolableCoordinate()); list->set(CircleRadiusIndex, createNeutralInterpolableRadius()); - return list.release(); + return std::move(list); } PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableValue, const CSSToLengthConversionData& conversionData) @@ -232,12 +232,12 @@ OwnPtr<InterpolableValue> radius; if (!(radius = convertCSSRadius(ellipse.radiusX()))) return nullptr; - list->set(EllipseRadiusXIndex, radius.release()); + list->set(EllipseRadiusXIndex, std::move(radius)); if (!(radius = convertCSSRadius(ellipse.radiusY()))) return nullptr; - list->set(EllipseRadiusYIndex, radius.release()); + list->set(EllipseRadiusYIndex, std::move(radius)); - return InterpolationValue(list.release(), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeEllipseType)); + return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeEllipseType)); } InterpolationValue convertBasicShape(const BasicShapeEllipse& ellipse, double zoom) @@ -249,12 +249,12 @@ OwnPtr<InterpolableValue> radius; if (!(radius = convertRadius(ellipse.radiusX(), zoom))) return nullptr; - list->set(EllipseRadiusXIndex, radius.release()); + list->set(EllipseRadiusXIndex, std::move(radius)); if (!(radius = convertRadius(ellipse.radiusY(), zoom))) return nullptr; - list->set(EllipseRadiusYIndex, radius.release()); + list->set(EllipseRadiusYIndex, std::move(radius)); - return InterpolationValue(list.release(), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeEllipseType)); + return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeEllipseType)); } PassOwnPtr<InterpolableValue> createNeutralValue() @@ -264,7 +264,7 @@ list->set(EllipseCenterYIndex, createNeutralInterpolableCoordinate()); list->set(EllipseRadiusXIndex, createNeutralInterpolableRadius()); list->set(EllipseRadiusYIndex, createNeutralInterpolableRadius()); - return list.release(); + return std::move(list); } PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableValue, const CSSToLengthConversionData& conversionData) @@ -314,7 +314,7 @@ list->set(InsetBorderBottomRightHeightIndex, convertCSSBorderRadiusHeight(inset.bottomRightRadius())); list->set(InsetBorderBottomLeftWidthIndex, convertCSSBorderRadiusWidth(inset.bottomLeftRadius())); list->set(InsetBorderBottomLeftHeightIndex, convertCSSBorderRadiusHeight(inset.bottomLeftRadius())); - return InterpolationValue(list.release(), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeInsetType)); + return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeInsetType)); } InterpolationValue convertBasicShape(const BasicShapeInset& inset, double zoom) @@ -333,7 +333,7 @@ list->set(InsetBorderBottomRightHeightIndex, convertLength(inset.bottomRightRadius().height(), zoom)); list->set(InsetBorderBottomLeftWidthIndex, convertLength(inset.bottomLeftRadius().width(), zoom)); list->set(InsetBorderBottomLeftHeightIndex, convertLength(inset.bottomLeftRadius().height(), zoom)); - return InterpolationValue(list.release(), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeInsetType)); + return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::create(BasicShape::BasicShapeInsetType)); } PassOwnPtr<InterpolableValue> createNeutralValue() @@ -352,7 +352,7 @@ list->set(InsetBorderBottomRightHeightIndex, CSSLengthInterpolationType::createNeutralInterpolableValue()); list->set(InsetBorderBottomLeftWidthIndex, CSSLengthInterpolationType::createNeutralInterpolableValue()); list->set(InsetBorderBottomLeftHeightIndex, CSSLengthInterpolationType::createNeutralInterpolableValue()); - return list.release(); + return std::move(list); } PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableValue, const CSSToLengthConversionData& conversionData) @@ -381,7 +381,7 @@ OwnPtr<InterpolableList> list = InterpolableList::create(size); for (size_t i = 0; i < size; i++) list->set(i, convertCSSLength(polygon.values()[i].get())); - return InterpolationValue(list.release(), BasicShapeNonInterpolableValue::createPolygon(polygon.getWindRule(), size)); + return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::createPolygon(polygon.getWindRule(), size)); } InterpolationValue convertBasicShape(const BasicShapePolygon& polygon, double zoom) @@ -390,7 +390,7 @@ OwnPtr<InterpolableList> list = InterpolableList::create(size); for (size_t i = 0; i < size; i++) list->set(i, convertLength(polygon.values()[i], zoom)); - return InterpolationValue(list.release(), BasicShapeNonInterpolableValue::createPolygon(polygon.getWindRule(), size)); + return InterpolationValue(std::move(list), BasicShapeNonInterpolableValue::createPolygon(polygon.getWindRule(), size)); } PassOwnPtr<InterpolableValue> createNeutralValue(const BasicShapeNonInterpolableValue& nonInterpolableValue) @@ -398,7 +398,7 @@ OwnPtr<InterpolableList> list = InterpolableList::create(nonInterpolableValue.size()); for (size_t i = 0; i < nonInterpolableValue.size(); i++) list->set(i, CSSLengthInterpolationType::createNeutralInterpolableValue()); - return list.release(); + return std::move(list); } PassRefPtr<BasicShape> createBasicShape(const InterpolableValue& interpolableValue, const BasicShapeNonInterpolableValue& nonInterpolableValue, const CSSToLengthConversionData& conversionData)
diff --git a/third_party/WebKit/Source/core/animation/CSSBasicShapeInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSBasicShapeInterpolationType.cpp index 71617dc5..0aabc32d 100644 --- a/third_party/WebKit/Source/core/animation/CSSBasicShapeInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSBasicShapeInterpolationType.cpp
@@ -96,7 +96,7 @@ { if (!BasicShapeInterpolationFunctions::shapesAreCompatible(*start.nonInterpolableValue, *end.nonInterpolableValue)) return nullptr; - return PairwiseInterpolationValue(start.interpolableValue.release(), end.interpolableValue.release(), start.nonInterpolableValue.release()); + return PairwiseInterpolationValue(std::move(start.interpolableValue), std::move(end.interpolableValue), start.nonInterpolableValue.release()); } InterpolationValue CSSBasicShapeInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const
diff --git a/third_party/WebKit/Source/core/animation/CSSBorderImageLengthBoxInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSBorderImageLengthBoxInterpolationType.cpp index 4feaa9e..c32c70a7 100644 --- a/third_party/WebKit/Source/core/animation/CSSBorderImageLengthBoxInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSBorderImageLengthBoxInterpolationType.cpp
@@ -147,12 +147,12 @@ InterpolationValue convertedSide = CSSLengthInterpolationType::maybeConvertLength(side.length(), zoom); if (!convertedSide) return nullptr; - list->set(i, convertedSide.interpolableValue.release()); + list->set(i, std::move(convertedSide.interpolableValue)); nonInterpolableValues[i] = convertedSide.nonInterpolableValue.release(); } } - return InterpolationValue(list.release(), CSSBorderImageLengthBoxNonInterpolableValue::create(SideNumbers(box), std::move(nonInterpolableValues))); + return InterpolationValue(std::move(list), CSSBorderImageLengthBoxNonInterpolableValue::create(SideNumbers(box), std::move(nonInterpolableValues))); } } // namespace @@ -207,12 +207,12 @@ InterpolationValue convertedSide = CSSLengthInterpolationType::maybeConvertCSSValue(side); if (!convertedSide) return nullptr; - list->set(i, convertedSide.interpolableValue.release()); + list->set(i, std::move(convertedSide.interpolableValue)); nonInterpolableValues[i] = convertedSide.nonInterpolableValue.release(); } } - return InterpolationValue(list.release(), CSSBorderImageLengthBoxNonInterpolableValue::create(SideNumbers(quad), std::move(nonInterpolableValues))); + return InterpolationValue(std::move(list), CSSBorderImageLengthBoxNonInterpolableValue::create(SideNumbers(quad), std::move(nonInterpolableValues))); } InterpolationValue CSSBorderImageLengthBoxInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const @@ -229,7 +229,7 @@ if (startSideNumbers != endSideNumbers) return nullptr; - return PairwiseInterpolationValue(start.interpolableValue.release(), end.interpolableValue.release(), start.nonInterpolableValue.release()); + return PairwiseInterpolationValue(std::move(start.interpolableValue), std::move(end.interpolableValue), start.nonInterpolableValue.release()); } void CSSBorderImageLengthBoxInterpolationType::composite(UnderlyingValueOwner& underlyingValueOwner, double underlyingFraction, const InterpolationValue& value, double interpolationFraction) const
diff --git a/third_party/WebKit/Source/core/animation/CSSClipInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSClipInterpolationType.cpp index 6fbb19e..e27f941 100644 --- a/third_party/WebKit/Source/core/animation/CSSClipInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSClipInterpolationType.cpp
@@ -148,7 +148,7 @@ { if (length.isAuto()) return InterpolableList::create(0); - return CSSLengthInterpolationType::maybeConvertLength(length, zoom).interpolableValue.release(); + return CSSLengthInterpolationType::maybeConvertLength(length, zoom).interpolableValue; } static InterpolationValue createClipValue(const LengthBox& clip, double zoom) @@ -158,7 +158,7 @@ list->set(ClipRight, convertClipComponent(clip.right(), zoom)); list->set(ClipBottom, convertClipComponent(clip.bottom(), zoom)); list->set(ClipLeft, convertClipComponent(clip.left(), zoom)); - return InterpolationValue(list.release(), CSSClipNonInterpolableValue::create(ClipAutos(clip))); + return InterpolationValue(std::move(list), CSSClipNonInterpolableValue::create(ClipAutos(clip))); } InterpolationValue CSSClipInterpolationType::maybeConvertNeutral(const InterpolationValue& underlying, ConversionCheckers& conversionCheckers) const @@ -198,7 +198,7 @@ { if (isCSSAuto(length)) return InterpolableList::create(0); - return CSSLengthInterpolationType::maybeConvertCSSValue(length).interpolableValue.release(); + return CSSLengthInterpolationType::maybeConvertCSSValue(length).interpolableValue; } InterpolationValue CSSClipInterpolationType::maybeConvertValue(const CSSValue& value, const StyleResolverState& state, ConversionCheckers&) const @@ -216,7 +216,7 @@ isCSSAuto(*quad.right()), isCSSAuto(*quad.bottom()), isCSSAuto(*quad.left())); - return InterpolationValue(list.release(), CSSClipNonInterpolableValue::create(autos)); + return InterpolationValue(std::move(list), CSSClipNonInterpolableValue::create(autos)); } InterpolationValue CSSClipInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const @@ -232,7 +232,7 @@ const ClipAutos& endAutos = toCSSClipNonInterpolableValue(*end.nonInterpolableValue).clipAutos(); if (startAutos != endAutos) return nullptr; - return PairwiseInterpolationValue(start.interpolableValue.release(), end.interpolableValue.release(), start.nonInterpolableValue.release()); + return PairwiseInterpolationValue(std::move(start.interpolableValue), std::move(end.interpolableValue), start.nonInterpolableValue.release()); } void CSSClipInterpolationType::composite(UnderlyingValueOwner& underlyingValueOwner, double underlyingFraction, const InterpolationValue& value, double interpolationFraction) const
diff --git a/third_party/WebKit/Source/core/animation/CSSColorInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSColorInterpolationType.cpp index 318df27de..e8c09fa5 100644 --- a/third_party/WebKit/Source/core/animation/CSSColorInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSColorInterpolationType.cpp
@@ -30,7 +30,7 @@ OwnPtr<InterpolableList> list = InterpolableList::create(InterpolableColorIndexCount); for (int i = 0; i < InterpolableColorIndexCount; i++) list->set(i, InterpolableNumber::create(i == index)); - return list.release(); + return std::move(list); } PassOwnPtr<InterpolableValue> CSSColorInterpolationType::createInterpolableColor(const Color& color) @@ -44,7 +44,7 @@ list->set(WebkitActivelink, InterpolableNumber::create(0)); list->set(WebkitLink, InterpolableNumber::create(0)); list->set(QuirkInherit, InterpolableNumber::create(0)); - return list.release(); + return std::move(list); } PassOwnPtr<InterpolableValue> CSSColorInterpolationType::createInterpolableColor(CSSValueID keyword) @@ -193,8 +193,8 @@ return nullptr; OwnPtr<InterpolableList> colorPair = InterpolableList::create(InterpolableColorPairIndexCount); colorPair->set(Unvisited, interpolableColor->clone()); - colorPair->set(Visited, interpolableColor.release()); - return InterpolationValue(colorPair.release()); + colorPair->set(Visited, std::move(interpolableColor)); + return InterpolationValue(std::move(colorPair)); } InterpolationValue CSSColorInterpolationType::convertStyleColorPair(const StyleColor& unvisitedColor, const StyleColor& visitedColor) const @@ -202,7 +202,7 @@ OwnPtr<InterpolableList> colorPair = InterpolableList::create(InterpolableColorPairIndexCount); colorPair->set(Unvisited, createInterpolableColor(unvisitedColor)); colorPair->set(Visited, createInterpolableColor(visitedColor)); - return InterpolationValue(colorPair.release()); + return InterpolationValue(std::move(colorPair)); } InterpolationValue CSSColorInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const
diff --git a/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp index 91eb2021..f7bee75 100644 --- a/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp
@@ -73,10 +73,10 @@ InterpolationValue filterResult = FilterInterpolationFunctions::maybeConvertFilter(*filterOperations.operations()[i], zoom); if (!filterResult) return nullptr; - interpolableList->set(i, filterResult.interpolableValue.release()); + interpolableList->set(i, std::move(filterResult.interpolableValue)); nonInterpolableValues[i] = filterResult.nonInterpolableValue.release(); } - return InterpolationValue(interpolableList.release(), NonInterpolableList::create(std::move(nonInterpolableValues))); + return InterpolationValue(std::move(interpolableList), NonInterpolableList::create(std::move(nonInterpolableValues))); } } // namespace @@ -117,10 +117,10 @@ InterpolationValue itemResult = FilterInterpolationFunctions::maybeConvertCSSFilter(*list.item(i)); if (!itemResult) return nullptr; - interpolableList->set(i, itemResult.interpolableValue.release()); + interpolableList->set(i, std::move(itemResult.interpolableValue)); nonInterpolableValues[i] = itemResult.nonInterpolableValue.release(); } - return InterpolationValue(interpolableList.release(), NonInterpolableList::create(std::move(nonInterpolableValues))); + return InterpolationValue(std::move(interpolableList), NonInterpolableList::create(std::move(nonInterpolableValues))); } InterpolationValue CSSFilterListInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const @@ -142,7 +142,7 @@ } if (startLength == endLength) - return PairwiseInterpolationValue(start.interpolableValue.release(), end.interpolableValue.release(), start.nonInterpolableValue.release()); + return PairwiseInterpolationValue(std::move(start.interpolableValue), std::move(end.interpolableValue), start.nonInterpolableValue.release()); // Extend the shorter InterpolableList with neutral values that are compatible with corresponding filters in the longer list. InterpolationValue& shorter = startLength < endLength ? start : end; @@ -154,13 +154,13 @@ OwnPtr<InterpolableList> extendedInterpolableList = InterpolableList::create(longerLength); for (size_t i = 0; i < longerLength; i++) { if (i < shorterLength) - extendedInterpolableList->set(i, shorterInterpolableList.getMutable(i).release()); + extendedInterpolableList->set(i, std::move(shorterInterpolableList.getMutable(i))); else extendedInterpolableList->set(i, FilterInterpolationFunctions::createNoneValue(*longerNonInterpolableList.get(i))); } - shorter.interpolableValue = extendedInterpolableList.release(); + shorter.interpolableValue = std::move(extendedInterpolableList); - return PairwiseInterpolationValue(start.interpolableValue.release(), end.interpolableValue.release(), longer.nonInterpolableValue.release()); + return PairwiseInterpolationValue(std::move(start.interpolableValue), std::move(end.interpolableValue), longer.nonInterpolableValue.release()); } void CSSFilterListInterpolationType::composite(UnderlyingValueOwner& underlyingValueOwner, double underlyingFraction, const InterpolationValue& value, double interpolationFraction) const @@ -191,11 +191,11 @@ OwnPtr<InterpolableList> extendedInterpolableList = InterpolableList::create(length); for (size_t i = 0; i < length; i++) { if (i < underlyingLength) - extendedInterpolableList->set(i, underlyingInterpolableList.getMutable(i).release()); + extendedInterpolableList->set(i, std::move(underlyingInterpolableList.getMutable(i))); else extendedInterpolableList->set(i, interpolableList.get(i)->clone()); } - underlyingValueOwner.mutableValue().interpolableValue = extendedInterpolableList.release(); + underlyingValueOwner.mutableValue().interpolableValue = std::move(extendedInterpolableList); // const_cast to take a ref. underlyingValueOwner.mutableValue().nonInterpolableValue = const_cast<NonInterpolableValue*>(value.nonInterpolableValue.get()); }
diff --git a/third_party/WebKit/Source/core/animation/CSSFontSizeInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSFontSizeInterpolationType.cpp index 388d58b5..76581ae 100644 --- a/third_party/WebKit/Source/core/animation/CSSFontSizeInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSFontSizeInterpolationType.cpp
@@ -77,9 +77,9 @@ InterpolationValue CSSFontSizeInterpolationType::maybeConvertValue(const CSSValue& value, const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { - OwnPtr<InterpolableValue> result = CSSLengthInterpolationType::maybeConvertCSSValue(value).interpolableValue.release(); + OwnPtr<InterpolableValue> result = CSSLengthInterpolationType::maybeConvertCSSValue(value).interpolableValue; if (result) - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); if (!value.isPrimitiveValue() || !toCSSPrimitiveValue(value).isValueID()) return nullptr;
diff --git a/third_party/WebKit/Source/core/animation/CSSImageListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSImageListInterpolationType.cpp index 26c4180..22d1ed50 100644 --- a/third_party/WebKit/Source/core/animation/CSSImageListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSImageListInterpolationType.cpp
@@ -114,10 +114,10 @@ InterpolationValue component = CSSImageInterpolationType::maybeConvertCSSValue(*valueList.item(i), false); if (!component) return nullptr; - interpolableList->set(i, component.interpolableValue.release()); + interpolableList->set(i, std::move(component.interpolableValue)); nonInterpolableValues[i] = component.nonInterpolableValue.release(); } - return InterpolationValue(interpolableList.release(), NonInterpolableList::create(std::move(nonInterpolableValues))); + return InterpolationValue(std::move(interpolableList), NonInterpolableList::create(std::move(nonInterpolableValues))); } PairwiseInterpolationValue CSSImageListInterpolationType::maybeMergeSingles(InterpolationValue&& start, InterpolationValue&& end) const
diff --git a/third_party/WebKit/Source/core/animation/CSSImageSliceInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSImageSliceInterpolationType.cpp index b1c8a772..28e27340 100644 --- a/third_party/WebKit/Source/core/animation/CSSImageSliceInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSImageSliceInterpolationType.cpp
@@ -141,7 +141,7 @@ list->set(i, InterpolableNumber::create(side.isFixed() ? side.pixels() / zoom : side.percent())); } - return InterpolationValue(list.release(), CSSImageSliceNonInterpolableValue::create(SliceTypes(slice))); + return InterpolationValue(std::move(list), CSSImageSliceNonInterpolableValue::create(SliceTypes(slice))); } } // namespace @@ -189,7 +189,7 @@ list->set(i, InterpolableNumber::create(sides[i]->getDoubleValue())); } - return InterpolationValue(list.release(), CSSImageSliceNonInterpolableValue::create(SliceTypes(slice))); + return InterpolationValue(std::move(list), CSSImageSliceNonInterpolableValue::create(SliceTypes(slice))); } InterpolationValue CSSImageSliceInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const @@ -206,7 +206,7 @@ if (startSliceTypes != endSliceTypes) return nullptr; - return PairwiseInterpolationValue(start.interpolableValue.release(), end.interpolableValue.release(), start.nonInterpolableValue.release()); + return PairwiseInterpolationValue(std::move(start.interpolableValue), std::move(end.interpolableValue), start.nonInterpolableValue.release()); } void CSSImageSliceInterpolationType::composite(UnderlyingValueOwner& underlyingValueOwner, double underlyingFraction, const InterpolationValue& value, double interpolationFraction) const
diff --git a/third_party/WebKit/Source/core/animation/CSSLengthInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSLengthInterpolationType.cpp index 4fad24c4..4ee4984 100644 --- a/third_party/WebKit/Source/core/animation/CSSLengthInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSLengthInterpolationType.cpp
@@ -56,14 +56,14 @@ { OwnPtr<InterpolableList> interpolableList = createNeutralInterpolableValue(); interpolableList->set(CSSPrimitiveValue::UnitTypePixels, InterpolableNumber::create(pixels)); - return interpolableList.release(); + return std::move(interpolableList); } InterpolationValue CSSLengthInterpolationType::createInterpolablePercent(double percent) { OwnPtr<InterpolableList> interpolableList = createNeutralInterpolableValue(); interpolableList->set(CSSPrimitiveValue::UnitTypePercentage, InterpolableNumber::create(percent)); - return InterpolationValue(interpolableList.release(), CSSLengthNonInterpolableValue::create(true)); + return InterpolationValue(std::move(interpolableList), CSSLengthNonInterpolableValue::create(true)); } InterpolationValue CSSLengthInterpolationType::maybeConvertLength(const Length& length, float zoom) @@ -76,7 +76,7 @@ values->set(CSSPrimitiveValue::UnitTypePixels, InterpolableNumber::create(pixelsAndPercent.pixels / zoom)); values->set(CSSPrimitiveValue::UnitTypePercentage, InterpolableNumber::create(pixelsAndPercent.percent)); - return InterpolationValue(values.release(), CSSLengthNonInterpolableValue::create(length.hasPercent())); + return InterpolationValue(std::move(values), CSSLengthNonInterpolableValue::create(length.hasPercent())); } PassOwnPtr<InterpolableList> CSSLengthInterpolationType::createNeutralInterpolableValue() @@ -85,14 +85,14 @@ OwnPtr<InterpolableList> values = InterpolableList::create(length); for (size_t i = 0; i < length; i++) values->set(i, InterpolableNumber::create(0)); - return values.release(); + return values; } PairwiseInterpolationValue CSSLengthInterpolationType::staticMergeSingleConversions(InterpolationValue&& start, InterpolationValue&& end) { return PairwiseInterpolationValue( - start.interpolableValue.release(), - end.interpolableValue.release(), + std::move(start.interpolableValue), + std::move(end.interpolableValue), CSSLengthNonInterpolableValue::merge(start.nonInterpolableValue.get(), end.nonInterpolableValue.get())); } @@ -141,7 +141,7 @@ values->set(i, InterpolableNumber::create(lengthArray.values[i])); bool hasPercentage = lengthArray.typeFlags.get(CSSPrimitiveValue::UnitTypePercentage); - return InterpolationValue(values.release(), CSSLengthNonInterpolableValue::create(hasPercentage)); + return InterpolationValue(std::move(values), CSSLengthNonInterpolableValue::create(hasPercentage)); } class ParentLengthChecker : public InterpolationType::ConversionChecker {
diff --git a/third_party/WebKit/Source/core/animation/CSSMotionRotationInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSMotionRotationInterpolationType.cpp index 8b43359..34cf81d3 100644 --- a/third_party/WebKit/Source/core/animation/CSSMotionRotationInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSMotionRotationInterpolationType.cpp
@@ -115,8 +115,8 @@ if (startType != endType) return nullptr; return PairwiseInterpolationValue( - start.interpolableValue.release(), - end.interpolableValue.release(), + std::move(start.interpolableValue), + std::move(end.interpolableValue), start.nonInterpolableValue.release()); }
diff --git a/third_party/WebKit/Source/core/animation/CSSPaintInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSPaintInterpolationType.cpp index 9516dde..2dcae1b 100644 --- a/third_party/WebKit/Source/core/animation/CSSPaintInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSPaintInterpolationType.cpp
@@ -76,7 +76,7 @@ OwnPtr<InterpolableValue> interpolableColor = CSSColorInterpolationType::maybeCreateInterpolableColor(value); if (!interpolableColor) return nullptr; - return InterpolationValue(interpolableColor.release()); + return InterpolationValue(std::move(interpolableColor)); } InterpolationValue CSSPaintInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const
diff --git a/third_party/WebKit/Source/core/animation/CSSPathInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSPathInterpolationType.cpp index 57775807..97c3e9c 100644 --- a/third_party/WebKit/Source/core/animation/CSSPathInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSPathInterpolationType.cpp
@@ -18,7 +18,7 @@ environment.state().style()->setD(nullptr); return; } - environment.state().style()->setD(StylePath::create(pathByteStream.release())); + environment.state().style()->setD(StylePath::create(std::move(pathByteStream))); } void CSSPathInterpolationType::composite(UnderlyingValueOwner& underlyingValueOwner, double underlyingFraction, const InterpolationValue& value, double interpolationFraction) const
diff --git a/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp index 69b9128..bbb48a1a 100644 --- a/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp
@@ -42,7 +42,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(3); for (size_t i = 0; i < 3; i++) result->set(i, InterpolableNumber::create(array[i])); - return result.release(); + return std::move(result); } bool operator==(const Scale& other) const @@ -169,8 +169,8 @@ PairwiseInterpolationValue CSSScaleInterpolationType::maybeMergeSingles(InterpolationValue&& start, InterpolationValue&& end) const { return PairwiseInterpolationValue( - start.interpolableValue.release(), - end.interpolableValue.release(), + std::move(start.interpolableValue), + std::move(end.interpolableValue), CSSScaleNonInterpolableValue::merge( toCSSScaleNonInterpolableValue(*start.nonInterpolableValue), toCSSScaleNonInterpolableValue(*end.nonInterpolableValue)));
diff --git a/third_party/WebKit/Source/core/animation/CSSTextIndentInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSTextIndentInterpolationType.cpp index 4801597..5aac056 100644 --- a/third_party/WebKit/Source/core/animation/CSSTextIndentInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSTextIndentInterpolationType.cpp
@@ -105,7 +105,7 @@ { InterpolationValue convertedLength = CSSLengthInterpolationType::maybeConvertLength(length, zoom); ASSERT(convertedLength); - return InterpolationValue(convertedLength.interpolableValue.release(), CSSTextIndentNonInterpolableValue::create(convertedLength.nonInterpolableValue.release(), mode)); + return InterpolationValue(std::move(convertedLength.interpolableValue), CSSTextIndentNonInterpolableValue::create(convertedLength.nonInterpolableValue.release(), mode)); } } // namespace @@ -149,7 +149,7 @@ ASSERT(length); return InterpolationValue( - length.interpolableValue.release(), + std::move(length.interpolableValue), CSSTextIndentNonInterpolableValue::create(length.nonInterpolableValue.release(), IndentMode(line, type))); } @@ -168,8 +168,8 @@ return nullptr; PairwiseInterpolationValue result = CSSLengthInterpolationType::staticMergeSingleConversions( - InterpolationValue(start.interpolableValue.release(), startNonInterpolableValue.lengthNonInterpolableValue().release()), - InterpolationValue(end.interpolableValue.release(), endNonInterpolableValue.lengthNonInterpolableValue().release())); + InterpolationValue(std::move(start.interpolableValue), startNonInterpolableValue.lengthNonInterpolableValue().release()), + InterpolationValue(std::move(end.interpolableValue), endNonInterpolableValue.lengthNonInterpolableValue().release())); result.nonInterpolableValue = CSSTextIndentNonInterpolableValue::create(result.nonInterpolableValue.release(), startNonInterpolableValue.mode()); return result; }
diff --git a/third_party/WebKit/Source/core/animation/CSSTransformInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSTransformInterpolationType.cpp index 37668598..445dee26 100644 --- a/third_party/WebKit/Source/core/animation/CSSTransformInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSTransformInterpolationType.cpp
@@ -163,7 +163,7 @@ OwnPtr<InterpolationType::ConversionChecker> lengthUnitsChecker = LengthUnitsChecker::maybeCreate(std::move(lengthArray), state); if (lengthUnitsChecker) - conversionCheckers.append(lengthUnitsChecker.release()); + conversionCheckers.append(std::move(lengthUnitsChecker)); } TransformOperations transform;
diff --git a/third_party/WebKit/Source/core/animation/CSSTranslateInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSTranslateInterpolationType.cpp index 519ab0e..fc8810a 100644 --- a/third_party/WebKit/Source/core/animation/CSSTranslateInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSTranslateInterpolationType.cpp
@@ -53,7 +53,7 @@ result->set(TranslateX, CSSLengthInterpolationType::createNeutralInterpolableValue()); result->set(TranslateY, CSSLengthInterpolationType::createNeutralInterpolableValue()); result->set(TranslateZ, CSSLengthInterpolationType::createNeutralInterpolableValue()); - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } InterpolationValue convertTranslateOperation(const TranslateTransformOperation* translate, double zoom) @@ -62,10 +62,10 @@ return createNeutralValue(); OwnPtr<InterpolableList> result = InterpolableList::create(TranslateComponentIndexCount); - result->set(TranslateX, CSSLengthInterpolationType::maybeConvertLength(translate->x(), zoom).interpolableValue.release()); - result->set(TranslateY, CSSLengthInterpolationType::maybeConvertLength(translate->y(), zoom).interpolableValue.release()); - result->set(TranslateZ, CSSLengthInterpolationType::maybeConvertLength(Length(translate->z(), Fixed), zoom).interpolableValue.release()); - return InterpolationValue(result.release()); + result->set(TranslateX, CSSLengthInterpolationType::maybeConvertLength(translate->x(), zoom).interpolableValue); + result->set(TranslateY, CSSLengthInterpolationType::maybeConvertLength(translate->y(), zoom).interpolableValue); + result->set(TranslateZ, CSSLengthInterpolationType::maybeConvertLength(Length(translate->z(), Fixed), zoom).interpolableValue); + return InterpolationValue(std::move(result)); } } // namespace @@ -106,9 +106,9 @@ } else { component = InterpolationValue(CSSLengthInterpolationType::createNeutralInterpolableValue()); } - result->set(i, component.interpolableValue.release()); + result->set(i, std::move(component.interpolableValue)); } - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } InterpolationValue CSSTranslateInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp b/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp index fd3f332..3648c200 100644 --- a/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp +++ b/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp
@@ -617,7 +617,7 @@ OwnPtr<CompositorFilterOperations> ops = adoptPtr(CompositorFactory::current().createFilterOperations()); toCompositorFilterOperations(toAnimatableFilterOperations(value)->operations(), ops.get()); - CompositorFilterKeyframe filterKeyframe(keyframe->offset(), ops.release()); + CompositorFilterKeyframe filterKeyframe(keyframe->offset(), std::move(ops)); CompositorFilterAnimationCurve* filterCurve = static_cast<CompositorFilterAnimationCurve*>(&curve); addKeyframeWithTimingFunction(*filterCurve, filterKeyframe, keyframeTimingFunction); break; @@ -632,7 +632,7 @@ OwnPtr<CompositorTransformOperations> ops = adoptPtr(CompositorFactory::current().createTransformOperations()); toCompositorTransformOperations(toAnimatableTransform(value)->transformOperations(), ops.get()); - CompositorTransformKeyframe transformKeyframe(keyframe->offset(), ops.release()); + CompositorTransformKeyframe transformKeyframe(keyframe->offset(), std::move(ops)); CompositorTransformAnimationCurve* transformCurve = static_cast<CompositorTransformAnimationCurve*>(&curve); addKeyframeWithTimingFunction(*transformCurve, transformKeyframe, keyframeTimingFunction); break; @@ -744,7 +744,7 @@ default: ASSERT_NOT_REACHED(); } - animations.append(animation.release()); + animations.append(std::move(animation)); } ASSERT(!animations.isEmpty()); }
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp index 54471a0..3d15b50 100644 --- a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp +++ b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp
@@ -221,7 +221,7 @@ RefPtr<AnimatableDouble> value = AnimatableDouble::create(values[i]); frames->append(createReplaceOpKeyframe(CSSPropertyOpacity, value.get(), offset).get()); } - return frames.release(); + return frames; } PassOwnPtr<AnimatableValueKeyframeVector> createCompositableTransformKeyframeVector(const Vector<TransformOperations>& values) @@ -232,7 +232,7 @@ RefPtr<AnimatableTransform> value = AnimatableTransform::create(values[i], 1); frames->append(createReplaceOpKeyframe(CSSPropertyTransform, value.get(), offset).get()); } - return frames.release(); + return frames; } AnimatableValueKeyframeEffectModel* createKeyframeEffectModel(PassRefPtr<AnimatableValueKeyframe> prpFrom, PassRefPtr<AnimatableValueKeyframe> prpTo, PassRefPtr<AnimatableValueKeyframe> prpC = nullptr, PassRefPtr<AnimatableValueKeyframe> prpD = nullptr)
diff --git a/third_party/WebKit/Source/core/animation/InterpolableValue.cpp b/third_party/WebKit/Source/core/animation/InterpolableValue.cpp index d5a4c5da..084ecf8 100644 --- a/third_party/WebKit/Source/core/animation/InterpolableValue.cpp +++ b/third_party/WebKit/Source/core/animation/InterpolableValue.cpp
@@ -67,7 +67,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(m_size); for (size_t i = 0; i < m_size; i++) result->set(i, m_values[i]->cloneAndZero()); - return result.release(); + return std::move(result); } void InterpolableNumber::scale(double scale)
diff --git a/third_party/WebKit/Source/core/animation/InterpolableValueTest.cpp b/third_party/WebKit/Source/core/animation/InterpolableValueTest.cpp index dd15681d..b65d8255fc 100644 --- a/third_party/WebKit/Source/core/animation/InterpolableValueTest.cpp +++ b/third_party/WebKit/Source/core/animation/InterpolableValueTest.cpp
@@ -98,7 +98,7 @@ listB->set(1, InterpolableNumber::create(-200)); listB->set(2, InterpolableNumber::create(300)); - RefPtr<Interpolation> i = interpolateLists(listA.release(), listB.release(), 0.3); + RefPtr<Interpolation> i = interpolateLists(std::move(listA), std::move(listB), 0.3); InterpolableList* outList = toInterpolableList(interpolationValue(*i.get())); EXPECT_FLOAT_EQ(30, toInterpolableNumber(outList->get(0))->value()); EXPECT_FLOAT_EQ(-30.6f, toInterpolableNumber(outList->get(1))->value()); @@ -111,17 +111,17 @@ listA->set(0, InterpolableNumber::create(0)); OwnPtr<InterpolableList> subListA = InterpolableList::create(1); subListA->set(0, InterpolableNumber::create(100)); - listA->set(1, subListA.release()); + listA->set(1, std::move(subListA)); listA->set(2, InterpolableBool::create(false)); OwnPtr<InterpolableList> listB = InterpolableList::create(3); listB->set(0, InterpolableNumber::create(100)); OwnPtr<InterpolableList> subListB = InterpolableList::create(1); subListB->set(0, InterpolableNumber::create(50)); - listB->set(1, subListB.release()); + listB->set(1, std::move(subListB)); listB->set(2, InterpolableBool::create(true)); - RefPtr<Interpolation> i = interpolateLists(listA.release(), listB.release(), 0.5); + RefPtr<Interpolation> i = interpolateLists(std::move(listA), std::move(listB), 0.5); InterpolableList* outList = toInterpolableList(interpolationValue(*i.get())); EXPECT_FLOAT_EQ(50, toInterpolableNumber(outList->get(0))->value()); EXPECT_FLOAT_EQ(75, toInterpolableNumber(toInterpolableList(outList->get(1))->get(0))->value());
diff --git a/third_party/WebKit/Source/core/animation/InterpolationType.h b/third_party/WebKit/Source/core/animation/InterpolationType.h index e502462c..68ddba1 100644 --- a/third_party/WebKit/Source/core/animation/InterpolationType.h +++ b/third_party/WebKit/Source/core/animation/InterpolationType.h
@@ -86,8 +86,8 @@ ASSERT(!start.nonInterpolableValue); ASSERT(!end.nonInterpolableValue); return PairwiseInterpolationValue( - start.interpolableValue.release(), - end.interpolableValue.release(), + std::move(start.interpolableValue), + std::move(end.interpolableValue), nullptr); }
diff --git a/third_party/WebKit/Source/core/animation/InterpolationValue.h b/third_party/WebKit/Source/core/animation/InterpolationValue.h index 71a70102..42b2b39 100644 --- a/third_party/WebKit/Source/core/animation/InterpolationValue.h +++ b/third_party/WebKit/Source/core/animation/InterpolationValue.h
@@ -24,13 +24,13 @@ InterpolationValue(std::nullptr_t) { } InterpolationValue(InterpolationValue&& other) - : interpolableValue(other.interpolableValue.release()) + : interpolableValue(std::move(other.interpolableValue)) , nonInterpolableValue(other.nonInterpolableValue.release()) { } void operator=(InterpolationValue&& other) { - interpolableValue = other.interpolableValue.release(); + interpolableValue = std::move(other.interpolableValue); nonInterpolableValue = other.nonInterpolableValue.release(); }
diff --git a/third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp b/third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp index 0469838..cc2efeb 100644 --- a/third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp +++ b/third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp
@@ -35,8 +35,8 @@ addConversionCheckers(*interpolationType, conversionCheckers); if (result) { return PairwisePrimitiveInterpolation::create(*interpolationType, - result.startInterpolableValue.release(), - result.endInterpolableValue.release(), + std::move(result.startInterpolableValue), + std::move(result.endInterpolableValue), result.nonInterpolableValue.release()); } } @@ -54,7 +54,7 @@ InterpolationValue result = interpolationType->maybeConvertSingle(keyframe, environment, underlyingValueOwner.value(), conversionCheckers); addConversionCheckers(*interpolationType, conversionCheckers); if (result) - return TypedInterpolationValue::create(*interpolationType, result.interpolableValue.release(), result.nonInterpolableValue.release()); + return TypedInterpolationValue::create(*interpolationType, std::move(result.interpolableValue), result.nonInterpolableValue.release()); } ASSERT(keyframe.isNeutral()); return nullptr; @@ -64,7 +64,7 @@ { for (size_t i = 0; i < conversionCheckers.size(); i++) { conversionCheckers[i]->setType(type); - m_conversionCheckers.append(conversionCheckers[i].release()); + m_conversionCheckers.append(std::move(conversionCheckers[i])); } } @@ -73,7 +73,7 @@ for (const auto& interpolationType : m_interpolationTypes) { InterpolationValue result = interpolationType->maybeConvertUnderlyingValue(environment); if (result) - return TypedInterpolationValue::create(*interpolationType, result.interpolableValue.release(), result.nonInterpolableValue.release()); + return TypedInterpolationValue::create(*interpolationType, std::move(result.interpolableValue), result.nonInterpolableValue.release()); } return nullptr; } @@ -128,7 +128,7 @@ OwnPtr<PairwisePrimitiveInterpolation> pairwiseConversion = maybeConvertPairwise(environment, underlyingValueOwner); if (pairwiseConversion) { m_cachedValue = pairwiseConversion->initialValue(); - m_cachedPairConversion = pairwiseConversion.release(); + m_cachedPairConversion = std::move(pairwiseConversion); } else { m_cachedPairConversion = FlipPrimitiveInterpolation::create( convertSingleKeyframe(*m_startKeyframe, environment, underlyingValueOwner),
diff --git a/third_party/WebKit/Source/core/animation/ListInterpolationFunctions.cpp b/third_party/WebKit/Source/core/animation/ListInterpolationFunctions.cpp index 3237603..32c42ff 100644 --- a/third_party/WebKit/Source/core/animation/ListInterpolationFunctions.cpp +++ b/third_party/WebKit/Source/core/animation/ListInterpolationFunctions.cpp
@@ -47,24 +47,24 @@ if (startLength == 0 && endLength == 0) { return PairwiseInterpolationValue( - start.interpolableValue.release(), - end.interpolableValue.release(), + std::move(start.interpolableValue), + std::move(end.interpolableValue), nullptr); } if (startLength == 0) { OwnPtr<InterpolableValue> startInterpolableValue = end.interpolableValue->cloneAndZero(); return PairwiseInterpolationValue( - startInterpolableValue.release(), - end.interpolableValue.release(), + std::move(startInterpolableValue), + std::move(end.interpolableValue), end.nonInterpolableValue.release()); } if (endLength == 0) { OwnPtr<InterpolableValue> endInterpolableValue = start.interpolableValue->cloneAndZero(); return PairwiseInterpolationValue( - start.interpolableValue.release(), - endInterpolableValue.release(), + std::move(start.interpolableValue), + std::move(endInterpolableValue), start.nonInterpolableValue.release()); } @@ -84,14 +84,14 @@ PairwiseInterpolationValue result = mergeSingleItemConversions(std::move(start), std::move(end)); if (!result) return nullptr; - resultStartInterpolableList->set(i, result.startInterpolableValue.release()); - resultEndInterpolableList->set(i, result.endInterpolableValue.release()); + resultStartInterpolableList->set(i, std::move(result.startInterpolableValue)); + resultEndInterpolableList->set(i, std::move(result.endInterpolableValue)); resultNonInterpolableValues[i] = result.nonInterpolableValue.release(); } return PairwiseInterpolationValue( - resultStartInterpolableList.release(), - resultEndInterpolableList.release(), + std::move(resultStartInterpolableList), + std::move(resultEndInterpolableList), NonInterpolableList::create(std::move(resultNonInterpolableValues))); } @@ -107,10 +107,10 @@ OwnPtr<InterpolableList> newInterpolableList = InterpolableList::create(length); Vector<RefPtr<NonInterpolableValue>> newNonInterpolableValues(length); for (size_t i = length; i-- > 0;) { - newInterpolableList->set(i, i < currentLength ? interpolableList.getMutable(i).release() : interpolableList.get(i % currentLength)->clone()); + newInterpolableList->set(i, i < currentLength ? std::move(interpolableList.getMutable(i)) : interpolableList.get(i % currentLength)->clone()); newNonInterpolableValues[i] = nonInterpolableList.get(i % currentLength); } - value.interpolableValue = newInterpolableList.release(); + value.interpolableValue = std::move(newInterpolableList); value.nonInterpolableValue = NonInterpolableList::create(std::move(newNonInterpolableValues)); }
diff --git a/third_party/WebKit/Source/core/animation/ListInterpolationFunctions.h b/third_party/WebKit/Source/core/animation/ListInterpolationFunctions.h index b8b7ea19..b80dd09f 100644 --- a/third_party/WebKit/Source/core/animation/ListInterpolationFunctions.h +++ b/third_party/WebKit/Source/core/animation/ListInterpolationFunctions.h
@@ -75,10 +75,10 @@ InterpolationValue item = createItem(i); if (!item) return nullptr; - interpolableList->set(i, item.interpolableValue.release()); + interpolableList->set(i, std::move(item.interpolableValue)); nonInterpolableValues[i] = item.nonInterpolableValue.release(); } - return InterpolationValue(interpolableList.release(), NonInterpolableList::create(std::move(nonInterpolableValues))); + return InterpolationValue(std::move(interpolableList), NonInterpolableList::create(std::move(nonInterpolableValues))); } } // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/PairwiseInterpolationValue.h b/third_party/WebKit/Source/core/animation/PairwiseInterpolationValue.h index 0d16dd8..6f1d96c2 100644 --- a/third_party/WebKit/Source/core/animation/PairwiseInterpolationValue.h +++ b/third_party/WebKit/Source/core/animation/PairwiseInterpolationValue.h
@@ -24,8 +24,8 @@ PairwiseInterpolationValue(std::nullptr_t) { } PairwiseInterpolationValue(PairwiseInterpolationValue&& other) - : startInterpolableValue(other.startInterpolableValue.release()) - , endInterpolableValue(other.endInterpolableValue.release()) + : startInterpolableValue(std::move(other.startInterpolableValue)) + , endInterpolableValue(std::move(other.endInterpolableValue)) , nonInterpolableValue(other.nonInterpolableValue.release()) { }
diff --git a/third_party/WebKit/Source/core/animation/PathInterpolationFunctions.cpp b/third_party/WebKit/Source/core/animation/PathInterpolationFunctions.cpp index da6cc36..c69d7ec 100644 --- a/third_party/WebKit/Source/core/animation/PathInterpolationFunctions.cpp +++ b/third_party/WebKit/Source/core/animation/PathInterpolationFunctions.cpp
@@ -63,13 +63,13 @@ OwnPtr<InterpolableList> pathArgs = InterpolableList::create(length); for (size_t i = 0; i < interpolablePathSegs.size(); i++) - pathArgs->set(i, interpolablePathSegs[i].release()); + pathArgs->set(i, std::move(interpolablePathSegs[i])); OwnPtr<InterpolableList> result = InterpolableList::create(PathComponentIndexCount); - result->set(PathArgsIndex, pathArgs.release()); + result->set(PathArgsIndex, std::move(pathArgs)); result->set(PathNeutralIndex, InterpolableNumber::create(0)); - return InterpolationValue(result.release(), SVGPathNonInterpolableValue::create(pathSegTypes)); + return InterpolationValue(std::move(result), SVGPathNonInterpolableValue::create(pathSegTypes)); } InterpolationValue PathInterpolationFunctions::convertValue(const StylePath* stylePath) @@ -114,7 +114,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(PathComponentIndexCount); result->set(PathArgsIndex, toInterpolableList(*underlying.interpolableValue).get(PathArgsIndex)->cloneAndZero()); result->set(PathNeutralIndex, InterpolableNumber::create(1)); - return InterpolationValue(result.release(), underlying.nonInterpolableValue.get()); + return InterpolationValue(std::move(result), underlying.nonInterpolableValue.get()); } static bool pathSegTypesMatch(const Vector<SVGPathSegType>& a, const Vector<SVGPathSegType>& b) @@ -137,7 +137,7 @@ if (!pathSegTypesMatch(startTypes, endTypes)) return nullptr; - return PairwiseInterpolationValue(start.interpolableValue.release(), end.interpolableValue.release(), end.nonInterpolableValue.release()); + return PairwiseInterpolationValue(std::move(start.interpolableValue), std::move(end.interpolableValue), end.nonInterpolableValue.release()); } void PathInterpolationFunctions::composite(UnderlyingValueOwner& underlyingValueOwner, double underlyingFraction, const InterpolationType& type, const InterpolationValue& value) @@ -165,7 +165,7 @@ toSVGPathNonInterpolableValue(nonInterpolableValue)->pathSegTypes()); SVGPathByteStreamBuilder builder(*pathByteStream); SVGPathParser::parsePath(source, builder); - return pathByteStream.release(); + return pathByteStream; } } // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/PropertyInterpolationTypesMapping.cpp b/third_party/WebKit/Source/core/animation/PropertyInterpolationTypesMapping.cpp index 7845e33..2e830b0c 100644 --- a/third_party/WebKit/Source/core/animation/PropertyInterpolationTypesMapping.cpp +++ b/third_party/WebKit/Source/core/animation/PropertyInterpolationTypesMapping.cpp
@@ -372,7 +372,7 @@ applicableTypes->append(adoptPtr(new SVGValueInterpolationType(attribute))); } - auto addResult = applicableTypesMap.add(property, applicableTypes.release()); + auto addResult = applicableTypesMap.add(property, std::move(applicableTypes)); return *addResult.storedValue->value.get(); }
diff --git a/third_party/WebKit/Source/core/animation/SVGIntegerOptionalIntegerInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGIntegerOptionalIntegerInterpolationType.cpp index 6d5773c5..e67c712 100644 --- a/third_party/WebKit/Source/core/animation/SVGIntegerOptionalIntegerInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/SVGIntegerOptionalIntegerInterpolationType.cpp
@@ -14,7 +14,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(2); result->set(0, InterpolableNumber::create(0)); result->set(1, InterpolableNumber::create(0)); - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } InterpolationValue SVGIntegerOptionalIntegerInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const @@ -26,7 +26,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(2); result->set(0, InterpolableNumber::create(integerOptionalInteger.firstInteger()->value())); result->set(1, InterpolableNumber::create(integerOptionalInteger.secondInteger()->value())); - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } static SVGInteger* toPositiveInteger(const InterpolableValue* number)
diff --git a/third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp index 1706ab9..275bc83 100644 --- a/third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/SVGLengthInterpolationType.cpp
@@ -81,7 +81,7 @@ for (size_t i = 0; i < numLengthInterpolatedUnits; ++i) listOfValues->set(i, InterpolableNumber::create(0)); - return listOfValues.release(); + return std::move(listOfValues); } InterpolationValue SVGLengthInterpolationType::convertSVGLength(const SVGLength& length) @@ -96,7 +96,7 @@ for (size_t i = 0; i < numLengthInterpolatedUnits; ++i) listOfValues->set(i, InterpolableNumber::create(values[i])); - return InterpolationValue(listOfValues.release()); + return InterpolationValue(std::move(listOfValues)); } SVGLength* SVGLengthInterpolationType::resolveInterpolableSVGLength(const InterpolableValue& interpolableValue, const SVGLengthContext& lengthContext, SVGLengthMode unitMode, bool negativeValuesForbidden)
diff --git a/third_party/WebKit/Source/core/animation/SVGLengthListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGLengthListInterpolationType.cpp index cc0ebe2..e70381b 100644 --- a/third_party/WebKit/Source/core/animation/SVGLengthListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/SVGLengthListInterpolationType.cpp
@@ -22,7 +22,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(underlyingLength); for (size_t i = 0; i < underlyingLength; i++) result->set(i, SVGLengthInterpolationType::neutralInterpolableValue()); - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } InterpolationValue SVGLengthListInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const @@ -34,9 +34,9 @@ OwnPtr<InterpolableList> result = InterpolableList::create(lengthList.length()); for (size_t i = 0; i < lengthList.length(); i++) { InterpolationValue component = SVGLengthInterpolationType::convertSVGLength(*lengthList.at(i)); - result->set(i, component.interpolableValue.release()); + result->set(i, std::move(component.interpolableValue)); } - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } PairwiseInterpolationValue SVGLengthListInterpolationType::maybeMergeSingles(InterpolationValue&& start, InterpolationValue&& end) const
diff --git a/third_party/WebKit/Source/core/animation/SVGNumberListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGNumberListInterpolationType.cpp index d227993..4eaa1e74 100644 --- a/third_party/WebKit/Source/core/animation/SVGNumberListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/SVGNumberListInterpolationType.cpp
@@ -21,7 +21,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(underlyingLength); for (size_t i = 0; i < underlyingLength; i++) result->set(i, InterpolableNumber::create(0)); - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } InterpolationValue SVGNumberListInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const @@ -33,7 +33,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(numberList.length()); for (size_t i = 0; i < numberList.length(); i++) result->set(i, InterpolableNumber::create(numberList.at(i)->value())); - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } PairwiseInterpolationValue SVGNumberListInterpolationType::maybeMergeSingles(InterpolationValue&& start, InterpolationValue&& end) const @@ -55,10 +55,10 @@ OwnPtr<InterpolableList> result = InterpolableList::create(paddedLength); size_t i = 0; for (; i < list.length(); i++) - result->set(i, list.getMutable(i).release()); + result->set(i, std::move(list.getMutable(i))); for (; i < paddedLength; i++) result->set(i, InterpolableNumber::create(0)); - listPointer = result.release(); + listPointer = std::move(result); } void SVGNumberListInterpolationType::composite(UnderlyingValueOwner& underlyingValueOwner, double underlyingFraction, const InterpolationValue& value, double interpolationFraction) const
diff --git a/third_party/WebKit/Source/core/animation/SVGNumberOptionalNumberInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGNumberOptionalNumberInterpolationType.cpp index 8d874d2..b4fcff91 100644 --- a/third_party/WebKit/Source/core/animation/SVGNumberOptionalNumberInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/SVGNumberOptionalNumberInterpolationType.cpp
@@ -14,7 +14,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(2); result->set(0, InterpolableNumber::create(0)); result->set(1, InterpolableNumber::create(0)); - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } InterpolationValue SVGNumberOptionalNumberInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const @@ -26,7 +26,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(2); result->set(0, InterpolableNumber::create(numberOptionalNumber.firstNumber()->value())); result->set(1, InterpolableNumber::create(numberOptionalNumber.secondNumber()->value())); - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } SVGPropertyBase* SVGNumberOptionalNumberInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue*) const
diff --git a/third_party/WebKit/Source/core/animation/SVGPathSegInterpolationFunctions.cpp b/third_party/WebKit/Source/core/animation/SVGPathSegInterpolationFunctions.cpp index 8526c8b..f317954 100644 --- a/third_party/WebKit/Source/core/animation/SVGPathSegInterpolationFunctions.cpp +++ b/third_party/WebKit/Source/core/animation/SVGPathSegInterpolationFunctions.cpp
@@ -64,7 +64,7 @@ coordinates.initialY = coordinates.currentY; } - return result.release(); + return std::move(result); } PathSegmentData consumeInterpolableSingleCoordinate(const InterpolableValue& value, SVGPathSegType segType, PathCoordinates& coordinates) @@ -95,7 +95,7 @@ result->set(3, consumeControlAxis(segment.y2(), isAbsolute, coordinates.currentY)); result->set(4, consumeCoordinateAxis(segment.x(), isAbsolute, coordinates.currentX)); result->set(5, consumeCoordinateAxis(segment.y(), isAbsolute, coordinates.currentY)); - return result.release(); + return std::move(result); } PathSegmentData consumeInterpolableCurvetoCubic(const InterpolableValue& value, SVGPathSegType segType, PathCoordinates& coordinates) @@ -121,7 +121,7 @@ result->set(1, consumeControlAxis(segment.y1(), isAbsolute, coordinates.currentY)); result->set(2, consumeCoordinateAxis(segment.x(), isAbsolute, coordinates.currentX)); result->set(3, consumeCoordinateAxis(segment.y(), isAbsolute, coordinates.currentY)); - return result.release(); + return std::move(result); } PathSegmentData consumeInterpolableCurvetoQuadratic(const InterpolableValue& value, SVGPathSegType segType, PathCoordinates& coordinates) @@ -148,7 +148,7 @@ result->set(4, InterpolableNumber::create(segment.arcAngle())); result->set(5, InterpolableBool::create(segment.largeArcFlag())); result->set(6, InterpolableBool::create(segment.sweepFlag())); - return result.release(); + return std::move(result); } PathSegmentData consumeInterpolableArc(const InterpolableValue& value, SVGPathSegType segType, PathCoordinates& coordinates) @@ -205,7 +205,7 @@ result->set(1, consumeControlAxis(segment.y2(), isAbsolute, coordinates.currentY)); result->set(2, consumeCoordinateAxis(segment.x(), isAbsolute, coordinates.currentX)); result->set(3, consumeCoordinateAxis(segment.y(), isAbsolute, coordinates.currentY)); - return result.release(); + return std::move(result); } PathSegmentData consumeInterpolableCurvetoCubicSmooth(const InterpolableValue& value, SVGPathSegType segType, PathCoordinates& coordinates)
diff --git a/third_party/WebKit/Source/core/animation/SVGPointListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGPointListInterpolationType.cpp index 18cbd21..534cd47 100644 --- a/third_party/WebKit/Source/core/animation/SVGPointListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/SVGPointListInterpolationType.cpp
@@ -22,7 +22,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(underlyingLength); for (size_t i = 0; i < underlyingLength; i++) result->set(i, InterpolableNumber::create(0)); - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } InterpolationValue SVGPointListInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const @@ -38,7 +38,7 @@ result->set(2 * i + 1, InterpolableNumber::create(point.y())); } - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } PairwiseInterpolationValue SVGPointListInterpolationType::maybeMergeSingles(InterpolationValue&& start, InterpolationValue&& end) const
diff --git a/third_party/WebKit/Source/core/animation/SVGRectInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGRectInterpolationType.cpp index 411d329..76ae445 100644 --- a/third_party/WebKit/Source/core/animation/SVGRectInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/SVGRectInterpolationType.cpp
@@ -23,7 +23,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(RectComponentIndexCount); for (size_t i = 0; i < RectComponentIndexCount; i++) result->set(i, InterpolableNumber::create(0)); - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } InterpolationValue SVGRectInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const @@ -37,7 +37,7 @@ result->set(RectY, InterpolableNumber::create(rect.y())); result->set(RectWidth, InterpolableNumber::create(rect.width())); result->set(RectHeight, InterpolableNumber::create(rect.height())); - return InterpolationValue(result.release()); + return InterpolationValue(std::move(result)); } SVGPropertyBase* SVGRectInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue*) const
diff --git a/third_party/WebKit/Source/core/animation/SVGTransformListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGTransformListInterpolationType.cpp index 9766c503..fd392aa 100644 --- a/third_party/WebKit/Source/core/animation/SVGTransformListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/SVGTransformListInterpolationType.cpp
@@ -46,7 +46,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(2); result->set(0, InterpolableNumber::create(translate.x())); result->set(1, InterpolableNumber::create(translate.y())); - return result.release(); + return std::move(result); } SVGTransform* translateFromInterpolableValue(const InterpolableValue& value) @@ -66,7 +66,7 @@ OwnPtr<InterpolableList> result = InterpolableList::create(2); result->set(0, InterpolableNumber::create(scale.width())); result->set(1, InterpolableNumber::create(scale.height())); - return result.release(); + return std::move(result); } SVGTransform* scaleFromInterpolableValue(const InterpolableValue& value) @@ -87,7 +87,7 @@ result->set(0, InterpolableNumber::create(transform->angle())); result->set(1, InterpolableNumber::create(rotationCenter.x())); result->set(2, InterpolableNumber::create(rotationCenter.y())); - return result.release(); + return std::move(result); } SVGTransform* rotateFromInterpolableValue(const InterpolableValue& value) @@ -227,7 +227,7 @@ result->set(i, toInterpolableValue(transform->clone(), transformType)); transformTypes.append(transformType); } - return InterpolationValue(result.release(), SVGTransformNonInterpolableValue::create(transformTypes)); + return InterpolationValue(std::move(result), SVGTransformNonInterpolableValue::create(transformTypes)); } InterpolationValue SVGTransformListInterpolationType::maybeConvertSingle(const PropertySpecificKeyframe& keyframe, const InterpolationEnvironment& environment, const InterpolationValue& underlying, ConversionCheckers& conversionCheckers) const @@ -251,7 +251,7 @@ if (!value) return nullptr; types.appendVector(getTransformTypes(value)); - interpolableParts.append(value.interpolableValue.release()); + interpolableParts.append(std::move(value.interpolableValue)); } OwnPtr<InterpolableList> interpolableList = InterpolableList::create(types.size()); @@ -259,12 +259,12 @@ for (auto& part : interpolableParts) { InterpolableList& list = toInterpolableList(*part); for (size_t i = 0; i < list.length(); ++i) { - interpolableList->set(interpolableListIndex, list.getMutable(i).release()); + interpolableList->set(interpolableListIndex, std::move(list.getMutable(i))); ++interpolableListIndex; } } - return InterpolationValue(interpolableList.release(), SVGTransformNonInterpolableValue::create(types)); + return InterpolationValue(std::move(interpolableList), SVGTransformNonInterpolableValue::create(types)); } SVGPropertyBase* SVGTransformListInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue) const @@ -282,7 +282,7 @@ if (!transformTypesMatch(start, end)) return nullptr; - return PairwiseInterpolationValue(start.interpolableValue.release(), end.interpolableValue.release(), end.nonInterpolableValue.release()); + return PairwiseInterpolationValue(std::move(start.interpolableValue), std::move(end.interpolableValue), end.nonInterpolableValue.release()); } void SVGTransformListInterpolationType::composite(UnderlyingValueOwner& underlyingValueOwner, double underlyingFraction, const InterpolationValue& value, double interpolationFraction) const
diff --git a/third_party/WebKit/Source/core/animation/ShadowInterpolationFunctions.cpp b/third_party/WebKit/Source/core/animation/ShadowInterpolationFunctions.cpp index 1ee4fd60..697f1bda 100644 --- a/third_party/WebKit/Source/core/animation/ShadowInterpolationFunctions.cpp +++ b/third_party/WebKit/Source/core/animation/ShadowInterpolationFunctions.cpp
@@ -57,7 +57,7 @@ { if (!nonInterpolableValuesAreCompatible(start.nonInterpolableValue.get(), end.nonInterpolableValue.get())) return nullptr; - return PairwiseInterpolationValue(start.interpolableValue.release(), end.interpolableValue.release(), start.nonInterpolableValue.release()); + return PairwiseInterpolationValue(std::move(start.interpolableValue), std::move(end.interpolableValue), start.nonInterpolableValue.release()); } InterpolationValue ShadowInterpolationFunctions::convertShadowData(const ShadowData& shadowData, double zoom) @@ -68,7 +68,7 @@ interpolableList->set(ShadowBlur, CSSLengthInterpolationType::createInterpolablePixels(shadowData.blur() / zoom)); interpolableList->set(ShadowSpread, CSSLengthInterpolationType::createInterpolablePixels(shadowData.spread() / zoom)); interpolableList->set(ShadowColor, CSSColorInterpolationType::createInterpolableColor(shadowData.color())); - return InterpolationValue(interpolableList.release(), ShadowNonInterpolableValue::create(shadowData.style())); + return InterpolationValue(std::move(interpolableList), ShadowNonInterpolableValue::create(shadowData.style())); } InterpolationValue ShadowInterpolationFunctions::maybeConvertCSSValue(const CSSValue& value) @@ -102,7 +102,7 @@ if (!lengthField) return nullptr; ASSERT(!lengthField.nonInterpolableValue); - interpolableList->set(i, lengthField.interpolableValue.release()); + interpolableList->set(i, std::move(lengthField.interpolableValue)); } else { interpolableList->set(i, CSSLengthInterpolationType::createInterpolablePixels(0)); } @@ -112,17 +112,17 @@ OwnPtr<InterpolableValue> interpolableColor = CSSColorInterpolationType::maybeCreateInterpolableColor(*shadow.color); if (!interpolableColor) return nullptr; - interpolableList->set(ShadowColor, interpolableColor.release()); + interpolableList->set(ShadowColor, std::move(interpolableColor)); } else { interpolableList->set(ShadowColor, CSSColorInterpolationType::createInterpolableColor(StyleColor::currentColor())); } - return InterpolationValue(interpolableList.release(), ShadowNonInterpolableValue::create(style)); + return InterpolationValue(std::move(interpolableList), ShadowNonInterpolableValue::create(style)); } PassOwnPtr<InterpolableValue> ShadowInterpolationFunctions::createNeutralInterpolableValue() { - return convertShadowData(ShadowData(FloatPoint(0, 0), 0, 0, Normal, StyleColor(Color::transparent)), 1).interpolableValue.release(); + return convertShadowData(ShadowData(FloatPoint(0, 0), 0, 0, Normal, StyleColor(Color::transparent)), 1).interpolableValue; } void ShadowInterpolationFunctions::composite(OwnPtr<InterpolableValue>& underlyingInterpolableValue, RefPtr<NonInterpolableValue>& underlyingNonInterpolableValue, double underlyingFraction, const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue)
diff --git a/third_party/WebKit/Source/core/animation/TypedInterpolationValue.h b/third_party/WebKit/Source/core/animation/TypedInterpolationValue.h index dc92019a..993ddf9d 100644 --- a/third_party/WebKit/Source/core/animation/TypedInterpolationValue.h +++ b/third_party/WebKit/Source/core/animation/TypedInterpolationValue.h
@@ -22,7 +22,7 @@ PassOwnPtr<TypedInterpolationValue> clone() const { InterpolationValue copy = m_value.clone(); - return create(m_type, copy.interpolableValue.release(), copy.nonInterpolableValue.release()); + return create(m_type, std::move(copy.interpolableValue), copy.nonInterpolableValue.release()); } const InterpolationType& type() const { return m_type; }
diff --git a/third_party/WebKit/Source/core/animation/animatable/AnimatablePath.cpp b/third_party/WebKit/Source/core/animation/animatable/AnimatablePath.cpp index 326ee89..deb2889 100644 --- a/third_party/WebKit/Source/core/animation/animatable/AnimatablePath.cpp +++ b/third_party/WebKit/Source/core/animation/animatable/AnimatablePath.cpp
@@ -52,7 +52,7 @@ SVGPathBlender blender(&fromSource, &toSource, &builder); bool ok = blender.blendAnimatedPath(fraction); ASSERT_UNUSED(ok, ok); - return AnimatablePath::create(StylePath::create(byteStream.release())); + return AnimatablePath::create(StylePath::create(std::move(byteStream))); } bool AnimatablePath::equalTo(const AnimatableValue* value) const
diff --git a/third_party/WebKit/Source/core/css/CSSPathValue.cpp b/third_party/WebKit/Source/core/css/CSSPathValue.cpp index d25c1f81..ff88f62 100644 --- a/third_party/WebKit/Source/core/css/CSSPathValue.cpp +++ b/third_party/WebKit/Source/core/css/CSSPathValue.cpp
@@ -34,7 +34,7 @@ // Need to be registered as LSan ignored, as it will be reachable and // separately referred to by emptyPathValue() callers. LEAK_SANITIZER_IGNORE_OBJECT(pathByteStream.get()); - return CSSPathValue::create(pathByteStream.release()); + return CSSPathValue::create(std::move(pathByteStream)); } } // namespace
diff --git a/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.cpp b/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.cpp index a2d03d66..5519d9c 100644 --- a/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.cpp +++ b/third_party/WebKit/Source/core/css/cssom/MatrixTransformComponent.cpp
@@ -36,21 +36,21 @@ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create(); if (length != 0) matrix->setM34(-1 / length); - return new MatrixTransformComponent(matrix.release(), PerspectiveType); + return new MatrixTransformComponent(std::move(matrix), PerspectiveType); } MatrixTransformComponent* MatrixTransformComponent::rotate(double angle) { OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create(); matrix->rotate(angle); - return new MatrixTransformComponent(matrix.release(), RotationType); + return new MatrixTransformComponent(std::move(matrix), RotationType); } MatrixTransformComponent* MatrixTransformComponent::rotate3d(double angle, double x, double y, double z) { OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create(); matrix->rotate3d(x, y, z, angle); - return new MatrixTransformComponent(matrix.release(), Rotation3DType); + return new MatrixTransformComponent(std::move(matrix), Rotation3DType); } MatrixTransformComponent* MatrixTransformComponent::scale(double x, double y) @@ -58,7 +58,7 @@ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create(); matrix->setM11(x); matrix->setM22(y); - return new MatrixTransformComponent(matrix.release(), ScaleType); + return new MatrixTransformComponent(std::move(matrix), ScaleType); } MatrixTransformComponent* MatrixTransformComponent::scale3d(double x, double y, double z) @@ -67,7 +67,7 @@ matrix->setM11(x); matrix->setM22(y); matrix->setM33(z); - return new MatrixTransformComponent(matrix.release(), Scale3DType); + return new MatrixTransformComponent(std::move(matrix), Scale3DType); } MatrixTransformComponent* MatrixTransformComponent::skew(double ax, double ay) @@ -78,7 +78,7 @@ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create(); matrix->setM12(tanAy); matrix->setM21(tanAx); - return new MatrixTransformComponent(matrix.release(), SkewType); + return new MatrixTransformComponent(std::move(matrix), SkewType); } MatrixTransformComponent* MatrixTransformComponent::translate(double x, double y) @@ -86,7 +86,7 @@ OwnPtr<TransformationMatrix> matrix = TransformationMatrix::create(); matrix->setM41(x); matrix->setM42(y); - return new MatrixTransformComponent(matrix.release(), TranslationType); + return new MatrixTransformComponent(std::move(matrix), TranslationType); } MatrixTransformComponent* MatrixTransformComponent::translate3d(double x, double y, double z) @@ -95,7 +95,7 @@ matrix->setM41(x); matrix->setM42(y); matrix->setM43(z); - return new MatrixTransformComponent(matrix.release(), Translation3DType); + return new MatrixTransformComponent(std::move(matrix), Translation3DType); } } // namespace blink
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp index d4fde0f..06425eb 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp +++ b/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp
@@ -222,7 +222,7 @@ selector->setForPage(); Vector<OwnPtr<CSSParserSelector>> selectorVector; - selectorVector.append(selector.release()); + selectorVector.append(std::move(selector)); CSSSelectorList selectorList = CSSSelectorList::adoptSelectorVector(selectorVector); return selectorList; } @@ -656,7 +656,7 @@ } consumeDeclarationList(block, StyleRule::Keyframe); - return StyleRuleKeyframe::create(keyList.release(), createStylePropertySet(m_parsedProperties, m_context.mode())); + return StyleRuleKeyframe::create(std::move(keyList), createStylePropertySet(m_parsedProperties, m_context.mode())); } static void observeSelectors(CSSParserObserverWrapper& wrapper, CSSParserTokenRange selectors) @@ -818,7 +818,7 @@ else return nullptr; // Parser error, invalid value in keyframe selector if (range.atEnd()) - return result.release(); + return result; if (range.consume().type() != CommaToken) return nullptr; // Parser error }
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserSelector.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserSelector.cpp index 1fb2579..f3263ea 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSParserSelector.cpp +++ b/third_party/WebKit/Source/core/css/parser/CSSParserSelector.cpp
@@ -39,13 +39,13 @@ if (!m_tagHistory) return; Vector<OwnPtr<CSSParserSelector>, 16> toDelete; - OwnPtr<CSSParserSelector> selector = m_tagHistory.release(); + OwnPtr<CSSParserSelector> selector = std::move(m_tagHistory); while (true) { - OwnPtr<CSSParserSelector> next = selector->m_tagHistory.release(); - toDelete.append(selector.release()); + OwnPtr<CSSParserSelector> next = std::move(selector->m_tagHistory); + toDelete.append(std::move(selector)); if (!next) break; - selector = next.release(); + selector = std::move(next); } } @@ -92,15 +92,15 @@ PassOwnPtr<CSSParserSelector> CSSParserSelector::releaseTagHistory() { setRelation(CSSSelector::SubSelector); - return m_tagHistory.release(); + return std::move(m_tagHistory); } void CSSParserSelector::prependTagSelector(const QualifiedName& tagQName, bool isImplicit) { OwnPtr<CSSParserSelector> second = CSSParserSelector::create(); - second->m_selector = m_selector.release(); - second->m_tagHistory = m_tagHistory.release(); - m_tagHistory = second.release(); + second->m_selector = std::move(m_selector); + second->m_tagHistory = std::move(m_tagHistory); + m_tagHistory = std::move(second); m_selector = adoptPtr(new CSSSelector(tagQName, isImplicit)); }
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserSelector.h b/third_party/WebKit/Source/core/css/parser/CSSParserSelector.h index 2f8177e..50ff17d 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSParserSelector.h +++ b/third_party/WebKit/Source/core/css/parser/CSSParserSelector.h
@@ -37,7 +37,7 @@ ~CSSParserSelector(); - PassOwnPtr<CSSSelector> releaseSelector() { return m_selector.release(); } + PassOwnPtr<CSSSelector> releaseSelector() { return std::move(m_selector); } CSSSelector::RelationType relation() const { return m_selector->relation(); } void setValue(const AtomicString& value, bool matchLowerCase = false) { m_selector->setValue(value, matchLowerCase); }
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp index 1b60d4f..3bd6eb1 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -1551,7 +1551,7 @@ range = functionRange; if (byteStream->isEmpty()) return cssValuePool().createIdentifierValue(CSSValueNone); - return CSSPathValue::create(byteStream.release()); + return CSSPathValue::create(std::move(byteStream)); } static CSSValue* consumePathOrNone(CSSParserTokenRange& range) @@ -3548,12 +3548,51 @@ return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount); } +static void countKeywordOnlyPropertyUsage(CSSPropertyID property, UseCounter* counter, CSSValueID valueID) +{ + if (!counter) + return; + switch (property) { + case CSSPropertyWebkitAppearance: + if (valueID == CSSValueNone) { + counter->count(UseCounter::CSSValueAppearanceNone); + } else { + counter->count(UseCounter::CSSValueAppearanceNotNone); + if (valueID == CSSValueButton) + counter->count(UseCounter::CSSValueAppearanceButton); + else if (valueID == CSSValueCaret) + counter->count(UseCounter::CSSValueAppearanceCaret); + else if (valueID == CSSValueCheckbox) + counter->count(UseCounter::CSSValueAppearanceCheckbox); + else if (valueID == CSSValueMenulist) + counter->count(UseCounter::CSSValueAppearanceMenulist); + else if (valueID == CSSValueMenulistButton) + counter->count(UseCounter::CSSValueAppearanceMenulistButton); + else if (valueID == CSSValueListbox) + counter->count(UseCounter::CSSValueAppearanceListbox); + else if (valueID == CSSValueRadio) + counter->count(UseCounter::CSSValueAppearanceRadio); + else if (valueID == CSSValueSearchfield) + counter->count(UseCounter::CSSValueAppearanceSearchField); + else if (valueID == CSSValueTextfield) + counter->count(UseCounter::CSSValueAppearanceTextField); + else + counter->count(UseCounter::CSSValueAppearanceOthers); + } + break; + + default: + break; + } +} + CSSValue* CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty, CSSPropertyID currentShorthand) { CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); if (CSSParserFastPaths::isKeywordPropertyID(property)) { if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_range.peek().id(), m_context.mode())) return nullptr; + countKeywordOnlyPropertyUsage(property, m_context.useCounter(), m_range.peek().id()); return consumeIdent(m_range); } switch (property) {
diff --git a/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp index e478a67..5b1effe 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp +++ b/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp
@@ -97,13 +97,13 @@ OwnPtr<CSSParserSelector> selector = consumeComplexSelector(range); if (!selector) return CSSSelectorList(); - selectorList.append(selector.release()); + selectorList.append(std::move(selector)); while (!range.atEnd() && range.peek().type() == CommaToken) { range.consumeIncludingWhitespace(); selector = consumeComplexSelector(range); if (!selector) return CSSSelectorList(); - selectorList.append(selector.release()); + selectorList.append(std::move(selector)); } if (m_failedParsing) @@ -119,14 +119,14 @@ range.consumeWhitespace(); if (!selector) return CSSSelectorList(); - selectorList.append(selector.release()); + selectorList.append(std::move(selector)); while (!range.atEnd() && range.peek().type() == CommaToken) { range.consumeIncludingWhitespace(); selector = consumeCompoundSelector(range); range.consumeWhitespace(); if (!selector) return CSSSelectorList(); - selectorList.append(selector.release()); + selectorList.append(std::move(selector)); } if (m_failedParsing) @@ -175,7 +175,7 @@ while (CSSSelector::RelationType combinator = consumeCombinator(range)) { OwnPtr<CSSParserSelector> nextSelector = consumeCompoundSelector(range); if (!nextSelector) - return combinator == CSSSelector::Descendant ? selector.release() : nullptr; + return combinator == CSSSelector::Descendant ? std::move(selector) : nullptr; if (previousCompoundFlags & HasPseudoElementForRightmostCompound) return nullptr; CSSParserSelector* end = nextSelector.get(); @@ -188,12 +188,12 @@ if (previousCompoundFlags & HasContentPseudoElement) end->setRelationIsAffectedByPseudoContent(); previousCompoundFlags = compoundFlags; - end->setTagHistory(selector.release()); + end->setTagHistory(std::move(selector)); - selector = nextSelector.release(); + selector = std::move(nextSelector); } - return selector.release(); + return selector; } namespace { @@ -304,9 +304,9 @@ compoundPseudoElement = simpleSelector->pseudoType(); if (compoundSelector) - compoundSelector = addSimpleSelectorToCompound(compoundSelector.release(), simpleSelector.release()); + compoundSelector = addSimpleSelectorToCompound(std::move(compoundSelector), std::move(simpleSelector)); else - compoundSelector = simpleSelector.release(); + compoundSelector = std::move(simpleSelector); } if (!compoundSelector) { @@ -320,7 +320,7 @@ return CSSParserSelector::create(QualifiedName(namespacePrefix, elementName, namespaceURI)); } prependTypeSelectorIfNeeded(namespacePrefix, elementName, compoundSelector.get()); - return splitCompoundAtImplicitShadowCrossingCombinator(compoundSelector.release()); + return splitCompoundAtImplicitShadowCrossingCombinator(std::move(compoundSelector)); } PassOwnPtr<CSSParserSelector> CSSSelectorParser::consumeSimpleSelector(CSSParserTokenRange& range) @@ -339,7 +339,7 @@ return nullptr; if (!selector) m_failedParsing = true; - return selector.release(); + return selector; } bool CSSSelectorParser::consumeName(CSSParserTokenRange& range, AtomicString& name, AtomicString& namespacePrefix) @@ -389,7 +389,7 @@ selector->setMatch(CSSSelector::Id); const AtomicString& value = range.consume().value(); selector->setValue(value, isQuirksModeBehavior(m_context.matchMode())); - return selector.release(); + return selector; } PassOwnPtr<CSSParserSelector> CSSSelectorParser::consumeClass(CSSParserTokenRange& range) @@ -403,7 +403,7 @@ selector->setMatch(CSSSelector::Class); const AtomicString& value = range.consume().value(); selector->setValue(value, isQuirksModeBehavior(m_context.matchMode())); - return selector.release(); + return selector; } PassOwnPtr<CSSParserSelector> CSSSelectorParser::consumeAttribute(CSSParserTokenRange& range) @@ -434,7 +434,7 @@ if (block.atEnd()) { selector->setAttribute(qualifiedName, CSSSelector::CaseSensitive); selector->setMatch(CSSSelector::AttributeSet); - return selector.release(); + return selector; } selector->setMatch(consumeAttributeMatch(block)); @@ -447,7 +447,7 @@ if (!block.atEnd()) return nullptr; - return selector.release(); + return selector; } PassOwnPtr<CSSParserSelector> CSSSelectorParser::consumePseudo(CSSParserTokenRange& range) @@ -479,7 +479,7 @@ range.consume(); if (selector->pseudoType() == CSSSelector::PseudoUnknown) return nullptr; - return selector.release(); + return selector; } CSSParserTokenRange block = range.consumeBlock(); @@ -499,8 +499,8 @@ *selectorList = consumeCompoundSelectorList(block); if (!selectorList->isValid() || !block.atEnd()) return nullptr; - selector->setSelectorList(selectorList.release()); - return selector.release(); + selector->setSelectorList(std::move(selectorList)); + return selector; } case CSSSelector::PseudoNot: { @@ -509,9 +509,9 @@ if (!innerSelector || !innerSelector->isSimple() || !block.atEnd()) return nullptr; Vector<OwnPtr<CSSParserSelector>> selectorVector; - selectorVector.append(innerSelector.release()); + selectorVector.append(std::move(innerSelector)); selector->adoptSelectorVector(selectorVector); - return selector.release(); + return selector; } case CSSSelector::PseudoSlotted: { @@ -522,9 +522,9 @@ if (!innerSelector || !block.atEnd() || !RuntimeEnabledFeatures::shadowDOMV1Enabled()) return nullptr; Vector<OwnPtr<CSSParserSelector>> selectorVector; - selectorVector.append(innerSelector.release()); + selectorVector.append(std::move(innerSelector)); selector->adoptSelectorVector(selectorVector); - return selector.release(); + return selector; } case CSSSelector::PseudoLang: { @@ -533,7 +533,7 @@ if (ident.type() != IdentToken || !block.atEnd()) return nullptr; selector->setArgument(ident.value()); - return selector.release(); + return selector; } case CSSSelector::PseudoNthChild: case CSSSelector::PseudoNthLastChild: @@ -547,7 +547,7 @@ if (!block.atEnd()) return nullptr; selector->setNth(ab.first, ab.second); - return selector.release(); + return selector; } default: break; @@ -787,7 +787,7 @@ OwnPtr<CSSParserSelector> secondCompound = splitAfter->releaseTagHistory(); secondCompound->appendTagHistory(secondCompound->pseudoType() == CSSSelector::PseudoSlotted ? CSSSelector::ShadowSlot : CSSSelector::ShadowPseudo, std::move(compoundSelector)); - return secondCompound.release(); + return secondCompound; } } // namespace blink
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp b/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp index 07dd462..46aaa667 100644 --- a/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp +++ b/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp
@@ -683,7 +683,7 @@ if (listStyleIdent != CSSValueNone) listStyleType = static_cast<EListStyleType>(listStyleIdent - CSSValueDisc); OwnPtr<CounterContent> counter = adoptPtr(new CounterContent(AtomicString(counterValue->identifier()), listStyleType, AtomicString(counterValue->separator()))); - nextContent = ContentData::create(counter.release()); + nextContent = ContentData::create(std::move(counter)); } else if (item->isPrimitiveValue()) { QuoteType quoteType; switch (toCSSPrimitiveValue(*item).getValueID()) {
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleResolverStats.cpp b/third_party/WebKit/Source/core/css/resolver/StyleResolverStats.cpp index 9bc076a..1e1902b 100644 --- a/third_party/WebKit/Source/core/css/resolver/StyleResolverStats.cpp +++ b/third_party/WebKit/Source/core/css/resolver/StyleResolverStats.cpp
@@ -87,7 +87,7 @@ tracedValue->setInteger("elementsStyled", elementsStyled); tracedValue->setInteger("pseudoElementsStyled", pseudoElementsStyled); tracedValue->setInteger("baseStylesUsed", baseStylesUsed); - return tracedValue.release(); + return tracedValue; }
diff --git a/third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp b/third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp index 0c90a77..b0f5d56c 100644 --- a/third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp +++ b/third_party/WebKit/Source/core/dom/DecodedDataDocumentParser.cpp
@@ -57,7 +57,7 @@ PassOwnPtr<TextResourceDecoder> DecodedDataDocumentParser::takeDecoder() { - return m_decoder.release(); + return std::move(m_decoder); } void DecodedDataDocumentParser::appendBytes(const char* data, size_t length)
diff --git a/third_party/WebKit/Source/core/dom/MessagePort.cpp b/third_party/WebKit/Source/core/dom/MessagePort.cpp index 36de6e4..de2091f 100644 --- a/third_party/WebKit/Source/core/dom/MessagePort.cpp +++ b/third_party/WebKit/Source/core/dom/MessagePort.cpp
@@ -87,7 +87,7 @@ getExecutionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, "MessagePort cannot send an ArrayBuffer as a transferable object yet. See http://crbug.com/334408")); WebString messageString = message->toWireString(); - OwnPtr<WebMessagePortChannelArray> webChannels = toWebMessagePortChannelArray(channels.release()); + OwnPtr<WebMessagePortChannelArray> webChannels = toWebMessagePortChannelArray(std::move(channels)); m_entangledChannel->postMessage(messageString, webChannels.leakPtr()); } @@ -100,7 +100,7 @@ for (size_t i = 0; i < channels->size(); ++i) (*webChannels)[i] = (*channels)[i].leakPtr(); } - return webChannels.release(); + return webChannels; } // static @@ -109,14 +109,14 @@ OwnPtr<MessagePortChannelArray> channels = adoptPtr(new MessagePortChannelArray(webChannels.size())); for (size_t i = 0; i < webChannels.size(); ++i) (*channels)[i] = adoptPtr(webChannels[i]); - return MessagePort::entanglePorts(*context, channels.release()); + return MessagePort::entanglePorts(*context, std::move(channels)); } PassOwnPtr<WebMessagePortChannel> MessagePort::disentangle() { DCHECK(m_entangledChannel); m_entangledChannel->setClient(0); - return m_entangledChannel.release(); + return std::move(m_entangledChannel); } // Invoked to notify us that there are messages available for this port. @@ -204,7 +204,7 @@ if (getExecutionContext()->isWorkerGlobalScope() && toWorkerGlobalScope(getExecutionContext())->isClosing()) return; - MessagePortArray* ports = MessagePort::entanglePorts(*getExecutionContext(), channels.release()); + MessagePortArray* ports = MessagePort::entanglePorts(*getExecutionContext(), std::move(channels)); Event* evt = MessageEvent::create(ports, message.release()); dispatchEvent(evt); @@ -248,7 +248,7 @@ OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelArray(ports.size())); for (unsigned i = 0; i < ports.size(); ++i) (*portArray)[i] = ports[i]->disentangle(); - return portArray.release(); + return portArray; } MessagePortArray* MessagePort::entanglePorts(ExecutionContext& context, PassOwnPtr<MessagePortChannelArray> channels) @@ -261,7 +261,7 @@ MessagePortArray* portArray = new MessagePortArray(channels->size()); for (unsigned i = 0; i < channels->size(); ++i) { MessagePort* port = MessagePort::create(context); - port->entangle((*channels)[i].release()); + port->entangle(std::move((*channels)[i])); (*portArray)[i] = port; } return portArray;
diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp index 1df2d265..baf6952 100644 --- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
@@ -1581,7 +1581,7 @@ else scope = document.documentElement(); - Range* range = Range::create(document, firstPositionInNode(scope), p.parentAnchoredEquivalent()); + Range* range = Range::create(document, Position::firstPositionInNode(scope), p.parentAnchoredEquivalent()); return TextIterator::rangeLength(range->startPosition(), range->endPosition(), true); }
diff --git a/third_party/WebKit/Source/core/editing/Position.h b/third_party/WebKit/Source/core/editing/Position.h index a00d20b..84dd327 100644 --- a/third_party/WebKit/Source/core/editing/Position.h +++ b/third_party/WebKit/Source/core/editing/Position.h
@@ -309,11 +309,6 @@ return PositionTemplate<Strategy>(anchorNode, PositionAnchorType::BeforeChildren); } -inline Position firstPositionInNode(Node* anchorNode) -{ - return Position::firstPositionInNode(anchorNode); -} - template <typename Strategy> PositionTemplate<Strategy> PositionTemplate<Strategy>::lastPositionInNode(Node* anchorNode) {
diff --git a/third_party/WebKit/Source/core/editing/SelectionEditor.cpp b/third_party/WebKit/Source/core/editing/SelectionEditor.cpp index a90e2b8..e0222b1 100644 --- a/third_party/WebKit/Source/core/editing/SelectionEditor.cpp +++ b/third_party/WebKit/Source/core/editing/SelectionEditor.cpp
@@ -689,12 +689,6 @@ if (!verticalDistance) return false; - if (userTriggered == UserTriggered) { - FrameSelection* trialFrameSelection = FrameSelection::create(); - trialFrameSelection->setSelection(m_selection); - trialFrameSelection->modify(alter, verticalDistance, direction, NotUserTriggered); - } - willBeModified(alter, direction == FrameSelection::DirectionUp ? DirectionBackward : DirectionForward); VisiblePosition pos;
diff --git a/third_party/WebKit/Source/core/editing/SurroundingText.cpp b/third_party/WebKit/Source/core/editing/SurroundingText.cpp index d22f472..de3fec1 100644 --- a/third_party/WebKit/Source/core/editing/SurroundingText.cpp +++ b/third_party/WebKit/Source/core/editing/SurroundingText.cpp
@@ -79,7 +79,7 @@ // Same as with the forward range but with the backward range. The range // starts at the document's start and ends at the selection start and will // be updated. - BackwardsCharacterIterator backwardsIterator(firstPositionInNode(document->documentElement()).parentAnchoredEquivalent(), startPosition, TextIteratorStopsOnFormControls); + BackwardsCharacterIterator backwardsIterator(Position::firstPositionInNode(document->documentElement()).parentAnchoredEquivalent(), startPosition, TextIteratorStopsOnFormControls); if (!backwardsIterator.atEnd()) backwardsIterator.advance(halfMaxLength);
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp index 6311cba4..854cc42 100644 --- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp +++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -1341,7 +1341,7 @@ Element* rootElement = node->hasEditableStyle(editableType) ? node->rootEditableElement(editableType) : node->document().documentElement(); if (!rootElement) return VisiblePosition(); - return createVisiblePosition(firstPositionInNode(rootElement)); + return createVisiblePosition(Position::firstPositionInNode(rootElement)); } VisiblePosition nextLinePosition(const VisiblePosition& visiblePosition, LayoutUnit lineDirectionPoint, EditableType editableType) @@ -1730,7 +1730,7 @@ { Position position = visiblePosition.deepEquivalent(); Element* startBlock = position.computeContainerNode() ? enclosingBlock(position.computeContainerNode(), rule) : 0; - return startBlock ? createVisiblePosition(firstPositionInNode(startBlock)) : VisiblePosition(); + return startBlock ? createVisiblePosition(Position::firstPositionInNode(startBlock)) : VisiblePosition(); } VisiblePosition endOfBlock(const VisiblePosition& visiblePosition, EditingBoundaryCrossingRule rule) @@ -1816,7 +1816,7 @@ if (!highestRoot) return VisiblePosition(); - return createVisiblePosition(firstPositionInNode(highestRoot)); + return createVisiblePosition(Position::firstPositionInNode(highestRoot)); } VisiblePosition endOfEditableContent(const VisiblePosition& visiblePosition)
diff --git a/third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.cpp index 1d459559..b0747970 100644 --- a/third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.cpp
@@ -210,7 +210,7 @@ int startOffset = start.offsetInContainerNode(); Text* startText = toText(start.computeContainerNode()); splitTextNode(startText, startOffset); - start = firstPositionInNode(startText); + start = Position::firstPositionInNode(startText); if (isStartAndEndOnSameNode) { DCHECK_GE(end.offsetInContainerNode(), startOffset); end = Position(startText, end.offsetInContainerNode() - startOffset); @@ -263,7 +263,7 @@ return endOfNextParagraph; Text* text = toText(position.computeContainerNode()); - if (!style->preserveNewline() || !position.offsetInContainerNode() || !isNewLineAtPosition(firstPositionInNode(text))) + if (!style->preserveNewline() || !position.offsetInContainerNode() || !isNewLineAtPosition(Position::firstPositionInNode(text))) return endOfNextParagraph; // \n at the beginning of the text node immediately following the current paragraph is trimmed by moveParagraphWithClones.
diff --git a/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp index c31c471..279533b 100644 --- a/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp
@@ -256,8 +256,8 @@ // addBlockStyleIfNeeded may moveParagraphs, which can remove these endpoints. // Calculate start and end indices from the start of the tree that they're in. Node& scope = NodeTraversal::highestAncestorOrSelf(*visibleStart.deepEquivalent().anchorNode()); - Range* startRange = Range::create(document(), firstPositionInNode(&scope), visibleStart.deepEquivalent().parentAnchoredEquivalent()); - Range* endRange = Range::create(document(), firstPositionInNode(&scope), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); + Range* startRange = Range::create(document(), Position::firstPositionInNode(&scope), visibleStart.deepEquivalent().parentAnchoredEquivalent()); + Range* endRange = Range::create(document(), Position::firstPositionInNode(&scope), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); int startIndex = TextIterator::rangeLength(startRange->startPosition(), startRange->endPosition(), true); int endIndex = TextIterator::rangeLength(endRange->startPosition(), endRange->endPosition(), true); @@ -1304,7 +1304,7 @@ Text* text = toText(start.computeContainerNode()); splitTextNode(text, start.offsetInContainerNode()); - updateStartEnd(firstPositionInNode(text), newEnd); + updateStartEnd(Position::firstPositionInNode(text), newEnd); } void ApplyStyleCommand::splitTextAtEnd(const Position& start, const Position& end)
diff --git a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp index 7d076998..8563826 100644 --- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
@@ -1021,7 +1021,7 @@ visiblePos = createVisiblePosition(pos, VP_DEFAULT_AFFINITY); visibleParagraphStart = startOfParagraph(visiblePos); visibleParagraphEnd = endOfParagraph(visiblePos); - moveParagraphs(visibleParagraphStart, visibleParagraphEnd, createVisiblePosition(firstPositionInNode(newBlock)), editingState); + moveParagraphs(visibleParagraphStart, visibleParagraphEnd, createVisiblePosition(Position::firstPositionInNode(newBlock)), editingState); if (editingState->isAborted()) return nullptr; @@ -1337,7 +1337,7 @@ document().updateLayoutIgnorePendingStylesheets(); } - destinationIndex = TextIterator::rangeLength(firstPositionInNode(document().documentElement()), destination.toParentAnchoredPosition(), true); + destinationIndex = TextIterator::rangeLength(Position::firstPositionInNode(document().documentElement()), destination.toParentAnchoredPosition(), true); setEndingSelection(VisibleSelection(destination, originalIsDirectional)); DCHECK(endingSelection().isCaretOrRange()); @@ -1447,7 +1447,7 @@ appendBlockPlaceholder(newBlock, editingState); if (editingState->isAborted()) return false; - setEndingSelection(VisibleSelection(firstPositionInNode(newBlock), TextAffinity::Downstream, endingSelection().isDirectional())); + setEndingSelection(VisibleSelection(Position::firstPositionInNode(newBlock), TextAffinity::Downstream, endingSelection().isDirectional())); style->prepareToApplyAt(endingSelection().start()); if (!style->isEmpty()) { @@ -1540,7 +1540,7 @@ // Don't avoid block level anchors, because that would insert content into the wrong paragraph. if (enclosingAnchor && !isEnclosingBlock(enclosingAnchor)) { - VisiblePosition firstInAnchor = createVisiblePosition(firstPositionInNode(enclosingAnchor)); + VisiblePosition firstInAnchor = createVisiblePosition(Position::firstPositionInNode(enclosingAnchor)); VisiblePosition lastInAnchor = createVisiblePosition(lastPositionInNode(enclosingAnchor)); // If visually just after the anchor, insert *inside* the anchor unless it's the last // VisiblePosition in the document, to match NSTextView. @@ -1607,7 +1607,7 @@ if (!parentElement) break; // Do not split a node when doing so introduces an empty node. - VisiblePosition positionInParent = createVisiblePosition(firstPositionInNode(parentElement)); + VisiblePosition positionInParent = createVisiblePosition(Position::firstPositionInNode(parentElement)); VisiblePosition positionInNode = createVisiblePosition(firstPositionInOrBeforeNode(node)); if (positionInParent.deepEquivalent() != positionInNode.deepEquivalent()) splitElement(parentElement, node);
diff --git a/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp index 76d2da2..84810315 100644 --- a/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp
@@ -49,7 +49,7 @@ static bool isTableCellEmpty(Node* cell) { DCHECK(isTableCell(cell)) << cell; - return createVisiblePosition(firstPositionInNode(cell)).deepEquivalent() == createVisiblePosition(lastPositionInNode(cell)).deepEquivalent(); + return createVisiblePosition(Position::firstPositionInNode(cell)).deepEquivalent() == createVisiblePosition(lastPositionInNode(cell)).deepEquivalent(); } static bool isTableRowEmpty(Node* row) @@ -394,7 +394,7 @@ } if (node == m_startBlock) { - VisiblePosition previous = previousPositionOf(createVisiblePosition(firstPositionInNode(m_startBlock.get()))); + VisiblePosition previous = previousPositionOf(createVisiblePosition(Position::firstPositionInNode(m_startBlock.get()))); if (previous.isNotNull() && !isEndOfBlock(previous)) m_needPlaceholder = true; }
diff --git a/third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.cpp b/third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.cpp index 9a1de6c..3c00f07 100644 --- a/third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.cpp
@@ -177,7 +177,7 @@ } // The selection is inside a blockquote i.e. enclosingNode is a blockquote - VisiblePosition positionInEnclosingBlock = createVisiblePosition(firstPositionInNode(enclosingElement)); + VisiblePosition positionInEnclosingBlock = createVisiblePosition(Position::firstPositionInNode(enclosingElement)); // If the blockquote is inline, the start of the enclosing block coincides with // positionInEnclosingBlock. VisiblePosition startOfEnclosingBlock = (enclosingElement->layoutObject() && enclosingElement->layoutObject()->isInline()) ? positionInEnclosingBlock : startOfBlock(positionInEnclosingBlock);
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp b/third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp index 5c0f925..49292c2 100644 --- a/third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp
@@ -144,7 +144,7 @@ insertNodeBefore(nodeToInsert, textNode, editingState); if (editingState->isAborted()) return; - Position endingPosition = firstPositionInNode(textNode); + Position endingPosition = Position::firstPositionInNode(textNode); // Handle whitespace that occurs after the split document().updateLayoutIgnorePendingStylesheets(); @@ -163,7 +163,7 @@ insertNodeAt(nbspNode, positionBeforeTextNode, editingState); if (editingState->isAborted()) return; - endingPosition = firstPositionInNode(nbspNode); + endingPosition = Position::firstPositionInNode(nbspNode); } }
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp b/third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp index 0fadbda..4f7b680 100644 --- a/third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp
@@ -278,10 +278,10 @@ if (editingState->isAborted()) return false; - Node* firstChildInList = enclosingListChild(createVisiblePosition(firstPositionInNode(listElement)).deepEquivalent().anchorNode(), listElement); + Node* firstChildInList = enclosingListChild(createVisiblePosition(Position::firstPositionInNode(listElement)).deepEquivalent().anchorNode(), listElement); Element* outerBlock = firstChildInList && isBlockFlowElement(*firstChildInList) ? toElement(firstChildInList) : listElement; - moveParagraphWithClones(createVisiblePosition(firstPositionInNode(listElement)), createVisiblePosition(lastPositionInNode(listElement)), newList, outerBlock, editingState); + moveParagraphWithClones(createVisiblePosition(Position::firstPositionInNode(listElement)), createVisiblePosition(lastPositionInNode(listElement)), newList, outerBlock, editingState); if (editingState->isAborted()) return false; @@ -305,7 +305,7 @@ if (rangeEndIsInList && newList) currentSelection.setEnd(newList, lastOffsetInNode(newList), IGNORE_EXCEPTION); - setEndingSelection(createVisiblePosition(firstPositionInNode(newList))); + setEndingSelection(createVisiblePosition(Position::firstPositionInNode(newList))); return true; } @@ -332,7 +332,7 @@ VisiblePosition end; DCHECK(listChildNode); if (isHTMLLIElement(*listChildNode)) { - start = createVisiblePosition(firstPositionInNode(listChildNode)); + start = createVisiblePosition(Position::firstPositionInNode(listChildNode)); end = createVisiblePosition(lastPositionInNode(listChildNode)); nextListChild = listChildNode->nextSibling(); previousListChild = listChildNode->previousSibling();
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp b/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp index 840e371..bba05a1 100644 --- a/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp
@@ -284,7 +284,7 @@ if (editingState->isAborted()) return; - setEndingSelection(VisibleSelection(firstPositionInNode(parent), TextAffinity::Downstream, endingSelection().isDirectional())); + setEndingSelection(VisibleSelection(Position::firstPositionInNode(parent), TextAffinity::Downstream, endingSelection().isDirectional())); return; } @@ -406,7 +406,7 @@ bool atEnd = static_cast<unsigned>(textOffset) >= textNode->length(); if (textOffset > 0 && !atEnd) { splitTextNode(textNode, textOffset); - positionAfterSplit = firstPositionInNode(textNode); + positionAfterSplit = Position::firstPositionInNode(textNode); insertionPosition = Position(textNode->previousSibling(), textOffset); visiblePos = createVisiblePosition(insertionPosition); } @@ -480,7 +480,7 @@ } } - setEndingSelection(VisibleSelection(firstPositionInNode(blockToInsert), TextAffinity::Downstream, endingSelection().isDirectional())); + setEndingSelection(VisibleSelection(Position::firstPositionInNode(blockToInsert), TextAffinity::Downstream, endingSelection().isDirectional())); applyStyleAfterInsertion(startBlock, editingState); }
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp b/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp index 2a80519..ecb2d28 100644 --- a/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp
@@ -52,7 +52,7 @@ insertNodeAtTabSpanPosition(textNode, pos, editingState); if (editingState->isAborted()) return Position(); - return firstPositionInNode(textNode); + return Position::firstPositionInNode(textNode); } // Prepare for text input by looking at the specified position. @@ -62,7 +62,7 @@ insertNodeAt(textNode, pos, editingState); if (editingState->isAborted()) return Position(); - return firstPositionInNode(textNode); + return Position::firstPositionInNode(textNode); } return pos;
diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp index 32f690e..dad54bf 100644 --- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
@@ -549,7 +549,7 @@ // styles from blockquoteNode are allowed to override those from the source document, see <rdar://problem/4930986> and <rdar://problem/5089327>. HTMLQuoteElement* blockquoteElement = !context || isMailPasteAsQuotationHTMLBlockQuoteElement(context) ? toHTMLQuoteElement(context) : - toHTMLQuoteElement(enclosingNodeOfType(firstPositionInNode(context), isMailHTMLBlockquoteElement, CanCrossEditingBoundary)); + toHTMLQuoteElement(enclosingNodeOfType(Position::firstPositionInNode(context), isMailHTMLBlockquoteElement, CanCrossEditingBoundary)); if (blockquoteElement) newInlineStyle->removeStyleFromRulesAndContext(element, document().documentElement()); @@ -571,7 +571,7 @@ // FIXME: Tolerate differences in id, class, and style attributes. if (element->parentNode() && isNonTableCellHTMLBlockElement(element) && areIdenticalElements(*element, *element->parentNode()) - && createVisiblePosition(firstPositionInNode(element->parentNode())).deepEquivalent() == createVisiblePosition(firstPositionInNode(element)).deepEquivalent() + && createVisiblePosition(Position::firstPositionInNode(element->parentNode())).deepEquivalent() == createVisiblePosition(Position::firstPositionInNode(element)).deepEquivalent() && createVisiblePosition(lastPositionInNode(element->parentNode())).deepEquivalent() == createVisiblePosition(lastPositionInNode(element)).deepEquivalent()) { insertedNodes.willRemoveNodePreservingChildren(*element); removeNodePreservingChildren(element, editingState); @@ -857,12 +857,12 @@ // styles from blockquoteElement are allowed to override those from the source document, see <rdar://problem/4930986> and <rdar://problem/5089327>. HTMLQuoteElement* blockquoteElement = isMailPasteAsQuotationHTMLBlockQuoteElement(context) ? toHTMLQuoteElement(context) : - toHTMLQuoteElement(enclosingNodeOfType(firstPositionInNode(context), isMailHTMLBlockquoteElement, CanCrossEditingBoundary)); + toHTMLQuoteElement(enclosingNodeOfType(Position::firstPositionInNode(context), isMailHTMLBlockquoteElement, CanCrossEditingBoundary)); if (blockquoteElement) context = document().documentElement(); // This operation requires that only editing styles to be removed from sourceDocumentStyle. - style->prepareToApplyAt(firstPositionInNode(context)); + style->prepareToApplyAt(Position::firstPositionInNode(context)); // Remove block properties in the span's style. This prevents properties that probably have no effect // currently from affecting blocks later if the style is cloned for a new block element during a future @@ -1153,7 +1153,7 @@ if (!m_matchStyle && !enclosingList(insertionPos.computeContainerNode())) { if (insertionPos.computeContainerNode()->isTextNode() && insertionPos.offsetInContainerNode() && !insertionPos.atLastEditingPositionForNode()) { splitTextNode(toText(insertionPos.computeContainerNode()), insertionPos.offsetInContainerNode()); - insertionPos = firstPositionInNode(insertionPos.computeContainerNode()); + insertionPos = Position::firstPositionInNode(insertionPos.computeContainerNode()); } if (HTMLElement* elementToSplitTo = elementToSplitToAvoidPastingIntoInlineElementsWithStyle(insertionPos)) { @@ -1351,7 +1351,7 @@ insertNodeAfter(newListItem, enclosingBlockElement, editingState); if (editingState->isAborted()) return; - setEndingSelection(createVisiblePosition(firstPositionInNode(newListItem))); + setEndingSelection(createVisiblePosition(Position::firstPositionInNode(newListItem))); } else { // Use a default paragraph element (a plain div) for the empty paragraph, using the last paragraph // block's style seems to annoy users. @@ -1482,7 +1482,7 @@ insertNodeBefore(node, startNode, editingState); if (editingState->isAborted()) return; - m_startOfInsertedContent = firstPositionInNode(node); + m_startOfInsertedContent = Position::firstPositionInNode(node); } } }
diff --git a/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp b/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp index 74de30c1..9544a09d 100644 --- a/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
@@ -463,7 +463,7 @@ addBlockPlaceholderIfNeeded(root, editingState); if (editingState->isAborted()) return false; - setEndingSelection(VisibleSelection(firstPositionInNode(root), TextAffinity::Downstream, endingSelection().isDirectional())); + setEndingSelection(VisibleSelection(Position::firstPositionInNode(root), TextAffinity::Downstream, endingSelection().isDirectional())); return true; } @@ -522,7 +522,7 @@ // If we have a caret selection at the beginning of a cell, we have nothing to do. Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivalent(), &isTableCell); - if (enclosingTableCell && visibleStart.deepEquivalent() == createVisiblePosition(firstPositionInNode(enclosingTableCell)).deepEquivalent()) + if (enclosingTableCell && visibleStart.deepEquivalent() == createVisiblePosition(Position::firstPositionInNode(enclosingTableCell)).deepEquivalent()) return; // If the caret is at the start of a paragraph after a table, move content into the last table cell.
diff --git a/third_party/WebKit/Source/core/editing/serializers/Serialization.cpp b/third_party/WebKit/Source/core/editing/serializers/Serialization.cpp index 80e0694..50d26a04 100644 --- a/third_party/WebKit/Source/core/editing/serializers/Serialization.cpp +++ b/third_party/WebKit/Source/core/editing/serializers/Serialization.cpp
@@ -210,7 +210,7 @@ Node* checkAncestor = specialCommonAncestor ? specialCommonAncestor : commonAncestor; if (checkAncestor->layoutObject()) { - HTMLElement* newSpecialCommonAncestor = toHTMLElement(highestEnclosingNodeOfType(firstPositionInNode(checkAncestor), &isPresentationalHTMLElement, CanCrossEditingBoundary, constrainingAncestor)); + HTMLElement* newSpecialCommonAncestor = toHTMLElement(highestEnclosingNodeOfType(Position::firstPositionInNode(checkAncestor), &isPresentationalHTMLElement, CanCrossEditingBoundary, constrainingAncestor)); if (newSpecialCommonAncestor) specialCommonAncestor = newSpecialCommonAncestor; } @@ -224,7 +224,7 @@ if (!specialCommonAncestor && isTabHTMLSpanElement(commonAncestor)) specialCommonAncestor = toHTMLSpanElement(commonAncestor); - if (HTMLAnchorElement* enclosingAnchor = toHTMLAnchorElement(enclosingElementWithTag(firstPositionInNode(specialCommonAncestor ? specialCommonAncestor : commonAncestor), aTag))) + if (HTMLAnchorElement* enclosingAnchor = toHTMLAnchorElement(enclosingElementWithTag(Position::firstPositionInNode(specialCommonAncestor ? specialCommonAncestor : commonAncestor), aTag))) specialCommonAncestor = enclosingAnchor; return specialCommonAncestor;
diff --git a/third_party/WebKit/Source/core/editing/serializers/StyledMarkupAccumulator.cpp b/third_party/WebKit/Source/core/editing/serializers/StyledMarkupAccumulator.cpp index 10bc148..c04aa27 100644 --- a/third_party/WebKit/Source/core/editing/serializers/StyledMarkupAccumulator.cpp +++ b/third_party/WebKit/Source/core/editing/serializers/StyledMarkupAccumulator.cpp
@@ -107,7 +107,7 @@ if (!shouldAnnotate()) { appendText(text); } else { - const bool useRenderedText = !enclosingElementWithTag(firstPositionInNode(&text), selectTag); + const bool useRenderedText = !enclosingElementWithTag(Position::firstPositionInNode(&text), selectTag); String content = useRenderedText ? renderedText(text) : stringValueForRange(text); StringBuilder buffer; MarkupFormatter::appendCharactersReplacingEntities(buffer, content, 0, content.length(), EntityMaskInPCDATA);
diff --git a/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp b/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp index 87a0de6..56ae182 100644 --- a/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp +++ b/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp
@@ -198,7 +198,7 @@ // TODO(hajimehoshi): This is calculated at createMarkupInternal too. Node* commonAncestor = Strategy::commonAncestor(*m_start.computeContainerNode(), *m_end.computeContainerNode()); DCHECK(commonAncestor); - HTMLBodyElement* body = toHTMLBodyElement(enclosingElementWithTag(firstPositionInNode(commonAncestor), bodyTag)); + HTMLBodyElement* body = toHTMLBodyElement(enclosingElementWithTag(Position::firstPositionInNode(commonAncestor), bodyTag)); HTMLBodyElement* fullySelectedRoot = nullptr; // FIXME: Do this for all fully selected blocks, not just the body. if (body && areSameRanges(body, m_start, m_end))
diff --git a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp index 96e5a3e..9721189 100644 --- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp +++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
@@ -127,7 +127,7 @@ bool isTextField = false; HTMLTextFormControlElement* enclosingHTMLTextFormControlElement = 0; if (!isHTMLTextFormControlElement(*element)) - enclosingHTMLTextFormControlElement = enclosingTextFormControl(firstPositionInNode(element)); + enclosingHTMLTextFormControlElement = enclosingTextFormControl(Position::firstPositionInNode(element)); element = enclosingHTMLTextFormControlElement ? enclosingHTMLTextFormControlElement : element; Element* parent = element; if (isHTMLTextFormControlElement(*element)) { @@ -518,7 +518,7 @@ TRACE_EVENT0("blink", "SpellChecker::chunkAndMarkAllMisspellingsAndBadGrammar"); if (!node) return; - EphemeralRange paragraphRange(firstPositionInNode(node), lastPositionInNode(node)); + EphemeralRange paragraphRange(Position::firstPositionInNode(node), lastPositionInNode(node)); TextCheckingParagraph textToCheck(insertedRange, paragraphRange); chunkAndMarkAllMisspellingsAndBadGrammar(resolveTextCheckingTypeMask(TextCheckingTypeSpelling | TextCheckingTypeGrammar), textToCheck); }
diff --git a/third_party/WebKit/Source/core/events/Event.cpp b/third_party/WebKit/Source/core/events/Event.cpp index ec0d6f14..8fd928d 100644 --- a/third_party/WebKit/Source/core/events/Event.cpp +++ b/third_party/WebKit/Source/core/events/Event.cpp
@@ -358,6 +358,15 @@ return timeStamp; } +void Event::setCancelBubble(ExecutionContext* context, bool cancel) +{ + if (!m_cancelBubble && cancel) + UseCounter::count(context, UseCounter::EventCancelBubbleWasChangedToTrue); + else if (m_cancelBubble && !cancel) + UseCounter::count(context, UseCounter::EventCancelBubbleWasChangedToFalse); + m_cancelBubble = cancel; +} + DEFINE_TRACE(Event) { visitor->trace(m_currentTarget);
diff --git a/third_party/WebKit/Source/core/events/Event.h b/third_party/WebKit/Source/core/events/Event.h index 7e6f186..3aadfc5c 100644 --- a/third_party/WebKit/Source/core/events/Event.h +++ b/third_party/WebKit/Source/core/events/Event.h
@@ -179,8 +179,8 @@ bool defaultHandled() const { return m_defaultHandled; } void setDefaultHandled() { m_defaultHandled = true; } - bool cancelBubble() const { return m_cancelBubble; } - void setCancelBubble(bool cancel) { m_cancelBubble = cancel; } + bool cancelBubble(ExecutionContext* = nullptr) const { return m_cancelBubble; } + void setCancelBubble(ExecutionContext*, bool); Event* underlyingEvent() const { return m_underlyingEvent.get(); } void setUnderlyingEvent(Event*);
diff --git a/third_party/WebKit/Source/core/events/Event.idl b/third_party/WebKit/Source/core/events/Event.idl index f9a37c3..d73b462 100644 --- a/third_party/WebKit/Source/core/events/Event.idl +++ b/third_party/WebKit/Source/core/events/Event.idl
@@ -87,5 +87,5 @@ const unsigned short CHANGE = 32768; [MeasureAs=EventSrcElement] readonly attribute EventTarget srcElement; [MeasureAs=EventReturnValue, CallWith=ExecutionContext, ImplementedAs=legacyReturnValue] attribute boolean returnValue; - [MeasureAs=EventCancelBubble] attribute boolean cancelBubble; + [MeasureAs=EventCancelBubble, CallWith=ExecutionContext] attribute boolean cancelBubble; };
diff --git a/third_party/WebKit/Source/core/events/EventDispatcher.cpp b/third_party/WebKit/Source/core/events/EventDispatcher.cpp index c97cc0e4..665cf82 100644 --- a/third_party/WebKit/Source/core/events/EventDispatcher.cpp +++ b/third_party/WebKit/Source/core/events/EventDispatcher.cpp
@@ -34,6 +34,7 @@ #include "core/events/WindowEventContext.h" #include "core/frame/FrameView.h" #include "core/frame/LocalDOMWindow.h" +#include "core/frame/UseCounter.h" #include "core/inspector/InspectorTraceEvents.h" #include "platform/EventDispatchForbiddenScope.h" #include "platform/TraceEvent.h" @@ -177,12 +178,15 @@ size_t size = m_event->eventPath().size(); for (size_t i = 1; i < size; ++i) { const NodeEventContext& eventContext = m_event->eventPath()[i]; - if (eventContext.currentTargetSameAsTarget()) + if (eventContext.currentTargetSameAsTarget()) { m_event->setEventPhase(Event::AT_TARGET); - else if (m_event->bubbles() && !m_event->cancelBubble()) + } else if (m_event->bubbles() && !m_event->cancelBubble()) { m_event->setEventPhase(Event::BUBBLING_PHASE); - else + } else { + if (m_event->bubbles() && m_event->cancelBubble() && eventContext.node()->hasEventListeners(m_event->type())) + UseCounter::count(eventContext.node()->document(), UseCounter::EventCancelBubbleAffected); continue; + } eventContext.handleLocalEvents(*m_event); if (m_event->propagationStopped()) return; @@ -190,6 +194,8 @@ if (m_event->bubbles() && !m_event->cancelBubble()) { m_event->setEventPhase(Event::BUBBLING_PHASE); m_event->eventPath().windowEventContext().handleLocalEvents(*m_event); + } else if (m_event->bubbles() && m_event->eventPath().windowEventContext().window()->hasEventListeners(m_event->type())) { + UseCounter::count(m_event->eventPath().windowEventContext().window()->getExecutionContext(), UseCounter::EventCancelBubbleAffected); } }
diff --git a/third_party/WebKit/Source/core/events/MessageEvent.cpp b/third_party/WebKit/Source/core/events/MessageEvent.cpp index 33bb457..bceaf11 100644 --- a/third_party/WebKit/Source/core/events/MessageEvent.cpp +++ b/third_party/WebKit/Source/core/events/MessageEvent.cpp
@@ -200,7 +200,7 @@ void MessageEvent::entangleMessagePorts(ExecutionContext* context) { - m_ports = MessagePort::entanglePorts(*context, m_channels.release()); + m_ports = MessagePort::entanglePorts(*context, std::move(m_channels)); } DEFINE_TRACE(MessageEvent)
diff --git a/third_party/WebKit/Source/core/fetch/CrossOriginAccessControl.cpp b/third_party/WebKit/Source/core/fetch/CrossOriginAccessControl.cpp index b0567997..68e0771 100644 --- a/third_party/WebKit/Source/core/fetch/CrossOriginAccessControl.cpp +++ b/third_party/WebKit/Source/core/fetch/CrossOriginAccessControl.cpp
@@ -52,7 +52,7 @@ headerSet->add("last-modified"); headerSet->add("pragma"); - return headerSet.release(); + return headerSet; } bool isOnAccessControlResponseHeaderWhitelist(const String& name)
diff --git a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp index f45d60fa..1b9ad3d 100644 --- a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp +++ b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
@@ -277,7 +277,7 @@ populateResourceTiming(info.get(), resource); info->clearLoadTimings(); info->setLoadFinishTime(info->initialTime()); - m_scheduledResourceTimingReports.append(info.release()); + m_scheduledResourceTimingReports.append(std::move(info)); if (!m_resourceTimingReportTimer.isActive()) m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); } @@ -292,7 +292,7 @@ { OwnPtr<TracedValue> value = TracedValue::create(); value->setString("url", url.getString()); - return value.release(); + return value; } Resource* ResourceFetcher::resourceForStaticData(const FetchRequest& request, const ResourceFactory& factory, const SubstituteData& substituteData) @@ -595,7 +595,7 @@ } if (!isMainResource || context().updateTimingInfoForIFrameNavigation(info.get())) - m_resourceTimingInfoMap.add(resource, info.release()); + m_resourceTimingInfoMap.add(resource, std::move(info)); } ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy(Resource::Type type, const FetchRequest& fetchRequest, Resource* existingResource, bool isStaticData) const
diff --git a/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp b/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp index 3d256438..14068bdc1 100644 --- a/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp +++ b/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp
@@ -247,7 +247,7 @@ } } - m_resource->responseReceived(resourceResponse, handle.release()); + m_resource->responseReceived(resourceResponse, std::move(handle)); if (m_state == ConnectionStateReleased) return;
diff --git a/third_party/WebKit/Source/core/fileapi/Blob.cpp b/third_party/WebKit/Source/core/fileapi/Blob.cpp index e373107..22143b9 100644 --- a/third_party/WebKit/Source/core/fileapi/Blob.cpp +++ b/third_party/WebKit/Source/core/fileapi/Blob.cpp
@@ -105,7 +105,7 @@ populateBlobData(blobData.get(), blobParts, normalizeLineEndingsToNative); long long blobSize = blobData->length(); - return new Blob(BlobDataHandle::create(blobData.release(), blobSize)); + return new Blob(BlobDataHandle::create(std::move(blobData), blobSize)); } Blob* Blob::create(const unsigned char* data, size_t bytes, const String& contentType) @@ -117,7 +117,7 @@ blobData->appendBytes(data, bytes); long long blobSize = blobData->length(); - return new Blob(BlobDataHandle::create(blobData.release(), blobSize)); + return new Blob(BlobDataHandle::create(std::move(blobData), blobSize)); } // static @@ -180,7 +180,7 @@ OwnPtr<BlobData> blobData = BlobData::create(); blobData->setContentType(contentType); blobData->appendBlob(m_blobDataHandle, start, length); - return Blob::create(BlobDataHandle::create(blobData.release(), length)); + return Blob::create(BlobDataHandle::create(std::move(blobData), length)); } void Blob::close(ExecutionContext* executionContext, ExceptionState& exceptionState) @@ -201,7 +201,7 @@ // (e.g., XHR.send()) consider them as empty. OwnPtr<BlobData> blobData = BlobData::create(); blobData->setContentType(type()); - m_blobDataHandle = BlobDataHandle::create(blobData.release(), 0); + m_blobDataHandle = BlobDataHandle::create(std::move(blobData), 0); m_isClosed = true; }
diff --git a/third_party/WebKit/Source/core/fileapi/File.cpp b/third_party/WebKit/Source/core/fileapi/File.cpp index 5da36bd..0270cca 100644 --- a/third_party/WebKit/Source/core/fileapi/File.cpp +++ b/third_party/WebKit/Source/core/fileapi/File.cpp
@@ -59,7 +59,7 @@ OwnPtr<BlobData> blobData = BlobData::create(); blobData->setContentType(contentType); blobData->appendFile(path); - return blobData.release(); + return blobData; } static PassOwnPtr<BlobData> createBlobDataForFile(const String& path, File::ContentTypeLookupPolicy policy) @@ -77,7 +77,7 @@ OwnPtr<BlobData> blobData = BlobData::create(); blobData->setContentType(getContentTypeFromFileName(fileSystemName, File::WellKnownContentTypes)); blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.modificationTime / msPerSecond); - return blobData.release(); + return blobData; } static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSystemURL, const FileMetadata& metadata) @@ -85,7 +85,7 @@ OwnPtr<BlobData> blobData = BlobData::create(); blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), File::WellKnownContentTypes)); blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length, metadata.modificationTime / msPerSecond); - return blobData.release(); + return blobData; } // static @@ -112,7 +112,7 @@ populateBlobData(blobData.get(), fileBits, normalizeLineEndingsToNative); long long fileSize = blobData->length(); - return File::create(fileName, lastModified, BlobDataHandle::create(blobData.release(), fileSize)); + return File::create(fileName, lastModified, BlobDataHandle::create(std::move(blobData), fileSize)); } File* File::createWithRelativePath(const String& path, const String& relativePath) @@ -285,7 +285,7 @@ ASSERT(!m_path.isEmpty()); blobData->appendFile(m_path, start, length, modificationTimeMS / msPerSecond); } - return Blob::create(BlobDataHandle::create(blobData.release(), length)); + return Blob::create(BlobDataHandle::create(std::move(blobData), length)); } void File::captureSnapshot(long long& snapshotSize, double& snapshotModificationTimeMS) const
diff --git a/third_party/WebKit/Source/core/frame/DOMWindow.cpp b/third_party/WebKit/Source/core/frame/DOMWindow.cpp index 2302eb2..341f6c3d 100644 --- a/third_party/WebKit/Source/core/frame/DOMWindow.cpp +++ b/third_party/WebKit/Source/core/frame/DOMWindow.cpp
@@ -219,7 +219,7 @@ else if (MixedContentChecker::isMixedContent(frame()->securityContext()->getSecurityOrigin(), sourceDocument->url())) UseCounter::count(frame(), UseCounter::PostMessageFromInsecureToSecure); - MessageEvent* event = MessageEvent::create(channels.release(), message, sourceOrigin, String(), source, sourceSuborigin); + MessageEvent* event = MessageEvent::create(std::move(channels), message, sourceOrigin, String(), source, sourceSuborigin); // Give the embedder a chance to intercept this postMessage. If the // target is a remote frame, the message will be forwarded through the // browser process.
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp index 73880dbd..e0ed0ef 100644 --- a/third_party/WebKit/Source/core/frame/FrameView.cpp +++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -844,7 +844,7 @@ value->setString("frame", String::format("0x%" PRIxPTR, reinterpret_cast<uintptr_t>(m_frame.get()))); value->setInteger("contentsHeightAfterLayout", layoutView()->documentRect().height()); value->setInteger("visibleHeight", visibleHeight()); - return value.release(); + return value; } #define PERFORM_LAYOUT_TRACE_CATEGORIES "blink,benchmark," TRACE_DISABLED_BY_DEFAULT("blink.debug.layout")
diff --git a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp index f109032..2908b28 100644 --- a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp +++ b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
@@ -37,7 +37,7 @@ { OwnPtr<uint8_t[]> dstPixels = adoptArrayPtr(new uint8_t[input->width() * input->height() * info.bytesPerPixel()]); input->readPixels(info, dstPixels.get(), input->width() * info.bytesPerPixel(), 0, 0); - return dstPixels.release(); + return dstPixels; } static PassRefPtr<SkImage> newSkImageFromRaster(SkImageInfo info, PassOwnPtr<uint8_t[]> imagePixels, int imageRowBytes) @@ -81,14 +81,14 @@ int bottomFirstElement = (height - 1 - i) * imageRowBytes; std::swap_ranges(imagePixels.get() + topFirstElement, imagePixels.get() + topLastElement, imagePixels.get() + bottomFirstElement); } - return newSkImageFromRaster(info, imagePixels.release(), imageRowBytes); + return newSkImageFromRaster(info, std::move(imagePixels), imageRowBytes); } static PassRefPtr<SkImage> premulSkImageToUnPremul(SkImage* input) { SkImageInfo info = SkImageInfo::Make(input->width(), input->height(), kN32_SkColorType, kUnpremul_SkAlphaType); OwnPtr<uint8_t[]> dstPixels = copySkImageData(input, info); - return newSkImageFromRaster(info, dstPixels.release(), input->width() * info.bytesPerPixel()); + return newSkImageFromRaster(info, std::move(dstPixels), input->width() * info.bytesPerPixel()); } PassRefPtr<SkImage> ImageBitmap::getSkImageFromDecoder(PassOwnPtr<ImageDecoder> decoder) @@ -119,7 +119,7 @@ if (srcRect.isEmpty() && !premultiplyAlpha) { SkImageInfo info = SkImageInfo::Make(cropRect.width(), cropRect.height(), kN32_SkColorType, kUnpremul_SkAlphaType); OwnPtr<uint8_t[]> dstPixels = adoptArrayPtr(new uint8_t[cropRect.width() * cropRect.height() * info.bytesPerPixel()]()); - return StaticBitmapImage::create(newSkImageFromRaster(info, dstPixels.release(), cropRect.width() * info.bytesPerPixel())); + return StaticBitmapImage::create(newSkImageFromRaster(info, std::move(dstPixels), cropRect.width() * info.bytesPerPixel())); } RefPtr<SkImage> skiaImage = image->imageForCurrentFrame(); @@ -131,7 +131,7 @@ if (!decoder) return nullptr; decoder->setData(image->data(), true); - skiaImage = ImageBitmap::getSkImageFromDecoder(decoder.release()); + skiaImage = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); if (!skiaImage) return nullptr; } @@ -288,7 +288,7 @@ } } } - m_image = StaticBitmapImage::create(newSkImageFromRaster(info, copiedDataBuffer.release(), dstPixelBytesPerRow)); + m_image = StaticBitmapImage::create(newSkImageFromRaster(info, std::move(copiedDataBuffer), dstPixelBytesPerRow)); } m_image->setPremultiplied(premultiplyAlpha); return; @@ -414,7 +414,7 @@ { SkImageInfo info = SkImageInfo::Make(width(), height(), kRGBA_8888_SkColorType, (alphaOp == PremultiplyAlpha) ? kPremul_SkAlphaType : kUnpremul_SkAlphaType); OwnPtr<uint8_t[]> dstPixels = copySkImageData(m_image->imageForCurrentFrame().get(), info); - return dstPixels.release(); + return dstPixels; } unsigned long ImageBitmap::width() const
diff --git a/third_party/WebKit/Source/core/frame/UseCounter.h b/third_party/WebKit/Source/core/frame/UseCounter.h index 9637901..d586504 100644 --- a/third_party/WebKit/Source/core/frame/UseCounter.h +++ b/third_party/WebKit/Source/core/frame/UseCounter.h
@@ -1161,6 +1161,21 @@ ProgressElementWithNoneAppearance = 1345, ProgressElementWithProgressBarAppearance = 1346, PointerEventAddListenerCount = 1347, + EventCancelBubbleAffected = 1348, + EventCancelBubbleWasChangedToTrue = 1349, + EventCancelBubbleWasChangedToFalse = 1350, + CSSValueAppearanceNone = 1351, + CSSValueAppearanceNotNone = 1352, + CSSValueAppearanceOthers = 1353, + CSSValueAppearanceButton = 1354, + CSSValueAppearanceCaret = 1355, + CSSValueAppearanceCheckbox = 1356, + CSSValueAppearanceMenulist = 1357, + CSSValueAppearanceMenulistButton = 1358, + CSSValueAppearanceListbox = 1359, + CSSValueAppearanceRadio = 1360, + CSSValueAppearanceSearchField = 1361, + CSSValueAppearanceTextField = 1362, // Add new features immediately above this line. Don't change assigned // numbers of any item, and don't reuse removed slots.
diff --git a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp index d66fa611..5fc1f26b 100644 --- a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp +++ b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
@@ -319,7 +319,7 @@ CSPHeaderAndType headerAndType(policy->header(), policy->headerType()); headers->append(headerAndType); } - return headers.release(); + return headers; } template<bool (CSPDirectiveList::*allowed)(ContentSecurityPolicy::ReportingStatus) const>
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp index bbb84df..30354d5 100644 --- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -754,7 +754,7 @@ OwnPtr<ImageBufferSurface> surface = adoptPtr(new Canvas2DImageBufferSurface(deviceSize, *msaaSampleCount, opacityMode, Canvas2DLayerBridge::EnableAcceleration)); if (surface->isValid()) { CanvasMetrics::countCanvasContextUsage(CanvasMetrics::GPUAccelerated2DCanvasImageBufferCreated); - return surface.release(); + return surface; } CanvasMetrics::countCanvasContextUsage(CanvasMetrics::GPUAccelerated2DCanvasImageBufferCreationFailed); } @@ -762,10 +762,10 @@ OwnPtr<RecordingImageBufferFallbackSurfaceFactory> surfaceFactory = adoptPtr(new UnacceleratedSurfaceFactory()); if (shouldUseDisplayList(deviceSize)) { - OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(deviceSize, surfaceFactory.release(), opacityMode)); + OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(deviceSize, std::move(surfaceFactory), opacityMode)); if (surface->isValid()) { CanvasMetrics::countCanvasContextUsage(CanvasMetrics::DisplayList2DCanvasImageBufferCreated); - return surface.release(); + return surface; } surfaceFactory = adoptPtr(new UnacceleratedSurfaceFactory()); // recreate because previous one was released } @@ -802,7 +802,7 @@ } else { surface = createImageBufferSurface(size(), &msaaSampleCount); } - m_imageBuffer = ImageBuffer::create(surface.release()); + m_imageBuffer = ImageBuffer::create(std::move(surface)); if (!m_imageBuffer) return; m_imageBuffer->setClient(this);
diff --git a/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp b/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp index b589dc5..470740c6 100644 --- a/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLTextFormControlElement.cpp
@@ -393,7 +393,7 @@ VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) const { if (index <= 0) - return createVisiblePosition(firstPositionInNode(innerEditorElement())); + return createVisiblePosition(Position::firstPositionInNode(innerEditorElement())); Position start, end; bool selected = Range::selectNodeContents(innerEditorElement(), start, end); if (!selected)
diff --git a/third_party/WebKit/Source/core/html/HTMLTrackElement.cpp b/third_party/WebKit/Source/core/html/HTMLTrackElement.cpp index d9a9108..7dc0f0cd 100644 --- a/third_party/WebKit/Source/core/html/HTMLTrackElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLTrackElement.cpp
@@ -94,7 +94,15 @@ // 4.8.10.12.3 Sourcing out-of-band text tracks // As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly... } else if (name == kindAttr) { - track()->setKind(!value.isNull() ? value.lower() : TextTrack::subtitlesKeyword()); + AtomicString lowerCaseValue = value.lower(); + // 'missing value default' ("subtitles") + if (lowerCaseValue.isNull()) + lowerCaseValue = TextTrack::subtitlesKeyword(); + // 'invalid value default' ("metadata") + else if (!TextTrack::isValidKindKeyword(lowerCaseValue)) + lowerCaseValue = TextTrack::metadataKeyword(); + + track()->setKind(lowerCaseValue); } else if (name == labelAttr) { track()->setLabel(value); } else if (name == srclangAttr) {
diff --git a/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp b/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp index 867b347..85c3487 100644 --- a/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp +++ b/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp
@@ -242,7 +242,7 @@ ASSERT(m_idleTaskStatus == IdleTaskSwitchedToMainThreadTask); // Continue encoding from the last completed row - if (JPEGImageEncoder::encodeWithPreInitializedState(m_jpegEncoderState.release(), m_data->data(), m_numRowsCompleted)) { + if (JPEGImageEncoder::encodeWithPreInitializedState(std::move(m_jpegEncoderState), m_data->data(), m_numRowsCompleted)) { this->createBlobAndInvokeCallback(); } else { this->createNullAndInvokeCallback();
diff --git a/third_party/WebKit/Source/core/html/forms/FormController.cpp b/third_party/WebKit/Source/core/html/forms/FormController.cpp index fecdd450..f9c01cbf 100644 --- a/third_party/WebKit/Source/core/html/forms/FormController.cpp +++ b/third_party/WebKit/Source/core/html/forms/FormController.cpp
@@ -222,7 +222,7 @@ return nullptr; savedFormState->appendControlState(AtomicString(name), AtomicString(type), state); } - return savedFormState.release(); + return savedFormState; } void SavedFormState::serializeTo(Vector<String>& stateVector) const @@ -493,7 +493,7 @@ i = 0; break; } - map.add(formKey, state.release()); + map.add(formKey, std::move(state)); } if (i != stateVector.size()) map.clear();
diff --git a/third_party/WebKit/Source/core/html/forms/InputType.cpp b/third_party/WebKit/Source/core/html/forms/InputType.cpp index 38b62415..6bd906c 100644 --- a/third_party/WebKit/Source/core/html/forms/InputType.cpp +++ b/third_party/WebKit/Source/core/html/forms/InputType.cpp
@@ -105,7 +105,7 @@ map->add(InputTypeNames::url, URLInputType::create); map->add(InputTypeNames::week, WeekInputType::create); // No need to register "text" because it is the default type. - return map.release(); + return map; } static const InputTypeFactoryMap* factoryMap()
diff --git a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp index 7b0a0342..110d688 100644 --- a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp +++ b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
@@ -102,9 +102,9 @@ , m_parser(config->parser) , m_pendingTokens(adoptPtr(new CompactHTMLTokenStream)) , m_pendingTokenLimit(config->pendingTokenLimit) - , m_xssAuditor(config->xssAuditor.release()) + , m_xssAuditor(std::move(config->xssAuditor)) , m_preloadScanner(adoptPtr(new TokenPreloadScanner(documentURL, std::move(cachedDocumentParameters), mediaValuesCachedData))) - , m_decoder(config->decoder.release()) + , m_decoder(std::move(config->decoder)) , m_loadingTaskRunner(std::move(loadingTaskRunner)) , m_parsedChunkQueue(config->parsedChunkQueue.release()) , m_startingScript(false) @@ -171,8 +171,8 @@ void BackgroundHTMLParser::resumeFrom(PassOwnPtr<Checkpoint> checkpoint) { m_parser = checkpoint->parser; - m_token = checkpoint->token.release(); - m_tokenizer = checkpoint->tokenizer.release(); + m_token = std::move(checkpoint->token); + m_tokenizer = std::move(checkpoint->tokenizer); m_treeBuilderSimulator.setState(checkpoint->treeBuilderState); m_input.rewindTo(checkpoint->inputCheckpoint, checkpoint->unparsedInput); m_preloadScanner->rewindTo(checkpoint->preloadScannerCheckpoint); @@ -242,7 +242,7 @@ if (OwnPtr<XSSInfo> xssInfo = m_xssAuditor->filterToken(FilterTokenRequest(*m_token, m_sourceTracker, m_tokenizer->shouldAllowCDATA()))) { xssInfo->m_textPosition = position; - m_pendingXSSInfos.append(xssInfo.release()); + m_pendingXSSInfos.append(std::move(xssInfo)); } CompactHTMLToken token(m_token.get(), position); @@ -297,12 +297,12 @@ chunk->treeBuilderState = m_treeBuilderSimulator.state(); chunk->inputCheckpoint = m_input.createCheckpoint(m_pendingTokens->size()); chunk->preloadScannerCheckpoint = m_preloadScanner->createCheckpoint(); - chunk->tokens = m_pendingTokens.release(); + chunk->tokens = std::move(m_pendingTokens); chunk->startingScript = m_startingScript; chunk->likelyDocumentWriteScriptIndices.swap(m_likelyDocumentWriteScriptIndices); m_startingScript = false; - bool isEmpty = m_parsedChunkQueue->enqueue(chunk.release()); + bool isEmpty = m_parsedChunkQueue->enqueue(std::move(chunk)); if (isEmpty) { m_loadingTaskRunner->postTask( BLINK_FROM_HERE,
diff --git a/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp b/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp index 15a5aaf..939aa383 100644 --- a/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp +++ b/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp
@@ -222,7 +222,7 @@ TextPosition position = TextPosition(source.currentLine(), source.currentColumn()); OwnPtr<PreloadRequest> request = PreloadRequest::create(FetchInitiatorTypeNames::css, position, url, *m_predictedBaseElementURL, Resource::CSSStyleSheet, m_referrerPolicy); // FIXME: Should this be including the charset in the preload request? - m_requests->append(request.release()); + m_requests->append(std::move(request)); } m_state = Initial; } else if (equalIgnoringCase(m_rule, "charset"))
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp index bbdb2df..f1ecb82d 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -302,7 +302,7 @@ if (!document()->documentElement()) { for (auto& chunk : pendingChunks) { for (auto& request : chunk->preloads) - m_queuedPreloads.append(request.release()); + m_queuedPreloads.append(std::move(request)); for (auto& index : chunk->likelyDocumentWriteScriptIndices) { const CompactHTMLToken& token = chunk->tokens->at(index); ASSERT(token.type() == HTMLToken::TokenType::Character); @@ -326,7 +326,7 @@ } for (auto& chunk : pendingChunks) - m_speculations.append(chunk.release()); + m_speculations.append(std::move(chunk)); if (!isWaitingForScripts() && !isScheduledForResume()) { if (m_tasksWereSuspended) @@ -355,8 +355,8 @@ } ASSERT(!m_lastChunkBeforeScript); - OwnPtr<HTMLTokenizer> tokenizer = m_tokenizer.release(); - OwnPtr<HTMLToken> token = m_token.release(); + OwnPtr<HTMLTokenizer> tokenizer = std::move(m_tokenizer); + OwnPtr<HTMLToken> token = std::move(m_token); if (!tokenizer) { // There must not have been any changes to the HTMLTokenizer state on @@ -377,7 +377,7 @@ return; } - discardSpeculationsAndResumeFrom(std::move(chunk), token.release(), tokenizer.release()); + discardSpeculationsAndResumeFrom(std::move(chunk), std::move(token), std::move(tokenizer)); } void HTMLDocumentParser::discardSpeculationsAndResumeFrom(PassOwnPtr<ParsedChunk> lastChunkBeforeScript, PassOwnPtr<HTMLToken> token, PassOwnPtr<HTMLTokenizer> tokenizer) @@ -396,7 +396,7 @@ m_input.current().clear(); // FIXME: This should be passed in instead of cleared. ASSERT(checkpoint->unparsedInput.isSafeToSendToAnotherThread()); - HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::resumeFrom, AllowCrossThreadAccess(m_backgroundParser), passed(checkpoint.release()))); + HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::resumeFrom, AllowCrossThreadAccess(m_backgroundParser), passed(std::move(checkpoint)))); } size_t HTMLDocumentParser::processParsedChunkFromBackgroundParser(PassOwnPtr<ParsedChunk> popChunk) @@ -415,7 +415,7 @@ ASSERT(!m_lastChunkBeforeScript); OwnPtr<ParsedChunk> chunk(std::move(popChunk)); - OwnPtr<CompactHTMLTokenStream> tokens = chunk->tokens.release(); + OwnPtr<CompactHTMLTokenStream> tokens = std::move(chunk->tokens); size_t elementTokenCount = 0; HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::startedChunkWithCheckpoint, AllowCrossThreadAccess(m_backgroundParser), chunk->inputCheckpoint)); @@ -469,7 +469,7 @@ if (isWaitingForScripts()) { ASSERT(it + 1 == tokens->end()); // The </script> is assumed to be the last token of this bunch. runScriptsForPausedTreeBuilder(); - validateSpeculations(chunk.release()); + validateSpeculations(std::move(chunk)); break; } @@ -525,7 +525,7 @@ SpeculationsPumpSession session(m_pumpSpeculationsSessionNestingLevel); while (!m_speculations.isEmpty()) { ASSERT(!isScheduledForResume()); - size_t elementTokenCount = processParsedChunkFromBackgroundParser(m_speculations.takeFirst().release()); + size_t elementTokenCount = processParsedChunkFromBackgroundParser(m_speculations.takeFirst()); session.addedElementTokens(elementTokenCount); // Always check isParsing first as m_document may be null. @@ -730,7 +730,7 @@ HTMLParserThread::shared()->postTask(threadSafeBind( &BackgroundHTMLParser::start, reference.release(), - passed(config.release()), + passed(std::move(config)), document()->url(), passed(CachedDocumentParameters::create(document())), MediaValuesCached::MediaValuesCachedData(*document()), @@ -927,7 +927,7 @@ ASSERT(!isWaitingForScripts()); if (m_haveBackgroundParser) { - validateSpeculations(m_lastChunkBeforeScript.release()); + validateSpeculations(std::move(m_lastChunkBeforeScript)); ASSERT(!m_lastChunkBeforeScript); pumpPendingSpeculations(); return; @@ -1016,7 +1016,7 @@ memcpy(buffer->data(), data, length); TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "HTMLDocumentParser::appendBytes", "size", (unsigned)length); - HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::appendRawBytesFromMainThread, AllowCrossThreadAccess(m_backgroundParser), passed(buffer.release()))); + HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::appendRawBytesFromMainThread, AllowCrossThreadAccess(m_backgroundParser), passed(std::move(buffer)))); return; }
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp index 01b52462..fe0dfa0e 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
@@ -236,7 +236,7 @@ request->setCharset(charset()); request->setDefer(m_defer); request->setIntegrityMetadata(m_integrityMetadata); - return request.release(); + return request; } private: @@ -736,7 +736,7 @@ scanner.handlePictureSourceURL(m_pictureData); OwnPtr<PreloadRequest> request = scanner.createPreloadRequest(m_predictedBaseElementURL, source, m_clientHintsPreferences, m_pictureData, m_documentParameters->referrerPolicy); if (request) - requests.append(request.release()); + requests.append(std::move(request)); return; } default: {
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloaderTest.cpp b/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloaderTest.cpp index 7de6acfa..4326fd3 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloaderTest.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLResourcePreloaderTest.cpp
@@ -65,7 +65,7 @@ if (testCase.isCORS) preloadRequest->setCrossOrigin(CrossOriginAttributeAnonymous); HTMLResourcePreloader* preloader = HTMLResourcePreloader::create(m_dummyPageHolder->document()); - preloader->preload(preloadRequest.release(), networkHints); + preloader->preload(std::move(preloadRequest), networkHints); ASSERT_TRUE(networkHints.didPreconnect()); ASSERT_EQ(testCase.isCORS, networkHints.isCrossOrigin()); ASSERT_EQ(testCase.isHTTPS, networkHints.isHTTPS());
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp b/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp index f89f9ab..b81d158 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLScriptRunner.cpp
@@ -63,7 +63,7 @@ value->setInteger("lineNumber", textPosition.m_line.oneBasedInt()); value->setInteger("columnNumber", textPosition.m_column.oneBasedInt()); } - return value.release(); + return value; } bool doExecuteScript(Element* scriptElement, const ScriptSourceCode& sourceCode, const TextPosition& textPosition)
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLToken.h b/third_party/WebKit/Source/core/html/parser/HTMLToken.h index 024e01ec..3c90de9d 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLToken.h +++ b/third_party/WebKit/Source/core/html/parser/HTMLToken.h
@@ -256,7 +256,7 @@ PassOwnPtr<DoctypeData> releaseDoctypeData() { - return m_doctypeData.release(); + return std::move(m_doctypeData); } /* Start/End Tag Tokens */
diff --git a/third_party/WebKit/Source/core/html/parser/ResourcePreloader.cpp b/third_party/WebKit/Source/core/html/parser/ResourcePreloader.cpp index 47bd619..48bb7ae 100644 --- a/third_party/WebKit/Source/core/html/parser/ResourcePreloader.cpp +++ b/third_party/WebKit/Source/core/html/parser/ResourcePreloader.cpp
@@ -14,7 +14,7 @@ requests.swap(r); for (PreloadRequestStream::iterator it = requests.begin(); it != requests.end(); ++it) - preload(it->release(), networkHintsInterface); + preload(std::move(*it), networkHintsInterface); } } // namespace blink
diff --git a/third_party/WebKit/Source/core/html/parser/XSSAuditor.cpp b/third_party/WebKit/Source/core/html/parser/XSSAuditor.cpp index 0112438c..bbf0cb1 100644 --- a/third_party/WebKit/Source/core/html/parser/XSSAuditor.cpp +++ b/third_party/WebKit/Source/core/html/parser/XSSAuditor.cpp
@@ -417,7 +417,7 @@ if (didBlockScript) { bool didBlockEntirePage = (m_xssProtection == BlockReflectedXSS); OwnPtr<XSSInfo> xssInfo = XSSInfo::create(m_documentURL, didBlockEntirePage, m_didSendValidXSSProtectionHeader, m_didSendValidCSPHeader); - return xssInfo.release(); + return xssInfo; } return nullptr; }
diff --git a/third_party/WebKit/Source/core/html/track/AudioTrack.cpp b/third_party/WebKit/Source/core/html/track/AudioTrack.cpp index b7d32c5..e24173b 100644 --- a/third_party/WebKit/Source/core/html/track/AudioTrack.cpp +++ b/third_party/WebKit/Source/core/html/track/AudioTrack.cpp
@@ -9,10 +9,9 @@ namespace blink { AudioTrack::AudioTrack(const String& id, const AtomicString& kind, const AtomicString& label, const AtomicString& language, bool enabled) - : TrackBase(WebMediaPlayer::AudioTrack, label, language, id) + : TrackBase(WebMediaPlayer::AudioTrack, kind, label, language, id) , m_enabled(enabled) { - setKind(kind); } AudioTrack::~AudioTrack() @@ -73,18 +72,13 @@ bool AudioTrack::isValidKindKeyword(const String& kind) { - return (kind == alternativeKeyword()) - || (kind == descriptionsKeyword()) - || (kind == mainKeyword()) - || (kind == mainDescriptionsKeyword()) - || (kind == translationKeyword()) - || (kind == commentaryKeyword()) - || (kind == emptyAtom); -} - -AtomicString AudioTrack::invalidValueDefaultKind() const -{ - return emptyAtom; + return kind == alternativeKeyword() + || kind == descriptionsKeyword() + || kind == mainKeyword() + || kind == mainDescriptionsKeyword() + || kind == translationKeyword() + || kind == commentaryKeyword() + || kind == emptyAtom; } } // namespace blink
diff --git a/third_party/WebKit/Source/core/html/track/AudioTrack.h b/third_party/WebKit/Source/core/html/track/AudioTrack.h index f6087e44..1a012a01 100644 --- a/third_party/WebKit/Source/core/html/track/AudioTrack.h +++ b/third_party/WebKit/Source/core/html/track/AudioTrack.h
@@ -17,7 +17,7 @@ public: static AudioTrack* create(const String& id, const AtomicString& kind, const AtomicString& label, const AtomicString& language, bool enabled) { - return new AudioTrack(id, kind, label, language, enabled); + return new AudioTrack(id, isValidKindKeyword(kind) ? kind : emptyAtom, label, language, enabled); } ~AudioTrack() override; @@ -39,10 +39,6 @@ private: AudioTrack(const String& id, const AtomicString& kind, const AtomicString& label, const AtomicString& language, bool enabled); - // TrackBase - bool isValidKind(const AtomicString& kind) const override { return isValidKindKeyword(kind); } - AtomicString invalidValueDefaultKind() const override; - bool m_enabled; };
diff --git a/third_party/WebKit/Source/core/html/track/InbandTextTrack.cpp b/third_party/WebKit/Source/core/html/track/InbandTextTrack.cpp index ebc5f73ad..78cb2b7 100644 --- a/third_party/WebKit/Source/core/html/track/InbandTextTrack.cpp +++ b/third_party/WebKit/Source/core/html/track/InbandTextTrack.cpp
@@ -25,51 +25,51 @@ #include "core/html/track/InbandTextTrack.h" -#include "bindings/core/v8/ExceptionStatePlaceholder.h" #include "core/html/HTMLMediaElement.h" #include "core/html/track/vtt/VTTCue.h" -#include "platform/Logging.h" #include "public/platform/WebInbandTextTrack.h" #include "public/platform/WebString.h" -#include <math.h> using blink::WebInbandTextTrack; using blink::WebString; namespace blink { +namespace { + +const AtomicString& textTrackKindToString(WebInbandTextTrack::Kind kind) +{ + switch (kind) { + case WebInbandTextTrack::KindSubtitles: + return TextTrack::subtitlesKeyword(); + case WebInbandTextTrack::KindCaptions: + return TextTrack::captionsKeyword(); + case WebInbandTextTrack::KindDescriptions: + return TextTrack::descriptionsKeyword(); + case WebInbandTextTrack::KindChapters: + return TextTrack::chaptersKeyword(); + case WebInbandTextTrack::KindMetadata: + return TextTrack::metadataKeyword(); + case WebInbandTextTrack::KindNone: + default: + break; + } + ASSERT_NOT_REACHED(); + return TextTrack::subtitlesKeyword(); +} + +} // namespace + InbandTextTrack* InbandTextTrack::create(WebInbandTextTrack* webTrack) { return new InbandTextTrack(webTrack); } InbandTextTrack::InbandTextTrack(WebInbandTextTrack* webTrack) - : TextTrack(subtitlesKeyword(), webTrack->label(), webTrack->language(), webTrack->id(), InBand) + : TextTrack(textTrackKindToString(webTrack->kind()), webTrack->label(), webTrack->language(), webTrack->id(), InBand) , m_webTrack(webTrack) { m_webTrack->setClient(this); - - switch (m_webTrack->kind()) { - case WebInbandTextTrack::KindSubtitles: - setKind(TextTrack::subtitlesKeyword()); - break; - case WebInbandTextTrack::KindCaptions: - setKind(TextTrack::captionsKeyword()); - break; - case WebInbandTextTrack::KindDescriptions: - setKind(TextTrack::descriptionsKeyword()); - break; - case WebInbandTextTrack::KindChapters: - setKind(TextTrack::chaptersKeyword()); - break; - case WebInbandTextTrack::KindMetadata: - setKind(TextTrack::metadataKeyword()); - break; - case WebInbandTextTrack::KindNone: - default: - ASSERT_NOT_REACHED(); - break; - } } InbandTextTrack::~InbandTextTrack()
diff --git a/third_party/WebKit/Source/core/html/track/TextTrack.cpp b/third_party/WebKit/Source/core/html/track/TextTrack.cpp index 097a1f2..9221e793 100644 --- a/third_party/WebKit/Source/core/html/track/TextTrack.cpp +++ b/third_party/WebKit/Source/core/html/track/TextTrack.cpp
@@ -78,24 +78,24 @@ const AtomicString& TextTrack::disabledKeyword() { - DEFINE_STATIC_LOCAL(const AtomicString, open, ("disabled")); - return open; + DEFINE_STATIC_LOCAL(const AtomicString, disabled, ("disabled")); + return disabled; } const AtomicString& TextTrack::hiddenKeyword() { - DEFINE_STATIC_LOCAL(const AtomicString, closed, ("hidden")); - return closed; + DEFINE_STATIC_LOCAL(const AtomicString, hidden, ("hidden")); + return hidden; } const AtomicString& TextTrack::showingKeyword() { - DEFINE_STATIC_LOCAL(const AtomicString, ended, ("showing")); - return ended; + DEFINE_STATIC_LOCAL(const AtomicString, showing, ("showing")); + return showing; } TextTrack::TextTrack(const AtomicString& kind, const AtomicString& label, const AtomicString& language, const AtomicString& id, TextTrackType type) - : TrackBase(WebMediaPlayer::TextTrack, label, language, id) + : TrackBase(WebMediaPlayer::TextTrack, kind, label, language, id) , m_cues(nullptr) , m_regions(nullptr) , m_trackList(nullptr) @@ -106,7 +106,6 @@ , m_renderedTrackIndex(invalidTrackIndex) , m_hasBeenConfigured(false) { - setKind(kind); } TextTrack::~TextTrack()
diff --git a/third_party/WebKit/Source/core/html/track/TextTrack.h b/third_party/WebKit/Source/core/html/track/TextTrack.h index 7dc97611..fbdae4b 100644 --- a/third_party/WebKit/Source/core/html/track/TextTrack.h +++ b/third_party/WebKit/Source/core/html/track/TextTrack.h
@@ -124,9 +124,6 @@ protected: TextTrack(const AtomicString& kind, const AtomicString& label, const AtomicString& language, const AtomicString& id, TextTrackType); - bool isValidKind(const AtomicString& kind) const override { return isValidKindKeyword(kind); } - AtomicString invalidValueDefaultKind() const override { return metadataKeyword(); } - void addListOfCues(HeapVector<Member<TextTrackCue>>&); private:
diff --git a/third_party/WebKit/Source/core/html/track/TrackBase.cpp b/third_party/WebKit/Source/core/html/track/TrackBase.cpp index dd21623..3db71a7d 100644 --- a/third_party/WebKit/Source/core/html/track/TrackBase.cpp +++ b/third_party/WebKit/Source/core/html/track/TrackBase.cpp
@@ -40,9 +40,10 @@ return ++next; } -TrackBase::TrackBase(WebMediaPlayer::TrackType type, const AtomicString& label, const AtomicString& language, const String& id) +TrackBase::TrackBase(WebMediaPlayer::TrackType type, const AtomicString& kind, const AtomicString& label, const AtomicString& language, const String& id) : m_trackId(nextTrackId()) , m_type(type) + , m_kind(kind) , m_label(label) , m_language(language) , m_id(id) @@ -67,10 +68,7 @@ void TrackBase::setKind(const AtomicString& kind) { - if (isValidKind(kind)) - m_kind = kind; - else - m_kind = invalidValueDefaultKind(); + m_kind = kind; } } // namespace blink
diff --git a/third_party/WebKit/Source/core/html/track/TrackBase.h b/third_party/WebKit/Source/core/html/track/TrackBase.h index b65f3a8..e756c0c 100644 --- a/third_party/WebKit/Source/core/html/track/TrackBase.h +++ b/third_party/WebKit/Source/core/html/track/TrackBase.h
@@ -63,10 +63,7 @@ DECLARE_VIRTUAL_TRACE(); protected: - TrackBase(WebMediaPlayer::TrackType, const AtomicString& label, const AtomicString& language, const String& id); - - virtual bool isValidKind(const AtomicString&) const = 0; - virtual AtomicString invalidValueDefaultKind() const = 0; + TrackBase(WebMediaPlayer::TrackType, const AtomicString& kind, const AtomicString& label, const AtomicString& language, const String& id); private: WebMediaPlayer::TrackId m_trackId;
diff --git a/third_party/WebKit/Source/core/html/track/VideoTrack.cpp b/third_party/WebKit/Source/core/html/track/VideoTrack.cpp index c2a0889..9903e3a 100644 --- a/third_party/WebKit/Source/core/html/track/VideoTrack.cpp +++ b/third_party/WebKit/Source/core/html/track/VideoTrack.cpp
@@ -9,10 +9,9 @@ namespace blink { VideoTrack::VideoTrack(const String& id, const AtomicString& kind, const AtomicString& label, const AtomicString& language, bool selected) - : TrackBase(WebMediaPlayer::VideoTrack, label, language, id) + : TrackBase(WebMediaPlayer::VideoTrack, kind, label, language, id) , m_selected(selected) { - setKind(kind); } VideoTrack::~VideoTrack() @@ -75,18 +74,13 @@ bool VideoTrack::isValidKindKeyword(const String& kind) { - return (kind == alternativeKeyword()) - || (kind == captionsKeyword()) - || (kind == mainKeyword()) - || (kind == signKeyword()) - || (kind == subtitlesKeyword()) - || (kind == commentaryKeyword()) - || (kind == emptyAtom); -} - -AtomicString VideoTrack::invalidValueDefaultKind() const -{ - return emptyAtom; + return kind == alternativeKeyword() + || kind == captionsKeyword() + || kind == mainKeyword() + || kind == signKeyword() + || kind == subtitlesKeyword() + || kind == commentaryKeyword() + || kind == emptyAtom; } } // namespace blink
diff --git a/third_party/WebKit/Source/core/html/track/VideoTrack.h b/third_party/WebKit/Source/core/html/track/VideoTrack.h index 4040120..5acc842 100644 --- a/third_party/WebKit/Source/core/html/track/VideoTrack.h +++ b/third_party/WebKit/Source/core/html/track/VideoTrack.h
@@ -17,7 +17,7 @@ public: static VideoTrack* create(const String& id, const AtomicString& kind, const AtomicString& label, const AtomicString& language, bool selected) { - return new VideoTrack(id, kind, label, language, selected); + return new VideoTrack(id, isValidKindKeyword(kind) ? kind : emptyAtom, label, language, selected); } ~VideoTrack() override; @@ -43,10 +43,6 @@ private: VideoTrack(const String& id, const AtomicString& kind, const AtomicString& label, const AtomicString& language, bool selected); - // TrackBase - bool isValidKind(const AtomicString& kind) const override { return isValidKindKeyword(kind); } - AtomicString invalidValueDefaultKind() const override; - bool m_selected; };
diff --git a/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp b/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp index 80df3828..9c29fa20 100644 --- a/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp +++ b/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp
@@ -238,7 +238,7 @@ RefPtr<SkImage> frame; if (decoder) { decoder->setData(sharedBuffer.get(), true); - frame = ImageBitmap::getSkImageFromDecoder(decoder.release()); + frame = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); } taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&ImageBitmapFactories::ImageBitmapLoader::resolvePromiseOnOriginalThread, AllowCrossThreadAccess(this), frame.release())); }
diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp index a273c53f..891e0ad 100644 --- a/third_party/WebKit/Source/core/input/EventHandler.cpp +++ b/third_party/WebKit/Source/core/input/EventHandler.cpp
@@ -628,7 +628,7 @@ scrollStateData->from_user_input = true; scrollStateData->delta_consumed_for_scroll_sequence = false; ScrollState* scrollState = - ScrollState::create(scrollStateData.release()); + ScrollState::create(std::move(scrollStateData)); customizedScroll(*node, *scrollState); @@ -2376,7 +2376,7 @@ scrollStateData->from_user_input = true; scrollStateData->is_direct_manipulation = true; scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsumedForScrollSequence; - ScrollState* scrollState = ScrollState::create(scrollStateData.release()); + ScrollState* scrollState = ScrollState::create(std::move(scrollStateData)); customizedScroll(*node, *scrollState); } } @@ -2417,7 +2417,7 @@ scrollStateData->is_beginning = true; scrollStateData->from_user_input = true; scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsumedForScrollSequence; - ScrollState* scrollState = ScrollState::create(scrollStateData.release()); + ScrollState* scrollState = ScrollState::create(std::move(scrollStateData)); customizedScroll(*m_scrollGestureHandlingNode.get(), *scrollState); } else { if (m_frame->isMainFrame()) @@ -2485,7 +2485,7 @@ scrollStateData->is_in_inertial_phase = gestureEvent.inertial(); scrollStateData->from_user_input = true; scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsumedForScrollSequence; - ScrollState* scrollState = ScrollState::create(scrollStateData.release()); + ScrollState* scrollState = ScrollState::create(std::move(scrollStateData)); if (m_previousGestureScrolledNode) { // The ScrollState needs to know what the current // native scrolling element is, so that for an
diff --git a/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp b/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp index 8502e4b3..0deb8ab 100644 --- a/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp +++ b/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp
@@ -622,7 +622,7 @@ return; } - CrossOriginPreflightResultCache::shared().appendEntry(getSecurityOrigin()->toString(), m_actualRequest.url(), preflightResult.release()); + CrossOriginPreflightResultCache::shared().appendEntry(getSecurityOrigin()->toString(), m_actualRequest.url(), std::move(preflightResult)); } void DocumentThreadableLoader::reportResponseReceived(unsigned long identifier, const ResourceResponse& response)
diff --git a/third_party/WebKit/Source/core/loader/DocumentWriter.cpp b/third_party/WebKit/Source/core/loader/DocumentWriter.cpp index acf9178..5cfca6d3 100644 --- a/third_party/WebKit/Source/core/loader/DocumentWriter.cpp +++ b/third_party/WebKit/Source/core/loader/DocumentWriter.cpp
@@ -87,7 +87,7 @@ ASSERT(m_parser); if (m_parser->needsDecoder() && 0 < length) { OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_document); - m_parser->setDecoder(decoder.release()); + m_parser->setDecoder(std::move(decoder)); } // appendBytes() can result replacing DocumentLoader::m_writer. m_parser->appendBytes(bytes, length); @@ -102,7 +102,7 @@ if (m_parser->needsDecoder()) { OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_document); - m_parser->setDecoder(decoder.release()); + m_parser->setDecoder(std::move(decoder)); } m_parser->finish();
diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp index 17bfc33..398434f 100644 --- a/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp +++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp
@@ -393,7 +393,7 @@ value->setString("requestId", requestId); value->setString("url", url.getString()); value->setInteger("priority", priority); - return value.release(); + return value; } void FrameFetchContext::willStartLoadingResource(Resource* resource, ResourceRequest& request)
diff --git a/third_party/WebKit/Source/core/loader/FrameLoader.cpp b/third_party/WebKit/Source/core/loader/FrameLoader.cpp index 6ddde49c..070cc94 100644 --- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp +++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
@@ -1562,7 +1562,7 @@ tracedValue->setString("stateMachine", m_stateMachine.toString()); tracedValue->setString("provisionalDocumentLoaderURL", m_provisionalDocumentLoader ? m_provisionalDocumentLoader->url() : String()); tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoader->url() : String()); - return tracedValue.release(); + return tracedValue; } inline void FrameLoader::takeObjectSnapshot() const
diff --git a/third_party/WebKit/Source/core/loader/TextResourceDecoderBuilder.cpp b/third_party/WebKit/Source/core/loader/TextResourceDecoderBuilder.cpp index 9b1e3d4..655aa28 100644 --- a/third_party/WebKit/Source/core/loader/TextResourceDecoderBuilder.cpp +++ b/third_party/WebKit/Source/core/loader/TextResourceDecoderBuilder.cpp
@@ -171,7 +171,7 @@ { OwnPtr<TextResourceDecoder> decoder = createDecoderInstance(document); setupEncoding(decoder.get(), document); - return decoder.release(); + return decoder; } void TextResourceDecoderBuilder::clear()
diff --git a/third_party/WebKit/Source/core/loader/WorkerThreadableLoader.cpp b/third_party/WebKit/Source/core/loader/WorkerThreadableLoader.cpp index 4d02cf9..013df23 100644 --- a/third_party/WebKit/Source/core/loader/WorkerThreadableLoader.cpp +++ b/third_party/WebKit/Source/core/loader/WorkerThreadableLoader.cpp
@@ -55,7 +55,7 @@ { OwnPtr<Vector<char>> buffer = adoptPtr(new Vector<char>(dataLength)); memcpy(buffer->data(), data, dataLength); - return buffer.release(); + return buffer; } WorkerThreadableLoader::WorkerThreadableLoader(WorkerGlobalScope& workerGlobalScope, ThreadableLoaderClient* client, const ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions, BlockingBehavior blockingBehavior)
diff --git a/third_party/WebKit/Source/core/page/DragController.cpp b/third_party/WebKit/Source/core/page/DragController.cpp index 7562128..aaaa83f6 100644 --- a/third_party/WebKit/Source/core/page/DragController.cpp +++ b/third_party/WebKit/Source/core/page/DragController.cpp
@@ -831,7 +831,7 @@ } dragLocation = dragOrigin + origin; - return dragImage.release(); + return dragImage; } static PassOwnPtr<DragImage> dragImageForLink(const KURL& linkURL, const String& linkText, float deviceScaleFactor, const IntPoint& mouseDraggedPoint, IntPoint& dragLoc) @@ -844,7 +844,7 @@ IntPoint dragImageOffset(-size.width() / 2, -LinkDragBorderInset); dragLoc = IntPoint(mouseDraggedPoint.x() + dragImageOffset.x(), mouseDraggedPoint.y() + dragImageOffset.y()); - return dragImage.release(); + return dragImage; } bool DragController::startDrag(LocalFrame* src, const DragState& state, const PlatformMouseEvent& dragEvent, const IntPoint& dragOrigin)
diff --git a/third_party/WebKit/Source/core/page/scrolling/ScrollState.cpp b/third_party/WebKit/Source/core/page/scrolling/ScrollState.cpp index 1d2f4e4..e8caada 100644 --- a/third_party/WebKit/Source/core/page/scrolling/ScrollState.cpp +++ b/third_party/WebKit/Source/core/page/scrolling/ScrollState.cpp
@@ -40,7 +40,7 @@ scrollStateData->from_user_input = init.fromUserInput(); scrollStateData->is_direct_manipulation = init.isDirectManipulation(); scrollStateData->delta_granularity = init.deltaGranularity(); - ScrollState* scrollState = new ScrollState(scrollStateData.release()); + ScrollState* scrollState = new ScrollState(std::move(scrollStateData)); return scrollState; }
diff --git a/third_party/WebKit/Source/core/page/scrolling/ScrollStateTest.cpp b/third_party/WebKit/Source/core/page/scrolling/ScrollStateTest.cpp index d0fb2dc..e79dce5 100644 --- a/third_party/WebKit/Source/core/page/scrolling/ScrollStateTest.cpp +++ b/third_party/WebKit/Source/core/page/scrolling/ScrollStateTest.cpp
@@ -19,7 +19,7 @@ scrollStateData->delta_y = deltaY; scrollStateData->is_beginning = beginning; scrollStateData->is_ending = ending; - return ScrollState::create(scrollStateData.release()); + return ScrollState::create(std::move(scrollStateData)); } class ScrollStateTest : public testing::Test {
diff --git a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp index 120b2a1..97799b10 100644 --- a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp +++ b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp
@@ -286,7 +286,7 @@ OwnPtr<WebScrollbarLayer> scrollbarLayer = adoptPtr(Platform::current()->compositorSupport()->createScrollbarLayer(WebScrollbarImpl::create(&scrollbar), painter, geometry.leakPtr())); GraphicsLayer::registerContentsLayer(scrollbarLayer->layer()); - return scrollbarLayer.release(); + return scrollbarLayer; } PassOwnPtr<WebScrollbarLayer> ScrollingCoordinator::createSolidColorScrollbarLayer(ScrollbarOrientation orientation, int thumbThickness, int trackStart, bool isLeftSideVerticalScrollbar) @@ -294,7 +294,7 @@ WebScrollbar::Orientation webOrientation = (orientation == HorizontalScrollbar) ? WebScrollbar::Horizontal : WebScrollbar::Vertical; OwnPtr<WebScrollbarLayer> scrollbarLayer = adoptPtr(Platform::current()->compositorSupport()->createSolidColorScrollbarLayer(webOrientation, thumbThickness, trackStart, isLeftSideVerticalScrollbar)); GraphicsLayer::registerContentsLayer(scrollbarLayer->layer()); - return scrollbarLayer.release(); + return scrollbarLayer; } static void detachScrollbarLayer(GraphicsLayer* scrollbarGraphicsLayer) @@ -356,7 +356,7 @@ } else { webScrollbarLayer = createScrollbarLayer(scrollbar, m_page->deviceScaleFactor()); } - scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, webScrollbarLayer.release()); + scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, std::move(webScrollbarLayer)); } WebLayer* scrollLayer = toWebLayer(scrollableArea->layerForScrolling());
diff --git a/third_party/WebKit/Source/core/paint/FilterPainter.cpp b/third_party/WebKit/Source/core/paint/FilterPainter.cpp index cfc6cd8..eb90aaa 100644 --- a/third_party/WebKit/Source/core/paint/FilterPainter.cpp +++ b/third_party/WebKit/Source/core/paint/FilterPainter.cpp
@@ -75,7 +75,7 @@ visualBounds.moveBy(-offsetFromRoot); layer.convertFromFlowThreadToVisualBoundingBoxInAncestor(paintingInfo.rootLayer, visualBounds); } - context.getPaintController().createAndAppend<BeginFilterDisplayItem>(*m_layoutObject, std::move(imageFilter), FloatRect(visualBounds), compositorFilterOperations.release()); + context.getPaintController().createAndAppend<BeginFilterDisplayItem>(*m_layoutObject, std::move(imageFilter), FloatRect(visualBounds), std::move(compositorFilterOperations)); } m_filterInProgress = true;
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp index 35b0fb3..eada3d7 100644 --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
@@ -213,7 +213,7 @@ borderBoxContext->transform = context.currentTransform; borderBoxContext->clip = context.currentClip; borderBoxContext->effect = context.currentEffect; - object.ensureObjectPaintProperties().setLocalBorderBoxProperties(borderBoxContext.release()); + object.ensureObjectPaintProperties().setLocalBorderBoxProperties(std::move(borderBoxContext)); } // TODO(trchen): Remove this once we bake the paint offset into frameRect.
diff --git a/third_party/WebKit/Source/core/style/ContentData.h b/third_party/WebKit/Source/core/style/ContentData.h index 2d8d007..683319d 100644 --- a/third_party/WebKit/Source/core/style/ContentData.h +++ b/third_party/WebKit/Source/core/style/ContentData.h
@@ -154,7 +154,7 @@ ContentData* cloneInternal() const override { OwnPtr<CounterContent> counterData = adoptPtr(new CounterContent(*counter())); - return create(counterData.release()); + return create(std::move(counterData)); } bool equals(const ContentData& data) const override
diff --git a/third_party/WebKit/Source/core/style/CounterDirectives.cpp b/third_party/WebKit/Source/core/style/CounterDirectives.cpp index b2dd65b..ce9d391cb 100644 --- a/third_party/WebKit/Source/core/style/CounterDirectives.cpp +++ b/third_party/WebKit/Source/core/style/CounterDirectives.cpp
@@ -37,7 +37,7 @@ { OwnPtr<CounterDirectiveMap> result = adoptPtr(new CounterDirectiveMap); *result = counterDirectives; - return result.release(); + return result; } } // namespace blink
diff --git a/third_party/WebKit/Source/core/style/ShadowList.cpp b/third_party/WebKit/Source/core/style/ShadowList.cpp index 38668bac..281d415 100644 --- a/third_party/WebKit/Source/core/style/ShadowList.cpp +++ b/third_party/WebKit/Source/core/style/ShadowList.cpp
@@ -88,7 +88,7 @@ DrawLooperBuilder::ShadowRespectsTransforms, alphaMode); } drawLooperBuilder->addUnmodifiedContent(); - return drawLooperBuilder.release(); + return drawLooperBuilder; } } // namespace blink
diff --git a/third_party/WebKit/Source/core/svg/SVGPath.cpp b/third_party/WebKit/Source/core/svg/SVGPath.cpp index fea565a..51837fc 100644 --- a/third_party/WebKit/Source/core/svg/SVGPath.cpp +++ b/third_party/WebKit/Source/core/svg/SVGPath.cpp
@@ -43,7 +43,7 @@ SVGPathByteStreamSource toSource(toStream); SVGPathBlender blender(&fromSource, &toSource, &builder); blender.blendAnimatedPath(progress); - return resultStream.release(); + return resultStream; } PassOwnPtr<SVGPathByteStream> addPathByteStreams(const SVGPathByteStream& fromStream, const SVGPathByteStream& byStream, unsigned repeatCount = 1) @@ -54,7 +54,7 @@ SVGPathByteStreamSource bySource(byStream); SVGPathBlender blender(&fromSource, &bySource, &builder); blender.addAnimatedPath(repeatCount); - return resultStream.release(); + return resultStream; } PassOwnPtr<SVGPathByteStream> conditionallyAddPathByteStreams(PassOwnPtr<SVGPathByteStream> fromStream, const SVGPathByteStream& byStream, unsigned repeatCount = 1) @@ -98,7 +98,7 @@ { OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create(); SVGParsingError parseStatus = buildByteStreamFromString(string, *byteStream); - m_pathValue = CSSPathValue::create(byteStream.release()); + m_pathValue = CSSPathValue::create(std::move(byteStream)); return parseStatus; } @@ -106,7 +106,7 @@ { OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create(); buildByteStreamFromString(value, *byteStream); - return SVGPath::create(CSSPathValue::create(byteStream.release())); + return SVGPath::create(CSSPathValue::create(std::move(byteStream))); } void SVGPath::add(SVGPropertyBase* other, SVGElement*) @@ -158,13 +158,13 @@ // Handle additive='sum'. if (animationElement->isAdditive() && !isToAnimation) - newStream = conditionallyAddPathByteStreams(newStream.release(), byteStream()); + newStream = conditionallyAddPathByteStreams(std::move(newStream), byteStream()); // Handle accumulate='sum'. if (animationElement->isAccumulated() && repeatCount) - newStream = conditionallyAddPathByteStreams(newStream.release(), toSVGPath(toAtEndOfDurationValue)->byteStream(), repeatCount); + newStream = conditionallyAddPathByteStreams(std::move(newStream), toSVGPath(toAtEndOfDurationValue)->byteStream(), repeatCount); - m_pathValue = CSSPathValue::create(newStream.release()); + m_pathValue = CSSPathValue::create(std::move(newStream)); } float SVGPath::calculateDistance(SVGPropertyBase* to, SVGElement*)
diff --git a/third_party/WebKit/Source/core/svg/SVGTextContentElement.cpp b/third_party/WebKit/Source/core/svg/SVGTextContentElement.cpp index 7569d2d..f8ff6279 100644 --- a/third_party/WebKit/Source/core/svg/SVGTextContentElement.cpp +++ b/third_party/WebKit/Source/core/svg/SVGTextContentElement.cpp
@@ -188,7 +188,7 @@ ASSERT(document().frame()); // Find selection start - VisiblePosition start = createVisiblePosition(firstPositionInNode(const_cast<SVGTextContentElement*>(this))); + VisiblePosition start = createVisiblePosition(Position::firstPositionInNode(const_cast<SVGTextContentElement*>(this))); for (unsigned i = 0; i < charnum; ++i) start = nextPositionOf(start);
diff --git a/third_party/WebKit/Source/core/workers/DedicatedWorkerGlobalScope.cpp b/third_party/WebKit/Source/core/workers/DedicatedWorkerGlobalScope.cpp index 902528ec..846935f 100644 --- a/third_party/WebKit/Source/core/workers/DedicatedWorkerGlobalScope.cpp +++ b/third_party/WebKit/Source/core/workers/DedicatedWorkerGlobalScope.cpp
@@ -48,7 +48,7 @@ { // Note: startupData is finalized on return. After the relevant parts has been // passed along to the created 'context'. - DedicatedWorkerGlobalScope* context = new DedicatedWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, thread, timeOrigin, startupData->m_starterOriginPrivilegeData.release(), startupData->m_workerClients.release()); + DedicatedWorkerGlobalScope* context = new DedicatedWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, thread, timeOrigin, std::move(startupData->m_starterOriginPrivilegeData), startupData->m_workerClients.release()); context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurityPolicyHeaders); context->setAddressSpace(startupData->m_addressSpace); OriginTrialContext::addTokens(context, startupData->m_originTrialTokens.get()); @@ -75,7 +75,7 @@ OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(context, ports, exceptionState); if (exceptionState.hadException()) return; - thread()->workerObjectProxy().postMessageToWorkerObject(message, channels.release()); + thread()->workerObjectProxy().postMessageToWorkerObject(message, std::move(channels)); } DedicatedWorkerThread* DedicatedWorkerGlobalScope::thread() const
diff --git a/third_party/WebKit/Source/core/workers/InProcessWorkerBase.cpp b/third_party/WebKit/Source/core/workers/InProcessWorkerBase.cpp index 44dd3da..472928b 100644 --- a/third_party/WebKit/Source/core/workers/InProcessWorkerBase.cpp +++ b/third_party/WebKit/Source/core/workers/InProcessWorkerBase.cpp
@@ -39,7 +39,7 @@ OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(context, ports, exceptionState); if (exceptionState.hadException()) return; - m_contextProxy->postMessageToWorkerGlobalScope(message, channels.release()); + m_contextProxy->postMessageToWorkerGlobalScope(message, std::move(channels)); } bool InProcessWorkerBase::initialize(ExecutionContext* context, const String& url, ExceptionState& exceptionState)
diff --git a/third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.cpp b/third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.cpp index 56e7647..763d127 100644 --- a/third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.cpp +++ b/third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.cpp
@@ -112,7 +112,7 @@ m_loaderProxy = WorkerLoaderProxy::create(this); m_workerThread = createWorkerThread(originTime); - m_workerThread->start(startupData.release()); + m_workerThread->start(std::move(startupData)); workerThreadCreated(); m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); }
diff --git a/third_party/WebKit/Source/core/workers/SharedWorker.cpp b/third_party/WebKit/Source/core/workers/SharedWorker.cpp index 5b5d0bf..d73595be6 100644 --- a/third_party/WebKit/Source/core/workers/SharedWorker.cpp +++ b/third_party/WebKit/Source/core/workers/SharedWorker.cpp
@@ -81,7 +81,7 @@ return nullptr; if (document->frame()->loader().client()->sharedWorkerRepositoryClient()) - document->frame()->loader().client()->sharedWorkerRepositoryClient()->connect(worker, remotePort.release(), scriptURL, name, exceptionState); + document->frame()->loader().client()->sharedWorkerRepositoryClient()->connect(worker, std::move(remotePort), scriptURL, name, exceptionState); return worker; }
diff --git a/third_party/WebKit/Source/core/workers/SharedWorkerGlobalScope.cpp b/third_party/WebKit/Source/core/workers/SharedWorkerGlobalScope.cpp index e72ab482..c70062a 100644 --- a/third_party/WebKit/Source/core/workers/SharedWorkerGlobalScope.cpp +++ b/third_party/WebKit/Source/core/workers/SharedWorkerGlobalScope.cpp
@@ -53,7 +53,7 @@ { // Note: startupData is finalized on return. After the relevant parts has been // passed along to the created 'context'. - SharedWorkerGlobalScope* context = new SharedWorkerGlobalScope(name, startupData->m_scriptURL, startupData->m_userAgent, thread, startupData->m_starterOriginPrivilegeData.release(), startupData->m_workerClients.release()); + SharedWorkerGlobalScope* context = new SharedWorkerGlobalScope(name, startupData->m_scriptURL, startupData->m_userAgent, thread, std::move(startupData->m_starterOriginPrivilegeData), startupData->m_workerClients.release()); context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurityPolicyHeaders); context->setAddressSpace(startupData->m_addressSpace); OriginTrialContext::addTokens(context, startupData->m_originTrialTokens.get());
diff --git a/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp b/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp index fccc4e3..35d55c2 100644 --- a/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp +++ b/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp
@@ -96,7 +96,7 @@ m_backingThread->initialize(); OwnPtr<V8IsolateInterruptor> interruptor = adoptPtr(new V8IsolateInterruptor(m_isolate)); - ThreadState::current()->addInterruptor(interruptor.release()); + ThreadState::current()->addInterruptor(std::move(interruptor)); ThreadState::current()->registerTraceDOMWrappers(m_isolate, V8GCController::traceDOMWrappers); if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) V8PerIsolateData::enableIdleTasks(m_isolate, adoptPtr(new V8IdleTaskRunner(backingThread().platformThread().scheduler())));
diff --git a/third_party/WebKit/Source/core/workers/WorkerScriptLoader.h b/third_party/WebKit/Source/core/workers/WorkerScriptLoader.h index 26cce14b..0b46670 100644 --- a/third_party/WebKit/Source/core/workers/WorkerScriptLoader.h +++ b/third_party/WebKit/Source/core/workers/WorkerScriptLoader.h
@@ -76,7 +76,7 @@ unsigned long identifier() const { return m_identifier; } long long appCacheID() const { return m_appCacheID; } - PassOwnPtr<Vector<char>> releaseCachedMetadata() { return m_cachedMetadata.release(); } + PassOwnPtr<Vector<char>> releaseCachedMetadata() { return std::move(m_cachedMetadata); } const Vector<char>* cachedMetadata() const { return m_cachedMetadata.get(); } ContentSecurityPolicy* contentSecurityPolicy() { return m_contentSecurityPolicy.get(); }
diff --git a/third_party/WebKit/Source/core/workers/WorkerThread.cpp b/third_party/WebKit/Source/core/workers/WorkerThread.cpp index a93320fd..1d2713c 100644 --- a/third_party/WebKit/Source/core/workers/WorkerThread.cpp +++ b/third_party/WebKit/Source/core/workers/WorkerThread.cpp
@@ -180,7 +180,7 @@ KURL scriptURL = startupData->m_scriptURL; String sourceCode = startupData->m_sourceCode; WorkerThreadStartMode startMode = startupData->m_startMode; - OwnPtr<Vector<char>> cachedMetaData = startupData->m_cachedMetaData.release(); + OwnPtr<Vector<char>> cachedMetaData = std::move(startupData->m_cachedMetaData); V8CacheOptions v8CacheOptions = startupData->m_v8CacheOptions; m_webScheduler = workerBackingThread().backingThread().platformThread().scheduler();
diff --git a/third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h b/third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h index 218e5f1..d223537 100644 --- a/third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h +++ b/third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h
@@ -158,7 +158,7 @@ inline WorkerGlobalScope* WorkerThreadForTest::createWorkerGlobalScope(PassOwnPtr<WorkerThreadStartupData> startupData) { - return new FakeWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, this, startupData->m_starterOriginPrivilegeData.release(), startupData->m_workerClients.release()); + return new FakeWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, this, std::move(startupData->m_starterOriginPrivilegeData), std::move(startupData->m_workerClients)); } } // namespace blink
diff --git a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp index 23687c6..f4ceb9f 100644 --- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp +++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -340,7 +340,7 @@ blobData->setContentType(finalResponseMIMETypeWithFallback().lower()); m_binaryResponseBuilder.clear(); } - m_responseBlob = Blob::create(BlobDataHandle::create(blobData.release(), size)); + m_responseBlob = Blob::create(BlobDataHandle::create(std::move(blobData), size)); } } @@ -1026,7 +1026,7 @@ // If, window.onload contains open() and send(), m_loader will be set to // non 0 value. So, we cannot continue the outer open(). In such case, // just abort the outer open() by returning false. - OwnPtr<ThreadableLoader> loader = m_loader.release(); + OwnPtr<ThreadableLoader> loader = std::move(m_loader); loader->cancel(); // If abort() called internalAbort() and a nested open() ended up @@ -1448,7 +1448,7 @@ // finalResponseMIMEType() after compatibility investigation. blobData->setContentType(finalResponseMIMETypeWithFallback().lower()); } - return BlobDataHandle::create(blobData.release(), m_lengthDownloadedToFile); + return BlobDataHandle::create(std::move(blobData), m_lengthDownloadedToFile); } void XMLHttpRequest::notifyParserStopped() @@ -1554,7 +1554,7 @@ if (!m_finalResponseCharset.isEmpty()) { OwnPtr<TextResourceDecoder> decoder(TextResourceDecoder::create("text/plain")); decoder->setEncoding(WTF::TextEncoding(m_finalResponseCharset), TextResourceDecoder::EncodingFromHTTPHeader); - return decoder.release(); + return decoder; } // allow TextResourceDecoder to look inside the m_response if it's XML or HTML @@ -1565,7 +1565,7 @@ // versions, Firefox and Opera. decoder->useLenientXMLDecoding(); - return decoder.release(); + return decoder; } if (responseIsHTML())
diff --git a/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp b/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp index 7806207..a1e70fb3 100644 --- a/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp +++ b/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp
@@ -249,7 +249,7 @@ PassOwnPtr<AXProperty> createRelatedNodeListProperty(const String& key, AXRelatedObjectVector& nodes) { OwnPtr<AXValue> nodeListValue = createRelatedNodeListValue(nodes, AXValueTypeEnum::NodeList); - return createProperty(key, nodeListValue.release()); + return createProperty(key, std::move(nodeListValue)); } PassOwnPtr<AXProperty> createRelatedNodeListProperty(const String& key, AXObject::AXObjectVector& nodes, const QualifiedName& attr, AXObject* axObject) @@ -257,7 +257,7 @@ OwnPtr<AXValue> nodeListValue = createRelatedNodeListValue(nodes); const AtomicString& attrValue = axObject->getAttribute(attr); nodeListValue->setValue(protocol::StringValue::create(attrValue)); - return createProperty(key, nodeListValue.release()); + return createProperty(key, std::move(nodeListValue)); } void fillRelationships(AXObject* axObject, protocol::Array<AXProperty>* properties) @@ -297,7 +297,7 @@ } else { roleNameValue = createValue(AXObject::internalRoleName(role), AXValueTypeEnum::InternalRole); } - return roleNameValue.release(); + return roleNameValue; } PassOwnPtr<AXNode> buildObjectForIgnoredNode(Node* node, AXObject* axObject, AXObjectCacheImpl* cacheImpl) @@ -318,9 +318,9 @@ OwnPtr<protocol::Array<AXProperty>> ignoredReasonProperties = protocol::Array<AXProperty>::create(); for (size_t i = 0; i < ignoredReasons.size(); i++) ignoredReasonProperties->addItem(createProperty(ignoredReasons[i])); - ignoredNodeObject->setIgnoredReasons(ignoredReasonProperties.release()); + ignoredNodeObject->setIgnoredReasons(std::move(ignoredReasonProperties)); - return ignoredNodeObject.release(); + return ignoredNodeObject; } PassOwnPtr<AXNode> buildObjectForNode(Node* node, AXObject* axObject, AXObjectCacheImpl* cacheImpl, PassOwnPtr<protocol::Array<AXProperty>> properties) @@ -344,16 +344,16 @@ properties->addItem(createRelatedNodeListProperty(AXRelationshipAttributesEnum::Labelledby, nameSource.relatedObjects)); } } - name->setSources(nameSourceProperties.release()); + name->setSources(std::move(nameSourceProperties)); } nodeObject->setProperties(std::move(properties)); - nodeObject->setName(name.release()); + nodeObject->setName(std::move(name)); } else { nodeObject->setProperties(std::move(properties)); } fillCoreProperties(axObject, nodeObject.get()); - return nodeObject.release(); + return nodeObject; } } // namespace @@ -397,7 +397,7 @@ fillWidgetStates(axObject, properties.get()); fillRelationships(axObject, properties.get()); - *accessibilityNode = buildObjectForNode(node, axObject, cacheImpl, properties.release()); + *accessibilityNode = buildObjectForNode(node, axObject, cacheImpl, std::move(properties)); } DEFINE_TRACE(InspectorAccessibilityAgent)
diff --git a/third_party/WebKit/Source/modules/accessibility/InspectorTypeBuilderHelper.cpp b/third_party/WebKit/Source/modules/accessibility/InspectorTypeBuilderHelper.cpp index d3e2958..7096806 100644 --- a/third_party/WebKit/Source/modules/accessibility/InspectorTypeBuilderHelper.cpp +++ b/third_party/WebKit/Source/modules/accessibility/InspectorTypeBuilderHelper.cpp
@@ -98,7 +98,7 @@ return PassOwnPtr<AXRelatedNode>(); OwnPtr<AXRelatedNode> relatedNode = AXRelatedNode::create().setBackendNodeId(backendNodeId).build(); if (!node->isElementNode()) - return relatedNode.release(); + return relatedNode; Element* element = toElement(node); String idref = element->getIdAttribute(); @@ -107,14 +107,14 @@ if (name) relatedNode->setText(*name); - return relatedNode.release(); + return relatedNode; } PassOwnPtr<AXValue> createRelatedNodeListValue(const AXObject* axObject, String* name, const String& valueType) { OwnPtr<protocol::Array<AXRelatedNode>> relatedNodes = protocol::Array<AXRelatedNode>::create(); relatedNodes->addItem(relatedNodeForAXObject(axObject, name)); - return AXValue::create().setType(valueType).setRelatedNodes(relatedNodes.release()).build(); + return AXValue::create().setType(valueType).setRelatedNodes(std::move(relatedNodes)).build(); } PassOwnPtr<AXValue> createRelatedNodeListValue(AXRelatedObjectVector& relatedObjects, const String& valueType) @@ -123,9 +123,9 @@ for (unsigned i = 0; i < relatedObjects.size(); i++) { OwnPtr<AXRelatedNode> frontendRelatedNode = relatedNodeForAXObject(relatedObjects[i]->object, &(relatedObjects[i]->text)); if (frontendRelatedNode) - frontendRelatedNodes->addItem(frontendRelatedNode.release()); + frontendRelatedNodes->addItem(std::move(frontendRelatedNode)); } - return AXValue::create().setType(valueType).setRelatedNodes(frontendRelatedNodes.release()).build(); + return AXValue::create().setType(valueType).setRelatedNodes(std::move(frontendRelatedNodes)).build(); } PassOwnPtr<AXValue> createRelatedNodeListValue(AXObject::AXObjectVector& axObjects, const String& valueType) @@ -134,9 +134,9 @@ for (unsigned i = 0; i < axObjects.size(); i++) { OwnPtr<AXRelatedNode> relatedNode = relatedNodeForAXObject(axObjects[i].get()); if (relatedNode) - relatedNodes->addItem(relatedNode.release()); + relatedNodes->addItem(std::move(relatedNode)); } - return AXValue::create().setType(valueType).setRelatedNodes(relatedNodes.release()).build(); + return AXValue::create().setType(valueType).setRelatedNodes(std::move(relatedNodes)).build(); } String valueSourceType(AXNameFrom nameFrom) @@ -189,7 +189,7 @@ OwnPtr<AXValue> attributeValue = createRelatedNodeListValue(nameSource.relatedObjects, AXValueTypeEnum::IdrefList); if (!nameSource.attributeValue.isNull()) attributeValue->setValue(protocol::StringValue::create(nameSource.attributeValue.getString())); - valueSource->setAttributeValue(attributeValue.release()); + valueSource->setAttributeValue(std::move(attributeValue)); } else if (nameSource.attribute == QualifiedName::null()) { valueSource->setNativeSourceValue(createRelatedNodeListValue(nameSource.relatedObjects, AXValueTypeEnum::NodeList)); } @@ -206,7 +206,7 @@ valueSource->setInvalid(true); if (nameSource.nativeSource != AXTextFromNativeHTMLUninitialized) valueSource->setNativeSource(nativeSourceType(nameSource.nativeSource)); - return valueSource.release(); + return valueSource; } } // namespace blink
diff --git a/third_party/WebKit/Source/modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.cpp b/third_party/WebKit/Source/modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.cpp index d75632a..f231e65 100644 --- a/third_party/WebKit/Source/modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.cpp +++ b/third_party/WebKit/Source/modules/audio_output_devices/HTMLMediaElementAudioOutputDevice.cpp
@@ -66,7 +66,7 @@ webMediaPlayer->setSinkId(m_sinkId, WebSecurityOrigin(context->getSecurityOrigin()), callbacks.leakPtr()); } else { if (AudioOutputDeviceClient* client = AudioOutputDeviceClient::from(context)) { - client->checkIfAudioSinkExistsAndIsAuthorized(context, m_sinkId, callbacks.release()); + client->checkIfAudioSinkExistsAndIsAuthorized(context, m_sinkId, std::move(callbacks)); } else { // The context has been detached. Impossible to get a security origin to check. ASSERT(context->activeDOMObjectsAreStopped());
diff --git a/third_party/WebKit/Source/modules/cachestorage/InspectorCacheStorageAgent.cpp b/third_party/WebKit/Source/modules/cachestorage/InspectorCacheStorageAgent.cpp index 03cec3f..6f12e89 100644 --- a/third_party/WebKit/Source/modules/cachestorage/InspectorCacheStorageAgent.cpp +++ b/third_party/WebKit/Source/modules/cachestorage/InspectorCacheStorageAgent.cpp
@@ -78,7 +78,7 @@ OwnPtr<WebServiceWorkerCacheStorage> cache = adoptPtr(Platform::current()->cacheStorage(WebSecurityOrigin(secOrigin))); if (!cache) *errorString = "Could not find cache storage."; - return cache.release(); + return cache; } PassOwnPtr<WebServiceWorkerCacheStorage> assertCacheStorageAndNameForId(ErrorString* errorString, const String& cacheId, String* cacheName) @@ -130,9 +130,9 @@ .setSecurityOrigin(m_securityOrigin) .setCacheName(name) .setCacheId(buildCacheId(m_securityOrigin, name)).build(); - array->addItem(entry.release()); + array->addItem(std::move(entry)); } - m_callback->sendSuccess(array.release()); + m_callback->sendSuccess(std::move(array)); } void onError(WebServiceWorkerCacheError error) override @@ -201,9 +201,9 @@ OwnPtr<DataEntry> entry = DataEntry::create() .setRequest(requestResponse.request) .setResponse(requestResponse.response).build(); - array->addItem(entry.release()); + array->addItem(std::move(entry)); } - m_callback->sendSuccess(array.release(), hasMore); + m_callback->sendSuccess(std::move(array), hasMore); } void sendFailure(const String& error) @@ -263,10 +263,10 @@ { if (requests.isEmpty()) { OwnPtr<Array<DataEntry>> array = Array<DataEntry>::create(); - m_callback->sendSuccess(array.release(), false); + m_callback->sendSuccess(std::move(array), false); return; } - RefPtr<ResponsesAccumulator> accumulator = adoptRef(new ResponsesAccumulator(requests.size(), m_params, m_callback.release())); + RefPtr<ResponsesAccumulator> accumulator = adoptRef(new ResponsesAccumulator(requests.size(), m_params, std::move(m_callback))); for (size_t i = 0; i < requests.size(); i++) { const auto& request = requests[i]; @@ -300,7 +300,7 @@ void onSuccess(std::unique_ptr<WebServiceWorkerCache> cache) override { - auto* cacheRequest = new GetCacheKeysForRequestData(m_params, adoptPtr(cache.release()), m_callback.release()); + auto* cacheRequest = new GetCacheKeysForRequestData(m_params, adoptPtr(cache.release()), std::move(m_callback)); cacheRequest->cache()->dispatchKeys(cacheRequest, nullptr, WebServiceWorkerCache::QueryParams()); } @@ -377,7 +377,7 @@ void onSuccess(std::unique_ptr<WebServiceWorkerCache> cache) override { - auto* deleteRequest = new DeleteCacheEntry(m_callback.release()); + auto* deleteRequest = new DeleteCacheEntry(std::move(m_callback)); BatchOperation deleteOperation; deleteOperation.operationType = WebServiceWorkerCache::OperationTypeDelete; deleteOperation.request.setURL(KURL(ParsedURLString, m_requestSpec));
diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp index da34ec8..a51049f 100644 --- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp +++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DTest.cpp
@@ -209,7 +209,7 @@ #define TEST_OVERDRAW_SETUP(EXPECTED_OVERDRAWS) \ OwnPtr<MockImageBufferSurfaceForOverwriteTesting> mockSurface = adoptPtr(new MockImageBufferSurfaceForOverwriteTesting(IntSize(10, 10), NonOpaque)); \ MockImageBufferSurfaceForOverwriteTesting* surfacePtr = mockSurface.get(); \ - canvasElement().createImageBufferUsingSurfaceForTesting(mockSurface.release()); \ + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(mockSurface)); \ EXPECT_CALL(*surfacePtr, willOverwriteCanvas()).Times(EXPECTED_OVERDRAWS); \ context2d()->save(); @@ -406,7 +406,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); EXPECT_FALSE(canvasElement().shouldBeDirectComposited()); } @@ -415,7 +415,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->setGlobalAlpha(0.5f); // To prevent overdraw optimization for (int i = 0; i < ExpensiveCanvasHeuristicParameters::ExpensiveOverdrawThreshold - 1; i++) { @@ -429,7 +429,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->setGlobalAlpha(0.5f); // To prevent overdraw optimization for (int i = 0; i < ExpensiveCanvasHeuristicParameters::ExpensiveOverdrawThreshold; i++) { @@ -443,7 +443,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); NonThrowableExceptionState exceptionState; Element* sourceCanvasElement = document().createElement("canvas", exceptionState); @@ -451,7 +451,7 @@ HTMLCanvasElement* sourceCanvas = static_cast<HTMLCanvasElement*>(sourceCanvasElement); IntSize sourceSize(10, 10 * ExpensiveCanvasHeuristicParameters::ExpensiveImageSizeRatio); OwnPtr<UnacceleratedImageBufferSurface> sourceSurface = adoptPtr(new UnacceleratedImageBufferSurface(sourceSize, NonOpaque)); - sourceCanvas->createImageBufferUsingSurfaceForTesting(sourceSurface.release()); + sourceCanvas->createImageBufferUsingSurfaceForTesting(std::move(sourceSurface)); const ImageBitmapOptions defaultOptions; // Go through an ImageBitmap to avoid triggering a display list fallback @@ -467,7 +467,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); NonThrowableExceptionState exceptionState; Element* sourceCanvasElement = document().createElement("canvas", exceptionState); @@ -475,7 +475,7 @@ HTMLCanvasElement* sourceCanvas = static_cast<HTMLCanvasElement*>(sourceCanvasElement); IntSize sourceSize(10, 10 * ExpensiveCanvasHeuristicParameters::ExpensiveImageSizeRatio + 1); OwnPtr<UnacceleratedImageBufferSurface> sourceSurface = adoptPtr(new UnacceleratedImageBufferSurface(sourceSize, NonOpaque)); - sourceCanvas->createImageBufferUsingSurfaceForTesting(sourceSurface.release()); + sourceCanvas->createImageBufferUsingSurfaceForTesting(std::move(sourceSurface)); const ImageBitmapOptions defaultOptions; // Go through an ImageBitmap to avoid triggering a display list fallback @@ -491,7 +491,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->beginPath(); context2d()->moveTo(7, 5); @@ -508,7 +508,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->beginPath(); context2d()->moveTo(7, 5); @@ -525,7 +525,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->beginPath(); context2d()->moveTo(1, 1); @@ -545,7 +545,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->beginPath(); context2d()->rect(1, 1, 2, 2); @@ -559,7 +559,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->beginPath(); context2d()->moveTo(1, 1); @@ -580,7 +580,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->setShadowColor(String("red")); context2d()->setShadowBlur(1.0f); @@ -597,7 +597,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->setShadowColor(String("red")); context2d()->setShadowOffsetX(1.0f); @@ -610,7 +610,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->fillRect(0, 0, 1, 1); // To have a non-empty dirty rect for (int i = 0; i < ExpensiveCanvasHeuristicParameters::ExpensiveRecordingStackDepth - 1; ++i) { @@ -624,7 +624,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->fillRect(0, 0, 1, 1); // To have a non-empty dirty rect for (int i = 0; i < ExpensiveCanvasHeuristicParameters::ExpensiveRecordingStackDepth; ++i) { @@ -643,7 +643,7 @@ // See: crbug.com/583809 createContext(Opaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectFallback), Opaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->fillText("Text", 0, 5); } @@ -652,7 +652,7 @@ { createContext(NonOpaque); OwnPtr<RecordingImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSurface(IntSize(10, 10), MockSurfaceFactory::create(MockSurfaceFactory::ExpectNoFallback), NonOpaque)); - canvasElement().createImageBufferUsingSurfaceForTesting(surface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(surface)); context2d()->fillText("Text", 0, 5); } @@ -685,7 +685,7 @@ OwnPtr<FakeAcceleratedImageBufferSurfaceForTesting> fakeAccelerateSurface = adoptPtr(new FakeAcceleratedImageBufferSurfaceForTesting(IntSize(10, 10), NonOpaque)); FakeAcceleratedImageBufferSurfaceForTesting* fakeAccelerateSurfacePtr = fakeAccelerateSurface.get(); - canvasElement().createImageBufferUsingSurfaceForTesting(fakeAccelerateSurface.release()); + canvasElement().createImageBufferUsingSurfaceForTesting(std::move(fakeAccelerateSurface)); // 800 = 10 * 10 * 4 * 2 where 10*10 is canvas size, 4 is num of bytes per pixel per buffer, // and 2 is an estimate of num of gpu buffers required EXPECT_EQ(800, getCurrentGPUMemoryUsage()); @@ -705,7 +705,7 @@ // Creating a different accelerated image buffer OwnPtr<FakeAcceleratedImageBufferSurfaceForTesting> fakeAccelerateSurface2 = adoptPtr(new FakeAcceleratedImageBufferSurfaceForTesting(IntSize(10, 5), NonOpaque)); - OwnPtr<ImageBuffer> imageBuffer2 = ImageBuffer::create(fakeAccelerateSurface2.release()); + OwnPtr<ImageBuffer> imageBuffer2 = ImageBuffer::create(std::move(fakeAccelerateSurface2)); EXPECT_EQ(800, getCurrentGPUMemoryUsage()); EXPECT_EQ(1200, getGlobalGPUMemoryUsage());
diff --git a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp index 38f958c..d096af9c 100644 --- a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp +++ b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp
@@ -16,7 +16,7 @@ { // Note: startupData is finalized on return. After the relevant parts has been // passed along to the created 'context'. - CompositorWorkerGlobalScope* context = new CompositorWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, thread, timeOrigin, startupData->m_starterOriginPrivilegeData.release(), startupData->m_workerClients.release()); + CompositorWorkerGlobalScope* context = new CompositorWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, thread, timeOrigin, std::move(startupData->m_starterOriginPrivilegeData), startupData->m_workerClients.release()); context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurityPolicyHeaders); context->setAddressSpace(startupData->m_addressSpace); return context; @@ -49,7 +49,7 @@ OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(executionContext, ports, exceptionState); if (exceptionState.hadException()) return; - thread()->workerObjectProxy().postMessageToWorkerObject(message, channels.release()); + thread()->workerObjectProxy().postMessageToWorkerObject(message, std::move(channels)); } int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* callback)
diff --git a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThreadTest.cpp b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThreadTest.cpp index 6f05b48..dd55032 100644 --- a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThreadTest.cpp +++ b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThreadTest.cpp
@@ -110,7 +110,7 @@ WebAddressSpaceLocal, nullptr, V8CacheOptionsDefault)); - return workerThread.release(); + return workerThread; } // Attempts to run some simple script for |worker|.
diff --git a/third_party/WebKit/Source/modules/crypto/NormalizeAlgorithm.cpp b/third_party/WebKit/Source/modules/crypto/NormalizeAlgorithm.cpp index 862b494..74f61e9 100644 --- a/third_party/WebKit/Source/modules/crypto/NormalizeAlgorithm.cpp +++ b/third_party/WebKit/Source/modules/crypto/NormalizeAlgorithm.cpp
@@ -946,7 +946,7 @@ if (!parseAlgorithmParams(raw, paramsType, params, context, error)) return false; - algorithm = WebCryptoAlgorithm(algorithmId, params.release()); + algorithm = WebCryptoAlgorithm(algorithmId, std::move(params)); return true; }
diff --git a/third_party/WebKit/Source/modules/fetch/Body.cpp b/third_party/WebKit/Source/modules/fetch/Body.cpp index d7061eb..239d6e6 100644 --- a/third_party/WebKit/Source/modules/fetch/Body.cpp +++ b/third_party/WebKit/Source/modules/fetch/Body.cpp
@@ -143,7 +143,7 @@ } else { OwnPtr<BlobData> blobData = BlobData::create(); blobData->setContentType(mimeType()); - resolver->resolve(Blob::create(BlobDataHandle::create(blobData.release(), 0))); + resolver->resolve(Blob::create(BlobDataHandle::create(std::move(blobData), 0))); } return promise;
diff --git a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp index 9eec54a2..24194dc 100644 --- a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp +++ b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
@@ -151,7 +151,7 @@ // We need to call these before calling closeAndLockAndDisturb. const bool isClosed = isStreamClosed(); const bool isErrored = isStreamErrored(); - OwnPtr<FetchDataConsumerHandle> handle = m_handle.release(); + OwnPtr<FetchDataConsumerHandle> handle = std::move(m_handle); closeAndLockAndDisturb(); @@ -164,7 +164,7 @@ return createFetchDataConsumerHandleFromWebHandle(createUnexpectedErrorDataConsumerHandle()); ASSERT(handle); - return handle.release(); + return handle; } void BodyStreamBuffer::startLoading(FetchDataLoader* loader, FetchDataLoader::Client* client)
diff --git a/third_party/WebKit/Source/modules/fetch/BodyStreamBufferTest.cpp b/third_party/WebKit/Source/modules/fetch/BodyStreamBufferTest.cpp index a9e006d..df8cba27 100644 --- a/third_party/WebKit/Source/modules/fetch/BodyStreamBufferTest.cpp +++ b/third_party/WebKit/Source/modules/fetch/BodyStreamBufferTest.cpp
@@ -57,7 +57,7 @@ { OwnPtr<FetchDataConsumerHandle> handle = createFetchDataConsumerHandleFromWebHandle(createWaitingDataConsumerHandle()); FetchDataConsumerHandle* rawHandle = handle.get(); - BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), handle.release()); + BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), std::move(handle)); EXPECT_FALSE(buffer->hasPendingActivity()); EXPECT_FALSE(buffer->isStreamLocked()); @@ -77,7 +77,7 @@ OwnPtr<BlobData> data = BlobData::create(); data->appendText("hello", false); auto size = data->length(); - RefPtr<BlobDataHandle> blobDataHandle = BlobDataHandle::create(data.release(), size); + RefPtr<BlobDataHandle> blobDataHandle = BlobDataHandle::create(std::move(data), size); BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), FetchBlobDataConsumerHandle::create(getExecutionContext(), blobDataHandle, new FakeLoaderFactory)); EXPECT_FALSE(buffer->isStreamLocked()); @@ -95,7 +95,7 @@ { // This handle is not drainable. OwnPtr<FetchDataConsumerHandle> handle = createFetchDataConsumerHandleFromWebHandle(createWaitingDataConsumerHandle()); - BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), handle.release()); + BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), std::move(handle)); EXPECT_FALSE(buffer->isStreamLocked()); EXPECT_FALSE(buffer->isStreamDisturbed()); @@ -132,7 +132,7 @@ { // This handle is not drainable. OwnPtr<FetchDataConsumerHandle> handle = createFetchDataConsumerHandleFromWebHandle(createWaitingDataConsumerHandle()); - BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), handle.release()); + BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), std::move(handle)); EXPECT_FALSE(buffer->isStreamLocked()); EXPECT_FALSE(buffer->isStreamDisturbed()); @@ -159,7 +159,7 @@ OwnPtr<ReplayingHandle> handle = ReplayingHandle::create(); handle->add(Command(Command::Data, "hello")); handle->add(Command(Command::Done)); - BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), createFetchDataConsumerHandleFromWebHandle(handle.release())); + BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), createFetchDataConsumerHandleFromWebHandle(std::move(handle))); buffer->startLoading(FetchDataLoader::createLoaderAsArrayBuffer(), client); EXPECT_TRUE(buffer->isStreamLocked()); @@ -191,7 +191,7 @@ OwnPtr<ReplayingHandle> handle = ReplayingHandle::create(); handle->add(Command(Command::Data, "hello")); handle->add(Command(Command::Done)); - BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), createFetchDataConsumerHandleFromWebHandle(handle.release())); + BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), createFetchDataConsumerHandleFromWebHandle(std::move(handle))); buffer->startLoading(FetchDataLoader::createLoaderAsBlobHandle("text/plain"), client); EXPECT_TRUE(buffer->isStreamLocked()); @@ -221,7 +221,7 @@ OwnPtr<ReplayingHandle> handle = ReplayingHandle::create(); handle->add(Command(Command::Data, "hello")); handle->add(Command(Command::Done)); - BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), createFetchDataConsumerHandleFromWebHandle(handle.release())); + BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), createFetchDataConsumerHandleFromWebHandle(std::move(handle))); buffer->startLoading(FetchDataLoader::createLoaderAsString(), client); EXPECT_TRUE(buffer->isStreamLocked()); @@ -354,7 +354,7 @@ OwnPtr<ReplayingHandle> handle = ReplayingHandle::create(); handle->add(Command(Command::Data, "hello")); handle->add(Command(Command::Done)); - Persistent<BodyStreamBuffer> buffer = new BodyStreamBuffer(getScriptState(), createFetchDataConsumerHandleFromWebHandle(handle.release())); + Persistent<BodyStreamBuffer> buffer = new BodyStreamBuffer(getScriptState(), createFetchDataConsumerHandleFromWebHandle(std::move(handle))); buffer->startLoading(FetchDataLoader::createLoaderAsString(), client); ThreadHeap::collectAllGarbage(); @@ -396,7 +396,7 @@ // |reader| is adopted by |obtainReader|. ASSERT_TRUE(reader.leakPtr()); - BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), handle.release()); + BodyStreamBuffer* buffer = new BodyStreamBuffer(getScriptState(), std::move(handle)); checkpoint.Call(1); ScriptValue reason(getScriptState(), v8String(getScriptState()->isolate(), "reason")); buffer->cancelSource(getScriptState(), reason);
diff --git a/third_party/WebKit/Source/modules/fetch/CompositeDataConsumerHandle.h b/third_party/WebKit/Source/modules/fetch/CompositeDataConsumerHandle.h index 200797b..cc41704d 100644 --- a/third_party/WebKit/Source/modules/fetch/CompositeDataConsumerHandle.h +++ b/third_party/WebKit/Source/modules/fetch/CompositeDataConsumerHandle.h
@@ -52,7 +52,7 @@ Updater* u = nullptr; OwnPtr<CompositeDataConsumerHandle> p = adoptPtr(new CompositeDataConsumerHandle(std::move(handle), &u)); *updater = u; - return p.release(); + return std::move(p); } ~CompositeDataConsumerHandle() override;
diff --git a/third_party/WebKit/Source/modules/fetch/CompositeDataConsumerHandleTest.cpp b/third_party/WebKit/Source/modules/fetch/CompositeDataConsumerHandleTest.cpp index c5e9a41..863dd6da 100644 --- a/third_party/WebKit/Source/modules/fetch/CompositeDataConsumerHandleTest.cpp +++ b/third_party/WebKit/Source/modules/fetch/CompositeDataConsumerHandleTest.cpp
@@ -296,13 +296,13 @@ ASSERT_TRUE(reader2.leakPtr()); CompositeDataConsumerHandle::Updater* updater = nullptr; - OwnPtr<WebDataConsumerHandle> handle = CompositeDataConsumerHandle::create(handle1.release(), &updater); + OwnPtr<WebDataConsumerHandle> handle = CompositeDataConsumerHandle::create(std::move(handle1), &updater); checkpoint.Call(0); OwnPtr<WebDataConsumerHandle::Reader> reader = handle->obtainReader(&client); checkpoint.Call(1); EXPECT_EQ(kOk, reader->read(buffer, sizeof(buffer), kNone, &size)); checkpoint.Call(2); - updater->update(handle2.release()); + updater->update(std::move(handle2)); checkpoint.Call(3); EXPECT_EQ(kOk, reader->read(buffer, sizeof(buffer), kNone, &size)); checkpoint.Call(4); @@ -339,7 +339,7 @@ ASSERT_TRUE(reader2.leakPtr()); CompositeDataConsumerHandle::Updater* updater = nullptr; - OwnPtr<WebDataConsumerHandle> handle = CompositeDataConsumerHandle::create(handle1.release(), &updater); + OwnPtr<WebDataConsumerHandle> handle = CompositeDataConsumerHandle::create(std::move(handle1), &updater); checkpoint.Call(0); OwnPtr<WebDataConsumerHandle::Reader> reader = handle->obtainReader(nullptr); checkpoint.Call(1); @@ -347,7 +347,7 @@ checkpoint.Call(2); EXPECT_EQ(kOk, reader->endRead(0)); checkpoint.Call(3); - updater->update(handle2.release()); + updater->update(std::move(handle2)); checkpoint.Call(4); EXPECT_EQ(kOk, reader->beginRead(&p, kNone, &size)); checkpoint.Call(5); @@ -393,19 +393,19 @@ ASSERT_TRUE(reader3.leakPtr()); CompositeDataConsumerHandle::Updater* updater = nullptr; - OwnPtr<WebDataConsumerHandle> handle = CompositeDataConsumerHandle::create(handle1.release(), &updater); + OwnPtr<WebDataConsumerHandle> handle = CompositeDataConsumerHandle::create(std::move(handle1), &updater); checkpoint.Call(0); OwnPtr<WebDataConsumerHandle::Reader> reader = handle->obtainReader(nullptr); checkpoint.Call(1); EXPECT_EQ(kOk, reader->beginRead(&p, kNone, &size)); checkpoint.Call(2); - updater->update(handle2.release()); + updater->update(std::move(handle2)); checkpoint.Call(3); EXPECT_EQ(kOk, reader->endRead(0)); checkpoint.Call(4); EXPECT_EQ(kShouldWait, reader->beginRead(&p, kNone, &size)); checkpoint.Call(5); - updater->update(handle3.release()); + updater->update(std::move(handle3)); checkpoint.Call(6); EXPECT_EQ(kOk, reader->beginRead(&p, kNone, &size)); checkpoint.Call(7);
diff --git a/third_party/WebKit/Source/modules/fetch/DataConsumerHandleTestUtil.cpp b/third_party/WebKit/Source/modules/fetch/DataConsumerHandleTestUtil.cpp index 1d91dcec..efb5391 100644 --- a/third_party/WebKit/Source/modules/fetch/DataConsumerHandleTestUtil.cpp +++ b/third_party/WebKit/Source/modules/fetch/DataConsumerHandleTestUtil.cpp
@@ -250,7 +250,7 @@ } OwnPtr<HandleReadResult> result = adoptPtr(new HandleReadResult(r, m_data)); m_data.clear(); - Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, bind(&HandleReader::runOnFinishedReading, this, passed(result.release()))); + Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, bind(&HandleReader::runOnFinishedReading, this, passed(std::move(result)))); m_reader = nullptr; } @@ -285,7 +285,7 @@ } OwnPtr<HandleReadResult> result = adoptPtr(new HandleReadResult(r, m_data)); m_data.clear(); - Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, bind(&HandleTwoPhaseReader::runOnFinishedReading, this, passed(result.release()))); + Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, bind(&HandleTwoPhaseReader::runOnFinishedReading, this, passed(std::move(result)))); m_reader = nullptr; }
diff --git a/third_party/WebKit/Source/modules/fetch/DataConsumerHandleTestUtil.h b/third_party/WebKit/Source/modules/fetch/DataConsumerHandleTestUtil.h index ae5de03..e629a03 100644 --- a/third_party/WebKit/Source/modules/fetch/DataConsumerHandleTestUtil.h +++ b/third_party/WebKit/Source/modules/fetch/DataConsumerHandleTestUtil.h
@@ -513,7 +513,7 @@ return nullptr; m_event->wait(); m_isDone = true; - return m_result.release(); + return std::move(m_result); } private:
diff --git a/third_party/WebKit/Source/modules/fetch/DataConsumerTee.cpp b/third_party/WebKit/Source/modules/fetch/DataConsumerTee.cpp index 14aae5a..71f3deb 100644 --- a/third_party/WebKit/Source/modules/fetch/DataConsumerTee.cpp +++ b/third_party/WebKit/Source/modules/fetch/DataConsumerTee.cpp
@@ -150,7 +150,7 @@ needsNotification = m_queue.isEmpty(); OwnPtr<Vector<char>> data = adoptPtr(new Vector<char>); data->append(buffer, size); - m_queue.append(data.release()); + m_queue.append(std::move(data)); } if (needsNotification) notify(); @@ -425,8 +425,8 @@ OwnPtr<WebDataConsumerHandle> webDest1, webDest2; DataConsumerTee::create(executionContext, static_cast<PassOwnPtr<WebDataConsumerHandle>>(std::move(src)), &webDest1, &webDest2); - *dest1 = createFetchDataConsumerHandleFromWebHandle(webDest1.release()); - *dest2 = createFetchDataConsumerHandleFromWebHandle(webDest2.release()); + *dest1 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest1)); + *dest2 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest2)); return; }
diff --git a/third_party/WebKit/Source/modules/fetch/DataConsumerTeeTest.cpp b/third_party/WebKit/Source/modules/fetch/DataConsumerTeeTest.cpp index a0cfd18b..d467143 100644 --- a/third_party/WebKit/Source/modules/fetch/DataConsumerTeeTest.cpp +++ b/third_party/WebKit/Source/modules/fetch/DataConsumerTeeTest.cpp
@@ -82,12 +82,12 @@ src->add(Command(Command::Done)); OwnPtr<TeeCreationThread<WebDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<WebDataConsumerHandle>()); - t->run(src.release(), &dest1, &dest2); + t->run(std::move(src), &dest1, &dest2); ASSERT_TRUE(dest1); ASSERT_TRUE(dest2); - HandleReaderRunner<HandleReader> r1(dest1.release()), r2(dest2.release()); + HandleReaderRunner<HandleReader> r1(std::move(dest1)), r2(std::move(dest2)); OwnPtr<HandleReadResult> res1 = r1.wait(); OwnPtr<HandleReadResult> res2 = r2.wait(); @@ -112,13 +112,13 @@ src->add(Command(Command::Done)); OwnPtr<TeeCreationThread<WebDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<WebDataConsumerHandle>()); - t->run(src.release(), &dest1, &dest2); + t->run(std::move(src), &dest1, &dest2); ASSERT_TRUE(dest1); ASSERT_TRUE(dest2); - HandleReaderRunner<HandleReader> r1(dest1.release()); - HandleReaderRunner<HandleReader> r2(dest2.release()); + HandleReaderRunner<HandleReader> r1(std::move(dest1)); + HandleReaderRunner<HandleReader> r2(std::move(dest2)); OwnPtr<HandleReadResult> res1 = r1.wait(); OwnPtr<HandleReadResult> res2 = r2.wait(); @@ -145,13 +145,13 @@ src->add(Command(Command::Done)); OwnPtr<TeeCreationThread<WebDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<WebDataConsumerHandle>()); - t->run(src.release(), &dest1, &dest2); + t->run(std::move(src), &dest1, &dest2); ASSERT_TRUE(dest1); ASSERT_TRUE(dest2); - HandleReaderRunner<HandleTwoPhaseReader> r1(dest1.release()); - HandleReaderRunner<HandleTwoPhaseReader> r2(dest2.release()); + HandleReaderRunner<HandleTwoPhaseReader> r1(std::move(dest1)); + HandleReaderRunner<HandleTwoPhaseReader> r2(std::move(dest2)); OwnPtr<HandleReadResult> res1 = r1.wait(); OwnPtr<HandleReadResult> res2 = r2.wait(); @@ -173,13 +173,13 @@ src->add(Command(Command::Error)); OwnPtr<TeeCreationThread<WebDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<WebDataConsumerHandle>()); - t->run(src.release(), &dest1, &dest2); + t->run(std::move(src), &dest1, &dest2); ASSERT_TRUE(dest1); ASSERT_TRUE(dest2); - HandleReaderRunner<HandleReader> r1(dest1.release()); - HandleReaderRunner<HandleReader> r2(dest2.release()); + HandleReaderRunner<HandleReader> r1(std::move(dest1)); + HandleReaderRunner<HandleReader> r2(std::move(dest2)); OwnPtr<HandleReadResult> res1 = r1.wait(); OwnPtr<HandleReadResult> res2 = r2.wait(); @@ -202,13 +202,13 @@ src->add(Command(Command::Data, "world")); OwnPtr<TeeCreationThread<WebDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<WebDataConsumerHandle>()); - t->run(src.release(), &dest1, &dest2); + t->run(std::move(src), &dest1, &dest2); ASSERT_TRUE(dest1); ASSERT_TRUE(dest2); - HandleReaderRunner<HandleReader> r1(dest1.release()); - HandleReaderRunner<HandleReader> r2(dest2.release()); + HandleReaderRunner<HandleReader> r1(std::move(dest1)); + HandleReaderRunner<HandleReader> r2(std::move(dest2)); // We can pass a raw pointer because the subsequent |wait| calls ensure // t->thread() is alive. @@ -230,13 +230,13 @@ src->add(Command(Command::Data, "world")); OwnPtr<TeeCreationThread<WebDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<WebDataConsumerHandle>()); - t->run(src.release(), &dest1, &dest2); + t->run(std::move(src), &dest1, &dest2); ASSERT_TRUE(dest1); ASSERT_TRUE(dest2); - HandleReaderRunner<HandleReader> r1(dest1.release()); - HandleReaderRunner<HandleReader> r2(dest2.release()); + HandleReaderRunner<HandleReader> r1(std::move(dest1)); + HandleReaderRunner<HandleReader> r2(std::move(dest2)); t = nullptr; @@ -257,12 +257,12 @@ src->add(Command(Command::Done)); OwnPtr<TeeCreationThread<WebDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<WebDataConsumerHandle>()); - t->run(src.release(), &dest1, &dest2); + t->run(std::move(src), &dest1, &dest2); ASSERT_TRUE(dest1); ASSERT_TRUE(dest2); - HandleReaderRunner<HandleReader> r1(dest1.release()); + HandleReaderRunner<HandleReader> r1(std::move(dest1)); OwnPtr<HandleReadResult> res1 = r1.wait(); EXPECT_EQ(kDone, res1->result()); @@ -270,7 +270,7 @@ t = nullptr; - HandleReaderRunner<HandleReader> r2(dest2.release()); + HandleReaderRunner<HandleReader> r2(std::move(dest2)); OwnPtr<HandleReadResult> res2 = r2.wait(); EXPECT_EQ(kDone, res2->result()); @@ -287,14 +287,14 @@ src->add(Command(Command::Done)); OwnPtr<TeeCreationThread<WebDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<WebDataConsumerHandle>()); - t->run(src.release(), &dest1, &dest2); + t->run(std::move(src), &dest1, &dest2); ASSERT_TRUE(dest1); ASSERT_TRUE(dest2); dest1 = nullptr; - HandleReaderRunner<HandleReader> r2(dest2.release()); + HandleReaderRunner<HandleReader> r2(std::move(dest2)); OwnPtr<HandleReadResult> res2 = r2.wait(); EXPECT_EQ(kDone, res2->result()); @@ -311,7 +311,7 @@ src->add(Command(Command::Data, "world")); OwnPtr<TeeCreationThread<WebDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<WebDataConsumerHandle>()); - t->run(src.release(), &dest1, &dest2); + t->run(std::move(src), &dest1, &dest2); ASSERT_TRUE(dest1); ASSERT_TRUE(dest2); @@ -345,7 +345,7 @@ OwnPtr<TeeCreationThread<FetchDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<FetchDataConsumerHandle>()); checkpoint.Call(1); - t->run(src.release(), &dest1, &dest2); + t->run(std::move(src), &dest1, &dest2); checkpoint.Call(2); ASSERT_TRUE(dest1); @@ -375,7 +375,7 @@ OwnPtr<TeeCreationThread<FetchDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<FetchDataConsumerHandle>()); checkpoint.Call(1); - t->run(src.release(), &dest1, &dest2); + t->run(std::move(src), &dest1, &dest2); checkpoint.Call(2); ASSERT_TRUE(dest1); @@ -394,7 +394,7 @@ src->add(Command(Command::Done)); OwnPtr<TeeCreationThread<FetchDataConsumerHandle>> t = adoptPtr(new TeeCreationThread<FetchDataConsumerHandle>()); - t->run(createFetchDataConsumerHandleFromWebHandle(src.release()), &dest1, &dest2); + t->run(createFetchDataConsumerHandleFromWebHandle(std::move(src)), &dest1, &dest2); ASSERT_TRUE(dest1); ASSERT_TRUE(dest2); @@ -402,7 +402,7 @@ EXPECT_FALSE(dest1->obtainReader(nullptr)->drainAsBlobDataHandle(kAllowBlobWithInvalidSize)); EXPECT_FALSE(dest2->obtainReader(nullptr)->drainAsBlobDataHandle(kAllowBlobWithInvalidSize)); - HandleReaderRunner<HandleReader> r1(dest1.release()), r2(dest2.release()); + HandleReaderRunner<HandleReader> r1(std::move(dest1)), r2(std::move(dest2)); OwnPtr<HandleReadResult> res1 = r1.wait(); OwnPtr<HandleReadResult> res2 = r2.wait();
diff --git a/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp b/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp index 759b52e..869a7273 100644 --- a/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp +++ b/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp
@@ -65,7 +65,7 @@ OwnPtr<BlobData> data = BlobData::create(); data->appendText(s, false); auto size = data->length(); - return BlobDataHandle::create(data.release(), size); + return BlobDataHandle::create(std::move(data), size); } String toString(const Vector<char>& data) @@ -236,8 +236,8 @@ checkpoint.Call(1); testing::runPendingTasks(); checkpoint.Call(2); - client->didReceiveResponse(0, ResourceResponse(), src.release()); - HandleReaderRunner<HandleReader> runner(handle.release()); + client->didReceiveResponse(0, ResourceResponse(), std::move(src)); + HandleReaderRunner<HandleReader> runner(std::move(handle)); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kDone, r->result()); EXPECT_EQ("hello, world", toString(r->data())); @@ -275,8 +275,8 @@ checkpoint.Call(1); testing::runPendingTasks(); checkpoint.Call(2); - client->didReceiveResponse(0, ResourceResponse(), src.release()); - HandleReaderRunner<HandleTwoPhaseReader> runner(handle.release()); + client->didReceiveResponse(0, ResourceResponse(), std::move(src)); + HandleReaderRunner<HandleTwoPhaseReader> runner(std::move(handle)); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kDone, r->result()); EXPECT_EQ("hello, world", toString(r->data())); @@ -307,7 +307,7 @@ testing::runPendingTasks(); checkpoint.Call(2); client->didFail(ResourceError()); - HandleReaderRunner<HandleReader> runner(handle.release()); + HandleReaderRunner<HandleReader> runner(std::move(handle)); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kUnexpectedError, r->result()); } @@ -342,8 +342,8 @@ checkpoint.Call(1); testing::runPendingTasks(); checkpoint.Call(2); - client->didReceiveResponse(0, ResourceResponse(), src.release()); - HandleReaderRunner<HandleReader> runner(handle.release()); + client->didReceiveResponse(0, ResourceResponse(), std::move(src)); + HandleReaderRunner<HandleReader> runner(std::move(handle)); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kUnexpectedError, r->result()); }
diff --git a/third_party/WebKit/Source/modules/fetch/FetchDataLoader.cpp b/third_party/WebKit/Source/modules/fetch/FetchDataLoader.cpp index 308a017..31967fe3 100644 --- a/third_party/WebKit/Source/modules/fetch/FetchDataLoader.cpp +++ b/third_party/WebKit/Source/modules/fetch/FetchDataLoader.cpp
@@ -74,7 +74,7 @@ case WebDataConsumerHandle::Done: { m_reader.clear(); long long size = m_blobData->length(); - m_client->didFetchDataLoadedBlobHandle(BlobDataHandle::create(m_blobData.release(), size)); + m_client->didFetchDataLoadedBlobHandle(BlobDataHandle::create(std::move(m_blobData), size)); m_client.clear(); return; }
diff --git a/third_party/WebKit/Source/modules/fetch/FetchDataLoaderTest.cpp b/third_party/WebKit/Source/modules/fetch/FetchDataLoaderTest.cpp index 0831dd9..9c031fa 100644 --- a/third_party/WebKit/Source/modules/fetch/FetchDataLoaderTest.cpp +++ b/third_party/WebKit/Source/modules/fetch/FetchDataLoaderTest.cpp
@@ -143,7 +143,7 @@ OwnPtr<BlobData> blobData = BlobData::create(); blobData->appendBytes(kQuickBrownFox, kQuickBrownFoxLengthWithTerminatingNull); blobData->setContentType("text/test"); - RefPtr<BlobDataHandle> inputBlobDataHandle = BlobDataHandle::create(blobData.release(), kQuickBrownFoxLengthWithTerminatingNull); + RefPtr<BlobDataHandle> inputBlobDataHandle = BlobDataHandle::create(std::move(blobData), kQuickBrownFoxLengthWithTerminatingNull); Checkpoint checkpoint; @@ -182,7 +182,7 @@ OwnPtr<BlobData> blobData = BlobData::create(); blobData->appendBytes(kQuickBrownFox, kQuickBrownFoxLengthWithTerminatingNull); blobData->setContentType("text/different"); - RefPtr<BlobDataHandle> inputBlobDataHandle = BlobDataHandle::create(blobData.release(), kQuickBrownFoxLengthWithTerminatingNull); + RefPtr<BlobDataHandle> inputBlobDataHandle = BlobDataHandle::create(std::move(blobData), kQuickBrownFoxLengthWithTerminatingNull); Checkpoint checkpoint;
diff --git a/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandle.cpp b/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandle.cpp index b175a7b..36bc1754 100644 --- a/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandle.cpp +++ b/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandle.cpp
@@ -65,7 +65,7 @@ blobData->appendBytes(m_flattenFormData.data(), m_flattenFormData.size()); m_flattenFormData.clear(); auto length = blobData->length(); - return BlobDataHandle::create(blobData.release(), length); + return BlobDataHandle::create(std::move(blobData), length); } PassRefPtr<EncodedFormData> drainFormData() @@ -268,9 +268,9 @@ auto size = blobData->length(); if (factory) { // For testing - m_handle = FetchBlobDataConsumerHandle::create(executionContext, BlobDataHandle::create(blobData.release(), size), factory); + m_handle = FetchBlobDataConsumerHandle::create(executionContext, BlobDataHandle::create(std::move(blobData), size), factory); } else { - m_handle = FetchBlobDataConsumerHandle::create(executionContext, BlobDataHandle::create(blobData.release(), size)); + m_handle = FetchBlobDataConsumerHandle::create(executionContext, BlobDataHandle::create(std::move(blobData), size)); } // It is important to initialize |m_formData| here, because even // read-only operations may make the form data unsharable with implicit
diff --git a/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandleTest.cpp b/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandleTest.cpp index e09a1ac6..f4432a6 100644 --- a/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandleTest.cpp +++ b/third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandleTest.cpp
@@ -60,13 +60,13 @@ OwnPtr<MockThreadableLoader> loader = MockThreadableLoader::create(); EXPECT_CALL(*loader, start(_)).WillOnce(InvokeWithoutArgs(this, &LoaderFactory::handleDidReceiveResponse)); EXPECT_CALL(*loader, cancel()).Times(1); - return loader.release(); + return std::move(loader); } private: void handleDidReceiveResponse() { - m_client->didReceiveResponse(0, ResourceResponse(), m_handle.release()); + m_client->didReceiveResponse(0, ResourceResponse(), std::move(m_handle)); } ThreadableLoaderClient* m_client; @@ -93,7 +93,7 @@ OwnPtr<BlobData> blobData = BlobData::create(); blobData->appendText("hello", false); auto size = blobData->length(); - RefPtr<BlobDataHandle> blobDataHandle = BlobDataHandle::create(blobData.release(), size); + RefPtr<BlobDataHandle> blobDataHandle = BlobDataHandle::create(std::move(blobData), size); data->appendBlob(blobDataHandle->uuid(), blobDataHandle); Vector<char> boundary; boundary.append("\0", 1); @@ -133,7 +133,7 @@ TEST_F(FetchFormDataConsumerHandleTest, ReadFromString) { OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create(String("hello, world")); - HandleReaderRunner<HandleReader> runner(handle.release()); + HandleReaderRunner<HandleReader> runner(std::move(handle)); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kDone, r->result()); EXPECT_EQ("hello, world", toString(r->data())); @@ -142,7 +142,7 @@ TEST_F(FetchFormDataConsumerHandleTest, TwoPhaseReadFromString) { OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create(String("hello, world")); - HandleReaderRunner<HandleTwoPhaseReader> runner(handle.release()); + HandleReaderRunner<HandleTwoPhaseReader> runner(std::move(handle)); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kDone, r->result()); EXPECT_EQ("hello, world", toString(r->data())); @@ -152,7 +152,7 @@ { UChar cs[] = {0x3042, 0}; OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create(String(cs)); - HandleReaderRunner<HandleReader> runner(handle.release()); + HandleReaderRunner<HandleReader> runner(std::move(handle)); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kDone, r->result()); EXPECT_EQ("\xe3\x81\x82", toString(r->data())); @@ -163,7 +163,7 @@ const unsigned char data[] = { 0x21, 0xfe, 0x00, 0x00, 0xff, 0xa3, 0x42, 0x30, 0x42, 0x99, 0x88 }; DOMArrayBuffer* buffer = DOMArrayBuffer::create(data, WTF_ARRAY_LENGTH(data)); OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create(buffer); - HandleReaderRunner<HandleReader> runner(handle.release()); + HandleReaderRunner<HandleReader> runner(std::move(handle)); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kDone, r->result()); Vector<char> expected; @@ -177,7 +177,7 @@ const size_t offset = 1, size = 4; DOMArrayBuffer* buffer = DOMArrayBuffer::create(data, WTF_ARRAY_LENGTH(data)); OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create(DOMUint8Array::create(buffer, offset, size)); - HandleReaderRunner<HandleReader> runner(handle.release()); + HandleReaderRunner<HandleReader> runner(std::move(handle)); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kDone, r->result()); Vector<char> expected; @@ -192,7 +192,7 @@ data->appendData("hoge", 4); OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::create(getDocument(), data); - HandleReaderRunner<HandleReader> runner(handle.release()); + HandleReaderRunner<HandleReader> runner(std::move(handle)); testing::runPendingTasks(); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kDone, r->result()); @@ -205,12 +205,12 @@ OwnPtr<ReplayingHandle> src = ReplayingHandle::create(); src->add(Command(Command::Data, "bar")); src->add(Command(Command::Done)); - OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::createForTest(getDocument(), data, new LoaderFactory(src.release())); + OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::createForTest(getDocument(), data, new LoaderFactory(std::move(src))); char c; size_t readSize; EXPECT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(&c, 1, kNone, &readSize)); - HandleReaderRunner<HandleReader> runner(handle.release()); + HandleReaderRunner<HandleReader> runner(std::move(handle)); testing::runPendingTasks(); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kDone, r->result()); @@ -223,12 +223,12 @@ OwnPtr<ReplayingHandle> src = ReplayingHandle::create(); src->add(Command(Command::Data, "bar")); src->add(Command(Command::Done)); - OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::createForTest(getDocument(), data, new LoaderFactory(src.release())); + OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::createForTest(getDocument(), data, new LoaderFactory(std::move(src))); char c; size_t readSize; EXPECT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(&c, 1, kNone, &readSize)); - HandleReaderRunner<HandleTwoPhaseReader> runner(handle.release()); + HandleReaderRunner<HandleTwoPhaseReader> runner(std::move(handle)); testing::runPendingTasks(); OwnPtr<HandleReadResult> r = runner.wait(); EXPECT_EQ(kDone, r->result()); @@ -397,7 +397,7 @@ OwnPtr<ReplayingHandle> src = ReplayingHandle::create(); src->add(Command(Command::Data, "bar")); src->add(Command(Command::Done)); - OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::createForTest(getDocument(), complexFormData(), new LoaderFactory(src.release())); + OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::createForTest(getDocument(), complexFormData(), new LoaderFactory(std::move(src))); OwnPtr<FetchDataConsumerHandle::Reader> reader = handle->obtainReader(nullptr); size_t readSize; EXPECT_EQ(kShouldWait, reader->read(nullptr, 0, kNone, &readSize)); @@ -414,7 +414,7 @@ OwnPtr<ReplayingHandle> src = ReplayingHandle::create(); src->add(Command(Command::Data, "bar")); src->add(Command(Command::Done)); - OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::createForTest(getDocument(), complexFormData(), new LoaderFactory(src.release())); + OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::createForTest(getDocument(), complexFormData(), new LoaderFactory(std::move(src))); OwnPtr<FetchDataConsumerHandle::Reader> reader = handle->obtainReader(nullptr); char c; size_t readSize; @@ -432,7 +432,7 @@ src->add(Command(Command::Data, "bar")); src->add(Command(Command::Done)); const void* buffer = nullptr; - OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::createForTest(getDocument(), complexFormData(), new LoaderFactory(src.release())); + OwnPtr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandle::createForTest(getDocument(), complexFormData(), new LoaderFactory(std::move(src))); OwnPtr<FetchDataConsumerHandle::Reader> reader = handle->obtainReader(nullptr); size_t available; EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available));
diff --git a/third_party/WebKit/Source/modules/fetch/FetchRequestData.cpp b/third_party/WebKit/Source/modules/fetch/FetchRequestData.cpp index c94a2f1..77a1ba3 100644 --- a/third_party/WebKit/Source/modules/fetch/FetchRequestData.cpp +++ b/third_party/WebKit/Source/modules/fetch/FetchRequestData.cpp
@@ -72,8 +72,8 @@ if (m_buffer) { OwnPtr<FetchDataConsumerHandle> dest1, dest2; DataConsumerTee::create(scriptState->getExecutionContext(), m_buffer->releaseHandle(), &dest1, &dest2); - m_buffer = new BodyStreamBuffer(scriptState, dest1.release()); - request->m_buffer = new BodyStreamBuffer(scriptState, dest2.release()); + m_buffer = new BodyStreamBuffer(scriptState, std::move(dest1)); + request->m_buffer = new BodyStreamBuffer(scriptState, std::move(dest2)); } return request; }
diff --git a/third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp b/third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp index f39879e..a3500d2 100644 --- a/third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp +++ b/third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp
@@ -192,8 +192,8 @@ if (m_buffer) { OwnPtr<WebDataConsumerHandle> handle1, handle2; DataConsumerTee::create(scriptState->getExecutionContext(), m_buffer->releaseHandle(), &handle1, &handle2); - m_buffer = new BodyStreamBuffer(scriptState, createFetchDataConsumerHandleFromWebHandle(handle1.release())); - newResponse->m_buffer = new BodyStreamBuffer(scriptState, createFetchDataConsumerHandleFromWebHandle(handle2.release())); + m_buffer = new BodyStreamBuffer(scriptState, createFetchDataConsumerHandleFromWebHandle(std::move(handle1))); + newResponse->m_buffer = new BodyStreamBuffer(scriptState, createFetchDataConsumerHandleFromWebHandle(std::move(handle2))); } break; }
diff --git a/third_party/WebKit/Source/modules/fetch/Request.cpp b/third_party/WebKit/Source/modules/fetch/Request.cpp index a486260..56ad8a3 100644 --- a/third_party/WebKit/Source/modules/fetch/Request.cpp +++ b/third_party/WebKit/Source/modules/fetch/Request.cpp
@@ -344,7 +344,7 @@ // contains no header named `Content-Type`, append // `Content-Type`/|Content-Type| to |r|'s Headers object. Rethrow any // exception." - temporaryBody = new BodyStreamBuffer(scriptState, init.body.release()); + temporaryBody = new BodyStreamBuffer(scriptState, std::move(init.body)); if (!init.contentType.isEmpty() && !r->getHeaders()->has(HTTPNames::Content_Type, exceptionState)) { r->getHeaders()->append(HTTPNames::Content_Type, init.contentType, exceptionState); }
diff --git a/third_party/WebKit/Source/modules/fetch/Response.cpp b/third_party/WebKit/Source/modules/fetch/Response.cpp index 0b1efca..be53df1d 100644 --- a/third_party/WebKit/Source/modules/fetch/Response.cpp +++ b/third_party/WebKit/Source/modules/fetch/Response.cpp
@@ -156,7 +156,7 @@ contentType = "text/plain;charset=UTF-8"; } // TODO(yhirano): Add the URLSearchParams case. - Response* response = create(scriptState, bodyHandle.release(), contentType, ResponseInit(init, exceptionState), exceptionState); + Response* response = create(scriptState, std::move(bodyHandle), contentType, ResponseInit(init, exceptionState), exceptionState); if (!exceptionState.hadException() && !reader.isEmpty()) { // Add a hidden reference so that the weak persistent in the // ReadableStreamDataConsumerHandle will be valid as long as the
diff --git a/third_party/WebKit/Source/modules/fetch/ResponseTest.cpp b/third_party/WebKit/Source/modules/fetch/ResponseTest.cpp index 7e63c188c..a1fad617 100644 --- a/third_party/WebKit/Source/modules/fetch/ResponseTest.cpp +++ b/third_party/WebKit/Source/modules/fetch/ResponseTest.cpp
@@ -38,7 +38,7 @@ webResponse->setResponseType(WebServiceWorkerResponseTypeDefault); for (int i = 0; headers[i].key; ++i) webResponse->setHeader(WebString::fromUTF8(headers[i].key), WebString::fromUTF8(headers[i].value)); - return webResponse.release(); + return webResponse; } class ServiceWorkerResponseTest : public ::testing::Test { @@ -191,7 +191,7 @@ src->add(Command(Command::Data, "Hello, ")); src->add(Command(Command::Data, "world")); src->add(Command(Command::Done)); - return new BodyStreamBuffer(scriptState, createFetchDataConsumerHandleFromWebHandle(src.release())); + return new BodyStreamBuffer(scriptState, createFetchDataConsumerHandleFromWebHandle(std::move(src))); } TEST_F(ServiceWorkerResponseTest, BodyStreamBufferCloneDefault)
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBEventDispatcher.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBEventDispatcher.cpp index 76ca8bc0d5..a57bddd 100644 --- a/third_party/WebKit/Source/modules/indexeddb/IDBEventDispatcher.cpp +++ b/third_party/WebKit/Source/modules/indexeddb/IDBEventDispatcher.cpp
@@ -28,6 +28,7 @@ #include "modules/indexeddb/IDBEventDispatcher.h" +#include "core/frame/UseCounter.h" #include "modules/EventModules.h" #include "modules/EventTargetModules.h" @@ -49,15 +50,29 @@ event->setEventPhase(Event::AT_TARGET); event->setCurrentTarget(eventTargets[0].get()); eventTargets[0]->fireEventListeners(event); - if (event->propagationStopped() || !event->bubbles() || event->cancelBubble()) + if (event->propagationStopped() || !event->bubbles()) goto doneDispatching; + if (event->bubbles() && event->cancelBubble()) { + for (size_t i = 1; i < size; ++i) { // Don't do the first element. + if (eventTargets[i]->hasEventListeners(event->type())) + UseCounter::count(eventTargets[i]->getExecutionContext(), UseCounter::EventCancelBubbleAffected); + } + goto doneDispatching; + } event->setEventPhase(Event::BUBBLING_PHASE); for (size_t i = 1; i < size; ++i) { // Don't do the first element. event->setCurrentTarget(eventTargets[i].get()); eventTargets[i]->fireEventListeners(event); - if (event->propagationStopped() || event->cancelBubble()) + if (event->propagationStopped()) goto doneDispatching; + if (event->cancelBubble()) { + for (size_t j = i + 1; j < size; ++j) { + if (eventTargets[j]->hasEventListeners(event->type())) + UseCounter::count(eventTargets[j]->getExecutionContext(), UseCounter::EventCancelBubbleAffected); + } + goto doneDispatching; + } } doneDispatching:
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp index bc932eb..bb3e62cc 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
@@ -70,7 +70,7 @@ context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, "ServiceWorker cannot send an ArrayBuffer as a transferable object yet. See http://crbug.com/511119")); WebString messageString = message->toWireString(); - OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePortChannelArray(channels.release()); + OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePortChannelArray(std::move(channels)); m_handle->serviceWorker()->postMessage(client->provider(), messageString, WebSecurityOrigin(getExecutionContext()->getSecurityOrigin()), webChannels.leakPtr()); }
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerClient.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerClient.cpp index 107ce6c5..ae934b81 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerClient.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerClient.cpp
@@ -78,8 +78,8 @@ context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, "ServiceWorkerClient cannot send an ArrayBuffer as a transferable object yet. See http://crbug.com/511119")); WebString messageString = message->toWireString(); - OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePortChannelArray(channels.release()); - ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, messageString, webChannels.release()); + OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePortChannelArray(std::move(channels)); + ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, messageString, std::move(webChannels)); } } // namespace blink
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerClients.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerClients.cpp index 4805bf9..85cad8a 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerClients.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerClients.cpp
@@ -76,7 +76,7 @@ m_resolver->resolve(); return; } - m_resolver->resolve(ServiceWorkerClient::take(m_resolver, client.release())); + m_resolver->resolve(ServiceWorkerClient::take(m_resolver, std::move(client))); } void onError(const WebServiceWorkerError& error) override
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp index 2cebac5..0ae84e2 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -104,7 +104,7 @@ m_resolver->resolve(); return; } - m_resolver->resolve(ServiceWorkerRegistration::getOrCreate(m_resolver->getExecutionContext(), handle.release())); + m_resolver->resolve(ServiceWorkerRegistration::getOrCreate(m_resolver->getExecutionContext(), std::move(handle))); } void onError(const WebServiceWorkerError& error) override
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp index 1811a8d..91ea315 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
@@ -69,7 +69,7 @@ { // Note: startupData is finalized on return. After the relevant parts has been // passed along to the created 'context'. - ServiceWorkerGlobalScope* context = new ServiceWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, thread, monotonicallyIncreasingTime(), startupData->m_starterOriginPrivilegeData.release(), startupData->m_workerClients.release()); + ServiceWorkerGlobalScope* context = new ServiceWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, thread, monotonicallyIncreasingTime(), std::move(startupData->m_starterOriginPrivilegeData), startupData->m_workerClients.release()); context->setV8CacheOptions(startupData->m_v8CacheOptions); context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurityPolicyHeaders);
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.h b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.h index 6958db4..1368c7e 100644 --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.h +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerRegistration.h
@@ -94,7 +94,7 @@ { HeapVector<Member<ServiceWorkerRegistration>> registrations; for (auto& registration : *webServiceWorkerRegistrations) - registrations.append(ServiceWorkerRegistration::getOrCreate(resolver->getExecutionContext(), registration.release())); + registrations.append(ServiceWorkerRegistration::getOrCreate(resolver->getExecutionContext(), std::move(registration))); return registrations; } };
diff --git a/third_party/WebKit/Source/modules/storage/InspectorDOMStorageAgent.cpp b/third_party/WebKit/Source/modules/storage/InspectorDOMStorageAgent.cpp index 51594694..c2ea9ecc 100644 --- a/third_party/WebKit/Source/modules/storage/InspectorDOMStorageAgent.cpp +++ b/third_party/WebKit/Source/modules/storage/InspectorDOMStorageAgent.cpp
@@ -127,9 +127,9 @@ OwnPtr<protocol::Array<String>> entry = protocol::Array<String>::create(); entry->addItem(name); entry->addItem(value); - storageItems->addItem(entry.release()); + storageItems->addItem(std::move(entry)); } - *items = storageItems.release(); + *items = std::move(storageItems); } static String toErrorString(ExceptionState& exceptionState) @@ -182,13 +182,13 @@ OwnPtr<protocol::DOMStorage::StorageId> id = storageId(securityOrigin, storageType == LocalStorage); if (key.isNull()) - frontend()->domStorageItemsCleared(id.release()); + frontend()->domStorageItemsCleared(std::move(id)); else if (newValue.isNull()) - frontend()->domStorageItemRemoved(id.release(), key); + frontend()->domStorageItemRemoved(std::move(id), key); else if (oldValue.isNull()) - frontend()->domStorageItemAdded(id.release(), key, newValue); + frontend()->domStorageItemAdded(std::move(id), key, newValue); else - frontend()->domStorageItemUpdated(id.release(), key, oldValue, newValue); + frontend()->domStorageItemUpdated(std::move(id), key, oldValue, newValue); } StorageArea* InspectorDOMStorageAgent::findStorageArea(ErrorString* errorString, PassOwnPtr<protocol::DOMStorage::StorageId> storageId, LocalFrame*& targetFrame)
diff --git a/third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp b/third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp index d61455f..35fca91 100644 --- a/third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp +++ b/third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp
@@ -309,7 +309,7 @@ // Use the first audio track in the media stream. MediaStreamTrack* audioTrack = audioTracks[0]; OwnPtr<AudioSourceProvider> provider = audioTrack->createWebAudioSource(); - MediaStreamAudioSourceNode* node = MediaStreamAudioSourceNode::create(*this, *mediaStream, audioTrack, provider.release()); + MediaStreamAudioSourceNode* node = MediaStreamAudioSourceNode::create(*this, *mediaStream, audioTrack, std::move(provider)); // FIXME: Only stereo streams are supported right now. We should be able to accept multi-channel streams. node->setFormat(2, sampleRate());
diff --git a/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp b/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp index 207bbf52..3f714f3 100644 --- a/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp +++ b/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp
@@ -132,7 +132,7 @@ { // Synchronize with process(). MutexLocker locker(m_processLock); - m_reverb = reverb.release(); + m_reverb = std::move(reverb); m_buffer = buffer; } }
diff --git a/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp b/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp index db4c8b2c..f630e8f 100644 --- a/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp +++ b/third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp
@@ -224,7 +224,7 @@ unsigned waveSize = periodicWaveSize(); OwnPtr<AudioFloatArray> table = adoptPtr(new AudioFloatArray(waveSize)); adjustV8ExternalMemory(waveSize * sizeof(float)); - m_bandLimitedTables.append(table.release()); + m_bandLimitedTables.append(std::move(table)); // Apply an inverse FFT to generate the time-domain table data. float* data = m_bandLimitedTables[rangeIndex]->data();
diff --git a/third_party/WebKit/Source/modules/webdatabase/Database.cpp b/third_party/WebKit/Source/modules/webdatabase/Database.cpp index 2a4302f..395f746 100644 --- a/third_party/WebKit/Source/modules/webdatabase/Database.cpp +++ b/third_party/WebKit/Source/modules/webdatabase/Database.cpp
@@ -266,7 +266,7 @@ DatabaseTracker::tracker().prepareToOpenDatabase(this); bool success = false; OwnPtr<DatabaseOpenTask> task = DatabaseOpenTask::create(this, setVersionInNewDatabase, &synchronizer, error, errorMessage, success); - getDatabaseContext()->databaseThread()->scheduleTask(task.release()); + getDatabaseContext()->databaseThread()->scheduleTask(std::move(task)); synchronizer.waitForTaskCompletion(); return success; @@ -334,7 +334,7 @@ OwnPtr<DatabaseTransactionTask> task = DatabaseTransactionTask::create(transaction); WTF_LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for transaction %p\n", task.get(), task->transaction()); m_transactionInProgress = true; - getDatabaseContext()->databaseThread()->scheduleTask(task.release()); + getDatabaseContext()->databaseThread()->scheduleTask(std::move(task)); } else { m_transactionInProgress = false; } @@ -347,7 +347,7 @@ OwnPtr<DatabaseTransactionTask> task = DatabaseTransactionTask::create(transaction); WTF_LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for the transaction step\n", task.get()); - getDatabaseContext()->databaseThread()->scheduleTask(task.release()); + getDatabaseContext()->databaseThread()->scheduleTask(std::move(task)); } SQLTransactionClient* Database::transactionClient() const @@ -836,7 +836,7 @@ ASSERT(callback == originalErrorCallback); if (callback) { OwnPtr<SQLErrorData> error = SQLErrorData::create(SQLError::UNKNOWN_ERR, "database has been closed"); - getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&callTransactionErrorCallback, callback, passed(error.release()))); + getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&callTransactionErrorCallback, callback, passed(std::move(error)))); } } } @@ -888,7 +888,7 @@ return result; OwnPtr<DatabaseTableNamesTask> task = DatabaseTableNamesTask::create(this, &synchronizer, result); - getDatabaseContext()->databaseThread()->scheduleTask(task.release()); + getDatabaseContext()->databaseThread()->scheduleTask(std::move(task)); synchronizer.waitForTaskCompletion(); return result;
diff --git a/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseAgent.cpp b/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseAgent.cpp index 7edd195..3eb2a43 100644 --- a/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseAgent.cpp +++ b/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseAgent.cpp
@@ -71,7 +71,7 @@ OwnPtr<protocol::Database::Error> errorObject = protocol::Database::Error::create() .setMessage(error->message()) .setCode(error->code()).build(); - m_callback->sendSuccess(Maybe<protocol::Array<String>>(), Maybe<protocol::Array<protocol::Value>>(), errorObject.release()); + m_callback->sendSuccess(Maybe<protocol::Array<String>>(), Maybe<protocol::Array<protocol::Value>>(), std::move(errorObject)); } private: @@ -112,7 +112,7 @@ case SQLValue::NullValue: values->addItem(protocol::Value::null()); break; } } - m_requestCallback->get()->sendSuccess(columnNames.release(), values.release(), Maybe<protocol::Database::Error>()); + m_requestCallback->get()->sendSuccess(std::move(columnNames), std::move(values), Maybe<protocol::Database::Error>()); return true; } @@ -320,7 +320,7 @@ return; } - RefPtr<ExecuteSQLCallbackWrapper> wrapper = ExecuteSQLCallbackWrapper::create(requestCallback.release()); + RefPtr<ExecuteSQLCallbackWrapper> wrapper = ExecuteSQLCallbackWrapper::create(std::move(requestCallback)); SQLTransactionCallback* callback = TransactionCallback::create(query, wrapper); SQLTransactionErrorCallback* errorCallback = TransactionErrorCallback::create(wrapper); VoidCallback* successCallback = TransactionSuccessCallback::create();
diff --git a/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseResource.cpp b/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseResource.cpp index 87a31b0..fdc4ac00 100644 --- a/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseResource.cpp +++ b/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseResource.cpp
@@ -62,7 +62,7 @@ .setDomain(m_domain) .setName(m_name) .setVersion(m_version).build(); - frontend->addDatabase(jsonObject.release()); + frontend->addDatabase(std::move(jsonObject)); } } // namespace blink
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.cpp index e83777a..a0cfba1 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.cpp
@@ -50,7 +50,7 @@ gl->PushGroupMarkerEXT(0, contextLabel.ascii().data()); } - WebGL2RenderingContext* renderingContext = new WebGL2RenderingContext(canvas, contextProvider.release(), attributes); + WebGL2RenderingContext* renderingContext = new WebGL2RenderingContext(canvas, std::move(contextProvider), attributes); if (!renderingContext->drawingBuffer()) { canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, "Could not create a WebGL2 context."));
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp index 8307c0c..fe348e8 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp
@@ -89,7 +89,7 @@ if (!shouldCreateContext(contextProvider.get())) return nullptr; - WebGLRenderingContext* renderingContext = new WebGLRenderingContext(offscreenCanvas, contextProvider.release(), attributes); + WebGLRenderingContext* renderingContext = new WebGLRenderingContext(offscreenCanvas, std::move(contextProvider), attributes); if (!renderingContext->drawingBuffer()) return nullptr; renderingContext->initializeNewContext(); @@ -105,7 +105,7 @@ if (!shouldCreateContext(contextProvider.get())) return nullptr; - WebGLRenderingContext* renderingContext = new WebGLRenderingContext(canvas, contextProvider.release(), attributes); + WebGLRenderingContext* renderingContext = new WebGLRenderingContext(canvas, std::move(contextProvider), attributes); if (!renderingContext->drawingBuffer()) { canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, "Could not create a WebGL context.")); return nullptr;
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp index c8e6dbbd..fa3c89ad 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -543,7 +543,7 @@ Platform::GraphicsInfo glInfo() { return m_glInfo; } ScriptState* scriptState() { return m_scriptState; } void setContextProvider(PassOwnPtr<WebGraphicsContext3DProvider> provider) { m_provider = std::move(provider); } - PassOwnPtr<WebGraphicsContext3DProvider> releaseContextProvider() { return m_provider.release(); } + PassOwnPtr<WebGraphicsContext3DProvider> releaseContextProvider() { return std::move(m_provider); } private: Platform::ContextAttributes m_contextAttributes; Platform::GraphicsInfo m_glInfo; @@ -557,7 +557,7 @@ Platform::GraphicsInfo glInfo = creationInfo->glInfo(); OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()->createOffscreenGraphicsContext3DProvider( creationInfo->contextAttributes(), creationInfo->scriptState()->getExecutionContext()->url(), 0, &glInfo, Platform::DoNotBindToCurrentThread)); - creationInfo->setContextProvider(provider.release()); + creationInfo->setContextProvider(std::move(provider)); waitableEvent->signal(); } @@ -601,7 +601,7 @@ canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, "OES_packed_depth_stencil support is required.")); return nullptr; } - return contextProvider.release(); + return contextProvider; } PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGraphicsContext3DProvider(HTMLCanvasElement* canvas, WebGLContextAttributes attributes, unsigned webGLVersion) @@ -4265,7 +4265,7 @@ // Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU. OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBufferSurface(IntSize(video->videoWidth(), video->videoHeight()))); if (surface->isValid()) { - OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release())); + OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(std::move(surface))); if (imageBuffer) { // The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface, // we enable the WebMediaPlayer implementation to do any necessary color space conversion on the GPU (though it @@ -6055,7 +6055,7 @@ RefPtr<DrawingBuffer> buffer; if (contextProvider) { // Construct a new drawing buffer with the new GL context. - buffer = createDrawingBuffer(contextProvider.release()); + buffer = createDrawingBuffer(std::move(contextProvider)); // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| is set to null. } if (!buffer) { @@ -6114,7 +6114,7 @@ if (!temp) return nullptr; i = std::min(m_capacity - 1, i); - m_buffers[i] = temp.release(); + m_buffers[i] = std::move(temp); ImageBuffer* buf = m_buffers[i].get(); bubbleToFront(i);
diff --git a/third_party/WebKit/Source/modules/webmidi/MIDIAccessInitializer.cpp b/third_party/WebKit/Source/modules/webmidi/MIDIAccessInitializer.cpp index a670413..52a3823 100644 --- a/third_party/WebKit/Source/modules/webmidi/MIDIAccessInitializer.cpp +++ b/third_party/WebKit/Source/modules/webmidi/MIDIAccessInitializer.cpp
@@ -102,7 +102,7 @@ { DCHECK(m_accessor); if (success) { - resolve(MIDIAccess::create(m_accessor.release(), m_options.hasSysex() && m_options.sysex(), m_portDescriptors, getExecutionContext())); + resolve(MIDIAccess::create(std::move(m_accessor), m_options.hasSysex() && m_options.sysex(), m_portDescriptors, getExecutionContext())); } else { // The spec says the name is one of // - SecurityError
diff --git a/third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp b/third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp index b7c0c1d..7212149c 100644 --- a/third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp +++ b/third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp
@@ -646,7 +646,7 @@ binaryData->swap(*rawData->mutableData()); OwnPtr<BlobData> blobData = BlobData::create(); blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); - Blob* blob = Blob::create(BlobDataHandle::create(blobData.release(), size)); + Blob* blob = Blob::create(BlobDataHandle::create(std::move(blobData), size)); recordReceiveTypeHistogram(WebSocketReceiveTypeBlob); m_eventQueue->dispatch(MessageEvent::create(blob, SecurityOrigin::create(m_url)->toString())); break;
diff --git a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp index 10e7c02..b2af8a9 100644 --- a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp +++ b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
@@ -508,7 +508,7 @@ } else { OwnPtr<Vector<char>> binaryData = adoptPtr(new Vector<char>); binaryData->swap(m_receivingMessageData); - m_client->didReceiveBinaryMessage(binaryData.release()); + m_client->didReceiveBinaryMessage(std::move(binaryData)); } }
diff --git a/third_party/WebKit/Source/modules/websockets/InspectorWebSocketEvents.cpp b/third_party/WebKit/Source/modules/websockets/InspectorWebSocketEvents.cpp index 0a9d36f..e95695f1 100644 --- a/third_party/WebKit/Source/modules/websockets/InspectorWebSocketEvents.cpp +++ b/third_party/WebKit/Source/modules/websockets/InspectorWebSocketEvents.cpp
@@ -18,7 +18,7 @@ if (!protocol.isNull()) value->setString("webSocketProtocol", protocol); setCallStack(value.get()); - return value.release(); + return value; } PassOwnPtr<TracedValue> InspectorWebSocketEvent::data(Document* document, unsigned long identifier) @@ -27,7 +27,7 @@ value->setInteger("identifier", identifier); value->setString("frame", toHexString(document->frame())); setCallStack(value.get()); - return value.release(); + return value; } } // namespace blink
diff --git a/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp b/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp index d230667..86114bc5 100644 --- a/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp +++ b/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp
@@ -408,7 +408,7 @@ if (message.length()) memcpy(data->data(), static_cast<const char*>(message.data()), message.length()); - m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendTextAsCharVector, AllowCrossThreadAccess(m_peer.get()), passed(data.release()))); + m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendTextAsCharVector, AllowCrossThreadAccess(m_peer.get()), passed(std::move(data)))); } void Bridge::send(const DOMArrayBuffer& binaryData, unsigned byteOffset, unsigned byteLength) @@ -419,7 +419,7 @@ if (binaryData.byteLength()) memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteOffset, byteLength); - m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBinaryAsCharVector, AllowCrossThreadAccess(m_peer.get()), passed(data.release()))); + m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBinaryAsCharVector, AllowCrossThreadAccess(m_peer.get()), passed(std::move(data)))); } void Bridge::send(PassRefPtr<BlobDataHandle> data)
diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.cpp b/third_party/WebKit/Source/platform/heap/ThreadState.cpp index f11c93b..e8910cb 100644 --- a/third_party/WebKit/Source/platform/heap/ThreadState.cpp +++ b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
@@ -264,6 +264,13 @@ { ASSERT(isMainThread()); +#if defined(LEAK_SANITIZER) + // See comment below, clear out most garbage before releasing static + // persistents should some of the finalizers depend on touching + // these persistents. + ThreadHeap::collectAllGarbage(); +#endif + releaseStaticPersistentNodes(); #if defined(LEAK_SANITIZER)
diff --git a/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp b/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp index a161aed..a0815f8 100644 --- a/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp +++ b/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp
@@ -1091,7 +1091,15 @@ return *this; } -// this = mat * this. +// Calculates *this = *this * mat. +// Note: A * B means that the transforms represented by A happen first, and +// then the transforms represented by B. That is, the matrix A * B corresponds +// to a CSS transform list <transform-function-A> <transform-function-B>. +// Some branches of this function may make use of the fact that +// transpose(A * B) == transpose(B) * transpose(A); remember that +// m_matrix[a][b] is matrix element row b, col a. +// FIXME: As of 2016-05-04, the ARM64 branch is NOT triggered by tests on the CQ +// bots, see crbug.com/477892 and crbug.com/584508. TransformationMatrix& TransformationMatrix::multiply(const TransformationMatrix& mat) { #if CPU(ARM64)
diff --git a/third_party/WebKit/Source/platform/transforms/TransformationMatrix.h b/third_party/WebKit/Source/platform/transforms/TransformationMatrix.h index a568010..a064a9f 100644 --- a/third_party/WebKit/Source/platform/transforms/TransformationMatrix.h +++ b/third_party/WebKit/Source/platform/transforms/TransformationMatrix.h
@@ -263,7 +263,7 @@ double f() const { return m_matrix[3][1]; } void setF(double f) { m_matrix[3][1] = f; } - // this = mat * this. + // *this = *this * mat. TransformationMatrix& multiply(const TransformationMatrix&); TransformationMatrix& scale(double);
diff --git a/third_party/WebKit/Source/platform/transforms/TransformationMatrixTest.cpp b/third_party/WebKit/Source/platform/transforms/TransformationMatrixTest.cpp index 309f5d16..92926e1 100644 --- a/third_party/WebKit/Source/platform/transforms/TransformationMatrixTest.cpp +++ b/third_party/WebKit/Source/platform/transforms/TransformationMatrixTest.cpp
@@ -74,4 +74,28 @@ EXPECT_EQ(FloatPoint3D(-1, -4, -9), matrix.mapPoint(FloatPoint3D(0, 0, 0))); } + +TEST(TransformationMatrixTest, Multiplication) +{ + TransformationMatrix a(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4); + // [ 1 2 3 4 ] + // [ 1 2 3 4 ] + // [ 1 2 3 4 ] + // [ 1 2 3 4 ] + + TransformationMatrix b(1, 2, 3, 5, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4); + // [ 1 1 1 1 ] + // [ 2 2 2 2 ] + // [ 3 3 3 3 ] + // [ 5 4 4 4 ] + + TransformationMatrix expectedAtimesB(34, 34, 34, 34, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30); + + EXPECT_EQ(expectedAtimesB, a * b); + + a.multiply(b); + EXPECT_EQ(expectedAtimesB, a); +} + } // namespace blink
diff --git a/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp b/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp index d68aea9..8b20a10 100644 --- a/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp +++ b/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
@@ -359,7 +359,12 @@ if (m_askedToTerminate) return; - if (m_mainScriptLoader->failed()) { + // The browser is expected to associate a registration and then load the + // script. If there's no associated registration, the browser could not + // successfully handle the SetHostedVersionID IPC, and the script load came + // through the normal network stack rather than through service worker + // loading code. + if (!m_workerContextClient->hasAssociatedRegistration() || m_mainScriptLoader->failed()) { m_mainScriptLoader.clear(); // This deletes 'this'. m_workerContextClient->workerContextFailedToStart();
diff --git a/third_party/WebKit/Source/web/WebEmbeddedWorkerImplTest.cpp b/third_party/WebKit/Source/web/WebEmbeddedWorkerImplTest.cpp index 2f14558..8b2cea6f 100644 --- a/third_party/WebKit/Source/web/WebEmbeddedWorkerImplTest.cpp +++ b/third_party/WebKit/Source/web/WebEmbeddedWorkerImplTest.cpp
@@ -23,13 +23,24 @@ class MockServiceWorkerContextClient : public WebServiceWorkerContextClient { public: - MockServiceWorkerContextClient() { } + MockServiceWorkerContextClient() + : m_hasAssociatedRegistration(true) + { + } ~MockServiceWorkerContextClient() override { } MOCK_METHOD0(workerReadyForInspection, void()); MOCK_METHOD0(workerContextFailedToStart, void()); MOCK_METHOD0(workerScriptLoaded, void()); MOCK_METHOD1(createServiceWorkerNetworkProvider, WebServiceWorkerNetworkProvider*(WebDataSource*)); MOCK_METHOD0(createServiceWorkerProvider, WebServiceWorkerProvider*()); + bool hasAssociatedRegistration() override + { + return m_hasAssociatedRegistration; + } + void setHasAssociatedRegistration(bool hasAssociatedRegistration) + { + m_hasAssociatedRegistration = hasAssociatedRegistration; + } void getClient(const WebString&, WebServiceWorkerClientCallbacks*) override { NOTREACHED(); } void getClients(const WebServiceWorkerClientQueryOptions&, WebServiceWorkerClientsCallbacks*) override { NOTREACHED(); } void openWindow(const WebURL&, WebServiceWorkerClientCallbacks*) override { NOTREACHED(); } @@ -40,6 +51,9 @@ void focus(const WebString& uuid, WebServiceWorkerClientCallbacks*) override { NOTREACHED(); } void navigate(const WebString& uuid, const WebURL&, WebServiceWorkerClientCallbacks*) override { NOTREACHED(); } void registerForeignFetchScopes(const WebVector<WebURL>& subScopes, const WebVector<WebSecurityOrigin>& origins) override { NOTREACHED(); } + +private: + bool m_hasAssociatedRegistration; }; class WebEmbeddedWorkerImplTest : public ::testing::Test { @@ -182,6 +196,32 @@ ::testing::Mock::VerifyAndClearExpectations(m_mockClient); } +TEST_F(WebEmbeddedWorkerImplTest, NoRegistration) +{ + EXPECT_CALL(*m_mockClient, workerReadyForInspection()) + .Times(1); + m_startData.pauseAfterDownloadMode = WebEmbeddedWorkerStartData::PauseAfterDownload; + m_worker->startWorkerContext(m_startData); + ::testing::Mock::VerifyAndClearExpectations(m_mockClient); + + // Load the shadow page. + EXPECT_CALL(*m_mockClient, createServiceWorkerNetworkProvider(::testing::_)) + .WillOnce(::testing::Return(nullptr)); + Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); + ::testing::Mock::VerifyAndClearExpectations(m_mockClient); + + // Load the script. + m_mockClient->setHasAssociatedRegistration(false); + EXPECT_CALL(*m_mockClient, workerScriptLoaded()) + .Times(0); + EXPECT_CALL(*m_mockClient, createServiceWorkerProvider()) + .Times(0); + EXPECT_CALL(*m_mockClient, workerContextFailedToStart()) + .Times(1); + Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); + ::testing::Mock::VerifyAndClearExpectations(m_mockClient); +} + // The running worker is detected as a memory leak. crbug.com/586897 #if defined(ADDRESS_SANITIZER) #define MAYBE_DontPauseAfterDownload DISABLED_DontPauseAfterDownload
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py b/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py index d281cf2..fbddf6a 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py
@@ -108,6 +108,13 @@ _CHECK_REPLACEMENT['EXPECT_FALSE_M'][op] = 'EXPECT_%s_M' % inv_replacement _CHECK_REPLACEMENT['ASSERT_FALSE_M'][op] = 'ASSERT_%s_M' % inv_replacement +_DEPRECATED_MACROS = [ + ['ASSERT', 'DCHECK or its variants'], + ['ASSERT_UNUSED', 'DCHECK or its variants'], + ['ASSERT_NOT_REACHED', 'NOTREACHED'], + ['ASSERT_WITH_SECURITY_IMPLICATION', 'SECURITY_DCHECK'], + ['WTF_LOG', 'DVLOG'] +] # These constants define types of headers for use with # _IncludeState.check_next_include_order(). @@ -2618,6 +2625,22 @@ break +def check_deprecated_macros(clean_lines, line_number, error): + """Checks the use of obsolete macros. + + Args: + clean_lines: A CleansedLines instance containing the file. + line_number: The number of the line to check. + error: The function to call with any errors found. + """ + + line = clean_lines.elided[line_number] + for pair in _DEPRECATED_MACROS: + if search(r'\b' + pair[0] + r'\(', line): + error(line_number, 'build/deprecated', 5, + '%s is deprecated. Use %s instead.' % (pair[0], pair[1])) + + def check_for_comparisons_to_boolean(clean_lines, line_number, error): # Get the line without comments and strings. line = clean_lines.elided[line_number] @@ -2974,6 +2997,7 @@ check_exit_statement_simplifications(clean_lines, line_number, error) check_spacing(file_extension, clean_lines, line_number, error) check_check(clean_lines, line_number, error) + check_deprecated_macros(clean_lines, line_number, error) check_for_comparisons_to_boolean(clean_lines, line_number, error) check_for_null(clean_lines, line_number, file_state, error) check_indentation_amount(clean_lines, line_number, error)
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py index b1d5a5756..d3b549f 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
@@ -1587,6 +1587,24 @@ self.assert_lint('CHECK_EQ("foo", "foo")', '') + def test_check_deprecated_macros(self): + self.assert_lint('ASSERT(foo)', 'ASSERT is deprecated. Use DCHECK or ' + 'its variants instead. [build/deprecated] [5]') + self.assert_lint(' ASSERT_UNUSED(foo, foo)', 'ASSERT_UNUSED is ' + 'deprecated. Use DCHECK or its variants instead. ' + '[build/deprecated] [5]') + self.assert_lint('ASSERT_NOT_REACHED()', 'ASSERT_NOT_REACHED is ' + 'deprecated. Use NOTREACHED instead. ' + '[build/deprecated] [5]') + self.assert_lint('ASSERT_WITH_SECURITY_IMPLICATION(foo)', + 'ASSERT_WITH_SECURITY_IMPLICATION is deprecated. Use ' + 'SECURITY_DCHECK instead. [build/deprecated] [5]') + self.assert_lint('WTF_LOG(foo)', 'WTF_LOG is deprecated. Use DVLOG ' + 'instead. [build/deprecated] [5]') + + self.assert_lint('FOO_BAR_ASSERT()', '') + self.assert_lint('ASSERT_NO_EXCEPTIONS', '') + def test_brace_at_begin_of_line(self): self.assert_lint('{', 'This { should be at the end of the previous line' @@ -3387,14 +3405,14 @@ 'More than one command on the same line [whitespace/newline] [4]') self.assert_multi_line_lint( 'class MyClass {\n' - ' int getIntValue() { ASSERT(m_ptr); return *m_ptr; }\n' + ' int getIntValue() { DCHECK(m_ptr); return *m_ptr; }\n' '};\n', '') self.assert_multi_line_lint( 'class MyClass {\n' ' int getIntValue()\n' ' {\n' - ' ASSERT(m_ptr); return *m_ptr;\n' + ' DCHECK(m_ptr); return *m_ptr;\n' ' }\n' '};\n', 'More than one command on the same line [whitespace/newline] [4]')
diff --git a/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h b/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h index 19ccccb..013e262 100644 --- a/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h +++ b/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextClient.h
@@ -69,6 +69,8 @@ // be started. Called on the main thread. virtual void workerScriptLoaded() { } + virtual bool hasAssociatedRegistration() { return false; } + // A new WorkerGlobalScope is created and started to run on the // worker thread. // This also gives back a proxy to the client to talk to the
diff --git a/tools/gn/command_gen.cc b/tools/gn/command_gen.cc index f872304b..7bdb6d8 100644 --- a/tools/gn/command_gen.cc +++ b/tools/gn/command_gen.cc
@@ -293,7 +293,7 @@ " --root-target=<target_name>\n" " Name of the root target for which the QtCreator project will be\n" " generated to contain files of it and its dependencies. If unset, \n" - " the whole build graph will be omitted.\n" + " the whole build graph will be emitted.\n" "\n" "\n" "Eclipse IDE Support\n"
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index 2378ce4..89c32d4e 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -40,6 +40,8 @@ 'Android GN Builder (dbg)': 'android_gn_debug_bot_minimal_symbols', 'Android MIPS Builder (dbg)': 'android_gn_debug_static_minimal_symbols_mipsel', + 'Android N5X Swarm Builder': + 'swarming_android_gn_release_bot_minimal_symbols_arm64', 'Android Swarm Builder': 'swarming_android_gn_release_bot_minimal_symbols', 'Android WebView CTS L-MR1 (dbg)': 'none', @@ -1450,6 +1452,10 @@ 'swarming', 'android', 'gn', 'release_bot_minimal_symbols', ], + 'swarming_android_gn_release_bot_minimal_symbols_arm64': [ + 'swarming', 'android', 'gn', 'release_bot_minimal_symbols', 'arm64', + ], + 'swarming_android_gn_release_trybot': [ 'swarming', 'android', 'gn', 'release_trybot', ],
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 9643bb8c..ce8198fc 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -72679,6 +72679,21 @@ <int value="1345" label="ProgressElementWithNoneAppearance"/> <int value="1346" label="ProgressElementWithProgressBarAppearance"/> <int value="1347" label="PointerEventAddListenerCount"/> + <int value="1348" label="EventCancelBubbleAffected"/> + <int value="1349" label="EventCancelBubbleWasChangedToTrue"/> + <int value="1350" label="EventCancelBubbleWasChangedToFalse"/> + <int value="1351" label="CSSValueAppearanceNone"/> + <int value="1352" label="CSSValueAppearanceNotNone"/> + <int value="1353" label="CSSValueAppearanceOthers"/> + <int value="1354" label="CSSValueAppearanceButton"/> + <int value="1355" label="CSSValueAppearanceCaret"/> + <int value="1356" label="CSSValueAppearanceCheckbox"/> + <int value="1357" label="CSSValueAppearanceMenulist"/> + <int value="1358" label="CSSValueAppearanceMenulistButton"/> + <int value="1359" label="CSSValueAppearanceListbox"/> + <int value="1360" label="CSSValueAppearanceRadio"/> + <int value="1361" label="CSSValueAppearanceSearchField"/> + <int value="1362" label="CSSValueAppearanceTextField"/> </enum> <enum name="FetchRequestMode" type="int">
diff --git a/ui/message_center/views/message_center_bubble.cc b/ui/message_center/views/message_center_bubble.cc index 93ae98a..62935c0c 100644 --- a/ui/message_center/views/message_center_bubble.cc +++ b/ui/message_center/views/message_center_bubble.cc
@@ -65,9 +65,7 @@ : MessageBubbleBase(message_center, tray), message_center_view_(NULL), initially_settings_visible_(false), - first_item_has_no_margin_(first_item_has_no_margin), - title_(l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_FOOTER_TITLE)) { -} + first_item_has_no_margin_(first_item_has_no_margin) {} MessageCenterBubble::~MessageCenterBubble() { } @@ -96,13 +94,9 @@ set_bubble_view(new_bubble_view); bubble_view()->GetWidget()->AddObserver(this); message_center_view_ = new MessageCenterView( - message_center(), - tray(), - max_height(), - initially_settings_visible_, - false, /* MessageCenterBubble should be used only on ChromeOS. - Message center is never shown top down in ChromeOS. */ - title_); + message_center(), tray(), max_height(), initially_settings_visible_, + false); /* MessageCenterBubble should be used only on ChromeOS. + Message center is never shown top down in ChromeOS. */ bubble_view()->AddChildView(new ContentsView(this, message_center_view_)); // Resize the content of the bubble view to the given bubble size. This is // necessary in case of the bubble border forcing a bigger size then the
diff --git a/ui/message_center/views/message_center_bubble.h b/ui/message_center/views/message_center_bubble.h index 05c435a..b7053aec 100644 --- a/ui/message_center/views/message_center_bubble.h +++ b/ui/message_center/views/message_center_bubble.h
@@ -55,8 +55,6 @@ // the used anchor. bool first_item_has_no_margin_; - base::string16 title_; - DISALLOW_COPY_AND_ASSIGN(MessageCenterBubble); };
diff --git a/ui/message_center/views/message_center_button_bar.cc b/ui/message_center/views/message_center_button_bar.cc index a92a5c4b..47613da 100644 --- a/ui/message_center/views/message_center_button_bar.cc +++ b/ui/message_center/views/message_center_button_bar.cc
@@ -278,6 +278,10 @@ Layout(); } +void MessageCenterButtonBar::SetTitle(const base::string16& title) { + notification_label_->SetText(title); +} + void MessageCenterButtonBar::ChildVisibilityChanged(views::View* child) { InvalidateLayout(); }
diff --git a/ui/message_center/views/message_center_button_bar.h b/ui/message_center/views/message_center_button_bar.h index e7932abd..3d74205 100644 --- a/ui/message_center/views/message_center_button_bar.h +++ b/ui/message_center/views/message_center_button_bar.h
@@ -49,6 +49,9 @@ // Sometimes we shouldn't see the back arrow (not in settings). void SetBackArrowVisible(bool visible); + // Update the label of the title. + void SetTitle(const base::string16& title); + private: // Updates the layout manager which can have differing configuration // depending on the visibility of different parts of the button bar.
diff --git a/ui/message_center/views/message_center_view.cc b/ui/message_center/views/message_center_view.cc index 3244188..47b7da85b 100644 --- a/ui/message_center/views/message_center_view.cc +++ b/ui/message_center/views/message_center_view.cc
@@ -111,8 +111,7 @@ MessageCenterTray* tray, int max_height, bool initially_settings_visible, - bool top_down, - const base::string16& title) + bool top_down) : message_center_(message_center), tray_(tray), scroller_(NULL), @@ -133,11 +132,9 @@ NotifierSettingsProvider* notifier_settings_provider = message_center_->GetNotifierSettingsProvider(); - button_bar_ = new MessageCenterButtonBar(this, - message_center, - notifier_settings_provider, - initially_settings_visible, - title); + button_bar_ = new MessageCenterButtonBar( + this, message_center, notifier_settings_provider, + initially_settings_visible, GetButtonBarTitle()); const int button_height = button_bar_->GetPreferredSize().height(); @@ -253,6 +250,7 @@ settings_transition_animation_->Start(); button_bar_->SetBackArrowVisible(visible); + button_bar_->SetTitle(GetButtonBarTitle()); } void MessageCenterView::ClearAllClosableNotifications() { @@ -601,6 +599,7 @@ } } button_bar_->SetCloseAllButtonEnabled(!no_closable_views); + button_bar_->SetTitle(GetButtonBarTitle()); if (no_message_views) { scroller_->SetFocusBehavior(FocusBehavior::NEVER); @@ -620,6 +619,14 @@ Layout(); } +base::string16 MessageCenterView::GetButtonBarTitle() const { + bool no_message_views = notification_views_.empty(); + if (no_message_views && !settings_visible_) + return l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NO_MESSAGES); + + return l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_FOOTER_TITLE); +} + void MessageCenterView::SetNotificationViewForTest(MessageView* view) { message_list_view_->AddNotificationAt(view, 0); }
diff --git a/ui/message_center/views/message_center_view.h b/ui/message_center/views/message_center_view.h index e609daf1..3783726 100644 --- a/ui/message_center/views/message_center_view.h +++ b/ui/message_center/views/message_center_view.h
@@ -44,8 +44,7 @@ MessageCenterTray* tray, int max_height, bool initially_settings_visible, - bool top_down, - const base::string16& title); + bool top_down); ~MessageCenterView() override; void SetNotifications(const NotificationList::Notifications& notifications); @@ -97,6 +96,7 @@ void AddNotificationAt(const Notification& notification, int index); void NotificationsChanged(); + base::string16 GetButtonBarTitle() const; void SetNotificationViewForTest(MessageView* view); MessageCenter* message_center_; // Weak reference.
diff --git a/ui/message_center/views/message_center_view_unittest.cc b/ui/message_center/views/message_center_view_unittest.cc index 10e01439..79b2d111 100644 --- a/ui/message_center/views/message_center_view_unittest.cc +++ b/ui/message_center/views/message_center_view_unittest.cc
@@ -198,9 +198,8 @@ message_center_->SetVisibleNotifications(notifications_); // Then create a new MessageCenterView with that single notification. - base::string16 title; message_center_view_.reset(new MessageCenterView( - message_center_.get(), NULL, 100, false, /*top_down =*/false, title)); + message_center_.get(), NULL, 100, false, /*top_down =*/false)); GetMessageListView()->quit_message_loop_after_animation_for_test_ = true; GetMessageCenterView()->SetBounds(0, 0, 380, 600); message_center_view_->SetNotifications(notifications_);
diff --git a/ui/ozone/platform/drm/gpu/gbm_buffer.cc b/ui/ozone/platform/drm/gpu/gbm_buffer.cc index 437ceab..4f5d7dd4 100644 --- a/ui/ozone/platform/drm/gpu/gbm_buffer.cc +++ b/ui/ozone/platform/drm/gpu/gbm_buffer.cc
@@ -30,11 +30,13 @@ gfx::BufferFormat format, gfx::BufferUsage usage, base::ScopedFD fd, + const gfx::Size& size, int stride) : GbmBufferBase(gbm, bo, format, usage), format_(format), usage_(usage), fd_(std::move(fd)), + size_(size), stride_(stride) {} GbmBuffer::~GbmBuffer() { @@ -50,6 +52,12 @@ return stride_; } +// TODO(reveman): This should not be needed once crbug.com/597932 is fixed, +// as the size would be queried directly from the underlying bo. +gfx::Size GbmBuffer::GetSize() const { + return size_; +} + // static scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer( const scoped_refptr<GbmDevice>& gbm, @@ -87,7 +95,7 @@ } scoped_refptr<GbmBuffer> buffer(new GbmBuffer( - gbm, bo, format, usage, std::move(fd), gbm_bo_get_stride(bo))); + gbm, bo, format, usage, std::move(fd), size, gbm_bo_get_stride(bo))); if (usage == gfx::BufferUsage::SCANOUT && !buffer->GetFramebufferId()) return nullptr; @@ -106,8 +114,9 @@ // TODO(reveman): Use gbm_bo_import after making buffers survive // GPU process crashes. crbug.com/597932 - return make_scoped_refptr(new GbmBuffer( - gbm, nullptr, format, gfx::BufferUsage::GPU_READ, std::move(fd), stride)); + return make_scoped_refptr(new GbmBuffer(gbm, nullptr, format, + gfx::BufferUsage::GPU_READ, + std::move(fd), size, stride)); } GbmPixmap::GbmPixmap(GbmSurfaceFactory* surface_manager,
diff --git a/ui/ozone/platform/drm/gpu/gbm_buffer.h b/ui/ozone/platform/drm/gpu/gbm_buffer.h index b62ccfcc..ed5175c9 100644 --- a/ui/ozone/platform/drm/gpu/gbm_buffer.h +++ b/ui/ozone/platform/drm/gpu/gbm_buffer.h
@@ -36,6 +36,7 @@ gfx::BufferUsage GetUsage() const { return usage_; } int GetFd() const; int GetStride() const; + gfx::Size GetSize() const override; private: GbmBuffer(const scoped_refptr<GbmDevice>& gbm, @@ -43,12 +44,14 @@ gfx::BufferFormat format, gfx::BufferUsage usage, base::ScopedFD fd, + const gfx::Size& size, int stride); ~GbmBuffer() override; gfx::BufferFormat format_; gfx::BufferUsage usage_; base::ScopedFD fd_; + gfx::Size size_; int stride_; DISALLOW_COPY_AND_ASSIGN(GbmBuffer);
diff --git a/ui/strings/ui_strings.grd b/ui/strings/ui_strings.grd index 5948744..4636be9 100644 --- a/ui/strings/ui_strings.grd +++ b/ui/strings/ui_strings.grd
@@ -633,7 +633,7 @@ </message> </if> <message name="IDS_MESSAGE_CENTER_NO_MESSAGES" desc="The message displayed in the message center when there are no notifications."> - Nothing to see here, move along. + You have no notifications </message> <message name="IDS_MESSAGE_CENTER_QUIET_MODE" desc="The button label for do not disturb mode."> Do not disturb
diff --git a/ui/webui/resources/cr_elements/icons.html b/ui/webui/resources/cr_elements/icons.html index 0f2ed59..f0e62a9b 100644 --- a/ui/webui/resources/cr_elements/icons.html +++ b/ui/webui/resources/cr_elements/icons.html
@@ -11,20 +11,25 @@ <!-- These icons are from iron-icons in third_party/polymer, but were curated here via the following URL and then sorted: - https://poly-icon.appspot.com/?name=cr&size=24&icon=icons:cancel&icon=icons:check&icon=icons:clear&icon=icons:expand-less&icon=icons:expand-more&icon=icons:extension&icon=icons:more-vert&icon=icons:search&icon=icons:settings&icon=icons:star&icon=icons:star-border&icon=social:domain&icon=social:group&icon=social:person + https://poly-icon.appspot.com/?name=cr&size=24&icon=icons:arrow-drop-down&icon=icons:cancel&icon=icons:check&icon=icons:chevron-right&icon=icons:clear&icon=icons:expand-less&icon=icons:expand-more&icon=icons:extension&icon=icons:file-download&icon=icons:fullscreen&icon=icons:more-vert&icon=icons:print&icon=icons:search&icon=icons:settings&icon=icons:star&icon=icons:star-border&icon=social:domain&icon=social:group&icon=social:person --> + <g id="arrow-drop-down"><path d="M7 10l5 5 5-5z"></path></g> <g id="cancel"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"></path></g> <if expr="chromeos"> <g id="check"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></g> </if> + <g id="chevron-right"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></g> <g id="clear"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></g> <g id="domain"><path d="M12 7V3H2v18h20V7H12zM6 19H4v-2h2v2zm0-4H4v-2h2v2zm0-4H4V9h2v2zm0-4H4V5h2v2zm4 12H8v-2h2v2zm0-4H8v-2h2v2zm0-4H8V9h2v2zm0-4H8V5h2v2zm10 12h-8v-2h2v-2h-2v-2h2v-2h-2V9h8v10zm-2-8h-2v2h2v-2zm0 4h-2v2h2v-2z"></path></g> <g id="expand-less"><path d="M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"></path></g> <g id="expand-more"><path d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"></path></g> <g id="extension"><path d="M20.5 11H19V7c0-1.1-.9-2-2-2h-4V3.5C13 2.12 11.88 1 10.5 1S8 2.12 8 3.5V5H4c-1.1 0-1.99.9-1.99 2v3.8H3.5c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-1.5c0-1.49 1.21-2.7 2.7-2.7 1.49 0 2.7 1.21 2.7 2.7V22H17c1.1 0 2-.9 2-2v-4h1.5c1.38 0 2.5-1.12 2.5-2.5S21.88 11 20.5 11z"></path></g> + <g id="file-download"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"></path></g> + <g id="fullscreen"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"></path></g> <g id="group"><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"></path></g> <g id="more-vert"><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path></g> <g id="person"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"></path></g> + <g id="print"><path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"></path></g> <g id="search"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path></g> <g id="settings"><path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"></path></g> <g id="star"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"></path></g>