diff --git a/DEPS b/DEPS index c374809c..b9da793 100644 --- a/DEPS +++ b/DEPS
@@ -39,11 +39,11 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': '5d04fda87747d82f4039cecf3e72b62ddf1ca76d', + 'skia_revision': 'c4ed68426649dd4ca2c3119cdafdd562d3c3ba28', # 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': 'a7c8a488faa5c22b465719632e8c78e700805f0d', + 'v8_revision': 'd93a2c276a84d4b46e6698b2fc0780c22b2d7585', # 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. @@ -96,7 +96,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling catapult # and whatever else without interference from each other. - 'catapult_revision': '924ec1f14b72847d11d3928f954c8c1f14e269a0', + 'catapult_revision': '2b8a913d1773ab2145bce5267c94580690cc7d17', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other. @@ -189,7 +189,7 @@ Var('chromium_git') + '/external/bidichecker/lib.git' + '@' + '97f2aa645b74c28c57eca56992235c79850fa9e0', 'src/third_party/webgl/src': - Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + 'a2415644f5d2afaeea15679b71feb1843e99b3bb', + Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + '3b5957b247eb4f0e4deed47eb4b7f1f6fdda252e', 'src/third_party/webdriver/pylib': Var('chromium_git') + '/external/selenium/py.git' + '@' + '5fd78261a75fe08d27ca4835fb6c5ce4b42275bd',
diff --git a/ash/host/ash_window_tree_host_unified.cc b/ash/host/ash_window_tree_host_unified.cc index ea96b99..7f6869b4 100644 --- a/ash/host/ash_window_tree_host_unified.cc +++ b/ash/host/ash_window_tree_host_unified.cc
@@ -15,7 +15,6 @@ #include "ui/aura/window_targeter.h" #include "ui/compositor/compositor.h" #include "ui/gfx/geometry/insets.h" -#include "ui/gfx/native_widget_types.h" #include "ui/platform_window/stub/stub_window.h" namespace ash { @@ -51,8 +50,7 @@ AshWindowTreeHostUnified::AshWindowTreeHostUnified( const gfx::Rect& initial_bounds) : AshWindowTreeHostPlatform() { - std::unique_ptr<ui::PlatformWindow> window( - new ui::StubWindow(this, gfx::kNullAcceleratedWidget)); + std::unique_ptr<ui::PlatformWindow> window(new ui::StubWindow(this)); window->SetBounds(initial_bounds); SetPlatformWindow(std::move(window)); }
diff --git a/ash/mus/sysui_application.cc b/ash/mus/sysui_application.cc index 037c67a0..a43fb159 100644 --- a/ash/mus/sysui_application.cc +++ b/ash/mus/sysui_application.cc
@@ -101,8 +101,7 @@ public: explicit AshWindowTreeHostMus(const gfx::Rect& initial_bounds) : AshWindowTreeHostPlatform() { - std::unique_ptr<ui::PlatformWindow> window( - new ui::StubWindow(this, gfx::kNullAcceleratedWidget)); + std::unique_ptr<ui::PlatformWindow> window(new ui::StubWindow(this)); window->SetBounds(initial_bounds); SetPlatformWindow(std::move(window)); }
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index 13f41a19..28b3392 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc
@@ -624,6 +624,9 @@ if (notification_bubble_) { notification_bubble_.reset(); UpdateNotificationBubble(); + // UpdateWebNotifications() should be called in UpdateNotificationBubble(). + } else if (!hide_notifications_) { + UpdateWebNotifications(); } }
diff --git a/base/i18n/number_formatting.cc b/base/i18n/number_formatting.cc index 6f454a08..b510833 100644 --- a/base/i18n/number_formatting.cc +++ b/base/i18n/number_formatting.cc
@@ -9,6 +9,7 @@ #include <memory> #include "base/format_macros.h" +#include "base/i18n/message_formatter.h" #include "base/lazy_instance.h" #include "base/logging.h" #include "base/strings/string_util.h" @@ -54,7 +55,7 @@ if (!number_format) { // As a fallback, just return the raw number in a string. - return UTF8ToUTF16(StringPrintf("%" PRId64, number)); + return ASCIIToUTF16(StringPrintf("%" PRId64, number)); } icu::UnicodeString ustr; number_format->format(number, ustr); @@ -68,7 +69,7 @@ if (!number_format) { // As a fallback, just return the raw number in a string. - return UTF8ToUTF16(StringPrintf("%f", number)); + return ASCIIToUTF16(StringPrintf("%f", number)); } number_format->setMaximumFractionDigits(fractional_digits); number_format->setMinimumFractionDigits(fractional_digits); @@ -78,6 +79,11 @@ return string16(ustr.getBuffer(), static_cast<size_t>(ustr.length())); } +string16 FormatPercent(int number) { + return i18n::MessageFormatter::FormatWithNumberedArgs( + ASCIIToUTF16("{0,number,percent}"), static_cast<double>(number) / 100.0); +} + namespace testing { void ResetFormatters() {
diff --git a/base/i18n/number_formatting.h b/base/i18n/number_formatting.h index bdb862f..9636bf4 100644 --- a/base/i18n/number_formatting.h +++ b/base/i18n/number_formatting.h
@@ -13,8 +13,7 @@ namespace base { // Return a number formatted with separators in the user's locale. -// Ex: FormatNumber(1234567) -// => "1,234,567" in English, "1.234.567" in German +// Ex: FormatNumber(1234567) => "1,234,567" in English, "1.234.567" in German BASE_I18N_EXPORT string16 FormatNumber(int64_t number); // Return a number formatted with separators in the user's locale. @@ -22,6 +21,10 @@ // => "1,234,567.8" in English, "1.234.567,8" in German BASE_I18N_EXPORT string16 FormatDouble(double number, int fractional_digits); +// Return a percentage formatted with space and symbol in the user's locale. +// Ex: FormatPercent(12) => "12%" in English, "12 %" in Romanian +BASE_I18N_EXPORT string16 FormatPercent(int number); + namespace testing { // Causes cached formatters to be discarded and recreated. Only useful for
diff --git a/base/i18n/number_formatting_unittest.cc b/base/i18n/number_formatting_unittest.cc index 31341ac..a131bf3 100644 --- a/base/i18n/number_formatting_unittest.cc +++ b/base/i18n/number_formatting_unittest.cc
@@ -94,5 +94,31 @@ } } +TEST(NumberFormattingTest, FormatPercent) { + static const struct { + int64_t number; + const char* expected_english; + const wchar_t* expected_german; // Note: Space before % isn't \x20. + const wchar_t* expected_persian; // Note: Non-Arabic numbers and %. + } cases[] = { + {0, "0%", L"0\xa0%", L"\x6f0\x200f\x66a"}, + {42, "42%", L"42\xa0%", L"\x6f4\x6f2\x200f\x66a"}, + {1024, "1,024%", L"1.024\xa0%", L"\x6f1\x66c\x6f0\x6f2\x6f4\x200f\x66a"}, + }; + + test::ScopedRestoreICUDefaultLocale restore_locale; + for (size_t i = 0; i < arraysize(cases); ++i) { + i18n::SetICUDefaultLocale("en"); + EXPECT_EQ(ASCIIToUTF16(cases[i].expected_english), + FormatPercent(cases[i].number)); + i18n::SetICUDefaultLocale("de"); + EXPECT_EQ(WideToUTF16(cases[i].expected_german), + FormatPercent(cases[i].number)); + i18n::SetICUDefaultLocale("fa"); + EXPECT_EQ(WideToUTF16(cases[i].expected_persian), + FormatPercent(cases[i].number)); + } +} + } // namespace } // namespace base
diff --git a/blimp/engine/app/ui/blimp_window_tree_host.cc b/blimp/engine/app/ui/blimp_window_tree_host.cc index a16d9c6..9c38d5dd 100644 --- a/blimp/engine/app/ui/blimp_window_tree_host.cc +++ b/blimp/engine/app/ui/blimp_window_tree_host.cc
@@ -5,15 +5,13 @@ #include "blimp/engine/app/ui/blimp_window_tree_host.h" #include "base/memory/ptr_util.h" -#include "ui/gfx/native_widget_types.h" #include "ui/platform_window/stub/stub_window.h" namespace blimp { namespace engine { BlimpWindowTreeHost::BlimpWindowTreeHost() : aura::WindowTreeHostPlatform() { - SetPlatformWindow(base::WrapUnique( - new ui::StubWindow(this, gfx::kNullAcceleratedWidget))); + SetPlatformWindow(base::WrapUnique(new ui::StubWindow(this))); } BlimpWindowTreeHost::~BlimpWindowTreeHost() {}
diff --git a/chrome/VERSION b/chrome/VERSION index 01d9340..89efe4ca 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=53 MINOR=0 -BUILD=2748 +BUILD=2749 PATCH=0
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java index d8f7a29..c4ef623 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticle.java
@@ -19,6 +19,7 @@ public final String mAmpUrl; public final String mThumbnailUrl; public final long mTimestamp; + public final float mScore; public final int mPosition; /** Bitmap of the thumbnail, fetched lazily, when the RecyclerView wants to show the snippet. */ @@ -33,10 +34,11 @@ * @param mAmpUrl the AMP url for the article (possible for this to be empty) * @param thumbnailUrl the URL of the thumbnail * @param timestamp the time in ms when this article was published + * @param score the score expressing relative quality of the article for the user * @param position the position of this article in the list of snippets */ public SnippetArticle(String id, String title, String publisher, String previewText, String url, - String ampUrl, String thumbnailUrl, long timestamp, int position) { + String ampUrl, String thumbnailUrl, long timestamp, float score, int position) { mId = id; mTitle = title; mPublisher = publisher; @@ -45,6 +47,7 @@ mAmpUrl = ampUrl; mThumbnailUrl = thumbnailUrl; mTimestamp = timestamp; + mScore = score; mPosition = position; }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java index 91ab350..317008d7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
@@ -39,6 +39,7 @@ private static final String TAG = "NtpSnippets"; private static final String PUBLISHER_FORMAT_STRING = "%s - %s"; private static final int FADE_IN_ANIMATION_TIME_MS = 300; + private static final int[] HISTOGRAM_FOR_POSITIONS = {0, 2, 4, 9}; private final NewTabPageManager mNewTabPageManager; private final TextView mHeadlineTextView; @@ -47,6 +48,8 @@ private final ImageView mThumbnailView; private FetchImageCallback mImageCallback; + private long mPublishTimestampMilliseconds; + private float mScore; public String mUrl; public int mPosition; @@ -96,6 +99,22 @@ RecordHistogram.recordSparseSlowlyHistogram("NewTabPage.Snippets.CardClicked", mPosition); NewTabPageUma.recordSnippetAction(NewTabPageUma.SNIPPETS_ACTION_CLICKED); NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_SNIPPET); + + // Track how the (approx.) position relates to age / score of the snippet that is clicked. + int ageInMinutes = + (int) ((System.currentTimeMillis() - mPublishTimestampMilliseconds) / 60000L); + recordAge("NewTabPage.Snippets.CardClickedAge", ageInMinutes); + recordScore("NewTabPage.Snippets.CardClickedScore", mScore); + int startPosition = 0; + for (int endPosition : HISTOGRAM_FOR_POSITIONS) { + if (mPosition >= startPosition && mPosition <= endPosition) { + String suffix = "_" + startPosition + "_" + endPosition; + recordAge("NewTabPage.Snippets.CardClickedAge" + suffix, ageInMinutes); + recordScore("NewTabPage.Snippets.CardClickedScore" + suffix, mScore); + break; + } + startPosition = endPosition + 1; + } } @Override @@ -110,6 +129,8 @@ mArticleSnippetTextView.setText(item.mPreviewText); mUrl = item.mUrl; mPosition = item.mPosition; + mPublishTimestampMilliseconds = item.mTimestamp; + mScore = item.mScore; // If there's still a pending thumbnail fetch, cancel it. cancelImageFetch(); @@ -147,6 +168,20 @@ } } + private static void recordAge(String histogramName, int ageInMinutes) { + // Negative values (when the time of the device is set inappropriately) provide no value. + if (ageInMinutes >= 0) { + // If the max value below (72 hours) were to be changed, the histogram should be renamed + // since it will change the shape of buckets. + RecordHistogram.recordCustomCountHistogram(histogramName, ageInMinutes, 0, 72 * 60, 50); + } + } + + private static void recordScore(String histogramName, float score) { + int recordedScore = Math.min((int) Math.ceil(score), 1000); + RecordHistogram.recordCount1000Histogram(histogramName, recordedScore); + } + private void cancelImageFetch() { if (mImageCallback != null) { mImageCallback.cancel();
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java index a712773..eb8dc31 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java
@@ -111,7 +111,8 @@ @CalledByNative private void onSnippetsAvailable(String[] ids, String[] titles, String[] urls, String[] ampUrls, - String[] thumbnailUrls, String[] previewText, long[] timestamps, String[] publishers) { + String[] thumbnailUrls, String[] previewText, long[] timestamps, String[] publishers, + float[] scores) { // Don't notify observer if we've already been destroyed. if (mNativeSnippetsBridge == 0) return; assert mObserver != null; @@ -119,7 +120,7 @@ List<SnippetArticle> newSnippets = new ArrayList<>(ids.length); for (int i = 0; i < ids.length; i++) { newSnippets.add(new SnippetArticle(ids[i], titles[i], publishers[i], previewText[i], - urls[i], ampUrls[i], thumbnailUrls[i], timestamps[i], i)); + urls[i], ampUrls[i], thumbnailUrls[i], timestamps[i], scores[i], i)); } mObserver.onSnippetsReceived(newSnippets);
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java index 0f068f8..201de20 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java
@@ -75,7 +75,7 @@ // The adapter should ignore any new incoming data. mSnippetsObserver.onSnippetsReceived(Arrays.asList(new SnippetArticle[] { - new SnippetArticle("foo", "title1", "pub1", "txt1", "foo", "bar", null, 0, 0)})); + new SnippetArticle("foo", "title1", "pub1", "txt1", "foo", "bar", null, 0, 0, 0)})); assertEquals(loadedItems, ntpa.getItemsForTesting()); } @@ -106,7 +106,7 @@ // The adapter should ignore any new incoming data. mSnippetsObserver.onSnippetsReceived(Arrays.asList(new SnippetArticle[] { - new SnippetArticle("foo", "title1", "pub1", "txt1", "foo", "bar", null, 0, 0)})); + new SnippetArticle("foo", "title1", "pub1", "txt1", "foo", "bar", null, 0, 0, 0)})); assertEquals(loadedItems, ntpa.getItemsForTesting()); } @@ -136,10 +136,10 @@ private List<SnippetArticle> createDummySnippets() { return Arrays.asList(new SnippetArticle[] { new SnippetArticle("https://site.com/url1", "title1", "pub1", "txt1", - "https://site.com/url1", "https://amp.site.com/url1", null, 0, 0), + "https://site.com/url1", "https://amp.site.com/url1", null, 0, 0, 0), new SnippetArticle("https://site.com/url2", "title2", "pub2", "txt2", - "https://site.com/url2", "https://amp.site.com/url1", null, 0, 0), + "https://site.com/url2", "https://amp.site.com/url1", null, 0, 0, 0), new SnippetArticle("https://site.com/url3", "title3", "pub3", "txt3", - "https://site.com/url3", "https://amp.site.com/url1", null, 0, 0)}); + "https://site.com/url3", "https://amp.site.com/url1", null, 0, 0, 0)}); } }
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index 1d78c2b..a81aaec22 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp
@@ -445,8 +445,20 @@ <message name="IDS_FILE_BROWSER_CUT_BUTTON_LABEL" desc="Button Label."> Cut </message> - <message name="IDS_FILE_BROWSER_OPEN_WITH_BUTTON_LABEL" desc="Menu item label, showing dialog to choose application to open selected files."> - Open with... + <message name="IDS_FILE_BROWSER_MORE_ACTIONS_BUTTON_LABEL" desc="Menu item label, showing dialog to choose extension to open selected files or directories."> + More actions... + </message> + <message name="IDS_FILE_BROWSER_OPEN_WITH_VERB_BUTTON_LABEL" desc="Verb that describe the action of opening one or more files or directories with the given extension."> + Open with <ph name="EXTENSION_NAME">$1<ex>Gallery</ex></ph> + </message> + <message name="IDS_FILE_BROWSER_ADD_TO_VERB_BUTTON_LABEL" desc="Verb that describes the uploading or addition of one or multiple files or directories to the given extension."> + Add to <ph name="EXTENSION_NAME">$1<ex>Evernote</ex></ph> + </message> + <message name="IDS_FILE_BROWSER_PACK_WITH_VERB_BUTTON_LABEL" desc="Verb that describes the packing or archiving of one or multiple files or directories with the given extension."> + Pack with <ph name="EXTENSION_NAME">$1<ex>ZIP</ex></ph> + </message> + <message name="IDS_FILE_BROWSER_SHARE_WITH_VERB_BUTTON_LABEL" desc="Verb that describes the action of sharing/attaching/sending files with the given application."> + Share with <ph name="EXTENSION_NAME">$1<ex>GMail</ex></ph> </message> <message name="IDS_FILE_BROWSER_ZIP_SELECTION_BUTTON_LABEL" desc="Menu item label, showing dialog to create zip file for selected files."> Zip selection @@ -460,9 +472,6 @@ <message name="IDS_FILE_BROWSER_SHARE_BUTTON_LABEL" desc="Menu item label, showing dialog to share the selected file."> Share </message> - <message name="IDS_FILE_BROWSER_SHARE_WITH_ACTION_LABEL" desc="Menu item label, describing the action of sharing/attaching/sending files with the given application."> - Share with <ph name="APPLICATION_NAME">$1<ex>GMail</ex></ph> - </message> <message name="IDS_FILE_BROWSER_TOGGLE_HIDDEN_FILES_COMMAND_LABEL" desc="Label for menu or button with checkmark that toggles visibility of hidden files."> Show hidden files </message>
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 3807b222..5e3c53d 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd
@@ -1075,9 +1075,6 @@ <message name="IDS_ZOOM_MINUS2" desc="The text label of the Make Text Smaller menu item in the merged menu"> − </message> - <message name="IDS_ZOOM_PERCENT" desc="Current pages zoom factor; shown in merged menu"> - <ph name="VALUE">$1<ex>100</ex></ph>% - </message> <message name="IDS_ENCODING_MENU" desc="The text label of the Encoding submenu"> &Encoding </message> @@ -1149,9 +1146,6 @@ <message name="IDS_ZOOM_MINUS2" desc="The text label of the Make Text Smaller menu item in the merged menu"> − </message> - <message name="IDS_ZOOM_PERCENT" desc="Current pages zoom factor; shown in merged menu"> - <ph name="VALUE">$1<ex>100</ex></ph>% - </message> <message name="IDS_ENCODING_MENU" desc="In Title Case: The text label of the Encoding submenu"> &Encoding </message> @@ -5227,6 +5221,21 @@ <message name="IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION" desc="Description of the 'Save Page as MHTML' lab."> Enables saving pages as MHTML: a single text file containing HTML and all sub-resources. </message> + + <!-- Flag and values for MHTML Geenrator options lab. --> + <message name="IDS_FLAGS_MHTML_GENERATOR_OPTION_NAME" desc="Name of the 'MHTML Generator Options' lab."> + MHTML Generation Option + </message> + <message name="IDS_FLAGS_MHTML_GENERATOR_OPTION_DESCRIPTION" desc="Description of the 'MHTML Generator Options' lab."> + Provides experimental options for MHTML file generator. + </message> + <message name="IDS_FLAGS_MHTML_SKIP_NOSTORE_MAIN"> + Skips no-store main frame. + </message> + <message name="IDS_FLAGS_MHTML_SKIP_NOSTORE_ALL"> + Skips all no-store resources. + </message> + <message name="IDS_FLAGS_DEVICE_DISCOVERY_NOTIFICATIONS_NAME" desc="Title of the 'device discovery notificatios' flag."> Device Discovery Notifications </message> @@ -6423,6 +6432,12 @@ <message name="IDS_FLAGS_APPS_SHOW_ON_FIRST_PAINT_DESCRIPTION" desc="Description of flag to enable show-on-first-paint for apps."> Show apps windows after the first paint. Windows will be shown significantly later for heavy apps loading resources synchronously but it will be insignificant for apps that load most of their resources asynchronously. </message> + <message name="IDS_FLAGS_PERMISSION_ACTION_REPORTING_NAME" desc="Title for the flag to enable permission action reporting to safe browsing servers."> + Permission Action Reporting + </message> + <message name="IDS_FLAGS_PERMISSION_ACTION_REPORTING_DESCRIPTION" desc="Description for the flag to enable permission action reporting to safe browsing servers"> + Enables permission action reporting to Safe Browsing servers for opted in users. + </message> <message name="IDS_FLAGS_PERMISSIONS_BLACKLIST_NAME" desc="Title for the flag to enable the permissions blacklist."> Permissions Blacklist </message> @@ -7199,7 +7214,7 @@ Translate this page </message> <message name="IDS_TOOLTIP_ZOOM" desc="The tooltip for the zoom bubble"> - Zoom: <ph name="VALUE">$1<ex>100</ex></ph>% + Zoom: <ph name="PERCENT">$1<ex>100%</ex></ph> </message> <message name="IDS_TOOLTIP_ZOOM_EXTENSION_ICON" desc="The tooltip for the extension icon in the zoom bubble"> This page was zoomed by the "<ph name="NAME">$1<ex>Google Cast</ex></ph>" extension
diff --git a/chrome/browser/OWNERS b/chrome/browser/OWNERS index 73d4716b..2e1aa012 100644 --- a/chrome/browser/OWNERS +++ b/chrome/browser/OWNERS
@@ -10,10 +10,10 @@ per-file browser_resources.grd=pam@chromium.org per-file browser_resources.grd=xiyuan@chromium.org +per-file browser_close_manager_browsertest.cc=creis@chromium.org + per-file browser_navigator_browsertest.*=alexmos@chromium.org -per-file browser_navigator_browsertest.*=creis@chromium.org -per-file browser_navigator_browsertest.*=nasko@chromium.org -per-file browser_navigator_browsertest.*=nick@chromium.org +per-file browser_navigator_browsertest.*=file://content/OWNERS per-file chrome_content_browser_client.cc=* per-file chrome_content_browser_client.h=* @@ -29,9 +29,13 @@ per-file chrome_elf_init_*=robertshield@chromium.org per-file chrome_navigation_browsertest.cc=alexmos@chromium.org -per-file chrome_navigation_browsertest.cc=creis@chromium.org -per-file chrome_navigation_browsertest.cc=nasko@chromium.org -per-file chrome_navigation_browsertest.cc=nick@chromium.org +per-file chrome_navigation_browsertest.cc=file://content/OWNERS + +per-file chrome_security_exploit_browsertest.cc=alexmos@chromium.org +per-file chrome_security_exploit_browsertest.cc=file://content/OWNERS + +per-file chrome_site_per_process_browsertest.cc=alexmos@chromium.org +per-file chrome_site_per_process_browsertest.cc=file://content/OWNERS per-file chrome_webusb_browser_client*=juncai@chromium.org per-file chrome_webusb_browser_client*=reillyg@chromium.org @@ -62,14 +66,18 @@ per-file shell_integration_win*=grt@chromium.org per-file shell_integration_linux*=erg@chromium.org +per-file site_details*=creis@chromium.org +per-file site_details*=nasko@chromium.org +per-file site_details*=nick@chromium.org + per-file site_per_process_interactive_browsertest.cc=alexmos@chromium.org -per-file site_per_process_interactive_browsertest.cc=creis@chromium.org -per-file site_per_process_interactive_browsertest.cc=nasko@chromium.org -per-file site_per_process_interactive_browsertest.cc=nick@chromium.org +per-file site_per_process_interactive_browsertest.cc=file://content/OWNERS per-file PRESUBMIT.py=dbeam@chromium.org per-file test_presubmit.py=dbeam@chromium.org +per-file unload_browsertest.cc=file://content/OWNERS + per-file web_bluetooth*=jyasskin@chromium.org per-file web_bluetooth*=ortuno@chromium.org per-file web_bluetooth*=scheib@chromium.org
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 559b960..180fcdc 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc
@@ -305,6 +305,14 @@ switches::kGpuRasterizationMSAASampleCount, "16" }, }; +const FeatureEntry::Choice kMHTMLGeneratorOptionChoices[] = { + { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, + { IDS_FLAGS_MHTML_SKIP_NOSTORE_MAIN, + switches::kMHTMLGeneratorOption, switches::kMHTMLSkipNostoreMain }, + { IDS_FLAGS_MHTML_SKIP_NOSTORE_ALL, + switches::kMHTMLGeneratorOption, switches::kMHTMLSkipNostoreAll }, +}; + const FeatureEntry::Choice kEnableGpuRasterizationChoices[] = { { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, @@ -690,6 +698,10 @@ IDS_FLAGS_SAVE_PAGE_AS_MHTML_NAME, IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION, kOsMac | kOsWin | kOsLinux, SINGLE_VALUE_TYPE(switches::kSavePageAsMHTML)}, + {"mhtml-generator-option", + IDS_FLAGS_MHTML_GENERATOR_OPTION_NAME, + IDS_FLAGS_MHTML_GENERATOR_OPTION_DESCRIPTION, kOsMac | kOsWin | kOsLinux, + MULTI_VALUE_TYPE(kMHTMLGeneratorOptionChoices)}, {"enable-quic", IDS_FLAGS_QUIC_NAME, IDS_FLAGS_QUIC_DESCRIPTION, kOsAll, ENABLE_DISABLE_VALUE_TYPE(switches::kEnableQuic, switches::kDisableQuic)}, {"enable-alternative-services", IDS_FLAGS_ALTSVC_NAME, @@ -1249,6 +1261,11 @@ {"num-raster-threads", IDS_FLAGS_NUM_RASTER_THREADS_NAME, IDS_FLAGS_NUM_RASTER_THREADS_DESCRIPTION, kOsAll, MULTI_VALUE_TYPE(kNumRasterThreadsChoices)}, + {"enable-permission-action-reporting", + IDS_FLAGS_PERMISSION_ACTION_REPORTING_NAME, + IDS_FLAGS_PERMISSION_ACTION_REPORTING_DESCRIPTION, kOsAll, + ENABLE_DISABLE_VALUE_TYPE(switches::kEnablePermissionActionReporting, + switches::kDisablePermissionActionReporting)}, {"enable-permissions-blacklist", IDS_FLAGS_PERMISSIONS_BLACKLIST_NAME, IDS_FLAGS_PERMISSIONS_BLACKLIST_DESCRIPTION, kOsAll, ENABLE_DISABLE_VALUE_TYPE(switches::kEnablePermissionsBlacklist,
diff --git a/chrome/browser/android/ntp/most_visited_sites.cc b/chrome/browser/android/ntp/most_visited_sites.cc index 372090f..2cff04d 100644 --- a/chrome/browser/android/ntp/most_visited_sites.cc +++ b/chrome/browser/android/ntp/most_visited_sites.cc
@@ -257,39 +257,47 @@ const ThumbnailCallback& callback, std::unique_ptr<SkBitmap> bitmap) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - if (!bitmap.get()) { - // A thumbnail is not locally available for |url|. Make sure it is put in - // the list to be fetched at the next visit to this site. - if (top_sites_) - top_sites_->AddForcedURL(url, base::Time::Now()); - // Also fetch a remote thumbnail if possible. PopularSites or the - // SuggestionsService can supply a thumbnail download URL. - if (popular_sites_) { - const std::vector<PopularSites::Site>& sites = popular_sites_->sites(); - auto it = std::find_if( - sites.begin(), sites.end(), - [&url](const PopularSites::Site& site) { return site.url == url; }); - if (it != sites.end() && it->thumbnail_url.is_valid()) { - return suggestions_service_->GetPageThumbnailWithURL( - url, it->thumbnail_url, - base::Bind(&MostVisitedSites::OnObtainedThumbnail, - weak_ptr_factory_.GetWeakPtr(), false, callback)); - } - } - if (mv_source_ == SUGGESTIONS_SERVICE) { - return suggestions_service_->GetPageThumbnail( - url, base::Bind(&MostVisitedSites::OnObtainedThumbnail, - weak_ptr_factory_.GetWeakPtr(), false, callback)); + if (bitmap.get()) { + callback.Run(true /* is_local_thumbnail */, bitmap.get()); + return; + } + + // A thumbnail is not locally available for |url|. Make sure it is put in + // the list to be fetched at the next visit to this site. + if (top_sites_) + top_sites_->AddForcedURL(url, base::Time::Now()); + // Also fetch a remote thumbnail if possible. PopularSites or the + // SuggestionsService can supply a thumbnail download URL. + if (popular_sites_) { + const std::vector<PopularSites::Site>& sites = popular_sites_->sites(); + auto it = std::find_if( + sites.begin(), sites.end(), + [&url](const PopularSites::Site& site) { return site.url == url; }); + if (it != sites.end() && it->thumbnail_url.is_valid()) { + return suggestions_service_->GetPageThumbnailWithURL( + url, it->thumbnail_url, + base::Bind(&MostVisitedSites::OnObtainedThumbnail, + weak_ptr_factory_.GetWeakPtr(), false, callback)); } } - OnObtainedThumbnail(true, callback, url, bitmap.get()); + if (mv_source_ == SUGGESTIONS_SERVICE) { + return suggestions_service_->GetPageThumbnail( + url, base::Bind(&MostVisitedSites::OnObtainedThumbnail, + weak_ptr_factory_.GetWeakPtr(), false, callback)); + } + // If no bitmap could be fetched and neither PopularSites nor the + // SuggestionsService is available then a nullptr is passed to the callback. + callback.Run(true /* is_local_thumbnail */, nullptr); } void MostVisitedSites::OnObtainedThumbnail(bool is_local_thumbnail, const ThumbnailCallback& callback, const GURL& url, - const SkBitmap* bitmap) { + const gfx::Image& image) { DCHECK_CURRENTLY_ON(BrowserThread::UI); + const SkBitmap* bitmap = nullptr; + if (!image.IsEmpty()) + bitmap = image.ToSkBitmap(); callback.Run(is_local_thumbnail, bitmap); }
diff --git a/chrome/browser/android/ntp/most_visited_sites.h b/chrome/browser/android/ntp/most_visited_sites.h index 14b3e636..d6bdb12 100644 --- a/chrome/browser/android/ntp/most_visited_sites.h +++ b/chrome/browser/android/ntp/most_visited_sites.h
@@ -23,6 +23,10 @@ #include "components/suggestions/suggestions_service.h" #include "url/gurl.h" +namespace gfx { +class Image; +} + namespace history { class TopSites; } @@ -220,7 +224,7 @@ bool is_local_thumbnail, const ThumbnailCallback& callback, const GURL& url, - const SkBitmap* bitmap); + const gfx::Image& bitmap); // Records thumbnail-related UMA histogram metrics. void RecordThumbnailUMAMetrics();
diff --git a/chrome/browser/android/ntp/ntp_snippets_bridge.cc b/chrome/browser/android/ntp/ntp_snippets_bridge.cc index 5e9e257a..6f006fd8 100644 --- a/chrome/browser/android/ntp/ntp_snippets_bridge.cc +++ b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
@@ -28,6 +28,7 @@ using base::android::JavaParamRef; using base::android::ToJavaArrayOfStrings; using base::android::ToJavaLongArray; +using base::android::ToJavaFloatArray; using base::android::ScopedJavaGlobalRef; using base::android::ScopedJavaLocalRef; @@ -135,6 +136,7 @@ std::vector<std::string> snippets; std::vector<int64_t> timestamps; std::vector<std::string> publishers; + std::vector<float> scores; for (const std::unique_ptr<ntp_snippets::NTPSnippet>& snippet : ntp_snippets_service_->snippets()) { ids.push_back(snippet->id()); @@ -147,6 +149,7 @@ snippets.push_back(snippet->snippet()); timestamps.push_back(snippet->publish_date().ToJavaTime()); publishers.push_back(snippet->best_source().publisher_name); + scores.push_back(snippet->score()); } JNIEnv* env = base::android::AttachCurrentThread(); @@ -158,7 +161,8 @@ ToJavaArrayOfStrings(env, thumbnail_urls).obj(), ToJavaArrayOfStrings(env, snippets).obj(), ToJavaLongArray(env, timestamps).obj(), - ToJavaArrayOfStrings(env, publishers).obj()); + ToJavaArrayOfStrings(env, publishers).obj(), + ToJavaFloatArray(env, scores).obj()); } void NTPSnippetsBridge::NTPSnippetsServiceShutdown() {
diff --git a/chrome/browser/chromeos/display/display_preferences.h b/chrome/browser/chromeos/display/display_preferences.h index 538b020..f17cb10 100644 --- a/chrome/browser/chromeos/display/display_preferences.h +++ b/chrome/browser/chromeos/display/display_preferences.h
@@ -13,7 +13,6 @@ class PrefRegistrySimple; namespace gfx { -class Display; class Insets; }
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc index 3a42508..8db17b7 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_strings.cc
@@ -519,7 +519,16 @@ SET_STRING("OPEN_IN_OTHER_DESKTOP_MESSAGE_PLURAL", IDS_FILE_BROWSER_OPEN_IN_OTHER_DESKTOP_MESSAGE_PLURAL); SET_STRING("OPEN_LABEL", IDS_FILE_BROWSER_OPEN_LABEL); - SET_STRING("OPEN_WITH_BUTTON_LABEL", IDS_FILE_BROWSER_OPEN_WITH_BUTTON_LABEL); + SET_STRING("MORE_ACTIONS_BUTTON_LABEL", + IDS_FILE_BROWSER_MORE_ACTIONS_BUTTON_LABEL); + SET_STRING("OPEN_WITH_VERB_BUTTON_LABEL", + IDS_FILE_BROWSER_OPEN_WITH_VERB_BUTTON_LABEL); + SET_STRING("ADD_TO_VERB_BUTTON_LABEL", + IDS_FILE_BROWSER_ADD_TO_VERB_BUTTON_LABEL); + SET_STRING("PACK_WITH_VERB_BUTTON_LABEL", + IDS_FILE_BROWSER_PACK_WITH_VERB_BUTTON_LABEL); + SET_STRING("SHARE_WITH_VERB_BUTTON_LABEL", + IDS_FILE_BROWSER_SHARE_WITH_VERB_BUTTON_LABEL); SET_STRING("PASTE_BUTTON_LABEL", IDS_FILE_BROWSER_PASTE_BUTTON_LABEL); SET_STRING("PASTE_INTO_FOLDER_BUTTON_LABEL", IDS_FILE_BROWSER_PASTE_INTO_FOLDER_BUTTON_LABEL);
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_tasks.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_tasks.cc index ec5c7fc..e84f0693 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_tasks.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_tasks.cc
@@ -205,6 +205,7 @@ if (!task.icon_url().is_empty()) converted.icon_url = task.icon_url().spec(); converted.title = task.task_title(); + converted.verb = task.task_verb(); converted.is_default = task.is_default(); converted.is_generic_file_handler = task.is_generic_file_handler(); results.push_back(std::move(converted));
diff --git a/chrome/browser/chromeos/file_manager/arc_file_tasks.cc b/chrome/browser/chromeos/file_manager/arc_file_tasks.cc index 7bae42d3..e04a552 100644 --- a/chrome/browser/chromeos/file_manager/arc_file_tasks.cc +++ b/chrome/browser/chromeos/file_manager/arc_file_tasks.cc
@@ -8,22 +8,26 @@ #include <string> #include <vector> +#include "base/base64.h" #include "base/bind.h" #include "base/files/file_path.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" +#include "base/threading/thread_restrictions.h" #include "chrome/browser/chromeos/file_manager/path_util.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/common/extensions/api/file_manager_private.h" #include "chrome/grit/generated_resources.h" #include "components/arc/arc_bridge_service.h" +#include "components/arc/arc_service_manager.h" #include "components/arc/common/intent_helper.mojom.h" +#include "components/arc/intent_helper/activity_icon_loader.h" #include "components/user_manager/user_manager.h" +#include "content/public/browser/browser_thread.h" #include "extensions/browser/entry_info.h" #include "mojo/public/cpp/bindings/binding.h" #include "net/base/filename_util.h" #include "storage/browser/fileapi/file_system_url.h" -#include "ui/base/l10n/l10n_util.h" #include "url/gurl.h" namespace file_manager { @@ -37,11 +41,14 @@ constexpr base::FilePath::CharType kArcDownloadPath[] = FILE_PATH_LITERAL("/sdcard/Download"); constexpr char kAppIdSeparator = '/'; +constexpr char kPngDataUrlPrefix[] = "data:image/png;base64,"; // Returns the Mojo interface for ARC Intent Helper, with version |minVersion| // or above. If the ARC bridge is not established, returns null. arc::mojom::IntentHelperInstance* GetArcIntentHelper(Profile* profile, int min_version) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + // File manager in secondary profile cannot access ARC. if (!chromeos::ProfileHelper::IsPrimaryProfile(profile)) return nullptr; @@ -62,6 +69,16 @@ return intent_helper_instance; } +// Returns the icon loader that wraps the Mojo interface for ARC Intent Helper. +scoped_refptr<arc::ActivityIconLoader> GetArcActivityIconLoader() { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + + arc::ArcServiceManager* arc_service_manager = arc::ArcServiceManager::Get(); + if (!arc_service_manager) + return nullptr; + return arc_service_manager->icon_loader(); +} + std::string ArcActionToString(arc::mojom::ActionType action) { switch (action) { case arc::mojom::ActionType::VIEW: @@ -107,6 +124,8 @@ // Converts the Chrome OS file path to ARC file URL. bool ConvertToArcUrl(const base::FilePath& path, GURL* arc_url) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + // Obtain the primary profile. This information is required because currently // only the file systems for the primary profile is exposed to ARC. if (!user_manager::UserManager::IsInitialized()) @@ -133,27 +152,112 @@ return false; } +// Below is the sequence of thread-hopping for loading ARC file tasks. +void OnArcHandlerList( + std::unique_ptr<std::vector<FullTaskDescriptor>> result_list, + const FindTasksCallback& callback, + mojo::Array<arc::mojom::UrlHandlerInfoPtr> handlers); + +void OnArcIconLoaded( + std::unique_ptr<std::vector<FullTaskDescriptor>> result_list, + const FindTasksCallback& callback, + mojo::Array<arc::mojom::UrlHandlerInfoPtr> handlers, + std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons); + +typedef std::map<arc::ActivityIconLoader::ActivityName, GURL> IconUrlMap; + +std::unique_ptr<IconUrlMap> EncodeIconsToDataURLs( + std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons); + +void OnArcIconEncoded( + std::unique_ptr<std::vector<FullTaskDescriptor>> result_list, + const FindTasksCallback& callback, + mojo::Array<arc::mojom::UrlHandlerInfoPtr> handlers, + std::unique_ptr<IconUrlMap> icons); + +// Called after the handlers from ARC is obtained. Proceeds to OnArcIconLoaded. void OnArcHandlerList( std::unique_ptr<std::vector<FullTaskDescriptor>> result_list, const FindTasksCallback& callback, mojo::Array<arc::mojom::UrlHandlerInfoPtr> handlers) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + + scoped_refptr<arc::ActivityIconLoader> icon_loader = + GetArcActivityIconLoader(); + if (!icon_loader) { + callback.Run(std::move(result_list)); + return; + } + + std::vector<arc::ActivityIconLoader::ActivityName> activity_names; + for (const arc::mojom::UrlHandlerInfoPtr& handler : handlers) + activity_names.emplace_back(handler->package_name, handler->activity_name); + + icon_loader->GetActivityIcons( + activity_names, base::Bind(&OnArcIconLoaded, base::Passed(&result_list), + callback, base::Passed(&handlers))); +} + +// Called after icon data for ARC apps are loaded. Proceeds to OnArcIconEncoded. +void OnArcIconLoaded( + std::unique_ptr<std::vector<FullTaskDescriptor>> result_list, + const FindTasksCallback& callback, + mojo::Array<arc::mojom::UrlHandlerInfoPtr> handlers, + std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + + base::PostTaskAndReplyWithResult( + content::BrowserThread::GetBlockingPool(), FROM_HERE, + base::Bind(&EncodeIconsToDataURLs, base::Passed(&icons)), + base::Bind(&OnArcIconEncoded, base::Passed(&result_list), callback, + base::Passed(&handlers))); +} + +// Encode the set of icon images to data URLs. +std::unique_ptr<IconUrlMap> EncodeIconsToDataURLs( + std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons) { + base::ThreadRestrictions::AssertIOAllowed(); + + std::unique_ptr<IconUrlMap> result(new IconUrlMap); + for (const auto& entry : *icons) { + scoped_refptr<base::RefCountedMemory> img = + entry.second.icon16.As1xPNGBytes(); + if (!img) + continue; + + std::string encoded; + base::Base64Encode(base::StringPiece(img->front_as<char>(), img->size()), + &encoded); + result->insert( + std::make_pair(entry.first, GURL(kPngDataUrlPrefix + encoded))); + } + return result; +} + +// Called after icon data is encoded on the blocking pool. +void OnArcIconEncoded( + std::unique_ptr<std::vector<FullTaskDescriptor>> result_list, + const FindTasksCallback& callback, + mojo::Array<arc::mojom::UrlHandlerInfoPtr> handlers, + std::unique_ptr<IconUrlMap> icons) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + + using extensions::api::file_manager_private::Verb; for (const arc::mojom::UrlHandlerInfoPtr& handler : handlers) { - // TODO(crbug.com/578725): Wire action to "verb" once it's implemented. std::string name(handler->name); + Verb handler_verb = Verb::VERB_NONE; if (handler->action == arc::mojom::ActionType::SEND || handler->action == arc::mojom::ActionType::SEND_MULTIPLE) { - name = l10n_util::GetStringFUTF8(IDS_FILE_BROWSER_SHARE_WITH_ACTION_LABEL, - base::UTF8ToUTF16(name)); + handler_verb = Verb::VERB_SHARE_WITH; } + const GURL& icon_url = (*icons)[arc::ActivityIconLoader::ActivityName( + handler->package_name, handler->activity_name)]; result_list->push_back(FullTaskDescriptor( TaskDescriptor( ActivityNameToAppId(handler->package_name, handler->activity_name), TASK_TYPE_ARC_APP, ArcActionToString(handler->action)), - name, - GURL(""), // TODO: get the icon - false, // is_default, - handler->action != arc::mojom::ActionType::VIEW // is_generic - )); + name, handler_verb, icon_url, false /* is_default */, + handler->action != arc::mojom::ActionType::VIEW /* is_generic */)); } callback.Run(std::move(result_list)); } @@ -164,6 +268,8 @@ const std::vector<extensions::EntryInfo>& entries, std::unique_ptr<std::vector<FullTaskDescriptor>> result_list, const FindTasksCallback& callback) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + arc::mojom::IntentHelperInstance* arc_intent_helper = GetArcIntentHelper(profile, kArcIntentHelperVersionWithUrlListSupport); if (!arc_intent_helper) { @@ -194,7 +300,9 @@ const TaskDescriptor& task, const std::vector<storage::FileSystemURL>& file_urls, const std::vector<std::string>& mime_types) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_EQ(file_urls.size(), mime_types.size()); + arc::mojom::IntentHelperInstance* const arc_intent_helper = GetArcIntentHelper(profile, kArcIntentHelperVersionWithUrlListSupport); if (!arc_intent_helper)
diff --git a/chrome/browser/chromeos/file_manager/file_tasks.cc b/chrome/browser/chromeos/file_manager/file_tasks.cc index 8eaf30a5..7dab852 100644 --- a/chrome/browser/chromeos/file_manager/file_tasks.cc +++ b/chrome/browser/chromeos/file_manager/file_tasks.cc
@@ -46,6 +46,7 @@ #include "storage/browser/fileapi/file_system_url.h" using extensions::Extension; +using extensions::api::file_manager_private::Verb; using extensions::app_file_handler_util::FindFileHandlersForEntries; using storage::FileSystemURL; @@ -167,18 +168,20 @@ } // namespace -FullTaskDescriptor::FullTaskDescriptor( - const TaskDescriptor& task_descriptor, - const std::string& task_title, - const GURL& icon_url, - bool is_default, - bool is_generic_file_handler) +FullTaskDescriptor::FullTaskDescriptor(const TaskDescriptor& task_descriptor, + const std::string& task_title, + const Verb task_verb, + const GURL& icon_url, + bool is_default, + bool is_generic_file_handler) : task_descriptor_(task_descriptor), task_title_(task_title), + task_verb_(task_verb), icon_url_(icon_url), is_default_(is_default), - is_generic_file_handler_(is_generic_file_handler) { -} + is_generic_file_handler_(is_generic_file_handler) {} + +FullTaskDescriptor::~FullTaskDescriptor() {} FullTaskDescriptor::FullTaskDescriptor(const FullTaskDescriptor& other) = default; @@ -403,12 +406,10 @@ GURL icon_url = drive::util::FindPreferredIcon( app_info.app_icons, drive::util::kPreferredIconSize); - result_list->push_back( - FullTaskDescriptor(descriptor, - app_info.app_name, - icon_url, - false /* is_default */, - false /* is_generic_file_handler */)); + + result_list->push_back(FullTaskDescriptor( + descriptor, app_info.app_name, Verb::VERB_OPEN_WITH, icon_url, + false /* is_default */, false /* is_generic_file_handler */)); } } @@ -475,35 +476,60 @@ continue; } - // Show the first good matching handler of each app. If there doesn't exist - // such handler, show the first matching handler of the app. - const extensions::FileHandlerInfo* file_handler = file_handlers.front(); - for (auto handler : file_handlers) { - if (IsGoodMatchFileHandler(*handler, entries)) { - file_handler = handler; - break; + // A map which has as key a handler verb, and as value a pair of the + // handler with which to open the given entries and a boolean marking + // if the handler is a good match. + std::map<std::string, std::pair<const extensions::FileHandlerInfo*, bool>> + handlers_for_entries; + // Show the first good matching handler of each verb supporting the given + // entries that corresponds to the app. If there doesn't exist such handler, + // show the first matching handler of the verb. + for (const extensions::FileHandlerInfo* handler : file_handlers) { + bool good_match = IsGoodMatchFileHandler(*handler, entries); + auto it = handlers_for_entries.find(handler->verb); + if (it == handlers_for_entries.end() || + (!it->second.second /* existing handler not a good match */ && + good_match)) { + handlers_for_entries[handler->verb] = + std::make_pair(handler, good_match); } } - std::string task_id = file_tasks::MakeTaskID( - extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, file_handler->id); + for (const auto& entry : handlers_for_entries) { + const extensions::FileHandlerInfo* handler = entry.second.first; + std::string task_id = file_tasks::MakeTaskID( + extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, handler->id); - GURL best_icon = extensions::ExtensionIconSource::GetIconURL( - extension, - drive::util::kPreferredIconSize, - ExtensionIconSet::MATCH_BIGGER, - false, // grayscale - NULL); // exists + GURL best_icon = extensions::ExtensionIconSource::GetIconURL( + extension, drive::util::kPreferredIconSize, + ExtensionIconSet::MATCH_BIGGER, + false, // grayscale + NULL); // exists - // If file handler doesn't match as good match, regards it as generic file - // handler. - const bool is_generic_file_handler = - !IsGoodMatchFileHandler(*file_handler, entries); - result_list->push_back(FullTaskDescriptor( - TaskDescriptor(extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, - file_handler->id), - extension->name(), best_icon, false /* is_default */, - is_generic_file_handler)); + // If file handler doesn't match as good match, regards it as generic file + // handler. + const bool is_generic_file_handler = + !IsGoodMatchFileHandler(*handler, entries); + Verb verb; + if (handler->verb == extensions::file_handler_verbs::kAddTo) { + verb = Verb::VERB_ADD_TO; + } else if (handler->verb == extensions::file_handler_verbs::kPackWith) { + verb = Verb::VERB_PACK_WITH; + } else if (handler->verb == extensions::file_handler_verbs::kShareWith) { + verb = Verb::VERB_SHARE_WITH; + } else { + // Only kOpenWith is a valid remaining verb. Invalid verbs should fall + // back to it. + DCHECK(handler->verb == extensions::file_handler_verbs::kOpenWith); + verb = Verb::VERB_OPEN_WITH; + } + + result_list->push_back(FullTaskDescriptor( + TaskDescriptor(extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, + handler->id), + extension->name(), verb, best_icon, false /* is_default */, + is_generic_file_handler)); + } } } @@ -540,13 +566,10 @@ NULL); // exists result_list->push_back(FullTaskDescriptor( - TaskDescriptor(extension_id, - file_tasks::TASK_TYPE_FILE_BROWSER_HANDLER, + TaskDescriptor(extension_id, file_tasks::TASK_TYPE_FILE_BROWSER_HANDLER, handler->id()), - handler->title(), - icon_url, - false /* is_default */, - false /* is_generic_file_handler */)); + handler->title(), Verb::VERB_NONE /* no verb for FileBrowserHandler */, + icon_url, false /* is_default */, false /* is_generic_file_handler */)); } }
diff --git a/chrome/browser/chromeos/file_manager/file_tasks.h b/chrome/browser/chromeos/file_manager/file_tasks.h index 7207051..8343ed65 100644 --- a/chrome/browser/chromeos/file_manager/file_tasks.h +++ b/chrome/browser/chromeos/file_manager/file_tasks.h
@@ -169,16 +169,25 @@ // Describes a task with extra information such as icon URL. class FullTaskDescriptor { public: - FullTaskDescriptor(const TaskDescriptor& task_descriptor, - const std::string& task_title, - const GURL& icon_url, - bool is_default, - bool is_generic_file_handler); + FullTaskDescriptor( + const TaskDescriptor& task_descriptor, + const std::string& task_title, + const extensions::api::file_manager_private::Verb task_verb, + const GURL& icon_url, + bool is_default, + bool is_generic_file_handler); + + ~FullTaskDescriptor(); + FullTaskDescriptor(const FullTaskDescriptor& other); const TaskDescriptor& task_descriptor() const { return task_descriptor_; } // The title of the task. const std::string& task_title() const { return task_title_; } + // The verb of the task. + extensions::api::file_manager_private::Verb task_verb() const { + return task_verb_; + } // The icon URL for the task (ex. app icon) const GURL& icon_url() const { return icon_url_; } @@ -198,6 +207,7 @@ private: TaskDescriptor task_descriptor_; std::string task_title_; + extensions::api::file_manager_private::Verb task_verb_; GURL icon_url_; bool is_default_; bool is_generic_file_handler_;
diff --git a/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc b/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc index afb46b328..a013bd95 100644 --- a/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc +++ b/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc
@@ -33,6 +33,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" +using extensions::api::file_manager_private::Verb; + namespace file_manager { namespace file_tasks { namespace { @@ -64,38 +66,33 @@ TEST(FileManagerFileTasksTest, FullTaskDescriptor_NonDriveAppWithIconAndDefault) { FullTaskDescriptor full_descriptor( - TaskDescriptor("app-id", - TASK_TYPE_FILE_BROWSER_HANDLER, - "action-id"), - "task title", - GURL("http://example.com/icon.png"), - true /* is_default */, - false /* is_generic_file_handler */); + TaskDescriptor("app-id", TASK_TYPE_FILE_BROWSER_HANDLER, "action-id"), + "task title", Verb::VERB_OPEN_WITH, GURL("http://example.com/icon.png"), + true /* is_default */, false /* is_generic_file_handler */); const std::string task_id = TaskDescriptorToId(full_descriptor.task_descriptor()); EXPECT_EQ("app-id|file|action-id", task_id); EXPECT_EQ("http://example.com/icon.png", full_descriptor.icon_url().spec()); EXPECT_EQ("task title", full_descriptor.task_title()); + EXPECT_EQ(Verb::VERB_OPEN_WITH, full_descriptor.task_verb()); EXPECT_TRUE(full_descriptor.is_default()); } TEST(FileManagerFileTasksTest, FullTaskDescriptor_DriveAppWithoutIconAndNotDefault) { FullTaskDescriptor full_descriptor( - TaskDescriptor("app-id", - TASK_TYPE_DRIVE_APP, - "action-id"), - "task title", + TaskDescriptor("app-id", TASK_TYPE_DRIVE_APP, "action-id"), "task title", + Verb::VERB_OPEN_WITH, GURL(), // No icon URL. - false /* is_default */, - false /* is_generic_file_handler */); + false /* is_default */, false /* is_generic_file_handler */); const std::string task_id = TaskDescriptorToId(full_descriptor.task_descriptor()); EXPECT_EQ("app-id|drive|action-id", task_id); EXPECT_TRUE(full_descriptor.icon_url().is_empty()); EXPECT_EQ("task title", full_descriptor.task_title()); + EXPECT_EQ(Verb::VERB_OPEN_WITH, full_descriptor.task_verb()); EXPECT_FALSE(full_descriptor.is_default()); } @@ -262,16 +259,12 @@ "action-id"); std::vector<FullTaskDescriptor> tasks; tasks.push_back(FullTaskDescriptor( - text_app_task, - "Text.app", - GURL("http://example.com/text_app.png"), - false /* is_default */, + text_app_task, "Text.app", Verb::VERB_OPEN_WITH, + GURL("http://example.com/text_app.png"), false /* is_default */, false /* is_generic_file_handler */)); tasks.push_back(FullTaskDescriptor( - nice_app_task, - "Nice.app", - GURL("http://example.com/nice_app.png"), - false /* is_default */, + nice_app_task, "Nice.app", Verb::VERB_ADD_TO, + GURL("http://example.com/nice_app.png"), false /* is_default */, false /* is_generic_file_handler */)); std::vector<extensions::EntryInfo> entries; entries.push_back(extensions::EntryInfo( @@ -330,10 +323,8 @@ "view-in-browser"); std::vector<FullTaskDescriptor> tasks; tasks.push_back(FullTaskDescriptor( - files_app_task, - "View in browser", - GURL("http://example.com/some_icon.png"), - false /* is_default */, + files_app_task, "View in browser", Verb::VERB_OPEN_WITH, + GURL("http://example.com/some_icon.png"), false /* is_default */, false /* is_generic_file_handler */)); std::vector<extensions::EntryInfo> entries; entries.push_back(extensions::EntryInfo( @@ -1056,5 +1047,139 @@ EXPECT_TRUE(dir_result[0].is_generic_file_handler()); } +// The basic logic is similar to a test case for FindDriveAppTasks above. +TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Verbs) { + // kFooId copied from FindFileHandlerTasks test above. + const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph"; + + // Foo.app can handle "text/plain" and "text/html". + extensions::ExtensionBuilder foo_app; + foo_app.SetManifest( + extensions::DictionaryBuilder() + .Set("name", "Foo") + .Set("version", "1.0.0") + .Set("manifest_version", 2) + .Set("app", extensions::DictionaryBuilder() + .Set("background", + extensions::DictionaryBuilder() + .Set("scripts", extensions::ListBuilder() + .Append("background.js") + .Build()) + .Build()) + .Build()) + .Set( + "file_handlers", + extensions::DictionaryBuilder() + .Set("any", + extensions::DictionaryBuilder() + .Set("types", + extensions::ListBuilder().Append("*").Build()) + .Set("verb", "add_to") + .Build()) + .Set("any_with_directories", + extensions::DictionaryBuilder() + .SetBoolean("include_directories", true) + .Set("types", + extensions::ListBuilder().Append("*").Build()) + .Set("verb", "pack_with") + .Build()) + .Set("all_text", extensions::DictionaryBuilder() + .Set("title", "Text") + .Set("types", extensions::ListBuilder() + .Append("text/plain") + .Append("text/html") + .Build()) + .Set("verb", "add_to") + .Build()) + .Set("plain_text", extensions::DictionaryBuilder() + .Set("title", "Plain") + .Set("types", extensions::ListBuilder() + .Append("text/plain") + .Build()) + .Set("verb", "open_with") + .Build()) + .Set("html_text_duplicate_verb", + extensions::DictionaryBuilder() + .Set("title", "Html") + .Set("types", extensions::ListBuilder() + .Append("text/html") + .Build()) + .Set("verb", "add_to") + .Build()) + .Set("share_plain_text", + extensions::DictionaryBuilder() + .Set("title", "Share Plain") + .Set("types", extensions::ListBuilder() + .Append("text/plain") + .Build()) + .Set("verb", "share_with") + .Build()) + .Build()) + .Build()); + foo_app.SetID(kFooId); + extension_service_->AddExtension(foo_app.Build().get()); + + // Find app with corresponding verbs for a "text/plain" file. + // Foo.app with ADD_TO, OPEN_WITH, PACK_WITH and SHARE_WITH should be found, + // but only one ADD_TO that is not a generic handler will be taken into + // account, even though there are 2 ADD_TO matches for "text/plain". + std::vector<extensions::EntryInfo> entries; + entries.push_back( + extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) + .AppendASCII("foo.txt"), + "text/plain", false)); + + std::vector<FullTaskDescriptor> tasks; + FindFileHandlerTasks(&test_profile_, entries, &tasks); + + ASSERT_EQ(4U, tasks.size()); + EXPECT_EQ(kFooId, tasks[0].task_descriptor().app_id); + EXPECT_EQ("Foo", tasks[0].task_title()); + EXPECT_EQ(Verb::VERB_ADD_TO, tasks[0].task_verb()); + EXPECT_EQ(kFooId, tasks[1].task_descriptor().app_id); + EXPECT_EQ("Foo", tasks[1].task_title()); + EXPECT_EQ(Verb::VERB_OPEN_WITH, tasks[1].task_verb()); + EXPECT_EQ(kFooId, tasks[2].task_descriptor().app_id); + EXPECT_EQ("Foo", tasks[2].task_title()); + EXPECT_EQ(Verb::VERB_PACK_WITH, tasks[2].task_verb()); + EXPECT_EQ(kFooId, tasks[3].task_descriptor().app_id); + EXPECT_EQ("Foo", tasks[3].task_title()); + EXPECT_EQ(Verb::VERB_SHARE_WITH, tasks[3].task_verb()); + + // Find app with corresponding verbs for a "text/html" file. + // Foo.app with ADD_TO and PACK_WITH should be found, but only the first + // ADD_TO that is a good match will be taken into account, even though there + // are 3 ADD_TO matches for "text/html". + entries.clear(); + entries.push_back( + extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) + .AppendASCII("foo.html"), + "text/html", false)); + tasks.clear(); + FindFileHandlerTasks(&test_profile_, entries, &tasks); + + ASSERT_EQ(2U, tasks.size()); + EXPECT_EQ(kFooId, tasks[0].task_descriptor().app_id); + EXPECT_EQ("Foo", tasks[0].task_title()); + EXPECT_EQ(Verb::VERB_ADD_TO, tasks[0].task_verb()); + EXPECT_EQ(kFooId, tasks[1].task_descriptor().app_id); + EXPECT_EQ("Foo", tasks[1].task_title()); + EXPECT_EQ(Verb::VERB_PACK_WITH, tasks[1].task_verb()); + + // Find app with corresponding verbs for directories. + // Foo.app with only PACK_WITH should be found. + entries.clear(); + entries.push_back(extensions::EntryInfo( + drive::util::GetDriveMountPointPath(&test_profile_).AppendASCII("dir"), + "", true)); + tasks.clear(); + FindFileHandlerTasks(&test_profile_, entries, &tasks); + + ASSERT_EQ(1U, tasks.size()); + EXPECT_EQ(kFooId, tasks[0].task_descriptor().app_id); + EXPECT_EQ("Foo", tasks[0].task_title()); + EXPECT_EQ(Verb::VERB_PACK_WITH, tasks[0].task_verb()); +} + } // namespace file_tasks } // namespace file_manager.
diff --git a/chrome/browser/extensions/display_info_provider_chromeos.cc b/chrome/browser/extensions/display_info_provider_chromeos.cc index 486c0d7..3238b42 100644 --- a/chrome/browser/extensions/display_info_provider_chromeos.cc +++ b/chrome/browser/extensions/display_info_provider_chromeos.cc
@@ -12,6 +12,7 @@ #include "ash/shell.h" #include "base/strings/string_number_conversions.h" #include "chrome/browser/chromeos/display/display_preferences.h" +#include "chrome/browser/chromeos/display/overscan_calibrator.h" #include "extensions/common/api/system_display.h" #include "ui/display/display.h" #include "ui/display/manager/display_layout.h" @@ -30,6 +31,15 @@ // Maximum allowed bounds origin absolute value. const int kMaxBoundsOrigin = 200 * 1000; +// Gets the display with the provided string id. +display::Display GetDisplay(const std::string& display_id_str) { + int64_t display_id; + if (!base::StringToInt64(display_id_str, &display_id)) + return display::Display(); + return ash::Shell::GetInstance()->display_manager()->GetDisplayForId( + display_id); +} + // Checks if the given integer value is valid display rotation in degrees. bool IsValidRotationValue(int rotation) { return rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270; @@ -195,10 +205,8 @@ // If mirroring source id is set, a display with the given id should exist, // and if should not be the same as the target display's id. if (info.mirroring_source_id && !info.mirroring_source_id->empty()) { - int64_t mirroring_id; - if (!base::StringToInt64(*info.mirroring_source_id, &mirroring_id) || - display_manager->GetDisplayForId(mirroring_id).id() == - display::Display::kInvalidDisplayID) { + int64_t mirroring_id = GetDisplay(*info.mirroring_source_id).id(); + if (mirroring_id == display::Display::kInvalidDisplayID) { *error = "Display " + *info.mirroring_source_id + " not found."; return false; } @@ -311,17 +319,6 @@ return true; } -// Gets the display with the provided string id. -display::Display GetTargetDisplay(const std::string& display_id_str, - ash::DisplayManager* manager) { - int64_t display_id; - if (!base::StringToInt64(display_id_str, &display_id)) { - // This should return invalid display. - return display::Display(); - } - return manager->GetDisplayForId(display_id); -} - extensions::api::system_display::DisplayMode GetDisplayMode( ash::DisplayManager* display_manager, const ash::DisplayInfo& display_info, @@ -359,8 +356,7 @@ ash::DisplayConfigurationController* display_configuration_controller = ash::Shell::GetInstance()->display_configuration_controller(); - const display::Display target = - GetTargetDisplay(display_id_str, display_manager); + const display::Display target = GetDisplay(display_id_str); if (target.id() == display::Display::kInvalidDisplayID) { *error = "Display not found."; @@ -482,6 +478,62 @@ return all_displays; } +bool DisplayInfoProviderChromeOS::OverscanCalibrationStart( + const std::string& id) { + VLOG(1) << "OverscanCalibrationStart: " << id; + const display::Display display = GetDisplay(id); + if (display.id() == display::Display::kInvalidDisplayID) + return false; + auto insets = + ash::Shell::GetInstance()->window_tree_host_manager()->GetOverscanInsets( + display.id()); + overscan_calibrators_[id].reset( + new chromeos::OverscanCalibrator(display, insets)); + return true; +} + +bool DisplayInfoProviderChromeOS::OverscanCalibrationAdjust( + const std::string& id, + const api::system_display::Insets& delta) { + VLOG(1) << "OverscanCalibrationAdjust: " << id; + chromeos::OverscanCalibrator* calibrator = GetCalibrator(id); + if (!calibrator) + return false; + gfx::Insets insets = calibrator->insets(); + insets += gfx::Insets(delta.top, delta.left, delta.bottom, delta.right); + calibrator->UpdateInsets(insets); + return true; +} + +bool DisplayInfoProviderChromeOS::OverscanCalibrationReset( + const std::string& id) { + VLOG(1) << "OverscanCalibrationReset: " << id; + chromeos::OverscanCalibrator* calibrator = GetCalibrator(id); + if (!calibrator) + return false; + calibrator->Reset(); + return true; +} + +bool DisplayInfoProviderChromeOS::OverscanCalibrationComplete( + const std::string& id) { + VLOG(1) << "OverscanCalibrationComplete: " << id; + chromeos::OverscanCalibrator* calibrator = GetCalibrator(id); + if (!calibrator) + return false; + calibrator->Commit(); + overscan_calibrators_[id].reset(); + return true; +} + +chromeos::OverscanCalibrator* DisplayInfoProviderChromeOS::GetCalibrator( + const std::string& id) { + auto iter = overscan_calibrators_.find(id); + if (iter == overscan_calibrators_.end()) + return nullptr; + return iter->second.get(); +} + // static DisplayInfoProvider* DisplayInfoProvider::Create() { return new DisplayInfoProviderChromeOS();
diff --git a/chrome/browser/extensions/display_info_provider_chromeos.h b/chrome/browser/extensions/display_info_provider_chromeos.h index 5db2116d..142d8da4 100644 --- a/chrome/browser/extensions/display_info_provider_chromeos.h +++ b/chrome/browser/extensions/display_info_provider_chromeos.h
@@ -5,9 +5,16 @@ #ifndef CHROME_BROWSER_EXTENSIONS_DISPLAY_INFO_PROVIDER_CHROMEOS_H_ #define CHROME_BROWSER_EXTENSIONS_DISPLAY_INFO_PROVIDER_CHROMEOS_H_ +#include <map> +#include <memory> + #include "base/macros.h" #include "extensions/browser/api/system_display/display_info_provider.h" +namespace chromeos { +class OverscanCalibrator; +} + namespace extensions { class DisplayInfoProviderChromeOS : public DisplayInfoProvider { @@ -24,8 +31,19 @@ api::system_display::DisplayUnitInfo* unit) override; void EnableUnifiedDesktop(bool enable) override; DisplayUnitInfoList GetAllDisplaysInfo() override; + bool OverscanCalibrationStart(const std::string& id) override; + bool OverscanCalibrationAdjust( + const std::string& id, + const api::system_display::Insets& delta) override; + bool OverscanCalibrationReset(const std::string& id) override; + bool OverscanCalibrationComplete(const std::string& id) override; private: + std::map<std::string, std::unique_ptr<chromeos::OverscanCalibrator>> + overscan_calibrators_; + + chromeos::OverscanCalibrator* GetCalibrator(const std::string& id); + DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeOS); };
diff --git a/chrome/browser/media/cast_transport_host_filter.cc b/chrome/browser/media/cast_transport_host_filter.cc index 49d8fd1..019114d 100644 --- a/chrome/browser/media/cast_transport_host_filter.cc +++ b/chrome/browser/media/cast_transport_host_filter.cc
@@ -9,7 +9,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/common/cast_messages.h" #include "components/net_log/chrome_net_log.h" -#include "content/public/browser/power_save_blocker_factory.h" +#include "content/public/browser/power_save_blocker.h" #include "media/cast/net/cast_transport.h" namespace { @@ -148,7 +148,7 @@ if (!power_save_blocker_) { DVLOG(1) << ("Preventing the application from being suspended while one or " "more transports are active for Cast Streaming."); - power_save_blocker_ = content::CreatePowerSaveBlocker( + power_save_blocker_ = content::PowerSaveBlocker::Create( content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, content::PowerSaveBlocker::kReasonOther, "Cast is streaming content to a remote receiver");
diff --git a/chrome/browser/password_manager/account_chooser_dialog_android.cc b/chrome/browser/password_manager/account_chooser_dialog_android.cc index f33ed44..e6f6a81 100644 --- a/chrome/browser/password_manager/account_chooser_dialog_android.cc +++ b/chrome/browser/password_manager/account_chooser_dialog_android.cc
@@ -20,6 +20,7 @@ #include "components/browser_sync/browser/profile_sync_service.h" #include "components/password_manager/core/browser/password_bubble_experiment.h" #include "components/password_manager/core/browser/password_manager_constants.h" +#include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/browser/password_ui_utils.h" #include "components/password_manager/core/common/credential_manager_types.h" #include "jni/AccountChooserDialog_jni.h" @@ -225,8 +226,13 @@ using namespace password_manager; if (type == CredentialType::CREDENTIAL_TYPE_EMPTY) { passwords_data_.ChooseCredential(nullptr); + password_manager::metrics_util::LogAccountChooserUserAction( + password_manager::metrics_util::ACCOUNT_CHOOSER_DISMISSED); + return; } + password_manager::metrics_util::LogAccountChooserUserAction( + password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN); const auto& credentials_forms = (type == CredentialType::CREDENTIAL_TYPE_PASSWORD) ? local_credentials_forms()
diff --git a/chrome/browser/permissions/permission_uma_util.cc b/chrome/browser/permissions/permission_uma_util.cc index 38ca363..bd0b9318 100644 --- a/chrome/browser/permissions/permission_uma_util.cc +++ b/chrome/browser/permissions/permission_uma_util.cc
@@ -20,7 +20,7 @@ #include "url/gurl.h" // UMA keys need to be statically initialized so plain function would not -// work. Use a Macro instead. +// work. Use macros instead. #define PERMISSION_ACTION_UMA(secure_origin, permission, permission_secure, \ permission_insecure, action) \ UMA_HISTOGRAM_ENUMERATION(permission, action, PERMISSION_ACTION_NUM); \ @@ -32,6 +32,12 @@ PERMISSION_ACTION_NUM); \ } +#define PERMISSION_BUBBLE_TYPE_UMA(metric_name, permission_bubble_type) \ + UMA_HISTOGRAM_ENUMERATION( \ + metric_name, \ + static_cast<base::HistogramBase::Sample>(permission_bubble_type), \ + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::NUM)) + using content::PermissionType; namespace { @@ -237,6 +243,21 @@ } // anonymous namespace +const char PermissionUmaUtil::kPermissionsPromptShown[] = + "Permissions.Prompt.Shown"; +const char PermissionUmaUtil::kPermissionsPromptAccepted[] = + "Permissions.Prompt.Accepted"; +const char PermissionUmaUtil::kPermissionsPromptDenied[] = + "Permissions.Prompt.Denied"; +const char PermissionUmaUtil::kPermissionsPromptRequestsPerPrompt[] = + "Permissions.Prompt.RequestsPerPrompt"; +const char PermissionUmaUtil::kPermissionsPromptMergedBubbleTypes[] = + "Permissions.Prompt.MergedBubbleTypes"; +const char PermissionUmaUtil::kPermissionsPromptMergedBubbleAccepted[] = + "Permissions.Prompt.MergedBubbleAccepted"; +const char PermissionUmaUtil::kPermissionsPromptMergedBubbleDenied[] = + "Permissions.Prompt.MergedBubbleDenied"; + // Make sure you update histograms.xml permission histogram_suffix if you // add new permission void PermissionUmaUtil::PermissionRequested(PermissionType permission, @@ -282,26 +303,63 @@ void PermissionUmaUtil::PermissionPromptShown( const std::vector<PermissionBubbleRequest*>& requests) { DCHECK(!requests.empty()); + PermissionBubbleType permission_prompt_type = PermissionBubbleType::MULTIPLE; if (requests.size() == 1) permission_prompt_type = requests[0]->GetPermissionBubbleType(); - UMA_HISTOGRAM_ENUMERATION( - "Permissions.Prompt.Shown", - static_cast<base::HistogramBase::Sample>(permission_prompt_type), - static_cast<base::HistogramBase::Sample>(PermissionBubbleType::NUM)); + PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptShown, permission_prompt_type); UMA_HISTOGRAM_ENUMERATION( - "Permissions.Prompt.RequestsPerPrompt", + kPermissionsPromptRequestsPerPrompt, static_cast<base::HistogramBase::Sample>(requests.size()), static_cast<base::HistogramBase::Sample>(10)); if (requests.size() > 1) { for (const auto* request : requests) { - UMA_HISTOGRAM_ENUMERATION( - "Permissions.Prompt.MergedBubbleTypes", - static_cast<base::HistogramBase::Sample>( - request->GetPermissionBubbleType()), - static_cast<base::HistogramBase::Sample>(PermissionBubbleType::NUM)); + PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptMergedBubbleTypes, + request->GetPermissionBubbleType()); } } } + +void PermissionUmaUtil::PermissionPromptAccepted( + const std::vector<PermissionBubbleRequest*>& requests, + const std::vector<bool>& accept_states) { + DCHECK(!requests.empty()); + DCHECK(requests.size() == accept_states.size()); + + bool all_accepted = accept_states[0]; + PermissionBubbleType permission_prompt_type = + requests[0]->GetPermissionBubbleType(); + if (requests.size() > 1) { + permission_prompt_type = PermissionBubbleType::MULTIPLE; + for (size_t i = 0; i < requests.size(); ++i) { + const auto* request = requests[i]; + if (accept_states[i]) { + PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptMergedBubbleAccepted, + request->GetPermissionBubbleType()); + } else { + all_accepted = false; + PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptMergedBubbleDenied, + request->GetPermissionBubbleType()); + } + } + } + + if (all_accepted) { + PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptAccepted, + permission_prompt_type); + } else { + PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptDenied, + permission_prompt_type); + } +} + +void PermissionUmaUtil::PermissionPromptDenied( + const std::vector<PermissionBubbleRequest*>& requests) { + DCHECK(!requests.empty()); + DCHECK(requests.size() == 1); + + PERMISSION_BUBBLE_TYPE_UMA(kPermissionsPromptDenied, + requests[0]->GetPermissionBubbleType()); +}
diff --git a/chrome/browser/permissions/permission_uma_util.h b/chrome/browser/permissions/permission_uma_util.h index c4c8001..f1636173 100644 --- a/chrome/browser/permissions/permission_uma_util.h +++ b/chrome/browser/permissions/permission_uma_util.h
@@ -38,6 +38,14 @@ // Provides a convenient way of logging UMA for permission related operations. class PermissionUmaUtil { public: + static const char kPermissionsPromptShown[]; + static const char kPermissionsPromptAccepted[]; + static const char kPermissionsPromptDenied[]; + static const char kPermissionsPromptRequestsPerPrompt[]; + static const char kPermissionsPromptMergedBubbleTypes[]; + static const char kPermissionsPromptMergedBubbleAccepted[]; + static const char kPermissionsPromptMergedBubbleDenied[]; + static void PermissionRequested(content::PermissionType permission, const GURL& requesting_origin, const GURL& embedding_origin, @@ -65,6 +73,18 @@ static void PermissionPromptShown( const std::vector<PermissionBubbleRequest*>& requests); + // The following two functions can be combined with the PermissionPromptShown + // metrics to calculate accept, deny and ignore rates. + // Note that for coalesced permission bubbles, PermissionPromptAccepted will + // always be called, with |accept_states| containing whether each request was + // accepted or denied. + static void PermissionPromptAccepted( + const std::vector<PermissionBubbleRequest*>& requests, + const std::vector<bool>& accept_states); + + static void PermissionPromptDenied( + const std::vector<PermissionBubbleRequest*>& requests); + private: DISALLOW_IMPLICIT_CONSTRUCTORS(PermissionUmaUtil); };
diff --git a/chrome/browser/resources/md_downloads/crisper.js b/chrome/browser/resources/md_downloads/crisper.js index 3b327d2..fd55c01 100644 --- a/chrome/browser/resources/md_downloads/crisper.js +++ b/chrome/browser/resources/md_downloads/crisper.js
@@ -5633,40 +5633,6 @@ Polymer.PaperRippleBehavior, Polymer.PaperInkyFocusBehaviorImpl ]; -Polymer({ - is: 'paper-material', - - properties: { - /** - * The z-depth of this element, from 0-5. Setting to 0 will remove the - * shadow, and each increasing number greater than 0 will be "deeper" - * than the last. - * - * @attribute elevation - * @type number - * @default 1 - */ - elevation: { - type: Number, - reflectToAttribute: true, - value: 1 - }, - - /** - * Set this to true to animate the shadow when setting a new - * `elevation` value. - * - * @attribute animated - * @type boolean - * @default false - */ - animated: { - type: Boolean, - reflectToAttribute: true, - value: false - } - } - }); /** @polymerBehavior Polymer.PaperButtonBehavior */ Polymer.PaperButtonBehaviorImpl = { @@ -5753,41 +5719,75 @@ Polymer.PaperButtonBehaviorImpl ]; Polymer({ - is: 'paper-button', - - behaviors: [ - Polymer.PaperButtonBehavior - ], + is: 'paper-material', properties: { /** - * If true, the button should be styled with a shadow. + * The z-depth of this element, from 0-5. Setting to 0 will remove the + * shadow, and each increasing number greater than 0 will be "deeper" + * than the last. + * + * @attribute elevation + * @type number + * @default 1 */ - raised: { + elevation: { + type: Number, + reflectToAttribute: true, + value: 1 + }, + + /** + * Set this to true to animate the shadow when setting a new + * `elevation` value. + * + * @attribute animated + * @type boolean + * @default false + */ + animated: { type: Boolean, reflectToAttribute: true, - value: false, - observer: '_calculateElevation' - } - }, - - _calculateElevation: function() { - if (!this.raised) { - this._setElevation(0); - } else { - Polymer.PaperButtonBehaviorImpl._calculateElevation.apply(this); + value: false } } - /** - - Fired when the animation finishes. - This is useful if you want to wait until - the ripple animation finishes to perform some action. - - @event transitionend - @param {{node: Object}} detail Contains the animated node. - */ }); +Polymer({ + is: 'paper-button', + + behaviors: [ + Polymer.PaperButtonBehavior + ], + + properties: { + /** + * If true, the button should be styled with a shadow. + */ + raised: { + type: Boolean, + reflectToAttribute: true, + value: false, + observer: '_calculateElevation' + } + }, + + _calculateElevation: function() { + if (!this.raised) { + this._setElevation(0); + } else { + Polymer.PaperButtonBehaviorImpl._calculateElevation.apply(this); + } + } + + /** + Fired when the animation finishes. + This is useful if you want to wait until + the ripple animation finishes to perform some action. + + @event transitionend + Event param: {{node: Object}} detail Contains the animated node. + */ + }); /** * `iron-range-behavior` provides the behavior for something with a minimum to maximum range. * @@ -5859,18 +5859,27 @@ }, _calcStep: function(value) { - /** - * if we calculate the step using - * `Math.round(value / step) * step` we may hit a precision point issue - * eg. 0.1 * 0.2 = 0.020000000000000004 - * http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html - * - * as a work around we can divide by the reciprocal of `step` - */ // polymer/issues/2493 value = parseFloat(value); - return this.step ? (Math.round((value + this.min) / this.step) - - (this.min / this.step)) / (1 / this.step) : value; + + if (!this.step) { + return value; + } + + var numSteps = Math.round((value - this.min) / this.step); + if (this.step < 1) { + /** + * For small values of this.step, if we calculate the step using + * `Math.round(value / step) * step` we may hit a precision point issue + * eg. 0.1 * 0.2 = 0.020000000000000004 + * http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html + * + * as a work around we can divide by the reciprocal of `step` + */ + return numSteps / (1 / this.step) + this.min; + } else { + return numSteps * this.step + this.min; + } }, _validateValue: function() { @@ -6625,8 +6634,8 @@ /** * Fired when the list of selectable items changes (e.g., items are - * added or removed). The detail of the event is a list of mutation - * records that describe what changed. + * added or removed). The detail of the event is a mutation record that + * describes what changed. * * @event iron-items-changed */ @@ -6933,7 +6942,7 @@ // observe items change under the given node. _observeItems: function(node) { - return Polymer.dom(node).observeNodes(function(mutations) { + return Polymer.dom(node).observeNodes(function(mutation) { this._updateItems(); if (this._shouldUpdateSelection) { @@ -6942,7 +6951,7 @@ // Let other interested parties know about the change so that // we don't have to recreate mutation observers everywhere. - this.fire('iron-items-changed', mutations, { + this.fire('iron-items-changed', mutation, { bubbles: false, cancelable: false }); @@ -7223,7 +7232,7 @@ var attr = this.attrForItemTitle || 'textContent'; var title = item[attr] || item.getAttribute(attr); - if (!item.hasAttribute('disabled') && title && + if (!item.hasAttribute('disabled') && title && title.trim().charAt(0).toLowerCase() === String.fromCharCode(event.keyCode).toLowerCase()) { this._setFocusedItem(item); break; @@ -7304,17 +7313,8 @@ * detail. */ _onIronItemsChanged: function(event) { - var mutations = event.detail; - var mutation; - var index; - - for (index = 0; index < mutations.length; ++index) { - mutation = mutations[index]; - - if (mutation.addedNodes.length) { - this._resetTabindices(); - break; - } + if (event.detail.addedNodes.length) { + this._resetTabindices(); } }, @@ -7749,10 +7749,15 @@ * Equivalent to calling `resetFit()` and `fit()`. Useful to call this after * the element or the `fitInto` element has been resized, or if any of the * positioning properties (e.g. `horizontalAlign, verticalAlign`) is updated. + * It preserves the scroll position of the sizingTarget. */ refit: function() { + var scrollLeft = this.sizingTarget.scrollLeft; + var scrollTop = this.sizingTarget.scrollTop; this.resetFit(); this.fit(); + this.sizingTarget.scrollLeft = scrollLeft; + this.sizingTarget.scrollTop = scrollTop; }, /** @@ -7976,37 +7981,41 @@ var position; for (var i = 0; i < positions.length; i++) { var pos = positions[i]; - // Align is ok if: - // - Horizontal AND vertical are required and match, or - // - Only vertical is required and matches, or - // - Only horizontal is required and matches. - var alignOk = (pos.verticalAlign === vAlign && pos.horizontalAlign === hAlign) || - (pos.verticalAlign === vAlign && !hAlign) || - (pos.horizontalAlign === hAlign && !vAlign); // If both vAlign and hAlign are defined, return exact match. // For dynamicAlign and noOverlap we'll have more than one candidate, so // we'll have to check the croppedArea to make the best choice. - if (!this.dynamicAlign && !this.noOverlap && vAlign && hAlign && alignOk) { + if (!this.dynamicAlign && !this.noOverlap && + pos.verticalAlign === vAlign && pos.horizontalAlign === hAlign) { position = pos; break; } + // Align is ok if alignment preferences are respected. If no preferences, + // it is considered ok. + var alignOk = (!vAlign || pos.verticalAlign === vAlign) && + (!hAlign || pos.horizontalAlign === hAlign); + // Filter out elements that don't match the alignment (if defined). // With dynamicAlign, we need to consider all the positions to find the // one that minimizes the cropped area. - if (!this.dynamicAlign && (vAlign || hAlign) && !alignOk) { + if (!this.dynamicAlign && !alignOk) { continue; } position = position || pos; pos.croppedArea = this.__getCroppedArea(pos, size, fitRect); var diff = pos.croppedArea - position.croppedArea; - // Check which crops less. If it crops equally, - // check for alignment preferences. + // Check which crops less. If it crops equally, check if align is ok. if (diff < 0 || (diff === 0 && alignOk)) { position = pos; } + // If not cropped and respects the align requirements, keep it. + // This allows to prefer positions overlapping horizontally over the + // ones overlapping vertically. + if (position.croppedArea === 0 && alignOk) { + break; + } } return position; @@ -8146,10 +8155,10 @@ */ this._backdropElement = null; - // Listen to mousedown or touchstart to be sure to be the first to capture - // clicks outside the overlay. - var clickEvent = ('ontouchstart' in window) ? 'touchstart' : 'mousedown'; - document.addEventListener(clickEvent, this._onCaptureClick.bind(this), true); + // Enable document-wide tap recognizer. + Polymer.Gestures.add(document, 'tap', null); + // Need to have useCapture=true, Polymer.Gestures doesn't offer that. + document.addEventListener('tap', this._onCaptureClick.bind(this), true); document.addEventListener('focus', this._onCaptureFocus.bind(this), true); document.addEventListener('keydown', this._onCaptureKeyDown.bind(this), true); }; @@ -8229,7 +8238,6 @@ } else { this.removeOverlay(overlay); } - this.trackBackdrop(); }, /** @@ -8241,6 +8249,7 @@ var i = this._overlays.indexOf(overlay); if (i >= 0) { this._bringOverlayAtIndexToFront(i); + this.trackBackdrop(); return; } var insertionIndex = this._overlays.length; @@ -8267,6 +8276,7 @@ // Get focused node. var element = this.deepActiveElement; overlay.restoreFocusNode = this._overlayParent(element) ? null : element; + this.trackBackdrop(); }, /** @@ -8285,6 +8295,7 @@ if (node && Polymer.dom(document.body).deepContains(node)) { node.focus(); } + this.trackBackdrop(); }, /** @@ -8453,12 +8464,6 @@ var overlay = /** @type {?} */ (this.currentOverlay()); // Check if clicked outside of top overlay. if (overlay && this._overlayInPath(Polymer.dom(event).path) !== overlay) { - if (overlay.withBackdrop) { - // There's no need to stop the propagation as the backdrop element - // already got this mousedown/touchstart event. Calling preventDefault - // on this event ensures that click/tap won't be triggered at all. - event.preventDefault(); - } overlay._onCaptureClick(event); } }, @@ -8808,12 +8813,17 @@ return; } - this._manager.addOrRemoveOverlay(this); - if (this.__openChangedAsync) { window.cancelAnimationFrame(this.__openChangedAsync); } + // Synchronously remove the overlay. + // The adding is done asynchronously to go out of the scope of the event + // which might have generated the opening. + if (!this.opened) { + this._manager.removeOverlay(this); + } + // Defer any animation-related code on attached // (_openedChanged gets called again on attached). if (!this.isAttached) { @@ -8826,6 +8836,7 @@ this.__openChangedAsync = window.requestAnimationFrame(function() { this.__openChangedAsync = null; if (this.opened) { + this._manager.addOverlay(this); this._prepareRenderOpened(); this._renderOpened(); } else { @@ -8848,7 +8859,7 @@ this.removeAttribute('tabindex'); this.__shouldRemoveTabIndex = false; } - if (this.opened) { + if (this.opened && this.isAttached) { this._manager.trackBackdrop(); } }, @@ -8898,6 +8909,12 @@ this.notifyResize(); this.__isAnimating = false; + + // Store it so we don't query too much. + var focusableNodes = this._focusableNodes; + this.__firstFocusableNode = focusableNodes[0]; + this.__lastFocusableNode = focusableNodes[focusableNodes.length - 1]; + this.fire('iron-overlay-opened'); }, @@ -9002,12 +9019,32 @@ * @protected */ _onCaptureTab: function(event) { + if (!this.withBackdrop) { + return; + } // TAB wraps from last to first focusable. // Shift + TAB wraps from first to last focusable. var shift = event.shiftKey; var nodeToCheck = shift ? this.__firstFocusableNode : this.__lastFocusableNode; var nodeToSet = shift ? this.__lastFocusableNode : this.__firstFocusableNode; - if (this.withBackdrop && this._focusedChild === nodeToCheck) { + var shouldWrap = false; + if (nodeToCheck === nodeToSet) { + // If nodeToCheck is the same as nodeToSet, it means we have an overlay + // with 0 or 1 focusables; in either case we still need to trap the + // focus within the overlay. + shouldWrap = true; + } else { + // In dom=shadow, the manager will receive focus changes on the main + // root but not the ones within other shadow roots, so we can't rely on + // _focusedChild, but we should check the deepest active element. + var focusedNode = this._manager.deepActiveElement; + // If the active element is not the nodeToCheck but the overlay itself, + // it means the focus is about to go outside the overlay, hence we + // should prevent that (e.g. user opens the overlay and hit Shift+TAB). + shouldWrap = (focusedNode === nodeToCheck || focusedNode === this); + } + + if (shouldWrap) { // When the overlay contains the last focusable element of the document // and it's already focused, pressing TAB would move the focus outside // the document (e.g. to the browser search bar). Similarly, when the @@ -9050,10 +9087,6 @@ if (this.opened && !this.__isAnimating) { this.notifyResize(); } - // Store it so we don't query too much. - var focusableNodes = this._focusableNodes; - this.__firstFocusableNode = focusableNodes[0]; - this.__lastFocusableNode = focusableNodes[focusableNodes.length - 1]; } }; @@ -9729,6 +9762,11 @@ return this.focusTarget || this.containedElement; }, + detached: function() { + this.cancelAnimation(); + Polymer.IronDropdownScrollManager.removeScrollLock(this); + }, + /** * Called when the value of `opened` changes. * Overridden from `IronOverlayBehavior` @@ -9753,10 +9791,7 @@ * Overridden from `IronOverlayBehavior`. */ _renderOpened: function() { - if (!this.noAnimations && this.animationConfig && this.animationConfig.open) { - if (this.withBackdrop) { - this.backdropElement.open(); - } + if (!this.noAnimations && this.animationConfig.open) { this.$.contentWrapper.classList.add('animating'); this.playAnimation('open'); } else { @@ -9768,10 +9803,7 @@ * Overridden from `IronOverlayBehavior`. */ _renderClosed: function() { - if (!this.noAnimations && this.animationConfig && this.animationConfig.close) { - if (this.withBackdrop) { - this.backdropElement.close(); - } + if (!this.noAnimations && this.animationConfig.close) { this.$.contentWrapper.classList.add('animating'); this.playAnimation('close'); } else { @@ -9788,9 +9820,9 @@ _onNeonAnimationFinish: function() { this.$.contentWrapper.classList.remove('animating'); if (this.opened) { - Polymer.IronOverlayBehaviorImpl._finishRenderOpened.apply(this); + this._finishRenderOpened(); } else { - Polymer.IronOverlayBehaviorImpl._finishRenderClosed.apply(this); + this._finishRenderClosed(); } }, @@ -9799,30 +9831,14 @@ * to configure specific parts of the opening and closing animations. */ _updateAnimationConfig: function() { - var animationConfig = {}; - var animations = []; - - if (this.openAnimationConfig) { - // NOTE(cdata): When making `display:none` elements visible in Safari, - // the element will paint once in a fully visible state, causing the - // dropdown to flash before it fades in. We prepend an - // `opaque-animation` to fix this problem: - animationConfig.open = [{ - name: 'opaque-animation', - }].concat(this.openAnimationConfig); - animations = animations.concat(animationConfig.open); + var animations = (this.openAnimationConfig || []).concat(this.closeAnimationConfig || []); + for (var i = 0; i < animations.length; i++) { + animations[i].node = this.containedElement; } - - if (this.closeAnimationConfig) { - animationConfig.close = this.closeAnimationConfig; - animations = animations.concat(animationConfig.close); - } - - animations.forEach(function(animation) { - animation.node = this.containedElement; - }, this); - - this.animationConfig = animationConfig; + this.animationConfig = { + open: this.openAnimationConfig, + close: this.closeAnimationConfig + }; }, /** @@ -9837,30 +9853,6 @@ }, /** - * Useful to call this after the element, the window, or the `fitInfo` - * element has been resized. Will maintain the scroll position. - */ - refit: function () { - if (!this.opened) { - return - } - var containedElement = this.containedElement; - var scrollTop; - var scrollLeft; - - if (containedElement) { - scrollTop = containedElement.scrollTop; - scrollLeft = containedElement.scrollLeft; - } - Polymer.IronFitBehavior.refit.apply(this, arguments); - - if (containedElement) { - containedElement.scrollTop = scrollTop; - containedElement.scrollLeft = scrollLeft; - } - }, - - /** * Apply focus to focusTarget or containedElement */ _applyFocus: function () {
diff --git a/chrome/browser/resources/md_downloads/vulcanized.html b/chrome/browser/resources/md_downloads/vulcanized.html index 0c49427..6363f38b 100644 --- a/chrome/browser/resources/md_downloads/vulcanized.html +++ b/chrome/browser/resources/md_downloads/vulcanized.html
@@ -647,16 +647,17 @@ </dom-module> <dom-module id="paper-button" assetpath="chrome://resources/polymer/v1_0/paper-button/"> <template strip-whitespace=""> - <style include="paper-material"> :host { - display: inline-block; + @apply(--layout-inline); + @apply(--layout-center-center); position: relative; box-sizing: border-box; min-width: 5.14em; margin: 0 0.29em; background: transparent; - text-align: center; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); + -webkit-tap-highlight-color: transparent; font: inherit; text-transform: uppercase; outline-width: 0; @@ -669,6 +670,7 @@ z-index: 0; padding: 0.7em 0.57em; + @apply(--paper-font-common-base); @apply(--paper-button); } @@ -694,15 +696,12 @@ paper-ripple { color: var(--paper-button-ink-color); } - - :host > ::content * { - text-transform: inherit; - } </style> + <content></content> </template> -</dom-module> + </dom-module> <style is="custom-style"> :root {
diff --git a/chrome/browser/resources/options/confirm_dialog.js b/chrome/browser/resources/options/confirm_dialog.js index bb9bd4e..c70c338 100644 --- a/chrome/browser/resources/options/confirm_dialog.js +++ b/chrome/browser/resources/options/confirm_dialog.js
@@ -22,10 +22,13 @@ * user has confirmed the dialog before. This ensures that the user is * presented with the dialog only once. If left |undefined|, the dialog * will pop up every time the user attempts to set |pref| to |true|. + * @param {boolean=} opt_confirmValue The value to which changing should + * trigger the confirmation dialog. Defaults to |true| if left + * |undefined|. * @extends {options.SettingsDialog} */ function ConfirmDialog(name, title, pageDivName, okButton, cancelButton, pref, - metric, opt_confirmedPref) { + metric, opt_confirmedPref, opt_confirmValue) { SettingsDialog.call(this, name, title, pageDivName, okButton, cancelButton); /** @protected */ @@ -39,6 +42,9 @@ /** @private */ this.confirmed_ = false; + + /** @private */ + this.confirmValue_ = opt_confirmValue === false ? false : true; } ConfirmDialog.prototype = { @@ -57,7 +63,7 @@ if (!event.value.uncommitted) return; - if (event.value.value && !this.confirmed_) + if (event.value.value == this.confirmValue_ && !this.confirmed_) PageManager.showPageByName(this.name, false); else Preferences.getInstance().commitPref(this.pref, this.metric); @@ -97,7 +103,8 @@ Preferences.getInstance().commitPref(this.pref, this.metric); if (this.confirmedPref_) - Preferences.setBooleanPref(this.confirmedPref_, true, true); + Preferences.setBooleanPref( + this.confirmedPref_, this.confirmValue_, true); }, /**
diff --git a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html index 1f2f4e6..8a9d431 100644 --- a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html +++ b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html
@@ -17,6 +17,20 @@ max-width: 600px; } + #dialog:not(.fully-rendered) { + visibility: hidden; + } + + .row { + align-items: center; + display: flex; + min-height: 40px; + } + + .row .start { + flex: 1; + } + paper-spinner { -webkit-margin-end: 16px; margin-bottom: auto;
diff --git a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js index ab1fff3..45fda80 100644 --- a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js +++ b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js
@@ -82,6 +82,8 @@ updateFooter_: function(syncing, otherFormsOfBrowsingHistory) { this.$.googleFooter.hidden = !otherFormsOfBrowsingHistory; this.$.syncedDataSentence.hidden = !syncing; + this.$.dialog.notifyResize(); + this.$.dialog.classList.add('fully-rendered'); }, open: function() {
diff --git a/chrome/browser/resources/settings/settings_dialog.html b/chrome/browser/resources/settings/settings_dialog.html index d923118..f3bd611 100644 --- a/chrome/browser/resources/settings/settings_dialog.html +++ b/chrome/browser/resources/settings/settings_dialog.html
@@ -8,61 +8,70 @@ <template> <style include="paper-dialog-shared-styles"></style> <style> - .body-content { - display: flex; - flex-direction: column; - min-height: 120px; + :host { + border-radius: 2px; } - .dialog-content { + :host ::content > * { + /* Overrides paper-dialog-shared-styles. */ -webkit-padding-end: 0; -webkit-padding-start: 0; margin-bottom: 0; margin-top: 0; } - .footer-container { - margin: 0; - padding: 0; - } - - .top-row { + .title-container { align-items: center; + /* TODO(dbeam): should this be a --settings-separator-line? */ border-bottom: 1px solid rgba(0, 0, 0, 0.14); display: flex; min-height: 52px; } - paper-icon-button { + :host ::content .title { + font-size: 114.28%; /* (16px / 14px) * 100 */ + } + + #close { height: 20px; margin: 16px; padding: 0; width: 20px; } - :host { - border-radius: 2px; + .body-container { + display: flex; + flex-direction: column; max-width: 800px; min-width: 512px; + /* TODO(dbeam): use <paper-dialog-scrollable> to get dividers? */ overflow: auto; } + :host ::content .body { + margin: 12px 0; + } + + :host ::content .body, + :host ::content .title { + -webkit-padding-end: 24px; + -webkit-padding-start: 24px; + flex: 1; + } + :host ::content .body, :host ::content .footer, :host ::content paper-button { font-size: 92.86%; /* (13px / 14px) * 100 */ } - :host ::content .body { - margin: 12px 0 24px 0; - } - :host ::content .button-container { -webkit-padding-end: 16px; -webkit-padding-start: 16px; display: flex; justify-content: flex-end; margin-bottom: 12px; + margin-top: 12px; } :host ::content .button-container .cancel-button { @@ -72,45 +81,22 @@ :host ::content .footer { background-color: var(--paper-grey-200); + border-bottom-left-radius: inherit; + border-bottom-right-radius: inherit; margin: 0; - padding: 20px; - } - - :host ::content .row { - align-items: center; - display: flex; - min-height: 40px; - } - - :host ::content .row .start { - flex: 1; - } - - :host ::content .title { - font-size: 114.28%; /* (16px / 14px) * 100 */ - } - - :host ::content .body, - :host ::content .title { - -webkit-padding-end: 24px; - -webkit-padding-start: 24px; - flex: 1; + padding: 12px 20px; } </style> - <div class="dialog-content"> - <div class="top-row"> - <content select=".title"></content> - <paper-icon-button icon="cr:clear" on-tap="cancel" id="close"> - </paper-icon-button> - </div> - <div class="body-content"> - <content select=".body"></content> - <content select=".button-container"></content> - </div> + <div class="title-container"> + <content select=".title"></content> + <paper-icon-button icon="cr:clear" on-tap="cancel" id="close"> + </paper-icon-button> </div> - <div class="footer-container"> - <content select=".footer"></content> + <div class="body-container"> + <content select=".body"></content> </div> + <content select=".button-container"></content> + <content select=".footer"></content> </template> <script src="settings_dialog.js"></script> </dom-module>
diff --git a/chrome/browser/resources/settings/settings_dialog.js b/chrome/browser/resources/settings/settings_dialog.js index 888ae0d..3f587d3 100644 --- a/chrome/browser/resources/settings/settings_dialog.js +++ b/chrome/browser/resources/settings/settings_dialog.js
@@ -21,6 +21,13 @@ value: false, }, + sizingTarget: { + type: Element, + value: function() { + return this.$$('.body-container'); + }, + }, + /** @override */ withBackdrop: { type: Boolean,
diff --git a/chrome/browser/search/suggestions/suggestions_ui.cc b/chrome/browser/search/suggestions/suggestions_ui.cc index de84dc4..9bd73d50 100644 --- a/chrome/browser/search/suggestions/suggestions_ui.cc +++ b/chrome/browser/search/suggestions/suggestions_ui.cc
@@ -28,6 +28,7 @@ #include "net/base/escape.h" #include "ui/base/l10n/time_format.h" #include "ui/gfx/codec/png_codec.h" +#include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia.h" #include "url/gurl.h" @@ -145,7 +146,7 @@ // Callback for responses from each Thumbnail request. void OnThumbnailAvailable(RequestContext* context, base::Closure barrier, - const GURL& url, const SkBitmap* bitmap); + const GURL& url, const gfx::Image& image); // Callback for when all requests are complete. Renders the output webpage and // passes the result to the original caller. @@ -249,10 +250,10 @@ void SuggestionsSource::OnThumbnailAvailable(RequestContext* context, base::Closure barrier, const GURL& url, - const SkBitmap* bitmap) { - if (bitmap) { + const gfx::Image& image) { + if (!image.IsEmpty()) { std::vector<unsigned char> output; - gfx::PNGCodec::EncodeBGRASkBitmap(*bitmap, false, &output); + gfx::PNGCodec::EncodeBGRASkBitmap(*image.ToSkBitmap(), false, &output); std::string encoded_output; base::Base64Encode(
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc index eaf5c403..9720ca5 100644 --- a/chrome/browser/shell_integration_win.cc +++ b/chrome/browser/shell_integration_win.cc
@@ -95,6 +95,14 @@ return profile_id; } +base::string16 GetAppListAppName() { + static const base::char16 kAppListAppNameSuffix[] = L"AppList"; + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + base::string16 app_name(dist->GetBaseAppId()); + app_name.append(kAppListAppNameSuffix); + return app_name; +} + // Gets expected app id for given Chrome (based on |command_line| and // |is_per_user_install|). base::string16 GetExpectedAppId(const base::CommandLine& command_line, @@ -127,6 +135,8 @@ app_name = base::UTF8ToUTF16( web_app::GenerateApplicationNameFromExtensionId( command_line.GetSwitchValueASCII(switches::kAppId))); + } else if (command_line.HasSwitch(switches::kShowAppList)) { + app_name = GetAppListAppName(); } else { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); app_name = ShellUtil::GetBrowserModelId(dist, is_per_user_install);
diff --git a/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.cc b/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.cc index 8718dac..a076845 100644 --- a/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.cc +++ b/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.cc
@@ -102,9 +102,9 @@ } void URLSuggestionResult::OnSuggestionsThumbnailAvailable( - const GURL& url, const SkBitmap* bitmap) { - if (bitmap) { - SetIcon(gfx::ImageSkia::CreateFrom1xBitmap(*bitmap)); + const GURL& url, const gfx::Image& image) { + if (!image.IsEmpty()) { + SetIcon(*image.ToImageSkia()); } else { // There is no image for this suggestion. Disable being shown on the start // screen.
diff --git a/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.h b/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.h index 2a86cf5..d5854c7 100644 --- a/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.h +++ b/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.h
@@ -15,7 +15,6 @@ class AppListControllerDelegate; class GURL; class Profile; -class SkBitmap; namespace favicon { class FaviconService; @@ -25,6 +24,10 @@ struct FaviconRawBitmapResult; } // namespace favicon_base +namespace gfx { +class Image; +} // namespace gfx + namespace suggestions { class SuggestionsService; } // namespace suggestions @@ -53,7 +56,8 @@ void UpdateIcon(); void OnDidGetIcon( const favicon_base::FaviconRawBitmapResult& bitmap_result); - void OnSuggestionsThumbnailAvailable(const GURL& url, const SkBitmap* bitmap); + void OnSuggestionsThumbnailAvailable(const GURL& url, + const gfx::Image& image); Profile* profile_; AppListControllerDelegate* list_controller_;
diff --git a/chrome/browser/ui/cocoa/browser/zoom_bubble_controller.mm b/chrome/browser/ui/cocoa/browser/zoom_bubble_controller.mm index 58390da..4de26629 100644 --- a/chrome/browser/ui/cocoa/browser/zoom_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/browser/zoom_bubble_controller.mm
@@ -4,8 +4,10 @@ #include "chrome/browser/ui/cocoa/browser/zoom_bubble_controller.h" +#include "base/i18n/number_formatting.h" #include "base/mac/foundation_util.h" #include "base/strings/string_number_conversions.h" +#include "base/strings/sys_string_conversions.h" #import "chrome/browser/ui/cocoa/info_bubble_view.h" #import "chrome/browser/ui/cocoa/info_bubble_window.h" #include "chrome/grit/generated_resources.h" @@ -147,8 +149,7 @@ return; int percent = zoomController->GetZoomPercent(); - NSString* string = - l10n_util::GetNSStringF(IDS_ZOOM_PERCENT, base::IntToString16(percent)); + NSString* string = base::SysUTF16ToNSString(base::FormatPercent(percent)); [zoomPercent_ setAttributedStringValue: [self attributedStringWithString:string fontSize:kTextFontSize]];
diff --git a/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm b/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm index 7fb1d0a..478e0a44 100644 --- a/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm +++ b/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm
@@ -4,6 +4,7 @@ #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" +#include "base/i18n/number_formatting.h" #include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "chrome/app/chrome_command_ids.h" @@ -41,9 +42,9 @@ } base::string16 zoom_percent = - base::IntToString16(zoom_controller->GetZoomPercent()); + base::FormatPercent(zoom_controller->GetZoomPercent()); NSString* zoom_string = - l10n_util::GetNSStringFWithFixup(IDS_TOOLTIP_ZOOM, zoom_percent); + l10n_util::GetNSStringF(IDS_TOOLTIP_ZOOM, zoom_percent); if (IsVisible() && [tooltip_ isEqualToString:zoom_string] && !default_zoom_changed) {
diff --git a/chrome/browser/ui/toolbar/app_menu_model.cc b/chrome/browser/ui/toolbar/app_menu_model.cc index e4cdf880..7cc41d2d 100644 --- a/chrome/browser/ui/toolbar/app_menu_model.cc +++ b/chrome/browser/ui/toolbar/app_menu_model.cc
@@ -10,9 +10,9 @@ #include "base/command_line.h" #include "base/debug/debugging_flags.h" #include "base/debug/profiler.h" +#include "base/i18n/number_formatting.h" #include "base/macros.h" #include "base/metrics/histogram.h" -#include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" @@ -939,8 +939,7 @@ browser_->tab_strip_model()->GetActiveWebContents()) ->GetZoomPercent(); } - zoom_label_ = l10n_util::GetStringFUTF16( - IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); + zoom_label_ = base::FormatPercent(zoom_percent); } void AppMenuModel::OnZoomLevelChanged(
diff --git a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc index 33439dc..9cb3a0d 100644 --- a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc +++ b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" +#include "base/i18n/number_formatting.h" #include "base/i18n/rtl.h" #include "base/strings/stringprintf.h" #include "chrome/browser/chrome_notification_types.h" @@ -176,8 +177,8 @@ ui_zoom::ZoomController* zoom_controller = ui_zoom::ZoomController::FromWebContents(web_contents_); int zoom_percent = zoom_controller->GetZoomPercent(); - label_ = new views::Label( - l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); + label_ = new views::Label(l10n_util::GetStringFUTF16( + IDS_TOOLTIP_ZOOM, base::FormatPercent(zoom_percent))); label_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( ui::ResourceBundle::MediumFont)); grid_layout->AddView(label_); @@ -245,8 +246,8 @@ ui_zoom::ZoomController* zoom_controller = ui_zoom::ZoomController::FromWebContents(web_contents_); int zoom_percent = zoom_controller->GetZoomPercent(); - label_->SetText( - l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); + label_->SetText(l10n_util::GetStringFUTF16( + IDS_TOOLTIP_ZOOM, base::FormatPercent(zoom_percent))); StartTimerIfNecessary(); }
diff --git a/chrome/browser/ui/views/location_bar/zoom_view.cc b/chrome/browser/ui/views/location_bar/zoom_view.cc index fcd4cd61..6ec3525 100644 --- a/chrome/browser/ui/views/location_bar/zoom_view.cc +++ b/chrome/browser/ui/views/location_bar/zoom_view.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/views/location_bar/zoom_view.h" +#include "base/i18n/number_formatting.h" #include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" #include "chrome/grit/generated_resources.h" @@ -33,8 +34,9 @@ return; } - SetTooltipText(l10n_util::GetStringFUTF16Int( - IDS_TOOLTIP_ZOOM, zoom_controller->GetZoomPercent())); + SetTooltipText(l10n_util::GetStringFUTF16( + IDS_TOOLTIP_ZOOM, + base::FormatPercent(zoom_controller->GetZoomPercent()))); // The icon is hidden when the zoom level is default. image_id_ = zoom_controller->GetZoomRelativeToDefault() ==
diff --git a/chrome/browser/ui/views/toolbar/app_menu.cc b/chrome/browser/ui/views/toolbar/app_menu.cc index 119a1ad..8abd0fa5d 100644 --- a/chrome/browser/ui/views/toolbar/app_menu.cc +++ b/chrome/browser/ui/views/toolbar/app_menu.cc
@@ -10,9 +10,9 @@ #include <cmath> #include <set> +#include "base/i18n/number_formatting.h" #include "base/macros.h" #include "base/metrics/histogram.h" -#include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "chrome/app/chrome_command_ids.h" @@ -499,8 +499,7 @@ IDS_ZOOM_MINUS2, InMenuButtonBackground::LEADING_BORDER, decrement_index, IDS_ACCNAME_ZOOM_MINUS2); - zoom_label_ = new Label( - l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, 100)); + zoom_label_ = new Label(base::FormatPercent(100)); zoom_label_->SetAutoColorReadabilityEnabled(false); zoom_label_->SetHorizontalAlignment(gfx::ALIGN_RIGHT); @@ -643,9 +642,7 @@ decrement_button_->SetEnabled(zoom > selected_tab->GetMinimumZoomPercent()); } - zoom_label_->SetText( - l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom)); - + zoom_label_->SetText(base::FormatPercent(zoom)); zoom_label_max_width_valid_ = false; } @@ -669,14 +666,12 @@ zoom_controller->GetZoomPercent()); for (auto zoom : zoom_factors) { int w = gfx::GetStringWidth( - l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, - static_cast<int>(zoom * 100 + 0.5)), + base::FormatPercent(static_cast<int>(std::round(zoom * 100))), font_list); max_w = std::max(w, max_w); } } else { - max_w = gfx::GetStringWidth( - l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, 100), font_list); + max_w = gfx::GetStringWidth(base::FormatPercent(100), font_list); } zoom_label_max_width_ = max_w + border_width;
diff --git a/chrome/browser/ui/website_settings/mock_permission_bubble_request.cc b/chrome/browser/ui/website_settings/mock_permission_bubble_request.cc index 06fbad6..ce08e3cf 100644 --- a/chrome/browser/ui/website_settings/mock_permission_bubble_request.cc +++ b/chrome/browser/ui/website_settings/mock_permission_bubble_request.cc
@@ -9,50 +9,46 @@ #include "grit/theme_resources.h" MockPermissionBubbleRequest::MockPermissionBubbleRequest() - : granted_(false), - cancelled_(false), - finished_(false) { - text_ = base::ASCIIToUTF16("test"); - accept_label_ = base::ASCIIToUTF16("button"); - deny_label_ = base::ASCIIToUTF16("button"); - origin_ = GURL("http://www.google.com"); -} + : MockPermissionBubbleRequest("test", + "button", + "button", + GURL("http://www.google.com"), + PermissionBubbleType::UNKNOWN) {} MockPermissionBubbleRequest::MockPermissionBubbleRequest( const std::string& text) - : granted_(false), - cancelled_(false), - finished_(false) { - text_ = base::UTF8ToUTF16(text); - accept_label_ = base::ASCIIToUTF16("button"); - deny_label_ = base::ASCIIToUTF16("button"); - origin_ = GURL("http://www.google.com"); -} + : MockPermissionBubbleRequest(text, + "button", + "button", + GURL("http://www.google.com"), + PermissionBubbleType::UNKNOWN) {} + +MockPermissionBubbleRequest::MockPermissionBubbleRequest( + const std::string& text, PermissionBubbleType bubble_type) + : MockPermissionBubbleRequest(text, + "button", + "button", + GURL("http://www.google.com"), + bubble_type) {} MockPermissionBubbleRequest::MockPermissionBubbleRequest( const std::string& text, const GURL& url) - : granted_(false), - cancelled_(false), - finished_(false) { - text_ = base::UTF8ToUTF16(text); - accept_label_ = base::ASCIIToUTF16("button"); - deny_label_ = base::ASCIIToUTF16("button"); - origin_ = url.GetOrigin(); -} + : MockPermissionBubbleRequest(text, + "button", + "button", + url, + PermissionBubbleType::UNKNOWN) {} MockPermissionBubbleRequest::MockPermissionBubbleRequest( const std::string& text, const std::string& accept_label, const std::string& deny_label) - : granted_(false), - cancelled_(false), - finished_(false) { - text_ = base::UTF8ToUTF16(text); - accept_label_ = base::UTF8ToUTF16(accept_label); - deny_label_ = base::UTF8ToUTF16(deny_label); - origin_ = GURL("http://www.google.com"); -} + : MockPermissionBubbleRequest(text, + accept_label, + deny_label, + GURL("http://www.google.com"), + PermissionBubbleType::UNKNOWN) {} MockPermissionBubbleRequest::~MockPermissionBubbleRequest() {} @@ -86,6 +82,11 @@ finished_ = true; } +PermissionBubbleType MockPermissionBubbleRequest::GetPermissionBubbleType() + const { + return bubble_type_; +} + bool MockPermissionBubbleRequest::granted() { return granted_; } @@ -98,3 +99,18 @@ return finished_; } +MockPermissionBubbleRequest::MockPermissionBubbleRequest( + const std::string& text, + const std::string& accept_label, + const std::string& deny_label, + const GURL& origin, + PermissionBubbleType bubble_type) + : granted_(false), + cancelled_(false), + finished_(false), + bubble_type_(bubble_type) { + text_ = base::UTF8ToUTF16(text); + accept_label_ = base::UTF8ToUTF16(accept_label); + deny_label_ = base::UTF8ToUTF16(deny_label); + origin_ = origin.GetOrigin(); +}
diff --git a/chrome/browser/ui/website_settings/mock_permission_bubble_request.h b/chrome/browser/ui/website_settings/mock_permission_bubble_request.h index 424c403..38f27b8 100644 --- a/chrome/browser/ui/website_settings/mock_permission_bubble_request.h +++ b/chrome/browser/ui/website_settings/mock_permission_bubble_request.h
@@ -13,11 +13,13 @@ public: MockPermissionBubbleRequest(); explicit MockPermissionBubbleRequest(const std::string& text); - explicit MockPermissionBubbleRequest(const std::string& text, - const GURL& url); - explicit MockPermissionBubbleRequest(const std::string& text, - const std::string& accept_label, - const std::string& deny_label); + MockPermissionBubbleRequest(const std::string& text, + PermissionBubbleType bubble_type); + MockPermissionBubbleRequest(const std::string& text, const GURL& url); + MockPermissionBubbleRequest(const std::string& text, + const std::string& accept_label, + const std::string& deny_label); + ~MockPermissionBubbleRequest() override; int GetIconId() const override; @@ -28,15 +30,22 @@ void PermissionDenied() override; void Cancelled() override; void RequestFinished() override; + PermissionBubbleType GetPermissionBubbleType() const override; bool granted(); bool cancelled(); bool finished(); private: + MockPermissionBubbleRequest(const std::string& text, + const std::string& accept_label, + const std::string& deny_label, + const GURL& url, + PermissionBubbleType bubble_type); bool granted_; bool cancelled_; bool finished_; + PermissionBubbleType bubble_type_; base::string16 text_; base::string16 accept_label_;
diff --git a/chrome/browser/ui/website_settings/permission_bubble_manager.cc b/chrome/browser/ui/website_settings/permission_bubble_manager.cc index c093ab42..a0ccb8fb 100644 --- a/chrome/browser/ui/website_settings/permission_bubble_manager.cc +++ b/chrome/browser/ui/website_settings/permission_bubble_manager.cc
@@ -144,7 +144,6 @@ if (is_main_frame) { requests_.push_back(request); - // TODO(gbillock): do we need to make default state a request property? accept_states_.push_back(true); } else { content::RecordAction( @@ -310,6 +309,8 @@ } void PermissionBubbleManager::Accept() { + PermissionUmaUtil::PermissionPromptAccepted(requests_, accept_states_); + std::vector<PermissionBubbleRequest*>::iterator requests_iter; std::vector<bool>::iterator accepts_iter = accept_states_.begin(); for (requests_iter = requests_.begin(), accepts_iter = accept_states_.begin(); @@ -325,6 +326,8 @@ } void PermissionBubbleManager::Deny() { + PermissionUmaUtil::PermissionPromptDenied(requests_); + std::vector<PermissionBubbleRequest*>::iterator requests_iter; for (requests_iter = requests_.begin(); requests_iter != requests_.end(); @@ -376,9 +379,6 @@ requests_.swap(queued_frame_requests_); // Sets the default value for each request to be 'accept'. - // TODO(leng): Currently all requests default to true. If that changes: - // a) Add additional accept_state queues to store default values. - // b) Change the request API to provide the default value. accept_states_.resize(requests_.size(), true); }
diff --git a/chrome/browser/ui/website_settings/permission_bubble_manager_unittest.cc b/chrome/browser/ui/website_settings/permission_bubble_manager_unittest.cc index ae72ce6b..9629d0a 100644 --- a/chrome/browser/ui/website_settings/permission_bubble_manager_unittest.cc +++ b/chrome/browser/ui/website_settings/permission_bubble_manager_unittest.cc
@@ -8,6 +8,8 @@ #include "base/command_line.h" #include "base/message_loop/message_loop.h" #include "base/strings/utf_string_conversions.h" +#include "base/test/histogram_tester.h" +#include "chrome/browser/permissions/permission_uma_util.h" #include "chrome/browser/ui/website_settings/mock_permission_bubble_factory.h" #include "chrome/browser/ui/website_settings/mock_permission_bubble_request.h" #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" @@ -20,8 +22,8 @@ public: PermissionBubbleManagerTest() : ChromeRenderViewHostTestHarness(), - request1_("test1"), - request2_("test2"), + request1_("test1", PermissionBubbleType::QUOTA), + request2_("test2", PermissionBubbleType::DOWNLOAD), iframe_request_same_domain_("iframe", GURL("http://www.google.com/some/url")), iframe_request_other_domain_("iframe", @@ -51,6 +53,10 @@ manager_->Accept(); } + void Deny() { + manager_->Deny(); + } + void Closing() { manager_->Closing(); } @@ -447,3 +453,154 @@ EXPECT_TRUE(view_factory_->is_visible()); } + +TEST_F(PermissionBubbleManagerTest, UMAForSimpleAcceptedBubble) { + base::HistogramTester histograms; + + manager_->AddRequest(&request1_); + manager_->DisplayPendingRequests(); + WaitForCoalescing(); + histograms.ExpectUniqueSample( + PermissionUmaUtil::kPermissionsPromptShown, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::QUOTA), + 1); + histograms.ExpectUniqueSample( + PermissionUmaUtil::kPermissionsPromptRequestsPerPrompt, 1, 1); + + ToggleAccept(0, true); + Accept(); + histograms.ExpectUniqueSample( + PermissionUmaUtil::kPermissionsPromptAccepted, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::QUOTA), 1); +} + +TEST_F(PermissionBubbleManagerTest, UMAForSimpleDeniedBubble) { + base::HistogramTester histograms; + + manager_->AddRequest(&request1_); + manager_->DisplayPendingRequests(); + WaitForCoalescing(); + // No need to test UMA for showing prompts again, they were tested in + // UMAForSimpleAcceptedBubble. + + Deny(); + histograms.ExpectUniqueSample( + PermissionUmaUtil::kPermissionsPromptDenied, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::QUOTA), 1); +} + +// This code path (calling Accept on a non-merged bubble, with no accepted +// permission) would never be used in actual Chrome, but its still tested for +// completeness. +TEST_F(PermissionBubbleManagerTest, UMAForSimpleDeniedBubbleAlternatePath) { + base::HistogramTester histograms; + + manager_->AddRequest(&request1_); + manager_->DisplayPendingRequests(); + WaitForCoalescing(); + // No need to test UMA for showing prompts again, they were tested in + // UMAForSimpleAcceptedBubble. + + ToggleAccept(0, false); + Accept(); + histograms.ExpectUniqueSample( + PermissionUmaUtil::kPermissionsPromptDenied, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::QUOTA), 1); +} + +TEST_F(PermissionBubbleManagerTest, UMAForMergedAcceptedBubble) { + base::HistogramTester histograms; + + manager_->AddRequest(&request1_); + manager_->AddRequest(&request2_); + manager_->DisplayPendingRequests(); + WaitForCoalescing(); + + histograms.ExpectUniqueSample( + PermissionUmaUtil::kPermissionsPromptShown, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::MULTIPLE), + 1); + histograms.ExpectBucketCount( + PermissionUmaUtil::kPermissionsPromptMergedBubbleTypes, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::QUOTA), + 1); + histograms.ExpectBucketCount( + PermissionUmaUtil::kPermissionsPromptMergedBubbleTypes, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::DOWNLOAD), + 1); + histograms.ExpectUniqueSample( + PermissionUmaUtil::kPermissionsPromptRequestsPerPrompt, 2, 1); + + ToggleAccept(0, true); + ToggleAccept(1, true); + Accept(); + + histograms.ExpectUniqueSample( + PermissionUmaUtil::kPermissionsPromptAccepted, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::MULTIPLE), + 1); + histograms.ExpectBucketCount( + PermissionUmaUtil::kPermissionsPromptMergedBubbleAccepted, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::QUOTA), + 1); + histograms.ExpectBucketCount( + PermissionUmaUtil::kPermissionsPromptMergedBubbleAccepted, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::DOWNLOAD), + 1); +} + +TEST_F(PermissionBubbleManagerTest, UMAForMergedMixedBubble) { + base::HistogramTester histograms; + + manager_->AddRequest(&request1_); + manager_->AddRequest(&request2_); + manager_->DisplayPendingRequests(); + WaitForCoalescing(); + // No need to test UMA for showing prompts again, they were tested in + // UMAForMergedAcceptedBubble. + + ToggleAccept(0, true); + ToggleAccept(1, false); + Accept(); + + histograms.ExpectUniqueSample( + PermissionUmaUtil::kPermissionsPromptDenied, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::MULTIPLE), + 1); + histograms.ExpectBucketCount( + PermissionUmaUtil::kPermissionsPromptMergedBubbleAccepted, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::QUOTA), + 1); + histograms.ExpectBucketCount( + PermissionUmaUtil::kPermissionsPromptMergedBubbleDenied, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::DOWNLOAD), + 1); +} + +TEST_F(PermissionBubbleManagerTest, UMAForMergedDeniedBubble) { + base::HistogramTester histograms; + + manager_->AddRequest(&request1_); + manager_->AddRequest(&request2_); + manager_->DisplayPendingRequests(); + WaitForCoalescing(); + // No need to test UMA for showing prompts again, they were tested in + // UMAForMergedAcceptedBubble. + + ToggleAccept(0, false); + ToggleAccept(1, false); + Accept(); + + histograms.ExpectUniqueSample( + PermissionUmaUtil::kPermissionsPromptDenied, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::MULTIPLE), + 1); + histograms.ExpectBucketCount( + PermissionUmaUtil::kPermissionsPromptMergedBubbleDenied, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::QUOTA), + 1); + histograms.ExpectBucketCount( + PermissionUmaUtil::kPermissionsPromptMergedBubbleDenied, + static_cast<base::HistogramBase::Sample>(PermissionBubbleType::DOWNLOAD), + 1); +}
diff --git a/chrome/browser/ui/website_settings/permission_ui_uma_util.cc b/chrome/browser/ui/website_settings/permission_ui_uma_util.cc deleted file mode 100644 index b97b05f..0000000 --- a/chrome/browser/ui/website_settings/permission_ui_uma_util.cc +++ /dev/null
@@ -1,19 +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. - -#include "chrome/browser/ui/website_settings/permission_ui_uma_util.h" - -#include "base/metrics/histogram_macros.h" -#include "chrome/browser/ui/website_settings/permission_bubble_request.h" - -void PermissionUiUmaUtil::PermissionPromptShown( - const std::vector<PermissionBubbleRequest*>& requests) { - PermissionBubbleType permission_prompt_type = PermissionBubbleType::MULTIPLE; - if (requests.size() == 1) - permission_prompt_type = requests[0]->GetPermissionBubbleType(); - UMA_HISTOGRAM_ENUMERATION( - "Permissions.Prompt.Shown", - static_cast<base::HistogramBase::Sample>(permission_prompt_type), - static_cast<base::HistogramBase::Sample>(PermissionBubbleType::NUM)); -}
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc index c665f6f..4c077679 100644 --- a/chrome/browser/ui/webui/options/browser_options_handler.cc +++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -12,12 +12,12 @@ #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/environment.h" +#include "base/i18n/number_formatting.h" #include "base/macros.h" #include "base/memory/singleton.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/stl_util.h" -#include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/value_conversions.h" #include "base/values.h" @@ -1999,8 +1999,7 @@ base::ListValue* option = new base::ListValue(); double factor = *i; int percent = static_cast<int>(factor * 100 + 0.5); - option->Append(new base::StringValue( - l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, percent))); + option->Append(new base::StringValue(base::FormatPercent(percent))); option->Append(new base::FundamentalValue(factor)); bool selected = content::ZoomValuesEqual(factor, default_zoom_factor); option->Append(new base::FundamentalValue(selected));
diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc index 6b8ed61..139e914 100644 --- a/chrome/browser/ui/webui/options/content_settings_handler.cc +++ b/chrome/browser/ui/webui/options/content_settings_handler.cc
@@ -13,11 +13,11 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" +#include "base/i18n/number_formatting.h" #include "base/logging.h" #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/stl_util.h" -#include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "build/build_config.h" @@ -1189,10 +1189,7 @@ // number. int zoom_percent = static_cast<int>( content::ZoomLevelToZoomFactor(i->zoom_level) * 100 + 0.5); - exception->SetString( - kZoom, - l10n_util::GetStringFUTF16(IDS_ZOOM_PERCENT, - base::IntToString16(zoom_percent))); + exception->SetString(kZoom, base::FormatPercent(zoom_percent)); exception->SetString( site_settings::kSource, site_settings::kPreferencesSource); // Append the new entry to the list and map.
diff --git a/chrome/common/chrome_features.cc b/chrome/common/chrome_features.cc index a0f1f59..9be348de 100644 --- a/chrome/common/chrome_features.cc +++ b/chrome/common/chrome_features.cc
@@ -39,6 +39,12 @@ const base::Feature kExperimentalKeyboardLockUI{ "ExperimentalKeyboardLockUI", base::FEATURE_DISABLED_BY_DEFAULT}; +#if defined (OS_CHROMEOS) +// Enables or disables the Happininess Tracking System for the device. +const base::Feature kHappininessTrackingSystem { + "HappininessTrackingSystem", base::FEATURE_DISABLED_BY_DEFAULT}; +#endif + #if defined(GOOGLE_CHROME_BUILD) && defined(OS_LINUX) && !defined(OS_CHROMEOS) // Enables showing the "This computer will no longer receive Google Chrome // updates" infobar instead of the "will soon stop receiving" infobar on
diff --git a/chrome/common/chrome_features.h b/chrome/common/chrome_features.h index fe2be68d..f968b12d 100644 --- a/chrome/common/chrome_features.h +++ b/chrome/common/chrome_features.h
@@ -31,6 +31,10 @@ extern const base::Feature kExperimentalKeyboardLockUI; +#if defined(OS_CHROMEOS) +extern const base::Feature kHappininessTrackingSystem; +#endif + #if defined(GOOGLE_CHROME_BUILD) && defined(OS_LINUX) && !defined(OS_CHROMEOS) extern const base::Feature kLinuxObsoleteSystemIsEndOfTheLine; #endif
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index a37e405..5165238 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc
@@ -293,6 +293,11 @@ // for blacklisted sites. const char kDisablePermissionsBlacklist[] = "disable-permissions-blacklist"; +// Disables permission action reporting to Safe Browsing servers for opted in +// users. +const char kDisablePermissionActionReporting[] = + "disable-permission-action-reporting"; + // Disable pop-up blocking. const char kDisablePopupBlocking[] = "disable-popup-blocking"; @@ -463,6 +468,11 @@ // for blacklisted sites. const char kEnablePermissionsBlacklist[] = "enable-permissions-blacklist"; +// Enables permission action reporting to Safe Browsing servers for opted in +// users. +const char kEnablePermissionActionReporting[] = + "enable-permission-action-reporting"; + // Enables a number of potentially annoying security features (strict mixed // content mode, powerful feature restrictions, etc.) const char kEnablePotentiallyAnnoyingSecurityFeatures[] =
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 3b2240bdb..7810996 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h
@@ -88,6 +88,7 @@ extern const char kDisableOfflineAutoReloadVisibleOnly[]; extern const char kDisableOutOfProcessPac[]; extern const char kDisablePasswordManagerReauthentication[]; +extern const char kDisablePermissionActionReporting[]; extern const char kDisablePermissionsBlacklist[]; extern const char kDisablePopupBlocking[]; extern const char kDisablePreconnect[]; @@ -142,6 +143,7 @@ extern const char kEnableOfflineAutoReloadVisibleOnly[]; extern const char kEnablePanels[]; extern const char kDisablePanels[]; +extern const char kEnablePermissionActionReporting[]; extern const char kEnablePermissionsBlacklist[]; extern const char kEnablePotentiallyAnnoyingSecurityFeatures[]; extern const char kEnablePowerOverlay[];
diff --git a/chrome/common/extensions/api/file_manager_private.idl b/chrome/common/extensions/api/file_manager_private.idl index 1f9248643..fef52e9 100644 --- a/chrome/common/extensions/api/file_manager_private.idl +++ b/chrome/common/extensions/api/file_manager_private.idl
@@ -184,6 +184,15 @@ system }; +// File handler verbs used to describe the action that an extension performs +// over a file or directory. +enum Verb { + open_with, + add_to, + pack_with, + share_with +}; + // A file task represents an action that the file manager can perform over the // currently selected files. See // chrome/browser/chromeos/extensions/file_manager/file_tasks.h for details @@ -195,6 +204,10 @@ // Task title (ex. App name). DOMString title; + // The verb that will be used to indicate the action a task performs over + // a file (ex. "open_with"). + Verb? verb; + // Task icon url (from chrome://extension-icon/...) DOMString iconUrl;
diff --git a/chrome/test/data/extensions/api_test/file_browser/app_file_handler_multi/manifest.json b/chrome/test/data/extensions/api_test/file_browser/app_file_handler_multi/manifest.json index 8fde887..1b42012 100644 --- a/chrome/test/data/extensions/api_test/file_browser/app_file_handler_multi/manifest.json +++ b/chrome/test/data/extensions/api_test/file_browser/app_file_handler_multi/manifest.json
@@ -13,6 +13,7 @@ "file_handlers": { "textAction": { "extensions": ["txt"], + "verb": "add_to", "include_directories": true } },
diff --git a/chrome/test/data/extensions/api_test/file_browser/app_file_handler_multi/test.js b/chrome/test/data/extensions/api_test/file_browser/app_file_handler_multi/test.js index 4dd2c99..ad0ea2bb 100644 --- a/chrome/test/data/extensions/api_test/file_browser/app_file_handler_multi/test.js +++ b/chrome/test/data/extensions/api_test/file_browser/app_file_handler_multi/test.js
@@ -166,6 +166,8 @@ chrome.fileManagerPrivate.getFileTasks(entries, fulfill); }).then(function(tasks) { chrome.test.assertEq(1, tasks.length); + chrome.test.assertEq("ChromeOS File handler extension", + tasks[0].title); chrome.test.assertEq( 'pkplfbidichfdicaijlchgnapepdginl|app|textAction', tasks[0].taskId);
diff --git a/components/arc/arc_service_manager.cc b/components/arc/arc_service_manager.cc index ef3ac77..4ef7122 100644 --- a/components/arc/arc_service_manager.cc +++ b/components/arc/arc_service_manager.cc
@@ -15,6 +15,7 @@ #include "components/arc/clipboard/arc_clipboard_bridge.h" #include "components/arc/crash_collector/arc_crash_collector_bridge.h" #include "components/arc/ime/arc_ime_service.h" +#include "components/arc/intent_helper/activity_icon_loader.h" #include "components/arc/intent_helper/arc_intent_helper_bridge.h" #include "components/arc/metrics/arc_metrics_service.h" #include "components/arc/net/arc_net_host_impl.h" @@ -56,7 +57,9 @@ AddService( base::WrapUnique(new ArcCrashCollectorBridge(arc_bridge_service()))); AddService(base::WrapUnique(new ArcImeService(arc_bridge_service()))); - AddService(base::WrapUnique(new ArcIntentHelperBridge(arc_bridge_service()))); + icon_loader_ = new ActivityIconLoader; + AddService(base::WrapUnique( + new ArcIntentHelperBridge(arc_bridge_service(), icon_loader_))); AddService(base::WrapUnique(new ArcMetricsService(arc_bridge_service()))); AddService(base::WrapUnique(new ArcNetHostImpl(arc_bridge_service()))); AddService(base::WrapUnique(new ArcObbMounterBridge(arc_bridge_service()))); @@ -111,6 +114,7 @@ } void ArcServiceManager::Shutdown() { + icon_loader_ = nullptr; services_.clear(); }
diff --git a/components/arc/arc_service_manager.h b/components/arc/arc_service_manager.h index 3dd7740..383ed47 100644 --- a/components/arc/arc_service_manager.h +++ b/components/arc/arc_service_manager.h
@@ -12,6 +12,7 @@ #include "base/memory/ref_counted.h" #include "base/task_runner.h" #include "base/threading/thread_checker.h" +#include "components/arc/intent_helper/activity_icon_loader.h" #include "components/signin/core/account_id/account_id.h" namespace arc { @@ -56,12 +57,16 @@ static void SetArcBridgeServiceForTesting( std::unique_ptr<ArcBridgeService> arc_bridge_service); + // Returns the icon loader owned by ArcServiceManager and shared by services. + scoped_refptr<ActivityIconLoader> icon_loader() { return icon_loader_; } + private: base::ThreadChecker thread_checker_; scoped_refptr<base::TaskRunner> blocking_task_runner_; std::unique_ptr<ArcBridgeService> arc_bridge_service_; std::vector<std::unique_ptr<ArcService>> services_; + scoped_refptr<ActivityIconLoader> icon_loader_; // True once the window manager service got added, barring adding any more // of those since OnAshStarted() might be called multiple times.
diff --git a/components/arc/intent_helper/activity_icon_loader.cc b/components/arc/intent_helper/activity_icon_loader.cc index 0927cc0..8e2495c 100644 --- a/components/arc/intent_helper/activity_icon_loader.cc +++ b/components/arc/intent_helper/activity_icon_loader.cc
@@ -13,6 +13,7 @@ #include "base/task_runner_util.h" #include "components/arc/arc_bridge_service.h" #include "components/arc/arc_service_manager.h" +#include "ui/base/layout.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia_operations.h" @@ -45,6 +46,12 @@ return intent_helper_instance; } +ui::ScaleFactor GetSupportedScaleFactor() { + std::vector<ui::ScaleFactor> scale_factors = ui::GetSupportedScaleFactors(); + DCHECK(!scale_factors.empty()); + return scale_factors.back(); +} + } // namespace ActivityIconLoader::Icons::Icons(const gfx::Image& icon16, @@ -61,8 +68,8 @@ std::tie(other.package_name, other.activity_name); } -ActivityIconLoader::ActivityIconLoader(ui::ScaleFactor scale_factor) - : scale_factor_(scale_factor) {} +ActivityIconLoader::ActivityIconLoader() + : scale_factor_(GetSupportedScaleFactor()) {} ActivityIconLoader::~ActivityIconLoader() {}
diff --git a/components/arc/intent_helper/activity_icon_loader.h b/components/arc/intent_helper/activity_icon_loader.h index f4e4537..f66ec30 100644 --- a/components/arc/intent_helper/activity_icon_loader.h +++ b/components/arc/intent_helper/activity_icon_loader.h
@@ -44,7 +44,7 @@ using OnIconsReadyCallback = base::Callback<void(std::unique_ptr<ActivityToIconsMap>)>; - explicit ActivityIconLoader(ui::ScaleFactor scale_factor); + ActivityIconLoader(); // Removes icons associated with |package_name| from the cache. void InvalidateIcons(const std::string& package_name);
diff --git a/components/arc/intent_helper/activity_icon_loader_unittest.cc b/components/arc/intent_helper/activity_icon_loader_unittest.cc index 31410193..4504e0d 100644 --- a/components/arc/intent_helper/activity_icon_loader_unittest.cc +++ b/components/arc/intent_helper/activity_icon_loader_unittest.cc
@@ -51,8 +51,7 @@ // Tests if InvalidateIcons properly cleans up the cache. TEST(ActivityIconLoaderTest, TestInvalidateIcons) { - scoped_refptr<ActivityIconLoader> loader( - new ActivityIconLoader(ui::SCALE_FACTOR_100P)); + scoped_refptr<ActivityIconLoader> loader(new ActivityIconLoader); loader->AddIconToCacheForTesting(ActivityIconLoader::ActivityName("p0", "a0"), gfx::Image()); loader->AddIconToCacheForTesting(ActivityIconLoader::ActivityName("p0", "a1"), @@ -76,8 +75,7 @@ // Tests if GetActivityIcons immediately returns cached icons. TEST(ActivityIconLoaderTest, TestGetActivityIcons) { - scoped_refptr<ActivityIconLoader> loader( - new ActivityIconLoader(ui::SCALE_FACTOR_100P)); + scoped_refptr<ActivityIconLoader> loader(new ActivityIconLoader); loader->AddIconToCacheForTesting(ActivityIconLoader::ActivityName("p0", "a0"), gfx::Image()); loader->AddIconToCacheForTesting(ActivityIconLoader::ActivityName("p1", "a1"), @@ -106,8 +104,7 @@ // Tests if OnIconsResized updates the cache. TEST(ActivityIconLoaderTest, TestOnIconsResized) { - scoped_refptr<ActivityIconLoader> loader( - new ActivityIconLoader(ui::SCALE_FACTOR_100P)); + scoped_refptr<ActivityIconLoader> loader(new ActivityIconLoader); std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> activity_to_icons( new ActivityIconLoader::ActivityToIconsMap); activity_to_icons->insert(
diff --git a/components/arc/intent_helper/arc_intent_helper_bridge.cc b/components/arc/intent_helper/arc_intent_helper_bridge.cc index dc314d6..0e55e8f 100644 --- a/components/arc/intent_helper/arc_intent_helper_bridge.cc +++ b/components/arc/intent_helper/arc_intent_helper_bridge.cc
@@ -17,20 +17,10 @@ namespace arc { -namespace { - -ui::ScaleFactor GetSupportedScaleFactor() { - std::vector<ui::ScaleFactor> scale_factors = ui::GetSupportedScaleFactors(); - DCHECK(!scale_factors.empty()); - return scale_factors.back(); -} - -} // namespace - -ArcIntentHelperBridge::ArcIntentHelperBridge(ArcBridgeService* bridge_service) - : ArcService(bridge_service), - binding_(this), - icon_loader_(new ActivityIconLoader(GetSupportedScaleFactor())) { +ArcIntentHelperBridge::ArcIntentHelperBridge( + ArcBridgeService* bridge_service, + const scoped_refptr<ActivityIconLoader>& icon_loader) + : ArcService(bridge_service), binding_(this), icon_loader_(icon_loader) { arc_bridge_service()->AddObserver(this); }
diff --git a/components/arc/intent_helper/arc_intent_helper_bridge.h b/components/arc/intent_helper/arc_intent_helper_bridge.h index 1469892..95f80c0 100644 --- a/components/arc/intent_helper/arc_intent_helper_bridge.h +++ b/components/arc/intent_helper/arc_intent_helper_bridge.h
@@ -31,7 +31,8 @@ public mojom::IntentHelperHost, public ash::LinkHandlerModelFactory { public: - explicit ArcIntentHelperBridge(ArcBridgeService* bridge_service); + ArcIntentHelperBridge(ArcBridgeService* bridge_service, + const scoped_refptr<ActivityIconLoader>& icon_loader); ~ArcIntentHelperBridge() override; // ArcBridgeService::Observer
diff --git a/components/drive/DEPS b/components/drive/DEPS index 5586c3bf..c23c40e 100644 --- a/components/drive/DEPS +++ b/components/drive/DEPS
@@ -14,7 +14,7 @@ # directory chrome/ and content/ and storage/ independent. # crbug.com/257943 "drive_uploader\.cc": [ - "+content/public/browser/power_save_blocker_factory.h", + "+content/public/browser/power_save_blocker.h", ], # The following test dependencies should be removed to fully componentize this
diff --git a/components/drive/drive_uploader.cc b/components/drive/drive_uploader.cc index e8b0c53..2253c82 100644 --- a/components/drive/drive_uploader.cc +++ b/components/drive/drive_uploader.cc
@@ -15,7 +15,7 @@ #include "base/strings/string_number_conversions.h" #include "base/task_runner_util.h" #include "components/drive/service/drive_service_interface.h" -#include "content/public/browser/power_save_blocker_factory.h" +#include "content/public/browser/power_save_blocker.h" #include "google_apis/drive/drive_api_parser.h" using google_apis::CancelCallback; @@ -98,7 +98,7 @@ progress_callback(progress_callback), content_length(0), next_start_position(-1), - power_save_blocker(content::CreatePowerSaveBlocker( + power_save_blocker(content::PowerSaveBlocker::Create( content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, content::PowerSaveBlocker::kReasonOther, "Upload in progress")),
diff --git a/components/metrics/file_metrics_provider.cc b/components/metrics/file_metrics_provider.cc index 5a6c14a..a1c560d43 100644 --- a/components/metrics/file_metrics_provider.cc +++ b/components/metrics/file_metrics_provider.cc
@@ -52,13 +52,18 @@ bool read_complete = false; // Once a file has been recognized as needing to be read, it is |mapped| - // into memory. If that file is "atomic" then the data from that file - // will be copied to |data| and the mapped file released. If the file is - // "active", it remains mapped and nothing is copied to local memory. + // into memory. The contents of that file may be copied to local |data| + // so that access to it does not cause disk I/O. std::vector<uint8_t> data; std::unique_ptr<base::MemoryMappedFile> mapped; std::unique_ptr<base::PersistentHistogramAllocator> allocator; + // Once a file has been processed, the actual releasing of the file must + // be done on a thread capable of doing file I/O. These fields hold the + // previously active objects that are to be released when possible. + std::unique_ptr<base::MemoryMappedFile> mapped_to_release; + std::unique_ptr<base::PersistentHistogramAllocator> allocator_to_release; + private: DISALLOW_COPY_AND_ASSIGN(SourceInfo); }; @@ -130,6 +135,15 @@ UMA_HISTOGRAM_ENUMERATION( "UMA.FileMetricsProvider.AccessResult", result, ACCESS_RESULT_MAX); } + + switch (source->type) { + case SOURCE_HISTOGRAMS_ATOMIC_FILE: + case SOURCE_HISTOGRAMS_ATOMIC_DIR: + // Remove the file if it's already been seen. + if (result == ACCESS_RESULT_NOT_MODIFIED) + base::DeleteFile(source->path, /*recursive=*/false); + break; + } } } @@ -139,11 +153,19 @@ FileMetricsProvider::AccessResult FileMetricsProvider::CheckAndMapNewMetrics( SourceInfo* source) { DCHECK(!source->mapped); - DCHECK(source->data.empty()); + DCHECK(!source->allocator); + // Release any resources from a previous run. + source->mapped_to_release.reset(); + source->allocator_to_release.reset(); + source->data.clear(); + source->read_complete = false; + + // If the source is a directory, look for files within it. if (!source->directory.empty() && !LocateNextFileInDirectory(source)) return ACCESS_RESULT_DOESNT_EXIST; + // Do basic validation on the file metadata. base::File::Info info; if (!base::GetFileInfo(source->path, &info)) return ACCESS_RESULT_DOESNT_EXIST; @@ -155,11 +177,13 @@ return ACCESS_RESULT_NOT_MODIFIED; // A new file of metrics has been found. Open it with exclusive access and - // map it into memory. + // map it into memory. The file is opened with "share delete" so it can + // be later deleted while still open. // TODO(bcwhite): Make this open read/write when supported for "active". base::File file(source->path, base::File::FLAG_OPEN | base::File::FLAG_READ | - base::File::FLAG_EXCLUSIVE_READ); + base::File::FLAG_EXCLUSIVE_READ | + base::File::FLAG_SHARE_DELETE); if (!file.IsValid()) return ACCESS_RESULT_NO_EXCLUSIVE_OPEN; source->mapped.reset(new base::MemoryMappedFile()); @@ -172,24 +196,27 @@ source->last_seen = info.last_modified; // Test the validity of the file contents. - if (!base::FilePersistentMemoryAllocator::IsFileAcceptable(*source->mapped)) + if (!base::FilePersistentMemoryAllocator::IsFileAcceptable(*source->mapped)) { + source->mapped.reset(); return ACCESS_RESULT_INVALID_CONTENTS; + } switch (source->type) { case SOURCE_HISTOGRAMS_ATOMIC_FILE: case SOURCE_HISTOGRAMS_ATOMIC_DIR: - // For an "atomic" file, immediately copy the data into local memory - // and release the file so that it is not held open. + // For an "atomic" file, copy the data into local memory but don't + // release the file so that it is held open to prevent access by other + // processes. The copy means all I/O is done on this thread instead of + // the thread processing the data. source->data.assign(source->mapped->data(), source->mapped->data() + source->mapped->length()); - source->mapped.reset(); break; } - source->read_complete = false; return ACCESS_RESULT_SUCCESS; } +// static bool FileMetricsProvider::LocateNextFileInDirectory(SourceInfo* source) { DCHECK_EQ(SOURCE_HISTOGRAMS_ATOMIC_DIR, source->type); DCHECK(!source->directory.empty()); @@ -261,6 +288,22 @@ return true; } +// static +void FileMetricsProvider::DeleteFileWhenPossible(const base::FilePath& path) { +#if defined(OS_WIN) + // Windows won't allow an open file to be removed from the filesystem so + // schedule the file to be deleted as soon as it is closed. No access flag + // (eg. FLAG_READ) is given as it would fail because the original read was + // exclusive. + base::File file(path, base::File::FLAG_OPEN | + base::File::FLAG_DELETE_ON_CLOSE); +#else + // Posix won't allow opening a file without some access flag (eg. FLAG_READ) + // but will allow one to be removed while open. Delete it the typical way. + base::DeleteFile(path, /*recursive=*/false); +#endif +} + void FileMetricsProvider::ScheduleSourcesCheck() { DCHECK(thread_checker_.CalledOnValidThread()); if (sources_to_check_.empty()) @@ -311,20 +354,23 @@ } void FileMetricsProvider::CreateAllocatorForSource(SourceInfo* source) { + DCHECK(source->mapped); DCHECK(!source->allocator); // File data was validated earlier. Files are not considered "untrusted" // as some processes might be (e.g. Renderer) so there's no need to check // again to try to thwart some malicious actor that may have modified the // data between then and now. - if (source->mapped) { - DCHECK(source->data.empty()); + if (source->data.empty()) { + // Data hasn't been copied into memory. Create the allocator directly + // on the memory-mapped file. // TODO(bcwhite): Make this do read/write when supported for "active". source->allocator.reset(new base::PersistentHistogramAllocator( base::WrapUnique(new base::FilePersistentMemoryAllocator( std::move(source->mapped), 0, "")))); } else { - DCHECK(!source->mapped); + // Data was copied from the mapped file into memory. Create an allocator + // on the copy thus eliminating disk I/O during data access. source->allocator.reset(new base::PersistentHistogramAllocator( base::WrapUnique(new base::PersistentMemoryAllocator( &source->data[0], source->data.size(), 0, 0, "", true)))); @@ -339,22 +385,50 @@ for (auto iter = checked->begin(); iter != checked->end();) { auto temp = iter++; const SourceInfo* source = temp->get(); - if (source->mapped || !source->data.empty()) + if (source->mapped) sources_to_read_.splice(sources_to_read_.end(), *checked, temp); else sources_to_check_.splice(sources_to_check_.end(), *checked, temp); } } -void FileMetricsProvider::RecordSourceAsSeen(SourceInfo* source) { +void FileMetricsProvider::RecordSourceAsRead(SourceInfo* source) { DCHECK(thread_checker_.CalledOnValidThread()); source->read_complete = true; + + // Persistently record the "last seen" timestamp of the source file to + // ensure that the file is never read again unless it is modified again. if (pref_service_ && !source->prefs_key.empty()) { pref_service_->SetInt64( metrics::prefs::kMetricsLastSeenPrefix + source->prefs_key, source->last_seen.ToInternalValue()); } + + switch (source->type) { + case SOURCE_HISTOGRAMS_ATOMIC_FILE: + case SOURCE_HISTOGRAMS_ATOMIC_DIR: + // The actual release of the data is delayed until the next sources- + // check so that the data remains valid in memory until it is fully + // processed by the caller. These will be released during the next + // ScheduleSourcesCheck() started by OnDidCreateMetricsLog() as soon + // as the data is uploaded. This is also necessary because unmapping + // must be done on a thread capable of file I/O. + source->mapped_to_release = std::move(source->mapped); + source->allocator_to_release = std::move(source->allocator); + + // Schedule the deletion of the file now that the data has been sent. + // While recording the last-modified time prevents this process from + // re-reading the data, deleting the file prevents other processes + // (such as those with different profile directories or those run by + // other users on the machine) from also reporting the contents of the + // file. + task_runner_->PostTask( + FROM_HERE, + base::Bind(&FileMetricsProvider::DeleteFileWhenPossible, + source->path)); + break; + } } void FileMetricsProvider::OnDidCreateMetricsLog() { @@ -365,19 +439,11 @@ auto temp = iter++; SourceInfo* source = temp->get(); - switch (source->type) { - // Atomic files are read once and then ignored unless they change. - case SOURCE_HISTOGRAMS_ATOMIC_FILE: - case SOURCE_HISTOGRAMS_ATOMIC_DIR: - if (source->read_complete) { - DCHECK(!source->mapped); - source->allocator.reset(); - source->data.clear(); - } - break; - } - - if (!source->allocator && !source->mapped && source->data.empty()) + // The file has been fully processed once it is no longer "mapped" (even + // though it may still be "mapped to release"). In practice, this only + // happens with "atomic" files since "active" files may always acquire + // more data to process. + if (!source->mapped) sources_to_check_.splice(sources_to_check_.end(), sources_to_read_, temp); } @@ -426,10 +492,12 @@ // If it couldn't be accessed, remove it from the list. There is only ever // one chance to record it so no point keeping it around for later. Also // mark it as having been read since uploading it with a future browser - // run would associate it with the previous run which would no longer be - // the run from which it came. + // run would associate it with the then-previous run which would no longer + // be the run from which it came. if (result != ACCESS_RESULT_SUCCESS) { - RecordSourceAsSeen(source); + DCHECK(!source->mapped); + DCHECK(!source->allocator); + RecordSourceAsRead(source); sources_for_previous_run_.erase(temp); } } @@ -453,24 +521,16 @@ SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.File"); - // If the source is mapped or loaded then it needs to have an allocator - // attached to it in order to read histograms out of it. - if (source->mapped || !source->data.empty()) - CreateAllocatorForSource(source.get()); - - // A source should not be under "sources to read" unless it has an allocator - // or is memory-mapped (at which point it will have received an allocator - // above). However, if this method gets called twice before the scheduled- - // sources-check has a chance to clean up, this may trigger. This also - // catches the case where creating an allocator from the source has failed. - if (!source->allocator) - continue; + // The source needs to have an allocator attached to it in order to read + // histograms out of it. + CreateAllocatorForSource(source.get()); + DCHECK(source->allocator); // Dump all histograms contained within the source to the snapshot-manager. RecordHistogramSnapshotsFromSource(snapshot_manager, source.get()); // Update the last-seen time so it isn't read again unless it changes. - RecordSourceAsSeen(source.get()); + RecordSourceAsRead(source.get()); } } @@ -491,7 +551,8 @@ // The source needs to have an allocator attached to it in order to read // histograms out of it. - DCHECK(source->mapped || !source->data.empty()); + DCHECK(!source->read_complete); + DCHECK(source->mapped); CreateAllocatorForSource(source.get()); DCHECK(source->allocator); @@ -499,7 +560,7 @@ RecordHistogramSnapshotsFromSource(snapshot_manager, source.get()); // Update the last-seen time so it isn't read again unless it changes. - RecordSourceAsSeen(source.get()); + RecordSourceAsRead(source.get()); } }
diff --git a/components/metrics/file_metrics_provider.h b/components/metrics/file_metrics_provider.h index 4fb0b86..2b71e1d 100644 --- a/components/metrics/file_metrics_provider.h +++ b/components/metrics/file_metrics_provider.h
@@ -40,7 +40,12 @@ // by an atomic rename) and the file is never updated again except to // be replaced by a completely new set of histograms. This is the only // option that can be used if the file is not writeable by *this* - // process. + // process. Once the file has been read, an attempt will be made to + // delete it thus providing some measure of safety should different + // instantiations (such as by different users of a system-level install) + // try to read it. In case the delete operation fails, this class + // persistently tracks the last-modified time of the file so it will + // not be read a second time. SOURCE_HISTOGRAMS_ATOMIC_FILE, // A directory of atomic PMA files. This handles a directory in which @@ -146,11 +151,16 @@ // be internally updated to indicate the next file to be read. static bool LocateNextFileInDirectory(SourceInfo* source); + // Deletes the file at the specified |path|. If the file is currently open, + // it is made inaccessible and deleted when closed. This needs to run on a + // thread allowed to do disk I/O. + static void DeleteFileWhenPossible(const base::FilePath& path); + // Creates a task to check all monitored sources for updates. void ScheduleSourcesCheck(); - // Creates a PersistentMemoryAllocator for a source that has been marked to - // have its metrics collected. + // Creates a PersistentMemoryAllocator for a |source| that has been marked + // to have its metrics collected. void CreateAllocatorForSource(SourceInfo* source); // Records all histograms from a given source via a snapshot-manager. @@ -163,7 +173,7 @@ void RecordSourcesChecked(SourceInfoList* checked); // Updates the persistent state information to show a source as being read. - void RecordSourceAsSeen(SourceInfo* source); + void RecordSourceAsRead(SourceInfo* source); // metrics::MetricsDataProvider: void OnDidCreateMetricsLog() override;
diff --git a/components/metrics/file_metrics_provider_unittest.cc b/components/metrics/file_metrics_provider_unittest.cc index ffeeca63..8fd27a4 100644 --- a/components/metrics/file_metrics_provider_unittest.cc +++ b/components/metrics/file_metrics_provider_unittest.cc
@@ -103,10 +103,12 @@ void WriteMetricsFile(const base::FilePath& path, base::PersistentHistogramAllocator* metrics) { - base::File writer(path, base::File::FLAG_CREATE | base::File::FLAG_WRITE); - ASSERT_TRUE(writer.IsValid()) << path.value(); - ASSERT_EQ(static_cast<int>(metrics->used()), - writer.Write(0, (const char*)metrics->data(), metrics->used())); + base::File writer(path, + base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); + // Use DCHECK so the stack-trace will indicate where this was called. + DCHECK(writer.IsValid()) << path.value(); + int amount = writer.Write(0, (const char*)metrics->data(), metrics->used()); + DCHECK_EQ(static_cast<int>(metrics->used()), amount); } void WriteMetricsFileAtTime(const base::FilePath& path, @@ -116,7 +118,8 @@ base::TouchFile(path, write_time, write_time); } - void CreateMetricsFileWithHistograms(int histogram_count) { + std::unique_ptr<base::PersistentHistogramAllocator> + CreateMetricsFileWithHistograms(int histogram_count) { // Get this first so it isn't created inside the persistent allocator. base::GlobalHistogramAllocator::GetCreateHistogramResultHistogram(); @@ -133,6 +136,7 @@ std::unique_ptr<base::PersistentHistogramAllocator> histogram_allocator = base::GlobalHistogramAllocator::ReleaseForTesting(); WriteMetricsFile(metrics_file(), histogram_allocator.get()); + return histogram_allocator; } private: @@ -148,10 +152,14 @@ TEST_F(FileMetricsProviderTest, AccessMetrics) { ASSERT_FALSE(PathExists(metrics_file())); - CreateMetricsFileWithHistograms(2); + + base::Time metrics_time = base::Time::Now() - base::TimeDelta::FromMinutes(5); + std::unique_ptr<base::PersistentHistogramAllocator> histogram_allocator = + CreateMetricsFileWithHistograms(2); + ASSERT_TRUE(PathExists(metrics_file())); + base::TouchFile(metrics_file(), metrics_time, metrics_time); // Register the file and allow the "checker" task to run. - ASSERT_TRUE(PathExists(metrics_file())); provider()->RegisterSource(metrics_file(), FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_FILE, FileMetricsProvider::ASSOCIATE_CURRENT_RUN, @@ -178,6 +186,15 @@ snapshot_manager.FinishDeltas(); EXPECT_EQ(0U, flattener.GetRecordedDeltaHistogramNames().size()); } + EXPECT_TRUE(base::PathExists(metrics_file())); + OnDidCreateMetricsLog(); + RunTasks(); + EXPECT_FALSE(base::PathExists(metrics_file())); + + // File should have been deleted but recreate it to test behavior should + // the file not be deleteable by this process. + WriteMetricsFileAtTime(metrics_file(), histogram_allocator.get(), + metrics_time); // Second full run on the same file should produce nothing. OnDidCreateMetricsLog(); @@ -190,16 +207,13 @@ snapshot_manager.FinishDeltas(); EXPECT_EQ(0U, flattener.GetRecordedDeltaHistogramNames().size()); } + RunTasks(); + EXPECT_FALSE(base::PathExists(metrics_file())); - // Update the time-stamp of the file to indicate that it is "new" and - // must be recorded. - { - base::File touch(metrics_file(), - base::File::FLAG_OPEN | base::File::FLAG_WRITE); - ASSERT_TRUE(touch.IsValid()); - base::Time next = base::Time::Now() + base::TimeDelta::FromSeconds(1); - touch.SetTimes(next, next); - } + // Recreate the file to indicate that it is "new" and must be recorded. + metrics_time = metrics_time + base::TimeDelta::FromMinutes(1); + WriteMetricsFileAtTime(metrics_file(), histogram_allocator.get(), + metrics_time); // This run should again have "new" histograms. OnDidCreateMetricsLog(); @@ -212,6 +226,10 @@ snapshot_manager.FinishDeltas(); EXPECT_EQ(2U, flattener.GetRecordedDeltaHistogramNames().size()); } + EXPECT_TRUE(base::PathExists(metrics_file())); + OnDidCreateMetricsLog(); + RunTasks(); + EXPECT_FALSE(base::PathExists(metrics_file())); } TEST_F(FileMetricsProviderTest, AccessDirectory) { @@ -312,6 +330,7 @@ // Record embedded snapshots via snapshot-manager. provider()->HasInitialStabilityMetrics(); + RunTasks(); { HistogramFlattenerDeltaRecorder flattener; base::HistogramSnapshotManager snapshot_manager(&flattener); @@ -320,20 +339,15 @@ snapshot_manager.FinishDeltas(); EXPECT_EQ(2U, flattener.GetRecordedDeltaHistogramNames().size()); } - - // Second full run on the same file should produce nothing. + EXPECT_TRUE(base::PathExists(metrics_file())); provider()->OnDidCreateMetricsLog(); RunTasks(); - { - HistogramFlattenerDeltaRecorder flattener; - base::HistogramSnapshotManager snapshot_manager(&flattener); - snapshot_manager.StartDeltas(); - provider()->RecordInitialHistogramSnapshots(&snapshot_manager); - snapshot_manager.FinishDeltas(); - EXPECT_EQ(0U, flattener.GetRecordedDeltaHistogramNames().size()); - } + EXPECT_FALSE(base::PathExists(metrics_file())); // A run for normal histograms should produce nothing. + CreateMetricsFileWithHistograms(2); + provider()->OnDidCreateMetricsLog(); + RunTasks(); { HistogramFlattenerDeltaRecorder flattener; base::HistogramSnapshotManager snapshot_manager(&flattener); @@ -342,6 +356,10 @@ snapshot_manager.FinishDeltas(); EXPECT_EQ(0U, flattener.GetRecordedDeltaHistogramNames().size()); } + EXPECT_TRUE(base::PathExists(metrics_file())); + provider()->OnDidCreateMetricsLog(); + RunTasks(); + EXPECT_TRUE(base::PathExists(metrics_file())); } } // namespace metrics
diff --git a/components/password_manager/core/browser/password_manager_metrics_util.cc b/components/password_manager/core/browser/password_manager_metrics_util.cc index 80cb5b3..32a0b249 100644 --- a/components/password_manager/core/browser/password_manager_metrics_util.cc +++ b/components/password_manager/core/browser/password_manager_metrics_util.cc
@@ -88,6 +88,12 @@ AUTO_SIGNIN_PROMO_ACTION_COUNT); } +void LogAccountChooserUserAction(AccountChooserUserAction action) { + // TODO(vasilii): deprecate the histogram when the new ones hit the Stable. + UMA_HISTOGRAM_ENUMERATION("PasswordManager.AccountChooserDialog", action, + ACCOUNT_CHOOSER_ACTION_COUNT); +} + void LogAccountChooserUserActionOneAccount(AccountChooserUserAction action) { UMA_HISTOGRAM_ENUMERATION("PasswordManager.AccountChooserDialogOneAccount", action, ACCOUNT_CHOOSER_ACTION_COUNT);
diff --git a/components/password_manager/core/browser/password_manager_metrics_util.h b/components/password_manager/core/browser/password_manager_metrics_util.h index e7b2ddb..038d7db 100644 --- a/components/password_manager/core/browser/password_manager_metrics_util.h +++ b/components/password_manager/core/browser/password_manager_metrics_util.h
@@ -173,6 +173,7 @@ void LogAutoSigninPromoUserAction(AutoSigninPromoUserAction action); // Log a user action on showing the account chooser for one or many accounts. +void LogAccountChooserUserAction(AccountChooserUserAction action); void LogAccountChooserUserActionOneAccount(AccountChooserUserAction action); void LogAccountChooserUserActionManyAccounts(AccountChooserUserAction action);
diff --git a/components/suggestions/image_manager.cc b/components/suggestions/image_manager.cc index 46618f4..9a536b2c 100644 --- a/components/suggestions/image_manager.cc +++ b/components/suggestions/image_manager.cc
@@ -30,19 +30,6 @@ encoded_data->size()); } -// Wraps an ImageManager callback so that it can be used with the ImageFetcher. -// ImageManager callbacks expect SkBitmaps while ImageFetcher callbacks expect -// gfx::Images. The image can be empty. In this case it is mapped to nullptr. -void WrapImageManagerCallback( - const base::Callback<void(const GURL&, const SkBitmap*)>& wrapped_callback, - const GURL& url, - const gfx::Image& image) { - const SkBitmap* bitmap = nullptr; - if (!image.IsEmpty()) - bitmap = image.ToSkBitmap(); - wrapped_callback.Run(url, bitmap); -} - } // namespace namespace suggestions { @@ -89,15 +76,13 @@ image_url_map_[url] = image_url; } -void ImageManager::GetImageForURL( - const GURL& url, - base::Callback<void(const GURL&, const SkBitmap*)> callback) { +void ImageManager::GetImageForURL(const GURL& url, ImageCallback callback) { DCHECK(thread_checker_.CalledOnValidThread()); // If |url| is not found in |image_url_map_|, then invoke |callback| with // NULL since there is no associated image for this |url|. GURL image_url; if (!GetImageURL(url, &image_url)) { - callback.Run(url, nullptr); + callback.Run(url, gfx::Image()); return; } @@ -127,8 +112,7 @@ } void ImageManager::QueueCacheRequest( - const GURL& url, const GURL& image_url, - base::Callback<void(const GURL&, const SkBitmap*)> callback) { + const GURL& url, const GURL& image_url, ImageCallback callback) { // To be served when the database has loaded. ImageCacheRequestMap::iterator it = pending_cache_requests_.find(url); if (it == pending_cache_requests_.end()) { @@ -146,13 +130,13 @@ void ImageManager::OnCacheImageDecoded( const GURL& url, const GURL& image_url, - base::Callback<void(const GURL&, const SkBitmap*)> callback, + const ImageCallback& callback, std::unique_ptr<SkBitmap> bitmap) { if (bitmap.get()) { - callback.Run(url, bitmap.get()); + callback.Run(url, gfx::Image::CreateFrom1xBitmap(*bitmap)); } else { image_fetcher_->StartOrQueueNetworkRequest( - url, image_url, base::Bind(&WrapImageManagerCallback, callback)); + url, image_url, callback); } } @@ -168,7 +152,7 @@ void ImageManager::ServeFromCacheOrNetwork( const GURL& url, const GURL& image_url, - base::Callback<void(const GURL&, const SkBitmap*)> callback) { + ImageCallback callback) { scoped_refptr<base::RefCountedMemory> encoded_data = GetEncodedImageFromCache(url); if (encoded_data.get()) { @@ -178,8 +162,7 @@ base::Bind(&ImageManager::OnCacheImageDecoded, weak_ptr_factory_.GetWeakPtr(), url, image_url, callback)); } else { - image_fetcher_->StartOrQueueNetworkRequest( - url, image_url, base::Bind(&WrapImageManagerCallback, callback)); + image_fetcher_->StartOrQueueNetworkRequest(url, image_url, callback); } }
diff --git a/components/suggestions/image_manager.h b/components/suggestions/image_manager.h index 518000d..9ddf9e3 100644 --- a/components/suggestions/image_manager.h +++ b/components/suggestions/image_manager.h
@@ -24,6 +24,10 @@ #include "ui/gfx/image/image_skia.h" #include "url/gurl.h" +namespace gfx { +class Image; +} + namespace image_fetcher { class ImageFetcher; } @@ -42,6 +46,7 @@ class ImageManager : public image_fetcher::ImageFetcherDelegate { public: typedef std::vector<ImageData> ImageDataVector; + using ImageCallback = base::Callback<void(const GURL&, const gfx::Image&)>; ImageManager( std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher, @@ -56,9 +61,7 @@ virtual void AddImageURL(const GURL& url, const GURL& image_url); // Should be called from the UI thread. - virtual void GetImageForURL( - const GURL& url, - base::Callback<void(const GURL&, const SkBitmap*)> callback); + virtual void GetImageForURL(const GURL& url, ImageCallback callback); protected: // Methods inherited from image_fetcher::ImageFetcherDelegate @@ -78,7 +81,7 @@ // Used for testing. ImageManager(); - typedef std::vector<base::Callback<void(const GURL&, const SkBitmap*)> > + typedef std::vector<base::Callback<void(const GURL&, const gfx::Image&)> > CallbackVector; typedef base::hash_map<std::string, scoped_refptr<base::RefCountedMemory>> ImageMap; @@ -104,17 +107,15 @@ bool GetImageURL(const GURL& url, GURL* image_url); void QueueCacheRequest( - const GURL& url, const GURL& image_url, - base::Callback<void(const GURL&, const SkBitmap*)> callback); + const GURL& url, const GURL& image_url, ImageCallback callback); void ServeFromCacheOrNetwork( - const GURL& url, const GURL& image_url, - base::Callback<void(const GURL&, const SkBitmap*)> callback); + const GURL& url, const GURL& image_url, ImageCallback callback); void OnCacheImageDecoded( const GURL& url, const GURL& image_url, - base::Callback<void(const GURL&, const SkBitmap*)> callback, + const ImageCallback& callback, std::unique_ptr<SkBitmap> bitmap); // Returns null if the |url| had no entry in the cache.
diff --git a/components/suggestions/image_manager_unittest.cc b/components/suggestions/image_manager_unittest.cc index 9ac3f089..59176d4f 100644 --- a/components/suggestions/image_manager_unittest.cc +++ b/components/suggestions/image_manager_unittest.cc
@@ -105,8 +105,8 @@ } void OnImageAvailable(base::RunLoop* loop, const GURL& url, - const SkBitmap* bitmap) { - if (bitmap) { + const gfx::Image& image) { + if (!image.IsEmpty()) { num_callback_valid_called_++; } else { num_callback_null_called_++;
diff --git a/components/suggestions/suggestions_service.h b/components/suggestions/suggestions_service.h index 7c11f25f..d29f15ed 100644 --- a/components/suggestions/suggestions_service.h +++ b/components/suggestions/suggestions_service.h
@@ -24,6 +24,10 @@ #include "net/url_request/url_fetcher_delegate.h" #include "url/gurl.h" +namespace gfx { +class Image; +} + namespace net { class URLRequestContextGetter; } // namespace net @@ -38,7 +42,6 @@ class OAuth2TokenService; class SigninManagerBase; -class SkBitmap; namespace suggestions { @@ -52,7 +55,7 @@ public sync_driver::SyncServiceObserver { public: using ResponseCallback = base::Callback<void(const SuggestionsProfile&)>; - using BitmapCallback = base::Callback<void(const GURL&, const SkBitmap*)>; + using BitmapCallback = base::Callback<void(const GURL&, const gfx::Image&)>; using ResponseCallbackList = base::CallbackList<void(const SuggestionsProfile&)>;
diff --git a/components/suggestions/suggestions_service_unittest.cc b/components/suggestions/suggestions_service_unittest.cc index 9a7676b6..aa627dd 100644 --- a/components/suggestions/suggestions_service_unittest.cc +++ b/components/suggestions/suggestions_service_unittest.cc
@@ -28,6 +28,7 @@ #include "net/url_request/url_request_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/gfx/image/image.h" using testing::DoAll; using ::testing::AnyNumber; @@ -153,7 +154,7 @@ MOCK_METHOD1(Initialize, void(const SuggestionsProfile&)); MOCK_METHOD2(GetImageForURL, void(const GURL&, - base::Callback<void(const GURL&, const SkBitmap*)>)); + base::Callback<void(const GURL&, const gfx::Image&)>)); MOCK_METHOD2(AddImageURL, void(const GURL&, const GURL&)); }; @@ -742,7 +743,7 @@ GURL test_url(kTestUrl); GURL thumbnail_url("https://www.thumbnails.com/thumb.jpg"); - base::Callback<void(const GURL&, const SkBitmap*)> dummy_callback; + base::Callback<void(const GURL&, const gfx::Image&)> dummy_callback; EXPECT_CALL(*mock_thumbnail_manager_, GetImageForURL(test_url, _)); suggestions_service->GetPageThumbnail(test_url, dummy_callback);
diff --git a/content/browser/DEPS b/content/browser/DEPS index bb34301..c651eb3 100644 --- a/content/browser/DEPS +++ b/content/browser/DEPS
@@ -114,16 +114,7 @@ specific_include_rules = { # See https://crbug.com/612337. - "(power_save_blocker_android\.cc" - "|power_save_blocker_android\.h" - "|power_save_blocker_chromeos\.cc" - "|power_save_blocker_impl\.cc" - "|power_save_blocker_impl\.h" - "|power_save_blocker_mac\.cc" - "|power_save_blocker_ozone\.cc" - "|power_save_blocker_win\.cc" - "|power_save_blocker_x11\.cc" - ")": [ + "power_save_blocker.*\.(cc|h)": [ "-content", # These will move to //device/power_save_blocker. @@ -134,6 +125,7 @@ "!content/browser/android/content_view_core_impl.h", "!content/browser/web_contents/web_contents_impl.h", "!content/public/browser/android/content_view_core.h", + "!content/public/browser/browser_thread.h", "!content/public/browser/web_contents_observer.h", ] }
diff --git a/content/browser/background_sync/background_sync_manager.cc b/content/browser/background_sync/background_sync_manager.cc index 9afe914..2d5880a0 100644 --- a/content/browser/background_sync/background_sync_manager.cc +++ b/content/browser/background_sync/background_sync_manager.cc
@@ -51,7 +51,7 @@ // Returns nullptr if the browser context cannot be accessed for any reason. BrowserContext* GetBrowserContextOnUIThread( - const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) { + scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { DCHECK_CURRENTLY_ON(BrowserThread::UI); if (!service_worker_context) @@ -66,11 +66,11 @@ // Returns nullptr if the controller cannot be accessed for any reason. BackgroundSyncController* GetBackgroundSyncControllerOnUIThread( - const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) { + scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { DCHECK_CURRENTLY_ON(BrowserThread::UI); BrowserContext* browser_context = - GetBrowserContextOnUIThread(service_worker_context); + GetBrowserContextOnUIThread(std::move(service_worker_context)); if (!browser_context) return nullptr; @@ -80,12 +80,12 @@ // Returns PermissionStatus::DENIED if the permission manager cannot be // accessed for any reason. blink::mojom::PermissionStatus GetBackgroundSyncPermissionOnUIThread( - const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context, + scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, const GURL& origin) { DCHECK_CURRENTLY_ON(BrowserThread::UI); BrowserContext* browser_context = - GetBrowserContextOnUIThread(service_worker_context); + GetBrowserContextOnUIThread(std::move(service_worker_context)); if (!browser_context) return blink::mojom::PermissionStatus::DENIED; @@ -100,12 +100,12 @@ } void NotifyBackgroundSyncRegisteredOnUIThread( - const scoped_refptr<ServiceWorkerContextWrapper>& sw_context_wrapper, + scoped_refptr<ServiceWorkerContextWrapper> sw_context_wrapper, const GURL& origin) { DCHECK_CURRENTLY_ON(BrowserThread::UI); BackgroundSyncController* background_sync_controller = - GetBackgroundSyncControllerOnUIThread(sw_context_wrapper); + GetBackgroundSyncControllerOnUIThread(std::move(sw_context_wrapper)); if (!background_sync_controller) return; @@ -114,7 +114,7 @@ } void RunInBackgroundOnUIThread( - const scoped_refptr<ServiceWorkerContextWrapper>& sw_context_wrapper, + scoped_refptr<ServiceWorkerContextWrapper> sw_context_wrapper, bool enabled, int64_t min_ms) { DCHECK_CURRENTLY_ON(BrowserThread::UI); @@ -127,7 +127,7 @@ } std::unique_ptr<BackgroundSyncParameters> GetControllerParameters( - const scoped_refptr<ServiceWorkerContextWrapper>& sw_context_wrapper, + scoped_refptr<ServiceWorkerContextWrapper> sw_context_wrapper, std::unique_ptr<BackgroundSyncParameters> parameters) { DCHECK_CURRENTLY_ON(BrowserThread::UI); @@ -145,11 +145,10 @@ return parameters; } -void OnSyncEventFinished( - const scoped_refptr<ServiceWorkerVersion>& active_version, - int request_id, - const ServiceWorkerVersion::StatusCallback& callback, - blink::mojom::ServiceWorkerEventStatus status) { +void OnSyncEventFinished(scoped_refptr<ServiceWorkerVersion> active_version, + int request_id, + const ServiceWorkerVersion::StatusCallback& callback, + blink::mojom::ServiceWorkerEventStatus status) { if (!active_version->FinishRequest( request_id, status == blink::mojom::ServiceWorkerEventStatus::COMPLETED)) { @@ -174,7 +173,7 @@ // static std::unique_ptr<BackgroundSyncManager> BackgroundSyncManager::Create( - const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) { + scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { DCHECK_CURRENTLY_ON(BrowserThread::IO); BackgroundSyncManager* sync_manager = @@ -259,8 +258,22 @@ weak_ptr_factory_.GetWeakPtr(), max_attempts, MakeEmptyCompletion())); } +void BackgroundSyncManager::EmulateDispatchSyncEvent( + const std::string& tag, + scoped_refptr<ServiceWorkerVersion> active_version, + bool last_chance, + const ServiceWorkerVersion::StatusCallback& callback) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + DispatchSyncEvent( + tag, std::move(active_version), + last_chance + ? blink::mojom::BackgroundSyncEventLastChance::IS_LAST_CHANCE + : blink::mojom::BackgroundSyncEventLastChance::IS_NOT_LAST_CHANCE, + callback); +} + BackgroundSyncManager::BackgroundSyncManager( - const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) + scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) : service_worker_context_(service_worker_context), parameters_(new BackgroundSyncParameters()), disabled_(false), @@ -736,7 +749,7 @@ void BackgroundSyncManager::DispatchSyncEvent( const std::string& tag, - const scoped_refptr<ServiceWorkerVersion>& active_version, + scoped_refptr<ServiceWorkerVersion> active_version, blink::mojom::BackgroundSyncEventLastChance last_chance, const ServiceWorkerVersion::StatusCallback& callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -761,9 +774,9 @@ ->GetMojoServiceForRequest<blink::mojom::BackgroundSyncServiceClient>( request_id); - client->Sync( - tag, last_chance, - base::Bind(&OnSyncEventFinished, active_version, request_id, callback)); + client->Sync(tag, last_chance, + base::Bind(&OnSyncEventFinished, std::move(active_version), + request_id, callback)); } void BackgroundSyncManager::ScheduleDelayedTask(const base::Closure& callback, @@ -1010,7 +1023,7 @@ // |service_worker_registration| is just to keep the registration alive // while the event is firing. void BackgroundSyncManager::EventComplete( - const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration, + scoped_refptr<ServiceWorkerRegistration> service_worker_registration, int64_t service_worker_id, const std::string& tag, const base::Closure& callback,
diff --git a/content/browser/background_sync/background_sync_manager.h b/content/browser/background_sync/background_sync_manager.h index e834495..9b8b7739 100644 --- a/content/browser/background_sync/background_sync_manager.h +++ b/content/browser/background_sync/background_sync_manager.h
@@ -64,7 +64,7 @@ std::unique_ptr<ScopedVector<BackgroundSyncRegistration>>)>; static std::unique_ptr<BackgroundSyncManager> Create( - const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); + scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); ~BackgroundSyncManager() override; // Stores the given background sync registration and adds it to the scheduling @@ -102,9 +102,16 @@ clock_ = std::move(clock); } + // Called from DevTools + void EmulateDispatchSyncEvent( + const std::string& tag, + scoped_refptr<ServiceWorkerVersion> active_version, + bool last_chance, + const ServiceWorkerVersion::StatusCallback& callback); + protected: explicit BackgroundSyncManager( - const scoped_refptr<ServiceWorkerContextWrapper>& context); + scoped_refptr<ServiceWorkerContextWrapper> context); // Init must be called before any public member function. Only call it once. void Init(); @@ -122,7 +129,7 @@ callback); virtual void DispatchSyncEvent( const std::string& tag, - const scoped_refptr<ServiceWorkerVersion>& active_version, + scoped_refptr<ServiceWorkerVersion> active_version, blink::mojom::BackgroundSyncEventLastChance last_chance, const ServiceWorkerVersion::StatusCallback& callback); virtual void ScheduleDelayedTask(const base::Closure& callback, @@ -247,12 +254,12 @@ void FireReadyEventsAllEventsFiring(const base::Closure& callback); // Called when a sync event has completed. - void EventComplete(const scoped_refptr<ServiceWorkerRegistration>& - service_worker_registration, - int64_t service_worker_id, - const std::string& tag, - const base::Closure& callback, - ServiceWorkerStatusCode status_code); + void EventComplete( + scoped_refptr<ServiceWorkerRegistration> service_worker_registration, + int64_t service_worker_id, + const std::string& tag, + const base::Closure& callback, + ServiceWorkerStatusCode status_code); void EventCompleteImpl(int64_t service_worker_id, const std::string& tag, ServiceWorkerStatusCode status_code,
diff --git a/content/browser/devtools/protocol/service_worker_handler.cc b/content/browser/devtools/protocol/service_worker_handler.cc index a3034a2..e008b685 100644 --- a/content/browser/devtools/protocol/service_worker_handler.cc +++ b/content/browser/devtools/protocol/service_worker_handler.cc
@@ -8,6 +8,8 @@ #include "base/containers/scoped_ptr_hash_map.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" +#include "content/browser/background_sync/background_sync_context.h" +#include "content/browser/background_sync/background_sync_manager.h" #include "content/browser/devtools/service_worker_devtools_agent_host.h" #include "content/browser/devtools/service_worker_devtools_manager.h" #include "content/browser/frame_host/frame_tree.h" @@ -16,6 +18,7 @@ #include "content/browser/service_worker/service_worker_context_watcher.h" #include "content/browser/service_worker/service_worker_context_wrapper.h" #include "content/browser/service_worker/service_worker_version.h" +#include "content/browser/storage_partition_impl_map.h" #include "content/common/service_worker/service_worker_utils.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" @@ -46,8 +49,15 @@ void ResultNoOp(bool success) { } + void StatusNoOp(ServiceWorkerStatusCode status) { } + +void StatusNoOpKeepingRegistration( + scoped_refptr<content::ServiceWorkerRegistration> protect, + ServiceWorkerStatusCode status) { +} + void PushDeliveryNoOp(PushDeliveryStatus status) { } @@ -253,6 +263,36 @@ return std::string(); } +void DidFindRegistrationForDispatchSyncEventOnIO( + scoped_refptr<BackgroundSyncContext> sync_context, + const std::string& tag, + bool last_chance, + ServiceWorkerStatusCode status, + const scoped_refptr<content::ServiceWorkerRegistration>& registration) { + if (status != SERVICE_WORKER_OK || !registration->active_version()) + return; + BackgroundSyncManager* background_sync_manager = + sync_context->background_sync_manager(); + scoped_refptr<content::ServiceWorkerVersion> version( + registration->active_version()); + // Keep the registration while dispatching the sync event. + background_sync_manager->EmulateDispatchSyncEvent( + tag, std::move(version), last_chance, + base::Bind(&StatusNoOpKeepingRegistration, registration)); +} + +void DispatchSyncEventOnIO(scoped_refptr<ServiceWorkerContextWrapper> context, + scoped_refptr<BackgroundSyncContext> sync_context, + const GURL& origin, + int64_t registration_id, + const std::string& tag, + bool last_chance) { + context->FindReadyRegistrationForId( + registration_id, origin, + base::Bind(&DidFindRegistrationForDispatchSyncEventOnIO, sync_context, + tag, last_chance)); +} + } // namespace ServiceWorkerHandler::ServiceWorkerHandler() @@ -469,6 +509,32 @@ return Response::OK(); } +Response ServiceWorkerHandler::DispatchSyncEvent( + const std::string& origin, + const std::string& registration_id, + const std::string& tag, + bool last_chance) { + if (!enabled_) + return Response::OK(); + if (!render_frame_host_) + return CreateContextErrorResponse(); + int64_t id = 0; + if (!base::StringToInt64(registration_id, &id)) + return CreateInvalidVersionIdErrorResponse(); + + StoragePartitionImpl* partition = + static_cast<StoragePartitionImpl*>(BrowserContext::GetStoragePartition( + render_frame_host_->GetProcess()->GetBrowserContext(), + render_frame_host_->GetSiteInstance())); + BackgroundSyncContext* sync_context = partition->GetBackgroundSyncContext(); + + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, + base::Bind(&DispatchSyncEventOnIO, context_, + make_scoped_refptr(sync_context), + GURL(origin), id, tag, last_chance)); + return Response::OK(); +} + Response ServiceWorkerHandler::GetTargetInfo( const std::string& target_id, scoped_refptr<TargetInfo>* target_info) {
diff --git a/content/browser/devtools/protocol/service_worker_handler.h b/content/browser/devtools/protocol/service_worker_handler.h index cf87537..ac7d460c 100644 --- a/content/browser/devtools/protocol/service_worker_handler.h +++ b/content/browser/devtools/protocol/service_worker_handler.h
@@ -62,6 +62,10 @@ Response DeliverPushMessage(const std::string& origin, const std::string& registration_id, const std::string& data); + Response DispatchSyncEvent(const std::string& origin, + const std::string& registration_id, + const std::string& tag, + bool last_chance); Response GetTargetInfo(const std::string& target_id, scoped_refptr<TargetInfo>* target_info); Response ActivateTarget(const std::string& target_id);
diff --git a/content/browser/devtools/render_frame_devtools_agent_host.cc b/content/browser/devtools/render_frame_devtools_agent_host.cc index d4f91ab5..f2aaf54 100644 --- a/content/browser/devtools/render_frame_devtools_agent_host.cc +++ b/content/browser/devtools/render_frame_devtools_agent_host.cc
@@ -39,7 +39,6 @@ #if defined(OS_ANDROID) #include "content/browser/power_save_blocker_impl.h" -#include "content/public/browser/power_save_blocker_factory.h" #include "content/public/browser/render_widget_host_view.h" #endif @@ -498,10 +497,9 @@ frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder()); #if defined(OS_ANDROID) power_save_blocker_.reset(static_cast<PowerSaveBlockerImpl*>( - CreatePowerSaveBlocker( + PowerSaveBlocker::Create( PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, - PowerSaveBlocker::kReasonOther, "DevTools") - .release())); + PowerSaveBlocker::kReasonOther, "DevTools").release())); power_save_blocker_->InitDisplaySleepBlocker(web_contents()); #endif
diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc index cc35a58..23dab98 100644 --- a/content/browser/download/download_browsertest.cc +++ b/content/browser/download/download_browsertest.cc
@@ -32,7 +32,7 @@ #include "content/browser/loader/resource_dispatcher_host_impl.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/download_danger_type.h" -#include "content/public/browser/power_save_blocker_factory.h" +#include "content/public/browser/power_save_blocker.h" #include "content/public/browser/resource_dispatcher_host_delegate.h" #include "content/public/browser/resource_throttle.h" #include "content/public/common/content_features.h" @@ -254,7 +254,7 @@ std::unique_ptr<ByteStreamReader> stream, const net::BoundNetLog& bound_net_log, base::WeakPtr<DownloadDestinationObserver> observer) { - std::unique_ptr<PowerSaveBlocker> psb(CreatePowerSaveBlocker( + std::unique_ptr<PowerSaveBlocker> psb(PowerSaveBlocker::Create( PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, PowerSaveBlocker::kReasonOther, "Download in progress")); return new DownloadFileWithDelay(std::move(save_info), @@ -350,7 +350,7 @@ std::unique_ptr<ByteStreamReader> stream, const net::BoundNetLog& bound_net_log, base::WeakPtr<DownloadDestinationObserver> observer) override { - std::unique_ptr<PowerSaveBlocker> psb(CreatePowerSaveBlocker( + std::unique_ptr<PowerSaveBlocker> psb(PowerSaveBlocker::Create( PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, PowerSaveBlocker::kReasonOther, "Download in progress")); return new CountingDownloadFile(std::move(save_info),
diff --git a/content/browser/download/download_request_core.cc b/content/browser/download/download_request_core.cc index 2f5b2f1..4ab373f 100644 --- a/content/browser/download/download_request_core.cc +++ b/content/browser/download/download_request_core.cc
@@ -29,7 +29,7 @@ #include "content/public/browser/download_item.h" #include "content/public/browser/download_manager_delegate.h" #include "content/public/browser/navigation_entry.h" -#include "content/public/browser/power_save_blocker_factory.h" +#include "content/public/browser/power_save_blocker.h" #include "content/public/browser/resource_context.h" #include "content/public/browser/web_contents.h" #include "net/base/elements_upload_data_stream.h" @@ -204,7 +204,7 @@ DCHECK(request_); DCHECK(delegate_); RecordDownloadCount(UNTHROTTLED_COUNT); - power_save_blocker_ = CreatePowerSaveBlocker( + power_save_blocker_ = PowerSaveBlocker::Create( PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, PowerSaveBlocker::kReasonOther, "Download in progress"); DownloadRequestData* request_data = DownloadRequestData::Get(request_);
diff --git a/content/browser/loader/DEPS b/content/browser/loader/DEPS index a9280c8..188bb2b 100644 --- a/content/browser/loader/DEPS +++ b/content/browser/loader/DEPS
@@ -95,7 +95,7 @@ "+content/public/browser/resource_throttle.h", # TODO: these all have to be removed. - "+content/public/browser/power_save_blocker_factory.h", + "+content/public/browser/power_save_blocker.h", ], "resource_dispatcher_host_impl\.(cc|h)": [ "-content",
diff --git a/content/browser/loader/power_save_block_resource_throttle.cc b/content/browser/loader/power_save_block_resource_throttle.cc index 9ef3e2b..76afe12 100644 --- a/content/browser/loader/power_save_block_resource_throttle.cc +++ b/content/browser/loader/power_save_block_resource_throttle.cc
@@ -4,7 +4,7 @@ #include "content/browser/loader/power_save_block_resource_throttle.h" -#include "content/public/browser/power_save_blocker_factory.h" +#include "content/public/browser/power_save_blocker.h" namespace content { @@ -40,7 +40,7 @@ } void PowerSaveBlockResourceThrottle::ActivatePowerSaveBlocker() { - power_save_blocker_ = CreatePowerSaveBlocker( + power_save_blocker_ = PowerSaveBlocker::Create( PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, PowerSaveBlocker::kReasonOther, "Uploading data to " + host_); }
diff --git a/content/browser/media/capture/aura_window_capture_machine.cc b/content/browser/media/capture/aura_window_capture_machine.cc index 529d09a8..6aff1cbc 100644 --- a/content/browser/media/capture/aura_window_capture_machine.cc +++ b/content/browser/media/capture/aura_window_capture_machine.cc
@@ -15,7 +15,7 @@ #include "content/browser/compositor/image_transport_factory.h" #include "content/browser/media/capture/desktop_capture_device_uma_types.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/power_save_blocker_factory.h" +#include "content/public/browser/power_save_blocker.h" #include "media/base/video_capture_types.h" #include "media/base/video_util.h" #include "media/capture/content/thread_safe_capture_oracle.h" @@ -86,10 +86,10 @@ compositor->AddAnimationObserver(this); power_save_blocker_.reset( - CreatePowerSaveBlocker( + PowerSaveBlocker::Create( PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, - PowerSaveBlocker::kReasonOther, "DesktopCaptureDevice is running") - .release()); + PowerSaveBlocker::kReasonOther, + "DesktopCaptureDevice is running").release()); return true; }
diff --git a/content/browser/media/capture/desktop_capture_device.cc b/content/browser/media/capture/desktop_capture_device.cc index 9ef0dc1..a76bc8d 100644 --- a/content/browser/media/capture/desktop_capture_device.cc +++ b/content/browser/media/capture/desktop_capture_device.cc
@@ -22,7 +22,7 @@ #include "content/browser/media/capture/desktop_capture_device_uma_types.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/desktop_media_id.h" -#include "content/public/browser/power_save_blocker_factory.h" +#include "content/public/browser/power_save_blocker.h" #include "media/base/video_util.h" #include "media/capture/content/capture_resolution_chooser.h" #include "third_party/libyuv/include/libyuv/scale_argb.h" @@ -170,10 +170,10 @@ params.resolution_change_policy)); power_save_blocker_.reset( - CreatePowerSaveBlocker( + PowerSaveBlocker::Create( PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, - PowerSaveBlocker::kReasonOther, "DesktopCaptureDevice is running") - .release()); + PowerSaveBlocker::kReasonOther, + "DesktopCaptureDevice is running").release()); desktop_capturer_->Start(this);
diff --git a/content/browser/media/media_web_contents_observer.cc b/content/browser/media/media_web_contents_observer.cc index 14251a7c6..c301e2e 100644 --- a/content/browser/media/media_web_contents_observer.cc +++ b/content/browser/media/media_web_contents_observer.cc
@@ -13,7 +13,6 @@ #include "content/browser/power_save_blocker_impl.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/common/media/media_player_delegate_messages.h" -#include "content/public/browser/power_save_blocker_factory.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "ipc/ipc_message_macros.h" @@ -181,7 +180,7 @@ void MediaWebContentsObserver::CreateAudioPowerSaveBlocker() { DCHECK(!audio_power_save_blocker_); - audio_power_save_blocker_ = CreatePowerSaveBlocker( + audio_power_save_blocker_ = PowerSaveBlocker::Create( PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, PowerSaveBlocker::kReasonAudioPlayback, "Playing audio"); } @@ -189,7 +188,7 @@ void MediaWebContentsObserver::CreateVideoPowerSaveBlocker() { DCHECK(!video_power_save_blocker_); DCHECK(!active_video_players_.empty()); - video_power_save_blocker_ = CreatePowerSaveBlocker( + video_power_save_blocker_ = PowerSaveBlocker::Create( PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, PowerSaveBlocker::kReasonVideoPlayback, "Playing video"); #if defined(OS_ANDROID)
diff --git a/content/browser/media/webrtc/webrtc_internals.cc b/content/browser/media/webrtc/webrtc_internals.cc index 4cf378d..09d7a97 100644 --- a/content/browser/media/webrtc/webrtc_internals.cc +++ b/content/browser/media/webrtc/webrtc_internals.cc
@@ -12,7 +12,7 @@ #include "content/browser/web_contents/web_contents_view.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" -#include "content/public/browser/power_save_blocker_factory.h" +#include "content/public/browser/power_save_blocker.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" @@ -502,7 +502,7 @@ } else if (!peer_connection_data_.empty() && !power_save_blocker_) { DVLOG(1) << ("Preventing the application from being suspended while one or " "more PeerConnections are active."); - power_save_blocker_ = content::CreatePowerSaveBlocker( + power_save_blocker_ = content::PowerSaveBlocker::Create( PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, PowerSaveBlocker::kReasonOther, "WebRTC has active PeerConnections"); }
diff --git a/content/browser/power_save_blocker_android.cc b/content/browser/power_save_blocker_android.cc index 34ff852..0adcd29 100644 --- a/content/browser/power_save_blocker_android.cc +++ b/content/browser/power_save_blocker_android.cc
@@ -9,6 +9,7 @@ #include "content/browser/power_save_blocker_impl.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/android/content_view_core.h" +#include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents_observer.h" #include "jni/PowerSaveBlocker_jni.h" #include "ui/android/view_android.h" @@ -21,8 +22,7 @@ : public base::RefCountedThreadSafe<PowerSaveBlockerImpl::Delegate>, public WebContentsObserver { public: - Delegate(WebContents* web_contents, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner); + explicit Delegate(WebContents* web_contents); // Does the actual work to apply or remove the desired power save block. void ApplyBlock(); @@ -36,15 +36,11 @@ base::android::ScopedJavaGlobalRef<jobject> java_power_save_blocker_; - scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; - DISALLOW_COPY_AND_ASSIGN(Delegate); }; -PowerSaveBlockerImpl::Delegate::Delegate( - WebContents* web_contents, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner) - : WebContentsObserver(web_contents), ui_task_runner_(ui_task_runner) { +PowerSaveBlockerImpl::Delegate::Delegate(WebContents* web_contents) + : WebContentsObserver(web_contents) { JNIEnv* env = AttachCurrentThread(); java_power_save_blocker_.Reset(Java_PowerSaveBlocker_create(env)); } @@ -53,7 +49,7 @@ } void PowerSaveBlockerImpl::Delegate::ApplyBlock() { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); base::android::ScopedJavaLocalRef<jobject> java_content_view_core = GetContentViewCore(); if (java_content_view_core.is_null()) @@ -66,7 +62,7 @@ } void PowerSaveBlockerImpl::Delegate::RemoveBlock() { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); base::android::ScopedJavaLocalRef<jobject> java_content_view_core = GetContentViewCore(); if (java_content_view_core.is_null()) @@ -91,30 +87,26 @@ return content_view_core_impl->GetJavaObject(); } -PowerSaveBlockerImpl::PowerSaveBlockerImpl( - PowerSaveBlockerType type, - Reason reason, - const std::string& description, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner, - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) - : ui_task_runner_(ui_task_runner), - blocking_task_runner_(blocking_task_runner) { +PowerSaveBlockerImpl::PowerSaveBlockerImpl(PowerSaveBlockerType type, + Reason reason, + const std::string& description) { // Don't support kPowerSaveBlockPreventAppSuspension } PowerSaveBlockerImpl::~PowerSaveBlockerImpl() { if (delegate_.get()) { - ui_task_runner_->PostTask(FROM_HERE, - base::Bind(&Delegate::RemoveBlock, delegate_)); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&Delegate::RemoveBlock, delegate_)); } } void PowerSaveBlockerImpl::InitDisplaySleepBlocker(WebContents* web_contents) { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); if (!web_contents) return; - delegate_ = new Delegate(web_contents, ui_task_runner_); + delegate_ = new Delegate(web_contents); delegate_->ApplyBlock(); }
diff --git a/content/browser/power_save_blocker_chromeos.cc b/content/browser/power_save_blocker_chromeos.cc index 6da18f9..bf50c89 100644 --- a/content/browser/power_save_blocker_chromeos.cc +++ b/content/browser/power_save_blocker_chromeos.cc
@@ -12,6 +12,7 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "chromeos/dbus/power_policy_controller.h" +#include "content/public/browser/browser_thread.h" namespace content { @@ -39,16 +40,11 @@ public: Delegate(PowerSaveBlockerType type, Reason reason, - const std::string& description, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner) - : type_(type), - reason_(reason), - description_(description), - block_id_(0), - ui_task_runner_(ui_task_runner) {} + const std::string& description) + : type_(type), reason_(reason), description_(description), block_id_(0) {} void ApplyBlock() { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); if (!chromeos::PowerPolicyController::IsInitialized()) return; @@ -68,7 +64,7 @@ } void RemoveBlock() { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); if (!chromeos::PowerPolicyController::IsInitialized()) return; @@ -86,27 +82,20 @@ // ID corresponding to the block request in PowerPolicyController. int block_id_; - scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; - DISALLOW_COPY_AND_ASSIGN(Delegate); }; -PowerSaveBlockerImpl::PowerSaveBlockerImpl( - PowerSaveBlockerType type, - Reason reason, - const std::string& description, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner, - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) - : delegate_(new Delegate(type, reason, description, ui_task_runner)), - ui_task_runner_(ui_task_runner), - blocking_task_runner_(blocking_task_runner) { - ui_task_runner_->PostTask(FROM_HERE, - base::Bind(&Delegate::ApplyBlock, delegate_)); +PowerSaveBlockerImpl::PowerSaveBlockerImpl(PowerSaveBlockerType type, + Reason reason, + const std::string& description) + : delegate_(new Delegate(type, reason, description)) { + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(&Delegate::ApplyBlock, delegate_)); } PowerSaveBlockerImpl::~PowerSaveBlockerImpl() { - ui_task_runner_->PostTask(FROM_HERE, - base::Bind(&Delegate::RemoveBlock, delegate_)); + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(&Delegate::RemoveBlock, delegate_)); } } // namespace content
diff --git a/content/browser/power_save_blocker_factory.cc b/content/browser/power_save_blocker_factory.cc deleted file mode 100644 index 8dea141..0000000 --- a/content/browser/power_save_blocker_factory.cc +++ /dev/null
@@ -1,24 +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. - -#include "content/public/browser/power_save_blocker_factory.h" - -#include "base/threading/sequenced_worker_pool.h" -#include "content/public/browser/browser_thread.h" - -namespace content { - -std::unique_ptr<PowerSaveBlocker> CreatePowerSaveBlocker( - PowerSaveBlocker::PowerSaveBlockerType type, - PowerSaveBlocker::Reason reason, - const std::string& description) { - base::SequencedWorkerPool::SequenceToken token = - base::SequencedWorkerPool::GetSequenceToken(); - return PowerSaveBlocker::CreateWithTaskRunners( - type, reason, description, - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), - BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(token)); -} - -} // namespace content
diff --git a/content/browser/power_save_blocker_impl.cc b/content/browser/power_save_blocker_impl.cc index 0257db0..52cb6a1d 100644 --- a/content/browser/power_save_blocker_impl.cc +++ b/content/browser/power_save_blocker_impl.cc
@@ -2,23 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/power_save_blocker_impl.h" - #include "build/build_config.h" +#include "content/browser/power_save_blocker_impl.h" namespace content { PowerSaveBlocker::~PowerSaveBlocker() {} // static -std::unique_ptr<PowerSaveBlocker> PowerSaveBlocker::CreateWithTaskRunners( - PowerSaveBlocker::PowerSaveBlockerType type, - PowerSaveBlocker::Reason reason, - const std::string& description, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner, - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) { - return std::unique_ptr<PowerSaveBlocker>(new PowerSaveBlockerImpl( - type, reason, description, ui_task_runner, blocking_task_runner)); +std::unique_ptr<PowerSaveBlocker> PowerSaveBlocker::Create( + PowerSaveBlockerType type, + Reason reason, + const std::string& description) { + return std::unique_ptr<PowerSaveBlocker>( + new PowerSaveBlockerImpl(type, reason, description)); } } // namespace content
diff --git a/content/browser/power_save_blocker_impl.h b/content/browser/power_save_blocker_impl.h index 5baf950..a01fc60 100644 --- a/content/browser/power_save_blocker_impl.h +++ b/content/browser/power_save_blocker_impl.h
@@ -18,12 +18,9 @@ class PowerSaveBlockerImpl : public PowerSaveBlocker { public: - PowerSaveBlockerImpl( - PowerSaveBlockerType type, - Reason reason, - const std::string& description, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner, - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); + PowerSaveBlockerImpl(PowerSaveBlockerType type, + Reason reason, + const std::string& description); ~PowerSaveBlockerImpl() override; #if defined(OS_ANDROID) @@ -55,9 +52,6 @@ scoped_refptr<Delegate> freedesktop_suspend_delegate_; #endif - scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; - DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockerImpl); };
diff --git a/content/browser/power_save_blocker_mac.cc b/content/browser/power_save_blocker_mac.cc index b9e5a8d..0ce80f6 100644 --- a/content/browser/power_save_blocker_mac.cc +++ b/content/browser/power_save_blocker_mac.cc
@@ -97,15 +97,10 @@ } } -PowerSaveBlockerImpl::PowerSaveBlockerImpl( - PowerSaveBlockerType type, - Reason reason, - const std::string& description, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner, - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) - : delegate_(new Delegate(type, description)), - ui_task_runner_(ui_task_runner), - blocking_task_runner_(blocking_task_runner) { +PowerSaveBlockerImpl::PowerSaveBlockerImpl(PowerSaveBlockerType type, + Reason reason, + const std::string& description) + : delegate_(new Delegate(type, description)) { g_power_thread.Pointer()->message_loop()->PostTask( FROM_HERE, base::Bind(&Delegate::ApplyBlock, delegate_));
diff --git a/content/browser/power_save_blocker_ozone.cc b/content/browser/power_save_blocker_ozone.cc index 11403b0..c310235 100644 --- a/content/browser/power_save_blocker_ozone.cc +++ b/content/browser/power_save_blocker_ozone.cc
@@ -25,15 +25,11 @@ DISALLOW_COPY_AND_ASSIGN(Delegate); }; -PowerSaveBlockerImpl::PowerSaveBlockerImpl( - PowerSaveBlockerType type, - Reason reason, - const std::string& description, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner, - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) - : delegate_(new Delegate()), - ui_task_runner_(ui_task_runner), - blocking_task_runner_(blocking_task_runner) {} +PowerSaveBlockerImpl::PowerSaveBlockerImpl(PowerSaveBlockerType type, + Reason reason, + const std::string& description) + : delegate_(new Delegate()) { +} PowerSaveBlockerImpl::~PowerSaveBlockerImpl() { }
diff --git a/content/browser/power_save_blocker_win.cc b/content/browser/power_save_blocker_win.cc index d9b6723..ff78f118 100644 --- a/content/browser/power_save_blocker_win.cc +++ b/content/browser/power_save_blocker_win.cc
@@ -2,15 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "content/browser/power_save_blocker_impl.h" + #include <windows.h> -#include "base/bind.h" #include "base/logging.h" #include "base/macros.h" #include "base/strings/utf_string_conversions.h" #include "base/win/scoped_handle.h" #include "base/win/windows_version.h" -#include "content/browser/power_save_blocker_impl.h" +#include "content/public/browser/browser_thread.h" namespace content { namespace { @@ -87,12 +88,8 @@ class PowerSaveBlockerImpl::Delegate : public base::RefCountedThreadSafe<PowerSaveBlockerImpl::Delegate> { public: - Delegate(PowerSaveBlockerType type, - const std::string& description, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner) - : type_(type), - description_(description), - ui_task_runner_(ui_task_runner) {} + Delegate(PowerSaveBlockerType type, const std::string& description) + : type_(type), description_(description) {} // Does the actual work to apply or remove the desired power save block. void ApplyBlock(); @@ -108,13 +105,12 @@ PowerSaveBlockerType type_; const std::string description_; base::win::ScopedHandle handle_; - scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; DISALLOW_COPY_AND_ASSIGN(Delegate); }; void PowerSaveBlockerImpl::Delegate::ApplyBlock() { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); if (base::win::GetVersion() < base::win::VERSION_WIN7) return ApplySimpleBlock(type_, 1); @@ -122,7 +118,7 @@ } void PowerSaveBlockerImpl::Delegate::RemoveBlock() { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); if (base::win::GetVersion() < base::win::VERSION_WIN7) return ApplySimpleBlock(type_, -1); @@ -139,22 +135,19 @@ return PowerRequestExecutionRequired; } -PowerSaveBlockerImpl::PowerSaveBlockerImpl( - PowerSaveBlockerType type, - Reason reason, - const std::string& description, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner, - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) - : delegate_(new Delegate(type, description, ui_task_runner)), - ui_task_runner_(ui_task_runner), - blocking_task_runner_(blocking_task_runner) { - ui_task_runner_->PostTask(FROM_HERE, - base::Bind(&Delegate::ApplyBlock, delegate_)); +PowerSaveBlockerImpl::PowerSaveBlockerImpl(PowerSaveBlockerType type, + Reason reason, + const std::string& description) + : delegate_(new Delegate(type, description)) { + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&Delegate::ApplyBlock, delegate_)); } PowerSaveBlockerImpl::~PowerSaveBlockerImpl() { - ui_task_runner_->PostTask(FROM_HERE, - base::Bind(&Delegate::RemoveBlock, delegate_)); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&Delegate::RemoveBlock, delegate_)); } } // namespace content
diff --git a/content/browser/power_save_blocker_x11.cc b/content/browser/power_save_blocker_x11.cc index 3e76173..e80265c 100644 --- a/content/browser/power_save_blocker_x11.cc +++ b/content/browser/power_save_blocker_x11.cc
@@ -20,13 +20,13 @@ #include "base/command_line.h" #include "base/environment.h" #include "base/files/file_path.h" -#include "base/location.h" #include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/singleton.h" #include "base/nix/xdg_util.h" #include "base/synchronization/lock.h" +#include "content/public/browser/browser_thread.h" #include "dbus/bus.h" #include "dbus/message.h" #include "dbus/object_path.h" @@ -76,9 +76,7 @@ // Picks an appropriate D-Bus API to use based on the desktop environment. Delegate(PowerSaveBlockerType type, const std::string& description, - bool freedesktop_only, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner, - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); + bool freedesktop_only); // Post a task to initialize the delegate on the UI thread, which will itself // then post a task to apply the power save block on the FILE thread. @@ -115,22 +113,22 @@ // Wrapper for XScreenSaverSuspend. Checks whether the X11 Screen Saver // Extension is available first. If it isn't, this is a no-op. // Must be called on the UI thread. - void XSSSuspendSet(bool suspend); + static void XSSSuspendSet(bool suspend); // If DPMS (the power saving system in X11) is not enabled, then we don't want // to try to disable power saving, since on some desktop environments that may // enable DPMS with very poor default settings (e.g. turning off the display // after only 1 second). Must be called on the UI thread. - bool DPMSEnabled(); + static bool DPMSEnabled(); // If no other method is available (i.e. not running under a Desktop // Environment) check whether the X11 Screen Saver Extension can be used // to disable the screen saver. Must be called on the UI thread. - bool XSSAvailable(); + static bool XSSAvailable(); // Returns an appropriate D-Bus API to use based on the desktop environment. // Must be called on the UI thread, as it may call DPMSEnabled() above. - DBusAPI SelectAPI(); + static DBusAPI SelectAPI(); const PowerSaveBlockerType type_; const std::string description_; @@ -160,26 +158,18 @@ // or 0 if there is no active inhibit request. uint32_t inhibit_cookie_; - scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; - DISALLOW_COPY_AND_ASSIGN(Delegate); }; -PowerSaveBlockerImpl::Delegate::Delegate( - PowerSaveBlockerType type, - const std::string& description, - bool freedesktop_only, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner, - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) +PowerSaveBlockerImpl::Delegate::Delegate(PowerSaveBlockerType type, + const std::string& description, + bool freedesktop_only) : type_(type), description_(description), freedesktop_only_(freedesktop_only), api_(NO_API), enqueue_apply_(false), - inhibit_cookie_(0), - ui_task_runner_(ui_task_runner), - blocking_task_runner_(blocking_task_runner) { + inhibit_cookie_(0) { // We're on the client's thread here, so we don't allocate the dbus::Bus // object yet. We'll do it later in ApplyBlock(), on the FILE thread. } @@ -191,8 +181,8 @@ block_inflight_ = false; unblock_inflight_ = false; enqueue_unblock_ = false; - ui_task_runner_->PostTask(FROM_HERE, - base::Bind(&Delegate::InitOnUIThread, this)); + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(&Delegate::InitOnUIThread, this)); } void PowerSaveBlockerImpl::Delegate::CleanUp() { @@ -204,17 +194,17 @@ enqueue_apply_ = false; } else { if (ShouldBlock()) { - blocking_task_runner_->PostTask(FROM_HERE, - base::Bind(&Delegate::RemoveBlock, this)); + BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, + base::Bind(&Delegate::RemoveBlock, this)); } - ui_task_runner_->PostTask( - FROM_HERE, base::Bind(&Delegate::XSSSuspendSet, this, false)); + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, + base::Bind(&Delegate::XSSSuspendSet, false)); } } void PowerSaveBlockerImpl::Delegate::InitOnUIThread() { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); base::AutoLock lock(lock_); api_ = SelectAPI(); @@ -224,8 +214,8 @@ // D-Bus library, so we need to use the same thread above for // RemoveBlock(). It must be a thread that allows I/O operations, so we // use the FILE thread. - blocking_task_runner_->PostTask(FROM_HERE, - base::Bind(&Delegate::ApplyBlock, this)); + BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, + base::Bind(&Delegate::ApplyBlock, this)); } XSSSuspendSet(true); } @@ -237,7 +227,7 @@ } void PowerSaveBlockerImpl::Delegate::ApplyBlock() { - DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::FILE); DCHECK(!bus_); // ApplyBlock() should only be called once. DCHECK(!block_inflight_); @@ -319,7 +309,7 @@ void PowerSaveBlockerImpl::Delegate::ApplyBlockFinished( dbus::Response* response) { - DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::FILE); DCHECK(bus_); DCHECK(block_inflight_); block_inflight_ = false; @@ -339,13 +329,13 @@ enqueue_unblock_ = false; // RemoveBlock() was called while the Inhibit operation was in flight, // so go ahead and remove the block now. - blocking_task_runner_->PostTask(FROM_HERE, - base::Bind(&Delegate::RemoveBlock, this)); + BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, + base::Bind(&Delegate::RemoveBlock, this)); } } void PowerSaveBlockerImpl::Delegate::RemoveBlock() { - DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::FILE); DCHECK(bus_); // RemoveBlock() should only be called once. DCHECK(!unblock_inflight_); @@ -401,7 +391,7 @@ void PowerSaveBlockerImpl::Delegate::RemoveBlockFinished( dbus::Response* response) { - DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::FILE); DCHECK(bus_); unblock_inflight_ = false; @@ -415,8 +405,9 @@ bus_ = nullptr; } +// static void PowerSaveBlockerImpl::Delegate::XSSSuspendSet(bool suspend) { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); if (!XSSAvailable()) return; @@ -425,8 +416,9 @@ XScreenSaverSuspend(display, suspend); } +// static bool PowerSaveBlockerImpl::Delegate::DPMSEnabled() { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); XDisplay* display = gfx::GetXDisplay(); BOOL enabled = false; int dummy; @@ -437,8 +429,9 @@ return enabled; } +// static bool PowerSaveBlockerImpl::Delegate::XSSAvailable() { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); XDisplay* display = gfx::GetXDisplay(); int dummy; int major; @@ -453,8 +446,9 @@ return major > 1 || (major == 1 && minor >= 1); } +// static DBusAPI PowerSaveBlockerImpl::Delegate::SelectAPI() { - DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); + DCHECK_CURRENTLY_ON(BrowserThread::UI); std::unique_ptr<base::Environment> env(base::Environment::Create()); switch (base::nix::GetDesktopEnvironment(env.get())) { case base::nix::DESKTOP_ENVIRONMENT_GNOME: @@ -476,25 +470,16 @@ return NO_API; } -PowerSaveBlockerImpl::PowerSaveBlockerImpl( - PowerSaveBlockerType type, - Reason reason, - const std::string& description, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner, - scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) - : delegate_(new Delegate(type, - description, - false /* freedesktop_only */, - ui_task_runner, - blocking_task_runner)), - ui_task_runner_(ui_task_runner), - blocking_task_runner_(blocking_task_runner) { +PowerSaveBlockerImpl::PowerSaveBlockerImpl(PowerSaveBlockerType type, + Reason reason, + const std::string& description) + : delegate_(new Delegate(type, description, false /* freedesktop_only */)) { delegate_->Init(); if (type == kPowerSaveBlockPreventDisplaySleep) { - freedesktop_suspend_delegate_ = new Delegate( - kPowerSaveBlockPreventAppSuspension, description, - true /* freedesktop_only */, ui_task_runner, blocking_task_runner); + freedesktop_suspend_delegate_ = + new Delegate(kPowerSaveBlockPreventAppSuspension, description, + true /* freedesktop_only */); freedesktop_suspend_delegate_->Init(); } }
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc index f3f506d..175fa61 100644 --- a/content/browser/service_worker/service_worker_version.cc +++ b/content/browser/service_worker/service_worker_version.cc
@@ -335,21 +335,31 @@ if (status_ == status) return; - status_ = status; + TRACE_EVENT2("ServiceWorker", "ServiceWorkerVersion::SetStatus", "Script URL", + script_url_.spec(), "New Status", VersionStatusToString(status)); + status_ = status; if (skip_waiting_ && status_ == ACTIVATED) { for (int request_id : pending_skip_waiting_requests_) DidSkipWaiting(request_id); pending_skip_waiting_requests_.clear(); } + // OnVersionStateChanged() invokes updates of the status using state + // change IPC at ServiceWorkerHandle (for JS-land on renderer process) and + // ServiceWorkerContextCore (for devtools and serviceworker-internals). + // This should be done before using the new status by + // |status_change_callbacks_| which sends the IPC for resolving the .ready + // property. + // TODO(shimazu): Clarify the dependency of OnVersionStateChanged and + // |status_change_callbacks_| + FOR_EACH_OBSERVER(Listener, listeners_, OnVersionStateChanged(this)); + std::vector<base::Closure> callbacks; callbacks.swap(status_change_callbacks_); for (const auto& callback : callbacks) callback.Run(); - FOR_EACH_OBSERVER(Listener, listeners_, OnVersionStateChanged(this)); - if (status == INSTALLED) embedded_worker_->OnWorkerVersionInstalled(); else if (status == REDUNDANT)
diff --git a/content/browser/wake_lock/wake_lock_service_context.cc b/content/browser/wake_lock/wake_lock_service_context.cc index 7a706e8..24c0296 100644 --- a/content/browser/wake_lock/wake_lock_service_context.cc +++ b/content/browser/wake_lock/wake_lock_service_context.cc
@@ -10,7 +10,7 @@ #include "build/build_config.h" #include "content/browser/power_save_blocker_impl.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/power_save_blocker_factory.h" +#include "content/public/browser/power_save_blocker.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/common/service_registry.h" @@ -61,7 +61,7 @@ void WakeLockServiceContext::CreateWakeLock() { DCHECK(!wake_lock_); - wake_lock_ = CreatePowerSaveBlocker( + wake_lock_ = PowerSaveBlocker::Create( PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, PowerSaveBlocker::kReasonOther, "Wake Lock API");
diff --git a/content/content_browser.gypi b/content/content_browser.gypi index ac9379c5..71d766a 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi
@@ -254,7 +254,6 @@ 'public/browser/plugin_service.h', 'public/browser/plugin_service_filter.h', 'public/browser/power_save_blocker.h', - 'public/browser/power_save_blocker_factory.h', 'public/browser/presentation_screen_availability_listener.h', 'public/browser/presentation_service_delegate.h', 'public/browser/presentation_session.cc', @@ -1174,7 +1173,6 @@ 'browser/power_monitor_message_broadcaster.h', 'browser/power_save_blocker_android.h', 'browser/power_save_blocker_chromeos.cc', - 'browser/power_save_blocker_factory.cc', 'browser/power_save_blocker_impl.cc', 'browser/power_save_blocker_impl.h', 'browser/power_save_blocker_mac.cc',
diff --git a/content/content_gpu.gypi b/content/content_gpu.gypi index 041ae41..f2a21d9 100644 --- a/content/content_gpu.gypi +++ b/content/content_gpu.gypi
@@ -54,5 +54,10 @@ '<(DEPTH)/third_party/libva', ], }], + ['OS=="android"', { + 'dependencies': [ + '<(DEPTH)/media/media.gyp:player_android', + ], + }], ], }
diff --git a/content/gpu/BUILD.gn b/content/gpu/BUILD.gn index 593136e..16c4aea 100644 --- a/content/gpu/BUILD.gn +++ b/content/gpu/BUILD.gn
@@ -65,11 +65,12 @@ "//ui/gl/init", ] + if (is_android) { + deps += [ "//media/base/android" ] + } + if (mojo_media_host == "gpu") { deps += [ "//media/mojo/services" ] - if (is_android) { - deps += [ "//media/base/android" ] - } } if (is_win) {
diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc index fec9818..cc97e94 100644 --- a/content/gpu/gpu_child_thread.cc +++ b/content/gpu/gpu_child_thread.cc
@@ -47,6 +47,7 @@ #endif #if defined(OS_ANDROID) +#include "media/base/android/media_client_android.h" #include "media/gpu/avda_surface_tracker.h" #endif @@ -223,7 +224,16 @@ void GpuChildThread::Init(const base::Time& process_start_time) { process_start_time_ = process_start_time; +#if defined(OS_ANDROID) + // When running in in-process mode, this has been set in the browser at + // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). + if (!in_browser_process_) + media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid()); +#endif + + // Only set once per process instance. process_control_.reset(new GpuProcessControlImpl()); + // Use of base::Unretained(this) is safe here because |service_registry()| // will be destroyed before GpuChildThread is destructed. service_registry()->AddService(base::Bind(
diff --git a/content/gpu/gpu_process_control_impl.cc b/content/gpu/gpu_process_control_impl.cc index 832ae7d..9ec00e1 100644 --- a/content/gpu/gpu_process_control_impl.cc +++ b/content/gpu/gpu_process_control_impl.cc
@@ -7,11 +7,7 @@ #if defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) #include "base/bind.h" #include "base/bind_helpers.h" -#include "content/public/common/content_client.h" #include "media/mojo/services/mojo_media_application_factory.h" // nogncheck -#if defined(OS_ANDROID) -#include "media/base/android/media_client_android.h" -#endif #endif namespace content { @@ -22,11 +18,6 @@ void GpuProcessControlImpl::RegisterApplications(ApplicationMap* apps) { #if defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) -#if defined(OS_ANDROID) - // Only set once per process instance. - media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid()); -#endif - MojoApplicationInfo app_info; app_info.application_factory = base::Bind(&media::CreateMojoMediaApplication); app_info.use_own_thread = true;
diff --git a/content/public/browser/power_save_blocker.h b/content/public/browser/power_save_blocker.h index 6eaa9a35..7b553e7 100644 --- a/content/public/browser/power_save_blocker.h +++ b/content/public/browser/power_save_blocker.h
@@ -8,8 +8,6 @@ #include <memory> #include <string> -#include "base/memory/ref_counted.h" -#include "base/sequenced_task_runner.h" #include "content/common/content_export.h" namespace content { @@ -50,12 +48,10 @@ // |reason| and |description| (a more-verbose, human-readable justification of // the blocking) may be provided to the underlying system APIs on some // platforms. - static std::unique_ptr<PowerSaveBlocker> CreateWithTaskRunners( + static std::unique_ptr<PowerSaveBlocker> Create( PowerSaveBlockerType type, Reason reason, - const std::string& description, - scoped_refptr<base::SequencedTaskRunner> ui_task_runner, - scoped_refptr<base::SequencedTaskRunner> file_task_runner); + const std::string& description); }; } // namespace content
diff --git a/content/public/browser/power_save_blocker_factory.h b/content/public/browser/power_save_blocker_factory.h deleted file mode 100644 index a40c0ce..0000000 --- a/content/public/browser/power_save_blocker_factory.h +++ /dev/null
@@ -1,25 +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 CONTENT_PUBLIC_BROWSER_POWER_SAVE_BLOCKER_FACTORY_H_ -#define CONTENT_PUBLIC_BROWSER_POWER_SAVE_BLOCKER_FACTORY_H_ - -#include <memory> -#include <string> - -#include "base/memory/ref_counted.h" -#include "base/sequenced_task_runner.h" -#include "content/common/content_export.h" -#include "content/public/browser/power_save_blocker.h" - -namespace content { - -CONTENT_EXPORT std::unique_ptr<PowerSaveBlocker> CreatePowerSaveBlocker( - PowerSaveBlocker::PowerSaveBlockerType type, - PowerSaveBlocker::Reason reason, - const std::string& description); - -} // namespace content - -#endif // CONTENT_PUBLIC_BROWSER_POWER_SAVE_BLOCKER_FACTORY_H_
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index a5c8951..5aeca95b 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc
@@ -632,6 +632,13 @@ // Renderer.Memory histogram. Used in memory tests. const char kMemoryMetrics[] = "memory-metrics"; +// Sets options for MHTML generator to skip no-store resources: +// "skip-nostore-main" - fails to save a page if main frame is 'no-store' +// "skip-nostore-all" - also skips no-store subresources. +const char kMHTMLGeneratorOption[] = "mhtml-generator-option"; +const char kMHTMLSkipNostoreMain[] = "skip-nostore-main"; +const char kMHTMLSkipNostoreAll[] = "skip-nostore-all"; + // Use a Mojo-based LocalStorage implementation. const char kMojoLocalStorage[] = "mojo-local-storage";
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index 441ab47..162dc9f 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h
@@ -185,6 +185,9 @@ extern const char kMaxUntiledLayerHeight[]; extern const char kMaxUntiledLayerWidth[]; extern const char kMemoryMetrics[]; +CONTENT_EXPORT extern const char kMHTMLGeneratorOption[]; +CONTENT_EXPORT extern const char kMHTMLSkipNostoreMain[]; +CONTENT_EXPORT extern const char kMHTMLSkipNostoreAll[]; CONTENT_EXPORT extern const char kMojoLocalStorage[]; CONTENT_EXPORT extern const char kMuteAudio[]; CONTENT_EXPORT extern const char kNoReferrers[];
diff --git a/content/public/common/mhtml_generation_params.cc b/content/public/common/mhtml_generation_params.cc index f5011aa..8d48664 100644 --- a/content/public/common/mhtml_generation_params.cc +++ b/content/public/common/mhtml_generation_params.cc
@@ -4,11 +4,27 @@ #include "content/public/common/mhtml_generation_params.h" +#include "base/command_line.h" #include "base/files/file_path.h" +#include "content/public/common/content_switches.h" namespace content { MHTMLGenerationParams::MHTMLGenerationParams(const base::FilePath& file_path) - : file_path(file_path) {} + : file_path(file_path) { + // Check which variant of MHTML generation is required. + std::string mhtmlGeneratorOptionFlag = + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kMHTMLGeneratorOption); + if (mhtmlGeneratorOptionFlag == switches::kMHTMLSkipNostoreMain) { + cache_control_policy = + blink::WebFrameSerializerCacheControlPolicy:: + FailForNoStoreMainFrame; + } else if (mhtmlGeneratorOptionFlag == switches::kMHTMLSkipNostoreAll) { + cache_control_policy = + blink::WebFrameSerializerCacheControlPolicy:: + SkipAnyFrameOrResourceMarkedNoStore; + } +} } // namespace content
diff --git a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py index e39f268..591bdde7 100644 --- a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py +++ b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
@@ -59,7 +59,6 @@ self.Skip('deqp/functional/gles3/shadertexturefunction/*.html', bug=483282) self.Skip('deqp/functional/gles3/sync.html', bug=483282) self.Skip('deqp/functional/gles3/textureshadow.html', bug=483282) - self.Skip('deqp/functional/gles3/texturewrap.html', bug=483282) self.Skip('deqp/functional/gles3/transformfeedback.html', bug=483282) self.Skip('deqp/functional/gles3/uniformapi.html', bug=483282) self.Skip('deqp/functional/gles3/uniformbuffers.html', bug=483282) @@ -69,7 +68,6 @@ self.Fail('conformance2/glsl3/forbidden-operators.html', bug=483282) - self.Fail('conformance2/misc/expando-loss-2.html', bug=483282) self.Flaky('conformance2/query/occlusion-query.html', bug=603168) self.Fail('conformance2/vertex_arrays/vertex-array-object.html', bug=483282) @@ -351,6 +349,8 @@ ['mac'], bug=612205) self.Fail('deqp/functional/gles3/textureformat/compressed_cube.html', ['mac'], bug=612205) + self.Fail('deqp/functional/gles3/texturewrap/e*', + ['mac'], bug=612205) self.Fail('deqp/data/gles3/shaders/qualification_order.html', ['mac'], bug=483282)
diff --git a/content/test/gpu/gpu_tests/webgl_conformance_expectations.py b/content/test/gpu/gpu_tests/webgl_conformance_expectations.py index d34f2e7..c342b9d 100644 --- a/content/test/gpu/gpu_tests/webgl_conformance_expectations.py +++ b/content/test/gpu/gpu_tests/webgl_conformance_expectations.py
@@ -326,21 +326,31 @@ ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) self.Fail('conformance/glsl/bugs/sampler-struct-function-arg.html', ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) - self.Fail('conformance/glsl/misc/shader-struct-scope.html', + # This test is skipped because running it causes a future test to fail. + # The list of tests which may be that future test is very long. It is + # almost (but not quite) every webgl conformance test. + self.Skip('conformance/glsl/misc/shader-struct-scope.html', + ['android', ('qualcomm', 'Adreno (TM) 420')], bug=614550) + self.Fail('conformance/glsl/misc/shaders-with-invariance.html', ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) - self.Fail('conformance/glsl/misc/shader-uniform-packing-restrictions.html', + self.Fail('conformance/rendering/gl-viewport-test.html', ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) - self.Fail('conformance/glsl/misc/shader-varying-packing-restrictions.html', + self.Fail('conformance/textures/svg_image/' + + 'tex-2d-rgb-rgb-unsigned_byte.html', ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) - self.Fail('conformance/glsl/misc/shader-with-256-character-define.html', + self.Fail('conformance/textures/svg_image/' + + 'tex-2d-rgb-rgb-unsigned_short_5_6_5.html', ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) - self.Fail('conformance/glsl/misc/' + - 'shader-with-256-character-identifier.frag.html', + self.Fail('conformance/textures/svg_image/' + + 'tex-2d-rgba-rgba-unsigned_byte.html', ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) - self.Fail('conformance/glsl/misc/shader-with-257-character-define.html', + self.Fail('conformance/textures/svg_image/' + + 'tex-2d-rgba-rgba-unsigned_short_4_4_4_4.html', ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) - self.Fail('conformance/glsl/misc/' + - 'shader-with-257-character-identifier.frag.html', + self.Fail('conformance/textures/svg_image/' + + 'tex-2d-rgba-rgba-unsigned_short_5_5_5_1.html', + ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) + self.Fail('deqp/data/gles2/shaders/preprocessor.html', ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945) self.Fail('conformance/glsl/misc/shader-with-_webgl-identifier.vert.html', ['android', ('qualcomm', 'Adreno (TM) 420')], bug=611945)
diff --git a/content/test/test_background_sync_manager.cc b/content/test/test_background_sync_manager.cc index 441561d..85636e5 100644 --- a/content/test/test_background_sync_manager.cc +++ b/content/test/test_background_sync_manager.cc
@@ -76,7 +76,7 @@ void TestBackgroundSyncManager::DispatchSyncEvent( const std::string& tag, - const scoped_refptr<ServiceWorkerVersion>& active_version, + scoped_refptr<ServiceWorkerVersion> active_version, blink::mojom::BackgroundSyncEventLastChance last_chance, const ServiceWorkerVersion::StatusCallback& callback) { ASSERT_FALSE(dispatch_sync_callback_.is_null());
diff --git a/content/test/test_background_sync_manager.h b/content/test/test_background_sync_manager.h index 508152d..c812c21 100644 --- a/content/test/test_background_sync_manager.h +++ b/content/test/test_background_sync_manager.h
@@ -106,7 +106,7 @@ // callback instead. void DispatchSyncEvent( const std::string& tag, - const scoped_refptr<ServiceWorkerVersion>& active_version, + scoped_refptr<ServiceWorkerVersion> active_version, blink::mojom::BackgroundSyncEventLastChance last_chance, const ServiceWorkerVersion::StatusCallback& callback) override;
diff --git a/device/bluetooth/bluetooth_adapter.cc b/device/bluetooth/bluetooth_adapter.cc index 6153a12..210eadb 100644 --- a/device/bluetooth/bluetooth_adapter.cc +++ b/device/bluetooth/bluetooth_adapter.cc
@@ -164,6 +164,14 @@ AdapterPoweredChanged(this, powered)); } +void BluetoothAdapter::NotifyDeviceChanged(BluetoothDevice* device) { + DCHECK(device); + DCHECK_EQ(device->GetAdapter(), this); + + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, + DeviceChanged(this, device)); +} + #if defined(OS_CHROMEOS) || defined(OS_LINUX) void BluetoothAdapter::NotifyDevicePairedChanged(BluetoothDevice* device, bool new_paired_status) {
diff --git a/device/bluetooth/bluetooth_adapter.h b/device/bluetooth/bluetooth_adapter.h index a922456..4fcc8c7 100644 --- a/device/bluetooth/bluetooth_adapter.h +++ b/device/bluetooth/bluetooth_adapter.h
@@ -82,9 +82,22 @@ virtual void DeviceAdded(BluetoothAdapter* adapter, BluetoothDevice* device) {} - // Called when properties of the device |device| known to the adapter - // |adapter| change. |device| should not be cached. Instead, copy its - // Bluetooth address. + // Called when the result of one of the following methods of the device + // |device| changes: + // * GetAddress() + // * GetAppearance() + // * GetBluetoothClass() + // * GetInquiryRSSI() + // * GetInquiryTxPower() + // * GetUUIDs() + // * IsConnectable() + // * IsConnected() + // * IsConnecting() + // * IsGattConnected() + // * IsPaired() + // * IsTrustable() + // + // |device| should not be cached. Instead, copy its Bluetooth address. virtual void DeviceChanged(BluetoothAdapter* adapter, BluetoothDevice* device) {} @@ -428,6 +441,8 @@ // The following methods are used to send various events to observers. void NotifyAdapterStateChanged(bool powered); + void NotifyDeviceChanged(BluetoothDevice* device); + #if defined(OS_CHROMEOS) || defined(OS_LINUX) // This function is implemented for ChromeOS only, and the support on // Android, MaxOS and Windows should be added on demand in the future.
diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc index 7d37591f..fa4322f 100644 --- a/device/bluetooth/bluetooth_device.cc +++ b/device/bluetooth/bluetooth_device.cc
@@ -26,7 +26,9 @@ services_data_(new base::DictionaryValue()) {} BluetoothDevice::~BluetoothDevice() { - DidDisconnectGatt(); + for (BluetoothGattConnection* connection : gatt_connections_) { + connection->InvalidateConnectionReference(); + } } BluetoothDevice::ConnectionInfo::ConnectionInfo() @@ -335,6 +337,7 @@ } create_gatt_connection_success_callbacks_.clear(); create_gatt_connection_error_callbacks_.clear(); + GetAdapter()->NotifyDeviceChanged(this); } void BluetoothDevice::DidFailToConnectGatt(ConnectErrorCode error) { @@ -358,6 +361,7 @@ connection->InvalidateConnectionReference(); } gatt_connections_.clear(); + GetAdapter()->NotifyDeviceChanged(this); } void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) {
diff --git a/device/bluetooth/bluetooth_device_unittest.cc b/device/bluetooth/bluetooth_device_unittest.cc index 0b075e2..6ac2f63 100644 --- a/device/bluetooth/bluetooth_device_unittest.cc +++ b/device/bluetooth/bluetooth_device_unittest.cc
@@ -158,6 +158,30 @@ #endif // defined(OS_ANDROID) || defined(OS_MACOSX) #if defined(OS_ANDROID) || defined(OS_MACOSX) +TEST_F(BluetoothTest, DisconnectionNotifiesDeviceChanged) { + if (!PlatformSupportsLowEnergy()) { + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; + return; + } + InitWithFakeAdapter(); + TestBluetoothAdapterObserver observer(adapter_); + StartLowEnergyDiscoverySession(); + BluetoothDevice* device = SimulateLowEnergyDevice(3); + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), + GetConnectErrorCallback(Call::NOT_EXPECTED)); + SimulateGattConnection(device); + EXPECT_EQ(1, observer.device_changed_count()); + EXPECT_TRUE(device->IsConnected()); + EXPECT_TRUE(device->IsGattConnected()); + + SimulateGattDisconnection(device); + EXPECT_EQ(2, observer.device_changed_count()); + EXPECT_FALSE(device->IsConnected()); + EXPECT_FALSE(device->IsGattConnected()); +} +#endif // defined(OS_ANDROID) || defined(OS_MACOSX) + +#if defined(OS_ANDROID) || defined(OS_MACOSX) // Creates BluetoothGattConnection instances and tests that the interface // functions even when some Disconnect and the BluetoothDevice is destroyed. TEST_F(BluetoothTest, BluetoothGattConnection) {
diff --git a/device/bluetooth/bluez/bluetooth_adapter_bluez.cc b/device/bluetooth/bluez/bluetooth_adapter_bluez.cc index 0ab81e47..b228200c 100644 --- a/device/bluetooth/bluez/bluetooth_adapter_bluez.cc +++ b/device/bluetooth/bluez/bluetooth_adapter_bluez.cc
@@ -989,14 +989,6 @@ AdapterPresentChanged(this, present)); } -void BluetoothAdapterBlueZ::NotifyDeviceChanged(BluetoothDeviceBlueZ* device) { - DCHECK(device); - DCHECK(device->adapter_ == this); - - FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, - DeviceChanged(this, device)); -} - void BluetoothAdapterBlueZ::NotifyDeviceAddressChanged( BluetoothDeviceBlueZ* device, const std::string& old_address) {
diff --git a/device/bluetooth/bluez/bluetooth_adapter_bluez.h b/device/bluetooth/bluez/bluetooth_adapter_bluez.h index 91b8863..e8fb572 100644 --- a/device/bluetooth/bluez/bluetooth_adapter_bluez.h +++ b/device/bluetooth/bluez/bluetooth_adapter_bluez.h
@@ -127,10 +127,6 @@ // BluetoothDevice methods are by address). BluetoothDeviceBlueZ* GetDeviceWithPath(const dbus::ObjectPath& object_path); - // Announces to observers a change in device state that is not reflected by - // its D-Bus properties. |device| is owned by the caller and cannot be NULL. - void NotifyDeviceChanged(BluetoothDeviceBlueZ* device); - // Announce to observers a device address change. void NotifyDeviceAddressChanged(BluetoothDeviceBlueZ* device, const std::string& old_address);
diff --git a/extensions/browser/api/power/power_api.cc b/extensions/browser/api/power/power_api.cc index c12d86b..e8b1c53 100644 --- a/extensions/browser/api/power/power_api.cc +++ b/extensions/browser/api/power/power_api.cc
@@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/lazy_instance.h" -#include "content/public/browser/power_save_blocker_factory.h" #include "extensions/browser/extension_registry.h" #include "extensions/common/api/power.h" #include "extensions/common/extension.h" @@ -72,9 +71,9 @@ void PowerAPI::SetCreateBlockerFunctionForTesting( CreateBlockerFunction function) { - create_blocker_function_ = !function.is_null() - ? function - : base::Bind(&content::CreatePowerSaveBlocker); + create_blocker_function_ = + !function.is_null() ? function + : base::Bind(&content::PowerSaveBlocker::Create); } void PowerAPI::OnExtensionUnloaded(content::BrowserContext* browser_context, @@ -86,7 +85,7 @@ PowerAPI::PowerAPI(content::BrowserContext* context) : browser_context_(context), - create_blocker_function_(base::Bind(&content::CreatePowerSaveBlocker)), + create_blocker_function_(base::Bind(&content::PowerSaveBlocker::Create)), current_level_(api::power::LEVEL_SYSTEM) { ExtensionRegistry::Get(browser_context_)->AddObserver(this); }
diff --git a/extensions/browser/api/system_display/display_info_provider.cc b/extensions/browser/api/system_display/display_info_provider.cc index 8260a84..914cd8b5 100644 --- a/extensions/browser/api/system_display/display_info_provider.cc +++ b/extensions/browser/api/system_display/display_info_provider.cc
@@ -89,6 +89,24 @@ return all_displays; } +bool DisplayInfoProvider::OverscanCalibrationStart(const std::string& id) { + return false; +} + +bool DisplayInfoProvider::OverscanCalibrationAdjust( + const std::string& id, + const api::system_display::Insets& delta) { + return false; +} + +bool DisplayInfoProvider::OverscanCalibrationReset(const std::string& id) { + return false; +} + +bool DisplayInfoProvider::OverscanCalibrationComplete(const std::string& id) { + return false; +} + DisplayInfoProvider::DisplayInfoProvider() { }
diff --git a/extensions/browser/api/system_display/display_info_provider.h b/extensions/browser/api/system_display/display_info_provider.h index 22783a0..6715ba8 100644 --- a/extensions/browser/api/system_display/display_info_provider.h +++ b/extensions/browser/api/system_display/display_info_provider.h
@@ -22,6 +22,7 @@ namespace system_display { struct DisplayProperties; struct DisplayUnitInfo; +struct Insets; } } @@ -52,6 +53,15 @@ // Get display information. virtual DisplayUnitInfoList GetAllDisplaysInfo(); + // Implement overscan calbiration methods. See system_display.idl. These + // return false if |id| is invalid. + virtual bool OverscanCalibrationStart(const std::string& id); + virtual bool OverscanCalibrationAdjust( + const std::string& id, + const api::system_display::Insets& delta); + virtual bool OverscanCalibrationReset(const std::string& id); + virtual bool OverscanCalibrationComplete(const std::string& id); + protected: DisplayInfoProvider();
diff --git a/extensions/browser/api/system_display/system_display_api.cc b/extensions/browser/api/system_display/system_display_api.cc index b8dc9c3..03adfd7 100644 --- a/extensions/browser/api/system_display/system_display_api.cc +++ b/extensions/browser/api/system_display/system_display_api.cc
@@ -21,6 +21,22 @@ namespace SetDisplayProperties = api::system_display::SetDisplayProperties; +const char SystemDisplayFunction::kCrosOnlyError[] = + "Function available only on ChromeOS."; +const char SystemDisplayFunction::kKioskOnlyError[] = + "Only kiosk enabled extensions are allowed to use this function."; + +bool SystemDisplayFunction::CheckValidExtension() { + if (!extension()) + return true; +#if defined(OS_CHROMEOS) + if (KioskModeInfo::IsKioskEnabled(extension())) + return true; +#endif + SetError(kKioskOnlyError); + return false; +} + bool SystemDisplayGetInfoFunction::RunSync() { DisplayUnitInfoList all_displays_info = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); @@ -30,13 +46,11 @@ bool SystemDisplaySetDisplayPropertiesFunction::RunSync() { #if !defined(OS_CHROMEOS) - SetError("Function available only on ChromeOS."); + SetError(kCrosOnlyError); return false; #else - if (extension() && !KioskModeInfo::IsKioskEnabled(extension())) { - SetError("The extension needs to be kiosk enabled to use the function."); + if (!CheckValidExtension()) return false; - } std::string error; std::unique_ptr<SetDisplayProperties::Params> params( SetDisplayProperties::Params::Create(*args_)); @@ -50,9 +64,11 @@ bool SystemDisplayEnableUnifiedDesktopFunction::RunSync() { #if !defined(OS_CHROMEOS) - SetError("Function available only on ChromeOS."); + SetError(kCrosOnlyError); return false; #else + if (!CheckValidExtension()) + return false; std::unique_ptr<api::system_display::EnableUnifiedDesktop::Params> params( api::system_display::EnableUnifiedDesktop::Params::Create(*args_)); DisplayInfoProvider::Get()->EnableUnifiedDesktop(params->enabled); @@ -60,4 +76,79 @@ #endif } +bool SystemDisplayOverscanCalibrationStartFunction::RunSync() { +#if !defined(OS_CHROMEOS) + SetError(kCrosOnlyError); + return false; +#else + if (!CheckValidExtension()) + return false; + std::unique_ptr<api::system_display::OverscanCalibrationStart::Params> params( + api::system_display::OverscanCalibrationStart::Params::Create(*args_)); + if (!DisplayInfoProvider::Get()->OverscanCalibrationStart(params->id)) { + SetError("Invalid display ID: " + params->id); + return false; + } + return true; +#endif +} + +bool SystemDisplayOverscanCalibrationAdjustFunction::RunSync() { +#if !defined(OS_CHROMEOS) + SetError(kCrosOnlyError); + return false; +#else + if (!CheckValidExtension()) + return false; + std::unique_ptr<api::system_display::OverscanCalibrationAdjust::Params> + params(api::system_display::OverscanCalibrationAdjust::Params::Create( + *args_)); + if (!params) { + SetError("Invalid parameters"); + return false; + } + if (!DisplayInfoProvider::Get()->OverscanCalibrationAdjust(params->id, + params->delta)) { + SetError("Calibration not started for display ID: " + params->id); + return false; + } + return true; +#endif +} + +bool SystemDisplayOverscanCalibrationResetFunction::RunSync() { +#if !defined(OS_CHROMEOS) + SetError(kCrosOnlyError); + return false; +#else + if (!CheckValidExtension()) + return false; + std::unique_ptr<api::system_display::OverscanCalibrationReset::Params> params( + api::system_display::OverscanCalibrationReset::Params::Create(*args_)); + if (!DisplayInfoProvider::Get()->OverscanCalibrationReset(params->id)) { + SetError("Calibration not started for display ID: " + params->id); + return false; + } + return true; +#endif +} + +bool SystemDisplayOverscanCalibrationCompleteFunction::RunSync() { +#if !defined(OS_CHROMEOS) + SetError(kCrosOnlyError); + return false; +#else + if (!CheckValidExtension()) + return false; + std::unique_ptr<api::system_display::OverscanCalibrationComplete::Params> + params(api::system_display::OverscanCalibrationComplete::Params::Create( + *args_)); + if (!DisplayInfoProvider::Get()->OverscanCalibrationComplete(params->id)) { + SetError("Calibration not started for display ID: " + params->id); + return false; + } + return true; +#endif +} + } // namespace extensions
diff --git a/extensions/browser/api/system_display/system_display_api.h b/extensions/browser/api/system_display/system_display_api.h index 3c35e64..d75aaa2 100644 --- a/extensions/browser/api/system_display/system_display_api.h +++ b/extensions/browser/api/system_display/system_display_api.h
@@ -11,7 +11,17 @@ namespace extensions { -class SystemDisplayGetInfoFunction : public SyncExtensionFunction { +class SystemDisplayFunction : public SyncExtensionFunction { + public: + static const char kCrosOnlyError[]; + static const char kKioskOnlyError[]; + + protected: + ~SystemDisplayFunction() override {} + bool CheckValidExtension(); +}; + +class SystemDisplayGetInfoFunction : public SystemDisplayFunction { public: DECLARE_EXTENSION_FUNCTION("system.display.getInfo", SYSTEM_DISPLAY_GETINFO); @@ -20,7 +30,7 @@ bool RunSync() override; }; -class SystemDisplaySetDisplayPropertiesFunction : public SyncExtensionFunction { +class SystemDisplaySetDisplayPropertiesFunction : public SystemDisplayFunction { public: DECLARE_EXTENSION_FUNCTION("system.display.setDisplayProperties", SYSTEM_DISPLAY_SETDISPLAYPROPERTIES); @@ -30,7 +40,7 @@ bool RunSync() override; }; -class SystemDisplayEnableUnifiedDesktopFunction : public SyncExtensionFunction { +class SystemDisplayEnableUnifiedDesktopFunction : public SystemDisplayFunction { public: DECLARE_EXTENSION_FUNCTION("system.display.enableUnifiedDesktop", SYSTEM_DISPLAY_ENABLEUNIFIEDDESKTOP); @@ -40,6 +50,50 @@ bool RunSync() override; }; +class SystemDisplayOverscanCalibrationStartFunction + : public SystemDisplayFunction { + public: + DECLARE_EXTENSION_FUNCTION("system.display.overscanCalibrationStart", + SYSTEM_DISPLAY_OVERSCANCALIBRATIONSTART); + + protected: + ~SystemDisplayOverscanCalibrationStartFunction() override {} + bool RunSync() override; +}; + +class SystemDisplayOverscanCalibrationAdjustFunction + : public SystemDisplayFunction { + public: + DECLARE_EXTENSION_FUNCTION("system.display.overscanCalibrationAdjust", + SYSTEM_DISPLAY_OVERSCANCALIBRATIONADJUST); + + protected: + ~SystemDisplayOverscanCalibrationAdjustFunction() override {} + bool RunSync() override; +}; + +class SystemDisplayOverscanCalibrationResetFunction + : public SystemDisplayFunction { + public: + DECLARE_EXTENSION_FUNCTION("system.display.overscanCalibrationReset", + SYSTEM_DISPLAY_OVERSCANCALIBRATIONRESET); + + protected: + ~SystemDisplayOverscanCalibrationResetFunction() override {} + bool RunSync() override; +}; + +class SystemDisplayOverscanCalibrationCompleteFunction + : public SystemDisplayFunction { + public: + DECLARE_EXTENSION_FUNCTION("system.display.overscanCalibrationComplete", + SYSTEM_DISPLAY_OVERSCANCALIBRATIONCOMPLETE); + + protected: + ~SystemDisplayOverscanCalibrationCompleteFunction() override {} + bool RunSync() override; +}; + } // namespace extensions #endif // EXTENSIONS_BROWSER_API_SYSTEM_DISPLAY_SYSTEM_DISPLAY_API_H_
diff --git a/extensions/browser/api/system_display/system_display_apitest.cc b/extensions/browser/api/system_display/system_display_apitest.cc index bdca5c3..94badf48 100644 --- a/extensions/browser/api/system_display/system_display_apitest.cc +++ b/extensions/browser/api/system_display/system_display_apitest.cc
@@ -165,7 +165,7 @@ set_info_function->set_has_callback(true); EXPECT_EQ( - "Function available only on ChromeOS.", + SystemDisplayFunction::kCrosOnlyError, api_test_utils::RunFunctionAndReturnError( set_info_function.get(), "[\"display_id\", {}]", browser_context())); @@ -197,7 +197,7 @@ set_info_function->set_has_callback(true); EXPECT_EQ( - "The extension needs to be kiosk enabled to use the function.", + SystemDisplayFunction::kKioskOnlyError, api_test_utils::RunFunctionAndReturnError( set_info_function.get(), "[\"display_id\", {}]", browser_context())); @@ -267,7 +267,8 @@ " \"background\": {\n" " \"scripts\": [\"background.js\"]\n" " }\n" - " }\n" + " },\n" + " \"kiosk_enabled\": true\n" "}")); scoped_refptr<Extension> test_extension( api_test_utils::CreateExtension(test_extension_value.get()));
diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index f65223b..c6c88edc 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h
@@ -1190,6 +1190,10 @@ BLUETOOTHLOWENERGY_REMOVESERVICE, AUTOFILLPRIVATE_GETADDRESSLIST, AUTOFILLPRIVATE_GETCREDITCARDLIST, + SYSTEM_DISPLAY_OVERSCANCALIBRATIONSTART, + SYSTEM_DISPLAY_OVERSCANCALIBRATIONADJUST, + SYSTEM_DISPLAY_OVERSCANCALIBRATIONRESET, + SYSTEM_DISPLAY_OVERSCANCALIBRATIONCOMPLETE, // Last entry: Add new entries above, then run: // python tools/metrics/histograms/update_extension_histograms.py ENUM_BOUNDARY
diff --git a/extensions/common/api/system_display.idl b/extensions/common/api/system_display.idl index ccb4a71..31fe79c 100644 --- a/extensions/common/api/system_display.idl +++ b/extensions/common/api/system_display.idl
@@ -180,6 +180,30 @@ // NOTE: This is only available to Chrome OS Kiosk apps and Web UI. // |enabled|: True if unified desktop should be enabled. static void enableUnifiedDesktop(boolean enabled); + + // Starts overscan calibration for a display. This will show an overlay + // on the screen indicating the current overscan insets. If overscan + // calibration for display |id| is in progress this will reset calibration. + // |id|: The display's unique identifier. + static void overscanCalibrationStart(DOMString id); + + // Adjusts the current overscan insets for a display. Typically this should + // etiher move the display along an axis (e.g. left+right have the same + // value) or scale it along an axis (e.g. top+bottom have opposite values). + // Each Adjust call is cumulative with previous calls since Start. + // |id|: The display's unique identifier. + // |delta|: The amount to change the overscan insets. + static void overscanCalibrationAdjust(DOMString id, Insets delta); + + // Resets the overscan insets for a display to the last saved value (i.e + // before Start was called). + // |id|: The display's unique identifier. + static void overscanCalibrationReset(DOMString id); + + // Complete overscan adjustments for a display by saving the current values + // and hiding the overlay. + // |id|: The display's unique identifier. + static void overscanCalibrationComplete(DOMString id); }; interface Events {
diff --git a/extensions/common/manifest_constants.cc b/extensions/common/manifest_constants.cc index 1c3f94c..2af671c 100644 --- a/extensions/common/manifest_constants.cc +++ b/extensions/common/manifest_constants.cc
@@ -50,6 +50,7 @@ const char kFileHandlers[] = "file_handlers"; const char kFileHandlerExtensions[] = "extensions"; const char kFileHandlerTypes[] = "types"; +const char kFileHandlerVerb[] = "verb"; const char kGlobal[] = "global"; const char kHideBookmarkButton[] = "hide_bookmark_button"; const char kHomepageURL[] = "homepage_url"; @@ -407,6 +408,8 @@ "Invalid value for 'file_handlers[*].types'."; const char kInvalidFileHandlerTypeElement[] = "Invalid value for 'file_handlers[*].types[*]'."; +const char kInvalidFileHandlerVerb[] = + "Invalid value for 'file_handlers[*].verb'."; const char kInvalidGlob[] = "Invalid value for 'content_scripts[*].*[*]'."; const char kInvalidGlobList[] =
diff --git a/extensions/common/manifest_constants.h b/extensions/common/manifest_constants.h index 186c2d05..d86d1dc 100644 --- a/extensions/common/manifest_constants.h +++ b/extensions/common/manifest_constants.h
@@ -52,6 +52,7 @@ extern const char kFileHandlers[]; extern const char kFileHandlerExtensions[]; extern const char kFileHandlerTypes[]; +extern const char kFileHandlerVerb[]; extern const char kFileFilters[]; extern const char kFileBrowserHandlers[]; extern const char kGlobal[]; @@ -325,6 +326,7 @@ extern const char kInvalidFileHandlerNoTypeOrExtension[]; extern const char kInvalidFileHandlerType[]; extern const char kInvalidFileHandlerTypeElement[]; +extern const char kInvalidFileHandlerVerb[]; extern const char kInvalidGlob[]; extern const char kInvalidGlobList[]; extern const char kInvalidHomepageOverrideURL[];
diff --git a/extensions/common/manifest_handlers/file_handler_info.cc b/extensions/common/manifest_handlers/file_handler_info.cc index 68ef832..5cc615e 100644 --- a/extensions/common/manifest_handlers/file_handler_info.cc +++ b/extensions/common/manifest_handlers/file_handler_info.cc
@@ -21,12 +21,31 @@ namespace keys = manifest_keys; namespace errors = manifest_errors; +namespace file_handler_verbs { + +const char kOpenWith[] = "open_with"; +const char kAddTo[] = "add_to"; +const char kPackWith[] = "pack_with"; +const char kShareWith[] = "share_with"; + +} // namespace file_handler_verbs + namespace { + const int kMaxTypeAndExtensionHandlers = 200; const char kNotRecognized[] = "'%s' is not a recognized file handler property."; + +bool IsSupportedVerb(const std::string& verb) { + return verb == file_handler_verbs::kOpenWith || + verb == file_handler_verbs::kAddTo || + verb == file_handler_verbs::kPackWith || + verb == file_handler_verbs::kShareWith; } -FileHandlerInfo::FileHandlerInfo() : include_directories(false) {} +} // namespace + +FileHandlerInfo::FileHandlerInfo() + : include_directories(false), verb(file_handler_verbs::kOpenWith) {} FileHandlerInfo::FileHandlerInfo(const FileHandlerInfo& other) = default; FileHandlerInfo::~FileHandlerInfo() {} @@ -82,6 +101,15 @@ return false; } + handler.verb = file_handler_verbs::kOpenWith; + if (handler_info.HasKey(keys::kFileHandlerVerb) && + (!handler_info.GetString(keys::kFileHandlerVerb, &handler.verb) || + !IsSupportedVerb(handler.verb))) { + *error = ErrorUtils::FormatErrorMessageUTF16( + errors::kInvalidFileHandlerVerb, handler_id); + return false; + } + if ((!mime_types || mime_types->empty()) && (!file_extensions || file_extensions->empty()) && !handler.include_directories) { @@ -123,7 +151,8 @@ for (base::DictionaryValue::Iterator it(handler_info); !it.IsAtEnd(); it.Advance()) { if (it.key() != keys::kFileHandlerExtensions && - it.key() != keys::kFileHandlerTypes) { + it.key() != keys::kFileHandlerTypes && + it.key() != keys::kFileHandlerVerb) { install_warnings->push_back( InstallWarning(base::StringPrintf(kNotRecognized, it.key().c_str()), keys::kFileHandlers,
diff --git a/extensions/common/manifest_handlers/file_handler_info.h b/extensions/common/manifest_handlers/file_handler_info.h index 90de31c..9903fd5d 100644 --- a/extensions/common/manifest_handlers/file_handler_info.h +++ b/extensions/common/manifest_handlers/file_handler_info.h
@@ -31,6 +31,9 @@ // True if the handler can manage directories. bool include_directories; + + // A verb describing the intent of the handler. + std::string verb; }; typedef std::vector<FileHandlerInfo> FileHandlersInfo; @@ -58,6 +61,16 @@ DISALLOW_COPY_AND_ASSIGN(FileHandlersParser); }; +namespace file_handler_verbs { + +// Supported verbs for file handlers. +extern const char kOpenWith[]; +extern const char kAddTo[]; +extern const char kPackWith[]; +extern const char kShareWith[]; + +} // namespace file_handler_verbs + } // namespace extensions #endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_FILE_HANDLER_INFO_H_
diff --git a/extensions/common/manifest_handlers/file_handler_manifest_unittest.cc b/extensions/common/manifest_handlers/file_handler_manifest_unittest.cc index d55c1484..6031849 100644 --- a/extensions/common/manifest_handlers/file_handler_manifest_unittest.cc +++ b/extensions/common/manifest_handlers/file_handler_manifest_unittest.cc
@@ -16,20 +16,22 @@ TEST_F(FileHandlersManifestTest, InvalidFileHandlers) { Testcase testcases[] = { - Testcase("file_handlers_invalid_handlers.json", - errors::kInvalidFileHandlers), - Testcase("file_handlers_invalid_type.json", - errors::kInvalidFileHandlerType), - Testcase("file_handlers_invalid_extension.json", - errors::kInvalidFileHandlerExtension), - Testcase("file_handlers_invalid_no_type_or_extension.json", - errors::kInvalidFileHandlerNoTypeOrExtension), - Testcase("file_handlers_invalid_type_element.json", - errors::kInvalidFileHandlerTypeElement), - Testcase("file_handlers_invalid_extension_element.json", - errors::kInvalidFileHandlerExtensionElement), - Testcase("file_handlers_invalid_too_many.json", - errors::kInvalidFileHandlersTooManyTypesAndExtensions), + Testcase("file_handlers_invalid_handlers.json", + errors::kInvalidFileHandlers), + Testcase("file_handlers_invalid_type.json", + errors::kInvalidFileHandlerType), + Testcase("file_handlers_invalid_extension.json", + errors::kInvalidFileHandlerExtension), + Testcase("file_handlers_invalid_no_type_or_extension.json", + errors::kInvalidFileHandlerNoTypeOrExtension), + Testcase("file_handlers_invalid_type_element.json", + errors::kInvalidFileHandlerTypeElement), + Testcase("file_handlers_invalid_extension_element.json", + errors::kInvalidFileHandlerExtensionElement), + Testcase("file_handlers_invalid_too_many.json", + errors::kInvalidFileHandlersTooManyTypesAndExtensions), + Testcase("file_handlers_invalid_verb.json", + errors::kInvalidFileHandlerVerb), }; RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR); } @@ -51,6 +53,7 @@ EXPECT_EQ(2U, handler.extensions.size()); EXPECT_EQ(1U, handler.extensions.count(".png")); EXPECT_EQ(1U, handler.extensions.count(".gif")); + EXPECT_EQ("add_to", handler.verb); handler = handlers->at(1); EXPECT_EQ("text", handler.id);
diff --git a/extensions/test/data/manifest_tests/file_handlers_invalid_verb.json b/extensions/test/data/manifest_tests/file_handlers_invalid_verb.json new file mode 100644 index 0000000..65e21aa --- /dev/null +++ b/extensions/test/data/manifest_tests/file_handlers_invalid_verb.json
@@ -0,0 +1,21 @@ +{ + "name": "test", + "description": "App with file_handlers manifest.", + "version": "1", + "app": { + "background": { + "scripts": ["background.js"] + } + }, + "file_handlers": { + "text": { + "types": [ + "text/*" + ] + }, + "verb": { + "extensions": ["*"], + "verb": "invalid_verb" + } + } +}
diff --git a/extensions/test/data/manifest_tests/file_handlers_valid.json b/extensions/test/data/manifest_tests/file_handlers_valid.json index d943091..db90140 100644 --- a/extensions/test/data/manifest_tests/file_handlers_valid.json +++ b/extensions/test/data/manifest_tests/file_handlers_valid.json
@@ -20,7 +20,8 @@ "extensions": [ ".png", ".gif" - ] + ], + "verb": "add_to" } } }
diff --git a/third_party/WebKit/LayoutTests/bluetooth/requestDevice/multiple-machting-devices.html b/third_party/WebKit/LayoutTests/bluetooth/requestDevice/multiple-matching-devices.html similarity index 100% rename from third_party/WebKit/LayoutTests/bluetooth/requestDevice/multiple-machting-devices.html rename to third_party/WebKit/LayoutTests/bluetooth/requestDevice/multiple-matching-devices.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/service-workers/service-workers-view-expected.txt b/third_party/WebKit/LayoutTests/http/tests/inspector/service-workers/service-workers-view-expected.txt index ca5624be3..fb64c28a 100644 --- a/third_party/WebKit/LayoutTests/http/tests/inspector/service-workers/service-workers-view-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/service-workers/service-workers-view-expected.txt
@@ -5,6 +5,7 @@ http://127.0.0.1:8000/inspector/service-workers/resources/scope1/ Update Push +Sync Unregister Source service-worker-empty.js @@ -21,6 +22,7 @@ http://127.0.0.1:8000/inspector/service-workers/resources/scope1/ Update Push +Sync Unregister Source service-worker-empty.js @@ -36,6 +38,7 @@ http://127.0.0.1:8000/inspector/service-workers/resources/scope2/ Update Push +Sync Unregister Source service-worker-empty.js @@ -52,6 +55,7 @@ http://127.0.0.1:8000/inspector/service-workers/resources/scope1/ - deleted Update Push +Sync Unregister Source service-worker-empty.js @@ -65,6 +69,7 @@ http://127.0.0.1:8000/inspector/service-workers/resources/scope2/ Update Push +Sync Unregister Source service-worker-empty.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/ready.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/ready.html index 19f9dd32..6458093 100644 --- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/ready.html +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/ready.html
@@ -12,27 +12,26 @@ 'registrations should return the same Promise object'); }, 'ready returns the same Promise object'); -async_test(function(t) { - with_iframe('resources/blank.html?uncontrolled') +promise_test(function(t) { + return with_iframe('resources/blank.html?uncontrolled') .then(t.step_func(function(frame) { var promise = frame.contentWindow.navigator.serviceWorker.ready; assert_equals(Object.getPrototypeOf(promise), frame.contentWindow.Promise.prototype, 'the Promise should be in the context of the ' + 'related document'); - frame.remove(); - t.done(); })); }, 'ready returns a Promise object in the context of the related document'); -async_test(function(t) { +promise_test(function(t) { var url = 'resources/empty-worker.js'; var scope = 'resources/blank.html?ready-controlled'; var expected_url = normalizeURL(url); var frame; - service_worker_unregister_and_register(t, url, scope) + return service_worker_unregister_and_register(t, url, scope) .then(function(registration) { + add_completion_callback(function() { registration.unregister(); }); return wait_for_state(t, registration.installing, 'activated'); }) .then(function() { return with_iframe(scope); }) @@ -51,25 +50,26 @@ frame.contentWindow.navigator.serviceWorker.controller.scriptURL, expected_url, 'controlled document should have a controller'); - - frame.remove(); - service_worker_unregister_and_done(t, scope); - }) - .catch(unreached_rejection(t)); + assert_in_array(registration.active.state, + ['activating', 'activated'], + '.ready should be resolved when the registration ' + + 'has an active worker'); + }); }, 'ready on a controlled document'); -async_test(function(t) { +promise_test(function(t) { var url = 'resources/empty-worker.js'; var scope = 'resources/blank.html?ready-potential-controlled'; var expected_url = normalizeURL(url); var frame; - with_iframe(scope) + return with_iframe(scope) .then(function(f) { frame = f; return navigator.serviceWorker.register(url, {scope:scope}); }) - .then(function() { + .then(function(r) { + add_completion_callback(function() { r.unregister(); }); return frame.contentWindow.navigator.serviceWorker.ready; }) .then(function(registration) { @@ -79,24 +79,89 @@ 'waiting should be null.') assert_equals(registration.active.scriptURL, expected_url, 'active after ready should not be null'); + assert_in_array(registration.active.state, + ['activating', 'activated'], + '.ready should be resolved when the registration ' + + 'has an active worker'); assert_equals(frame.contentWindow.navigator.serviceWorker.controller, null, 'uncontrolled document should not have a controller'); - - frame.remove(); - service_worker_unregister_and_done(t, scope); - }) - .catch(unreached_rejection(t)); + }); }, 'ready on a potential controlled document'); -async_test(function(t) { +promise_test(function(t) { + var url = 'resources/empty-worker.js'; + var scope = 'resources/blank.html?ready-installing'; + + return service_worker_unregister(t, scope) + .then(function() { + return with_iframe(scope); + }) + .then(function(f) { + var promise = f.contentWindow.navigator.serviceWorker.ready; + navigator.serviceWorker.register(url, {scope: scope}); + return promise; + }) + .then(function(registration) { + // add_completion_callback(function() { registration.unregister(); }) + // might not work because the registration is associated with an + // iframe's context, and if the iframe is removed before calling the + // callback, unregistraion would fail. Hence we manually call + // unregister() before finishing this test and removing the iframe. + var promise = registration.unregister(); + + // |registration| should still be valid even after unregister(). + assert_equals(registration.installing, null, + 'installing should be null'); + assert_equals(registration.waiting, null, 'waiting should be null'); + assert_not_equals(registration.active, null, + 'active after ready should not be null'); + assert_in_array(registration.active.state, + ['activating', 'activated'], + '.ready should be resolved when the registration ' + + 'has an active worker'); + return promise; + }); + }, 'ready on an iframe whose parent registers a new service worker'); + +promise_test(function(t) { + var url = 'resources/empty-worker.js'; + var scope = 'resources/register-iframe.html'; + var expected_url = normalizeURL(url); + + return with_iframe(scope) + .then(function(f) { + return f.contentWindow.navigator.serviceWorker.ready; + }) + .then(function(registration) { + // add_completion_callback(function() { registration.unregister(); }) + // might not work because the registration is associated with an + // iframe's context, and if the iframe is removed before calling the + // callback, unregistraion would fail. Hence we manually call + // unregister() before finishing this test and removing the iframe. + var promise = registration.unregister(); + + // |registration| should still be valid even after unregister(). + assert_equals(registration.installing, null, + 'installing should be null'); + assert_equals(registration.waiting, null, 'waiting should be null'); + assert_not_equals(registration.active, null, + 'active after ready should not be null'); + assert_in_array(registration.active.state, + ['activating', 'activated'], + '.ready should be resolved with "active worker"'); + return promise; + }); + }, 'ready on an iframe with installing a new service worker by itself'); + +promise_test(function(t) { var url = 'resources/empty-worker.js'; var matched_scope = 'resources/blank.html?ready-after-match'; var longer_matched_scope = 'resources/blank.html?ready-after-match-longer'; var frame, registration; - Promise.all([service_worker_unregister(t, matched_scope), - service_worker_unregister(t, longer_matched_scope)]) + return Promise.all([service_worker_unregister(t, matched_scope), + service_worker_unregister(t, longer_matched_scope)]) .then(function() { return with_iframe(longer_matched_scope); }) @@ -105,6 +170,7 @@ return navigator.serviceWorker.register(url, {scope: matched_scope}); }) .then(function(r) { + add_completion_callback(function() { r.unregister(); }); registration = r; return wait_for_state(t, r.installing, 'activated'); }) @@ -112,7 +178,8 @@ return navigator.serviceWorker.register( url, {scope: longer_matched_scope}); }) - .then(function() { + .then(function(r) { + add_completion_callback(function() { r.unregister(); }); return frame.contentWindow.navigator.serviceWorker.ready; }) .then(function(r) { @@ -120,24 +187,19 @@ 'longer matched registration should be returned'); assert_equals(frame.contentWindow.navigator.serviceWorker.controller, null, 'controller should be null'); - return registration.unregister(); - }) - .then(function() { - frame.remove(); - return service_worker_unregister_and_done(t, longer_matched_scope); - }) - .catch(unreached_rejection(t)); + }); }, 'ready after a longer matched registration registered'); -async_test(function(t) { +promise_test(function(t) { var url = 'resources/empty-worker.js'; var matched_scope = 'resources/blank.html?ready-after-resolve'; var longer_matched_scope = 'resources/blank.html?ready-after-resolve-longer'; var frame, registration; - service_worker_unregister_and_register(t, url, matched_scope) + return service_worker_unregister_and_register(t, url, matched_scope) .then(function(r) { + add_completion_callback(function() { r.unregister(); }); registration = r; return wait_for_state(t, r.installing, 'activated'); }) @@ -154,19 +216,14 @@ return navigator.serviceWorker.register( url, {scope: longer_matched_scope}); }) - .then(function() { + .then(function(r) { + add_completion_callback(function() { r.unregister(); }); return frame.contentWindow.navigator.serviceWorker.ready; }) .then(function(r) { assert_equals(r.scope, normalizeURL(matched_scope), 'ready should only be resolved once'); - return registration.unregister(); - }) - .then(function() { - frame.remove(); - return service_worker_unregister_and_done(t, longer_matched_scope); - }) - .catch(unreached_rejection(t)); + }); }, 'access ready after it has been resolved'); </script>
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-iframe.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-iframe.html new file mode 100644 index 0000000..f5a040e4 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-iframe.html
@@ -0,0 +1,4 @@ +<script type="text/javascript"> +navigator.serviceWorker.register('empty-worker.js', + {scope: 'register-iframe.html'}); +</script>
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/html/dom/documents/dom-tree-accessors/nameditem-06-expected.txt b/third_party/WebKit/LayoutTests/imported/wpt/html/dom/documents/dom-tree-accessors/nameditem-06-expected.txt index 52b73e3b..1d96570 100644 --- a/third_party/WebKit/LayoutTests/imported/wpt/html/dom/documents/dom-tree-accessors/nameditem-06-expected.txt +++ b/third_party/WebKit/LayoutTests/imported/wpt/html/dom/documents/dom-tree-accessors/nameditem-06-expected.txt
@@ -1,7 +1,7 @@ This is a testharness.js-based test. PASS If there is one img, it should be returned (name) PASS If there are two imgs, a collection should be returned. (name) -PASS If there is one img, it should not be returned (id) +FAIL If there is one img, it should not be returned (id) assert_false: "test3" in document should be false expected false got true FAIL If there are two imgs, nothing should be returned. (id) assert_false: "test4" in document should be false expected false got true PASS If there are two imgs, the one with a name should be returned. (name and id) PASS If there are two imgs, the one with a name should be returned. (id and name)
diff --git a/third_party/WebKit/LayoutTests/inspector/components/color-expected.txt b/third_party/WebKit/LayoutTests/inspector/components/color-expected.txt index eb75fee2..86c7990 100644 --- a/third_party/WebKit/LayoutTests/inspector/components/color-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/components/color-expected.txt
@@ -7,7 +7,9 @@ - hsla(0, 100%, 50%, 1) - hsv(0, 100%, 100%) - hsva(0, 100%, 100%, 1) + - #ff0000ff - #ff0000 + - #f00f - #f00 - red - default: red @@ -20,8 +22,10 @@ - hsla(120, 100%, 25%, 1) - hsv(120, 100%, 50%) - hsva(120, 100%, 50%, 1) + - #008000ff - #008000 - null + - null - green - default: green - inverse color: rgba(255, 127, 255, 1) @@ -33,7 +37,9 @@ - hsla(240, 100%, 50%, 1) - hsv(240, 100%, 100%) - hsva(240, 100%, 100%, 1) + - #0000ffff - #0000ff + - #00ff - #00f - blue - default: blue @@ -46,7 +52,9 @@ - hsla(180, 100%, 50%, 1) - hsv(180, 100%, 100%) - hsva(180, 100%, 100%, 1) + - #00ffffff - #00ffff + - #0fff - #0ff - cyan - default: cyan @@ -59,7 +67,9 @@ - hsla(300, 100%, 50%, 1) - hsv(300, 100%, 100%) - hsva(300, 100%, 100%, 1) + - #ff00ffff - #ff00ff + - #f0ff - #f0f - magenta - default: magenta @@ -72,7 +82,9 @@ - hsla(60, 100%, 50%, 1) - hsv(60, 100%, 100%) - hsva(60, 100%, 100%, 1) + - #ffff00ff - #ffff00 + - #ff0f - #ff0 - yellow - default: yellow @@ -85,7 +97,9 @@ - hsla(0, 0%, 100%, 1) - hsv(0, 0%, 100%) - hsva(0, 0%, 100%, 1) + - #ffffffff - #ffffff + - #ffff - #fff - white - default: white @@ -98,7 +112,9 @@ - hsla(0, 0%, 0%, 1) - hsv(0, 0%, 0%) - hsva(0, 0%, 0%, 1) + - #000000ff - #000000 + - #000f - #000 - black - default: black @@ -111,9 +127,11 @@ - hsla(115, 16%, 43%, 1) - hsv(115, 28%, 49%) - hsva(115, 28%, 49%, 1) + - #5e7e5bff - #5e7e5b - null - null + - null - default: rgb(94, 126, 91) - inverse color: rgba(161, 129, 164, 1) - setAlpha(0.42): rgba(94, 126, 91, 0.42) @@ -124,6 +142,8 @@ - hsla(115, 16%, 43%, 0.5) - hsv(115, 28%, 49%) - hsva(115, 28%, 49%, 0.5) + - #5e7e5b80 + - null - null - null - null @@ -137,9 +157,11 @@ - hsla(212, 55%, 32%, 1) - hsv(212, 71%, 50%) - hsva(212, 71%, 50%, 1) + - #254f7eff - #254f7e - null - null + - null - default: hsl(212, 55%, 32%) - inverse color: rgba(218, 176, 129, 1) - setAlpha(0.42): rgba(37, 79, 126, 0.42) @@ -150,12 +172,29 @@ - hsla(212, 55%, 32%, 0.5) - hsv(212, 71%, 50%) - hsva(212, 71%, 50%, 0.5) + - #254f7e80 + - null - null - null - null - default: hsla(212, 55%, 32%, 0.5) - inverse color: rgba(218, 176, 129, 0.5) - setAlpha(0.42): rgba(37, 79, 126, 0.42) +Dumping '#12345678' in different formats: + - null + - rgba(18, 52, 86, 0.47058823529411764) + - null + - hsla(210, 65%, 20%, 0.47058823529411764) + - hsv(210, 79%, 34%) + - hsva(210, 79%, 34%, 0.47058823529411764) + - #12345678 + - null + - null + - null + - null + - default: #12345678 + - inverse color: rgba(237, 203, 169, 0.47058823529411764) + - setAlpha(0.42): rgba(18, 52, 86, 0.42) Dumping '#00FFFF' in different formats: - rgb(0, 255, 255) - rgba(0, 255, 255, 1) @@ -163,12 +202,29 @@ - hsla(180, 100%, 50%, 1) - hsv(180, 100%, 100%) - hsva(180, 100%, 100%, 1) + - #00ffffff - #00FFFF + - #0fff - #0ff - cyan - default: #00ffff - inverse color: rgba(255, 0, 0, 1) - setAlpha(0.42): rgba(0, 255, 255, 0.42) +Dumping '#1234' in different formats: + - null + - rgba(17, 34, 51, 0.26666666666666666) + - null + - hsla(210, 50%, 13%, 0.26666666666666666) + - hsv(210, 67%, 20%) + - hsva(210, 67%, 20%, 0.26666666666666666) + - #11223344 + - null + - #1234 + - null + - null + - default: #1234 + - inverse color: rgba(238, 221, 204, 0.26666666666666666) + - setAlpha(0.42): rgba(17, 34, 51, 0.42) Dumping '#0FF' in different formats: - rgb(0, 255, 255) - rgba(0, 255, 255, 1) @@ -176,7 +232,9 @@ - hsla(180, 100%, 50%, 1) - hsv(180, 100%, 100%) - hsva(180, 100%, 100%, 1) + - #00ffffff - #00ffff + - #0fff - #0FF - cyan - default: #0ff
diff --git a/third_party/WebKit/LayoutTests/inspector/components/color.html b/third_party/WebKit/LayoutTests/inspector/components/color.html index 4c54b2d..2813ea2b 100644 --- a/third_party/WebKit/LayoutTests/inspector/components/color.html +++ b/third_party/WebKit/LayoutTests/inspector/components/color.html
@@ -21,7 +21,9 @@ var hsvaString = String.sprintf("hsva(%d, %d%, %d%, %f)", Math.round(hsva[0] * 360), Math.round(hsva[1] * 100), Math.round(hsva[2] * 100), hsva[3]); InspectorTest.addResult(" - " + hsvaString); + InspectorTest.addResult(" - " + color.asString(WebInspector.Color.Format.HEXA)); InspectorTest.addResult(" - " + color.asString(WebInspector.Color.Format.HEX)); + InspectorTest.addResult(" - " + color.asString(WebInspector.Color.Format.ShortHEXA)); InspectorTest.addResult(" - " + color.asString(WebInspector.Color.Format.ShortHEX)); InspectorTest.addResult(" - " + color.asString(WebInspector.Color.Format.Nickname)); InspectorTest.addResult(" - default: " + color.asString()); @@ -45,7 +47,9 @@ dumpColor("hsl(212, 55%, 32%)"); dumpColor("hsla(212, 55%, 32%, 0.5)"); + dumpColor("#12345678"); dumpColor("#00FFFF"); + dumpColor("#1234"); dumpColor("#0FF"); InspectorTest.completeTest(); }
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/styles-3/spectrum-expected.txt b/third_party/WebKit/LayoutTests/inspector/elements/styles-3/spectrum-expected.txt index 8e2f7f1..c10d6167 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/styles-3/spectrum-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/elements/styles-3/spectrum-expected.txt
@@ -5,8 +5,12 @@ red Testing: #ABC #abc +Testing: #1234 +#1234 Testing: #ABCDEF #abcdef +Testing: #ABCDEFAA +#abcdefaa Testing: rgb(1, 2, 3) rgb(1, 2, 3) Testing: rgba(1, 2, 3, 0.2) @@ -19,9 +23,13 @@ Testing: red rgba(255, 0, 0, 0) Testing: #ABC -rgba(170, 187, 204, 0) +#abc0 +Testing: #1234 +#1230 Testing: #ABCDEF -rgba(171, 205, 239, 0) +#abcdef00 +Testing: #ABCDEFAA +#abcdef00 Testing: rgb(1, 2, 3) rgba(1, 2, 3, 0) Testing: rgba(1, 2, 3, 0.2) @@ -37,19 +45,25 @@ Testing: #ABC rgb hsl +Testing: #1234 +rgb +hsl Testing: #ABCDEF rgb hsl +Testing: #ABCDEFAA +rgb +hsl Testing: rgb(1, 2, 3) hsl hex Testing: rgba(1, 2, 3, 0.2) hsl -rgb +hex Testing: hsl(1, 100%, 50%) hex rgb Testing: hsla(1, 100%, 50%, 0.2) +hex rgb -hsl
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/styles-3/spectrum.html b/third_party/WebKit/LayoutTests/inspector/elements/styles-3/spectrum.html index 81e0a9ef..0bf241b 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/styles-3/spectrum.html +++ b/third_party/WebKit/LayoutTests/inspector/elements/styles-3/spectrum.html
@@ -41,7 +41,9 @@ var inputColors = [ { string: "red", format: cf.Nickname }, { string: "#ABC", format: cf.ShortHEX }, + { string: "#1234", format: cf.ShortHEXA }, { string: "#ABCDEF", format: cf.HEX }, + { string: "#ABCDEFAA", format: cf.HEXA }, { string: "rgb(1, 2, 3)", format: cf.RGB }, { string: "rgba(1, 2, 3, 0.2)", format: cf.RGB }, { string: "hsl(1, 100%, 50%)", format: cf.HSL },
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/styles-4/styles-invalid-color-values-expected.txt b/third_party/WebKit/LayoutTests/inspector/elements/styles-4/styles-invalid-color-values-expected.txt index 29d72a7..bc9e06a8 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/styles-4/styles-invalid-color-values-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector/elements/styles-4/styles-invalid-color-values-expected.txt
@@ -9,6 +9,8 @@ nickname: red hex: #ff0000 shorthex: #f00 + hexa: #ff0000ff + shorthexa: #f00f rgb: rgb(255, 0, 0) hsl: hsl(0, 100%, 50%) @@ -18,6 +20,41 @@ nickname: red hex: #ff0000 shorthex: #F00 + hexa: #ff0000ff + shorthexa: #f00f + rgb: rgb(255, 0, 0) + hsl: hsl(0, 100%, 50%) + +color: #F00F + simple: true + original: #F00F + nickname: red + hex: #ff0000 + shorthex: #f00 + hexa: #ff0000ff + shorthexa: #F00F + rgb: rgb(255, 0, 0) + hsl: hsl(0, 100%, 50%) + +color: #FF0000 + simple: true + original: #FF0000 + nickname: red + hex: #FF0000 + shorthex: #f00 + hexa: #ff0000ff + shorthexa: #f00f + rgb: rgb(255, 0, 0) + hsl: hsl(0, 100%, 50%) + +color: #FF0000FF + simple: true + original: #FF0000FF + nickname: red + hex: #ff0000 + shorthex: #f00 + hexa: #FF0000FF + shorthexa: #f00f rgb: rgb(255, 0, 0) hsl: hsl(0, 100%, 50%) @@ -27,6 +64,8 @@ nickname: red hex: #ff0000 shorthex: #f00 + hexa: #ff0000ff + shorthexa: #f00f rgb: rgb(255,0,0) hsl: hsl(0, 100%, 50%) @@ -36,6 +75,8 @@ nickname: red hex: #ff0000 shorthex: #f00 + hexa: #ff0000ff + shorthexa: #f00f rgb: rgb(255, 0, 0) hsl: hsl(0, 100%, 50%) @@ -45,6 +86,8 @@ nickname: red hex: #ff0000 shorthex: #f00 + hexa: #ff0000ff + shorthexa: #f00f rgb: rgb(255, 0, 0) hsl: hsl(0, 100%, 50%) @@ -54,12 +97,16 @@ nickname: red hex: #ff0000 shorthex: #f00 + hexa: #ff0000ff + shorthexa: #f00f rgb: rgb(255, 0, 0) hsl: hsl(0, 100%, 50%) color: rgba(0,0,0,0.5) simple: false original: rgba(0,0,0,0.5) + hexa: #00000080 + shorthexa: null rgb: null rgba: rgba(0,0,0,0.5) hsl: null @@ -71,6 +118,8 @@ nickname: blue hex: #0000ff shorthex: #00f + hexa: #0000ffff + shorthexa: #00ff rgb: rgb(0, 0, 255) hsl: hsl(-120, 100%, 50%) @@ -80,6 +129,8 @@ nickname: white hex: #ffffff shorthex: #fff + hexa: #ffffffff + shorthexa: #ffff rgb: rgb(255, 255, 255) hsl: hsl(-120, 200%, 200%) @@ -89,6 +140,8 @@ nickname: black hex: #000000 shorthex: #000 + hexa: #000000ff + shorthexa: #000f rgb: rgb(0, 0, 0) hsl: hsl(0, 0%, 0%) @@ -96,6 +149,8 @@ simple: false original: hsla(-120, -200%, -200%, -5) nickname: transparent + hexa: #00000000 + shorthexa: #0000 rgb: null rgba: rgba(0, 0, 0, 0) hsl: null @@ -104,6 +159,8 @@ color: hsla(240,100%,50%,0.05) simple: false original: hsla(240,100%,50%,0.05) + hexa: #0000ff0d + shorthexa: null rgb: null rgba: rgba(0, 0, 255, 0.05) hsl: null @@ -114,6 +171,8 @@ original: hsl(200.5,0%,50%) nickname: grey hex: #808080 + hexa: #808080ff + shorthexa: null rgb: rgb(128, 128, 128) hsl: hsl(200.5,0%,50%) @@ -121,12 +180,16 @@ simple: true original: hsla(200,1.5%,50%,1) hex: #7e8081 + hexa: #7e8081ff + shorthexa: null rgb: rgb(126, 128, 129) hsl: hsl(200, 1%, 50%) color: rgba(0,0,0,.5) simple: false original: rgba(0,0,0,.5) + hexa: #00000080 + shorthexa: null rgb: null rgba: rgba(0,0,0,.5) hsl: null @@ -135,6 +198,8 @@ color: hsla(.5,.5%,.5%,.5) simple: false original: hsla(.5,.5%,.5%,.5) + hexa: #01010180 + shorthexa: null rgb: null rgba: rgba(1, 1, 1, 0.5) hsl: null @@ -143,6 +208,8 @@ color: hsla(100.5,50.5%,50.5%,.5) simple: false original: hsla(100.5,50.5%,50.5%,.5) + hexa: #6ac14180 + shorthexa: null rgb: null rgba: rgba(106, 193, 65, 0.5) hsl: null @@ -151,6 +218,8 @@ color: rgba(255, 0, 0, -5) simple: false original: rgba(255, 0, 0, -5) + hexa: #ff000000 + shorthexa: #f000 rgb: null rgba: rgba(255, 0, 0, 0) hsl: null @@ -162,6 +231,8 @@ nickname: red hex: #ff0000 shorthex: #f00 + hexa: #ff0000ff + shorthexa: #f00f rgb: rgb(255, 0, 0) hsl: hsl(0, 100%, 50%) @@ -169,8 +240,6 @@ SUCCESS: parsed invalid color none to null -SUCCESS: parsed invalid color #0000 to null - SUCCESS: parsed invalid color #00000 to null SUCCESS: parsed invalid color #ggg to null
diff --git a/third_party/WebKit/LayoutTests/inspector/elements/styles-4/styles-invalid-color-values.html b/third_party/WebKit/LayoutTests/inspector/elements/styles-4/styles-invalid-color-values.html index 6ad4d68..7f139ce3 100644 --- a/third_party/WebKit/LayoutTests/inspector/elements/styles-4/styles-invalid-color-values.html +++ b/third_party/WebKit/LayoutTests/inspector/elements/styles-4/styles-invalid-color-values.html
@@ -9,6 +9,9 @@ // Each of these is red. Some may need to be clipped to [0, 255]. 'red', '#F00', + '#F00F', + '#FF0000', + '#FF0000FF', 'rgb(255,0,0)', 'rgb(300,0,0)', // clipped to rgb(255,0,0) 'rgb(255,-10,0)', // clipped to rgb(255,0,0) @@ -35,7 +38,6 @@ var invalidColors = [ // An invalid color, eg a value for a shorthand like 'border' which can have a color 'none', - '#0000', '#00000', '#ggg', 'rgb(a,b,c)', @@ -98,7 +100,7 @@ if (color.hasAlpha() && (colorFormat === cf.ShortHEX || colorFormat === cf.HEX)) continue; // If there is no ShortHEX then skip it. - if (colorFormat === cf.ShortHEX && !color.canBeShortHex()) + if (colorFormat === cf.ShortHEX && color.detectHEXFormat() !== cf.ShortHEX) continue; // If there is no nickname, then skip it. if (colorFormat === cf.Nickname && !color.nickname())
diff --git a/third_party/WebKit/LayoutTests/platform/linux-precise/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png b/third_party/WebKit/LayoutTests/platform/linux-precise/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png deleted file mode 100644 index ce02af0..0000000 --- a/third_party/WebKit/LayoutTests/platform/linux-precise/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac-mac10.10/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png b/third_party/WebKit/LayoutTests/platform/mac-mac10.10/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png deleted file mode 100644 index 5b0bf80..0000000 --- a/third_party/WebKit/LayoutTests/platform/mac-mac10.10/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac-mac10.9/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png b/third_party/WebKit/LayoutTests/platform/mac-mac10.9/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png deleted file mode 100644 index 5b0bf80..0000000 --- a/third_party/WebKit/LayoutTests/platform/mac-mac10.9/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac-retina/scrollbars/custom-scrollbar-appearance-property-expected.png b/third_party/WebKit/LayoutTests/platform/mac-retina/scrollbars/custom-scrollbar-appearance-property-expected.png deleted file mode 100644 index a0c6f1ed..0000000 --- a/third_party/WebKit/LayoutTests/platform/mac-retina/scrollbars/custom-scrollbar-appearance-property-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac-retina/scrollbars/custom-scrollbar-appearance-property-expected.txt b/third_party/WebKit/LayoutTests/platform/mac-retina/scrollbars/custom-scrollbar-appearance-property-expected.txt deleted file mode 100644 index 950d3cfd..0000000 --- a/third_party/WebKit/LayoutTests/platform/mac-retina/scrollbars/custom-scrollbar-appearance-property-expected.txt +++ /dev/null
@@ -1,11 +0,0 @@ -layer at (0,0) size 800x600 - LayoutView at (0,0) size 800x600 -layer at (0,0) size 800x84 - LayoutBlockFlow {HTML} at (0,0) size 800x84 - LayoutBlockFlow {BODY} at (8,8) size 784x68 - LayoutBlockFlow (anonymous) at (0,0) size 784x18 - LayoutText {#text} at (0,0) size 132x18 - text run at (0,0) width 132: "PASS if not crashed." -layer at (8,26) size 50x50 clip at (8,26) size 35x36 scrollWidth 200 scrollHeight 200 - LayoutBlockFlow {DIV} at (0,18) size 50x50 - LayoutBlockFlow {DIV} at (0,0) size 200x200
diff --git a/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png b/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png deleted file mode 100644 index a0c6f1ed..0000000 --- a/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.txt b/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.txt deleted file mode 100644 index 950d3cfd..0000000 --- a/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.txt +++ /dev/null
@@ -1,11 +0,0 @@ -layer at (0,0) size 800x600 - LayoutView at (0,0) size 800x600 -layer at (0,0) size 800x84 - LayoutBlockFlow {HTML} at (0,0) size 800x84 - LayoutBlockFlow {BODY} at (8,8) size 784x68 - LayoutBlockFlow (anonymous) at (0,0) size 784x18 - LayoutText {#text} at (0,0) size 132x18 - text run at (0,0) width 132: "PASS if not crashed." -layer at (8,26) size 50x50 clip at (8,26) size 35x36 scrollWidth 200 scrollHeight 200 - LayoutBlockFlow {DIV} at (0,18) size 50x50 - LayoutBlockFlow {DIV} at (0,0) size 200x200
diff --git a/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/rootlayerscrolls/scrollbars/custom-scrollbar-appearance-property-expected.png b/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/rootlayerscrolls/scrollbars/custom-scrollbar-appearance-property-expected.png deleted file mode 100644 index a0c6f1ed..0000000 --- a/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/rootlayerscrolls/scrollbars/custom-scrollbar-appearance-property-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/rootlayerscrolls/scrollbars/custom-scrollbar-appearance-property-expected.txt b/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/rootlayerscrolls/scrollbars/custom-scrollbar-appearance-property-expected.txt deleted file mode 100644 index 950d3cfd..0000000 --- a/third_party/WebKit/LayoutTests/platform/mac-retina/virtual/rootlayerscrolls/scrollbars/custom-scrollbar-appearance-property-expected.txt +++ /dev/null
@@ -1,11 +0,0 @@ -layer at (0,0) size 800x600 - LayoutView at (0,0) size 800x600 -layer at (0,0) size 800x84 - LayoutBlockFlow {HTML} at (0,0) size 800x84 - LayoutBlockFlow {BODY} at (8,8) size 784x68 - LayoutBlockFlow (anonymous) at (0,0) size 784x18 - LayoutText {#text} at (0,0) size 132x18 - text run at (0,0) width 132: "PASS if not crashed." -layer at (8,26) size 50x50 clip at (8,26) size 35x36 scrollWidth 200 scrollHeight 200 - LayoutBlockFlow {DIV} at (0,18) size 50x50 - LayoutBlockFlow {DIV} at (0,0) size 200x200
diff --git a/third_party/WebKit/LayoutTests/platform/win7/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png b/third_party/WebKit/LayoutTests/platform/win7/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png deleted file mode 100644 index be20160..0000000 --- a/third_party/WebKit/LayoutTests/platform/win7/virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scrollbar-appearance-property-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/WebKit/LayoutTests/presentation/iframe-no-sandbox.html b/third_party/WebKit/LayoutTests/presentation/iframe-no-sandbox.html new file mode 100644 index 0000000..061cd333 --- /dev/null +++ b/third_party/WebKit/LayoutTests/presentation/iframe-no-sandbox.html
@@ -0,0 +1,31 @@ +<!DOCTYPE html> +<html> +<body> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> + +<iframe></iframe> + +<script> + +async_test(function(t) { + window.onmessage = t.step_func_done(function(e) { + e.data.forEach(function(result) { + if (result.test == 'getAvailability') { + assert_equals(result.status, 'success', result.test); + return; + } + + // TODO(mlamouri): we are only testing that it doesn't fail for security + // reasons because the request will still fail for lack of devices/backend. + assert_equals(result.status, 'failure', result.test); + assert_not_equals(result.name, 'SecurityError', result.test); + }); + }); + + document.querySelector('iframe').src = 'resources/embedded-smoke-tests.html'; +}, 'Test that Presentation API works from inside an iframe.'); + +</script> +</body> +</html>
diff --git a/third_party/WebKit/LayoutTests/presentation/iframe-sandbox-allow-presentation.html b/third_party/WebKit/LayoutTests/presentation/iframe-sandbox-allow-presentation.html new file mode 100644 index 0000000..8e47458 --- /dev/null +++ b/third_party/WebKit/LayoutTests/presentation/iframe-sandbox-allow-presentation.html
@@ -0,0 +1,31 @@ +<!DOCTYPE html> +<html> +<body> +<script src='../resources/testharness.js'></script> +<script src='../resources/testharnessreport.js'></script> + +<iframe sandbox='allow-scripts allow-same-origin allow-presentation'></iframe> + +<script> + +async_test(function(t) { + window.onmessage = t.step_func_done(function(e) { + e.data.forEach(function(result) { + if (result.test == 'getAvailability') { + assert_equals(result.status, 'success', result.test); + return; + } + + // TODO(mlamouri): we are only testing that it doesn't fail for security + // reasons because the request will still fail for lack of devices/backend. + assert_equals(result.status, 'failure', result.test); + assert_not_equals(result.name, 'SecurityError', result.test); + }); + }); + + document.querySelector('iframe').src = 'resources/embedded-smoke-tests.html'; +}, 'Test that calling Presentation API works from inside a sandboxed iframe with "allow-presentation".'); + +</script> +</body> +</html>
diff --git a/third_party/WebKit/LayoutTests/presentation/iframe-sandbox-default.html b/third_party/WebKit/LayoutTests/presentation/iframe-sandbox-default.html new file mode 100644 index 0000000..4857da904 --- /dev/null +++ b/third_party/WebKit/LayoutTests/presentation/iframe-sandbox-default.html
@@ -0,0 +1,24 @@ +<!DOCTYPE html> +<html> +<body> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> + +<iframe sandbox='allow-scripts allow-same-origin'></iframe> + +<script> + +async_test(function(t) { + window.onmessage = t.step_func_done(function(e) { + e.data.forEach(function(result) { + assert_equals(result.status, 'failure', result.test); + assert_equals(result.name, 'SecurityError', result.test); + }); + }); + + document.querySelector('iframe').src = 'resources/embedded-smoke-tests.html'; +}, 'Test that Presentation API is blocked inside a sandboxed iframe without "allow-presentation".'); + +</script> +</body> +</html>
diff --git a/third_party/WebKit/LayoutTests/presentation/resources/embedded-smoke-tests.html b/third_party/WebKit/LayoutTests/presentation/resources/embedded-smoke-tests.html new file mode 100644 index 0000000..2769287 --- /dev/null +++ b/third_party/WebKit/LayoutTests/presentation/resources/embedded-smoke-tests.html
@@ -0,0 +1,88 @@ +<!DOCTYPE html> +<html> +<body> +<script> + +var FAKE_SESSION_ID = 'fake'; +var gCurrentConnection = null; + +// Returns the test runner used to run this test.. +// Current possible values are 'blink' and 'manual'. +function getTestRunner() { + if ('internals' in window) + return 'blink'; + return 'manual'; +} + +// Returns a promise that is resolved when the user press a 'click me' button or +// is automatically resolved if a supported test runner is detected. +function getUserGesture() { + return new Promise(function (resolve) { + switch (getTestRunner()) { + case 'blink': + internals.settings.setPresentationRequiresUserGesture(false); + setTimeout(resolve); + break; + case 'manual': + var button = document.createElement('button'); + button.textContent = 'click me'; + button.onclick = function() { + document.body.removeChild(button); + resolve(); + }; + document.body.appendChild(button); + break; + default: + parent.window.postMessage({ error: 'unknown test runner' }, '*'); + } + }); +} + +var results = []; + +// start() +getUserGesture().then(function() { + if (getTestRunner() == 'manual') { + var description = document.createElement('div'); + description.id = 'description'; + description.textContent = 'Pick a device if asked for it'; + document.body.appendChild(description); + } + + var p = new PresentationRequest('https://example.com'); + return p.start().then(function(connection) { + gCurrentConnection = connection; + results.push({ test: 'start', status: 'success' }) + }, function(e) { + results.push({ test: 'start', status: 'failure', name: e.name }); + }).then(function() { + if (getTestRunner() == 'manual') + document.body.removeChild(document.querySelector('#description')); + }); +}).then(function() { + // reconnect() + return getUserGesture().then(function() { + var p = new PresentationRequest('https://example.com'); + return p.reconnect(gCurrentConnection ? gCurrentConnection.id : FAKE_SESSION_ID).then(function() { + results.push({ test: 'reconnect', status: 'success' }) + }, function(e) { + results.push({ test: 'reconnect', status: 'failure', name: e.name }); + }); + }); +}).then(function() { + // getAvailability() + return getUserGesture().then(function() { + var p = new PresentationRequest('https://example.com'); + return p.getAvailability().then(function() { + results.push({ test: 'getAvailability', status: 'success' }) + }, function(e) { + results.push({ test: 'getAvailability', status: 'failure', name: e.name }); + }); + }); +}).then(function() { + parent.window.postMessage(results, '*'); +}); + +</script> +</body> +</html>
diff --git a/third_party/WebKit/LayoutTests/svg/text/obb-paintserver.html b/third_party/WebKit/LayoutTests/svg/text/obb-paintserver.html index cf8ba7f..9d8cc7e 100644 --- a/third_party/WebKit/LayoutTests/svg/text/obb-paintserver.html +++ b/third_party/WebKit/LayoutTests/svg/text/obb-paintserver.html
@@ -1,4 +1,5 @@ <!DOCTYPE html> +<script src="../../resources/ahem.js"></script> <svg width="200" height="400"> <linearGradient id="gradient" x1="0" x2="0" y1="0" y2="1"> <stop offset="0" stop-color="green"/>
diff --git a/third_party/WebKit/LayoutTests/typedcssom/cssLengthValue.html b/third_party/WebKit/LayoutTests/typedcssom/cssLengthValue.html index 46013f1..6f5a408 100644 --- a/third_party/WebKit/LayoutTests/typedcssom/cssLengthValue.html +++ b/third_party/WebKit/LayoutTests/typedcssom/cssLengthValue.html
@@ -5,10 +5,10 @@ test(function() { var result = CSSLengthValue.from(5, 'px'); - assert_true(result instanceof SimpleLength); + assert_true(result instanceof CSSSimpleLength); assert_equals(result.value, 5); assert_equals(result.type, 'px'); -}, "Test that CSSLengthValue's static from(double value, LengthType type) method produces a SimpleLength."); +}, "Test that CSSLengthValue's static from(double value, LengthType type) method produces a CSSSimpleLength."); test(function() { var result = CSSLengthValue.from({px: 1, percent: 2.5});
diff --git a/third_party/WebKit/LayoutTests/typedcssom/cssPositionValue.html b/third_party/WebKit/LayoutTests/typedcssom/cssPositionValue.html index 4dcbb03..0e9d416 100644 --- a/third_party/WebKit/LayoutTests/typedcssom/cssPositionValue.html +++ b/third_party/WebKit/LayoutTests/typedcssom/cssPositionValue.html
@@ -5,14 +5,14 @@ <script> test(function() { - assert_equals(new CSSPositionValue(new SimpleLength(50, 'px'), + assert_equals(new CSSPositionValue(new CSSSimpleLength(50, 'px'), new CalcLength({px: -10, em: -3.2, pt: 0})).cssString, '50px calc((-3.2em - 10px) + 0pt)'); - assert_equals(new CSSPositionValue(new SimpleLength(50, 'px'), - new SimpleLength(2, 'em')).cssString, '50px 2em'); + assert_equals(new CSSPositionValue(new CSSSimpleLength(50, 'px'), + new CSSSimpleLength(2, 'em')).cssString, '50px 2em'); assert_equals(new CSSPositionValue(new CalcLength({px: -10, em: -3.2, pt: 0}), new CalcLength({px: -10, em: 3.2})).cssString, 'calc((-3.2em - 10px) + 0pt) calc(3.2em - 10px)'); assert_equals(new CSSPositionValue(new CalcLength({px: -10, em: -3.2, pt: 0}), - new SimpleLength(10, 'percent')).cssString, 'calc((-3.2em - 10px) + 0pt) 10%'); + new CSSSimpleLength(10, 'percent')).cssString, 'calc((-3.2em - 10px) + 0pt) 10%'); }, "cssString returns a string with the x and y positions cssStrings separated by a space"); </script>
diff --git a/third_party/WebKit/LayoutTests/typedcssom/cssSimpleLength.html b/third_party/WebKit/LayoutTests/typedcssom/cssSimpleLength.html new file mode 100644 index 0000000..537de59 --- /dev/null +++ b/third_party/WebKit/LayoutTests/typedcssom/cssSimpleLength.html
@@ -0,0 +1,133 @@ +<!DOCTYPE html> +<script src='../resources/testharness.js'></script> +<script src='../resources/testharnessreport.js'></script> + +<script> + +test(function() { + var simpleLength1 = new CSSSimpleLength(5.1, 'px'); + var simpleLength2 = new CSSSimpleLength(10, 'px'); + + var result = simpleLength1.add(simpleLength2); + + assert_not_equals(simpleLength1, result); + assert_not_equals(simpleLength2, result); + assert_true(result instanceof CSSSimpleLength); + assert_equals(result.value, 15.1); + assert_equals(result.type, 'px'); +}, 'Test that adding CSSSimpleLengths with the same unit produces a new CSSSimpleLength with the correct value.'); + +test(function() { + var simpleLength1 = new CSSSimpleLength(5.1, 'px'); + var simpleLength2 = new CSSSimpleLength(10, 'percent'); + + var result = simpleLength1.add(simpleLength2); + + assert_true(result instanceof CalcLength); + assert_equals(result.px, 5.1); + assert_equals(result.percent, 10); +}, 'Test that adding CSSSimpleLengths with different units produces a calc length with the correct values.'); + +test(function() { + var simpleLength1 = new CSSSimpleLength(5.1, 'px'); + var simpleLength2 = new CSSSimpleLength(10, 'px'); + + var result = simpleLength1.subtract(simpleLength2); + + assert_not_equals(simpleLength1, result); + assert_not_equals(simpleLength2, result); + assert_true(result instanceof CSSSimpleLength); + assert_equals(result.value, -4.9); + assert_equals(result.type, 'px'); +}, 'Test that subtracting CSSSimpleLengths with the same unit produces a new CSSSimpleLength with the correct value.'); + +test(function() { + var simpleLength1 = new CSSSimpleLength(5.1, 'px'); + var simpleLength2 = new CSSSimpleLength(10, 'percent'); + + var result = simpleLength1.subtract(simpleLength2); + + assert_true(result instanceof CalcLength); + assert_equals(result.px, 5.1); + assert_equals(result.percent, -10); +}, 'Test that subtracting CSSSimpleLengths with different units produces a calc length with the correct values.'); + +test(function() { + var simpleLength = new CSSSimpleLength(5.2, 'px'); + var result = simpleLength.multiply(4); + + assert_not_equals(simpleLength, result); + assert_true(result instanceof CSSSimpleLength); + assert_approx_equals(result.value, 20.8, 0.00000001); + assert_equals(result.type, 'px'); +}, 'Test that multiplying a CSSSimpleLength produces a new CSSSimpleLength with the correct value.'); + +test(function() { + var simpleLength = new CSSSimpleLength(25, 'px'); + var result = simpleLength.divide(2); + + assert_not_equals(simpleLength, result); + assert_true(result instanceof CSSSimpleLength); + assert_equals(result.value, 12.5); + assert_equals(result.type, 'px'); +}, 'Test that dividing a CSSSimpleLength produces a new CSSSimpleLength with the correct value.'); + +test(function() { + var values = [ + {input: new CSSSimpleLength(1, 'px'), cssString: '1px' }, + {input: new CSSSimpleLength(2, 'percent'), cssString: '2%' }, + {input: new CSSSimpleLength(3, '%'), cssString: '3%' }, + {input: new CSSSimpleLength(4, 'em'), cssString: '4em' }, + {input: new CSSSimpleLength(5, 'ex'), cssString: '5ex' }, + {input: new CSSSimpleLength(6, 'ch'), cssString: '6ch' }, + {input: new CSSSimpleLength(7, 'rem'), cssString: '7rem' }, + {input: new CSSSimpleLength(8, 'vw'), cssString: '8vw' }, + {input: new CSSSimpleLength(9, 'vh'), cssString: '9vh' }, + {input: new CSSSimpleLength(10, 'vmin'), cssString: '10vmin' }, + {input: new CSSSimpleLength(11, 'vmax'), cssString: '11vmax' }, + {input: new CSSSimpleLength(12, 'cm'), cssString: '12cm' }, + {input: new CSSSimpleLength(13, 'mm'), cssString: '13mm' }, + {input: new CSSSimpleLength(14, 'in'), cssString: '14in' }, + {input: new CSSSimpleLength(15, 'pc'), cssString: '15pc' }, + {input: new CSSSimpleLength(16, 'pt'), cssString: '16pt' }, + // Same again to double check that it's case insensitive. + {input: new CSSSimpleLength(1, 'PX'), cssString: '1px' }, + {input: new CSSSimpleLength(2, 'PERCENT'), cssString: '2%' }, + {input: new CSSSimpleLength(3, '%'), cssString: '3%' }, + {input: new CSSSimpleLength(4, 'EM'), cssString: '4em' }, + {input: new CSSSimpleLength(5, 'EX'), cssString: '5ex' }, + {input: new CSSSimpleLength(6, 'CH'), cssString: '6ch' }, + {input: new CSSSimpleLength(7, 'REM'), cssString: '7rem' }, + {input: new CSSSimpleLength(8, 'VW'), cssString: '8vw' }, + {input: new CSSSimpleLength(9, 'VH'), cssString: '9vh' }, + {input: new CSSSimpleLength(10, 'VMIN'), cssString: '10vmin' }, + {input: new CSSSimpleLength(11, 'VMAX'), cssString: '11vmax' }, + {input: new CSSSimpleLength(12, 'CM'), cssString: '12cm' }, + {input: new CSSSimpleLength(13, 'MM'), cssString: '13mm' }, + {input: new CSSSimpleLength(14, 'IN'), cssString: '14in' }, + {input: new CSSSimpleLength(15, 'PC'), cssString: '15pc' }, + {input: new CSSSimpleLength(16, 'PT'), cssString: '16pt' }, + ]; + + for (var i = 0; i < values.length; ++i) { + assert_equals(values[i].input.cssString, values[i].cssString); + } +}, 'Test that the CSSSimpleLength css string is generated correctly for each unit type.'); + +test(function() { + var values = [ + {value: NaN, unit: 'px'}, + {value: Infinity, unit: 'px'}, + {value: -Infinity, unit: 'px'}, + {value: 5, unit: 'puppies'} + ]; + + for (var i = 0; i < values.length; ++i) { + assert_throws(null, function() { new CSSSimpleLength(values[i].value, values[i].unit); }); + } +}, 'Test that invalid input throws an exception.'); + +</script> + +<body> +</body>
diff --git a/third_party/WebKit/LayoutTests/typedcssom/cssTranslation.html b/third_party/WebKit/LayoutTests/typedcssom/cssTranslation.html index 6362dc1..c62d2ff1 100644 --- a/third_party/WebKit/LayoutTests/typedcssom/cssTranslation.html +++ b/third_party/WebKit/LayoutTests/typedcssom/cssTranslation.html
@@ -4,13 +4,13 @@ <script> -var simpleLength = new SimpleLength(0, "px"); -var decimalLength = new SimpleLength(1.1, "px"); -var negativeLength = new SimpleLength(-2.2, "em"); +var simpleLength = new CSSSimpleLength(0, "px"); +var decimalLength = new CSSSimpleLength(1.1, "px"); +var negativeLength = new CSSSimpleLength(-2.2, "em"); var calcLengthPx = new CalcLength({px: 1}); var calcLength = new CalcLength({px: 1, em: -2.2}); -var simplePercent = new SimpleLength(10, "percent"); +var simplePercent = new CSSSimpleLength(10, "percent"); var calcPercent = new CalcLength({px: 1, percent: 2.2}); var values = [
diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_append.html b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_append.html index 2b91905..045c4f2 100644 --- a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_append.html +++ b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_append.html
@@ -9,7 +9,7 @@ // Append test(function() { assert_throws(new TypeError(), function() { - testElement.styleMap.append('width', new SimpleLength(60, 'px')); + testElement.styleMap.append('width', new CSSSimpleLength(60, 'px')); }); }, "Attempting to append to a property that doesn't support multiple values throws");
diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_delete.html b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_delete.html index 9c15a84..2ee5327 100644 --- a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_delete.html +++ b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_delete.html
@@ -17,7 +17,7 @@ }, "delete() removes the value from the property when set in element.style"); test(function() { - testElement.styleMap.set('width', new SimpleLength(100, 'px')); + testElement.styleMap.set('width', new CSSSimpleLength(100, 'px')); assert_equals(testElement.styleMap.get('width').cssString, '100px'); testElement.styleMap.delete('width');
diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_getAll.html b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_getAll.html index e1098ee..372cdde 100644 --- a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_getAll.html +++ b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_getAll.html
@@ -8,14 +8,14 @@ test(function() { // TODO(meade): Make this a test case for a property with multiple values when that is supported. - testElement.styleMap.set('width', new SimpleLength(90, 'px')); + testElement.styleMap.set('width', new CSSSimpleLength(90, 'px')); var result = testElement.styleMap.getAll('width'); assert_equals(result.length, 1); assert_equals(result[0].cssString, '90px'); }, "getAll() returns a list of values"); test(function() { - testElement.styleMap.set('width', new SimpleLength(100, 'px')); + testElement.styleMap.set('width', new CSSSimpleLength(100, 'px')); var lowerResult = testElement.styleMap.getAll('width'); var upperResult = testElement.styleMap.getAll('WIDTH'); var mixedResult = testElement.styleMap.getAll('wIdTh');
diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_getProperties.html b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_getProperties.html index 8b4d0e87..e8a834f89 100644 --- a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_getProperties.html +++ b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_getProperties.html
@@ -13,12 +13,12 @@ test(function() { testElement.style = ''; - testElement.styleMap.set('width', new SimpleLength(10, 'px')); + testElement.styleMap.set('width', new CSSSimpleLength(10, 'px')); assert_array_equals(testElement.styleMap.getProperties(), ['width']); }, "getProperties returns the name of a property if it is set"); test(function() { - testElement.styleMap.set('width', new SimpleLength(10, 'px')); + testElement.styleMap.set('width', new CSSSimpleLength(10, 'px')); assert_array_equals(testElement.styleMap.getProperties(), ['width']); testElement.styleMap.get('height'); @@ -26,7 +26,7 @@ }, "Accessing another property doesn't add a spurious result"); test(function() { - testElement.styleMap.set('width', new SimpleLength(10, 'px')); + testElement.styleMap.set('width', new CSSSimpleLength(10, 'px')); assert_array_equals(testElement.styleMap.getProperties(), ['width']); testElement.styleMap.delete('width'); @@ -34,10 +34,10 @@ }, "property name does not appear in result after deletion"); test(function() { - testElement.styleMap.set('width', new SimpleLength(10, 'px')); + testElement.styleMap.set('width', new CSSSimpleLength(10, 'px')); assert_array_equals(testElement.styleMap.getProperties(), ['width']); - testElement.styleMap.set('border-top-width', new SimpleLength(10, 'px')); + testElement.styleMap.set('border-top-width', new CSSSimpleLength(10, 'px')); var result = testElement.styleMap.getProperties(); // TODO(meade): The spec should describe an order for this. assert_equals(2, result.length, 2);
diff --git a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_setGet.html b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_setGet.html index 3ee25740..c882278 100644 --- a/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_setGet.html +++ b/third_party/WebKit/LayoutTests/typedcssom/inlinestyle/inlineStylePropertyMap_setGet.html
@@ -7,14 +7,14 @@ <script> test(function() { - testElement.styleMap.set('width', new SimpleLength(10, 'px')); + testElement.styleMap.set('width', new CSSSimpleLength(10, 'px')); assert_equals(testElement.styleMap.get('width').cssString, '10px'); }, "Setting and getting round trips"); test(function() { - testElement.styleMap.set('WIDTH', new SimpleLength(40, 'px')); + testElement.styleMap.set('WIDTH', new CSSSimpleLength(40, 'px')); assert_equals(testElement.styleMap.get('WiDtH').cssString, '40px'); - testElement.styleMap.set('wIdTh', new SimpleLength(50, 'px')); + testElement.styleMap.set('wIdTh', new CSSSimpleLength(50, 'px')); assert_equals(testElement.styleMap.get('width').cssString, '50px'); }, "Setting and getting is not case sensitive"); @@ -24,7 +24,7 @@ }, "Changes to element.style are reflected in the element.styleMap"); test(function() { - testElement.styleMap.set('width', new SimpleLength(30, 'px')); + testElement.styleMap.set('width', new CSSSimpleLength(30, 'px')); assert_equals(testElement.style.width, '30px'); }, "Changes to element.styleMap are reflected in element.style"); @@ -35,7 +35,7 @@ }, "Attempting to set an invalid type for a property throws"); test(function() { - testElement.styleMap.set('width', new SimpleLength(2, 'px')); + testElement.styleMap.set('width', new CSSSimpleLength(2, 'px')); assert_throws(new TypeError(), function() { testElement.styleMap.set('width', new CSSNumberValue(4)); });
diff --git a/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html b/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html index e6a4afa..e7260daf 100644 --- a/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html +++ b/third_party/WebKit/LayoutTests/typedcssom/perspectiveTransformComponent.html
@@ -10,12 +10,12 @@ }, "Constructor should throw an error for CalcLengths with a percentage type"); test(function() { - var simpleLength = new SimpleLength(10, 'percent'); + var simpleLength = new CSSSimpleLength(10, 'percent'); assert_throws(null, function() { new Perspective(simpleLength) }); -}, "Constructor should throw an error for SimpleLengths with a percentage type"); +}, "Constructor should throw an error for CSSSimpleLengths with a percentage type"); test(function() { - var simpleLength = new SimpleLength(10, 'px'); + var simpleLength = new CSSSimpleLength(10, 'px'); var calcLength = new CalcLength({px: 10, em: 3.2}); var perspectiveTransformSimple = new Perspective(simpleLength); var perspectiveTransformCalc = new Perspective(calcLength);
diff --git a/third_party/WebKit/LayoutTests/typedcssom/simpleLength.html b/third_party/WebKit/LayoutTests/typedcssom/simpleLength.html deleted file mode 100644 index 01bf523..0000000 --- a/third_party/WebKit/LayoutTests/typedcssom/simpleLength.html +++ /dev/null
@@ -1,136 +0,0 @@ -<!DOCTYPE html> -<script src='../resources/testharness.js'></script> -<script src='../resources/testharnessreport.js'></script> - -<script> - -test(function() { - var simpleLength1 = new SimpleLength(5.1, 'px'); - var simpleLength2 = new SimpleLength(10, 'px'); - - var result = simpleLength1.add(simpleLength2); - - assert_not_equals(simpleLength1, result); - assert_not_equals(simpleLength2, result); - assert_true(result instanceof SimpleLength); - assert_equals(result.value, 15.1); - assert_equals(result.type, 'px'); -}, 'Test that adding SimpleLengths with the same unit produces a new SimpleLength with the correct value.'); - -test(function() { - var simpleLength1 = new SimpleLength(5.1, 'px'); - var simpleLength2 = new SimpleLength(10, 'percent'); - - var result = simpleLength1.add(simpleLength2); - - assert_true(result instanceof CalcLength); - assert_equals(result.px, 5.1); - assert_equals(result.percent, 10); - -}, 'Test that adding SimpleLengths with different units produces a calc length with the correct values.'); - -test(function() { - var simpleLength1 = new SimpleLength(5.1, 'px'); - var simpleLength2 = new SimpleLength(10, 'px'); - - var result = simpleLength1.subtract(simpleLength2); - - assert_not_equals(simpleLength1, result); - assert_not_equals(simpleLength2, result); - assert_true(result instanceof SimpleLength); - assert_equals(result.value, -4.9); - assert_equals(result.type, 'px'); -}, 'Test that subtracting SimpleLengths with the same unit produces a new SimpleLength with the correct value.'); - -test(function() { - var simpleLength1 = new SimpleLength(5.1, 'px'); - var simpleLength2 = new SimpleLength(10, 'percent'); - - var result = simpleLength1.subtract(simpleLength2); - - assert_true(result instanceof CalcLength); - assert_equals(result.px, 5.1); - assert_equals(result.percent, -10); - -}, 'Test that subtracting SimpleLengths with different units produces a calc length with the correct values.'); - -test(function() { - var simpleLength = new SimpleLength(5.2, 'px'); - var result = simpleLength.multiply(4); - - assert_not_equals(simpleLength, result); - assert_true(result instanceof SimpleLength); - assert_approx_equals(result.value, 20.8, 0.00000001); - assert_equals(result.type, 'px'); -}, 'Test that multiplying a SimpleLength produces a new SimpleLength with the correct value.'); - -test(function() { - var simpleLength = new SimpleLength(25, 'px'); - var result = simpleLength.divide(2); - - assert_not_equals(simpleLength, result); - assert_true(result instanceof SimpleLength); - assert_equals(result.value, 12.5); - assert_equals(result.type, 'px'); -}, 'Test that dividing a SimpleLength produces a new SimpleLength with the correct value.'); - -test(function() { - var values = [ - {input: new SimpleLength(1, 'px'), cssString: '1px' }, - {input: new SimpleLength(2, 'percent'), cssString: '2%' }, - {input: new SimpleLength(3, '%'), cssString: '3%' }, - {input: new SimpleLength(4, 'em'), cssString: '4em' }, - {input: new SimpleLength(5, 'ex'), cssString: '5ex' }, - {input: new SimpleLength(6, 'ch'), cssString: '6ch' }, - {input: new SimpleLength(7, 'rem'), cssString: '7rem' }, - {input: new SimpleLength(8, 'vw'), cssString: '8vw' }, - {input: new SimpleLength(9, 'vh'), cssString: '9vh' }, - {input: new SimpleLength(10, 'vmin'), cssString: '10vmin' }, - {input: new SimpleLength(11, 'vmax'), cssString: '11vmax' }, - {input: new SimpleLength(12, 'cm'), cssString: '12cm' }, - {input: new SimpleLength(13, 'mm'), cssString: '13mm' }, - {input: new SimpleLength(14, 'in'), cssString: '14in' }, - {input: new SimpleLength(15, 'pc'), cssString: '15pc' }, - {input: new SimpleLength(16, 'pt'), cssString: '16pt' }, - // Same again to double check that it's case insensitive. - {input: new SimpleLength(1, 'PX'), cssString: '1px' }, - {input: new SimpleLength(2, 'PERCENT'), cssString: '2%' }, - {input: new SimpleLength(3, '%'), cssString: '3%' }, - {input: new SimpleLength(4, 'EM'), cssString: '4em' }, - {input: new SimpleLength(5, 'EX'), cssString: '5ex' }, - {input: new SimpleLength(6, 'CH'), cssString: '6ch' }, - {input: new SimpleLength(7, 'REM'), cssString: '7rem' }, - {input: new SimpleLength(8, 'VW'), cssString: '8vw' }, - {input: new SimpleLength(9, 'VH'), cssString: '9vh' }, - {input: new SimpleLength(10, 'VMIN'), cssString: '10vmin' }, - {input: new SimpleLength(11, 'VMAX'), cssString: '11vmax' }, - {input: new SimpleLength(12, 'CM'), cssString: '12cm' }, - {input: new SimpleLength(13, 'MM'), cssString: '13mm' }, - {input: new SimpleLength(14, 'IN'), cssString: '14in' }, - {input: new SimpleLength(15, 'PC'), cssString: '15pc' }, - {input: new SimpleLength(16, 'PT'), cssString: '16pt' }, - ]; - - for (var i = 0; i < values.length; ++i) { - assert_equals(values[i].input.cssString, values[i].cssString); - } -}, 'Test that the SimpleLength css string is generated correctly for each unit type.'); - -test(function() { - var values = [ - {value: NaN, unit: 'px'}, - {value: Infinity, unit: 'px'}, - {value: -Infinity, unit: 'px'}, - {value: 5, unit: 'puppies'} - ]; - - for (var i = 0; i < values.length; ++i) { - assert_throws(null, function() { new SimpleLength(values[i].value, values[i].unit); }); - } - -}, 'Test that invalid input throws an exception.'); - -</script> - -<body> -</body>
diff --git a/third_party/WebKit/LayoutTests/typedcssom/styleValue-parse-basic.html b/third_party/WebKit/LayoutTests/typedcssom/styleValue-parse-basic.html index 1b3754b..2c1b2e8 100644 --- a/third_party/WebKit/LayoutTests/typedcssom/styleValue-parse-basic.html +++ b/third_party/WebKit/LayoutTests/typedcssom/styleValue-parse-basic.html
@@ -7,10 +7,10 @@ var result = StyleValue.parse('width', '10px'); assert_not_equals(result, null); - assert_true(result instanceof SimpleLength); + assert_true(result instanceof CSSSimpleLength); assert_equals(result.value, 10); assert_equals(result.type, 'px'); -}, 'Parsing 10px results in a SimpleLength'); +}, 'Parsing 10px results in a CSSSimpleLength'); test(function() { assert_equals(StyleValue.parse('width', 'hello'), null);
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt index 029e76d69..757668d 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
@@ -504,6 +504,12 @@ method @@iterator method constructor method item +interface CSSSimpleLength : CSSLengthValue + attribute @@toStringTag + getter type + getter value + method constructor + setter value interface CSSStyleDeclaration attribute @@toStringTag getter cssFloat @@ -5793,12 +5799,6 @@ getter regionCode getter sortingCode method constructor -interface SimpleLength : CSSLengthValue - attribute @@toStringTag - getter type - getter value - method constructor - setter value interface SiteBoundCredential : Credential attribute @@toStringTag getter iconURL
diff --git a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp index 293a277..ee0a071 100644 --- a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.cpp
@@ -198,7 +198,7 @@ void DOMWrapperWorld::dispose() { m_domObjectHolders.clear(); - m_domDataStore.clear(); + m_domDataStore.reset(); } #if ENABLE(ASSERT)
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp index 8c89829..d318dd64 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp
@@ -288,6 +288,16 @@ windowProxy(DOMWrapperWorld::mainWorld())->updateDocument(); } +void ScriptController::namedItemAdded(HTMLDocument* doc, const AtomicString& name) +{ + windowProxy(DOMWrapperWorld::mainWorld())->namedItemAdded(doc, name); +} + +void ScriptController::namedItemRemoved(HTMLDocument* doc, const AtomicString& name) +{ + windowProxy(DOMWrapperWorld::mainWorld())->namedItemRemoved(doc, name); +} + static bool isInPrivateScriptIsolateWorld(v8::Isolate* isolate) { v8::Local<v8::Context> context = isolate->GetCurrentContext();
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptController.h b/third_party/WebKit/Source/bindings/core/v8/ScriptController.h index e3bda432..e5ae8c1 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptController.h +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptController.h
@@ -128,6 +128,9 @@ void clearWindowProxy(); void updateDocument(); + void namedItemAdded(HTMLDocument*, const AtomicString&); + void namedItemRemoved(HTMLDocument*, const AtomicString&); + void updateSecurityOrigin(SecurityOrigin*); void clearForClose();
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyTest.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyTest.cpp index 3ad60fb..b39a29e3 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyTest.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyTest.cpp
@@ -122,7 +122,7 @@ void destroyContext() { - m_page.clear(); + m_page.reset(); if (m_otherScriptState) { m_otherScriptState->disposePerContextData(); m_otherScriptState = nullptr;
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp index bc4fef05..642cb5c 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp
@@ -541,7 +541,7 @@ // V8 cannot stream the script. suppressStreaming(); m_stream = 0; - m_source.clear(); + m_source.reset(); recordNotStreamingReasonHistogram(m_scriptType, V8CannotStream); recordStartedStreamingHistogram(m_scriptType, 0); return;
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp index 77f7733..21f16e35 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp
@@ -555,34 +555,29 @@ ScriptValueSerializer::StateBase* ScriptValueSerializer::AbstractObjectState::serializeProperties(bool ignoreIndexed, ScriptValueSerializer& serializer) { while (m_index < m_propertyNames->Length()) { - if (!m_nameDone) { - v8::Local<v8::Value> propertyName; - if (!m_propertyNames->Get(serializer.context(), m_index).ToLocal(&propertyName)) - return serializer.handleError(JSException, "Failed to get a property while cloning an object.", this); - bool hasStringProperty = propertyName->IsString() && v8CallBoolean(composite()->HasRealNamedProperty(serializer.context(), propertyName.As<v8::String>())); - if (StateBase* newState = serializer.checkException(this)) - return newState; - bool hasIndexedProperty = !hasStringProperty && propertyName->IsUint32() && v8CallBoolean(composite()->HasRealIndexedProperty(serializer.context(), propertyName.As<v8::Uint32>()->Value())); - if (StateBase* newState = serializer.checkException(this)) - return newState; - if (hasStringProperty || (hasIndexedProperty && !ignoreIndexed)) { - m_propertyName = propertyName; - } else { - ++m_index; - continue; - } - } - ASSERT(!m_propertyName.IsEmpty()); - if (!m_nameDone) { - m_nameDone = true; - if (StateBase* newState = serializer.doSerialize(m_propertyName, this)) - return newState; - } - v8::Local<v8::Value> value; - if (!composite()->Get(serializer.context(), m_propertyName).ToLocal(&value)) + v8::Local<v8::Value> propertyName; + if (!m_propertyNames->Get(serializer.context(), m_index).ToLocal(&propertyName)) return serializer.handleError(JSException, "Failed to get a property while cloning an object.", this); - m_nameDone = false; - m_propertyName.Clear(); + + bool hasProperty = false; + if (propertyName->IsString()) { + hasProperty = v8CallBoolean(composite()->HasRealNamedProperty(serializer.context(), propertyName.As<v8::String>())); + } else if (propertyName->IsUint32()) { + hasProperty = v8CallBoolean(composite()->HasRealIndexedProperty(serializer.context(), propertyName.As<v8::Uint32>()->Value())) && !ignoreIndexed; + } + if (StateBase* newState = serializer.checkException(this)) + return newState; + if (!hasProperty) { + ++m_index; + continue; + } + + // |propertyName| is v8::String or v8::Uint32, so its serialization cannot be recursive. + serializer.doSerialize(propertyName, nullptr); + + v8::Local<v8::Value> value; + if (!composite()->Get(serializer.context(), propertyName).ToLocal(&value)) + return serializer.handleError(JSException, "Failed to get a property while cloning an object.", this); ++m_index; ++m_numSerializedProperties; // If we return early here, it's either because we have pushed a new state onto the
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.h b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.h index f53e1cb..3f436616 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.h +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.h
@@ -279,7 +279,6 @@ : State<v8::Object>(object, next) , m_index(0) , m_numSerializedProperties(0) - , m_nameDone(false) { } @@ -290,10 +289,8 @@ v8::Local<v8::Array> m_propertyNames; private: - v8::Local<v8::Value> m_propertyName; unsigned m_index; unsigned m_numSerializedProperties; - bool m_nameDone; }; class ObjectState final : public AbstractObjectState {
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8HiddenValue.h b/third_party/WebKit/Source/bindings/core/v8/V8HiddenValue.h index 6e1795e..a9876ad0 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8HiddenValue.h +++ b/third_party/WebKit/Source/bindings/core/v8/V8HiddenValue.h
@@ -56,6 +56,8 @@ V(webglCubeMapTextures) \ V(webglExtensions) \ V(webglMisc) \ + V(webglQueries) \ + V(webglSamplers) \ V(webglShaders) \ SCRIPT_PROMISE_PROPERTIES(V, Promise) \ SCRIPT_PROMISE_PROPERTIES(V, Resolver)
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp b/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp index d8b07299..1d9d8d4c 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.cpp
@@ -186,7 +186,7 @@ { V8PerIsolateData* data = from(isolate); - data->m_threadDebugger.clear(); + data->m_threadDebugger.reset(); // Clear any data that may have handles into the heap, // prior to calling ThreadState::detach(). data->clearEndOfScopeTasks(); @@ -206,9 +206,9 @@ if (data->m_scriptRegexpScriptState) data->m_scriptRegexpScriptState->disposePerContextData(); data->m_liveRoot.clear(); - data->m_hiddenValue.clear(); + data->m_hiddenValue.reset(); data->m_stringCache->dispose(); - data->m_stringCache.clear(); + data->m_stringCache.reset(); data->m_interfaceTemplateMapForNonMainWorld.clear(); data->m_interfaceTemplateMapForMainWorld.clear(); data->m_operationTemplateMapForNonMainWorld.clear();
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp index b74f0d9..bc0aa71 100644 --- a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp
@@ -225,6 +225,7 @@ { TRACE_EVENT0("v8", "WindowProxy::initialize"); TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "InitializeWindow"); + SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Binding.InitializeWindowProxy"); ScriptForbiddenScope::AllowUserAgentScript allowScript; @@ -478,6 +479,79 @@ updateSecurityOrigin(m_frame->securityContext()->getSecurityOrigin()); } +static v8::Local<v8::Value> getNamedProperty(HTMLDocument* htmlDocument, const AtomicString& key, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) +{ + if (!htmlDocument->hasNamedItem(key) && !htmlDocument->hasExtraNamedItem(key)) + return v8Undefined(); + + DocumentNameCollection* items = htmlDocument->documentNamedItems(key); + if (items->isEmpty()) + return v8Undefined(); + + if (items->hasExactlyOneItem()) { + HTMLElement* element = items->item(0); + ASSERT(element); + Frame* frame = isHTMLIFrameElement(*element) ? toHTMLIFrameElement(*element).contentFrame() : 0; + if (frame) + return toV8(frame->domWindow(), creationContext, isolate); + return toV8(element, creationContext, isolate); + } + return toV8(items, creationContext, isolate); +} + +static void getter(v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) +{ + if (!property->IsString()) + return; + // FIXME: Consider passing StringImpl directly. + AtomicString name = toCoreAtomicString(property.As<v8::String>()); + HTMLDocument* htmlDocument = V8HTMLDocument::toImpl(info.Holder()); + ASSERT(htmlDocument); + v8::Local<v8::Value> result = getNamedProperty(htmlDocument, name, info.Holder(), info.GetIsolate()); + if (!result.IsEmpty()) { + v8SetReturnValue(info, result); + return; + } + v8::Local<v8::Value> prototype = info.Holder()->GetPrototype(); + if (prototype->IsObject()) { + v8::Local<v8::Value> value; + if (prototype.As<v8::Object>()->Get(info.GetIsolate()->GetCurrentContext(), property).ToLocal(&value)) + v8SetReturnValue(info, value); + } +} + +void WindowProxy::namedItemAdded(HTMLDocument* document, const AtomicString& name) +{ + ASSERT(m_world->isMainWorld()); + + if (!isContextInitialized() || !m_scriptState->contextIsValid()) + return; + + ScriptState::Scope scope(m_scriptState.get()); + ASSERT(!m_document.isEmpty()); + v8::Local<v8::Context> context = m_scriptState->context(); + v8::Local<v8::Object> documentHandle = m_document.newLocal(m_isolate); + checkDocumentWrapper(documentHandle, document); + documentHandle->SetAccessor(context, v8String(m_isolate, name), getter); +} + +void WindowProxy::namedItemRemoved(HTMLDocument* document, const AtomicString& name) +{ + ASSERT(m_world->isMainWorld()); + + if (!isContextInitialized()) + return; + + if (document->hasNamedItem(name) || document->hasExtraNamedItem(name)) + return; + + ScriptState::Scope scope(m_scriptState.get()); + ASSERT(!m_document.isEmpty()); + v8::Local<v8::Object> documentHandle = m_document.newLocal(m_isolate); + checkDocumentWrapper(documentHandle, document); + documentHandle->Delete(m_isolate->GetCurrentContext(), v8String(m_isolate, name)); +} + void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) { if (!isContextInitialized())
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.h b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.h index 388e166c..0765d02 100644 --- a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.h +++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.h
@@ -63,6 +63,9 @@ // Update document object of the frame. void updateDocument(); + void namedItemAdded(HTMLDocument*, const AtomicString&); + void namedItemRemoved(HTMLDocument*, const AtomicString&); + // Update the security origin of a document // (e.g., after setting docoument.domain). void updateSecurityOrigin(SecurityOrigin*);
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLDocumentCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLDocumentCustom.cpp deleted file mode 100644 index bc3f2d3..0000000 --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLDocumentCustom.cpp +++ /dev/null
@@ -1,76 +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. - -#include "bindings/core/v8/V8HTMLDocument.h" - -#include "bindings/core/v8/ToV8.h" -#include "bindings/core/v8/V8Binding.h" -#include "bindings/core/v8/V8StringResource.h" -#include "core/html/DocumentNameCollection.h" -#include "core/html/HTMLDocument.h" -#include "core/html/HTMLIFrameElement.h" - -#include <cstring> - -namespace blink { - -namespace { - -v8::Local<v8::Value> getNamedProperty(v8::Isolate* isolate, HTMLDocument* htmlDocument, const AtomicString& key, v8::Local<v8::Object> creationContext) -{ - if (!htmlDocument->hasNamedItem(key) && !htmlDocument->hasExtraNamedItem(key)) - return v8Undefined(); - DocumentNameCollection* items = htmlDocument->documentNamedItems(key); - if (items->isEmpty()) - return v8Undefined(); - - // https://html.spec.whatwg.org/multipage/dom.html#dom-document-namedItem-which - if (items->hasExactlyOneItem()) { - HTMLElement* element = items->item(0); - DCHECK(element); - if (isHTMLIFrameElement(*element)) { - Frame* frame = toHTMLIFrameElement(*element).contentFrame(); - if (frame) - return toV8(frame->domWindow(), creationContext, isolate); - } - return toV8(element, creationContext, isolate); - } - return toV8(items, creationContext, isolate); -} - -void propertyGetterCustom(const AtomicString& name, v8::PropertyCallbackInfo<v8::Value> const& info) -{ - HTMLDocument* htmlDocument = V8HTMLDocument::toImpl(info.Holder()); - DCHECK(htmlDocument); - - v8::Local<v8::Value> result = getNamedProperty(info.GetIsolate(), htmlDocument, name, info.Holder()); - if (result.IsEmpty()) - return; - - v8SetReturnValue(info, result); -} - -} // namespace - -void V8HTMLDocument::indexedPropertyGetterCustom(unsigned index, v8::PropertyCallbackInfo<v8::Value> const& info) -{ - propertyGetterCustom(AtomicString::number(index), info); -} - -void V8HTMLDocument::namedPropertyGetterCustom(v8::Local<v8::Name> name, v8::PropertyCallbackInfo<v8::Value> const& info) -{ - v8::String::Utf8Value nameStr(name); - - // [Unforgeable] attributes in an [OverrideBuiltin] interface must be looked - // up before any named properties - // (http://heycam.github.io/webidl/#dfn-named-property-visibility). - // So we return immediately before looking up named propertiees. - // TODO(peria): Support the behavior correctly. - if (std::strcmp(*nameStr, "location") == 0) - return; - - propertyGetterCustom(AtomicString(*nameStr), info); -} - -} // namespace blink
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/custom.gypi b/third_party/WebKit/Source/bindings/core/v8/custom/custom.gypi index 5cfbc7e..3f2037b 100644 --- a/third_party/WebKit/Source/bindings/core/v8/custom/custom.gypi +++ b/third_party/WebKit/Source/bindings/core/v8/custom/custom.gypi
@@ -15,7 +15,6 @@ 'V8ErrorEventCustom.cpp', 'V8EventTargetCustom.cpp', 'V8HTMLAllCollectionCustom.cpp', - 'V8HTMLDocumentCustom.cpp', 'V8HTMLElementCustom.cpp', 'V8HTMLPlugInElementCustom.cpp', 'V8IntersectionObserverCustom.cpp',
diff --git a/third_party/WebKit/Source/core/animation/Animation.cpp b/third_party/WebKit/Source/core/animation/Animation.cpp index cb61588..4769897 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.clear(); + m_compositorState.reset(); } if (effectChanged && m_compositorState) { m_compositorState->effectChanged = true; @@ -919,7 +919,7 @@ if (m_compositorPlayer) { detachCompositorTimeline(); m_compositorPlayer->setAnimationDelegate(nullptr); - m_compositorPlayer.clear(); + m_compositorPlayer.reset(); } }
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp b/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp index ce8ff42d..3a897e0 100644 --- a/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp +++ b/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp
@@ -492,7 +492,7 @@ } template<typename PlatformAnimationCurveType, typename PlatformAnimationKeyframeType> -void addKeyframeWithTimingFunction(PlatformAnimationCurveType& curve, const PlatformAnimationKeyframeType& keyframe, const TimingFunction* timingFunction) +void addCompositorKeyframeWithTimingFunction(PlatformAnimationCurveType& curve, const PlatformAnimationKeyframeType& keyframe, const TimingFunction* timingFunction) { if (!timingFunction) { curve.add(keyframe); @@ -567,9 +567,35 @@ } } -} // namespace +void addKeyframeToCurve(CompositorFilterAnimationCurve& curve, Keyframe::PropertySpecificKeyframe* keyframe, + const AnimatableValue* value, const TimingFunction* keyframeTimingFunction) +{ + OwnPtr<CompositorFilterOperations> ops = adoptPtr(CompositorFactory::current().createFilterOperations()); + toCompositorFilterOperations(toAnimatableFilterOperations(value)->operations(), ops.get()); -void CompositorAnimationsImpl::addKeyframesToCurve(CompositorAnimationCurve& curve, const PropertySpecificKeyframeVector& keyframes, const Timing& timing) + CompositorFilterKeyframe filterKeyframe(keyframe->offset(), std::move(ops)); + addCompositorKeyframeWithTimingFunction(curve, filterKeyframe, keyframeTimingFunction); +} + +void addKeyframeToCurve(CompositorFloatAnimationCurve& curve, Keyframe::PropertySpecificKeyframe* keyframe, + const AnimatableValue* value, const TimingFunction* keyframeTimingFunction) +{ + CompositorFloatKeyframe floatKeyframe(keyframe->offset(), toAnimatableDouble(value)->toDouble()); + addCompositorKeyframeWithTimingFunction(curve, floatKeyframe, keyframeTimingFunction); +} + +void addKeyframeToCurve(CompositorTransformAnimationCurve& curve, Keyframe::PropertySpecificKeyframe* keyframe, + const AnimatableValue* value, const TimingFunction* keyframeTimingFunction) +{ + OwnPtr<CompositorTransformOperations> ops = adoptPtr(CompositorFactory::current().createTransformOperations()); + toCompositorTransformOperations(toAnimatableTransform(value)->transformOperations(), ops.get()); + + CompositorTransformKeyframe transformKeyframe(keyframe->offset(), std::move(ops)); + addCompositorKeyframeWithTimingFunction(curve, transformKeyframe, keyframeTimingFunction); +} + +template <typename PlatformAnimationCurveType> +void addKeyframesToCurve(PlatformAnimationCurveType& curve, const AnimatableValuePropertySpecificKeyframeVector& keyframes) { auto* lastKeyframe = keyframes.last().get(); for (const auto& keyframe : keyframes) { @@ -583,37 +609,12 @@ // and convert using another set of toAnimatableXXXOperations functions. const AnimatableValue* value = keyframe->getAnimatableValue().get(); - switch (curve.type()) { - case CompositorAnimationCurve::AnimationCurveTypeFilter: { - OwnPtr<CompositorFilterOperations> ops = adoptPtr(CompositorFactory::current().createFilterOperations()); - toCompositorFilterOperations(toAnimatableFilterOperations(value)->operations(), ops.get()); - - CompositorFilterKeyframe filterKeyframe(keyframe->offset(), std::move(ops)); - CompositorFilterAnimationCurve* filterCurve = static_cast<CompositorFilterAnimationCurve*>(&curve); - addKeyframeWithTimingFunction(*filterCurve, filterKeyframe, keyframeTimingFunction); - break; - } - case CompositorAnimationCurve::AnimationCurveTypeFloat: { - CompositorFloatKeyframe floatKeyframe(keyframe->offset(), toAnimatableDouble(value)->toDouble()); - CompositorFloatAnimationCurve* floatCurve = static_cast<CompositorFloatAnimationCurve*>(&curve); - addKeyframeWithTimingFunction(*floatCurve, floatKeyframe, keyframeTimingFunction); - break; - } - case CompositorAnimationCurve::AnimationCurveTypeTransform: { - OwnPtr<CompositorTransformOperations> ops = adoptPtr(CompositorFactory::current().createTransformOperations()); - toCompositorTransformOperations(toAnimatableTransform(value)->transformOperations(), ops.get()); - - CompositorTransformKeyframe transformKeyframe(keyframe->offset(), std::move(ops)); - CompositorTransformAnimationCurve* transformCurve = static_cast<CompositorTransformAnimationCurve*>(&curve); - addKeyframeWithTimingFunction(*transformCurve, transformKeyframe, keyframeTimingFunction); - break; - } - default: - ASSERT_NOT_REACHED(); - } + addKeyframeToCurve(curve, keyframe.get(), value, keyframeTimingFunction); } } +} // namespace + void CompositorAnimationsImpl::getAnimationOnCompositor(const Timing& timing, int group, double startTime, double timeOffset, const KeyframeEffectModelBase& effect, Vector<OwnPtr<CompositorAnimation>>& animations, double animationPlaybackRate) { ASSERT(animations.isEmpty()); @@ -641,7 +642,7 @@ targetProperty = CompositorTargetProperty::OPACITY; CompositorFloatAnimationCurve* floatCurve = CompositorFactory::current().createFloatAnimationCurve(); - addKeyframesToCurve(*floatCurve, values, timing); + addKeyframesToCurve(*floatCurve, values); setTimingFunctionOnCurve(*floatCurve, timing.timingFunction.get()); curve = adoptPtr(floatCurve); break; @@ -650,7 +651,7 @@ case CSSPropertyBackdropFilter: { targetProperty = CompositorTargetProperty::FILTER; CompositorFilterAnimationCurve* filterCurve = CompositorFactory::current().createFilterAnimationCurve(); - addKeyframesToCurve(*filterCurve, values, timing); + addKeyframesToCurve(*filterCurve, values); setTimingFunctionOnCurve(*filterCurve, timing.timingFunction.get()); curve = adoptPtr(filterCurve); break; @@ -661,7 +662,7 @@ case CSSPropertyTransform: { targetProperty = CompositorTargetProperty::TRANSFORM; CompositorTransformAnimationCurve* transformCurve = CompositorFactory::current().createTransformAnimationCurve(); - addKeyframesToCurve(*transformCurve, values, timing); + addKeyframesToCurve(*transformCurve, values); setTimingFunctionOnCurve(*transformCurve, timing.timingFunction.get()); curve = adoptPtr(transformCurve); break;
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimationsImpl.h b/third_party/WebKit/Source/core/animation/CompositorAnimationsImpl.h index fb751bb..324b967 100644 --- a/third_party/WebKit/Source/core/animation/CompositorAnimationsImpl.h +++ b/third_party/WebKit/Source/core/animation/CompositorAnimationsImpl.h
@@ -41,8 +41,6 @@ namespace blink { -class CompositorAnimationCurve; - class CORE_EXPORT CompositorAnimationsImpl { STATIC_ONLY(CompositorAnimationsImpl); private: @@ -70,8 +68,6 @@ static void getAnimationOnCompositor(const Timing&, int group, double startTime, double timeOffset, const KeyframeEffectModelBase&, Vector<OwnPtr<CompositorAnimation>>& animations, double animationPlaybackRate); - static void addKeyframesToCurve(CompositorAnimationCurve&, const AnimatableValuePropertySpecificKeyframeVector&, const Timing&); - friend class CompositorAnimations; friend class AnimationCompositorAnimationsTest; };
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp index 2cc8b87..4610e8a 100644 --- a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp +++ b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp
@@ -690,7 +690,7 @@ Vector<OwnPtr<CompositorAnimation>> result; getAnimationOnCompositor(m_timing, *effect, result); EXPECT_EQ(1U, result.size()); - result[0].clear(); + result[0].reset(); } TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) @@ -735,7 +735,7 @@ Vector<OwnPtr<CompositorAnimation>> result; getAnimationOnCompositor(m_timing, *effect, result); EXPECT_EQ(1U, result.size()); - result[0].clear(); + result[0].reset(); } TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimationLinear) @@ -787,7 +787,7 @@ Vector<OwnPtr<CompositorAnimation>> result; getAnimationOnCompositor(m_timing, *effect, result); EXPECT_EQ(1U, result.size()); - result[0].clear(); + result[0].reset(); } TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay) @@ -834,7 +834,7 @@ Vector<OwnPtr<CompositorAnimation>> result; getAnimationOnCompositor(m_timing, *effect, result); EXPECT_EQ(1U, result.size()); - result[0].clear(); + result[0].reset(); } TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimationChained) @@ -891,7 +891,7 @@ Vector<OwnPtr<CompositorAnimation>> result; getAnimationOnCompositor(m_timing, *effect, result); EXPECT_EQ(1U, result.size()); - result[0].clear(); + result[0].reset(); } TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) @@ -949,7 +949,7 @@ Vector<OwnPtr<CompositorAnimation>> result; getAnimationOnCompositor(m_timing, *effect, result); EXPECT_EQ(1U, result.size()); - result[0].clear(); + result[0].reset(); } TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegativeStartDelay) @@ -997,7 +997,7 @@ Vector<OwnPtr<CompositorAnimation>> result; getAnimationOnCompositor(m_timing, *effect, result); EXPECT_EQ(1U, result.size()); - result[0].clear(); + result[0].reset(); } TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRates) @@ -1043,7 +1043,7 @@ // Set player plaback rate also getAnimationOnCompositor(m_timing, *effect, result, -1.5); EXPECT_EQ(1U, result.size()); - result[0].clear(); + result[0].reset(); } TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNone) @@ -1088,7 +1088,7 @@ Vector<OwnPtr<CompositorAnimation>> result; getAnimationOnCompositor(m_timing, *effect, result); EXPECT_EQ(1U, result.size()); - result[0].clear(); + result[0].reset(); } TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAuto) @@ -1133,7 +1133,7 @@ Vector<OwnPtr<CompositorAnimation>> result; getAnimationOnCompositor(m_timing, *effect, result); EXPECT_EQ(1U, result.size()); - result[0].clear(); + result[0].reset(); } TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTimingFunction) @@ -1178,7 +1178,7 @@ Vector<OwnPtr<CompositorAnimation>> result; getAnimationOnCompositor(m_timing, *effect, result); EXPECT_EQ(1U, result.size()); - result[0].clear(); + result[0].reset(); } TEST_F(AnimationCompositorAnimationsTest, CancelIncompatibleCompositorAnimations)
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimationsTestHelper.h b/third_party/WebKit/Source/core/animation/CompositorAnimationsTestHelper.h index 580c937..9f393a6 100644 --- a/third_party/WebKit/Source/core/animation/CompositorAnimationsTestHelper.h +++ b/third_party/WebKit/Source/core/animation/CompositorAnimationsTestHelper.h
@@ -93,7 +93,7 @@ ~WebCompositorAnimationMock() { delete_(); } }; -template<typename CurveType, CompositorAnimationCurve::AnimationCurveType CurveId, typename KeyframeType> +template<typename CurveType, typename KeyframeType> class WebCompositorAnimationCurveMock : public CurveType { public: MOCK_METHOD1_T(add, void(const KeyframeType&)); @@ -108,13 +108,11 @@ MOCK_CONST_METHOD1_T(getValue, float(double)); // Only on CompositorFloatAnimationCurve, but can't hurt to have here. - virtual CompositorAnimationCurve::AnimationCurveType type() const { return CurveId; } - MOCK_METHOD0(delete_, void()); ~WebCompositorAnimationCurveMock() override { delete_(); } }; -using WebFloatAnimationCurveMock = WebCompositorAnimationCurveMock<CompositorFloatAnimationCurve, CompositorAnimationCurve::AnimationCurveTypeFloat, CompositorFloatKeyframe>; +using WebFloatAnimationCurveMock = WebCompositorAnimationCurveMock<CompositorFloatAnimationCurve, CompositorFloatKeyframe>; class WebCompositorAnimationTimelineMock : public CompositorAnimationTimeline { public:
diff --git a/third_party/WebKit/Source/core/animation/ElementAnimations.cpp b/third_party/WebKit/Source/core/animation/ElementAnimations.cpp index 1b136502..5726411f 100644 --- a/third_party/WebKit/Source/core/animation/ElementAnimations.cpp +++ b/third_party/WebKit/Source/core/animation/ElementAnimations.cpp
@@ -30,8 +30,6 @@ #include "core/animation/ElementAnimations.h" -#include "core/layout/LayoutObject.h" - namespace blink { ElementAnimations::ElementAnimations()
diff --git a/third_party/WebKit/Source/core/animation/InterpolationValue.h b/third_party/WebKit/Source/core/animation/InterpolationValue.h index 42b2b39..f3d2d84 100644 --- a/third_party/WebKit/Source/core/animation/InterpolationValue.h +++ b/third_party/WebKit/Source/core/animation/InterpolationValue.h
@@ -43,7 +43,7 @@ void clear() { - interpolableValue.clear(); + interpolableValue.reset(); nonInterpolableValue.clear(); }
diff --git a/third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp b/third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp index cc2efeb..816d580 100644 --- a/third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp +++ b/third_party/WebKit/Source/core/animation/InvalidatableInterpolation.cpp
@@ -91,9 +91,9 @@ void InvalidatableInterpolation::clearCache() const { m_isCached = false; - m_cachedPairConversion.clear(); + m_cachedPairConversion.reset(); m_conversionCheckers.clear(); - m_cachedValue.clear(); + m_cachedValue.reset(); } bool InvalidatableInterpolation::isCacheValid(const InterpolationEnvironment& environment, const UnderlyingValueOwner& underlyingValueOwner) const
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp b/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp index d83c4f8..1545e0f 100644 --- a/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp +++ b/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp
@@ -368,7 +368,7 @@ KeyframeEffect* animation = KeyframeEffect::create(element.get(), nullptr, timing); EXPECT_EQ(element.get(), animation->target()); document().timeline().play(animation); - pageHolder.clear(); + pageHolder.reset(); element.clear(); }
diff --git a/third_party/WebKit/Source/core/animation/css/CSSAnimationUpdate.h b/third_party/WebKit/Source/core/animation/css/CSSAnimationUpdate.h index ee5053f..c1920e48 100644 --- a/third_party/WebKit/Source/core/animation/css/CSSAnimationUpdate.h +++ b/third_party/WebKit/Source/core/animation/css/CSSAnimationUpdate.h
@@ -12,7 +12,6 @@ #include "core/animation/css/CSSAnimatableValueFactory.h" #include "core/css/CSSKeyframesRule.h" #include "core/css/CSSPropertyEquality.h" -#include "core/layout/LayoutObject.h" #include "wtf/Allocator.h" #include "wtf/HashMap.h" #include "wtf/Vector.h"
diff --git a/third_party/WebKit/Source/core/core.gypi b/third_party/WebKit/Source/core/core.gypi index 533c67c..b0a92e2 100644 --- a/third_party/WebKit/Source/core/core.gypi +++ b/third_party/WebKit/Source/core/core.gypi
@@ -45,12 +45,12 @@ 'css/cssom/CSSNumberValue.idl', 'css/cssom/CSSPositionValue.idl', 'css/cssom/CSSRotation.idl', + 'css/cssom/CSSSimpleLength.idl', 'css/cssom/CSSTranslation.idl', 'css/cssom/CalcLength.idl', 'css/cssom/Matrix.idl', 'css/cssom/Perspective.idl', 'css/cssom/Scale.idl', - 'css/cssom/SimpleLength.idl', 'css/cssom/Skew.idl', 'css/cssom/StylePropertyMap.idl', 'css/cssom/StyleValue.idl', @@ -1339,6 +1339,8 @@ 'css/cssom/CSSPositionValue.h', 'css/cssom/CSSRotation.cpp', 'css/cssom/CSSRotation.h', + 'css/cssom/CSSSimpleLength.cpp', + 'css/cssom/CSSSimpleLength.h', 'css/cssom/CSSTranslation.cpp', 'css/cssom/CSSTranslation.h', 'css/cssom/ImmutableStylePropertyMap.h', @@ -1351,8 +1353,6 @@ 'css/cssom/PerspectiveTransformComponent.h', 'css/cssom/ScaleTransformComponent.cpp', 'css/cssom/ScaleTransformComponent.h', - 'css/cssom/SimpleLength.cpp', - 'css/cssom/SimpleLength.h', 'css/cssom/SkewTransformComponent.cpp', 'css/cssom/SkewTransformComponent.h', 'css/cssom/StyleCalcLength.cpp',
diff --git a/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp b/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp index 3f4fdab..2c8b1b2 100644 --- a/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp +++ b/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp
@@ -187,7 +187,7 @@ { OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(500, 500)); LocalFrame* frame = &pageHolder->frame(); - pageHolder.clear(); + pageHolder.reset(); ASSERT_EQ(nullptr, frame->view()); MediaQueryEvaluator mediaQueryEvaluator(frame); MediaQuerySet* querySet = MediaQuerySet::create("foobar");
diff --git a/third_party/WebKit/Source/core/css/SelectorChecker.cpp b/third_party/WebKit/Source/core/css/SelectorChecker.cpp index 4a45c2d..c9c325e 100644 --- a/third_party/WebKit/Source/core/css/SelectorChecker.cpp +++ b/third_party/WebKit/Source/core/css/SelectorChecker.cpp
@@ -929,7 +929,7 @@ if (ShadowRoot* root = element.containingShadowRoot()) { if (root->type() != ShadowRootType::UserAgent) return false; - const ComputedStyle* style = root->host()->computedStyle(); + const ComputedStyle* style = root->host().computedStyle(); return style && style->hasAppearance(); } return false;
diff --git a/third_party/WebKit/Source/core/css/SelectorFilter.cpp b/third_party/WebKit/Source/core/css/SelectorFilter.cpp index b1ea350..73107df 100644 --- a/third_party/WebKit/Source/core/css/SelectorFilter.cpp +++ b/third_party/WebKit/Source/core/css/SelectorFilter.cpp
@@ -75,7 +75,7 @@ m_parentStack.removeLast(); if (m_parentStack.isEmpty()) { ASSERT(m_ancestorIdentifierFilter->likelyEmpty()); - m_ancestorIdentifierFilter.clear(); + m_ancestorIdentifierFilter.reset(); } }
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp b/third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp index fead7ea..8db5b55 100644 --- a/third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp +++ b/third_party/WebKit/Source/core/css/cssom/CSSLengthValue.cpp
@@ -5,8 +5,8 @@ #include "core/css/cssom/CSSLengthValue.h" #include "bindings/core/v8/ExceptionState.h" +#include "core/css/cssom/CSSSimpleLength.h" #include "core/css/cssom/CalcDictionary.h" -#include "core/css/cssom/SimpleLength.h" #include "core/css/cssom/StyleCalcLength.h" #include "wtf/HashMap.h" @@ -28,7 +28,7 @@ CSSLengthValue* CSSLengthValue::from(double value, const String& type, ExceptionState&) { - return SimpleLength::create(value, unitFromName(type)); + return CSSSimpleLength::create(value, unitFromName(type)); } CSSLengthValue* CSSLengthValue::from(const CalcDictionary& dictionary, ExceptionState& exceptionState)
diff --git a/third_party/WebKit/Source/core/css/cssom/SimpleLength.cpp b/third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.cpp similarity index 62% rename from third_party/WebKit/Source/core/css/cssom/SimpleLength.cpp rename to third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.cpp index cd51b91..20e9b0fb 100644 --- a/third_party/WebKit/Source/core/css/cssom/SimpleLength.cpp +++ b/third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.cpp
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "core/css/cssom/SimpleLength.h" +#include "core/css/cssom/CSSSimpleLength.h" #include "core/css/CSSPrimitiveValue.h" #include "core/css/cssom/StyleCalcLength.h" @@ -10,19 +10,19 @@ namespace blink { -CSSValue* SimpleLength::toCSSValue() const +CSSValue* CSSSimpleLength::toCSSValue() const { return cssValuePool().createValue(m_value, m_unit); } -bool SimpleLength::containsPercent() const +bool CSSSimpleLength::containsPercent() const { return lengthUnit() == CSSPrimitiveValue::UnitType::Percentage; } -CSSLengthValue* SimpleLength::addInternal(const CSSLengthValue* other, ExceptionState& exceptionState) +CSSLengthValue* CSSSimpleLength::addInternal(const CSSLengthValue* other, ExceptionState& exceptionState) { - const SimpleLength* o = toSimpleLength(other); + const CSSSimpleLength* o = toCSSSimpleLength(other); if (m_unit == o->m_unit) return create(m_value + o->value(), m_unit); @@ -31,9 +31,9 @@ return result->add(other, exceptionState); } -CSSLengthValue* SimpleLength::subtractInternal(const CSSLengthValue* other, ExceptionState& exceptionState) +CSSLengthValue* CSSSimpleLength::subtractInternal(const CSSLengthValue* other, ExceptionState& exceptionState) { - const SimpleLength* o = toSimpleLength(other); + const CSSSimpleLength* o = toCSSSimpleLength(other); if (m_unit == o->m_unit) return create(m_value - o->value(), m_unit); @@ -42,12 +42,12 @@ return result->subtract(other, exceptionState); } -CSSLengthValue* SimpleLength::multiplyInternal(double x, ExceptionState& exceptionState) +CSSLengthValue* CSSSimpleLength::multiplyInternal(double x, ExceptionState& exceptionState) { return create(m_value * x, m_unit); } -CSSLengthValue* SimpleLength::divideInternal(double x, ExceptionState& exceptionState) +CSSLengthValue* CSSSimpleLength::divideInternal(double x, ExceptionState& exceptionState) { return create(m_value / x, m_unit); }
diff --git a/third_party/WebKit/Source/core/css/cssom/SimpleLength.h b/third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.h similarity index 70% rename from third_party/WebKit/Source/core/css/cssom/SimpleLength.h rename to third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.h index 645822c..7a3a153 100644 --- a/third_party/WebKit/Source/core/css/cssom/SimpleLength.h +++ b/third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SimpleLength_h -#define SimpleLength_h +#ifndef CSSSimpleLength_h +#define CSSSimpleLength_h #include "bindings/core/v8/ExceptionState.h" #include "core/css/cssom/CSSLengthValue.h" @@ -12,23 +12,23 @@ class CSSPrimitiveValue; -class CORE_EXPORT SimpleLength final : public CSSLengthValue { - WTF_MAKE_NONCOPYABLE(SimpleLength); +class CORE_EXPORT CSSSimpleLength final : public CSSLengthValue { + WTF_MAKE_NONCOPYABLE(CSSSimpleLength); DEFINE_WRAPPERTYPEINFO(); public: - static SimpleLength* create(double value, const String& type, ExceptionState& exceptionState) + static CSSSimpleLength* create(double value, const String& type, ExceptionState& exceptionState) { CSSPrimitiveValue::UnitType unit = unitFromName(type); if (!isSupportedLengthUnit(unit)) { - exceptionState.throwTypeError("Invalid unit for SimpleLength: " + type); + exceptionState.throwTypeError("Invalid unit for CSSSimpleLength: " + type); return nullptr; } - return new SimpleLength(value, unit); + return new CSSSimpleLength(value, unit); } - static SimpleLength* create(double value, CSSPrimitiveValue::UnitType type) + static CSSSimpleLength* create(double value, CSSPrimitiveValue::UnitType type) { - return new SimpleLength(value, type); + return new CSSSimpleLength(value, type); } bool containsPercent() const override; @@ -50,14 +50,14 @@ virtual CSSLengthValue* divideInternal(double, ExceptionState&); private: - SimpleLength(double value, CSSPrimitiveValue::UnitType unit) : CSSLengthValue(), m_unit(unit), m_value(value) {} + CSSSimpleLength(double value, CSSPrimitiveValue::UnitType unit) : CSSLengthValue(), m_unit(unit), m_value(value) {} CSSPrimitiveValue::UnitType m_unit; double m_value; }; #define DEFINE_SIMPLE_LENGTH_TYPE_CASTS(argumentType) \ - DEFINE_TYPE_CASTS(SimpleLength, argumentType, value, \ + DEFINE_TYPE_CASTS(CSSSimpleLength, argumentType, value, \ value->type() == CSSLengthValue::StyleValueType::SimpleLengthType, \ value.type() == CSSLengthValue::StyleValueType::SimpleLengthType)
diff --git a/third_party/WebKit/Source/core/css/cssom/SimpleLength.idl b/third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.idl similarity index 89% rename from third_party/WebKit/Source/core/css/cssom/SimpleLength.idl rename to third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.idl index dd6af73..a9f8b31 100644 --- a/third_party/WebKit/Source/core/css/cssom/SimpleLength.idl +++ b/third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.idl
@@ -6,7 +6,7 @@ Constructor(double value, DOMString type), RaisesException=Constructor, RuntimeEnabled=CSSTypedOM -] interface SimpleLength : CSSLengthValue { +] interface CSSSimpleLength : CSSLengthValue { [EnforceRange] attribute double value; [ImplementedAs=unit] readonly attribute LengthType type; };
diff --git a/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp b/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp index 7615a2d..6e54251 100644 --- a/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp +++ b/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp
@@ -10,7 +10,7 @@ #include "core/css/CSSValueList.h" #include "core/css/StylePropertySet.h" #include "core/css/cssom/CSSOMTypes.h" -#include "core/css/cssom/SimpleLength.h" +#include "core/css/cssom/CSSSimpleLength.h" namespace blink {
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.cpp b/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.cpp index adc3f562..5fb5dde 100644 --- a/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.cpp +++ b/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.cpp
@@ -6,8 +6,8 @@ #include "core/css/CSSCalculationValue.h" #include "core/css/CSSPrimitiveValue.h" +#include "core/css/cssom/CSSSimpleLength.h" #include "core/css/cssom/CalcDictionary.h" -#include "core/css/cssom/SimpleLength.h" #include "wtf/Vector.h" namespace blink { @@ -19,7 +19,7 @@ m_hasValues(other.m_hasValues) {} -StyleCalcLength::StyleCalcLength(const SimpleLength& other) : +StyleCalcLength::StyleCalcLength(const CSSSimpleLength& other) : m_values(CSSLengthValue::kNumSupportedUnits), m_hasValues(CSSLengthValue::kNumSupportedUnits) { set(other.value(), other.lengthUnit()); @@ -28,7 +28,7 @@ StyleCalcLength* StyleCalcLength::create(const CSSLengthValue* length) { if (length->type() == SimpleLengthType) { - const SimpleLength* simpleLength = toSimpleLength(length); + const CSSSimpleLength* simpleLength = toCSSSimpleLength(length); return new StyleCalcLength(*simpleLength); } @@ -95,7 +95,7 @@ } } } else { - const SimpleLength* o = toSimpleLength(other); + const CSSSimpleLength* o = toCSSSimpleLength(other); result->set(get(o->lengthUnit()) - o->value(), o->lengthUnit()); } return result;
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.h b/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.h index b0eb93c..1bfa6e3 100644 --- a/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.h +++ b/third_party/WebKit/Source/core/css/cssom/StyleCalcLength.h
@@ -11,7 +11,7 @@ namespace blink { class CalcDictionary; -class SimpleLength; +class CSSSimpleLength; class CORE_EXPORT StyleCalcLength final : public CSSLengthValue { DEFINE_WRAPPERTYPEINFO(); @@ -62,7 +62,7 @@ private: StyleCalcLength(); StyleCalcLength(const StyleCalcLength& other); - StyleCalcLength(const SimpleLength& other); + StyleCalcLength(const CSSSimpleLength& other); static int indexForUnit(CSSPrimitiveValue::UnitType); static CSSPrimitiveValue::UnitType unitFromIndex(int index)
diff --git a/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp b/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp index c873718..265feb1 100644 --- a/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp +++ b/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp
@@ -5,7 +5,7 @@ #include "core/css/cssom/StylePropertyMap.h" #include "bindings/core/v8/ExceptionState.h" -#include "core/css/cssom/SimpleLength.h" +#include "core/css/cssom/CSSSimpleLength.h" #include "core/css/cssom/StyleValue.h" #include "core/css/cssom/StyleValueFactory.h"
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp index 2a0a0a7..2b43010f 100644 --- a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp +++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
@@ -5,7 +5,7 @@ #include "core/css/cssom/StyleValueFactory.h" #include "core/css/CSSValue.h" -#include "core/css/cssom/SimpleLength.h" +#include "core/css/cssom/CSSSimpleLength.h" #include "core/css/cssom/StyleValue.h" namespace blink { @@ -15,7 +15,7 @@ if (value.isPrimitiveValue()) { const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); if (primitiveValue.isLength() && !primitiveValue.isCalculated()) { - return SimpleLength::create(primitiveValue.getDoubleValue(), primitiveValue.typeWithCalcResolved()); + return CSSSimpleLength::create(primitiveValue.getDoubleValue(), primitiveValue.typeWithCalcResolved()); } } // TODO(meade): Implement the rest.
diff --git a/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp b/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp index f78ba6e..43f3969 100644 --- a/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp +++ b/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp
@@ -161,8 +161,8 @@ ASSERT(!m_dirtiesAllStyle); if (m_treeScope->rootNode().isShadowRoot()) { - ContainerNode* shadowHost = toShadowRoot(m_treeScope->rootNode()).host(); - shadowHost->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleSheetChange)); + ContainerNode& shadowHost = toShadowRoot(m_treeScope->rootNode()).host(); + shadowHost.setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleSheetChange)); return; }
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp index 2fc2a0c..3213110a 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp +++ b/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp
@@ -836,8 +836,7 @@ if (!CSSParserFastPaths::isKeywordPropertyID(propertyId)) { // All properties accept the values of "initial" and "inherit". - String lowerCaseString = string.lower(); - if (lowerCaseString != "initial" && lowerCaseString != "inherit") + if (!equalIgnoringASCIICase(string, "initial") && !equalIgnoringASCIICase(string, "inherit")) return nullptr; // Parse initial/inherit shorthands using the CSSPropertyParser. @@ -901,12 +900,12 @@ return true; } +static const int kShortestValidTransformStringLength = 12; + template <typename CharType> static CSSFunctionValue* parseSimpleTransformValue(CharType*& pos, CharType* end) { - static const int shortestValidTransformStringLength = 12; - - if (end - pos < shortestValidTransformStringLength) + if (end - pos < kShortestValidTransformStringLength) return nullptr; const bool isTranslate = toASCIILower(pos[0]) == 't' @@ -987,8 +986,56 @@ } template <typename CharType> -static CSSValueList* parseSimpleTransformList(CharType*& pos, CharType* end) +static bool transformCanLikelyUseFastPath(const CharType* chars, unsigned length) { + // Very fast scan that attempts to reject most transforms that couldn't + // take the fast path. This avoids doing the malloc and string->double + // conversions in parseSimpleTransformValue only to discard them when we + // run into a transform component we don't understand. + unsigned i = 0; + while (i < length) { + if (isCSSSpace(chars[i])) { + ++i; + continue; + } + if (length - i < kShortestValidTransformStringLength) + return false; + switch (toASCIILower(chars[i])) { + case 't': + // translate, translateX, translateY, translateZ, translate3d. + if (toASCIILower(chars[i + 8]) != 'e') + return false; + i += 9; + break; + case 'm': + // matrix3d. + if (toASCIILower(chars[i + 7]) != 'd') + return false; + i += 8; + break; + case 's': + // scale3d. + if (toASCIILower(chars[i + 6]) != 'd') + return false; + i += 7; + break; + default: + // All other things, ex. rotate. + return false; + } + // Advance to the end of the arguments. + i = WTF::find(chars, length, ')', i) + 1; + } + return i == length; +} + +template <typename CharType> +static CSSValueList* parseSimpleTransformList(const CharType* chars, unsigned length) +{ + if (!transformCanLikelyUseFastPath(chars, length)) + return nullptr; + const CharType*& pos = chars; + const CharType* end = chars + length; CSSValueList* transformList = nullptr; while (pos < end) { while (pos < end && isCSSSpace(*pos)) @@ -1011,14 +1058,9 @@ if (propertyID != CSSPropertyTransform) return nullptr; - if (string.is8Bit()) { - const LChar* pos = string.characters8(); - const LChar* end = pos + string.length(); - return parseSimpleTransformList(pos, end); - } - const UChar* pos = string.characters16(); - const UChar* end = pos + string.length(); - return parseSimpleTransformList(pos, end); + if (string.is8Bit()) + return parseSimpleTransformList(string.characters8(), string.length()); + return parseSimpleTransformList(string.characters16(), string.length()); } CSSValue* CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID, const String& string, CSSParserMode parserMode)
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp index 5e30abe8..e603bd9 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp +++ b/third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp
@@ -10,6 +10,36 @@ namespace blink { +TEST(CSSParserFastPathsTest, ParseKeyword) +{ + CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyFloat, "left", HTMLStandardMode); + ASSERT_NE(nullptr, value); + EXPECT_TRUE(value->isPrimitiveValue()); + CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); + EXPECT_TRUE(primitiveValue->isValueID()); + EXPECT_EQ(CSSValueLeft, primitiveValue->getValueID()); + value = CSSParserFastPaths::maybeParseValue(CSSPropertyFloat, "foo", HTMLStandardMode); + ASSERT_EQ(nullptr, value); +} +TEST(CSSParserFastPathsTest, ParseInitialAndInheritKeyword) +{ + CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyMarginTop, "inherit", HTMLStandardMode); + ASSERT_NE(nullptr, value); + EXPECT_TRUE(value->isInheritedValue()); + value = CSSParserFastPaths::maybeParseValue(CSSPropertyMarginRight, "InHeriT", HTMLStandardMode); + ASSERT_NE(nullptr, value); + EXPECT_TRUE(value->isInheritedValue()); + value = CSSParserFastPaths::maybeParseValue(CSSPropertyMarginBottom, "initial", HTMLStandardMode); + ASSERT_NE(nullptr, value); + EXPECT_TRUE(value->isInitialValue()); + value = CSSParserFastPaths::maybeParseValue(CSSPropertyMarginLeft, "IniTiaL", HTMLStandardMode); + ASSERT_NE(nullptr, value); + EXPECT_TRUE(value->isInitialValue()); + // Fast path doesn't handle short hands. + value = CSSParserFastPaths::maybeParseValue(CSSPropertyMargin, "initial", HTMLStandardMode); + ASSERT_EQ(nullptr, value); +} + TEST(CSSParserFastPathsTest, ParseTransform) { CSSValue* value = CSSParserFastPaths::maybeParseValue(CSSPropertyTransform, "translate(5.5px, 5px)", HTMLStandardMode);
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserImpl.h b/third_party/WebKit/Source/core/css/parser/CSSParserImpl.h index 2f88a08..3d8fbea 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSParserImpl.h +++ b/third_party/WebKit/Source/core/css/parser/CSSParserImpl.h
@@ -113,7 +113,7 @@ // FIXME: Can we build StylePropertySets directly? // FIXME: Investigate using a smaller inline buffer HeapVector<CSSProperty, 256> m_parsedProperties; - CSSParserContext m_context; + const CSSParserContext& m_context; Member<StyleSheetContents> m_styleSheet;
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserSelector.h b/third_party/WebKit/Source/core/css/parser/CSSParserSelector.h index 50ff17d..8be43de 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSParserSelector.h +++ b/third_party/WebKit/Source/core/css/parser/CSSParserSelector.h
@@ -67,7 +67,7 @@ CSSParserSelector* tagHistory() const { return m_tagHistory.get(); } void setTagHistory(PassOwnPtr<CSSParserSelector> selector) { m_tagHistory = std::move(selector); } - void clearTagHistory() { m_tagHistory.clear(); } + void clearTagHistory() { m_tagHistory.reset(); } void appendTagHistory(CSSSelector::RelationType, PassOwnPtr<CSSParserSelector>); PassOwnPtr<CSSParserSelector> releaseTagHistory(); void prependTagSelector(const QualifiedName&, bool tagIsImplicit = false);
diff --git a/third_party/WebKit/Source/core/dom/ExecutionContext.cpp b/third_party/WebKit/Source/core/dom/ExecutionContext.cpp index 4619388..98610a0f 100644 --- a/third_party/WebKit/Source/core/dom/ExecutionContext.cpp +++ b/third_party/WebKit/Source/core/dom/ExecutionContext.cpp
@@ -166,7 +166,7 @@ PendingException* e = m_pendingExceptions->at(i).get(); logExceptionToConsole(e->m_errorMessage, e->m_scriptId, e->m_sourceURL, e->m_lineNumber, e->m_columnNumber, e->m_callStack); } - m_pendingExceptions.clear(); + m_pendingExceptions.reset(); } bool ExecutionContext::dispatchErrorEvent(ErrorEvent* errorEvent, AccessControlStatus corsStatus)
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp index b6a7a56..8ac672a 100644 --- a/third_party/WebKit/Source/core/dom/Node.cpp +++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -1040,7 +1040,7 @@ Element* Node::shadowHost() const { if (ShadowRoot* root = containingShadowRoot()) - return root->host(); + return &root->host(); return nullptr; } @@ -1078,7 +1078,7 @@ return nullptr; if (parent->isShadowRoot()) - return toShadowRoot(parent)->host(); + return &toShadowRoot(parent)->host(); if (!parent->isElementNode()) return nullptr;
diff --git a/third_party/WebKit/Source/core/dom/SandboxFlags.cpp b/third_party/WebKit/Source/core/dom/SandboxFlags.cpp index c97e074..1226f526 100644 --- a/third_party/WebKit/Source/core/dom/SandboxFlags.cpp +++ b/third_party/WebKit/Source/core/dom/SandboxFlags.cpp
@@ -63,6 +63,8 @@ flags &= ~SandboxPropagatesToAuxiliaryBrowsingContexts; } else if (equalIgnoringCase(sandboxToken, "allow-modals") && RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { flags &= ~SandboxModals; + } else if (equalIgnoringCase(sandboxToken, "allow-presentation")) { + flags &= ~SandboxPresentation; } else { if (numberOfTokenErrors) tokenErrors.appendLiteral(", '");
diff --git a/third_party/WebKit/Source/core/dom/SandboxFlags.h b/third_party/WebKit/Source/core/dom/SandboxFlags.h index 98cabac..efd733d8 100644 --- a/third_party/WebKit/Source/core/dom/SandboxFlags.h +++ b/third_party/WebKit/Source/core/dom/SandboxFlags.h
@@ -48,6 +48,7 @@ SandboxOrientationLock = 1 << 10, // See https://w3c.github.io/screen-orientation/#dfn-sandboxed-orientation-lock-browsing-context-flag. SandboxPropagatesToAuxiliaryBrowsingContexts = 1 << 11, SandboxModals = 1 << 12, + SandboxPresentation = 1 << 13, // See https://w3c.github.io/presentation-api/#sandboxing-and-the-allow-presentation-keyword SandboxAll = -1 // Mask with all bits set to 1. };
diff --git a/third_party/WebKit/Source/core/dom/SelectorQuery.cpp b/third_party/WebKit/Source/core/dom/SelectorQuery.cpp index 5966fc9..facc59b 100644 --- a/third_party/WebKit/Source/core/dom/SelectorQuery.cpp +++ b/third_party/WebKit/Source/core/dom/SelectorQuery.cpp
@@ -425,7 +425,7 @@ return youngerShadowRoot; } - current = shadowRoot->host(); + current = &shadowRoot->host(); } return nullptr; }
diff --git a/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp b/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp index cc64efe..31aabc7 100644 --- a/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp +++ b/third_party/WebKit/Source/core/dom/ShadowTreeStyleSheetCollection.cpp
@@ -84,7 +84,7 @@ } } if (change.requiresFullStyleRecalc) - toShadowRoot(treeScope().rootNode()).host()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::ActiveStylesheetsUpdate)); + toShadowRoot(treeScope().rootNode()).host().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::ActiveStylesheetsUpdate)); collection.swap(*this); }
diff --git a/third_party/WebKit/Source/core/dom/shadow/ElementShadow.cpp b/third_party/WebKit/Source/core/dom/shadow/ElementShadow.cpp index e5a8f03e..597c4bf64 100644 --- a/third_party/WebKit/Source/core/dom/shadow/ElementShadow.cpp +++ b/third_party/WebKit/Source/core/dom/shadow/ElementShadow.cpp
@@ -222,7 +222,7 @@ if (m_needsDistributionRecalc) return; m_needsDistributionRecalc = true; - host()->markAncestorsWithChildNeedsDistributionRecalc(); + host().markAncestorsWithChildNeedsDistributionRecalc(); clearDistribution(); } @@ -282,7 +282,7 @@ void ElementShadow::distributeV0() { HeapVector<Member<HTMLShadowElement>, 32> shadowInsertionPoints; - DistributionPool pool(*host()); + DistributionPool pool(host()); for (ShadowRoot* root = &youngestShadowRoot(); root; root = root->olderShadowRoot()) { HTMLShadowElement* shadowInsertionPoint = 0; @@ -319,7 +319,7 @@ if (ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*shadowInsertionPoint)) shadow->setNeedsDistributionRecalc(); } - InspectorInstrumentation::didPerformElementShadowDistribution(host()); + InspectorInstrumentation::didPerformElementShadowDistribution(&host()); } void ElementShadow::didDistributeNode(const Node* node, InsertionPoint* insertionPoint)
diff --git a/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h b/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h index de4aa36..95b935d 100644 --- a/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h +++ b/third_party/WebKit/Source/core/dom/shadow/ElementShadow.h
@@ -43,7 +43,7 @@ static ElementShadow* create(); ~ElementShadow(); - Element* host() const; + Element& host() const; ShadowRoot& youngestShadowRoot() const; ShadowRoot* oldestShadowRoot() const { return m_shadowRoot; } ElementShadow* containingShadow() const; @@ -99,7 +99,7 @@ bool m_needsSelectFeatureSet; }; -inline Element* ElementShadow::host() const +inline Element& ElementShadow::host() const { DCHECK(m_shadowRoot); return m_shadowRoot->host(); @@ -121,7 +121,7 @@ inline ElementShadow* ElementShadow::containingShadow() const { - if (ShadowRoot* parentRoot = host()->containingShadowRoot()) + if (ShadowRoot* parentRoot = host().containingShadowRoot()) return parentRoot->owner(); return 0; }
diff --git a/third_party/WebKit/Source/core/dom/shadow/FlatTreeTraversal.cpp b/third_party/WebKit/Source/core/dom/shadow/FlatTreeTraversal.cpp index d7fae26..fea08570 100644 --- a/third_party/WebKit/Source/core/dom/shadow/FlatTreeTraversal.cpp +++ b/third_party/WebKit/Source/core/dom/shadow/FlatTreeTraversal.cpp
@@ -203,7 +203,7 @@ DCHECK(!shadowRoot->shadowInsertionPointOfYoungerShadowRoot()); if (!shadowRoot->isYoungest()) return nullptr; - return shadowRoot->host(); + return &shadowRoot->host(); } Node* FlatTreeTraversal::childAt(const Node& node, unsigned index)
diff --git a/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp b/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp index 28287de..aabea367 100644 --- a/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp +++ b/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.cpp
@@ -130,12 +130,7 @@ void ShadowRoot::setInnerHTML(const String& markup, ExceptionState& exceptionState) { - if (isOrphan()) { - exceptionState.throwDOMException(InvalidAccessError, "The ShadowRoot does not have a host."); - return; - } - - if (DocumentFragment* fragment = createFragmentForInnerOuterHTML(markup, host(), AllowScriptingContent, "innerHTML", exceptionState)) + if (DocumentFragment* fragment = createFragmentForInnerOuterHTML(markup, &host(), AllowScriptingContent, "innerHTML", exceptionState)) replaceChildrenWithFragment(this, fragment, exceptionState); } @@ -175,7 +170,7 @@ if (m_registeredWithParentShadowRoot) return InsertionDone; - if (ShadowRoot* root = host()->containingShadowRoot()) { + if (ShadowRoot* root = host().containingShadowRoot()) { root->addChildShadowRoot(); m_registeredWithParentShadowRoot = true; } @@ -188,7 +183,7 @@ if (insertionPoint->inShadowIncludingDocument()) { document().styleEngine().shadowRootRemovedFromDocument(this); if (m_registeredWithParentShadowRoot) { - ShadowRoot* root = host()->containingShadowRoot(); + ShadowRoot* root = host().containingShadowRoot(); if (!root) root = insertionPoint->containingShadowRoot(); if (root)
diff --git a/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h b/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h index 271865f..eaa59e9 100644 --- a/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h +++ b/third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h
@@ -72,10 +72,8 @@ using TreeScope::setDocument; using TreeScope::setParentTreeScope; - // TODO(kochi): crbug.com/507413 In non-Oilpan, host() may return null during queued - // event handling (e.g. during execCommand()). - Element* host() const { return toElement(parentOrShadowHostNode()); } - ElementShadow* owner() const { return host() ? host()->shadow() : 0; } + Element& host() const { DCHECK(parentOrShadowHostNode()); return *toElement(parentOrShadowHostNode()); } + ElementShadow* owner() const { return host().shadow(); } ShadowRootType type() const { return static_cast<ShadowRootType>(m_type); } String mode() const { return (type() == ShadowRootType::V0 || type() == ShadowRootType::Open) ? "open" : "closed"; }; @@ -159,9 +157,6 @@ // ShadowRoots should never be cloned. Node* cloneNode(bool) override { return nullptr; } - // FIXME: This shouldn't happen. https://bugs.webkit.org/show_bug.cgi?id=88834 - bool isOrphan() const { return !host(); } - void invalidateDescendantSlots(); unsigned descendantSlotCount() const;
diff --git a/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp b/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp index a13e9fb..712a29c 100644 --- a/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp +++ b/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp
@@ -40,7 +40,7 @@ name2slot.add(slot->name(), slot.get()); } - for (Node& child : NodeTraversal::childrenOf(*shadowRoot.host())) { + for (Node& child : NodeTraversal::childrenOf(shadowRoot.host())) { if (child.isInsertionPoint()) { // A re-distribution across v0 and v1 shadow trees is not supported. detachNotAssignedNode(child);
diff --git a/third_party/WebKit/Source/core/editing/CaretBase.cpp b/third_party/WebKit/Source/core/editing/CaretBase.cpp index 0a75091..dc32b36 100644 --- a/third_party/WebKit/Source/core/editing/CaretBase.cpp +++ b/third_party/WebKit/Source/core/editing/CaretBase.cpp
@@ -70,6 +70,11 @@ // if caretNode is a block and caret is inside it then caret should be painted by that block bool paintedByBlock = layoutObject->isLayoutBlock() && caretRendersInsideNode(node); + // TODO(yoichio): This function is called at least + // DocumentLifeCycle::LayoutClean but caretRendersInsideNode above can + // layout. Thus |node->layoutObject()| can be changed then this is bad + // design. We should make caret painting algorithm clean. + CHECK_EQ(layoutObject, node->layoutObject()) << "Layout tree should not changed"; return paintedByBlock ? toLayoutBlock(layoutObject) : layoutObject->containingBlock(); } @@ -134,6 +139,9 @@ return caretPainter->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoundingBox(); } +// TODO(yoichio): |node| is FrameSelection::m_previousCaretNode and this is bad +// design. We should use only previous layoutObject or Rectangle to invalidate +// old caret. void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect) { LayoutBlockItem caretPainter = LayoutBlockItem(caretLayoutObject(node));
diff --git a/third_party/WebKit/Source/core/editing/DOMSelection.cpp b/third_party/WebKit/Source/core/editing/DOMSelection.cpp index 4273f58..1c73094 100644 --- a/third_party/WebKit/Source/core/editing/DOMSelection.cpp +++ b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
@@ -79,6 +79,11 @@ m_treeScope = nullptr; } +bool DOMSelection::isAvailable() const +{ + return m_frame; +} + const VisibleSelection& DOMSelection::visibleSelection() const { DCHECK(m_frame); @@ -109,7 +114,7 @@ Node* DOMSelection::anchorNode() const { - if (!m_frame) + if (!isAvailable()) return 0; return shadowAdjustedNode(anchorPosition(visibleSelection())); @@ -117,7 +122,7 @@ int DOMSelection::anchorOffset() const { - if (!m_frame) + if (!isAvailable()) return 0; return shadowAdjustedOffset(anchorPosition(visibleSelection())); @@ -125,7 +130,7 @@ Node* DOMSelection::focusNode() const { - if (!m_frame) + if (!isAvailable()) return 0; return shadowAdjustedNode(focusPosition(visibleSelection())); @@ -133,7 +138,7 @@ int DOMSelection::focusOffset() const { - if (!m_frame) + if (!isAvailable()) return 0; return shadowAdjustedOffset(focusPosition(visibleSelection())); @@ -141,7 +146,7 @@ Node* DOMSelection::baseNode() const { - if (!m_frame) + if (!isAvailable()) return 0; return shadowAdjustedNode(basePosition(visibleSelection())); @@ -149,7 +154,7 @@ int DOMSelection::baseOffset() const { - if (!m_frame) + if (!isAvailable()) return 0; return shadowAdjustedOffset(basePosition(visibleSelection())); @@ -157,7 +162,7 @@ Node* DOMSelection::extentNode() const { - if (!m_frame) + if (!isAvailable()) return 0; return shadowAdjustedNode(extentPosition(visibleSelection())); @@ -165,7 +170,7 @@ int DOMSelection::extentOffset() const { - if (!m_frame) + if (!isAvailable()) return 0; return shadowAdjustedOffset(extentPosition(visibleSelection())); @@ -173,14 +178,14 @@ bool DOMSelection::isCollapsed() const { - if (!m_frame || selectionShadowAncestor(m_frame)) + if (!isAvailable() || selectionShadowAncestor(m_frame)) return true; return !m_frame->selection().isRange(); } String DOMSelection::type() const { - if (!m_frame) + if (!isAvailable()) return String(); FrameSelection& selection = m_frame->selection(); @@ -197,14 +202,14 @@ int DOMSelection::rangeCount() const { - if (!m_frame) + if (!isAvailable()) return 0; return m_frame->selection().isNone() ? 0 : 1; } void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionState) { - if (!m_frame) + if (!isAvailable()) return; if (!node) { @@ -232,7 +237,7 @@ void DOMSelection::collapseToEnd(ExceptionState& exceptionState) { - if (!m_frame) + if (!isAvailable()) return; const VisibleSelection& selection = m_frame->selection().selection(); @@ -247,7 +252,7 @@ void DOMSelection::collapseToStart(ExceptionState& exceptionState) { - if (!m_frame) + if (!isAvailable()) return; const VisibleSelection& selection = m_frame->selection().selection(); @@ -262,14 +267,14 @@ void DOMSelection::empty() { - if (!m_frame) + if (!isAvailable()) return; m_frame->selection().clear(); } void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extentNode, int extentOffset, ExceptionState& exceptionState) { - if (!m_frame) + if (!isAvailable()) return; if (baseOffset < 0) { @@ -296,7 +301,7 @@ void DOMSelection::modify(const String& alterString, const String& directionString, const String& granularityString) { - if (!m_frame) + if (!isAvailable()) return; FrameSelection::EAlteration alter; @@ -348,7 +353,7 @@ { DCHECK(node); - if (!m_frame) + if (!isAvailable()) return; if (offset < 0) { @@ -372,7 +377,7 @@ Range* DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) { - if (!m_frame) + if (!isAvailable()) return nullptr; if (index < 0 || index >= rangeCount()) { @@ -397,7 +402,7 @@ void DOMSelection::removeAllRanges() { - if (!m_frame) + if (!isAvailable()) return; m_frame->selection().clear(); } @@ -406,7 +411,7 @@ { DCHECK(newRange); - if (!m_frame) + if (!isAvailable()) return; if (!newRange->inShadowIncludingDocument()) { @@ -452,7 +457,7 @@ void DOMSelection::deleteFromDocument() { - if (!m_frame) + if (!isAvailable()) return; FrameSelection& selection = m_frame->selection(); @@ -473,7 +478,7 @@ { DCHECK(n); - if (!m_frame) + if (!isAvailable()) return false; FrameSelection& selection = m_frame->selection(); @@ -517,7 +522,7 @@ String DOMSelection::toString() { - if (!m_frame) + if (!isAvailable()) return String(); const EphemeralRange range = m_frame->selection().selection().toNormalizedEphemeralRange();
diff --git a/third_party/WebKit/Source/core/editing/DOMSelection.h b/third_party/WebKit/Source/core/editing/DOMSelection.h index 6e03db6..72db3a2 100644 --- a/third_party/WebKit/Source/core/editing/DOMSelection.h +++ b/third_party/WebKit/Source/core/editing/DOMSelection.h
@@ -99,6 +99,8 @@ private: explicit DOMSelection(const TreeScope*); + bool isAvailable() const; + // Convenience method for accessors, does not check m_frame present. const VisibleSelection& visibleSelection() const;
diff --git a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp index 3d9312b1..8af22ad 100644 --- a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp +++ b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
@@ -133,9 +133,12 @@ dummyPageHolder().frameView().setFrameRect(frameRect); } OwnPtr<PaintController> paintController = PaintController::create(); - GraphicsContext context(*paintController); - DrawingRecorder drawingRecorder(context, *dummyPageHolder().frameView().layoutView(), DisplayItem::Caret, LayoutRect::infiniteIntRect()); - selection().paintCaret(context, LayoutPoint()); + { + GraphicsContext context(*paintController); + DrawingRecorder drawingRecorder(context, *dummyPageHolder().frameView().layoutView(), DisplayItem::Caret, LayoutRect::infiniteIntRect()); + selection().paintCaret(context, LayoutPoint()); + } + paintController->commitNewDisplayItems(); EXPECT_EQ(startCount, layoutCount()); }
diff --git a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp index d2db91b..d18629b 100644 --- a/third_party/WebKit/Source/core/editing/VisibleSelection.cpp +++ b/third_party/WebKit/Source/core/editing/VisibleSelection.cpp
@@ -947,9 +947,39 @@ #endif +template <typename Strategy> +void VisibleSelectionTemplate<Strategy>::PrintTo( + const VisibleSelectionTemplate<Strategy>& selection, + std::ostream* ostream) +{ + if (selection.isNone()) { + *ostream << "VisibleSelection()"; + return; + } + *ostream << "VisibleSelection(base: " << selection.base() + << " extent:" << selection.extent() + << " start: " << selection.start() + << " end: " << selection.end() + << ' ' << selection.affinity() + << ' ' << (selection.isDirectional() ? "Directional" : "NonDirectional") + << ')'; +} + template class CORE_TEMPLATE_EXPORT VisibleSelectionTemplate<EditingStrategy>; template class CORE_TEMPLATE_EXPORT VisibleSelectionTemplate<EditingInFlatTreeStrategy>; +std::ostream& operator<<(std::ostream& ostream, const VisibleSelection& selection) +{ + VisibleSelection::PrintTo(selection, &ostream); + return ostream; +} + +std::ostream& operator<<(std::ostream& ostream, const VisibleSelectionInFlatTree& selection) +{ + VisibleSelectionInFlatTree::PrintTo(selection, &ostream); + return ostream; +} + } // namespace blink #ifndef NDEBUG
diff --git a/third_party/WebKit/Source/core/editing/VisibleSelection.h b/third_party/WebKit/Source/core/editing/VisibleSelection.h index 7c73188..f1ded2a4 100644 --- a/third_party/WebKit/Source/core/editing/VisibleSelection.h +++ b/third_party/WebKit/Source/core/editing/VisibleSelection.h
@@ -156,6 +156,7 @@ void formatForDebugger(char* buffer, unsigned length) const; void showTreeForThis() const; #endif + static void PrintTo(const VisibleSelectionTemplate&, std::ostream*); void setStartRespectingGranularity(TextGranularity, EWordSide = RightWordIfOnBoundary); void setEndRespectingGranularity(TextGranularity, EWordSide = RightWordIfOnBoundary); @@ -217,6 +218,9 @@ // TODO(sof): move more firstRangeOf() uses to be over EphemeralRange instead. CORE_EXPORT Range* firstRangeOf(const VisibleSelection&); +CORE_EXPORT std::ostream& operator<<(std::ostream&, const VisibleSelection&); +CORE_EXPORT std::ostream& operator<<(std::ostream&, const VisibleSelectionInFlatTree&); + } // namespace blink #ifndef NDEBUG
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp index cedcaab..f3bfbde7 100644 --- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp +++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -65,6 +65,7 @@ #include "platform/RuntimeEnabledFeatures.h" #include "platform/heap/Handle.h" #include "platform/text/TextBoundaries.h" +#include "platform/text/TextBreakIterator.h" namespace blink { @@ -1923,7 +1924,7 @@ InlineBox* inlineBox = nullptr; int caretOffset = position.computeEditingOffset(); Node* const anchorNode = position.anchorNode(); - LayoutObject* layoutObject = anchorNode->isShadowRoot() ? toShadowRoot(anchorNode)->host()->layoutObject() : anchorNode->layoutObject(); + LayoutObject* layoutObject = anchorNode->isShadowRoot() ? toShadowRoot(anchorNode)->host().layoutObject() : anchorNode->layoutObject(); DCHECK(layoutObject) << position;
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp index 1064fc0..99c5895 100644 --- a/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp +++ b/third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp
@@ -389,7 +389,7 @@ m_fullyClippedStack.pushFullyClippedState(m_node); } else { // We are the last shadow root; exit from here and go back to where we were. - m_node = shadowRoot->host(); + m_node = &shadowRoot->host(); m_iterationProgress = HandledOpenShadowRoots; --m_shadowDepth; m_fullyClippedStack.pop(); @@ -398,7 +398,7 @@ // If we are in a closed or user-agent shadow root, then go back to the host. // TODO(kochi): Make sure we treat closed shadow as user agent shadow here. DCHECK(shadowRoot->type() == ShadowRootType::Closed || shadowRoot->type() == ShadowRootType::UserAgent); - m_node = shadowRoot->host(); + m_node = &shadowRoot->host(); m_iterationProgress = HandledUserAgentShadowRoot; --m_shadowDepth; m_fullyClippedStack.pop();
diff --git a/third_party/WebKit/Source/core/fetch/FontResource.cpp b/third_party/WebKit/Source/core/fetch/FontResource.cpp index 72f2872..2483a03c 100644 --- a/third_party/WebKit/Source/core/fetch/FontResource.cpp +++ b/third_party/WebKit/Source/core/fetch/FontResource.cpp
@@ -169,7 +169,7 @@ void FontResource::allClientsAndObserversRemoved() { - m_fontData.clear(); + m_fontData.reset(); Resource::allClientsAndObserversRemoved(); }
diff --git a/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp b/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp index 80393f4..6c4b6553 100644 --- a/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp +++ b/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp
@@ -154,7 +154,7 @@ if (responseNeedsAccessControlCheck()) { if (response.wasFetchedViaServiceWorker()) { if (response.wasFallbackRequiredByServiceWorker()) { - m_loader.clear(); + m_loader.reset(); m_loader = adoptPtr(Platform::current()->createURLLoader()); ASSERT(m_loader); ResourceRequest request = m_resource->lastResourceRequest(); @@ -206,13 +206,13 @@ void ResourceLoader::didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataLength) { - m_loader.clear(); + m_loader.reset(); m_fetcher->didFinishLoading(m_resource.get(), finishTime, encodedDataLength, ResourceFetcher::DidFinishLoading); } void ResourceLoader::didFail(WebURLLoader*, const WebURLError& error) { - m_loader.clear(); + m_loader.reset(); m_fetcher->didFailLoading(m_resource.get(), error); }
diff --git a/third_party/WebKit/Source/core/fileapi/FileReaderLoader.cpp b/third_party/WebKit/Source/core/fileapi/FileReaderLoader.cpp index d060667..2fe149e 100644 --- a/third_party/WebKit/Source/core/fileapi/FileReaderLoader.cpp +++ b/third_party/WebKit/Source/core/fileapi/FileReaderLoader.cpp
@@ -166,10 +166,10 @@ // If we get any error, we do not need to keep a buffer around. if (m_errorCode) { - m_rawData.clear(); + m_rawData.reset(); m_stringResult = ""; m_isRawDataConverted = true; - m_decoder.clear(); + m_decoder.reset(); } } @@ -248,7 +248,7 @@ unsigned bytesAppended = m_rawData->append(data, dataLength); if (!bytesAppended) { - m_rawData.clear(); + m_rawData.reset(); m_bytesLoaded = 0; failed(FileError::NOT_READABLE_ERR); return;
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp index 2678d32..ffa4af4 100644 --- a/third_party/WebKit/Source/core/frame/FrameView.cpp +++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -224,7 +224,7 @@ m_visuallyNonEmptyPixelCount = 0; m_isVisuallyNonEmpty = false; clearFragmentAnchor(); - m_viewportConstrainedObjects.clear(); + m_viewportConstrainedObjects.reset(); m_layoutSubtreeRootList.clear(); m_orthogonalWritingModeRootList.clear(); } @@ -825,7 +825,7 @@ bool isTracing = false; TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink.debug.layout"), &isTracing); if (!isTracing) { - m_analyzer.clear(); + m_analyzer.reset(); return; } if (!m_analyzer)
diff --git a/third_party/WebKit/Source/core/frame/LocalFrame.cpp b/third_party/WebKit/Source/core/frame/LocalFrame.cpp index d253c73..39c1273 100644 --- a/third_party/WebKit/Source/core/frame/LocalFrame.cpp +++ b/third_party/WebKit/Source/core/frame/LocalFrame.cpp
@@ -318,7 +318,7 @@ SubframeLoadingDisabler disabler(*document()); m_loader.dispatchUnloadEvent(); detachChildren(); - m_frameScheduler.clear(); + m_frameScheduler.reset(); // All done if detaching the subframes brought about a detach of this frame also. if (!client())
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp index 96218cb1..72bf3360 100644 --- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -950,7 +950,7 @@ void HTMLCanvasElement::discardImageBuffer() { - m_imageBuffer.clear(); + m_imageBuffer.reset(); m_dirtyRect = FloatRect(); updateExternallyAllocatedMemory(); }
diff --git a/third_party/WebKit/Source/core/html/HTMLDocument.cpp b/third_party/WebKit/Source/core/html/HTMLDocument.cpp index f3a16be1f..cc13db4 100644 --- a/third_party/WebKit/Source/core/html/HTMLDocument.cpp +++ b/third_party/WebKit/Source/core/html/HTMLDocument.cpp
@@ -170,6 +170,8 @@ if (name.isEmpty()) return; map.add(name); + if (LocalFrame* f = frame()) + f->script().namedItemAdded(this, name); } void HTMLDocument::removeItemFromMap(HashCountedSet<AtomicString>& map, const AtomicString& name) @@ -177,6 +179,8 @@ if (name.isEmpty()) return; map.remove(name); + if (LocalFrame* f = frame()) + f->script().namedItemRemoved(this, name); } void HTMLDocument::addNamedItem(const AtomicString& name)
diff --git a/third_party/WebKit/Source/core/html/HTMLDocument.idl b/third_party/WebKit/Source/core/html/HTMLDocument.idl index 2f472d3..2b3f5b97 100644 --- a/third_party/WebKit/Source/core/html/HTMLDocument.idl +++ b/third_party/WebKit/Source/core/html/HTMLDocument.idl
@@ -23,7 +23,6 @@ // whose value is the Document interface object." // https://html.spec.whatwg.org/#the-window-object -[OverrideBuiltins] interface HTMLDocument : Document { // https://html.spec.whatwg.org/#Document-partial @@ -37,9 +36,6 @@ [MeasureAs=DocumentCaptureEvents] void captureEvents(); [MeasureAs=DocumentReleaseEvents] void releaseEvents(); - [Custom, NotEnumerable] getter object (unsigned long index); - [Custom, NotEnumerable] getter object (DOMString name); - // FIXME: all should not be [Replaceable]. [Replaceable, ImplementedAs=allForBinding] readonly attribute HTMLAllCollection all; };
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp index bb6419a..c7e6fe7 100644 --- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -3118,7 +3118,7 @@ getAudioSourceProvider().setClient(nullptr); if (m_webMediaPlayer) { m_audioSourceProvider.wrap(nullptr); - m_webMediaPlayer.clear(); + m_webMediaPlayer.reset(); } }
diff --git a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp index 422185f..f22dd48 100644 --- a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
@@ -2032,8 +2032,16 @@ : m_select(select) { m_observer = MutationObserver::create(this); + Vector<String> filter; + filter.reserveCapacity(4); + // Observe only attributes which affect popup content. + filter.append(String("disabled")); + filter.append(String("label")); + filter.append(String("selected")); + filter.append(String("value")); MutationObserverInit init; init.setAttributes(true); + init.setAttributeFilter(filter); init.setCharacterData(true); init.setChildList(true); init.setSubtree(true);
diff --git a/third_party/WebKit/Source/core/html/HTMLShadowElement.cpp b/third_party/WebKit/Source/core/html/HTMLShadowElement.cpp index fcffbb5e..8926204 100644 --- a/third_party/WebKit/Source/core/html/HTMLShadowElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLShadowElement.cpp
@@ -72,7 +72,7 @@ // Warn if trying to reproject between user agent and author shadows. ShadowRoot* root = containingShadowRoot(); if (root && root->olderShadowRoot() && root->type() != root->olderShadowRoot()->type()) { - String message = String::format("<shadow> doesn't work for %s element host.", root->host()->tagName().utf8().data()); + String message = String::format("<shadow> doesn't work for %s element host.", root->host().tagName().utf8().data()); document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, WarningMessageLevel, message)); } }
diff --git a/third_party/WebKit/Source/core/html/HTMLTableElement.cpp b/third_party/WebKit/Source/core/html/HTMLTableElement.cpp index bdd13a2..642ed23 100644 --- a/third_party/WebKit/Source/core/html/HTMLTableElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLTableElement.cpp
@@ -31,8 +31,10 @@ #include "core/HTMLNames.h" #include "core/css/CSSImageValue.h" #include "core/css/CSSValuePool.h" +#include "core/css/StylePropertySet.h" #include "core/dom/Attribute.h" #include "core/dom/ElementTraversal.h" +#include "core/dom/ExceptionCode.h" #include "core/dom/NodeListsNodeData.h" #include "core/dom/StyleChangeReason.h" #include "core/html/HTMLTableCaptionElement.h"
diff --git a/third_party/WebKit/Source/core/html/canvas/CanvasFontCache.cpp b/third_party/WebKit/Source/core/html/canvas/CanvasFontCache.cpp index a580d8a..cc641808 100644 --- a/third_party/WebKit/Source/core/html/canvas/CanvasFontCache.cpp +++ b/third_party/WebKit/Source/core/html/canvas/CanvasFontCache.cpp
@@ -40,7 +40,7 @@ CanvasFontCache::~CanvasFontCache() { - m_mainCachePurgePreventer.clear(); + m_mainCachePurgePreventer.reset(); if (m_pruningScheduled) { Platform::current()->currentThread()->removeTaskObserver(this); } @@ -124,7 +124,7 @@ m_fontsResolvedUsingDefaultStyle.remove(m_fontLRUList.first()); m_fontLRUList.removeFirst(); } - m_mainCachePurgePreventer.clear(); + m_mainCachePurgePreventer.reset(); Platform::current()->currentThread()->removeTaskObserver(this); m_pruningScheduled = false; }
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp index ab6d459..cf5ea7ff0 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -164,8 +164,8 @@ m_treeBuilder->detach(); // FIXME: It seems wrong that we would have a preload scanner here. // Yet during fast/dom/HTMLScriptElement/script-load-events.html we do. - m_preloadScanner.clear(); - m_insertionPreloadScanner.clear(); + m_preloadScanner.reset(); + m_insertionPreloadScanner.reset(); if (m_parserScheduler) { m_parserScheduler->detach(); m_parserScheduler.clear(); @@ -174,8 +174,8 @@ // HTMLToken::m_data and let the allocator reuse the memory for // HTMLToken::m_data of a next HTMLDocumentParser. We need to clear // m_tokenizer first because m_tokenizer has a raw pointer to m_token. - m_tokenizer.clear(); - m_token.clear(); + m_tokenizer.reset(); + m_token.reset(); } void HTMLDocumentParser::stopParsing() @@ -763,7 +763,7 @@ if (m_input.current().isEmpty() && !isWaitingForScripts()) { // We have parsed until the end of the current input and so are now moving ahead of the preload scanner. // Clear the scanner so we know to scan starting from the current input point if we block again. - m_preloadScanner.clear(); + m_preloadScanner.reset(); } else { m_preloadScanner->appendToEnd(source); if (isWaitingForScripts()) @@ -933,7 +933,7 @@ return; } - m_insertionPreloadScanner.clear(); + m_insertionPreloadScanner.reset(); pumpTokenizerIfPossible(); endIfDelayed(); }
diff --git a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp index 49897d7c..1185bd8 100644 --- a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp +++ b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp
@@ -146,7 +146,7 @@ else m_encoding = encoding; - m_codec.clear(); + m_codec.reset(); m_source = source; } @@ -344,7 +344,7 @@ return; setEncoding(m_charsetParser->encoding(), EncodingFromMetaTag); - m_charsetParser.clear(); + m_charsetParser.reset(); m_checkedForMetaCharset = true; return; } @@ -436,7 +436,7 @@ String result = m_codec->decode(m_buffer.data(), m_buffer.size(), FetchEOF, m_contentType == XMLContent && !m_useLenientXMLDecoding, m_sawError); m_buffer.clear(); - m_codec.clear(); + m_codec.reset(); m_checkedForBOM = false; // Skip BOM again when re-decoding. return result; }
diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp index 6b6482a..f5ce2f8c 100644 --- a/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp +++ b/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp
@@ -8,6 +8,7 @@ #include "core/css/StylePropertySet.h" #include "core/dom/Document.h" #include "core/dom/ElementTraversal.h" +#include "core/dom/StyleEngine.h" #include "core/frame/Settings.h" #include "core/html/HTMLVideoElement.h" #include "core/testing/DummyPageHolder.h"
diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp index c3ee71d..29f59a87 100644 --- a/third_party/WebKit/Source/core/input/EventHandler.cpp +++ b/third_party/WebKit/Source/core/input/EventHandler.cpp
@@ -139,7 +139,7 @@ Node* targetNode = mev.innerNode(); if (!targetNode || !targetNode->parentNode()) return true; - return targetNode->isShadowRoot() && isHTMLInputElement(*toShadowRoot(targetNode)->host()); + return targetNode->isShadowRoot() && isHTMLInputElement(toShadowRoot(targetNode)->host()); } // TODO(bokan): This method can go away once all scrolls happen through the
diff --git a/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp index dc3895c..63a656f9 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorCSSAgent.cpp
@@ -68,7 +68,6 @@ #include "core/layout/LayoutObject.h" #include "core/layout/LayoutObjectInlines.h" #include "core/layout/LayoutText.h" -#include "core/layout/LayoutTextFragment.h" #include "core/layout/api/LayoutViewItem.h" #include "core/layout/line/InlineTextBox.h" #include "core/loader/DocumentLoader.h"
diff --git a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp index 3417f3d..587a222 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp
@@ -892,13 +892,13 @@ const ShadowRoot* shadowRoot = toShadowRoot(node); if (shadowRoot->olderShadowRoot()) return shadowRoot->olderShadowRoot(); - Node* host = shadowRoot->host(); - if (host && host->hasChildren()) - return host->firstChild(); + Element& host = shadowRoot->host(); + if (host.hasChildren()) + return host.firstChild(); } if (node->nextSibling()) return node->nextSibling(); - node = node->isShadowRoot() ? toShadowRoot(node)->host() : node->parentNode(); + node = node->isShadowRoot() ? &toShadowRoot(node)->host() : node->parentNode(); } while (node); return nullptr;
diff --git a/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp b/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp index dc69575..afda780 100644 --- a/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp +++ b/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp
@@ -16,9 +16,6 @@ #include "core/inspector/InspectorCSSAgent.h" #include "core/inspector/InspectorDOMAgent.h" #include "core/inspector/InspectorHighlight.h" -#include "core/layout/LayoutBox.h" -#include "core/layout/LayoutInline.h" -#include "core/layout/LayoutObject.h" #include "core/style/ComputedStyle.h" #include "platform/ScriptForbiddenScope.h" #include "platform/inspector_protocol/Values.h"
diff --git a/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp b/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp index 3e43ab9..5feed2b 100644 --- a/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp +++ b/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp
@@ -72,7 +72,7 @@ void ThreadDebugger::endUserGesture() { - m_userGestureIndicator.clear(); + m_userGestureIndicator.reset(); } String16 ThreadDebugger::valueSubtype(v8::Local<v8::Value> value)
diff --git a/third_party/WebKit/Source/core/layout/ClipPathOperation.h b/third_party/WebKit/Source/core/layout/ClipPathOperation.h index 264fc76d..7258316 100644 --- a/third_party/WebKit/Source/core/layout/ClipPathOperation.h +++ b/third_party/WebKit/Source/core/layout/ClipPathOperation.h
@@ -104,7 +104,7 @@ const Path& path(const FloatRect& boundingRect) { ASSERT(m_shape); - m_path.clear(); + m_path.reset(); m_path = adoptPtr(new Path); m_shape->path(*m_path, boundingRect); m_path->setWindRule(m_shape->getWindRule());
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp index 7ec33d6..246bd48c 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -479,7 +479,7 @@ void LayoutBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool) { - m_overflow.clear(); + m_overflow.reset(); // Add overflow from children. addOverflowFromChildren(); @@ -1466,7 +1466,7 @@ if (node()->isRootEditableElement()) return true; - if (node()->isShadowRoot() && isHTMLInputElement(*toShadowRoot(node())->host())) + if (node()->isShadowRoot() && isHTMLInputElement(toShadowRoot(node())->host())) return true; return false;
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.h b/third_party/WebKit/Source/core/layout/LayoutBlock.h index ed0ab4c..c0cce94 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlock.h +++ b/third_party/WebKit/Source/core/layout/LayoutBlock.h
@@ -24,17 +24,14 @@ #define LayoutBlock_h #include "core/CoreExport.h" -#include "core/layout/FloatingObjects.h" -#include "core/layout/GapRects.h" #include "core/layout/LayoutBox.h" -#include "core/style/ShapeValue.h" -#include "platform/text/TextBreakIterator.h" #include "wtf/ListHashSet.h" #include "wtf/OwnPtr.h" namespace blink { struct PaintInfo; +class LineLayoutBox; class WordMeasurement; typedef WTF::ListHashSet<LayoutBox*, 16> TrackedLayoutBoxListHashSet;
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h index ebb499dc..4dbb8a8a 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h +++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.h
@@ -43,7 +43,6 @@ #include "core/layout/line/LineBoxList.h" #include "core/layout/line/RootInlineBox.h" #include "core/layout/line/TrailingObjects.h" -#include "core/style/ComputedStyleConstants.h" namespace blink { @@ -51,7 +50,6 @@ class ClipScope; class MarginInfo; class LayoutInline; -class LineBreaker; class LineInfo; class LineLayoutState; class LineWidth;
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp index 8f81209f..344e567 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp
@@ -1321,7 +1321,6 @@ // values (if any of them are larger than our current min/max). We then look at // the width of the last non-breakable run and use that to start a new line // (unless we end in whitespace). - const ComputedStyle& childStyle = child->styleRef(); LayoutUnit childMin; LayoutUnit childMax; @@ -1349,6 +1348,7 @@ bool clearPreviousFloat; if (child->isFloating()) { + const ComputedStyle& childStyle = child->styleRef(); clearPreviousFloat = (prevFloat && ((prevFloat->styleRef().floating() == LeftFloat && (childStyle.clear() & ClearLeft)) || (prevFloat->styleRef().floating() == RightFloat && (childStyle.clear() & ClearRight))));
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.h b/third_party/WebKit/Source/core/layout/LayoutBox.h index 2198a02..07533af 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBox.h +++ b/third_party/WebKit/Source/core/layout/LayoutBox.h
@@ -408,7 +408,7 @@ void addOverflowFromChild(LayoutBox* child) { addOverflowFromChild(child, child->locationOffset()); } void addOverflowFromChild(LayoutBox* child, const LayoutSize& delta); void clearLayoutOverflow(); - void clearAllOverflows() { m_overflow.clear(); } + void clearAllOverflows() { m_overflow.reset(); } void updateLayerTransformAfterLayout();
diff --git a/third_party/WebKit/Source/core/layout/LayoutEmbeddedObject.cpp b/third_party/WebKit/Source/core/layout/LayoutEmbeddedObject.cpp index e393783..f4e0ec81 100644 --- a/third_party/WebKit/Source/core/layout/LayoutEmbeddedObject.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutEmbeddedObject.cpp
@@ -127,7 +127,7 @@ updateLogicalWidth(); updateLogicalHeight(); - m_overflow.clear(); + m_overflow.reset(); addVisualEffectOverflow(); updateLayerTransformAfterLayout();
diff --git a/third_party/WebKit/Source/core/layout/LayoutIFrame.cpp b/third_party/WebKit/Source/core/layout/LayoutIFrame.cpp index 6944527..b187b40e 100644 --- a/third_party/WebKit/Source/core/layout/LayoutIFrame.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutIFrame.cpp
@@ -66,7 +66,7 @@ // No kids to layout as a replaced element. updateLogicalHeight(); - m_overflow.clear(); + m_overflow.reset(); addVisualEffectOverflow(); updateLayerTransformAfterLayout();
diff --git a/third_party/WebKit/Source/core/layout/LayoutMultiColumnSpannerPlaceholder.cpp b/third_party/WebKit/Source/core/layout/LayoutMultiColumnSpannerPlaceholder.cpp index 825e401..8dd4f5b 100644 --- a/third_party/WebKit/Source/core/layout/LayoutMultiColumnSpannerPlaceholder.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutMultiColumnSpannerPlaceholder.cpp
@@ -112,7 +112,7 @@ // Take the overflow from the spanner, so that it gets // propagated to the multicol container and beyond. - m_overflow.clear(); + m_overflow.reset(); addContentsVisualOverflow(m_layoutObjectInFlowThread->visualOverflowRect()); addLayoutOverflow(m_layoutObjectInFlowThread->layoutOverflowRect());
diff --git a/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp b/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp index 0abe779..ff657ef 100644 --- a/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutReplaced.cpp
@@ -91,7 +91,7 @@ updateLogicalWidth(); updateLogicalHeight(); - m_overflow.clear(); + m_overflow.reset(); addVisualEffectOverflow(); updateLayerTransformAfterLayout(); invalidateBackgroundObscurationStatus();
diff --git a/third_party/WebKit/Source/core/layout/LayoutRubyRun.h b/third_party/WebKit/Source/core/layout/LayoutRubyRun.h index 7c90a25..88491bd 100644 --- a/third_party/WebKit/Source/core/layout/LayoutRubyRun.h +++ b/third_party/WebKit/Source/core/layout/LayoutRubyRun.h
@@ -32,6 +32,7 @@ #define LayoutRubyRun_h #include "core/layout/LayoutBlockFlow.h" +#include "platform/text/TextBreakIterator.h" namespace blink {
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableRow.cpp b/third_party/WebKit/Source/core/layout/LayoutTableRow.cpp index cc800331..c7cf306 100644 --- a/third_party/WebKit/Source/core/layout/LayoutTableRow.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutTableRow.cpp
@@ -172,7 +172,7 @@ cell->layout(); } - m_overflow.clear(); + m_overflow.reset(); addVisualEffectOverflow(); // We do not call addOverflowFromCell here. The cell are laid out to be // measured above and will be sized correctly in a follow-up phase.
diff --git a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp index fc632892..5a3cadd7 100644 --- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp
@@ -1141,7 +1141,7 @@ unsigned totalCellsCount = nEffCols * totalRows; unsigned maxAllowedOverflowingCellsCount = totalCellsCount < gMinTableSizeToUseFastPaintPathWithOverflowingCell ? 0 : gMaxAllowedOverflowingCellRatioForFastPaintPath * totalCellsCount; - m_overflow.clear(); + m_overflow.reset(); m_overflowingCells.clear(); m_forceSlowPaintPathWithOverflowingCell = false; #if ENABLE(ASSERT)
diff --git a/third_party/WebKit/Source/core/layout/LayoutView.cpp b/third_party/WebKit/Source/core/layout/LayoutView.cpp index 132be2fb..85719079 100644 --- a/third_party/WebKit/Source/core/layout/LayoutView.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutView.cpp
@@ -251,7 +251,7 @@ if (!m_fragmentationContext) m_fragmentationContext = adoptPtr(new ViewFragmentationContext(*this)); } else if (m_fragmentationContext) { - m_fragmentationContext.clear(); + m_fragmentationContext.reset(); } SubtreeLayoutScope layoutScope(*this); @@ -997,7 +997,7 @@ if (PaintLayer* layer = this->layer()) layer->setNeedsRepaint(); LayoutBlockFlow::willBeDestroyed(); - m_compositor.clear(); + m_compositor.reset(); } void LayoutView::registerMediaForPositionChangeNotification(LayoutMedia& media)
diff --git a/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp b/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp index a4a95a6..d41e8f7 100644 --- a/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp +++ b/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp
@@ -904,7 +904,7 @@ } if (m_overflow) - m_overflow.clear(); + m_overflow.reset(); // Visual overflow just includes overflow for stuff we need to issues paint invalidations for ourselves. Self-painting layers are ignored. // Layout overflow is used to determine scrolling extent, so it still includes child layers and also factors in
diff --git a/third_party/WebKit/Source/core/layout/shapes/ShapeOutsideInfo.h b/third_party/WebKit/Source/core/layout/shapes/ShapeOutsideInfo.h index efa0104..56f27f27e 100644 --- a/third_party/WebKit/Source/core/layout/shapes/ShapeOutsideInfo.h +++ b/third_party/WebKit/Source/core/layout/shapes/ShapeOutsideInfo.h
@@ -109,7 +109,7 @@ static void removeInfo(const LayoutBox& key) { infoMap().remove(&key); } static ShapeOutsideInfo* info(const LayoutBox& key) { return infoMap().get(&key); } - void markShapeAsDirty() { m_shape.clear(); } + void markShapeAsDirty() { m_shape.reset(); } bool isShapeDirty() { return !m_shape.get(); } LayoutSize shapeSize() const { return m_referenceBoxLogicalSize; } bool isComputingShape() const { return m_isComputingShape; }
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp index 1b52a0c7..f33a86d9 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp
@@ -165,7 +165,7 @@ m_needsBoundariesOrTransformUpdate = false; } - m_overflow.clear(); + m_overflow.reset(); addVisualEffectOverflow(); if (!shouldApplyViewportClip()) {
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGShape.h b/third_party/WebKit/Source/core/layout/svg/LayoutSVGShape.h index d32716a..2e4899c1 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGShape.h +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGShape.h
@@ -91,7 +91,7 @@ const char* name() const override { return "LayoutSVGShape"; } protected: - void clearPath() { m_path.clear(); } + void clearPath() { m_path.reset(); } void createPath(); virtual void updateShapeFromElement();
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp index 477024d..5671072 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp
@@ -257,7 +257,7 @@ if (!firstLineBox()) setFrameRect(LayoutRect()); - m_overflow.clear(); + m_overflow.reset(); addVisualEffectOverflow(); if (!updateParentBoundaries)
diff --git a/third_party/WebKit/Source/core/loader/ThreadableLoaderTest.cpp b/third_party/WebKit/Source/core/loader/ThreadableLoaderTest.cpp index 268016ee..b2a664b6 100644 --- a/third_party/WebKit/Source/core/loader/ThreadableLoaderTest.cpp +++ b/third_party/WebKit/Source/core/loader/ThreadableLoaderTest.cpp
@@ -126,7 +126,7 @@ } void cancelLoader() override { m_loader->cancel(); } - void clearLoader() override { m_loader.clear(); } + void clearLoader() override { m_loader.reset(); } Checkpoint& checkpoint() override { return m_checkpoint; } void callCheckpoint(int n) override { m_checkpoint.Call(n); } @@ -140,7 +140,7 @@ void onTearDown() override { - m_loader.clear(); + m_loader.reset(); } private: @@ -194,7 +194,7 @@ { ASSERT(m_workerThread); ASSERT(m_workerThread->isCurrentThread()); - m_loader.clear(); + m_loader.reset(); } Checkpoint& checkpoint() override @@ -375,7 +375,7 @@ m_helper->onTearDown(); Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); memoryCache()->evictResources(); - m_client.clear(); + m_client.reset(); } void setUpSuccessURL()
diff --git a/third_party/WebKit/Source/core/loader/appcache/ApplicationCacheHost.cpp b/third_party/WebKit/Source/core/loader/appcache/ApplicationCacheHost.cpp index ed3a560..1b8f3189 100644 --- a/third_party/WebKit/Source/core/loader/appcache/ApplicationCacheHost.cpp +++ b/third_party/WebKit/Source/core/loader/appcache/ApplicationCacheHost.cpp
@@ -184,7 +184,7 @@ { // Detach from the owning DocumentLoader and let go of WebApplicationCacheHost. setApplicationCache(nullptr); - m_host.clear(); + m_host.reset(); m_documentLoader = nullptr; }
diff --git a/third_party/WebKit/Source/core/page/ContextMenuController.cpp b/third_party/WebKit/Source/core/page/ContextMenuController.cpp index 2c470469..d388d1e 100644 --- a/third_party/WebKit/Source/core/page/ContextMenuController.cpp +++ b/third_party/WebKit/Source/core/page/ContextMenuController.cpp
@@ -67,7 +67,7 @@ void ContextMenuController::clearContextMenu() { - m_contextMenu.clear(); + m_contextMenu.reset(); if (m_menuProvider) m_menuProvider->contextMenuCleared(); m_menuProvider = nullptr;
diff --git a/third_party/WebKit/Source/core/page/FocusController.cpp b/third_party/WebKit/Source/core/page/FocusController.cpp index 2ea563e..ce3dd37 100644 --- a/third_party/WebKit/Source/core/page/FocusController.cpp +++ b/third_party/WebKit/Source/core/page/FocusController.cpp
@@ -222,7 +222,7 @@ ASSERT(m_rootNode); if (m_rootNode->isShadowRoot()) { ShadowRoot& shadowRoot = toShadowRoot(*m_rootNode); - return shadowRoot.isYoungest() ? shadowRoot.host() : shadowRoot.shadowInsertionPointOfYoungerShadowRoot(); + return shadowRoot.isYoungest() ? &shadowRoot.host() : shadowRoot.shadowInsertionPointOfYoungerShadowRoot(); } // FIXME: Figure out the right thing for OOPI here. if (Frame* frame = m_rootNode->document().frame())
diff --git a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp index ce5e657..24e4dc1 100644 --- a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp +++ b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp
@@ -689,7 +689,7 @@ { if (m_programmaticScrollAnimatorTimeline) { layerTreeView.detachCompositorAnimationTimeline(m_programmaticScrollAnimatorTimeline->animationTimeline()); - m_programmaticScrollAnimatorTimeline.clear(); + m_programmaticScrollAnimatorTimeline.reset(); } }
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.cpp b/third_party/WebKit/Source/core/paint/PaintLayer.cpp index 9e7ab1d..0c2035c 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp +++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
@@ -412,7 +412,7 @@ if (hasTransform) ensureRareData().transform = TransformationMatrix::create(); else - m_rareData->transform.clear(); + m_rareData->transform.reset(); // PaintLayers with transforms act as clip rects roots, so clear the cached clip rects here. clipper().clearClipRectsIncludingDescendants(); @@ -989,7 +989,7 @@ { m_ancestorDependentCompositingInputs = compositingInputs; if (rareCompositingInputs.isDefault()) - m_rareAncestorDependentCompositingInputs.clear(); + m_rareAncestorDependentCompositingInputs.reset(); else m_rareAncestorDependentCompositingInputs = adoptPtr(new RareAncestorDependentCompositingInputs(rareCompositingInputs)); m_hasAncestorWithClipPath = hasAncestorWithClipPath; @@ -2349,7 +2349,7 @@ } if (m_rareData) - m_rareData->compositedLayerMapping.clear(); + m_rareData->compositedLayerMapping.reset(); if (!layerBeingDestroyed) updateOrRemoveFilterEffectBuilder();
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.h b/third_party/WebKit/Source/core/paint/PaintLayer.h index b190197..0d627d0 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayer.h +++ b/third_party/WebKit/Source/core/paint/PaintLayer.h
@@ -696,7 +696,7 @@ m_clipRectsCache = adoptPtr(new ClipRectsCache); return *m_clipRectsCache; } - void clearClipRectsCache() const { m_clipRectsCache.clear(); } + void clearClipRectsCache() const { m_clipRectsCache.reset(); } void dirty3DTransformedDescendantStatus(); // Both updates the status, and returns true if descendants of this have 3d.
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp index 262a70c..d489ae5 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp +++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
@@ -976,7 +976,7 @@ if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { if (shadowRoot->type() == ShadowRootType::UserAgent) - return *shadowRoot->host()->layoutObject(); + return *shadowRoot->host().layoutObject(); } }
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerStackingNode.h b/third_party/WebKit/Source/core/paint/PaintLayerStackingNode.h index 6826c9c..977f7be 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayerStackingNode.h +++ b/third_party/WebKit/Source/core/paint/PaintLayerStackingNode.h
@@ -196,8 +196,8 @@ updateStackingParentForZOrderLists(0); #endif - m_posZOrderList.clear(); - m_negZOrderList.clear(); + m_posZOrderList.reset(); + m_negZOrderList.reset(); } inline void PaintLayerStackingNode::updateZOrderLists()
diff --git a/third_party/WebKit/Source/core/svg/SVGElement.cpp b/third_party/WebKit/Source/core/svg/SVGElement.cpp index e6b2e755..abc2a1fa 100644 --- a/third_party/WebKit/Source/core/svg/SVGElement.cpp +++ b/third_party/WebKit/Source/core/svg/SVGElement.cpp
@@ -562,7 +562,7 @@ { if (ShadowRoot* root = containingShadowRoot()) { if (isSVGUseElement(root->host()) && (root->type() == ShadowRootType::UserAgent)) - return toSVGUseElement(root->host()); + return &toSVGUseElement(root->host()); } return nullptr; }
diff --git a/third_party/WebKit/Source/core/workers/WorkerThread.cpp b/third_party/WebKit/Source/core/workers/WorkerThread.cpp index e98767b..f78e15e 100644 --- a/third_party/WebKit/Source/core/workers/WorkerThread.cpp +++ b/third_party/WebKit/Source/core/workers/WorkerThread.cpp
@@ -51,7 +51,7 @@ namespace blink { -class WorkerMicrotaskRunner : public WebThread::TaskObserver { +class WorkerThread::WorkerMicrotaskRunner : public WebThread::TaskObserver { public: explicit WorkerMicrotaskRunner(WorkerThread* workerThread) : m_workerThread(workerThread) @@ -238,7 +238,23 @@ postInitialize(); } -void WorkerThread::performShutdownTask() +void WorkerThread::prepareForShutdown() +{ + DCHECK(isCurrentThread()); + { + MutexLocker lock(m_threadStateMutex); + if (m_readyToShutdown) + return; + m_readyToShutdown = true; + } + + workerReportingProxy().willDestroyWorkerGlobalScope(); + InspectorInstrumentation::allAsyncTasksCanceled(workerGlobalScope()); + workerGlobalScope()->dispose(); + workerBackingThread().backingThread().removeTaskObserver(m_microtaskRunner.get()); +} + +void WorkerThread::performShutdown() { DCHECK(isCurrentThread()); #if DCHECK_IS_ON @@ -329,7 +345,7 @@ m_inspectorTaskRunner->kill(); workerBackingThread().backingThread().postTask(BLINK_FROM_HERE, threadSafeBind(&WorkerThread::prepareForShutdown, AllowCrossThreadAccess(this))); - workerBackingThread().backingThread().postTask(BLINK_FROM_HERE, threadSafeBind(&WorkerThread::performShutdownTask, AllowCrossThreadAccess(this))); + workerBackingThread().backingThread().postTask(BLINK_FROM_HERE, threadSafeBind(&WorkerThread::performShutdown, AllowCrossThreadAccess(this))); } void WorkerThread::terminateAndWait() @@ -353,22 +369,6 @@ thread->m_shutdownEvent->wait(); } -void WorkerThread::prepareForShutdown() -{ - DCHECK(isCurrentThread()); - { - MutexLocker lock(m_threadStateMutex); - if (m_readyToShutdown) - return; - m_readyToShutdown = true; - } - - workerReportingProxy().willDestroyWorkerGlobalScope(); - InspectorInstrumentation::allAsyncTasksCanceled(workerGlobalScope()); - workerGlobalScope()->dispose(); - workerBackingThread().backingThread().removeTaskObserver(m_microtaskRunner.get()); -} - WorkerGlobalScope* WorkerThread::workerGlobalScope() { DCHECK(isCurrentThread());
diff --git a/third_party/WebKit/Source/core/workers/WorkerThread.h b/third_party/WebKit/Source/core/workers/WorkerThread.h index 696696c0..a8b118f2 100644 --- a/third_party/WebKit/Source/core/workers/WorkerThread.h +++ b/third_party/WebKit/Source/core/workers/WorkerThread.h
@@ -45,7 +45,6 @@ class WorkerBackingThread; class WorkerGlobalScope; class WorkerInspectorController; -class WorkerMicrotaskRunner; class WorkerReportingProxy; class WorkerThreadStartupData; @@ -75,9 +74,6 @@ void terminateAndWait(); static void terminateAndWaitForAllWorkers(); - // Called on the worker thread. Disposes |m_workerGlobalScope|. - void prepareForShutdown(); - virtual WorkerBackingThread& workerBackingThread() = 0; virtual bool shouldAttachThreadDebugger() const { return true; } v8::Isolate* isolate(); @@ -128,12 +124,15 @@ virtual void postInitialize() { } private: + class WorkerMicrotaskRunner; + std::unique_ptr<CrossThreadClosure> createWorkerThreadTask(std::unique_ptr<ExecutionContextTask>, bool isInstrumented); // Called on the worker thread. void initialize(PassOwnPtr<WorkerThreadStartupData>); void performTask(std::unique_ptr<ExecutionContextTask>, bool isInstrumented); - void performShutdownTask(); + void prepareForShutdown(); + void performShutdown(); void runDebuggerTask(std::unique_ptr<CrossThreadClosure>); void runDebuggerTaskDontWait(); @@ -145,7 +144,7 @@ bool m_shouldTerminateV8Execution = false; OwnPtr<InspectorTaskRunner> m_inspectorTaskRunner; - OwnPtr<WebThread::TaskObserver> m_microtaskRunner; + OwnPtr<WorkerMicrotaskRunner> m_microtaskRunner; RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; WorkerReportingProxy& m_workerReportingProxy;
diff --git a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp index eaab8343..b0112b2 100644 --- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp +++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -992,7 +992,7 @@ m_blobLoader = nullptr; } - m_decoder.clear(); + m_decoder.reset(); if (m_responseDocumentParser) { m_responseDocumentParser->removeClient(this);
diff --git a/third_party/WebKit/Source/devtools/front_end/common/Color.js b/third_party/WebKit/Source/devtools/front_end/common/Color.js index 5384226..f63df82 100644 --- a/third_party/WebKit/Source/devtools/front_end/common/Color.js +++ b/third_party/WebKit/Source/devtools/front_end/common/Color.js
@@ -62,6 +62,8 @@ Nickname: "nickname", HEX: "hex", ShortHEX: "shorthex", + HEXA: "hexa", + ShortHEXA: "shorthexa", RGB: "rgb", RGBA: "rgba", HSL: "hsl", @@ -76,7 +78,7 @@ { // Simple - #hex, rgb(), nickname, hsl() var value = text.toLowerCase().replace(/\s+/g, ""); - var simple = /^(?:#([0-9a-f]{3}|[0-9a-f]{6})|rgb\(((?:-?\d+%?,){2}-?\d+%?)\)|(\w+)|hsl\((-?\d+\.?\d*(?:,-?\d+\.?\d*%){2})\))$/i; + var simple = /^(?:#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgb\(((?:-?\d+%?,){2}-?\d+%?)\)|(\w+)|hsl\((-?\d+\.?\d*(?:,-?\d+\.?\d*%){2})\))$/i; var match = value.match(simple); if (match) { if (match[1]) { // hex @@ -85,12 +87,19 @@ if (hex.length === 3) { format = WebInspector.Color.Format.ShortHEX; hex = hex.charAt(0) + hex.charAt(0) + hex.charAt(1) + hex.charAt(1) + hex.charAt(2) + hex.charAt(2); - } else + } else if (hex.length === 4) { + format = WebInspector.Color.Format.ShortHEXA; + hex = hex.charAt(0) + hex.charAt(0) + hex.charAt(1) + hex.charAt(1) + hex.charAt(2) + hex.charAt(2) + hex.charAt(3) + hex.charAt(3); + } else if (hex.length === 6) { format = WebInspector.Color.Format.HEX; + } else { + format = WebInspector.Color.Format.HEXA; + } var r = parseInt(hex.substring(0,2), 16); var g = parseInt(hex.substring(2,4), 16); var b = parseInt(hex.substring(4,6), 16); - return new WebInspector.Color([r / 255, g / 255, b / 255, 1], format, text); + var a = hex.length === 8 ? parseInt(hex.substring(6, 8), 16) / 255 : 1; + return new WebInspector.Color([r / 255, g / 255, b / 255, a], format, text); } if (match[2]) { // rgb @@ -254,18 +263,21 @@ }, /** - * @return {boolean} + * @return {!WebInspector.Color.Format} */ - canBeShortHex: function() + detectHEXFormat: function() { - if (this.hasAlpha()) - return false; - for (var i = 0; i < 3; ++i) { + var canBeShort = true; + for (var i = 0; i < 4; ++i) { var c = Math.round(this._rgba[i] * 255); if (c % 17) - return false; + canBeShort = false; } - return true; + var hasAlpha = this.hasAlpha(); + var cf = WebInspector.Color.Format; + if (canBeShort) + return hasAlpha ? cf.ShortHEXA : cf.ShortHEX; + return hasAlpha ? cf.HEXA : cf.HEX; }, /** @@ -324,14 +336,21 @@ case WebInspector.Color.Format.HSLA: var hsla = this.hsla(); return String.sprintf("hsla(%d, %d%, %d%, %f)", Math.round(hsla[0] * 360), Math.round(hsla[1] * 100), Math.round(hsla[2] * 100), hsla[3]); + case WebInspector.Color.Format.HEXA: + return String.sprintf("#%s%s%s%s", toHexValue(this._rgba[0]), toHexValue(this._rgba[1]), toHexValue(this._rgba[2]), toHexValue(this._rgba[3])).toLowerCase(); case WebInspector.Color.Format.HEX: if (this.hasAlpha()) return null; - return String.sprintf("#%s%s%s", toHexValue(this._rgba[0]), toHexValue(this._rgba[1]), toHexValue(this._rgba[2])).toLowerCase();; - case WebInspector.Color.Format.ShortHEX: - if (!this.canBeShortHex()) + return String.sprintf("#%s%s%s", toHexValue(this._rgba[0]), toHexValue(this._rgba[1]), toHexValue(this._rgba[2])).toLowerCase(); + case WebInspector.Color.Format.ShortHEXA: + var hexFormat = this.detectHEXFormat(); + if (hexFormat !== WebInspector.Color.Format.ShortHEXA && hexFormat !== WebInspector.Color.Format.ShortHEX) return null; - return String.sprintf("#%s%s%s", toShortHexValue(this._rgba[0]), toShortHexValue(this._rgba[1]), toShortHexValue(this._rgba[2])).toLowerCase();; + return String.sprintf("#%s%s%s%s", toShortHexValue(this._rgba[0]), toShortHexValue(this._rgba[1]), toShortHexValue(this._rgba[2]), toShortHexValue(this._rgba[3])).toLowerCase(); + case WebInspector.Color.Format.ShortHEX: + if (this.detectHEXFormat() !== WebInspector.Color.Format.ShortHEX) + return null; + return String.sprintf("#%s%s%s", toShortHexValue(this._rgba[0]), toShortHexValue(this._rgba[1]), toShortHexValue(this._rgba[2])).toLowerCase(); case WebInspector.Color.Format.Nickname: return this.nickname(); } @@ -813,8 +832,8 @@ format = (color.hasAlpha() ? cf.RGBA : cf.RGB); else if (formatSetting === cf.HSL) format = (color.hasAlpha() ? cf.HSLA : cf.HSL); - else if (!color.hasAlpha()) - format = (color.canBeShortHex() ? cf.ShortHEX : cf.HEX); + else if (formatSetting === cf.HEX) + format = color.detectHEXFormat(); else format = cf.RGBA;
diff --git a/third_party/WebKit/Source/devtools/front_end/elements/Spectrum.js b/third_party/WebKit/Source/devtools/front_end/elements/Spectrum.js index 677bc77..ad2adce 100644 --- a/third_party/WebKit/Source/devtools/front_end/elements/Spectrum.js +++ b/third_party/WebKit/Source/devtools/front_end/elements/Spectrum.js
@@ -90,7 +90,7 @@ // HEX display. this._hexContainer = this.contentElement.createChild("div", "spectrum-text spectrum-text-hex source-code"); this._hexValue = this._hexContainer.createChild("input", "spectrum-text-value"); - this._hexValue.maxLength = 7; + this._hexValue.maxLength = 9; this._hexValue.addEventListener("keydown", this._inputChanged.bind(this), false); this._hexValue.addEventListener("input", this._inputChanged.bind(this), false); this._hexValue.addEventListener("mousewheel", this._inputChanged.bind(this), false); @@ -165,8 +165,8 @@ var hsva = this._hsv.slice(); hsva[3] = Number.constrain(newAlpha, 0, 1); var colorFormat = undefined; - if (hsva[3] !== 1 && (this._colorFormat === WebInspector.Color.Format.ShortHEX || this._colorFormat === WebInspector.Color.Format.HEX || this._colorFormat === WebInspector.Color.Format.Nickname)) - colorFormat = WebInspector.Color.Format.RGB; + if (hsva[3] !== 1 && this._colorFormat === WebInspector.Color.Format.Nickname) + colorFormat = WebInspector.Color.Format.HEX; this._innerSetColor(hsva, "", colorFormat, WebInspector.Spectrum._ChangeSource.Other); } @@ -584,11 +584,16 @@ if (colorString !== undefined) this._colorString = colorString; if (colorFormat !== undefined) { - console.assert(colorFormat !== WebInspector.Color.Format.Original, "Spectrum's color format cannot be Original"); - if (colorFormat === WebInspector.Color.Format.RGBA) - colorFormat = WebInspector.Color.Format.RGB; - else if (colorFormat === WebInspector.Color.Format.HSLA) - colorFormat = WebInspector.Color.Format.HSL; + var cf = WebInspector.Color.Format; + console.assert(colorFormat !== cf.Original, "Spectrum's color format cannot be Original"); + if (colorFormat === cf.RGBA) + colorFormat = cf.RGB; + else if (colorFormat === cf.HSLA) + colorFormat = cf.HSL; + else if (colorFormat === cf.HEXA) + colorFormat = cf.HEX; + else if (colorFormat === cf.ShortHEXA) + colorFormat = cf.ShortHEX; this._colorFormat = colorFormat; } @@ -631,14 +636,23 @@ if (colorString) return colorString; - if (this._colorFormat === cf.Nickname || this._colorFormat === cf.ShortHEX) { + if (this._colorFormat === cf.Nickname) { colorString = color.asString(cf.HEX); if (colorString) return colorString; } - console.assert(color.hasAlpha()); - return this._colorFormat === cf.HSL ? /** @type {string} */(color.asString(cf.HSLA)) : /** @type {string} */(color.asString(cf.RGBA)); + if (this._colorFormat === cf.ShortHEX) + colorString = color.asString(color.detectHEXFormat()); + else if (this._colorFormat === cf.HEX) + colorString = color.asString(color.hasAlpha() ? cf.HEXA : cf.HEX); + else if (this._colorFormat === cf.HSL) + colorString = color.asString(cf.HSLA); + else + colorString = color.asString(cf.RGBA); + + console.assert(colorString); + return colorString || ""; }, _updateHelperLocations: function() @@ -672,10 +686,11 @@ if (this._colorFormat === cf.HEX || this._colorFormat === cf.ShortHEX || this._colorFormat === cf.Nickname) { this._hexContainer.hidden = false; this._displayContainer.hidden = true; - if (this._colorFormat === cf.ShortHEX && this._color().canBeShortHex()) - this._hexValue.value = this._color().asString(cf.ShortHEX); + if (this._colorFormat === cf.ShortHEX) + this._hexValue.value = this._color().asString(this._color().detectHEXFormat()); else - this._hexValue.value = this._color().asString(cf.HEX); + // Don't use short HEX if original was not in that format. + this._hexValue.value = this._color().asString(this._color().hasAlpha() ? cf.HEXA : cf.HEX); } else { // RGBA, HSLA display. this._hexContainer.hidden = true; @@ -802,7 +817,7 @@ var format = cf.RGB; if (this._colorFormat === cf.RGB) format = cf.HSL; - else if (this._colorFormat === cf.HSL && !this._color().hasAlpha()) + else if (this._colorFormat === cf.HSL) format = this._originalFormat === cf.ShortHEX ? cf.ShortHEX : cf.HEX; this._innerSetColor(undefined, "", format, WebInspector.Spectrum._ChangeSource.Other); }, @@ -849,7 +864,7 @@ return; var hsv = color.hsva(); if (this._colorFormat === cf.HEX || this._colorFormat === cf.ShortHEX) - this._colorFormat = color.canBeShortHex() ? cf.ShortHEX : cf.HEX; + this._colorFormat = color.detectHEXFormat(); this._innerSetColor(hsv, colorString, undefined, WebInspector.Spectrum._ChangeSource.Input); },
diff --git a/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js b/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js index a61d5cb..71505a19 100644 --- a/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js +++ b/third_party/WebKit/Source/devtools/front_end/elements/StylesSidebarPane.js
@@ -3031,7 +3031,7 @@ } WebInspector.StylesSidebarPropertyRenderer._variableRegex = /(var\(--.*?\))/g; -WebInspector.StylesSidebarPropertyRenderer._colorRegex = /((?:rgb|hsl)a?\([^)]+\)|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}|\b\w+\b(?!-))/g; +WebInspector.StylesSidebarPropertyRenderer._colorRegex = /((?:rgb|hsl)a?\([^)]+\)|#[0-9a-fA-F]{8}|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3,4}|\b\w+\b(?!-))/g; WebInspector.StylesSidebarPropertyRenderer._bezierRegex = /((cubic-bezier\([^)]+\))|\b(linear|ease-in-out|ease-in|ease-out|ease)\b)/g; /**
diff --git a/third_party/WebKit/Source/devtools/front_end/resources/ServiceWorkersView.js b/third_party/WebKit/Source/devtools/front_end/resources/ServiceWorkersView.js index de5912c..2ff6091 100644 --- a/third_party/WebKit/Source/devtools/front_end/resources/ServiceWorkersView.js +++ b/third_party/WebKit/Source/devtools/front_end/resources/ServiceWorkersView.js
@@ -145,6 +145,9 @@ this._pushButton = new WebInspector.ToolbarButton(WebInspector.UIString("Emulate push event"), undefined, WebInspector.UIString("Push")); this._pushButton.addEventListener("click", this._pushButtonClicked.bind(this)); this._toolbar.appendToolbarItem(this._pushButton); + this._syncButton = new WebInspector.ToolbarButton(WebInspector.UIString("Emulate background sync event"), undefined, WebInspector.UIString("Sync")); + this._syncButton.addEventListener("click", this._syncButtonClicked.bind(this)); + this._toolbar.appendToolbarItem(this._syncButton); this._deleteButton = new WebInspector.ToolbarButton(WebInspector.UIString("Unregister service worker"), undefined, WebInspector.UIString("Unregister")); this._deleteButton.addEventListener("click", this._unregisterButtonClicked.bind(this)); this._toolbar.appendToolbarItem(this._deleteButton); @@ -297,10 +300,17 @@ _pushButtonClicked: function() { - var data = "Test push message from DevTools." + var data = "Test push message from DevTools."; this._manager.deliverPushMessage(this._registration.id, data); }, + _syncButtonClicked: function() + { + var tag = "test-tag-from-devtools"; + var lastChance = true; + this._manager.dispatchSyncEvent(this._registration.id, tag, lastChance); + }, + /** * @param {!Element} element * @param {?WebInspector.TargetInfo} targetInfo
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/ServiceWorkerManager.js b/third_party/WebKit/Source/devtools/front_end/sdk/ServiceWorkerManager.js index fc5d284..10dfcb62 100644 --- a/third_party/WebKit/Source/devtools/front_end/sdk/ServiceWorkerManager.js +++ b/third_party/WebKit/Source/devtools/front_end/sdk/ServiceWorkerManager.js
@@ -178,6 +178,20 @@ }, /** + * @param {string} registrationId + * @param {string} tag + * @param {boolean} lastChance + */ + dispatchSyncEvent: function(registrationId, tag, lastChance) + { + var registration = this._registrations.get(registrationId); + if (!registration) + return; + var origin = WebInspector.ParsedURL.extractOrigin(registration.scopeURL); + this._agent.dispatchSyncEvent(origin, registrationId, tag, lastChance); + }, + + /** * @param {!ServiceWorkerAgent.TargetID} targetId */ activateTarget: function(targetId)
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/ColorSwatch.js b/third_party/WebKit/Source/devtools/front_end/ui/ColorSwatch.js index a9a6bf22..96de2b96 100644 --- a/third_party/WebKit/Source/devtools/front_end/ui/ColorSwatch.js +++ b/third_party/WebKit/Source/devtools/front_end/ui/ColorSwatch.js
@@ -118,9 +118,8 @@ // * rgb(a) // * hsl(a) // * nickname (if the color has a nickname) - // * if the color is simple: - // - shorthex (if has short hex) - // - hex + // * shorthex (if has short hex) + // * hex var cf = WebInspector.Color.Format; switch (curFormat) { @@ -135,22 +134,20 @@ case cf.HSLA: if (color.nickname()) return cf.Nickname; - if (!color.hasAlpha()) - return color.canBeShortHex() ? cf.ShortHEX : cf.HEX; - else - return cf.Original; + return color.detectHEXFormat(); case cf.ShortHEX: return cf.HEX; + case cf.ShortHEXA: + return cf.HEXA; + + case cf.HEXA: case cf.HEX: return cf.Original; case cf.Nickname: - if (!color.hasAlpha()) - return color.canBeShortHex() ? cf.ShortHEX : cf.HEX; - else - return cf.Original; + return color.detectHEXFormat(); default: return cf.RGBA;
diff --git a/third_party/WebKit/Source/devtools/protocol.json b/third_party/WebKit/Source/devtools/protocol.json index 9b9e807..f8afcbad 100644 --- a/third_party/WebKit/Source/devtools/protocol.json +++ b/third_party/WebKit/Source/devtools/protocol.json
@@ -4352,6 +4352,16 @@ "handlers": ["browser"] }, { + "name": "dispatchSyncEvent", + "parameters": [ + { "name": "origin", "type": "string" }, + { "name": "registrationId", "type": "string" }, + { "name": "tag", "type": "string" }, + { "name": "lastChance", "type": "boolean" } + ], + "handlers": ["browser"] + }, + { "name": "getTargetInfo", "parameters": [ { "name": "targetId", "$ref": "TargetID" }
diff --git a/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp b/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp index 931af86f..811874b0 100644 --- a/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp +++ b/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp
@@ -33,7 +33,7 @@ return UnknownError; } - ASSERT_NOT_REACHED(); + NOTREACHED(); return UnknownError; } @@ -48,19 +48,19 @@ void ContentDecryptionModuleResultPromise::complete() { - ASSERT_NOT_REACHED(); + NOTREACHED(); reject(InvalidStateError, "Unexpected completion."); } void ContentDecryptionModuleResultPromise::completeWithContentDecryptionModule(WebContentDecryptionModule* cdm) { - ASSERT_NOT_REACHED(); + NOTREACHED(); reject(InvalidStateError, "Unexpected completion."); } void ContentDecryptionModuleResultPromise::completeWithSession(WebContentDecryptionModuleResult::SessionStatus status) { - ASSERT_NOT_REACHED(); + NOTREACHED(); reject(InvalidStateError, "Unexpected completion."); }
diff --git a/third_party/WebKit/Source/modules/encryptedmedia/EncryptedMediaUtils.cpp b/third_party/WebKit/Source/modules/encryptedmedia/EncryptedMediaUtils.cpp index 6a2a46d..f87963c 100644 --- a/third_party/WebKit/Source/modules/encryptedmedia/EncryptedMediaUtils.cpp +++ b/third_party/WebKit/Source/modules/encryptedmedia/EncryptedMediaUtils.cpp
@@ -41,7 +41,7 @@ return String(); } - ASSERT_NOT_REACHED(); + NOTREACHED(); return String(); } @@ -67,11 +67,11 @@ case WebEncryptedMediaSessionType::PersistentReleaseMessage: case WebEncryptedMediaSessionType::Unknown: // Chromium should not use Unknown. - ASSERT_NOT_REACHED(); + NOTREACHED(); return String(); } - ASSERT_NOT_REACHED(); + NOTREACHED(); return String(); }
diff --git a/third_party/WebKit/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp b/third_party/WebKit/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp index 809753e5..dc8dce23 100644 --- a/third_party/WebKit/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp +++ b/third_party/WebKit/Source/modules/encryptedmedia/HTMLMediaElementEncryptedMedia.cpp
@@ -21,6 +21,8 @@ #include "platform/Logging.h" #include "wtf/Functional.h" +#define EME_LOG_LEVEL 3 + namespace blink { // This class allows MediaKeys to be set asynchronously. @@ -73,13 +75,13 @@ void completeWithContentDecryptionModule(WebContentDecryptionModule*) override { - ASSERT_NOT_REACHED(); + NOTREACHED(); (*m_failureCallback)(InvalidStateError, "Unexpected completion."); } void completeWithSession(WebContentDecryptionModuleResult::SessionStatus status) override { - ASSERT_NOT_REACHED(); + NOTREACHED(); (*m_failureCallback)(InvalidStateError, "Unexpected completion."); } @@ -116,7 +118,7 @@ , m_madeReservation(false) , m_timer(this, &SetMediaKeysHandler::timerFired) { - WTF_LOG(Media, "SetMediaKeysHandler::SetMediaKeysHandler"); + DVLOG(EME_LOG_LEVEL) << __FUNCTION__; // 5. Run the following steps in parallel. m_timer.startOneShot(0, BLINK_FROM_HERE); @@ -133,7 +135,7 @@ void SetMediaKeysHandler::clearExistingMediaKeys() { - WTF_LOG(Media, "SetMediaKeysHandler::clearExistingMediaKeys"); + DVLOG(EME_LOG_LEVEL) << __FUNCTION__; HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(*m_element); // 5.1 If mediaKeys is not null, the CDM instance represented by @@ -182,7 +184,7 @@ void SetMediaKeysHandler::setNewMediaKeys() { - WTF_LOG(Media, "SetMediaKeysHandler::setNewMediaKeys"); + DVLOG(EME_LOG_LEVEL) << __FUNCTION__; // 5.3 If mediaKeys is not null, run the following steps: if (m_newMediaKeys) { @@ -210,7 +212,7 @@ void SetMediaKeysHandler::finish() { - WTF_LOG(Media, "SetMediaKeysHandler::finish"); + DVLOG(EME_LOG_LEVEL) << __FUNCTION__; HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(*m_element); // 5.4 Set the mediaKeys attribute to mediaKeys. @@ -242,7 +244,7 @@ void SetMediaKeysHandler::clearFailed(ExceptionCode code, const String& errorMessage) { - WTF_LOG(Media, "SetMediaKeysHandler::clearFailed (%d, %s)", code, errorMessage.ascii().data()); + DVLOG(EME_LOG_LEVEL) << __FUNCTION__ << "(" << code << ", " << errorMessage << ")"; HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(*m_element); // 5.2.4 If the preceding step failed, let this object's attaching media @@ -254,7 +256,7 @@ void SetMediaKeysHandler::setFailed(ExceptionCode code, const String& errorMessage) { - WTF_LOG(Media, "SetMediaKeysHandler::setFailed (%d, %s)", code, errorMessage.ascii().data()); + DVLOG(EME_LOG_LEVEL) << __FUNCTION__ << "(" << code << ", " << errorMessage << ")"; HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(*m_element); // 5.3.2 If the preceding step failed (in setContentDecryptionModule() @@ -286,7 +288,7 @@ HTMLMediaElementEncryptedMedia::~HTMLMediaElementEncryptedMedia() { - WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::~HTMLMediaElementEncryptedMedia"); + DVLOG(EME_LOG_LEVEL) << __FUNCTION__; } const char* HTMLMediaElementEncryptedMedia::supplementName() @@ -313,7 +315,7 @@ ScriptPromise HTMLMediaElementEncryptedMedia::setMediaKeys(ScriptState* scriptState, HTMLMediaElement& element, MediaKeys* mediaKeys) { HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia::from(element); - WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::setMediaKeys current(%p), new(%p)", thisElement.m_mediaKeys.get(), mediaKeys); + DVLOG(EME_LOG_LEVEL) << __FUNCTION__ << " current(" << thisElement.m_mediaKeys.get() << "), new(" << mediaKeys << ")"; // From http://w3c.github.io/encrypted-media/#setMediaKeys @@ -350,7 +352,7 @@ void HTMLMediaElementEncryptedMedia::encrypted(WebEncryptedMediaInitDataType initDataType, const unsigned char* initData, unsigned initDataLength) { - WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::encrypted"); + DVLOG(EME_LOG_LEVEL) << __FUNCTION__; Event* event; if (m_mediaElement->isMediaDataCORSSameOrigin(m_mediaElement->getExecutionContext()->getSecurityOrigin())) { @@ -367,7 +369,7 @@ void HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey() { - WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey"); + DVLOG(EME_LOG_LEVEL) << __FUNCTION__; // From https://w3c.github.io/encrypted-media/#queue-waitingforkey: // It should only be called when the HTMLMediaElement object is potentially @@ -392,7 +394,7 @@ void HTMLMediaElementEncryptedMedia::didResumePlaybackBlockedForKey() { - WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::didResumePlaybackBlockedForKey"); + DVLOG(EME_LOG_LEVEL) << __FUNCTION__; // Logic is on the Chromium side to attempt to resume playback when a new // key is available. However, |m_isWaitingForKey| needs to be cleared so
diff --git a/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp b/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp index 54b7d8c9..fb3d232 100644 --- a/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp +++ b/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp
@@ -53,6 +53,8 @@ #include <cmath> #include <limits> +#define MEDIA_KEY_SESSION_LOG_LEVEL 3 + namespace { // Minimum and maximum length for session ids. @@ -102,7 +104,7 @@ return "internal-error"; } - ASSERT_NOT_REACHED(); + NOTREACHED(); return "internal-error"; } @@ -138,51 +140,51 @@ DOMArrayBuffer* data() const { - ASSERT(m_type == GenerateRequest || m_type == Update); + DCHECK(m_type == GenerateRequest || m_type == Update); return m_data; } WebEncryptedMediaInitDataType initDataType() const { - ASSERT(m_type == GenerateRequest); + DCHECK_EQ(GenerateRequest, m_type); return m_initDataType; } const String& sessionId() const { - ASSERT(m_type == Load); + DCHECK_EQ(Load, m_type); return m_stringData; } static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleResult* result, WebEncryptedMediaInitDataType initDataType, DOMArrayBuffer* initData) { - ASSERT(result); - ASSERT(initData); + DCHECK(result); + DCHECK(initData); return new PendingAction(GenerateRequest, result, initDataType, initData, String()); } static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult* result, const String& sessionId) { - ASSERT(result); + DCHECK(result); return new PendingAction(Load, result, WebEncryptedMediaInitDataType::Unknown, nullptr, sessionId); } static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* result, DOMArrayBuffer* data) { - ASSERT(result); - ASSERT(data); + DCHECK(result); + DCHECK(data); return new PendingAction(Update, result, WebEncryptedMediaInitDataType::Unknown, data, String()); } static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* result) { - ASSERT(result); + DCHECK(result); return new PendingAction(Close, result, WebEncryptedMediaInitDataType::Unknown, nullptr, String()); } static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* result) { - ASSERT(result); + DCHECK(result); return new PendingAction(Remove, result, WebEncryptedMediaInitDataType::Unknown, nullptr, String()); } @@ -234,7 +236,7 @@ void completeWithSession(WebContentDecryptionModuleResult::SessionStatus status) override { if (status != WebContentDecryptionModuleResult::NewSession) { - ASSERT_NOT_REACHED(); + NOTREACHED(); reject(InvalidStateError, "Unexpected completion."); } @@ -283,12 +285,12 @@ return; case WebContentDecryptionModuleResult::SessionAlreadyExists: - ASSERT_NOT_REACHED(); + NOTREACHED(); reject(InvalidStateError, "Unexpected completion."); return; } - ASSERT_NOT_REACHED(); + NOTREACHED(); } DEFINE_INLINE_TRACE() @@ -322,7 +324,7 @@ , m_closedPromise(new ClosedPromise(scriptState->getExecutionContext(), this, ClosedPromise::Closed)) , m_actionTimer(this, &MediaKeySession::actionTimerFired) { - WTF_LOG(Media, "MediaKeySession(%p)::MediaKeySession", this); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")"; ThreadState::current()->registerPreFinalizer(this); // Create the matching Chromium object. It will not be usable until @@ -335,25 +337,25 @@ // From https://w3c.github.io/encrypted-media/#createSession: // MediaKeys::createSession(), step 3. // 3.1 Let the sessionId attribute be the empty string. - ASSERT(sessionId().isEmpty()); + DCHECK(sessionId().isEmpty()); // 3.2 Let the expiration attribute be NaN. - ASSERT(std::isnan(m_expiration)); + DCHECK(std::isnan(m_expiration)); // 3.3 Let the closed attribute be a new promise. - ASSERT(!closed(scriptState).isUndefinedOrNull()); + DCHECK(!closed(scriptState).isUndefinedOrNull()); // 3.4 Let the keyStatuses attribute be empty. - ASSERT(m_keyStatusesMap->size() == 0); + DCHECK_EQ(0u, m_keyStatusesMap->size()); // 3.5 Let the session type be sessionType. - ASSERT(m_sessionType != WebEncryptedMediaSessionType::Unknown); + DCHECK(m_sessionType != WebEncryptedMediaSessionType::Unknown); // 3.6 Let uninitialized be true. - ASSERT(m_isUninitialized); + DCHECK(m_isUninitialized); // 3.7 Let callable be false. - ASSERT(!m_isCallable); + DCHECK(!m_isCallable); // 3.8 Let the use distinctive identifier value be this object's // use distinctive identifier. @@ -365,7 +367,7 @@ MediaKeySession::~MediaKeySession() { - WTF_LOG(Media, "MediaKeySession(%p)::~MediaKeySession", this); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")"; } void MediaKeySession::dispose() @@ -392,7 +394,7 @@ ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const String& initDataTypeString, const DOMArrayPiece& initData) { - WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataTypeString.ascii().data()); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") " << initDataTypeString; // From https://w3c.github.io/encrypted-media/#generateRequest: // Generates a request based on the initData. When this method is invoked, @@ -447,7 +449,7 @@ // 9. Run the following steps asynchronously (documented in // actionTimerFired()) m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result, initDataType, initDataBuffer)); - ASSERT(!m_actionTimer.isActive()); + DCHECK(!m_actionTimer.isActive()); m_actionTimer.startOneShot(0, BLINK_FROM_HERE); // 10. Return promise. @@ -456,7 +458,7 @@ ScriptPromise MediaKeySession::load(ScriptState* scriptState, const String& sessionId) { - WTF_LOG(Media, "MediaKeySession(%p)::load %s", this, sessionId.ascii().data()); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") " << sessionId; // From https://w3c.github.io/encrypted-media/#load: // Loads the data stored for the specified session into this object. When @@ -501,7 +503,7 @@ // 8. Run the following steps asynchronously (documented in // actionTimerFired()) m_pendingActions.append(PendingAction::CreatePendingLoadRequest(result, sessionId)); - ASSERT(!m_actionTimer.isActive()); + DCHECK(!m_actionTimer.isActive()); m_actionTimer.startOneShot(0, BLINK_FROM_HERE); // 9. Return promise. @@ -510,8 +512,8 @@ ScriptPromise MediaKeySession::update(ScriptState* scriptState, const DOMArrayPiece& response) { - WTF_LOG(Media, "MediaKeySession(%p)::update", this); - ASSERT(!m_isClosed); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")"; + DCHECK(!m_isClosed); // From https://w3c.github.io/encrypted-media/#update: // Provides messages, including licenses, to the CDM. When this method is @@ -548,7 +550,7 @@ ScriptPromise MediaKeySession::close(ScriptState* scriptState) { - WTF_LOG(Media, "MediaKeySession(%p)::close", this); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")"; // From https://w3c.github.io/encrypted-media/#close: // Indicates that the application no longer needs the session and the CDM @@ -581,7 +583,7 @@ ScriptPromise MediaKeySession::remove(ScriptState* scriptState) { - WTF_LOG(Media, "MediaKeySession(%p)::remove", this); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")"; // From https://w3c.github.io/encrypted-media/#remove: // Removes stored session data associated with this object. When this @@ -624,7 +626,7 @@ void MediaKeySession::actionTimerFired(Timer<MediaKeySession>*) { - ASSERT(m_pendingActions.size()); + DCHECK(m_pendingActions.size()); // Resolving promises now run synchronously and may result in additional // actions getting added to the queue. As a result, swap the queue to @@ -638,7 +640,7 @@ switch (action->getType()) { case PendingAction::GenerateRequest: // NOTE: Continue step 9 of MediaKeySession::generateRequest(). - WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: GenerateRequest", this); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") GenerateRequest"; // initializeNewSession() in Chromium will execute steps 9.1 to 9.7. m_session->initializeNewSession(action->initDataType(), static_cast<unsigned char*>(action->data()->data()), action->data()->byteLength(), m_sessionType, action->result()->result()); @@ -649,7 +651,7 @@ case PendingAction::Load: // NOTE: Continue step 8 of MediaKeySession::load(). - WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Load", this); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") Load"; // 8.1 Let sanitized session ID be a validated and/or sanitized // version of sessionId. The user agent should thoroughly @@ -673,7 +675,7 @@ // 8.4 Let expiration time be NaN. // (Done in the constructor.) - ASSERT(std::isnan(m_expiration)); + DCHECK(std::isnan(m_expiration)); // load() in Chromium will execute steps 8.5 through 8.8. m_session->load(action->sessionId(), action->result()->result()); @@ -684,7 +686,7 @@ case PendingAction::Update: // NOTE: Continue step 5 of MediaKeySession::update(). - WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Update", this); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") Update"; // update() in Chromium will execute steps 5.1 through 5.8. m_session->update(static_cast<unsigned char*>(action->data()->data()), action->data()->byteLength(), action->result()->result()); @@ -695,7 +697,7 @@ case PendingAction::Close: // NOTE: Continue step 4 of MediaKeySession::close(). - WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Close", this); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") Close"; // close() in Chromium will execute steps 4.1 through 4.2. m_session->close(action->result()->result()); @@ -706,7 +708,7 @@ case PendingAction::Remove: // NOTE: Continue step 5 of MediaKeySession::remove(). - WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Remove", this); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") Remove"; // remove() in Chromium will execute steps 5.1 through 5.3. m_session->remove(action->result()->result()); @@ -725,7 +727,7 @@ // (Done by CDM calling result.completeWithError() as appropriate.) // 9.9 Set the sessionId attribute to session id. - ASSERT(!sessionId().isEmpty()); + DCHECK(!sessionId().isEmpty()); // 9.10 Let this object's callable be true. m_isCallable = true; @@ -745,7 +747,7 @@ // (Done by CDM calling result.completeWithError() as appropriate.) // 8.10 Set the sessionId attribute to sanitized session ID. - ASSERT(!sessionId().isEmpty()); + DCHECK(!sessionId().isEmpty()); // 8.11 Let this object's callable be true. m_isCallable = true; @@ -776,10 +778,10 @@ // Queue a task to fire a simple event named keymessage at the new object. void MediaKeySession::message(MessageType messageType, const unsigned char* message, size_t messageLength) { - WTF_LOG(Media, "MediaKeySession(%p)::message", this); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")"; // Verify that 'message' not fired before session initialization is complete. - ASSERT(m_isCallable); + DCHECK(m_isCallable); // From https://w3c.github.io/encrypted-media/#queue-message: // The following steps are run: @@ -810,7 +812,7 @@ void MediaKeySession::close() { - WTF_LOG(Media, "MediaKeySession(%p)::close", this); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")"; // From https://w3c.github.io/encrypted-media/#session-close: // The following steps are run: @@ -826,7 +828,7 @@ void MediaKeySession::expirationChanged(double updatedExpiryTimeInMS) { - WTF_LOG(Media, "MediaKeySession(%p)::expirationChanged %f", this, updatedExpiryTimeInMS); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") " << updatedExpiryTimeInMS; // From https://w3c.github.io/encrypted-media/#update-expiration: // The following steps are run: @@ -847,7 +849,7 @@ void MediaKeySession::keysStatusesChange(const WebVector<WebEncryptedMediaKeyInformation>& keys, bool hasAdditionalUsableKey) { - WTF_LOG(Media, "MediaKeySession(%p)::keysStatusesChange with %zu keys and hasAdditionalUsableKey is %s", this, keys.size(), hasAdditionalUsableKey ? "true" : "false"); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") with " << keys.size() << " keys and hasAdditionalUsableKey is " << (hasAdditionalUsableKey ? "true" : "false"); // From https://w3c.github.io/encrypted-media/#update-key-statuses: // The following steps are run: @@ -897,10 +899,10 @@ { // Remain around if there are pending events or MediaKeys is still around // and we're not closed. - WTF_LOG(Media, "MediaKeySession(%p)::hasPendingActivity %s%s%s", this, - !m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "", - m_asyncEventQueue->hasPendingEvents() ? " m_asyncEventQueue->hasPendingEvents()" : "", - (m_mediaKeys && !m_isClosed) ? " m_mediaKeys && !m_isClosed" : ""); + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")" + << (!m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "") + << (m_asyncEventQueue->hasPendingEvents() ? " m_asyncEventQueue->hasPendingEvents()" : "") + << ((m_mediaKeys && !m_isClosed) ? " m_mediaKeys && !m_isClosed" : ""); return !m_pendingActions.isEmpty() || m_asyncEventQueue->hasPendingEvents()
diff --git a/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySystemAccess.cpp b/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySystemAccess.cpp index 5aa37b8..9485c91 100644 --- a/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySystemAccess.cpp +++ b/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySystemAccess.cpp
@@ -91,7 +91,7 @@ return "not-allowed"; } - ASSERT_NOT_REACHED(); + NOTREACHED(); return "not-allowed"; }
diff --git a/third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.cpp b/third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.cpp index 66afd1f2..aefb7f2 100644 --- a/third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.cpp +++ b/third_party/WebKit/Source/modules/encryptedmedia/MediaKeys.cpp
@@ -39,6 +39,8 @@ #include "public/platform/WebContentDecryptionModule.h" #include "wtf/RefPtr.h" +#define MEDIA_KEYS_LOG_LEVEL 3 + namespace blink { // A class holding a pending action. @@ -56,8 +58,8 @@ static PendingAction* CreatePendingSetServerCertificate(ContentDecryptionModuleResult* result, DOMArrayBuffer* serverCertificate) { - ASSERT(result); - ASSERT(serverCertificate); + DCHECK(result); + DCHECK(serverCertificate); return new PendingAction(result, serverCertificate); } @@ -94,17 +96,17 @@ , m_reservedForMediaElement(false) , m_timer(this, &MediaKeys::timerFired) { - WTF_LOG(Media, "MediaKeys(%p)::MediaKeys", this); + DVLOG(MEDIA_KEYS_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")"; } MediaKeys::~MediaKeys() { - WTF_LOG(Media, "MediaKeys(%p)::~MediaKeys", this); + DVLOG(MEDIA_KEYS_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")"; } MediaKeySession* MediaKeys::createSession(ScriptState* scriptState, const String& sessionTypeString, ExceptionState& exceptionState) { - WTF_LOG(Media, "MediaKeys(%p)::createSession %s", this, sessionTypeString.utf8().data()); + DVLOG(MEDIA_KEYS_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") " << sessionTypeString; // From http://w3c.github.io/encrypted-media/#createSession @@ -189,7 +191,7 @@ void MediaKeys::clearMediaElement() { - ASSERT(m_mediaElement); + DCHECK(m_mediaElement); m_mediaElement.clear(); } @@ -205,7 +207,7 @@ void MediaKeys::timerFired(Timer<MediaKeys>*) { - ASSERT(m_pendingActions.size()); + DCHECK(m_pendingActions.size()); // Swap the queue to a local copy to avoid problems if resolving promises // run synchronously. @@ -214,7 +216,7 @@ while (!pendingActions.isEmpty()) { PendingAction* action = pendingActions.takeFirst(); - WTF_LOG(Media, "MediaKeys(%p)::timerFired: Certificate", this); + DVLOG(MEDIA_KEYS_LOG_LEVEL) << __FUNCTION__ << "(" << this << ") Certificate"; // 5.1 Let cdm be the cdm during the initialization of this object. WebContentDecryptionModule* cdm = contentDecryptionModule(); @@ -252,9 +254,9 @@ bool MediaKeys::hasPendingActivity() const { // Remain around if there are pending events. - WTF_LOG(Media, "MediaKeys(%p)::hasPendingActivity %s%s", this, - !m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "", - m_reservedForMediaElement ? " m_reservedForMediaElement" : ""); + DVLOG(MEDIA_KEYS_LOG_LEVEL) << __FUNCTION__ << "(" << this << ")" + << (!m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "") + << (m_reservedForMediaElement ? " m_reservedForMediaElement" : ""); return !m_pendingActions.isEmpty() || m_reservedForMediaElement; }
diff --git a/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp b/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp index 7f69eda..dd0af18 100644 --- a/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp +++ b/third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp
@@ -67,7 +67,7 @@ return WebMediaKeySystemConfiguration::Requirement::NotAllowed; // Everything else gets the default value. - ASSERT_NOT_REACHED(); + NOTREACHED(); return WebMediaKeySystemConfiguration::Requirement::Optional; } @@ -147,9 +147,9 @@ webConfig.hasVideoCapabilities = true; webConfig.videoCapabilities = convertCapabilities(config.videoCapabilities()); } - ASSERT(config.hasDistinctiveIdentifier()); + DCHECK(config.hasDistinctiveIdentifier()); webConfig.distinctiveIdentifier = convertMediaKeysRequirement(config.distinctiveIdentifier()); - ASSERT(config.hasPersistentState()); + DCHECK(config.hasPersistentState()); webConfig.persistentState = convertMediaKeysRequirement(config.persistentState()); if (config.hasSessionTypes()) { webConfig.hasSessionTypes = true; @@ -250,7 +250,7 @@ const String& keySystem, const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) { - WTF_LOG(Media, "NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess()"); + DVLOG(3) << __FUNCTION__; // From https://w3c.github.io/encrypted-media/#requestMediaKeySystemAccess // When this method is invoked, the user agent must run the following steps:
diff --git a/third_party/WebKit/Source/modules/filesystem/SyncCallbackHelper.h b/third_party/WebKit/Source/modules/filesystem/SyncCallbackHelper.h index ad42a1c..534242f 100644 --- a/third_party/WebKit/Source/modules/filesystem/SyncCallbackHelper.h +++ b/third_party/WebKit/Source/modules/filesystem/SyncCallbackHelper.h
@@ -47,34 +47,18 @@ namespace blink { -template <typename ResultType, typename CallbackArg> -struct HelperResultType { - DISALLOW_NEW(); -public: - typedef ResultType* ReturnType; - typedef Member<ResultType> StorageType; - - static ReturnType createFromCallbackArg(CallbackArg argument) - { - return ResultType::create(argument); - } -}; - // A helper template for FileSystemSync implementation. template <typename SuccessCallback, typename CallbackArg, typename ResultType> class SyncCallbackHelper final : public GarbageCollected<SyncCallbackHelper<SuccessCallback, CallbackArg, ResultType>> { public: typedef SyncCallbackHelper<SuccessCallback, CallbackArg, ResultType> HelperType; - typedef HelperResultType<ResultType, CallbackArg> ResultTypeTrait; - typedef typename ResultTypeTrait::StorageType ResultStorageType; - typedef typename ResultTypeTrait::ReturnType ResultReturnType; static HelperType* create() { return new SyncCallbackHelper(); } - ResultReturnType getResult(ExceptionState& exceptionState) + ResultType* getResult(ExceptionState& exceptionState) { if (m_errorCode) FileError::throwDOMException(exceptionState, m_errorCode); @@ -163,11 +147,11 @@ void setResult(CallbackArg result) { - m_result = ResultTypeTrait::createFromCallbackArg(result); + m_result = ResultType::create(result); m_completed = true; } - ResultStorageType m_result; + Member<ResultType> m_result; FileError::ErrorCode m_errorCode; bool m_completed; };
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp index ffa6932..7f79b25 100644 --- a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp +++ b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
@@ -28,7 +28,7 @@ // TODO(mlamouri): refactor in one common place. WebPresentationClient* presentationClient(ExecutionContext* executionContext) { - ASSERT(executionContext && executionContext->isDocument()); + DCHECK(executionContext); Document* document = toDocument(executionContext); if (!document->frame()) @@ -39,7 +39,7 @@ Settings* settings(ExecutionContext* executionContext) { - ASSERT(executionContext && executionContext->isDocument()); + DCHECK(executionContext); Document* document = toDocument(executionContext); return document->settings(); @@ -101,13 +101,17 @@ return promise; } + if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) { + resolver->reject(DOMException::create(SecurityError, "The document is sandboxed and lacks the 'allow-presentation' flag.")); + return promise; + } + WebPresentationClient* client = presentationClient(getExecutionContext()); if (!client) { resolver->reject(DOMException::create(InvalidStateError, "The PresentationRequest is no longer associated to a frame.")); return promise; } client->startSession(m_url.getString(), new PresentationConnectionCallbacks(resolver, this)); - return promise; } @@ -116,13 +120,17 @@ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); + if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) { + resolver->reject(DOMException::create(SecurityError, "The document is sandboxed and lacks the 'allow-presentation' flag.")); + return promise; + } + WebPresentationClient* client = presentationClient(getExecutionContext()); if (!client) { resolver->reject(DOMException::create(InvalidStateError, "The PresentationRequest is no longer associated to a frame.")); return promise; } client->joinSession(m_url.getString(), id, new PresentationConnectionCallbacks(resolver, this)); - return promise; } @@ -131,6 +139,11 @@ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); + if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) { + resolver->reject(DOMException::create(SecurityError, "The document is sandboxed and lacks the 'allow-presentation' flag.")); + return promise; + } + WebPresentationClient* client = presentationClient(getExecutionContext()); if (!client) { resolver->reject(DOMException::create(InvalidStateError, "The object is no longer associated to a frame."));
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp index a7cfc38..67204a9 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
@@ -1715,7 +1715,7 @@ return contextGL()->IsQueryEXT(query->object()); } -void WebGL2RenderingContextBase::beginQuery(GLenum target, WebGLQuery* query) +void WebGL2RenderingContextBase::beginQuery(ScriptState* scriptState, GLenum target, WebGLQuery* query) { bool deleted; if (!query) { @@ -1764,6 +1764,7 @@ query->setTarget(target); contextGL()->BeginQueryEXT(target, query->object()); + preserveObjectWrapper(scriptState, this, V8HiddenValue::webglQueries(scriptState->isolate()), &m_queryWrappers, static_cast<uint32_t>(target), query); } void WebGL2RenderingContextBase::endQuery(GLenum target) @@ -1901,7 +1902,7 @@ return contextGL()->IsSampler(sampler->object()); } -void WebGL2RenderingContextBase::bindSampler(GLuint unit, WebGLSampler* sampler) +void WebGL2RenderingContextBase::bindSampler(ScriptState* scriptState, GLuint unit, WebGLSampler* sampler) { if (isContextLost()) return; @@ -1922,6 +1923,8 @@ m_samplerUnits[unit] = sampler; contextGL()->BindSampler(unit, objectOrZero(sampler)); + + preserveObjectWrapper(scriptState, this, V8HiddenValue::webglSamplers(scriptState->isolate()), &m_samplerWrappers, static_cast<uint32_t>(unit), sampler); } void WebGL2RenderingContextBase::samplerParameter(WebGLSampler* sampler, GLenum pname, GLfloat paramf, GLint parami, bool isFloat) @@ -2155,7 +2158,7 @@ return contextGL()->IsTransformFeedback(feedback->object()); } -void WebGL2RenderingContextBase::bindTransformFeedback(GLenum target, WebGLTransformFeedback* feedback) +void WebGL2RenderingContextBase::bindTransformFeedback(ScriptState* scriptState, GLenum target, WebGLTransformFeedback* feedback) { bool deleted; if (!checkObjectToBeBound("bindTransformFeedback", feedback, deleted)) @@ -2178,8 +2181,11 @@ m_transformFeedbackBinding = feedback; contextGL()->BindTransformFeedback(target, objectOrZero(feedback)); - if (feedback) + if (feedback) { feedback->setTarget(target); + preserveObjectWrapper(scriptState, this, V8HiddenValue::webglMisc(scriptState->isolate()), &m_miscWrappers, static_cast<uint32_t>(PreservedTransformFeedback), feedback); + } + } void WebGL2RenderingContextBase::beginTransformFeedback(GLenum primitiveMode)
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h index e688ca6..05f3499 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h +++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h
@@ -146,7 +146,7 @@ WebGLQuery* createQuery(); void deleteQuery(WebGLQuery*); GLboolean isQuery(WebGLQuery*); - void beginQuery(GLenum, WebGLQuery*); + void beginQuery(ScriptState*, GLenum, WebGLQuery*); void endQuery(GLenum); WebGLQuery* getQuery(GLenum, GLenum); ScriptValue getQueryParameter(ScriptState*, WebGLQuery*, GLenum); @@ -155,7 +155,7 @@ WebGLSampler* createSampler(); void deleteSampler(WebGLSampler*); GLboolean isSampler(WebGLSampler*); - void bindSampler(GLuint, WebGLSampler*); + void bindSampler(ScriptState*, GLuint, WebGLSampler*); void samplerParameteri(WebGLSampler*, GLenum, GLint); void samplerParameterf(WebGLSampler*, GLenum, GLfloat); ScriptValue getSamplerParameter(ScriptState*, WebGLSampler*, GLenum); @@ -173,7 +173,7 @@ WebGLTransformFeedback* createTransformFeedback(); void deleteTransformFeedback(WebGLTransformFeedback*); GLboolean isTransformFeedback(WebGLTransformFeedback*); - void bindTransformFeedback(GLenum, WebGLTransformFeedback*); + void bindTransformFeedback(ScriptState*, GLenum, WebGLTransformFeedback*); void beginTransformFeedback(GLenum); void endTransformFeedback(); void transformFeedbackVaryings(WebGLProgram*, const Vector<String>&, GLenum); @@ -311,6 +311,9 @@ GLint m_unpackSkipPixels; GLint m_unpackSkipRows; GLint m_unpackSkipImages; + + ScopedPersistent<v8::Array> m_samplerWrappers; + ScopedPersistent<v8::Array> m_queryWrappers; }; DEFINE_TYPE_CASTS(WebGL2RenderingContextBase, CanvasRenderingContext, context,
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.idl b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.idl index 555607e..6bddcfb 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.idl +++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.idl
@@ -391,7 +391,7 @@ WebGLQuery createQuery(); void deleteQuery(WebGLQuery? query); GLboolean isQuery(WebGLQuery? query); - void beginQuery(GLenum target, WebGLQuery? query); + [CallWith=ScriptState] void beginQuery(GLenum target, WebGLQuery? query); void endQuery(GLenum target); WebGLQuery getQuery(GLenum target, GLenum pname); [CallWith=ScriptState] any getQueryParameter(WebGLQuery? query, GLenum pname); @@ -400,7 +400,7 @@ WebGLSampler createSampler(); void deleteSampler(WebGLSampler? sampler); GLboolean isSampler(WebGLSampler? sampler); - void bindSampler(GLuint unit, WebGLSampler? sampler); + [CallWith=ScriptState] void bindSampler(GLuint unit, WebGLSampler? sampler); void samplerParameteri(WebGLSampler? sampler, GLenum pname, GLint param); void samplerParameterf(WebGLSampler? sampler, GLenum pname, GLfloat param); [CallWith=ScriptState] any getSamplerParameter(WebGLSampler? sampler, GLenum pname); @@ -418,7 +418,7 @@ WebGLTransformFeedback createTransformFeedback(); void deleteTransformFeedback(WebGLTransformFeedback? feedback); GLboolean isTransformFeedback(WebGLTransformFeedback? feedback); - void bindTransformFeedback (GLenum target, WebGLTransformFeedback? feedback); + [CallWith=ScriptState] void bindTransformFeedback (GLenum target, WebGLTransformFeedback? feedback); void beginTransformFeedback(GLenum primitiveMode); void endTransformFeedback(); void transformFeedbackVaryings(WebGLProgram? program, sequence<DOMString> varyings, GLenum bufferMode);
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp index b3639aae..377dc58 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp
@@ -29,7 +29,6 @@ #include "bindings/modules/v8/RenderingContext.h" #include "core/frame/LocalFrame.h" #include "core/frame/Settings.h" -#include "core/layout/LayoutBox.h" #include "core/loader/FrameLoader.h" #include "core/loader/FrameLoaderClient.h" #include "gpu/command_buffer/client/gles2_interface.h"
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h index 1025c79..92ca41e 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
@@ -1057,6 +1057,7 @@ PreservedRenderbuffer, PreservedDefaultVAO, PreservedVAO, + PreservedTransformFeedback, }; ScopedPersistent<v8::Array> m_miscWrappers;
diff --git a/third_party/WebKit/Source/platform/Histogram.cpp b/third_party/WebKit/Source/platform/Histogram.cpp index 517cc29..cdda2dca 100644 --- a/third_party/WebKit/Source/platform/Histogram.cpp +++ b/third_party/WebKit/Source/platform/Histogram.cpp
@@ -24,6 +24,11 @@ m_histogram->Add(sample); } +BooleanHistogram::BooleanHistogram(const char* name) + : CustomCountHistogram(base::BooleanHistogram::FactoryGet(name, base::HistogramBase::kUmaTargetedHistogramFlag)) +{ +} + EnumerationHistogram::EnumerationHistogram(const char* name, base::HistogramBase::Sample boundaryValue) : CustomCountHistogram(base::LinearHistogram::FactoryGet(name, 1, boundaryValue, boundaryValue + 1, base::HistogramBase::kUmaTargetedHistogramFlag)) {
diff --git a/third_party/WebKit/Source/platform/Histogram.h b/third_party/WebKit/Source/platform/Histogram.h index 73ed721..8885b9fce 100644 --- a/third_party/WebKit/Source/platform/Histogram.h +++ b/third_party/WebKit/Source/platform/Histogram.h
@@ -27,6 +27,11 @@ base::HistogramBase* m_histogram; }; +class PLATFORM_EXPORT BooleanHistogram : public CustomCountHistogram { +public: + BooleanHistogram(const char* name); +}; + class PLATFORM_EXPORT EnumerationHistogram : public CustomCountHistogram { public: EnumerationHistogram(const char* name, base::HistogramBase::Sample boundaryValue);
diff --git a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in index 3d088986..c0283769 100644 --- a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in +++ b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
@@ -214,7 +214,7 @@ TrustedEventsDefaultAction UnsafeES3APIs UnsandboxedAuxiliary status=stable -UserSelectAll status=experimental +UserSelectAll status=stable WebAnimationsAPI status=experimental WebAnimationsSVG status=experimental WebBluetooth
diff --git a/third_party/WebKit/Source/platform/WebThreadSupportingGC.cpp b/third_party/WebKit/Source/platform/WebThreadSupportingGC.cpp index a0d4ad3..6c7f2cdc 100644 --- a/third_party/WebKit/Source/platform/WebThreadSupportingGC.cpp +++ b/third_party/WebKit/Source/platform/WebThreadSupportingGC.cpp
@@ -42,7 +42,7 @@ if (ThreadState::current() && m_owningThread) { // WebThread's destructor blocks until all the tasks are processed. SafePointScope scope(BlinkGC::HeapPointersOnStack); - m_owningThread.clear(); + m_owningThread.reset(); } } @@ -58,7 +58,7 @@ ThreadState::current()->releaseStaticPersistentNodes(); #endif // Ensure no posted tasks will run from this point on. - m_gcTaskRunner.clear(); + m_gcTaskRunner.reset(); // Shutdown the thread (via its scheduler) only when the thread is created // and is owned by this instance.
diff --git a/third_party/WebKit/Source/platform/animation/CompositorAnimation.cpp b/third_party/WebKit/Source/platform/animation/CompositorAnimation.cpp index fb96aef..7d07a5b 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorAnimation.cpp +++ b/third_party/WebKit/Source/platform/animation/CompositorAnimation.cpp
@@ -20,38 +20,14 @@ namespace blink { -CompositorAnimation::CompositorAnimation(const CompositorAnimationCurve& webCurve, CompositorTargetProperty::Type targetProperty, int animationId, int groupId) +CompositorAnimation::CompositorAnimation(const CompositorAnimationCurve& curve, CompositorTargetProperty::Type targetProperty, int animationId, int groupId) { if (!animationId) animationId = AnimationIdProvider::NextAnimationId(); if (!groupId) groupId = AnimationIdProvider::NextGroupId(); - CompositorAnimationCurve::AnimationCurveType curveType = webCurve.type(); - std::unique_ptr<cc::AnimationCurve> curve; - switch (curveType) { - case CompositorAnimationCurve::AnimationCurveTypeFloat: { - const blink::CompositorFloatAnimationCurve* floatCurve = static_cast<const blink::CompositorFloatAnimationCurve*>(&webCurve); - curve = floatCurve->cloneToAnimationCurve(); - break; - } - case CompositorAnimationCurve::AnimationCurveTypeTransform: { - const blink::CompositorTransformAnimationCurve* transformCurve = static_cast<const blink::CompositorTransformAnimationCurve*>(&webCurve); - curve = transformCurve->cloneToAnimationCurve(); - break; - } - case CompositorAnimationCurve::AnimationCurveTypeFilter: { - const blink::CompositorFilterAnimationCurve* filterCurve = static_cast<const blink::CompositorFilterAnimationCurve*>(&webCurve); - curve = filterCurve->cloneToAnimationCurve(); - break; - } - case CompositorAnimationCurve::AnimationCurveTypeScrollOffset: { - const blink::CompositorScrollOffsetAnimationCurve* scrollCurve = static_cast<const blink::CompositorScrollOffsetAnimationCurve*>(&webCurve); - curve = scrollCurve->cloneToAnimationCurve(); - break; - } - } - m_animation = Animation::Create(std::move(curve), animationId, groupId, targetProperty); + m_animation = Animation::Create(curve.cloneToAnimationCurve(), animationId, groupId, targetProperty); } CompositorAnimation::CompositorAnimation() {}
diff --git a/third_party/WebKit/Source/platform/animation/CompositorAnimationCurve.h b/third_party/WebKit/Source/platform/animation/CompositorAnimationCurve.h index 3f3285d4..4b85868 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorAnimationCurve.h +++ b/third_party/WebKit/Source/platform/animation/CompositorAnimationCurve.h
@@ -10,6 +10,7 @@ #include <memory> namespace cc { +class AnimationCurve; class TimingFunction; } @@ -25,16 +26,8 @@ TimingFunctionTypeLinear }; - enum AnimationCurveType { - AnimationCurveTypeFilter, - AnimationCurveTypeFloat, - AnimationCurveTypeScrollOffset, - AnimationCurveTypeTransform, - }; - virtual ~CompositorAnimationCurve() {} - - virtual AnimationCurveType type() const = 0; + virtual std::unique_ptr<cc::AnimationCurve> cloneToAnimationCurve() const = 0; protected: static std::unique_ptr<cc::TimingFunction> createTimingFunction(TimingFunctionType);
diff --git a/third_party/WebKit/Source/platform/animation/CompositorFilterAnimationCurve.cpp b/third_party/WebKit/Source/platform/animation/CompositorFilterAnimationCurve.cpp index 0f86ff9..1608638 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorFilterAnimationCurve.cpp +++ b/third_party/WebKit/Source/platform/animation/CompositorFilterAnimationCurve.cpp
@@ -22,11 +22,6 @@ { } -blink::CompositorAnimationCurve::AnimationCurveType CompositorFilterAnimationCurve::type() const -{ - return CompositorAnimationCurve::AnimationCurveTypeFilter; -} - void CompositorFilterAnimationCurve::add(const CompositorFilterKeyframe& keyframe, TimingFunctionType type) { const cc::FilterOperations& filterOperations = keyframe.value().asFilterOperations();
diff --git a/third_party/WebKit/Source/platform/animation/CompositorFilterAnimationCurve.h b/third_party/WebKit/Source/platform/animation/CompositorFilterAnimationCurve.h index 7e8f0b5..5463a409 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorFilterAnimationCurve.h +++ b/third_party/WebKit/Source/platform/animation/CompositorFilterAnimationCurve.h
@@ -14,7 +14,6 @@ #include <memory> namespace cc { -class AnimationCurve; class KeyframedFilterAnimationCurve; } @@ -44,9 +43,7 @@ virtual void setStepsTimingFunction(int numberOfSteps, StepsTimingFunction::StepPosition); // blink::CompositorAnimationCurve implementation. - AnimationCurveType type() const override; - - std::unique_ptr<cc::AnimationCurve> cloneToAnimationCurve() const; + std::unique_ptr<cc::AnimationCurve> cloneToAnimationCurve() const override; private: std::unique_ptr<cc::KeyframedFilterAnimationCurve> m_curve;
diff --git a/third_party/WebKit/Source/platform/animation/CompositorFilterKeyframe.cpp b/third_party/WebKit/Source/platform/animation/CompositorFilterKeyframe.cpp index 7505cfa..1758ee89 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorFilterKeyframe.cpp +++ b/third_party/WebKit/Source/platform/animation/CompositorFilterKeyframe.cpp
@@ -14,7 +14,7 @@ CompositorFilterKeyframe::~CompositorFilterKeyframe() { - m_value.clear(); + m_value.reset(); } } // namespace blink
diff --git a/third_party/WebKit/Source/platform/animation/CompositorFloatAnimationCurve.cpp b/third_party/WebKit/Source/platform/animation/CompositorFloatAnimationCurve.cpp index d294fb59..e325d3b 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorFloatAnimationCurve.cpp +++ b/third_party/WebKit/Source/platform/animation/CompositorFloatAnimationCurve.cpp
@@ -21,11 +21,6 @@ { } -CompositorAnimationCurve::AnimationCurveType CompositorFloatAnimationCurve::type() const -{ - return CompositorAnimationCurve::AnimationCurveTypeFloat; -} - void CompositorFloatAnimationCurve::add(const CompositorFloatKeyframe& keyframe) { add(keyframe, TimingFunctionTypeEase);
diff --git a/third_party/WebKit/Source/platform/animation/CompositorFloatAnimationCurve.h b/third_party/WebKit/Source/platform/animation/CompositorFloatAnimationCurve.h index 03c9e0d3..26060f27 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorFloatAnimationCurve.h +++ b/third_party/WebKit/Source/platform/animation/CompositorFloatAnimationCurve.h
@@ -14,7 +14,6 @@ #include <memory> namespace cc { -class AnimationCurve; class KeyframedFloatAnimationCurve; } @@ -48,9 +47,7 @@ virtual float getValue(double time) const; // CompositorAnimationCurve implementation. - AnimationCurveType type() const override; - - std::unique_ptr<cc::AnimationCurve> cloneToAnimationCurve() const; + std::unique_ptr<cc::AnimationCurve> cloneToAnimationCurve() const override; private: std::unique_ptr<cc::KeyframedFloatAnimationCurve> m_curve;
diff --git a/third_party/WebKit/Source/platform/animation/CompositorScrollOffsetAnimationCurve.cpp b/third_party/WebKit/Source/platform/animation/CompositorScrollOffsetAnimationCurve.cpp index 7aeb8f2..6c9ba0c 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorScrollOffsetAnimationCurve.cpp +++ b/third_party/WebKit/Source/platform/animation/CompositorScrollOffsetAnimationCurve.cpp
@@ -49,11 +49,6 @@ { } -CompositorAnimationCurve::AnimationCurveType CompositorScrollOffsetAnimationCurve::type() const -{ - return CompositorAnimationCurve::AnimationCurveTypeScrollOffset; -} - void CompositorScrollOffsetAnimationCurve::setInitialValue(FloatPoint initialValue) { m_curve->SetInitialValue(gfx::ScrollOffset(initialValue.x(), initialValue.y()));
diff --git a/third_party/WebKit/Source/platform/animation/CompositorScrollOffsetAnimationCurve.h b/third_party/WebKit/Source/platform/animation/CompositorScrollOffsetAnimationCurve.h index 2f13a48..ebf9e7a 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorScrollOffsetAnimationCurve.h +++ b/third_party/WebKit/Source/platform/animation/CompositorScrollOffsetAnimationCurve.h
@@ -10,10 +10,7 @@ #include "platform/geometry/FloatPoint.h" #include "wtf/Noncopyable.h" -#include <memory> - namespace cc { -class AnimationCurve; class ScrollOffsetAnimationCurve; } @@ -32,16 +29,14 @@ CompositorScrollOffsetAnimationCurve(cc::ScrollOffsetAnimationCurve*); ~CompositorScrollOffsetAnimationCurve() override; - // CompositorAnimationCurve implementation. - AnimationCurveType type() const override; - virtual void setInitialValue(FloatPoint); virtual FloatPoint getValue(double time) const; virtual double duration() const; virtual FloatPoint targetValue() const; virtual void updateTarget(double time, FloatPoint newTarget); - std::unique_ptr<cc::AnimationCurve> cloneToAnimationCurve() const; + // CompositorAnimationCurve implementation. + std::unique_ptr<cc::AnimationCurve> cloneToAnimationCurve() const override; private: std::unique_ptr<cc::ScrollOffsetAnimationCurve> m_curve;
diff --git a/third_party/WebKit/Source/platform/animation/CompositorTransformAnimationCurve.cpp b/third_party/WebKit/Source/platform/animation/CompositorTransformAnimationCurve.cpp index 4a95aca..7f320a06 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorTransformAnimationCurve.cpp +++ b/third_party/WebKit/Source/platform/animation/CompositorTransformAnimationCurve.cpp
@@ -22,11 +22,6 @@ { } -CompositorAnimationCurve::AnimationCurveType CompositorTransformAnimationCurve::type() const -{ - return CompositorAnimationCurve::AnimationCurveTypeTransform; -} - void CompositorTransformAnimationCurve::add(const CompositorTransformKeyframe& keyframe) { add(keyframe, TimingFunctionTypeEase);
diff --git a/third_party/WebKit/Source/platform/animation/CompositorTransformAnimationCurve.h b/third_party/WebKit/Source/platform/animation/CompositorTransformAnimationCurve.h index 942dba00..25ae686 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorTransformAnimationCurve.h +++ b/third_party/WebKit/Source/platform/animation/CompositorTransformAnimationCurve.h
@@ -14,7 +14,6 @@ #include <memory> namespace cc { -class AnimationCurve; class KeyframedTransformAnimationCurve; } @@ -46,9 +45,7 @@ virtual void setStepsTimingFunction(int numberOfSteps, StepsTimingFunction::StepPosition); // CompositorAnimationCurve implementation. - AnimationCurveType type() const override; - - std::unique_ptr<cc::AnimationCurve> cloneToAnimationCurve() const; + std::unique_ptr<cc::AnimationCurve> cloneToAnimationCurve() const override; private: std::unique_ptr<cc::KeyframedTransformAnimationCurve> m_curve;
diff --git a/third_party/WebKit/Source/platform/animation/CompositorTransformKeyframe.cpp b/third_party/WebKit/Source/platform/animation/CompositorTransformKeyframe.cpp index 4d0b8c1..dc7e32a 100644 --- a/third_party/WebKit/Source/platform/animation/CompositorTransformKeyframe.cpp +++ b/third_party/WebKit/Source/platform/animation/CompositorTransformKeyframe.cpp
@@ -14,7 +14,7 @@ CompositorTransformKeyframe::~CompositorTransformKeyframe() { - m_value.clear(); + m_value.reset(); } double CompositorTransformKeyframe::time() const
diff --git a/third_party/WebKit/Source/platform/audio/AudioChannel.h b/third_party/WebKit/Source/platform/audio/AudioChannel.h index a1fb5ad7..f156911 100644 --- a/third_party/WebKit/Source/platform/audio/AudioChannel.h +++ b/third_party/WebKit/Source/platform/audio/AudioChannel.h
@@ -73,7 +73,7 @@ // storage represents external memory not managed by this object. void set(float* storage, size_t length) { - m_memBuffer.clear(); // cleanup managed storage + m_memBuffer.reset(); // cleanup managed storage m_rawPointer = storage; m_length = length; m_silent = false;
diff --git a/third_party/WebKit/Source/platform/audio/HRTFDatabaseLoader.cpp b/third_party/WebKit/Source/platform/audio/HRTFDatabaseLoader.cpp index aa39a07..d57b760 100644 --- a/third_party/WebKit/Source/platform/audio/HRTFDatabaseLoader.cpp +++ b/third_party/WebKit/Source/platform/audio/HRTFDatabaseLoader.cpp
@@ -120,7 +120,7 @@ // TODO(alexclarke): Should this be posted as a loading task? m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&HRTFDatabaseLoader::cleanupTask, AllowCrossThreadAccess(this), AllowCrossThreadAccess(&sync))); sync.waitForTaskCompletion(); - m_thread.clear(); + m_thread.reset(); } } // namespace blink
diff --git a/third_party/WebKit/Source/platform/audio/ReverbConvolver.cpp b/third_party/WebKit/Source/platform/audio/ReverbConvolver.cpp index e204727..4a59630 100644 --- a/third_party/WebKit/Source/platform/audio/ReverbConvolver.cpp +++ b/third_party/WebKit/Source/platform/audio/ReverbConvolver.cpp
@@ -122,7 +122,7 @@ ReverbConvolver::~ReverbConvolver() { // Wait for background thread to stop - m_backgroundThread.clear(); + m_backgroundThread.reset(); } void ReverbConvolver::processInBackground()
diff --git a/third_party/WebKit/Source/platform/geometry/TransformState.cpp b/third_party/WebKit/Source/platform/geometry/TransformState.cpp index c119f0f..cdfc0120 100644 --- a/third_party/WebKit/Source/platform/geometry/TransformState.cpp +++ b/third_party/WebKit/Source/platform/geometry/TransformState.cpp
@@ -42,7 +42,7 @@ m_forceAccumulatingTransform = other.m_forceAccumulatingTransform; m_direction = other.m_direction; - m_accumulatedTransform.clear(); + m_accumulatedTransform.reset(); if (other.m_accumulatedTransform) m_accumulatedTransform = TransformationMatrix::create(*other.m_accumulatedTransform);
diff --git a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp index e2055c5..2432bb0 100644 --- a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp +++ b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
@@ -547,7 +547,7 @@ { // This timer is used to animate all occurrences of this image. Don't invalidate // the timer unless all renderers have stopped drawing. - m_frameTimer.clear(); + m_frameTimer.reset(); } void BitmapImage::resetAnimation()
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp index f566abe8..30d5694 100644 --- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp +++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -130,7 +130,7 @@ clearCHROMIUMImageCache(); #endif // USE_IOSURFACE_FOR_2D_CANVAS - m_layer.clear(); + m_layer.reset(); ASSERT(m_mailboxes.size() == 0); } @@ -543,7 +543,7 @@ m_haveRecordedDrawCommands = false; m_isDeferralEnabled = false; - m_recorder.clear(); + m_recorder.reset(); // install the current matrix/clip stack onto the immediate canvas SkSurface* surface = getOrCreateSurface(); if (m_imageBuffer && surface) @@ -565,7 +565,7 @@ if (isHibernating()) m_logger->reportHibernationEvent(HibernationEndedWithTeardown); m_hibernationImage.clear(); - m_recorder.clear(); + m_recorder.reset(); m_imageBuffer = nullptr; m_destructionInProgress = true; setIsHidden(true);
diff --git a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp index ad4312a1..c8041a9 100644 --- a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp +++ b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp
@@ -273,7 +273,7 @@ if (m_allDataReceived) { m_repetitionCount = m_actualDecoder->repetitionCount(); - m_actualDecoder.clear(); + m_actualDecoder.reset(); // Hold on to m_rwBuffer, which is still needed by createFrameAtIndex. } }
diff --git a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp index 71ed10c3..d7f5d4b 100644 --- a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp +++ b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp
@@ -246,7 +246,7 @@ // Create a thread to rasterize SkPicture. OwnPtr<WebThread> thread = adoptPtr(Platform::current()->createThread("RasterThread")); thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&rasterizeMain, AllowCrossThreadAccess(m_surface->getCanvas()), AllowCrossThreadAccess(picture.get()))); - thread.clear(); + thread.reset(); EXPECT_EQ(0, m_decodeRequestCount); SkBitmap canvasBitmap;
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp index 008f0652..b5ea4ac 100644 --- a/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp +++ b/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp
@@ -181,7 +181,7 @@ // to disable rendering of the source primitive. When not shadow-only, we // clear the looper. if (shadowMode != DrawShadowOnly) - drawLooperBuilder.clear(); + drawLooperBuilder.reset(); setDrawLooper(std::move(drawLooperBuilder)); return;
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp index a95334c4..5dec2fd 100644 --- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp +++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp
@@ -936,7 +936,7 @@ updateLayerIsDrawable(); if (!drawsContent && m_paintController) - m_paintController.clear(); + m_paintController.reset(); } void GraphicsLayer::setContentsVisible(bool contentsVisible) @@ -1114,7 +1114,7 @@ } else { if (m_imageLayer) { unregisterContentsLayer(m_imageLayer->layer()); - m_imageLayer.clear(); + m_imageLayer.reset(); } }
diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp index 60c4b349..68ecef10 100644 --- a/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp +++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp
@@ -68,8 +68,8 @@ ~GraphicsLayerTest() override { - m_graphicsLayer.clear(); - m_layerTreeView.clear(); + m_graphicsLayer.reset(); + m_layerTreeView.reset(); } WebLayerTreeView* layerTreeView() { return m_layerTreeView.get(); }
diff --git a/third_party/WebKit/Source/platform/graphics/ImageFrameGeneratorTest.cpp b/third_party/WebKit/Source/platform/graphics/ImageFrameGeneratorTest.cpp index 2d75f18..74e5a2b 100644 --- a/third_party/WebKit/Source/platform/graphics/ImageFrameGeneratorTest.cpp +++ b/third_party/WebKit/Source/platform/graphics/ImageFrameGeneratorTest.cpp
@@ -186,7 +186,7 @@ addNewData(); OwnPtr<WebThread> thread = adoptPtr(Platform::current()->createThread("DecodeThread")); thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&decodeThreadMain, m_generator, m_segmentReader)); - thread.clear(); + thread.reset(); EXPECT_EQ(2, m_decodeRequestCount); EXPECT_EQ(1, m_decodersDestroyed);
diff --git a/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp b/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp index 08caf761..c19292b 100644 --- a/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp +++ b/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp
@@ -90,7 +90,7 @@ if (m_currentFrame) { m_currentFrame->finishRecordingAsPicture()->playback(m_fallbackSurface->canvas()); - m_currentFrame.clear(); + m_currentFrame.reset(); } if (m_imageBuffer) {
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp index 73ed04b0..13efb12 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp +++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
@@ -152,8 +152,8 @@ { ASSERT(m_destructionInProgress); ASSERT(m_textureMailboxes.isEmpty()); - m_layer.clear(); - m_contextProvider.clear(); + m_layer.reset(); + m_contextProvider.reset(); } void DrawingBuffer::markContentsChanged()
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.cpp b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.cpp index 3842c8f..5e0a79b9 100644 --- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.cpp +++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.cpp
@@ -4,7 +4,8 @@ #include "platform/graphics/paint/DisplayItemClient.h" -#if ENABLE(ASSERT) +#if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS +#include "wtf/HashMap.h" #include "wtf/HashSet.h" #endif @@ -12,12 +13,14 @@ DisplayItemCacheGeneration::Generation DisplayItemCacheGeneration::s_nextGeneration = 1; -#if DCHECK_IS_ON() +#if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS HashSet<const DisplayItemClient*>* liveDisplayItemClients = nullptr; +HashMap<const DisplayItemClient*, String>* displayItemClientsShouldKeepAlive = nullptr; DisplayItemClient::DisplayItemClient() { + CHECK(!displayItemClientsShouldKeepAlive || !displayItemClientsShouldKeepAlive->contains(this)); if (!liveDisplayItemClients) liveDisplayItemClients = new HashSet<const DisplayItemClient*>(); liveDisplayItemClients->add(this); @@ -25,14 +28,35 @@ DisplayItemClient::~DisplayItemClient() { + CHECK(!displayItemClientsShouldKeepAlive || !displayItemClientsShouldKeepAlive->contains(this)) + << "Short-lived DisplayItemClient: " << displayItemClientsShouldKeepAlive->get(this) + << ". See crbug.com/570030."; liveDisplayItemClients->remove(this); } -bool DisplayItemClient::isAlive(const DisplayItemClient& client) +bool DisplayItemClient::isAlive() const { - return liveDisplayItemClients && liveDisplayItemClients->contains(&client); + return liveDisplayItemClients && liveDisplayItemClients->contains(this); } -#endif // DCHECK_IS_ON() +void DisplayItemClient::beginShouldKeepAlive() const +{ + CHECK(isAlive()); + if (!displayItemClientsShouldKeepAlive) + displayItemClientsShouldKeepAlive = new HashMap<const DisplayItemClient*, String>(); + auto addResult = displayItemClientsShouldKeepAlive->add(this, ""); +#ifndef NDEBUG + if (addResult.isNewEntry) + addResult.storedValue->value = debugName(); +#endif +} + +void DisplayItemClient::endShouldKeepAlive() const +{ + CHECK(isAlive()); + displayItemClientsShouldKeepAlive->remove(this); +} + +#endif // CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS } // namespace blink
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h index 9362e372..03e01b6 100644 --- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h +++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
@@ -10,6 +10,8 @@ #include "wtf/Assertions.h" #include "wtf/text/WTFString.h" +#define CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS DCHECK_IS_ON() + namespace blink { // Holds a unique cache generation id of display items and paint controllers. @@ -53,9 +55,17 @@ // no longer dereferenced unless we can make sure the client is still valid. class PLATFORM_EXPORT DisplayItemClient { public: -#if DCHECK_IS_ON() +#if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS DisplayItemClient(); virtual ~DisplayItemClient(); + + // Tests if this DisplayItemClient object has been created and has not been deleted yet. + bool isAlive() const; + // Called when any DisplayItem of this DisplayItemClient is added into PaintController + // using PaintController::createAndAppend(). + void beginShouldKeepAlive() const; + // Called when the DisplayItems of this DisplayItemClient are committed in PaintController. + void endShouldKeepAlive() const; #else virtual ~DisplayItemClient() { } #endif @@ -69,13 +79,6 @@ virtual bool displayItemsAreCached(DisplayItemCacheGeneration) const = 0; virtual void setDisplayItemsCached(DisplayItemCacheGeneration) const = 0; virtual void setDisplayItemsUncached() const = 0; - -#if DCHECK_IS_ON() - // Tests if a DisplayItemClient object has been created and has not been deleted yet. - static bool isAlive(const DisplayItemClient&); -#endif - -protected: }; #define DISPLAY_ITEM_CACHE_STATUS_IMPLEMENTATION \
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClientTest.cpp b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClientTest.cpp index 0c93d8d..fbf188d 100644 --- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClientTest.cpp +++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClientTest.cpp
@@ -14,11 +14,11 @@ TEST(DisplayItemClientTest, IsAlive) { - EXPECT_FALSE(DisplayItemClient::isAlive(*reinterpret_cast<DisplayItemClient*>(0x12345678))); + EXPECT_FALSE(reinterpret_cast<DisplayItemClient*>(0x12345678)->isAlive()); FakeDisplayItemClient* testClient = new FakeDisplayItemClient; - EXPECT_TRUE(DisplayItemClient::isAlive(*testClient)); + EXPECT_TRUE(testClient->isAlive()); delete testClient; - EXPECT_FALSE(DisplayItemClient::isAlive(*testClient)); + EXPECT_FALSE(testClient->isAlive()); } #endif // ENABLE(ASSERT)
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemList.cpp b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemList.cpp index 0968fcb..93b307d 100644 --- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemList.cpp +++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemList.cpp
@@ -36,19 +36,6 @@ return result; } -#if ENABLE(ASSERT) -void DisplayItemList::assertDisplayItemClientsAreAlive() const -{ - for (auto& item : *this) { -#ifdef NDEBUG - DCHECK(DisplayItemClient::isAlive(item.client())) << "Short-lived DisplayItemClient. See crbug.com/570030."; -#else - DCHECK(DisplayItemClient::isAlive(item.client())) << "Short-lived DisplayItemClient: " << item.clientDebugString() << ". See crbug.com/570030."; -#endif - } -} -#endif - void DisplayItemList::appendVisualRect(const IntRect& visualRect) { size_t itemIndex = m_visualRects.size();
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemList.h b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemList.h index 1a9b410..df66a435 100644 --- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemList.h +++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemList.h
@@ -53,10 +53,6 @@ void appendVisualRect(const IntRect& visualRect); -#if ENABLE(ASSERT) - void assertDisplayItemClientsAreAlive() const; -#endif - // Useful for iterating with a range-based for loop. template <typename Iterator> class Range {
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp index ad669e7a..c61fd4d4 100644 --- a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp +++ b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp
@@ -99,9 +99,6 @@ void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const { TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList"); -#if ENABLE(ASSERT) - m_displayItemList.assertDisplayItemClientsAreAlive(); -#endif unsigned visualRectIndex = 0; for (const DisplayItem& displayItem : m_displayItemList) { displayItem.appendToWebDisplayItemList(m_displayItemList.visualRect(visualRectIndex), list);
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp index 8cf24c2..6b6db13 100644 --- a/third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp +++ b/third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp
@@ -65,6 +65,11 @@ DCHECK(!m_constructionDisabled); DCHECK(!skippingCache() || !displayItem.isCached()); +#if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS + if (!skippingCache() && (displayItem.isCacheable() || displayItem.isCached())) + displayItem.client().beginShouldKeepAlive(); +#endif + if (displayItem.isCached()) ++m_numCachedNewItems; @@ -158,8 +163,8 @@ bool PaintController::clientCacheIsValid(const DisplayItemClient& client) const { -#if DCHECK_IS_ON() - DCHECK(DisplayItemClient::isAlive(client)); +#if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS + CHECK(client.isAlive()); #endif if (skippingCache()) return false; @@ -261,17 +266,6 @@ } while (!endSubsequenceId.matches(updatedList.last())); } -void PaintController::commitNewDisplayItems(const LayoutSize& offsetFromLayoutObject) -{ -#if DCHECK_IS_ON() - m_newDisplayItemList.assertDisplayItemClientsAreAlive(); -#endif - commitNewDisplayItemsInternal(offsetFromLayoutObject); -#if DCHECK_IS_ON() - m_currentPaintArtifact.getDisplayItemList().assertDisplayItemClientsAreAlive(); -#endif -} - static IntRect visualRectForDisplayItem(const DisplayItem& displayItem, const LayoutSize& offsetFromLayoutObject) { LayoutRect visualRect = displayItem.client().visualRect(); @@ -290,7 +284,7 @@ // Coefficients are related to the ratio of out-of-order CachedDisplayItems // and the average number of (Drawing|Subsequence)DisplayItems per client. // -void PaintController::commitNewDisplayItemsInternal(const LayoutSize& offsetFromLayoutObject) +void PaintController::commitNewDisplayItems(const LayoutSize& offsetFromLayoutObject) { TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems", "current_display_list_size", (int)m_currentPaintArtifact.getDisplayItemList().size(), @@ -441,8 +435,12 @@ { m_currentCacheGeneration = DisplayItemCacheGeneration::next(); for (const DisplayItem& displayItem : m_currentPaintArtifact.getDisplayItemList()) { - if (displayItem.isCacheable()) - displayItem.client().setDisplayItemsCached(m_currentCacheGeneration); + if (!displayItem.isCacheable()) + continue; + displayItem.client().setDisplayItemsCached(m_currentCacheGeneration); +#if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS + displayItem.client().endShouldKeepAlive(); +#endif } }
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintController.h b/third_party/WebKit/Source/platform/graphics/paint/PaintController.h index 429b8500..dfa343e 100644 --- a/third_party/WebKit/Source/platform/graphics/paint/PaintController.h +++ b/third_party/WebKit/Source/platform/graphics/paint/PaintController.h
@@ -208,8 +208,6 @@ void checkNoRemainingCachedDisplayItems(); #endif - void commitNewDisplayItemsInternal(const LayoutSize& offsetFromLayoutObject); - void updateCacheGeneration(); // The last complete paint artifact.
diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp index 70de782..300a627 100644 --- a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp +++ b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
@@ -306,7 +306,7 @@ // static void ImageDecoder::setColorProfileAndTransform(const char* iccData, unsigned iccLength, bool hasAlpha, bool useSRGB) { - m_sourceToOutputDeviceColorTransform.clear(); + m_sourceToOutputDeviceColorTransform.reset(); // Create the input profile OwnPtr<qcms_profile> inputProfile;
diff --git a/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageDecoder.cpp index 01815ab..87a80281 100644 --- a/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageDecoder.cpp +++ b/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageDecoder.cpp
@@ -54,7 +54,7 @@ bool BMPImageDecoder::setFailed() { - m_reader.clear(); + m_reader.reset(); return ImageDecoder::setFailed(); } @@ -70,7 +70,7 @@ // If we're done decoding the image, we don't need the BMPImageReader // anymore. (If we failed, |m_reader| has already been cleared.) else if (!m_frameBufferCache.isEmpty() && (m_frameBufferCache.first().getStatus() == ImageFrame::FrameComplete)) - m_reader.clear(); + m_reader.reset(); } bool BMPImageDecoder::decodeHelper(bool onlySize)
diff --git a/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp b/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp index 7e10d1d..3f48117 100644 --- a/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp +++ b/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp
@@ -30,6 +30,9 @@ #include "platform/image-decoders/bmp/BMPImageReader.h" +#include "platform/Histogram.h" +#include "wtf/Threading.h" + namespace { // See comments on m_lookupTableAddresses in the header. @@ -205,6 +208,11 @@ return false; m_decodedOffset += m_infoHeader.biSize; + DEFINE_THREAD_SAFE_STATIC_LOCAL(blink::CustomCountHistogram, + dimensionsLocationHistogram, + new blink::CustomCountHistogram("Blink.DecodedImage.EffectiveDimensionsLocation.BMP", 0, 50000, 50)); + dimensionsLocationHistogram.count(m_decodedOffset - 1); + // Sanity-check header values. if (!isInfoHeaderValid()) return m_parent->setFailed();
diff --git a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp index 457666d2..2cae67e0a 100644 --- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp +++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
@@ -97,7 +97,7 @@ bool GIFImageDecoder::setFailed() { - m_reader.clear(); + m_reader.reset(); return ImageDecoder::setFailed(); }
diff --git a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.cpp b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.cpp index 103d6d3..34679f5 100644 --- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.cpp +++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.cpp
@@ -74,6 +74,9 @@ #include "platform/image-decoders/gif/GIFImageReader.h" +#include "platform/Histogram.h" +#include "wtf/Threading.h" + #include <string.h> using blink::GIFImageDecoder; @@ -335,7 +338,7 @@ m_lzwContext = adoptPtr(new GIFLZWContext(client, this)); if (!m_lzwContext->prepareToDecode()) { - m_lzwContext.clear(); + m_lzwContext.reset(); return false; } @@ -365,7 +368,7 @@ // There will be no more decoding for this frame so it's time to cleanup. if (isComplete()) { *frameDecoded = true; - m_lzwContext.clear(); + m_lzwContext.reset(); } return true; } @@ -697,6 +700,29 @@ // set to zero, since usually the first frame completely fills // the image. if (currentFrameIsFirstFrame()) { + int yCanvasExpansion = (m_screenHeight < yOffset + height) ? yOffset + height - m_screenHeight : 0; + int xCanvasExpansion = (m_screenWidth < xOffset + width) ? xOffset + width - m_screenWidth : 0; + DEFINE_THREAD_SAFE_STATIC_LOCAL(blink::BooleanHistogram, + canvasExpandedHistogram, + new blink::BooleanHistogram("Blink.DecodedImage.CanvasExpanded.GIF")); + canvasExpandedHistogram.count(xCanvasExpansion > 0 || yCanvasExpansion > 0); + if (yCanvasExpansion > 0) { + DEFINE_THREAD_SAFE_STATIC_LOCAL(blink::CustomCountHistogram, + yCanvasExpansionHistogram, + new blink::CustomCountHistogram("Blink.DecodedImage.YCanvasExpansion.GIF", 0, 10000, 50)); + yCanvasExpansionHistogram.count(yCanvasExpansion); + } + if (xCanvasExpansion > 0) { + DEFINE_THREAD_SAFE_STATIC_LOCAL(blink::CustomCountHistogram, + xCanvasExpansionHistogram, + new blink::CustomCountHistogram("Blink.DecodedImage.XCanvasExpansion.GIF", 0, 10000, 50)); + xCanvasExpansionHistogram.count(xCanvasExpansion); + } + DEFINE_THREAD_SAFE_STATIC_LOCAL(blink::CustomCountHistogram, + dimensionsLocationHistogram, + new blink::CustomCountHistogram("Blink.DecodedImage.EffectiveDimensionsLocation.GIF", 0, 50000, 50)); + dimensionsLocationHistogram.count(dataPosition - 1); + m_screenHeight = std::max(m_screenHeight, yOffset + height); m_screenWidth = std::max(m_screenWidth, xOffset + width); }
diff --git a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.h b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.h index bfa9897..1ec9d384 100644 --- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.h +++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageReader.h
@@ -248,7 +248,7 @@ bool interlaced() const { return m_interlaced; } void setInterlaced(bool interlaced) { m_interlaced = interlaced; } - void clearDecodeState() { m_lzwContext.clear(); } + void clearDecodeState() { m_lzwContext.reset(); } const GIFColorMap& localColorMap() const { return m_localColorMap; } GIFColorMap& localColorMap() { return m_localColorMap; }
diff --git a/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp index a189f81..e50b37c 100644 --- a/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp +++ b/third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
@@ -30,10 +30,12 @@ #include "platform/image-decoders/ico/ICOImageDecoder.h" -#include <algorithm> - +#include "platform/Histogram.h" #include "platform/image-decoders/png/PNGImageDecoder.h" #include "wtf/PassOwnPtr.h" +#include "wtf/Threading.h" + +#include <algorithm> namespace blink { @@ -148,8 +150,8 @@ // PNGImageDecoder anymore. (If we failed, these have already been // cleared.) } else if ((m_frameBufferCache.size() > index) && (m_frameBufferCache[index].getStatus() == ImageFrame::FrameComplete)) { - m_bmpReaders[index].clear(); - m_pngDecoders[index].clear(); + m_bmpReaders[index].reset(); + m_pngDecoders[index].reset(); } } @@ -241,6 +243,11 @@ return setFailed(); } + DEFINE_THREAD_SAFE_STATIC_LOCAL(blink::CustomCountHistogram, + dimensionsLocationHistogram, + new blink::CustomCountHistogram("Blink.DecodedImage.EffectiveDimensionsLocation.ICO", 0, 50000, 50)); + dimensionsLocationHistogram.count(m_decodedOffset - 1); + // Arrange frames in decreasing quality order. std::sort(m_dirEntries.begin(), m_dirEntries.end(), compareEntries);
diff --git a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp index 03b465d8..95bb9acd 100644 --- a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp +++ b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
@@ -37,7 +37,9 @@ #include "platform/image-decoders/jpeg/JPEGImageDecoder.h" +#include "platform/Histogram.h" #include "platform/PlatformInstrumentation.h" +#include "wtf/Threading.h" extern "C" { #include <stdio.h> // jpeglib.h needs stdio FILE. @@ -423,6 +425,12 @@ m_state = JPEG_START_DECOMPRESS; + { + DEFINE_THREAD_SAFE_STATIC_LOCAL(blink::CustomCountHistogram, + dimensionsLocationHistogram, + new blink::CustomCountHistogram("Blink.DecodedImage.EffectiveDimensionsLocation.JPEG", 0, 50000, 50)); + dimensionsLocationHistogram.count(m_nextReadPosition - m_info.src->bytes_in_buffer - 1); + } // We can fill in the size now that the header is available. if (!m_decoder->setSize(m_info.image_width, m_info.image_height)) return false; @@ -991,7 +999,7 @@ // If decoding is done or failed, we don't need the JPEGImageReader anymore. if (isComplete(this, onlySize) || failed()) - m_reader.clear(); + m_reader.reset(); } } // namespace blink
diff --git a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp index 5f787b5..d444caa 100644 --- a/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp +++ b/third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp
@@ -38,7 +38,10 @@ #include "platform/image-decoders/png/PNGImageDecoder.h" +#include "platform/Histogram.h" #include "png.h" +#include "wtf/Threading.h" + #if !defined(PNG_LIBPNG_VER_MAJOR) || !defined(PNG_LIBPNG_VER_MINOR) #error version error: compile against a versioned libpng. #endif @@ -133,6 +136,7 @@ png_structp pngPtr() const { return m_png; } png_infop infoPtr() const { return m_info; } + size_t getReadOffset() const { return m_readOffset; } void setReadOffset(size_t offset) { m_readOffset = offset; } size_t currentBufferSize() const { return m_currentBufferSize; } bool decodingSizeOnly() const { return m_decodingSizeOnly; } @@ -177,6 +181,11 @@ png_uint_32 width = png_get_image_width(png, info); png_uint_32 height = png_get_image_height(png, info); + DEFINE_THREAD_SAFE_STATIC_LOCAL(blink::CustomCountHistogram, + dimensionsLocationHistogram, + new blink::CustomCountHistogram("Blink.DecodedImage.EffectiveDimensionsLocation.PNG", 0, 50000, 50)); + dimensionsLocationHistogram.count(m_reader->getReadOffset() - png->current_buffer_size - 1); + // Protect against large PNGs. See http://bugzil.la/251381 for more details. const unsigned long maxPNGSize = 1000000UL; if (width > maxPNGSize || height > maxPNGSize) { @@ -435,7 +444,7 @@ // If decoding is done or failed, we don't need the PNGImageReader anymore. if (isComplete(this) || failed()) - m_reader.clear(); + m_reader.reset(); } } // namespace blink
diff --git a/third_party/WebKit/Source/platform/mediastream/MediaStreamComponent.cpp b/third_party/WebKit/Source/platform/mediastream/MediaStreamComponent.cpp index a05a6ab8..a81c0a57 100644 --- a/third_party/WebKit/Source/platform/mediastream/MediaStreamComponent.cpp +++ b/third_party/WebKit/Source/platform/mediastream/MediaStreamComponent.cpp
@@ -60,7 +60,7 @@ void MediaStreamComponent::dispose() { - m_extraData.clear(); + m_extraData.reset(); } void MediaStreamComponent::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* provider)
diff --git a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp index f7a8f0f..59bac45 100644 --- a/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp +++ b/third_party/WebKit/Source/platform/scroll/ProgrammaticScrollAnimator.cpp
@@ -28,7 +28,7 @@ void ProgrammaticScrollAnimator::resetAnimationState() { ScrollAnimatorCompositorCoordinator::resetAnimationState(); - m_animationCurve.clear(); + m_animationCurve.reset(); m_startTime = 0.0; }
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp index 4791dba..7303921b 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimator.cpp
@@ -95,7 +95,7 @@ { ScrollAnimatorCompositorCoordinator::resetAnimationState(); if (m_animationCurve) - m_animationCurve.clear(); + m_animationCurve.reset(); m_startTime = 0.0; }
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp index 70fa7f9..5ef66a4 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp
@@ -36,7 +36,7 @@ void ScrollAnimatorCompositorCoordinator::dispose() { m_compositorPlayer->setAnimationDelegate(nullptr); - m_compositorPlayer.clear(); + m_compositorPlayer.reset(); } void ScrollAnimatorCompositorCoordinator::resetAnimationState()
diff --git a/third_party/WebKit/Source/platform/weborigin/KURL.cpp b/third_party/WebKit/Source/platform/weborigin/KURL.cpp index 63fec31d..d8b32348 100644 --- a/third_party/WebKit/Source/platform/weborigin/KURL.cpp +++ b/third_party/WebKit/Source/platform/weborigin/KURL.cpp
@@ -290,7 +290,7 @@ if (other.m_innerURL) m_innerURL = adoptPtr(new KURL(other.m_innerURL->copy())); else - m_innerURL.clear(); + m_innerURL.reset(); return *this; } @@ -814,13 +814,13 @@ void KURL::initInnerURL() { if (!m_isValid) { - m_innerURL.clear(); + m_innerURL.reset(); return; } if (url::Parsed* innerParsed = m_parsed.inner_parsed()) m_innerURL = adoptPtr(new KURL(ParsedURLString, m_string.substring(innerParsed->scheme.begin, innerParsed->Length() - innerParsed->scheme.begin))); else - m_innerURL.clear(); + m_innerURL.reset(); } template<typename CHAR>
diff --git a/third_party/WebKit/Source/web/AssociatedURLLoader.cpp b/third_party/WebKit/Source/web/AssociatedURLLoader.cpp index 1f50e2c..008e332 100644 --- a/third_party/WebKit/Source/web/AssociatedURLLoader.cpp +++ b/third_party/WebKit/Source/web/AssociatedURLLoader.cpp
@@ -401,9 +401,9 @@ if (m_loader) { m_loader->cancel(); - m_loader.clear(); + m_loader.reset(); } - m_clientAdapter.clear(); + m_clientAdapter.reset(); } void AssociatedURLLoader::setDefersLoading(bool defersLoading)
diff --git a/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp b/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp index 43517e24..b4ed0a35 100644 --- a/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp +++ b/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp
@@ -135,7 +135,8 @@ { return !data.linkURL.isEmpty() || data.mediaType == WebContextMenuData::MediaTypeImage - || data.mediaType == WebContextMenuData::MediaTypeVideo; + || data.mediaType == WebContextMenuData::MediaTypeVideo + || data.isEditable; } bool ContextMenuClientImpl::showContextMenu(const ContextMenu* defaultMenu, bool fromTouch) @@ -263,9 +264,6 @@ } } - if (fromTouch && !shouldShowContextMenuFromTouch(data)) - return false; - // If it's not a link, an image, a media element, or an image/media link, // show a selection menu or a more generic page menu. if (selectedFrame->document()->loader()) @@ -368,11 +366,15 @@ data.inputFieldType = WebContextMenuData::InputFieldTypeNone; } + if (fromTouch && !shouldShowContextMenuFromTouch(data)) + return false; + WebLocalFrameImpl* selectedWebFrame = WebLocalFrameImpl::fromFrame(selectedFrame); selectedWebFrame->setContextMenuNode(r.innerNodeOrImageMapImage()); - if (selectedWebFrame->client()) - selectedWebFrame->client()->showContextMenu(data); + if (!selectedWebFrame->client()) + return false; + selectedWebFrame->client()->showContextMenu(data); return true; }
diff --git a/third_party/WebKit/Source/web/DevToolsEmulator.cpp b/third_party/WebKit/Source/web/DevToolsEmulator.cpp index 04c742b1..f87f2e7 100644 --- a/third_party/WebKit/Source/web/DevToolsEmulator.cpp +++ b/third_party/WebKit/Source/web/DevToolsEmulator.cpp
@@ -377,8 +377,8 @@ m_webViewImpl->mainFrame()->setScrollOffset(toIntSize(*m_lastPinchAnchorCss.get() - toIntSize(anchorCss))); } if (gestureEvent.type() == PlatformEvent::GesturePinchEnd) { - m_lastPinchAnchorCss.clear(); - m_lastPinchAnchorDip.clear(); + m_lastPinchAnchorCss.reset(); + m_lastPinchAnchorDip.reset(); } return true; }
diff --git a/third_party/WebKit/Source/web/ExternalPopupMenu.cpp b/third_party/WebKit/Source/web/ExternalPopupMenu.cpp index 99bc7b12..b9c93176a 100644 --- a/third_party/WebKit/Source/web/ExternalPopupMenu.cpp +++ b/third_party/WebKit/Source/web/ExternalPopupMenu.cpp
@@ -126,7 +126,7 @@ void ExternalPopupMenu::dispatchEvent(Timer<ExternalPopupMenu>*) { m_webView.handleInputEvent(*m_syntheticEvent); - m_syntheticEvent.clear(); + m_syntheticEvent.reset(); } void ExternalPopupMenu::hide()
diff --git a/third_party/WebKit/Source/web/InspectorOverlay.cpp b/third_party/WebKit/Source/web/InspectorOverlay.cpp index ecb2795..b6fa2c7 100644 --- a/third_party/WebKit/Source/web/InspectorOverlay.cpp +++ b/third_party/WebKit/Source/web/InspectorOverlay.cpp
@@ -301,7 +301,7 @@ { m_highlightNode.clear(); m_eventTargetNode.clear(); - m_highlightQuad.clear(); + m_highlightQuad.reset(); scheduleUpdate(); } @@ -367,7 +367,7 @@ { if (isEmpty()) { if (m_pageOverlay) - m_pageOverlay.clear(); + m_pageOverlay.reset(); return; } m_needsUpdate = true; @@ -697,7 +697,7 @@ if (m_inspectMode != InspectorDOMAgent::SearchingForUAShadow) { ShadowRoot* shadowRoot = InspectorDOMAgent::userAgentShadowRoot(node); if (shadowRoot) - node = shadowRoot->host(); + node = &shadowRoot->host(); } // Shadow roots don't have boxes - use host element instead.
diff --git a/third_party/WebKit/Source/web/LinkHighlightImpl.cpp b/third_party/WebKit/Source/web/LinkHighlightImpl.cpp index 0b2b2b2b..bd87ec4 100644 --- a/third_party/WebKit/Source/web/LinkHighlightImpl.cpp +++ b/third_party/WebKit/Source/web/LinkHighlightImpl.cpp
@@ -103,7 +103,7 @@ if (m_owningWebViewImpl->linkHighlightsTimeline()) m_owningWebViewImpl->linkHighlightsTimeline()->playerDestroyed(*this); m_compositorPlayer->setAnimationDelegate(nullptr); - m_compositorPlayer.clear(); + m_compositorPlayer.reset(); clearGraphicsLayerLinkHighlightPointer(); releaseResources();
diff --git a/third_party/WebKit/Source/web/WebDataSourceImpl.cpp b/third_party/WebKit/Source/web/WebDataSourceImpl.cpp index 81b720e..b0292e1 100644 --- a/third_party/WebKit/Source/web/WebDataSourceImpl.cpp +++ b/third_party/WebKit/Source/web/WebDataSourceImpl.cpp
@@ -144,7 +144,7 @@ void WebDataSourceImpl::detachFromFrame() { DocumentLoader::detachFromFrame(); - m_extraData.clear(); + m_extraData.reset(); } DEFINE_TRACE(WebDataSourceImpl)
diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp index 6da1ba8..830df41 100644 --- a/third_party/WebKit/Source/web/WebViewImpl.cpp +++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -968,7 +968,7 @@ bool WebViewImpl::endActiveFlingAnimation() { if (m_gestureAnimation) { - m_gestureAnimation.clear(); + m_gestureAnimation.reset(); m_flingSourceDevice = WebGestureDeviceUninitialized; if (m_layerTreeView) m_layerTreeView->didStopFlinging(); @@ -2767,7 +2767,7 @@ if (m_linkHighlightsTimeline) { m_linkHighlights.clear(); detachCompositorAnimationTimeline(m_linkHighlightsTimeline.get()); - m_linkHighlightsTimeline.clear(); + m_linkHighlightsTimeline.reset(); } if (m_layerTreeView) @@ -4133,7 +4133,7 @@ void WebViewImpl::setPageOverlayColor(WebColor color) { if (m_pageColorOverlay) - m_pageColorOverlay.clear(); + m_pageColorOverlay.reset(); if (color == Color::transparent) return;
diff --git a/third_party/WebKit/Source/web/tests/SpinLockTest.cpp b/third_party/WebKit/Source/web/tests/SpinLockTest.cpp index 2a5e47dc..80531c59 100644 --- a/third_party/WebKit/Source/web/tests/SpinLockTest.cpp +++ b/third_party/WebKit/Source/web/tests/SpinLockTest.cpp
@@ -83,8 +83,8 @@ thread1->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&threadMain, AllowCrossThreadAccess(static_cast<char*>(sharedBuffer)))); thread2->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&threadMain, AllowCrossThreadAccess(static_cast<char*>(sharedBuffer)))); - thread1.clear(); - thread2.clear(); + thread1.reset(); + thread2.reset(); } } // namespace blink
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp index 5b404dba..7e3ebf3f 100644 --- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp +++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -4619,7 +4619,7 @@ void clearSelection() override { m_selectionCleared = true; - m_selection.clear(); + m_selection.reset(); } bool getAndResetSelectionCleared()
diff --git a/third_party/WebKit/Source/web/tests/WebHelperPluginTest.cpp b/third_party/WebKit/Source/web/tests/WebHelperPluginTest.cpp index 3e58925..a479ed64 100644 --- a/third_party/WebKit/Source/web/tests/WebHelperPluginTest.cpp +++ b/third_party/WebKit/Source/web/tests/WebHelperPluginTest.cpp
@@ -52,7 +52,7 @@ void destroyHelperPlugin() { - m_plugin.clear(); + m_plugin.reset(); // WebHelperPlugin is destroyed by a task posted to the message loop. testing::runPendingTasks(); }
diff --git a/third_party/WebKit/Source/web/tests/WebViewTest.cpp b/third_party/WebKit/Source/web/tests/WebViewTest.cpp index 3019bcd..9ec6c06 100644 --- a/third_party/WebKit/Source/web/tests/WebViewTest.cpp +++ b/third_party/WebKit/Source/web/tests/WebViewTest.cpp
@@ -1687,6 +1687,26 @@ EXPECT_EQ(WebInputEventResult::HandledSystem, webView->handleInputEvent(event)); } +TEST_F(WebViewTest, LongPressEmptyEditableSelection) +{ + URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), + WebString::fromUTF8("long_press_empty_editable_selection.html")); + + WebViewImpl* webView = m_webViewHelper.initializeAndLoad( + m_baseURL + "long_press_empty_editable_selection.html", true); + webView->resize(WebSize(500, 300)); + webView->updateAllLifecyclePhases(); + runPendingTasks(); + + WebGestureEvent event; + event.type = WebInputEvent::GestureLongPress; + event.sourceDevice = WebGestureDeviceTouchscreen; + event.x = 10; + event.y = 10; + + EXPECT_EQ(WebInputEventResult::HandledSystem, webView->handleInputEvent(event)); +} + TEST_F(WebViewTest, LongPressSelection) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("longpress_selection.html"));
diff --git a/third_party/WebKit/Source/web/tests/data/long_press_empty_editable_selection.html b/third_party/WebKit/Source/web/tests/data/long_press_empty_editable_selection.html new file mode 100644 index 0000000..347c768 --- /dev/null +++ b/third_party/WebKit/Source/web/tests/data/long_press_empty_editable_selection.html
@@ -0,0 +1 @@ +<input>
diff --git a/third_party/WebKit/Source/wtf/DequeTest.cpp b/third_party/WebKit/Source/wtf/DequeTest.cpp index 99b2662..114afbb9 100644 --- a/third_party/WebKit/Source/wtf/DequeTest.cpp +++ b/third_party/WebKit/Source/wtf/DequeTest.cpp
@@ -218,7 +218,7 @@ EXPECT_EQ(0u, deque.size()); EXPECT_EQ(1, destructNumber); - ownCounter1.clear(); + ownCounter1.reset(); EXPECT_EQ(2, destructNumber); size_t count = 1025;
diff --git a/third_party/WebKit/Source/wtf/HashMapTest.cpp b/third_party/WebKit/Source/wtf/HashMapTest.cpp index 3ba8e67..25207ff 100644 --- a/third_party/WebKit/Source/wtf/HashMapTest.cpp +++ b/third_party/WebKit/Source/wtf/HashMapTest.cpp
@@ -135,7 +135,7 @@ EXPECT_EQ(0UL, map.size()); EXPECT_EQ(1, destructNumber); - ownCounter1.clear(); + ownCounter1.reset(); EXPECT_EQ(2, destructNumber); }
diff --git a/third_party/WebKit/Source/wtf/VectorTest.cpp b/third_party/WebKit/Source/wtf/VectorTest.cpp index 74c6fe9..11e508c0 100644 --- a/third_party/WebKit/Source/wtf/VectorTest.cpp +++ b/third_party/WebKit/Source/wtf/VectorTest.cpp
@@ -206,7 +206,7 @@ ASSERT_EQ(0u, vector.size()); ASSERT_EQ(1, destructNumber); - ownCounter1.clear(); + ownCounter1.reset(); EXPECT_EQ(2, destructNumber); size_t count = 1025;
diff --git a/third_party/WebKit/Source/wtf/text/StringImpl.cpp b/third_party/WebKit/Source/wtf/text/StringImpl.cpp index a37127b..1fcfd6b 100644 --- a/third_party/WebKit/Source/wtf/text/StringImpl.cpp +++ b/third_party/WebKit/Source/wtf/text/StringImpl.cpp
@@ -2292,12 +2292,10 @@ return equalIgnoringASCIICase(a->characters16(), b->characters16(), length); } -bool equalIgnoringASCIICase(const StringImpl* a, const LChar* b) +bool equalIgnoringASCIICase(const StringImpl* a, const LChar* b, unsigned length) { if (!a || !b) return !a == !b; - size_t length = strlen(reinterpret_cast<const char*>(b)); - CHECK_LE(length, numeric_limits<unsigned>::max()); if (length != a->length()) return false; return equalSubstringIgnoringASCIICase(a, 0, b, length);
diff --git a/third_party/WebKit/Source/wtf/text/StringImpl.h b/third_party/WebKit/Source/wtf/text/StringImpl.h index eaf077a7..a851385b 100644 --- a/third_party/WebKit/Source/wtf/text/StringImpl.h +++ b/third_party/WebKit/Source/wtf/text/StringImpl.h
@@ -488,8 +488,8 @@ WTF_EXPORT bool equalIgnoringCase(const StringImpl*, const StringImpl*); WTF_EXPORT bool equalIgnoringCase(const StringImpl*, const LChar*); inline bool equalIgnoringCase(const LChar* a, const StringImpl* b) { return equalIgnoringCase(b, a); } -WTF_EXPORT bool equalIgnoringCase(const LChar*, const LChar*, unsigned); -WTF_EXPORT bool equalIgnoringCase(const UChar*, const LChar*, unsigned); +WTF_EXPORT bool equalIgnoringCase(const LChar*, const LChar*, unsigned length); +WTF_EXPORT bool equalIgnoringCase(const UChar*, const LChar*, unsigned length); inline bool equalIgnoringCase(const UChar* a, const char* b, unsigned length) { return equalIgnoringCase(a, reinterpret_cast<const LChar*>(b), length); } inline bool equalIgnoringCase(const LChar* a, const UChar* b, unsigned length) { return equalIgnoringCase(b, a, length); } inline bool equalIgnoringCase(const char* a, const UChar* b, unsigned length) { return equalIgnoringCase(b, reinterpret_cast<const LChar*>(a), length); } @@ -514,7 +514,14 @@ } WTF_EXPORT bool equalIgnoringASCIICase(const StringImpl*, const StringImpl*); -WTF_EXPORT bool equalIgnoringASCIICase(const StringImpl*, const LChar*); +WTF_EXPORT bool equalIgnoringASCIICase(const StringImpl*, const LChar*, unsigned length); +inline bool equalIgnoringASCIICase(const StringImpl* a, const char* b, unsigned length) { return equalIgnoringASCIICase(a, reinterpret_cast<const LChar*>(b), length); } +inline bool equalIgnoringASCIICase(const StringImpl* a, const LChar* b) +{ + size_t length = b ? strlen(reinterpret_cast<const char*>(b)) : 0; + return equalIgnoringASCIICase(a, b, length); +} +inline bool equalIgnoringASCIICase(const StringImpl* a, const char* b) { return equalIgnoringASCIICase(a, reinterpret_cast<const LChar*>(b)); } WTF_EXPORT int codePointCompareIgnoringASCIICase(const StringImpl*, const LChar*);
diff --git a/third_party/WebKit/Source/wtf/text/WTFString.h b/third_party/WebKit/Source/wtf/text/WTFString.h index 8d01437..f07c96d 100644 --- a/third_party/WebKit/Source/wtf/text/WTFString.h +++ b/third_party/WebKit/Source/wtf/text/WTFString.h
@@ -503,6 +503,8 @@ inline bool equalIgnoringCase(const char* a, const String& b) { return equalIgnoringCase(reinterpret_cast<const LChar*>(a), b.impl()); } inline bool equalIgnoringASCIICase(const String& a, const String& b) { return equalIgnoringASCIICase(a.impl(), b.impl()); } +inline bool equalIgnoringASCIICase(const String& a, const LChar* b) { return equalIgnoringASCIICase(a.impl(), b); } +inline bool equalIgnoringASCIICase(const String& a, const char* b) { return equalIgnoringASCIICase(a.impl(), b); } inline bool equalPossiblyIgnoringCase(const String& a, const String& b, bool ignoreCase) {
diff --git a/third_party/closure_compiler/externs/file_manager_private.js b/third_party/closure_compiler/externs/file_manager_private.js index ce3e0af..0a7f1ed 100644 --- a/third_party/closure_compiler/externs/file_manager_private.js +++ b/third_party/closure_compiler/externs/file_manager_private.js
@@ -682,3 +682,11 @@ /** @type {!ChromeEvent} */ chrome.fileManagerPrivate.onDriveSyncError; + +/** @enum {string} */ +chrome.fileManagerPrivate.Verb = { + OPEN_WITH: 'open_with', + ADD_TO: 'add_to', + PACK_WITH: 'pack_with', + SHARE_WITH: 'share_with', +};
diff --git a/third_party/closure_compiler/externs/system_display.js b/third_party/closure_compiler/externs/system_display.js index 60a492a..82f8db80 100644 --- a/third_party/closure_compiler/externs/system_display.js +++ b/third_party/closure_compiler/externs/system_display.js
@@ -126,6 +126,42 @@ chrome.system.display.enableUnifiedDesktop = function(enabled) {}; /** + * Starts overscan calibration for a display. This will show an overlay on the + * screen indicating the current overscan insets. + * @param {string} id The display's unique identifier. + * @see https://developer.chrome.com/extensions/system.display#method-overscanCalibrationStart + */ +chrome.system.display.overscanCalibrationStart = function(id) {}; + +/** + * Adjusts the current overscan insets for a display. Typically this should + * etiher move the display along an axis (e.g. left+right have the same value) + * or scale it along an axis (e.g. top+bottom have opposite values). Each Adjust + * call is cumulative with previous calls since Start. + * @param {string} id The display's unique identifier. + * @param {!chrome.system.display.Insets} delta The amount to change the + * overscan insets. + * @see https://developer.chrome.com/extensions/system.display#method-overscanCalibrationAdjust + */ +chrome.system.display.overscanCalibrationAdjust = function(id, delta) {}; + +/** + * Resets the overscan insets for a display to the last saved value (i.e before + * Start was called). + * @param {string} id The display's unique identifier. + * @see https://developer.chrome.com/extensions/system.display#method-overscanCalibrationReset + */ +chrome.system.display.overscanCalibrationReset = function(id) {}; + +/** + * Complete overscan adjustments for a display by saving the current values and + * hiding the overlay. + * @param {string} id The display's unique identifier. + * @see https://developer.chrome.com/extensions/system.display#method-overscanCalibrationComplete + */ +chrome.system.display.overscanCalibrationComplete = function(id) {}; + +/** * Fired when anything changes to the display configuration. * @type {!ChromeEvent} * @see https://developer.chrome.com/extensions/system.display#event-onDisplayChanged
diff --git a/third_party/closure_compiler/interfaces/system_display_interface.js b/third_party/closure_compiler/interfaces/system_display_interface.js index 23c9615..402fe9c 100644 --- a/third_party/closure_compiler/interfaces/system_display_interface.js +++ b/third_party/closure_compiler/interfaces/system_display_interface.js
@@ -47,6 +47,42 @@ * @see https://developer.chrome.com/extensions/system.display#method-enableUnifiedDesktop */ enableUnifiedDesktop: assertNotReached, + + /** + * Starts overscan calibration for a display. This will show an overlay on the + * screen indicating the current overscan insets. + * @param {string} id The display's unique identifier. + * @see https://developer.chrome.com/extensions/system.display#method-overscanCalibrationStart + */ + overscanCalibrationStart: assertNotReached, + + /** + * Adjusts the current overscan insets for a display. Typically this should + * etiher move the display along an axis (e.g. left+right have the same value) + * or scale it along an axis (e.g. top+bottom have opposite values). Each + * Adjust call is cumulative with previous calls since Start. + * @param {string} id The display's unique identifier. + * @param {!chrome.system.display.Insets} delta The amount to change the + * overscan insets. + * @see https://developer.chrome.com/extensions/system.display#method-overscanCalibrationAdjust + */ + overscanCalibrationAdjust: assertNotReached, + + /** + * Resets the overscan insets for a display to the last saved value (i.e + * before Start was called). + * @param {string} id The display's unique identifier. + * @see https://developer.chrome.com/extensions/system.display#method-overscanCalibrationReset + */ + overscanCalibrationReset: assertNotReached, + + /** + * Complete overscan adjustments for a display by saving the current values + * and hiding the overlay. + * @param {string} id The display's unique identifier. + * @see https://developer.chrome.com/extensions/system.display#method-overscanCalibrationComplete + */ + overscanCalibrationComplete: assertNotReached, }; /**
diff --git a/third_party/polymer/v1_0/bower.json b/third_party/polymer/v1_0/bower.json index 0ca92a7..71ba2f5 100644 --- a/third_party/polymer/v1_0/bower.json +++ b/third_party/polymer/v1_0/bower.json
@@ -2,7 +2,8 @@ "name": "chromium", "private": true, "dependencies": { - "carbon-route": "PolymerElements/carbon-route#^0.8.4", + "app-layout": "PolymerElements/app-layout#^0.9.0", + "app-route": "PolymerElements/app-route#^0.9.0", "font-roboto": "PolymerElements/font-roboto#^1.0.0", "iron-a11y-announcer": "PolymerElements/iron-a11y-announcer#^1.0.4", "iron-a11y-keys-behavior": "PolymerElements/iron-a11y-keys-behavior#^1.0.0",
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-box/app-box-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-box/app-box-extracted.js new file mode 100644 index 0000000..674db91 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-box/app-box-extracted.js
@@ -0,0 +1,93 @@ +Polymer({ + is: 'app-box', + + behaviors: [ + Polymer.AppScrollEffectsBehavior, + Polymer.IronResizableBehavior + ], + + listeners: { + 'iron-resize': '_resizeHandler' + }, + + /** + * The current scroll progress. + * + * @type {number} + */ + _progress: 0, + + attached: function() { + this.resetLayout(); + }, + + /** + * Resets the layout. This method is automatically called when the element is attached to the DOM. + * + * @method resetLayout + */ + resetLayout: function() { + this.debounce('_resetLayout', function() { + // noop if the box isn't in the rendered tree + if (this.offsetWidth === 0 && this.offsetHeight === 0) { + return; + } + + var scrollTop = this._clampedScrollTop; + var savedDisabled = this.disabled; + + this.disabled = true; + this._elementTop = this._getElementTop(); + this._elementHeight = this.offsetHeight; + this._cachedScrollTargetHeight = this._scrollTargetHeight; + this._setUpEffect(); + this._updateScrollState(scrollTop); + this.disabled = savedDisabled; + }, 1); + }, + + _getElementTop: function() { + var currentNode = this; + var top = 0; + + while (currentNode && currentNode !== this.scrollTarget) { + top += currentNode.offsetTop; + currentNode = currentNode.offsetParent; + } + return top; + }, + + _updateScrollState: function(scrollTop) { + if (this.isOnScreen()) { + var viewportTop = this._elementTop - scrollTop; + this._progress = 1 - (viewportTop + this._elementHeight) / this._cachedScrollTargetHeight; + this._runEffects(this._progress, scrollTop); + } + }, + + /** + * Returns true if this app-box is on the screen. + * That is, visible in the current viewport. + * + * @method isOnScreen + * @return {boolean} + */ + isOnScreen: function() { + return this._elementTop < this._scrollTop + this._cachedScrollTargetHeight + && this._elementTop + this._elementHeight > this._scrollTop; + }, + + _resizeHandler: function() { + this.resetLayout(); + }, + + /** + * Returns an object containing the progress value of the scroll effects. + * + * @method getScrollState + * @return {Object} + */ + getScrollState: function() { + return { progress: this._progress }; + } + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-box/app-box.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-box/app-box.html new file mode 100644 index 0000000..8b9314b3 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-box/app-box.html
@@ -0,0 +1,114 @@ +<!-- +@license +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../../polymer/polymer.html"> +<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html"> +<link rel="import" href="../../iron-resizable-behavior/iron-resizable-behavior.html"> +<link rel="import" href="../app-scroll-effects/app-scroll-effects-behavior.html"> + +<!-- +app-box is a container element that can have scroll effects - visual effects based on +scroll position. For example, the parallax effect can be used to move an image at a slower +rate than the foreground. + +```html +<app-box style="height: 100px;" effects="parallax-background"> + <img background src="picture.png" style="width: 100%; height: 600px;"> +</app-box> +``` + +Notice the `background` attribute in the `img` element; this attribute specifies that that image is used as the background. +By adding the background to the light dom, you can compose backgrounds that can change dynamically. +Alternatively, the mixin `--app-box-background-front-layer` allows to style the background. For example: + +```css + .parallaxAppBox { + --app-box-background-front-layer: { + background-image: url(picture.png); + }; + } +``` + +Finally, app-box can have content inside. For example: + +```html +<app-box effects="parallax-background"> + <h2>Sub title</h2> +</app-box> +``` + +## Scroll effects + +Effect name | Description +----------------|------------- +`parallax-background` | A parallax effect + +## Styling + +Mixin | Description | Default +----------------|-------------|---------- +`--app-box-background-front-layer` | Applies to the front layer of the background | {} + +@group App Elements +@element app-box +@demo app-box/demo/document-scroll.html Document Scroll +@demo app-box/demo/scrolling-region.html Scrolling Region +--> + +</head><body><dom-module id="app-box"> + <template> + <style> + :host { + position: relative; + + display: block; + } + + #background { + @apply(--layout-fit); + + overflow: hidden; + + height: 100%; + } + + #backgroundFrontLayer { + min-height: 100%; + + pointer-events: none; + + background-size: cover; + + @apply(--app-box-background-front-layer); + } + + #contentContainer { + position: relative; + + width: 100%; + height: 100%; + } + + :host([disabled]), + :host([disabled]) #backgroundFrontLayer { + transition: none !important; + } + </style> + + <div id="background"> + <div id="backgroundFrontLayer"> + <content select="[background]"></content> + </div> + </div> + <div id="contentContainer"> + <content id="content"></content> + </div> + </template> + + </dom-module> +<script src="app-box-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-box/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-layout/app-box/compiled_resources2.gyp new file mode 100644 index 0000000..b846327 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-box/compiled_resources2.gyp
@@ -0,0 +1,17 @@ +# 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. +# +# NOTE: Created with generate_compiled_resources_gyp.py, please do not edit. +{ + 'targets': [ + { + 'target_name': 'app-box-extracted', + 'dependencies': [ + '../../iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted', + '../app-scroll-effects/compiled_resources2.gyp:app-scroll-effects-behavior-extracted', + ], + 'includes': ['../../../../../closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer-layout/app-drawer-layout-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer-layout/app-drawer-layout-extracted.js new file mode 100644 index 0000000..e303e94 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer-layout/app-drawer-layout-extracted.js
@@ -0,0 +1,90 @@ +Polymer({ + is: 'app-drawer-layout', + + behaviors: [ + Polymer.IronResizableBehavior + ], + + properties: { + /** + * If true, ignore `responsiveWidth` setting and force the narrow layout. + */ + forceNarrow: { + type: Boolean, + value: false + }, + + /** + * If the viewport's width is smaller than this value, the panel will change to narrow layout. + * In the mode the drawer will be closed. + */ + responsiveWidth: { + type: String, + value: '640px' + }, + + _narrow: Boolean + }, + + listeners: { + 'tap': '_tapHandler', + 'app-drawer-reset-layout': 'resetLayout' + }, + + observers: [ + 'resetLayout(_narrow, isAttached)' + ], + + /** + * A reference to the app-drawer element. + * + * @property drawer + */ + get drawer() { + return Polymer.dom(this.$.drawerContent).getDistributedNodes()[0]; + }, + + _tapHandler: function(e) { + var target = Polymer.dom(e).localTarget; + if (target && target.hasAttribute('drawer-toggle')) { + this.drawer.toggle(); + } + }, + + resetLayout: function() { + this.debounce('_resetLayout', function() { + if (!this.isAttached) { + return; + } + + var drawer = this.drawer; + var drawerWidth = this.drawer.getWidth(); + var contentContainer = this.$.contentContainer; + + if (this._narrow) { + drawer.opened = drawer.persistent = false; + contentContainer.classList.add('narrow'); + + contentContainer.style.marginLeft = ''; + contentContainer.style.marginRight = ''; + } else { + drawer.opened = drawer.persistent = true; + contentContainer.classList.remove('narrow'); + + if (drawer.position == 'right') { + contentContainer.style.marginLeft = ''; + contentContainer.style.marginRight = drawerWidth + 'px'; + } else { + contentContainer.style.marginLeft = drawerWidth + 'px'; + contentContainer.style.marginRight = ''; + } + } + + this.notifyResize(); + }); + }, + + _computeMediaQuery: function(forceNarrow, responsiveWidth) { + return forceNarrow ? '(min-width: 0px)' : '(max-width: ' + responsiveWidth + ')'; + } + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer-layout/app-drawer-layout.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer-layout/app-drawer-layout.html new file mode 100644 index 0000000..7008187 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer-layout/app-drawer-layout.html
@@ -0,0 +1,125 @@ +<!-- +@license +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../../polymer/polymer.html"> +<link rel="import" href="../../iron-media-query/iron-media-query.html"> +<link rel="import" href="../../iron-resizable-behavior/iron-resizable-behavior.html"> +<link rel="import" href="../app-drawer/app-drawer.html"> + +<!-- +app-drawer-layout is a wrapper element that positions an app-drawer and other content. When +the viewport width is smaller than `responsiveWidth`, this element changes to narrow layout. +In narrow layout, the drawer will be stacked on top of the main content. The drawer will slide +in/out to hide/reveal the main content. + +By default the drawer is aligned to the start, which is left in LTR layouts: + +```html +<app-drawer-layout> + <app-drawer> + drawer content + </app-drawer> + <div> + main content + </div> +</app-drawer-layout> +``` + +Align the drawer at the end: + +```html +<app-drawer-layout> + <app-drawer align="end"> + drawer content + </app-drawer> + <div> + main content + </div> +</app-drawer-layout> +``` + +With an app-header-layout: + +```html +<app-drawer-layout> + <app-drawer> + drawer-content + </app-drawer> + <app-header-layout> + <app-header> + <app-toolbar> + <div title>App name</div> + </app-toolbar> + </app-header> + + main content + + </app-header-layout> +</app-drawer-layout> +``` + +Add the `fullbleed` attribute to app-drawer-layout to make it fit the size of its container: + +```html +<app-drawer-layout fullbleed> + <app-drawer> + drawer content + </app-drawer> + <div> + main content + </div> +</app-drawer-layout> +``` + +### Styling + +Custom property | Description | Default +-----------------------------------------|--------------------------------------|--------- +`--app-drawer-layout-content-transition` | Transition for the content container | none + +@group App Elements +@element app-drawer-layout +@demo app-drawer-layout/demo/simple-drawer.html Simple Demo +@demo app-drawer-layout/demo/two-drawers.html Two drawers +--> + +</head><body><dom-module id="app-drawer-layout"> + <template> + <style> + :host { + display: block; + } + + :host([fullbleed]) { + @apply(--layout-fit); + } + + #contentContainer { + position: relative; + + height: 100%; + + transition: var(--app-drawer-layout-content-transition, none); + } + + #contentContainer:not(.narrow) > ::content [drawer-toggle] { + display: none; + } + </style> + + <div id="contentContainer"> + <content select=":not(app-drawer)"></content> + </div> + + <content id="drawerContent" select="app-drawer"></content> + + <iron-media-query query="[[_computeMediaQuery(forceNarrow, responsiveWidth)]]" query-matches="{{_narrow}}"></iron-media-query> + </template> + + </dom-module> +<script src="app-drawer-layout-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer-layout/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer-layout/compiled_resources2.gyp new file mode 100644 index 0000000..a607ca2 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer-layout/compiled_resources2.gyp
@@ -0,0 +1,18 @@ +# 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. +# +# NOTE: Created with generate_compiled_resources_gyp.py, please do not edit. +{ + 'targets': [ + { + 'target_name': 'app-drawer-layout-extracted', + 'dependencies': [ + '../../iron-media-query/compiled_resources2.gyp:iron-media-query-extracted', + '../../iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted', + '../app-drawer/compiled_resources2.gyp:app-drawer-extracted', + ], + 'includes': ['../../../../../closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer/app-drawer-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer/app-drawer-extracted.js new file mode 100644 index 0000000..3b47d39 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer/app-drawer-extracted.js
@@ -0,0 +1,492 @@ +Polymer({ + is: 'app-drawer', + + properties: { + /** + * The opened state of the drawer. + */ + opened: { + type: Boolean, + value: false, + notify: true, + reflectToAttribute: true + }, + + /** + * The drawer does not have a scrim and cannot be swiped close. + */ + persistent: { + type: Boolean, + value: false, + reflectToAttribute: true + }, + + /** + * The alignment of the drawer on the screen ('left', 'right', 'start' or 'end'). + * 'start' computes to left and 'end' to right in LTR layout and vice versa in RTL + * layout. + */ + align: { + type: String, + value: 'left' + }, + + /** + * The computed, read-only position of the drawer on the screen ('left' or 'right'). + */ + position: { + type: String, + readOnly: true, + value: 'left', + reflectToAttribute: true + }, + + /** + * Create an area at the edge of the screen to swipe open the drawer. + */ + swipeOpen: { + type: Boolean, + value: false, + reflectToAttribute: true + }, + + /** + * Trap keyboard focus when the drawer is opened and not persistent. + */ + noFocusTrap: { + type: Boolean, + value: false + } + }, + + observers: [ + 'resetLayout(position)', + '_resetPosition(align, isAttached)' + ], + + _translateOffset: 0, + + _trackDetails: null, + + _drawerState: 0, + + _boundEscKeydownHandler: null, + + _firstTabStop: null, + + _lastTabStop: null, + + ready: function() { + // Set the scroll direction so you can vertically scroll inside the drawer. + this.setScrollDirection('y'); + + // Only transition the drawer after its first render (e.g. app-drawer-layout + // may need to set the initial opened state which should not be transitioned). + this._setTransitionDuration('0s'); + }, + + attached: function() { + // Only transition the drawer after its first render (e.g. app-drawer-layout + // may need to set the initial opened state which should not be transitioned). + Polymer.RenderStatus.afterNextRender(this, function() { + this._setTransitionDuration(''); + this._boundEscKeydownHandler = this._escKeydownHandler.bind(this); + this._resetDrawerState(); + + this.listen(this, 'track', '_track'); + this.addEventListener('transitionend', this._transitionend.bind(this)); + this.addEventListener('keydown', this._tabKeydownHandler.bind(this)) + }); + }, + + detached: function() { + document.removeEventListener('keydown', this._boundEscKeydownHandler); + }, + + /** + * Opens the drawer. + */ + open: function() { + this.opened = true; + }, + + /** + * Closes the drawer. + */ + close: function() { + this.opened = false; + }, + + /** + * Toggles the drawer open and close. + */ + toggle: function() { + this.opened = !this.opened; + }, + + /** + * Gets the width of the drawer. + * + * @return {number} The width of the drawer in pixels. + */ + getWidth: function() { + return this.$.contentContainer.offsetWidth; + }, + + /** + * Resets the layout. If you changed the size of app-header via CSS + * you can notify the changes by either firing the `iron-resize` event + * or calling `resetLayout` directly. + * + * @method resetLayout + */ + resetLayout: function() { + this.debounce('_resetLayout', function() { + this.fire('app-drawer-reset-layout'); + }, 1); + }, + + _isRTL: function() { + return window.getComputedStyle(this).direction === 'rtl'; + }, + + _resetPosition: function() { + switch (this.align) { + case 'start': + this._setPosition(this._isRTL() ? 'right' : 'left'); + return; + case 'end': + this._setPosition(this._isRTL() ? 'left' : 'right'); + return; + } + this._setPosition(this.align); + }, + + _escKeydownHandler: function(event) { + var ESC_KEYCODE = 27; + if (event.keyCode === ESC_KEYCODE) { + // Prevent any side effects if app-drawer closes. + event.preventDefault(); + this.close(); + } + }, + + _track: function(event) { + if (this.persistent) { + return; + } + + // Disable user selection on desktop. + event.preventDefault(); + + switch (event.detail.state) { + case 'start': + this._trackStart(event); + break; + case 'track': + this._trackMove(event); + break; + case 'end': + this._trackEnd(event); + break; + } + }, + + _trackStart: function(event) { + this._drawerState = this._DRAWER_STATE.TRACKING; + + // Disable transitions since style attributes will reflect user track events. + this._setTransitionDuration('0s'); + this.style.visibility = 'visible'; + + var rect = this.$.contentContainer.getBoundingClientRect(); + if (this.position === 'left') { + this._translateOffset = rect.left; + } else { + this._translateOffset = rect.right - window.innerWidth; + } + + this._trackDetails = []; + }, + + _trackMove: function(event) { + this._translateDrawer(event.detail.dx + this._translateOffset); + + // Use Date.now() since event.timeStamp is inconsistent across browsers (e.g. most + // browsers use milliseconds but FF 44 uses microseconds). + this._trackDetails.push({ + dx: event.detail.dx, + timeStamp: Date.now() + }); + }, + + _trackEnd: function(event) { + var x = event.detail.dx + this._translateOffset; + var drawerWidth = this.getWidth(); + var isPositionLeft = this.position === 'left'; + var isInEndState = isPositionLeft ? (x >= 0 || x <= -drawerWidth) : + (x <= 0 || x >= drawerWidth); + + if (!isInEndState) { + // No longer need the track events after this method returns - allow them to be GC'd. + var trackDetails = this._trackDetails; + this._trackDetails = null; + + this._flingDrawer(event, trackDetails); + if (this._drawerState === this._DRAWER_STATE.FLINGING) { + return; + } + } + + // If the drawer is not flinging, toggle the opened state based on the position of + // the drawer. + var halfWidth = drawerWidth / 2; + if (event.detail.dx < -halfWidth) { + this.opened = this.position === 'right'; + } else if (event.detail.dx > halfWidth) { + this.opened = this.position === 'left'; + } + + // Trigger app-drawer-transitioned now since there will be no transitionend event. + if (isInEndState) { + this._resetDrawerState(); + } + + this._setTransitionDuration(''); + this._resetDrawerTranslate(); + this.style.visibility = ''; + }, + + _calculateVelocity: function(event, trackDetails) { + // Find the oldest track event that is within 100ms using binary search. + var now = Date.now(); + var timeLowerBound = now - 100; + var trackDetail; + var min = 0; + var max = trackDetails.length - 1; + + while (min <= max) { + // Floor of average of min and max. + var mid = (min + max) >> 1; + var d = trackDetails[mid]; + if (d.timeStamp >= timeLowerBound) { + trackDetail = d; + max = mid - 1; + } else { + min = mid + 1; + } + } + + if (trackDetail) { + var dx = event.detail.dx - trackDetail.dx; + var dt = (now - trackDetail.timeStamp) || 1; + return dx / dt; + } + return 0; + }, + + _flingDrawer: function(event, trackDetails) { + var velocity = this._calculateVelocity(event, trackDetails); + + // Do not fling if velocity is not above a threshold. + if (Math.abs(velocity) < this._MIN_FLING_THRESHOLD) { + return; + } + + this._drawerState = this._DRAWER_STATE.FLINGING; + + var x = event.detail.dx + this._translateOffset; + var drawerWidth = this.getWidth(); + var isPositionLeft = this.position === 'left'; + var isVelocityPositive = velocity > 0; + var isClosingLeft = !isVelocityPositive && isPositionLeft; + var isClosingRight = isVelocityPositive && !isPositionLeft; + var dx; + if (isClosingLeft) { + dx = -(x + drawerWidth); + } else if (isClosingRight) { + dx = (drawerWidth - x); + } else { + dx = -x; + } + + // Enforce a minimum transition velocity to make the drawer feel snappy. + if (isVelocityPositive) { + velocity = Math.max(velocity, this._MIN_TRANSITION_VELOCITY); + this.opened = this.position === 'left'; + } else { + velocity = Math.min(velocity, -this._MIN_TRANSITION_VELOCITY); + this.opened = this.position === 'right'; + } + + // Calculate the amount of time needed to finish the transition based on the + // initial slope of the timing function. + this._setTransitionDuration((this._FLING_INITIAL_SLOPE * dx / velocity) + 'ms'); + this._setTransitionTimingFunction(this._FLING_TIMING_FUNCTION); + + this._resetDrawerTranslate(); + }, + + _transitionend: function(event) { + // contentContainer will transition on opened state changed, and scrim will + // transition on persistent state changed when opened - these are the + // transitions we are interested in. + var target = Polymer.dom(event).rootTarget; + if (target === this.$.contentContainer || target === this.$.scrim) { + + // If the drawer was flinging, we need to reset the style attributes. + if (this._drawerState === this._DRAWER_STATE.FLINGING) { + this._setTransitionDuration(''); + this._setTransitionTimingFunction(''); + this.style.visibility = ''; + } + + this._resetDrawerState(); + } + }, + + _setTransitionDuration: function(duration) { + this.$.contentContainer.style.transitionDuration = duration; + this.$.scrim.style.transitionDuration = duration; + }, + + _setTransitionTimingFunction: function(timingFunction) { + this.$.contentContainer.style.transitionTimingFunction = timingFunction; + this.$.scrim.style.transitionTimingFunction = timingFunction; + }, + + _translateDrawer: function(x) { + var drawerWidth = this.getWidth(); + + if (this.position === 'left') { + x = Math.max(-drawerWidth, Math.min(x, 0)); + this.$.scrim.style.opacity = 1 + x / drawerWidth; + } else { + x = Math.max(0, Math.min(x, drawerWidth)); + this.$.scrim.style.opacity = 1 - x / drawerWidth; + } + + this.translate3d(x + 'px', '0', '0', this.$.contentContainer); + }, + + _resetDrawerTranslate: function() { + this.$.scrim.style.opacity = ''; + this.transform('', this.$.contentContainer); + }, + + _resetDrawerState: function() { + var oldState = this._drawerState; + if (this.opened) { + this._drawerState = this.persistent ? + this._DRAWER_STATE.OPENED_PERSISTENT : this._DRAWER_STATE.OPENED; + } else { + this._drawerState = this._DRAWER_STATE.CLOSED; + } + + if (oldState !== this._drawerState) { + if (this._drawerState === this._DRAWER_STATE.OPENED) { + this._setKeyboardFocusTrap(); + document.addEventListener('keydown', this._boundEscKeydownHandler); + document.body.style.overflow = 'hidden'; + } else { + document.removeEventListener('keydown', this._boundEscKeydownHandler); + document.body.style.overflow = ''; + } + + // Don't fire the event on initial load. + if (oldState !== this._DRAWER_STATE.INIT) { + this.fire('app-drawer-transitioned'); + } + } + }, + + _setKeyboardFocusTrap: function() { + if (this.noFocusTrap) { + return; + } + + // NOTE: Unless we use /deep/ (which we shouldn't since it's deprecated), this will + // not select focusable elements inside shadow roots. + var focusableElementsSelector = [ + 'a[href]:not([tabindex="-1"])', + 'area[href]:not([tabindex="-1"])', + 'input:not([disabled]):not([tabindex="-1"])', + 'select:not([disabled]):not([tabindex="-1"])', + 'textarea:not([disabled]):not([tabindex="-1"])', + 'button:not([disabled]):not([tabindex="-1"])', + 'iframe:not([tabindex="-1"])', + '[tabindex]:not([tabindex="-1"])', + '[contentEditable=true]:not([tabindex="-1"])' + ].join(','); + var focusableElements = Polymer.dom(this).querySelectorAll(focusableElementsSelector); + + if (focusableElements.length > 0) { + this._firstTabStop = focusableElements[0]; + this._lastTabStop = focusableElements[focusableElements.length - 1]; + } else { + // Reset saved tab stops when there are no focusable elements in the drawer. + this._firstTabStop = null; + this._lastTabStop = null; + } + + // Focus on app-drawer if it has non-zero tabindex. Otherwise, focus the first focusable + // element in the drawer, if it exists. Use the tabindex attribute since the this.tabIndex + // property in IE/Edge returns 0 (instead of -1) when the attribute is not set. + var tabindex = this.getAttribute('tabindex'); + if (tabindex && parseInt(tabindex, 10) > -1) { + this.focus(); + } else if (this._firstTabStop) { + this._firstTabStop.focus(); + } + }, + + _tabKeydownHandler: function(event) { + if (this.noFocusTrap) { + return; + } + + var TAB_KEYCODE = 9; + if (this._drawerState === this._DRAWER_STATE.OPENED && event.keyCode === TAB_KEYCODE) { + if (event.shiftKey) { + if (this._firstTabStop && Polymer.dom(event).localTarget === this._firstTabStop) { + event.preventDefault(); + this._lastTabStop.focus(); + } + } else { + if (this._lastTabStop && Polymer.dom(event).localTarget === this._lastTabStop) { + event.preventDefault(); + this._firstTabStop.focus(); + } + } + } + }, + + _MIN_FLING_THRESHOLD: 0.2, + + _MIN_TRANSITION_VELOCITY: 1.2, + + _FLING_TIMING_FUNCTION: 'cubic-bezier(0.667, 1, 0.667, 1)', + + _FLING_INITIAL_SLOPE: 1.5, + + _DRAWER_STATE: { + INIT: 0, + OPENED: 1, + OPENED_PERSISTENT: 2, + CLOSED: 3, + TRACKING: 4, + FLINGING: 5 + } + + /** + * Fired when the layout of app-drawer has changed. + * + * @event app-drawer-reset-layout + */ + + /** + * Fired when app-drawer has finished transitioning. + * + * @event app-drawer-transitioned + */ + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer/app-drawer.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer/app-drawer.html new file mode 100644 index 0000000..94c54b79 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer/app-drawer.html
@@ -0,0 +1,172 @@ +<!-- +@license +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../../polymer/polymer.html"> +<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html"> + +<!-- +app-drawer is a navigation drawer that can slide in from the left or right. + +Example: + +Align the drawer at the start, which is left in LTR layouts (default): + +```html +<app-drawer opened></app-drawer> +``` + +Align the drawer at the end: + +```html +<app-drawer align="end" opened></app-drawer> +``` + +To make the contents of the drawer scrollable, create a wrapper for the scroll +content, and apply height and overflow styles to it. + +```html +<app-drawer> + <div style="height: 100%; overflow: auto;"></div> +</app-drawer> +``` + +### Styling + +Custom property | Description | Default +---------------------------------|----------------------------------------|-------------------- +`--app-drawer-width` | Width of the drawer | 256px +`--app-drawer-content-container` | Mixin for the drawer content container | {} +`--app-drawer-scrim-background` | Background for the scrim | rgba(0, 0, 0, 0.5) + +@group App Elements +@element app-drawer +@demo app-drawer/demo/left-drawer.html Simple Left Drawer +@demo app-drawer/demo/right-drawer.html Right Drawer with Icons +--> + +</head><body><dom-module id="app-drawer"> + <template> + <style> + :host { + position: fixed; + top: -120px; + right: 0; + bottom: -120px; + left: 0; + + visibility: hidden; + + transition: visibility 0.2s ease; + } + + :host([opened]) { + visibility: visible; + } + + :host([persistent]) { + width: var(--app-drawer-width, 256px); + } + + :host([persistent][position=left]) { + right: auto; + } + + :host([persistent][position=right]) { + left: auto; + } + + #contentContainer { + position: absolute; + top: 0; + bottom: 0; + left: 0; + + width: var(--app-drawer-width, 256px); + padding: 120px 0; + + transition: 0.2s ease; + transition-property: -webkit-transform; + transition-property: transform; + -webkit-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + + background-color: #FFF; + + @apply(--app-drawer-content-container); + } + + :host([position=right]) > #contentContainer { + right: 0; + left: auto; + + -webkit-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + } + + :host([swipe-open]) > #contentContainer::after { + position: fixed; + top: 0; + bottom: 0; + left: 100%; + + visibility: visible; + + width: 20px; + + content: ''; + } + + :host([swipe-open][position=right]) > #contentContainer::after { + right: 100%; + left: auto; + } + + :host([opened]) > #contentContainer { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + } + + #scrim { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + + transition: opacity 0.2s ease; + -webkit-transform: translateZ(0); + transform: translateZ(0); + + opacity: 0; + background: var(--app-drawer-scrim-background, rgba(0, 0, 0, 0.5)); + } + + :host([opened]) > #scrim { + opacity: 1; + } + + :host([opened][persistent]) > #scrim { + visibility: hidden; + /** + * NOTE(keanulee): Keep both opacity: 0 and visibility: hidden to prevent the + * scrim from showing when toggling between closed and opened/persistent. + */ + + opacity: 0; + } + </style> + + <div id="scrim" on-tap="close"></div> + + <div id="contentContainer"> + <content></content> + </div> + </template> + + </dom-module> +<script src="app-drawer-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer/compiled_resources2.gyp new file mode 100644 index 0000000..10b46ba --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-drawer/compiled_resources2.gyp
@@ -0,0 +1,13 @@ +# 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. +# +# NOTE: Created with generate_compiled_resources_gyp.py, please do not edit. +{ + 'targets': [ + { + 'target_name': 'app-drawer-extracted', + 'includes': ['../../../../../closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-header-layout/app-header-layout-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-header-layout/app-header-layout-extracted.js new file mode 100644 index 0000000..4935acd --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-header-layout/app-header-layout-extracted.js
@@ -0,0 +1,98 @@ +Polymer({ + is: 'app-header-layout', + + behaviors: [ + Polymer.IronResizableBehavior + ], + + properties: { + /** + * If true, the current element will have its own scrolling region. + * Otherwise, it will use the document scroll to control the header. + */ + hasScrollingRegion: { + type: Boolean, + value: false, + reflectToAttribute: true + } + }, + + listeners: { + 'iron-resize': '_resizeHandler', + 'app-header-reset-layout': 'resetLayout' + }, + + observers: [ + 'resetLayout(isAttached, hasScrollingRegion)' + ], + + /** + * A reference to the app-header element. + * + * @property header + */ + get header() { + return Polymer.dom(this.$.header).getDistributedNodes()[0]; + }, + + /** + * Resets the layout. This method is automatically called when the element is attached + * to the DOM. + * + * @method resetLayout + */ + resetLayout: function() { + this._updateScroller(); + this.debounce('_resetLayout', this._updateContentPosition); + }, + + _updateContentPosition: function() { + var header = this.header; + if (!this.isAttached || !header) { + return; + } + + // Get header height here so that style reads are batched together before style writes + // (i.e. getBoundingClientRect() below). + var headerHeight = header.offsetHeight; + + // Update the header position. + if (!this.hasScrollingRegion) { + var rect = this.getBoundingClientRect(); + var rightOffset = document.documentElement.clientWidth - rect.right; + header.style.left = rect.left + 'px'; + header.style.right = rightOffset + 'px'; + } else { + header.style.left = ''; + header.style.right = ''; + } + + // Update the content container position. + var containerStyle = this.$.contentContainer.style; + if (header.fixed && !header.willCondense() && this.hasScrollingRegion) { + // If the header size does not change and we're using a scrolling region, exclude + // the header area from the scrolling region so that the header doesn't overlap + // the scrollbar. + containerStyle.marginTop = headerHeight + 'px'; + containerStyle.paddingTop = ''; + } else { + containerStyle.paddingTop = headerHeight + 'px'; + containerStyle.marginTop = ''; + } + }, + + _updateScroller: function() { + if (!this.isAttached) { + return; + } + var header = this.header; + if (header) { + header.scrollTarget = this.hasScrollingRegion ? + this.$.contentContainer : this.ownerDocument.documentElement; + } + }, + + _resizeHandler: function() { + this.resetLayout(); + } + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-header-layout/app-header-layout.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-header-layout/app-header-layout.html new file mode 100644 index 0000000..2060b9dc --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-header-layout/app-header-layout.html
@@ -0,0 +1,107 @@ +<!-- +@license +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../../polymer/polymer.html"> +<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html"> +<link rel="import" href="../../iron-resizable-behavior/iron-resizable-behavior.html"> + +<!-- +app-header-layout is a wrapper element that positions an app-header and other content. This +element uses the document scroll by default, but it can also define its own scrolling region. + +Using the document scroll: + +```html +<app-header-layout> + <app-header fixed condenses effects="waterfall"> + <app-toolbar> + <div title>App name</div> + </app-toolbar> + </app-header> + <div> + main content + </div> +</app-header-layout> +``` + +Using an own scrolling region: + +```html +<app-header-layout has-scrolling-region style="width: 300px; height: 400px;"> + <app-header fixed condenses effects="waterfall"> + <app-toolbar> + <div title>App name</div> + </app-toolbar> + </app-header> + <div> + main content + </div> +</app-header-layout> +``` + +@group App Elements +@element app-header-layout +@demo app-header-layout/demo/simple.html Simple Demo +@demo app-header-layout/demo/scrolling-region.html Scrolling Region +@demo app-header-layout/demo/music.html Music Demo +--> + +</head><body><dom-module id="app-header-layout"> + <template> + <style> + :host { + display: block; + + /** + * Force app-header-layout to have its own stacking context so that its parent can + * control the stacking of it relative to other elements (e.g. app-drawer-layout). + * This could be done using `isolation: isolate`, but that's not well supported + * across browsers. + */ + position: relative; + z-index: 0; + } + + :host([has-scrolling-region]) { + height: 100%; + } + + :host > ::content > app-header { + @apply(--layout-fixed-top); + + z-index: 1; + } + + :host([has-scrolling-region]) > ::content > app-header { + position: absolute; + } + + #contentContainer { + /* Create a stacking context here so that all children appear below the header. */ + position: relative; + z-index: 0; + } + + :host([has-scrolling-region]) > #contentContainer { + @apply(--layout-fit); + + overflow-y: auto; + -webkit-overflow-scrolling: touch; + } + </style> + + <content id="header" select="app-header"></content> + + <div id="contentContainer"> + <content></content> + </div> + + </template> + + </dom-module> +<script src="app-header-layout-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-header-layout/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-layout/app-header-layout/compiled_resources2.gyp new file mode 100644 index 0000000..211d335 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-header-layout/compiled_resources2.gyp
@@ -0,0 +1,16 @@ +# 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. +# +# NOTE: Created with generate_compiled_resources_gyp.py, please do not edit. +{ + 'targets': [ + { + 'target_name': 'app-header-layout-extracted', + 'dependencies': [ + '../../iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted', + ], + 'includes': ['../../../../../closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-header/app-header-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-header/app-header-extracted.js new file mode 100644 index 0000000..0774a14 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-header/app-header-extracted.js
@@ -0,0 +1,364 @@ +Polymer({ + is: 'app-header', + + behaviors: [ + Polymer.AppScrollEffectsBehavior, + Polymer.IronResizableBehavior + ], + + properties: { + /** + * If true, the header will automatically collapse when scrolling down. + * That is, the `primary` element remains visible when the header is fully condensed + * whereas the rest of the elements will collapse below `primary` element. + * + * By default, the `primary` element is the first toolbar in the light DOM: + * + *```html + * <app-header condenses> + * <app-toolbar>This toolbar remains on top</app-toolbar> + * <app-toolbar></app-toolbar> + * <app-toolbar></app-toolbar> + * </app-header> + * ``` + * + * Additionally, you can specify which toolbar or element remains visible in condensed mode + * by adding the `primary` attribute to that element. For example: if we want the last + * toolbar to remain visible, we can add the `primary` attribute to it. + * + *```html + * <app-header condenses> + * <app-toolbar></app-toolbar> + * <app-toolbar></app-toolbar> + * <app-toolbar primary>This toolbar remains on top</app-toolbar> + * </app-header> + * ``` + * + * Note the `primary` element must be a child of `app-header`. + */ + condenses: { + type: Boolean, + value: false + }, + + /** + * Mantains the header fixed at the top so it never moves away. + */ + fixed: { + type: Boolean, + value: false + }, + + /** + * Slides back the header when scrolling back up. + */ + reveals: { + type: Boolean, + value: false + }, + + /** + * Displays a shadow below the header. + */ + shadow: { + type: Boolean, + reflectToAttribute: true, + value: false + } + }, + + observers: [ + 'resetLayout(isAttached, condenses, fixed)' + ], + + listeners: { + 'iron-resize': '_resizeHandler' + }, + + /** + * A cached offsetHeight of the current element. + * + * @type {number} + */ + _height: 0, + + /** + * The distance in pixels the header will be translated to when scrolling. + * + * @type {number} + */ + _dHeight: 0, + + /** + * The offsetTop of `_primaryEl` + * + * @type {number} + */ + _primaryElTop: 0, + + /** + * The element that remains visible when the header condenses. + * + * @type {HTMLElement} + */ + _primaryEl: null, + + /** + * The header's top value used for the `transformY` + * + * @type {number} + */ + _top: 0, + + /** + * The current scroll progress. + * + * @type {number} + */ + _progress: 0, + + _wasScrollingDown: false, + _initScrollTop: 0, + _initTimestamp: 0, + _lastTimestamp: 0, + _lastScrollTop: 0, + + /** + * The distance the header is allowed to move away. + * + * @type {number} + */ + get _maxHeaderTop() { + return this.fixed ? this._dHeight : this._height + 5; + }, + + /** + * Returns a reference to the element that remains visible when the header condenses. + * + * @return {HTMLElement}? + */ + _getPrimaryEl: function() { + /** @type {HTMLElement} */ + var primaryEl; + var nodes = Polymer.dom(this.$.content).getDistributedNodes(); + + for (var i = 0; i < nodes.length; i++) { + if (nodes[i].nodeType === Node.ELEMENT_NODE) { + var node = /** @type {HTMLElement} */ (nodes[i]); + if (node.hasAttribute('primary')) { + primaryEl = node; + break; + } else if (!primaryEl) { + primaryEl = node; + } + } + } + return primaryEl; + }, + + /** + * Resets the layout. If you changed the size of app-header via CSS + * you can notify the changes by either firing the `iron-resize` event + * or calling `resetLayout` directly. + * + * @method resetLayout + */ + resetLayout: function() { + this.fire('app-header-reset-layout'); + + this.debounce('_resetLayout', function() { + // noop if the header isn't visible + if (this.offsetWidth === 0 && this.offsetHeight === 0) { + return; + } + + var scrollTop = this._clampedScrollTop; + var firstSetup = this._height === 0 || scrollTop === 0; + var currentDisabled = this.disabled; + + this._height = this.offsetHeight; + this._primaryEl = this._getPrimaryEl(); + this.disabled = true; + + // prepare for measurement + if (!firstSetup) { + this._updateScrollState(0, true); + } + + if (this._mayMove()) { + this._dHeight = this._primaryEl ? this._height - this._primaryEl.offsetHeight : 0; + } else { + this._dHeight = 0; + } + + this._primaryElTop = this._primaryEl ? this._primaryEl.offsetTop : 0; + this._setUpEffect(); + + if (firstSetup) { + this._updateScrollState(scrollTop, true); + } else { + this._updateScrollState(this._lastScrollTop, true); + this._layoutIfDirty(); + } + // restore no transition + this.disabled = currentDisabled; + }); + }, + + /** + * Updates the scroll state. + * + * @param {number} scrollTop + * @param {boolean=} forceUpdate (default: false) + */ + _updateScrollState: function(scrollTop, forceUpdate) { + if (this._height === 0) { + return; + } + + var progress = 0; + var top = 0; + var lastTop = this._top; + var lastScrollTop = this._lastScrollTop; + var maxHeaderTop = this._maxHeaderTop; + var dScrollTop = scrollTop - this._lastScrollTop; + var absDScrollTop = Math.abs(dScrollTop); + var isScrollingDown = scrollTop > this._lastScrollTop; + var now = Date.now(); + + if (this._mayMove()) { + top = this._clamp(this.reveals ? lastTop + dScrollTop : scrollTop, 0, maxHeaderTop); + } + + if (scrollTop >= this._dHeight) { + top = this.condenses ? Math.max(this._dHeight, top) : top; + this.style.transitionDuration = '0ms'; + } + + if (this.reveals && !this.disabled && absDScrollTop < 100) { + // set the initial scroll position + if (now - this._initTimestamp > 300 || this._wasScrollingDown !== isScrollingDown) { + this._initScrollTop = scrollTop; + this._initTimestamp = now; + } + + if (scrollTop >= maxHeaderTop) { + // check if the header is allowed to snap + if (Math.abs(this._initScrollTop - scrollTop) > 30 || absDScrollTop > 10) { + if (isScrollingDown && scrollTop >= maxHeaderTop) { + top = maxHeaderTop; + } else if (!isScrollingDown && scrollTop >= this._dHeight) { + top = this.condenses ? this._dHeight : 0; + } + + var scrollVelocity = dScrollTop / (now - this._lastTimestamp); + this.style.transitionDuration = this._clamp((top - lastTop) / scrollVelocity, 0, 300) + 'ms'; + } else { + top = this._top; + } + } + } + + if (this._dHeight === 0) { + progress = scrollTop > 0 ? 1 : 0; + } else { + progress = top / this._dHeight; + } + + if (!forceUpdate) { + this._lastScrollTop = scrollTop; + this._top = top; + this._wasScrollingDown = isScrollingDown; + this._lastTimestamp = now; + } + + if (forceUpdate || progress !== this._progress || lastTop !== top || scrollTop === 0) { + this._progress = progress; + this._runEffects(progress, top); + this._transformHeader(top); + } + }, + + /** + * Returns true if the current header is allowed to move as the user scrolls. + * + * @return {boolean} + */ + _mayMove: function() { + return this.condenses || !this.fixed; + }, + + /** + * Returns true if the current header will condense based on the size of the header + * and the `consenses` property. + * + * @return {boolean} + */ + willCondense: function() { + return this._dHeight > 0 && this.condenses; + }, + + /** + * Returns true if the current element is on the screen. + * That is, visible in the current viewport. + * + * @method isOnScreen + * @return {boolean} + */ + isOnScreen: function() { + return this._height !== 0 && this._top < this._height; + }, + + /** + * Returns true if there's content below the current element. + * + * @method isContentBelow + * @return {boolean} + */ + isContentBelow: function() { + if (this._top === 0) { + return this._clampedScrollTop > 0; + } + + return this._clampedScrollTop - this._maxHeaderTop >= 0; + }, + + /** + * Transforms the header. + * + * @param {number} y + */ + _transformHeader: function(y) { + this.translate3d(0, (-y) + 'px', 0); + + if (this._primaryEl && this.condenses && y >= this._primaryElTop) { + this.translate3d(0, (Math.min(y, this._dHeight) - this._primaryElTop) + 'px', 0, + this._primaryEl); + } + }, + + _resizeHandler: function() { + this.resetLayout(); + }, + + _clamp: function(v, min, max) { + return Math.min(max, Math.max(min, v)); + }, + + /** + * Returns an object containing the progress value of the scroll effects + * and the top position of the header. + * + * @method getScrollState + * @return {Object} + */ + getScrollState: function() { + return { progress: this._progress, top: this._top }; + } + + /** + * Fires when the layout of `app-header` changed. + * + * @event app-header-reset-layout + */ + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-header/app-header.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-header/app-header.html new file mode 100644 index 0000000..c69ff882 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-header/app-header.html
@@ -0,0 +1,336 @@ +<!-- +@license +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../../polymer/polymer.html"> +<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html"> +<link rel="import" href="../../iron-resizable-behavior/iron-resizable-behavior.html"> +<link rel="import" href="../app-scroll-effects/app-scroll-effects-behavior.html"> + +<!-- +app-header is container element for app-toolbars at the top of the screen that can have scroll +effects. By default, an app-header moves away from the viewport when scrolling down and +if using `reveals`, the header slides back when scrolling back up. For example: + +```html +<app-header reveals> + <app-toolbar> + <div title>App name</div> + </app-toolbar> +</app-header> +``` + +app-header can also condense when scrolling down. To achieve this behavior, the header +must have a larger height than the `primary` element in the light DOM. For example: + +```html +<app-header style="height: 96px;" condenses fixed> + <app-toolbar style="height: 64px;"> + <div title>App name</div> + </app-toolbar> +</app-header> +``` + +In this case the header is initially `96px` tall, and it shrinks to `64px` when scrolling down. +That is what is meant by "condensing". + +### Primary element + +As the header condenses, the immediate children of app-header are stacked up. +In this case, the primary element is the immediate child that would always stayed above +the others as the header condenses. By default, the `primary` element is the first app-toolbar +that is an immediate children of app-header. + +```html +<app-header condenses> + <app-toolbar> Primary element </app-toolbar> +</app-header> +``` + +```html +<app-header condenses> + <app-toolbar></app-toolbar> + <app-toolbar primary> Primary element </app-toolbar> +</app-header> +``` + +The primary element must be a direct child of app-header. + +### Scroll target + +The app-header's `scrollTarget` property allows to customize the scrollable element to which +the header responds when the user scrolls. By default, app-header uses the document as +the scroll target, but you can customize this property by setting the id of the element, e.g. + +```html +<div id="scrollingRegion" style="overflow-y: auto;"> + <app-header scroll-target="scrollingRegion"> + </app-header> +</div> +``` + +In this case, the `scrollTarget` property points to the outer div element. Alternatively, +you can set this property programmatically: + +```js +appHeader.scrollTarget = document.querySelector("#scrollingRegion"); +``` + +## Backgrounds +app-header has two background layers that can be used for styling when the header is condensed +or when the scrollable element is scrolled to the top. + +## Scroll effects + +Scroll effects are _optional_ visual effects applied in app-header based on scroll position. For example, +The [Material Design scrolling techniques](https://www.google.com/design/spec/patterns/scrolling-techniques.html) +recommends effects that can be installed via the `effects` property. e.g. + +```html +<app-header effects="waterfall"> + <app-toolbar>App name</app-toolbar> +</app-header> +``` + +#### Importing the effects + +To use the scroll effects, you must explicitly import them in addition to `app-header`: + +```html +<link rel="import" href="/bower_components/app-layout/app-scroll-effects/app-scroll-effects.html"> +``` + +#### List of effects + +* **blend-background** +Fades in/out two background elements by applying CSS opacity based on scroll position. +You can use this effect to smoothly change the background color or image of the header. +For example, using the mixin `--app-header-background-rear-layer` lets you assign a different +background when the header is condensed: + +```css +app-header { + background-color: red; + --app-header-background-rear-layer: { + /* The header is blue when condensed */ + background-color: blue; + }; +} +``` + +* **fade-background** +Upon scrolling past a threshold, this effect will trigger an opacity transition to +fade in/out the backgrounds. Compared to the `blend-background` effect, +this effect doesn't interpolate the opacity based on scroll position. + + +* **parallax-background** +A simple parallax effect that vertically translates the backgrounds based on a fraction +of the scroll position. For example: + +```css +app-header { + --app-header-background-front-layer: { + background-image: url(...); + }; +} +``` +```html +<app-header style="height: 300px;" effects="parallax-background"> + <app-toolbar>App name</app-toolbar> +</app-header> +``` + +The fraction determines how far the background moves relative to the scroll position. +This value can be assigned via the `scalar` config value and it is typically a value +between 0 and 1 inclusive. If `scalar=0`, the background doesn't move away from the header. + +* **resize-title** +Progressively interpolates the size of the title from the element with the `title` attribute +to the element with the `condensed-title` attribute as the header condenses. For example: + +```html +<app-header condenses reveals effects="resize-title"> + <app-toolbar> + <h4 condensed-title>App name</h4> + </app-toolbar> + <app-toolbar> + <h1 title>App name</h1> + </app-toolbar> +</app-header> +``` + +* **resize-snapped-title** +Upon scrolling past a threshold, this effect fades in/out the titles using opacity transitions. +Similarly to `resize-title`, the `title` and `condensed-title` elements must be placed in the +light DOM. + +* **waterfall** +Toggles the shadow property in app-header to create a sense of depth (as recommended in the +MD spec) between the header and the underneath content. You can change the shadow by +customizing the `--app-header-shadow` mixin. For example: + +```css +app-header { + --app-header-shadow: { + box-shadow: inset 0px 5px 2px -3px rgba(0, 0, 0, 0.2); + }; +} +``` + +```html +<app-header condenses reveals effects="waterfall"> + <app-toolbar> + <h1 title>App name</h1> + </app-toolbar> +</app-header> +``` + +* **material** +Installs the waterfall, resize-title, blend-background and parallax-background effects. + +### Content attributes + +Attribute | Description | Default +----------|---------------------|---------------------------------------- +`primary` | Element that remains at the top when the header condenses. | The first app-toolbar in the light DOM. + + +## Styling + +Mixin | Description | Default +------|-------------|---------- +`--app-header-background-front-layer` | Applies to the front layer of the background. | {} +`--app-header-background-rear-layer` | Applies to the rear layer of the background. | {} +`--app-header-shadow` | Applies to the shadow. | {} + +@group App Elements +@element app-header +@demo app-header/demo/blend-background-1.html Blend Background Image +@demo app-header/demo/blend-background-2.html Blend 2 Background Images +@demo app-header/demo/blend-background-3.html Blend Background Colors +@demo app-header/demo/contacts.html Contacts Demo +@demo app-header/demo/give.html Resize Snapped Title Demo +@demo app-header/demo/music.html Reveals Demo +@demo app-header/demo/no-effects.html Condenses and Reveals Demo +@demo app-header/demo/notes.html Fixed with Dynamic Shadow Demo +--> + +</head><body><dom-module id="app-header"> + <template> + <style> + :host { + position: relative; + + display: block; + + transition-timing-function: linear; + transition-property: -webkit-transform; + transition-property: transform; + } + + :host::after { + position: absolute; + right: 0px; + bottom: -5px; + left: 0px; + + width: 100%; + height: 5px; + + content: ""; + transition: opacity 0.4s; + pointer-events: none; + + opacity: 0; + box-shadow: inset 0px 5px 6px -3px rgba(0, 0, 0, 0.4); + + will-change: opacity; + + @apply(--app-header-shadow); + } + + :host([shadow])::after { + opacity: 1; + } + + #contentContainer > ::content [condensed-title] { + -webkit-transform-origin: left top; + transform-origin: left top; + white-space: nowrap; + + opacity: 0; + } + + #contentContainer > ::content [title] { + -webkit-transform-origin: left top; + transform-origin: left top; + white-space: nowrap; + } + + #background { + @apply(--layout-fit); + + overflow: hidden; + } + + #backgroundFrontLayer, + #backgroundRearLayer { + @apply(--layout-fit); + + height: 100%; + + pointer-events: none; + + background-size: cover; + } + + #backgroundFrontLayer { + @apply(--app-header-background-front-layer); + } + + #backgroundRearLayer { + opacity: 0; + + @apply(--app-header-background-rear-layer); + } + + #contentContainer { + position: relative; + + width: 100%; + height: 100%; + } + + :host([disabled]), + :host([disabled])::after, + :host([disabled]) #backgroundFrontLayer, + :host([disabled]) #backgroundRearLayer, + :host([disabled]) ::content > app-toolbar:first-of-type, + :host([disabled]) ::content > [primary], + /* Silent scrolling should not run CSS transitions */ + :host-context(.app-layout-silent-scroll), + :host-context(.app-layout-silent-scroll)::after, + :host-context(.app-layout-silent-scroll) #backgroundFrontLayer, + :host-context(.app-layout-silent-scroll) #backgroundRearLayer, + :host-context(.app-layout-silent-scroll) ::content > app-toolbar:first-of-type, + :host-context(.app-layout-silent-scroll) ::content > [primary] { + transition: none !important; + } + </style> + + <div id="background"> + <div id="backgroundRearLayer"></div> + <div id="backgroundFrontLayer"></div> + </div> + <div id="contentContainer"> + <content id="content"></content> + </div> + </template> + + </dom-module> +<script src="app-header-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-header/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-layout/app-header/compiled_resources2.gyp new file mode 100644 index 0000000..69011cf --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-header/compiled_resources2.gyp
@@ -0,0 +1,17 @@ +# 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. +# +# NOTE: Created with generate_compiled_resources_gyp.py, please do not edit. +{ + 'targets': [ + { + 'target_name': 'app-header-extracted', + 'dependencies': [ + '../../iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted', + '../app-scroll-effects/compiled_resources2.gyp:app-scroll-effects-behavior-extracted', + ], + 'includes': ['../../../../../closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-layout.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-layout.html new file mode 100644 index 0000000..98da6e0 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-layout.html
@@ -0,0 +1,18 @@ +<!-- +@license +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--> + +<link rel="import" href="helpers/helpers.html"> +<link rel="import" href="app-drawer-layout/app-drawer-layout.html"> +<link rel="import" href="app-drawer/app-drawer.html"> +<link rel="import" href="app-header/app-header.html"> +<link rel="import" href="app-header-layout/app-header-layout.html"> +<link rel="import" href="app-scrollpos-control/app-scrollpos-control.html"> +<link rel="import" href="app-toolbar/app-toolbar.html"> +<link rel="import" href="app-box/app-box.html">
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/app-scroll-effects-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/app-scroll-effects-behavior-extracted.js new file mode 100644 index 0000000..b9ea1dc --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/app-scroll-effects-behavior-extracted.js
@@ -0,0 +1,338 @@ +/** + * `Polymer.AppScrollEffectsBehavior` provides an interface that allows an element to use scrolls effects. + * + * ### Importing the app-layout effects + * + * app-layout provides a set of scroll effects that can be used by explicitly importing + * `app-scroll-effects.html`: + * + * ```html + * <link rel="import" href="/bower_components/app-layout/app-scroll-effects/app-scroll-effects.html"> + * ``` + * + * The scroll effects can also be used by individually importing + * `app-layout/app-scroll-effects/effects/[effectName].html`. For example: + * + * ```html + * <link rel="import" href="/bower_components/app-layout/app-scroll-effects/effects/waterfall.html"> + * ``` + * + * ### Consuming effects + * + * Effects can be consumed via the `effects` property. For example: + * + * ```html + * <app-header effects="waterfall"></app-header> + * ``` + * + * ### Creating scroll effects + * + * You may want to create a custom scroll effect if you need to modify the CSS of an element + * based on the scroll position. + * + * A scroll effect definition is an object with `setUp()`, `tearDown()` and `run()` functions. + * + * To register the effect, you can use `Polymer.AppLayout.registerEffect(effectName, effectDef)` + * For example, let's define an effect that resizes the header's logo: + * + * ```js + * Polymer.AppLayout.registerEffect('resizable-logo', { + * setUp: function(config) { + * // the effect's config is passed to the setUp. + * this._fxResizeLogo = { logo: Polymer.dom(this).querySelector('[logo]') }; + * }, + * + * run: function(progress) { + * // the progress of the effect + * this.transform('scale3d(' + progress + ', '+ progress +', 1)', this._fxResizeLogo.logo); + * }, + * + * tearDown: function() { + * // clean up and reset of states + * delete this._fxResizeLogo; + * } + * }); + * ``` + * Now, you can consume the effect: + * + * ```html + * <app-header id="appHeader" effects="resizable-logo"> + * <img logo src="logo.svg"> + * </app-header> + * ``` + * + * ### Imperative API + * + * ```js + * var logoEffect = appHeader.createEffect('resizable-logo', effectConfig); + * // run the effect: logoEffect.run(progress); + * // tear down the effect: logoEffect.tearDown(); + * ``` + * + * ### Configuring effects + * + * For effects installed via the `effects` property, their configuration can be set + * via the `effectsConfig` property. For example: + * + * ```html + * <app-header effects="waterfall" + * effects-config='{"waterfall": {"startsAt": 0, "endsAt": 0.5}}'> + * </app-header> + * ``` + * + * All effects have a `startsAt` and `endsAt` config property. They specify at what + * point the effect should start and end. This value goes from 0 to 1 inclusive. + * + * @polymerBehavior + */ + Polymer.AppScrollEffectsBehavior = [ + Polymer.IronScrollTargetBehavior, + { + + properties: { + + /** + * A space-separated list of the effects names that will be triggered when the user scrolls. + * e.g. `waterfall parallax-background` installs the `waterfall` and `parallax-background`. + */ + effects: { + type: String + }, + + /** + * An object that configurates the effects installed via the `effects` property. e.g. + * ```js + * element.effectsConfig = { + * "blend-background": { + * "startsAt": 0.5 + * } + * }; + * ``` + * Every effect has at least two config properties: `startsAt` and `endsAt`. + * These properties indicate when the event should start and end respectively + * and relative to the overall element progress. So for example, if `blend-background` + * starts at `0.5`, the effect will only start once the current element reaches 0.5 + * of its progress. In this context, the progress is a value in the range of `[0, 1]` + * that indicates where this element is on the screen relative to the viewport. + */ + effectsConfig: { + type: Object, + value: function() { + return {}; + } + }, + + /** + * Disables CSS transitions and scroll effects on the element. + */ + disabled: { + type: Boolean, + reflectToAttribute: true, + value: false + } + }, + + observers: [ + '_effectsChanged(effects, effectsConfig)' + ], + + /** + * Updates the scroll state. This method should be overridden + * by the consumer of this behavior. + * + * @method _updateScrollState + */ + _updateScrollState: function() {}, + + /** + * Returns true if the current element is on the screen. + * That is, visible in the current viewport. This method should be + * overridden by the consumer of this behavior. + * + * @method isOnScreen + * @return {boolean} + */ + isOnScreen: function() { + return false; + }, + + /** + * Returns true if there's content below the current element. This method + * should be overridden by the consumer of this behavior. + * + * @method isContentBelow + * @return {boolean} + */ + isContentBelow: function() { + return false; + }, + + /** + * List of effects handlers that will take place during scroll. + * + * @type {Array<Function>} + */ + _effectsRunFn: null, + + /** + * List of the effects definitions installed via the `effects` property. + * + * @type {Array<Object>} + */ + _effects: null, + + /** + * The clamped value of `_scrollTop`. + * @type number + */ + get _clampedScrollTop() { + return Math.max(0, this._scrollTop); + }, + + detached: function() { + this._tearDownEffects(); + }, + + /** + * Creates an effect object from an effect's name that can be used to run + * effects programmatically. + * + * @method createEffect + * @param {string} effectName The effect's name registered via `Polymer.AppLayout.registerEffect`. + * @param {Object=} effectConfig The effect config object. (Optional) + * @return {Object} An effect object with the following functions: + * + * * `effect.setUp()`, Sets up the requirements for the effect. + * This function is called automatically before the `effect` function returns. + * * `effect.run(progress, y)`, Runs the effect given a `progress`. + * * `effect.tearDown()`, Cleans up any DOM nodes or element references used by the effect. + * + * Example: + * ```js + * var parallax = element.createEffect('parallax-background'); + * // runs the effect + * parallax.run(0.5, 0); + * ``` + */ + createEffect: function(effectName, effectConfig) { + var effectDef = Polymer.AppLayout._scrollEffects[effectName]; + if (!effectDef) { + throw new ReferenceError(this._getUndefinedMsg(effectName)); + } + var prop = this._boundEffect(effectDef, effectConfig || {}); + prop.setUp(); + return prop; + }, + + /** + * Called when `effects` or `effectsConfig` changes. + */ + _effectsChanged: function(effects, effectsConfig) { + this._tearDownEffects(); + + if (effects === '') { + return; + } + effects.split(' ').forEach(function(effectName) { + var effectDef; + if (effectName !== '') { + if ((effectDef = Polymer.AppLayout._scrollEffects[effectName])) { + this._effects.push(this._boundEffect(effectDef, effectsConfig[effectName])); + } else { + this._warn(this._logf('_effectsChanged', this._getUndefinedMsg(effectName))); + } + } + }, this); + + this._setUpEffect(); + }, + + /** + * Forces layout + */ + _layoutIfDirty: function() { + return this.offsetWidth; + }, + + /** + * Returns an effect object bound to the current context. + * + * @param {Object} effectDef + * @param {Object=} effectsConfig The effect config object if the effect accepts config values. (Optional) + */ + _boundEffect: function(effectDef, effectsConfig) { + effectsConfig = effectsConfig || {}; + var startsAt = parseFloat(effectsConfig.startsAt || 0); + var endsAt = parseFloat(effectsConfig.endsAt || 1); + var deltaS = endsAt - startsAt; + var noop = Function(); + // fast path if possible + var runFn = (startsAt === 0 && endsAt === 1) ? effectDef.run : + function(progress, y) { + effectDef.run.call(this, + Math.max(0, (progress - startsAt) / deltaS), y); + }; + return { + setUp: effectDef.setUp ? effectDef.setUp.bind(this, effectsConfig) : noop, + run: effectDef.run ? runFn.bind(this) : noop, + tearDown: effectDef.tearDown ? effectDef.tearDown.bind(this) : noop + }; + }, + + /** + * Sets up the effects. + */ + _setUpEffect: function() { + if (this.isAttached && this._effects) { + this._effectsRunFn = []; + this._effects.forEach(function(effectDef) { + // install the effect only if no error was reported + if (effectDef.setUp() !== false) { + this._effectsRunFn.push(effectDef.run); + } + }, this); + } + }, + + /** + * Tears down the effects. + */ + _tearDownEffects: function() { + if (this._effects) { + this._effects.forEach(function(effectDef) { + effectDef.tearDown(); + }); + } + this._effectsRunFn = []; + this._effects = []; + }, + + /** + * Runs the effects. + * + * @param {number} p The progress + * @param {number} y The top position of the current element relative to the viewport. + */ + _runEffects: function(p, y) { + if (this._effectsRunFn) { + this._effectsRunFn.forEach(function(run) { + run(p, y); + }); + } + }, + + /** + * Overrides the `_scrollHandler`. + */ + _scrollHandler: function() { + if (!this.disabled) { + this._updateScrollState(this._clampedScrollTop); + } + }, + + _getUndefinedMsg: function(effectName) { + return 'Scroll effect `' + effectName + '` is undefined. ' + + 'Did you forget to import app-layout/app-scroll-effects/effects/' + effectName + '.html ?'; + } + + }]; \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/app-scroll-effects-behavior.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/app-scroll-effects-behavior.html new file mode 100644 index 0000000..9daa3fa2 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/app-scroll-effects-behavior.html
@@ -0,0 +1,13 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../../polymer/polymer.html"> +<link rel="import" href="../../iron-scroll-target-behavior/iron-scroll-target-behavior.html"> +<link rel="import" href="../helpers/helpers.html"> + +</head><body><script src="app-scroll-effects-behavior-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/app-scroll-effects.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/app-scroll-effects.html new file mode 100644 index 0000000..d61258f --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/app-scroll-effects.html
@@ -0,0 +1,17 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--> + +<link rel="import" href="effects/blend-background.html"> +<link rel="import" href="effects/fade-background.html"> +<link rel="import" href="effects/material.html"> +<link rel="import" href="effects/parallax-background.html"> +<link rel="import" href="effects/resize-snapped-title.html"> +<link rel="import" href="effects/resize-title.html"> +<link rel="import" href="effects/waterfall.html">
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/compiled_resources2.gyp new file mode 100644 index 0000000..2261750 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/compiled_resources2.gyp
@@ -0,0 +1,30 @@ +# 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. +# +# NOTE: Created with generate_compiled_resources_gyp.py, please do not edit. +{ + 'targets': [ + { + 'target_name': 'app-scroll-effects-behavior-extracted', + 'dependencies': [ + '../../iron-scroll-target-behavior/compiled_resources2.gyp:iron-scroll-target-behavior-extracted', + '../helpers/compiled_resources2.gyp:helpers-extracted', + ], + 'includes': ['../../../../../closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'app-scroll-effects-extracted', + 'dependencies': [ + 'effects/compiled_resources2.gyp:blend-background-extracted', + 'effects/compiled_resources2.gyp:fade-background-extracted', + 'effects/compiled_resources2.gyp:material-extracted', + 'effects/compiled_resources2.gyp:parallax-background-extracted', + 'effects/compiled_resources2.gyp:resize-snapped-title-extracted', + 'effects/compiled_resources2.gyp:resize-title-extracted', + 'effects/compiled_resources2.gyp:waterfall-extracted', + ], + 'includes': ['../../../../../closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/blend-background-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/blend-background-extracted.js new file mode 100644 index 0000000..e48b32a --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/blend-background-extracted.js
@@ -0,0 +1,19 @@ +/** + * While scrolling down, fade in the rear background layer and fade out the front background + * layer (opacity interpolated based on scroll position). + */ + Polymer.AppLayout.registerEffect('blend-background', { + /** @this Polymer.AppLayout.ElementWithBackground */ + setUp: function setUp() { + this.$.backgroundFrontLayer.style.willChange = 'opacity'; + this.$.backgroundFrontLayer.style.webkitTransform = 'translateZ(0)'; + this.$.backgroundRearLayer.style.willChange = 'opacity'; + this.$.backgroundRearLayer.style.webkitTransform = 'translateZ(0)'; + this.$.backgroundRearLayer.style.opacity = 0; + }, + /** @this Polymer.AppLayout.ElementWithBackground */ + run: function run(p, y) { + this.$.backgroundFrontLayer.style.opacity = 1 - p; + this.$.backgroundRearLayer.style.opacity = p; + } + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/blend-background.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/blend-background.html new file mode 100644 index 0000000..2434d69 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/blend-background.html
@@ -0,0 +1,11 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../app-scroll-effects-behavior.html"> + +</head><body><script src="blend-background-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/compiled_resources2.gyp new file mode 100644 index 0000000..3c66f75 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/compiled_resources2.gyp
@@ -0,0 +1,62 @@ +# 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. +# +# NOTE: Created with generate_compiled_resources_gyp.py, please do not edit. +{ + 'targets': [ + { + 'target_name': 'blend-background-extracted', + 'dependencies': [ + '../compiled_resources2.gyp:app-scroll-effects-behavior-extracted', + ], + 'includes': ['../../../../../../closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'fade-background-extracted', + 'dependencies': [ + '../compiled_resources2.gyp:app-scroll-effects-behavior-extracted', + ], + 'includes': ['../../../../../../closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'material-extracted', + 'dependencies': [ + '../compiled_resources2.gyp:app-scroll-effects-behavior-extracted', + 'blend-background-extracted', + 'parallax-background-extracted', + 'resize-title-extracted', + 'waterfall-extracted', + ], + 'includes': ['../../../../../../closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'parallax-background-extracted', + 'dependencies': [ + '../compiled_resources2.gyp:app-scroll-effects-behavior-extracted', + ], + 'includes': ['../../../../../../closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'resize-snapped-title-extracted', + 'dependencies': [ + '../compiled_resources2.gyp:app-scroll-effects-behavior-extracted', + ], + 'includes': ['../../../../../../closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'resize-title-extracted', + 'dependencies': [ + '../compiled_resources2.gyp:app-scroll-effects-behavior-extracted', + ], + 'includes': ['../../../../../../closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'waterfall-extracted', + 'dependencies': [ + '../compiled_resources2.gyp:app-scroll-effects-behavior-extracted', + ], + 'includes': ['../../../../../../closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/fade-background-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/fade-background-extracted.js new file mode 100644 index 0000000..ea2ac26f --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/fade-background-extracted.js
@@ -0,0 +1,28 @@ +/** + * Upon scrolling past a threshold, fade in the rear background layer and fade out the front + * background layer (opacity CSS transitioned over time). + */ + Polymer.AppLayout.registerEffect('fade-background', { + /** @this Polymer.AppLayout.ElementWithBackground */ + setUp: function setUp(config) { + var duration = config.duration || '0.5s'; + this.$.backgroundFrontLayer.style.willChange = 'opacity'; + this.$.backgroundFrontLayer.style.webkitTransform = 'translateZ(0)'; + this.$.backgroundFrontLayer.style.transitionProperty = 'opacity'; + this.$.backgroundFrontLayer.style.transitionDuration = duration; + this.$.backgroundRearLayer.style.willChange = 'opacity'; + this.$.backgroundRearLayer.style.webkitTransform = 'translateZ(0)'; + this.$.backgroundRearLayer.style.transitionProperty = 'opacity'; + this.$.backgroundRearLayer.style.transitionDuration = duration; + }, + /** @this Polymer.AppLayout.ElementWithBackground */ + run: function run(p, y) { + if (p >= 1) { + this.$.backgroundFrontLayer.style.opacity = 0; + this.$.backgroundRearLayer.style.opacity = 1; + } else { + this.$.backgroundFrontLayer.style.opacity = 1; + this.$.backgroundRearLayer.style.opacity = 0; + } + } + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/fade-background.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/fade-background.html new file mode 100644 index 0000000..d2bfa8db --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/fade-background.html
@@ -0,0 +1,11 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../app-scroll-effects-behavior.html"> + +</head><body><script src="fade-background-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/material-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/material-extracted.js new file mode 100644 index 0000000..6cf0eae --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/material-extracted.js
@@ -0,0 +1,12 @@ +/** + * Shorthand for the waterfall, resize-title, blend-background, and parallax-background effects. + */ + Polymer.AppLayout.registerEffect('material', { + /** + * @this Polymer.AppLayout.ElementWithBackground + */ + setUp: function setUp() { + this.effects = 'waterfall resize-title blend-background parallax-background'; + return false; + } + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/material.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/material.html new file mode 100644 index 0000000..4611ad0e --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/material.html
@@ -0,0 +1,15 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../app-scroll-effects-behavior.html"> +<link rel="import" href="waterfall.html"> +<link rel="import" href="resize-title.html"> +<link rel="import" href="blend-background.html"> +<link rel="import" href="parallax-background.html"> + +</head><body><script src="material-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/parallax-background-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/parallax-background-extracted.js new file mode 100644 index 0000000..06ed13a --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/parallax-background-extracted.js
@@ -0,0 +1,36 @@ +/** + * Vertically translate the background based on a factor of the scroll position. + */ + Polymer.AppLayout.registerEffect('parallax-background', { + /** + * @param {{scalar: string}} config + * @this Polymer.AppLayout.ElementWithBackground + */ + setUp: function setUp(config) { + var scalar = parseFloat(config.scalar); + + this._deltaBg = this.$.backgroundFrontLayer.offsetHeight - this.$.background.offsetHeight; + if (this._deltaBg === 0) { + if (isNaN(scalar)) { + scalar = 0.8; + } + this._deltaBg = this._dHeight * scalar; + } else { + if (isNaN(scalar)) { + scalar = 1; + } + this._deltaBg = this._deltaBg * scalar; + } + }, + /** @this Polymer.AppLayout.ElementWithBackground */ + tearDown: function tearDown() { + delete this._deltaBg; + }, + /** @this Polymer.AppLayout.ElementWithBackground */ + run: function run(p, y) { + this.transform('translate3d(0px, ' + (this._deltaBg * Math.min(1, p)) + 'px, 0px)', this.$.backgroundFrontLayer); + if (this.$.backgroundRearLayer) { + this.transform('translate3d(0px, ' + (this._deltaBg * Math.min(1, p)) + 'px, 0px)', this.$.backgroundRearLayer); + } + } + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/parallax-background.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/parallax-background.html new file mode 100644 index 0000000..d00f0fcc --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/parallax-background.html
@@ -0,0 +1,11 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../app-scroll-effects-behavior.html"> + +</head><body><script src="parallax-background-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-snapped-title-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-snapped-title-extracted.js new file mode 100644 index 0000000..37f656c --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-snapped-title-extracted.js
@@ -0,0 +1,51 @@ +/** + * Upon scrolling past a threshold, CSS transition the font size of a designated title element + * between two values. + */ + Polymer.AppLayout.registerEffect('resize-snapped-title', { + /** + * @this Polymer.AppLayout.ElementWithBackground + */ + setUp: function setUp(config) { + var title = Polymer.dom(this).querySelector('[title]'); + var condensedTitle = Polymer.dom(this).querySelector('[condensed-title]'); + var duration = config.duration || '0.2s'; + var fx = {}; + + if (!condensedTitle) { + this._warn(this._logf('effects[resize-snapped-title]', 'undefined `condensed-title`')); + return false; + } + if (!title) { + this._warn(this._logf('effects[resize-snapped-title]', 'undefined `title`')); + return false; + } + + title.style.transitionProperty = 'opacity'; + title.style.transitionDuration = duration; + condensedTitle.style.transitionProperty = 'opacity'; + condensedTitle.style.transitionDuration = duration; + + fx.condensedTitle = condensedTitle; + fx.title = title; + this._fxResizeSnappedTitle = fx; + }, + /** @this Polymer.AppLayout.ElementWithBackground */ + tearDown: function tearDown() { + var fx = this._fxResizeSnappedTitle; + fx.title.style.transition = ''; + fx.condensedTitle.style.transition = ''; + delete this._fxResizeSnappedTitle; + }, + /** @this Polymer.AppLayout.ElementWithBackground */ + run: function run(p, y) { + var fx = this._fxResizeSnappedTitle; + if (p > 0) { + fx.title.style.opacity = 0; + fx.condensedTitle.style.opacity = 1; + } else { + fx.title.style.opacity = 1; + fx.condensedTitle.style.opacity = 0; + } + } + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-snapped-title.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-snapped-title.html new file mode 100644 index 0000000..904523a --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-snapped-title.html
@@ -0,0 +1,11 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../app-scroll-effects-behavior.html"> + +</head><body><script src="resize-snapped-title-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-title-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-title-extracted.js new file mode 100644 index 0000000..68c59a5 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-title-extracted.js
@@ -0,0 +1,76 @@ +(function() { + function interpolate(progress, points, fn, ctx) { + fn.apply(ctx, points.map(function(point) { + return point[0] + (point[1] - point[0]) * progress; + })); + } + + /** + * Transform the font size of a designated title element between two values based on the scroll + * position. + */ + Polymer.AppLayout.registerEffect('resize-title', { + /** @this Polymer.AppLayout.ElementWithBackground */ + setUp: function setUp() { + var title = Polymer.dom(this).querySelector('[title]'); + var condensedTitle = Polymer.dom(this).querySelector('[condensed-title]'); + + if (!condensedTitle) { + this._warn(this._logf('effects[resize-title]', 'undefined `condensed-title`')); + return false; + } + if (!title) { + this._warn(this._logf('effects[resize-title]', 'undefined `title`')); + return false; + } + + condensedTitle.style.willChange = 'opacity'; + title.style.willChange = 'opacity'; + + condensedTitle.style.webkitTransform = 'translateZ(0)'; + title.style.webkitTransform = 'translateZ(0)'; + + var titleClientRect = title.getBoundingClientRect(); + var condensedTitleClientRect = condensedTitle.getBoundingClientRect(); + var fx = {}; + + fx.scale = parseInt(window.getComputedStyle(condensedTitle)['font-size'], 10) / + parseInt(window.getComputedStyle(title)['font-size'], 10); + fx.titleDX = titleClientRect.left - condensedTitleClientRect.left; + fx.titleDY = titleClientRect.top - condensedTitleClientRect.top; + fx.condensedTitle = condensedTitle; + fx.title = title; + + this._fxResizeTitle = fx; + }, + /** @this Polymer.AppLayout.ElementWithBackground */ + tearDown: function tearDown() { + delete this._fxResizeTitle; + }, + /** @this PolymerElement */ + run: function run(p, y) { + var fx = this._fxResizeTitle; + if (!this.condenses) { + y = 0; + } + if (p >= 1) { + fx.title.style.opacity = 0; + fx.condensedTitle.style.opacity = 1; + } else { + fx.title.style.opacity = 1; + fx.condensedTitle.style.opacity = 0; + } + + interpolate(Math.min(1, p), + [ + [1, fx.scale], + [0, -fx.titleDX], + [y, y-fx.titleDY] + ], + function(scale, translateX, translateY) { + this.transform('translate(' + translateX + 'px, ' + translateY + 'px) ' + + 'scale3d(' + scale + ', ' + scale + ', 1)', fx.title); + }, this); + } + }); + })(); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-title.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-title.html new file mode 100644 index 0000000..57ca057e --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-title.html
@@ -0,0 +1,11 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../app-scroll-effects-behavior.html"> + +</head><body><script src="resize-title-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/waterfall-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/waterfall-extracted.js new file mode 100644 index 0000000..a0b133ab --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/waterfall-extracted.js
@@ -0,0 +1,12 @@ +/** + * Toggles the shadow property in app-header when content is scrolled to create a sense of depth + * between the element and the content underneath. + */ + Polymer.AppLayout.registerEffect('waterfall', { + /** + * @this Polymer.AppLayout.ElementWithBackground + */ + run: function run(p, y) { + this.shadow = this.isOnScreen() && this.isContentBelow(); + } + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/waterfall.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/waterfall.html new file mode 100644 index 0000000..52eaa1b --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/waterfall.html
@@ -0,0 +1,11 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../app-scroll-effects-behavior.html"> + +</head><body><script src="waterfall-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/app-scrollpos-control-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/app-scrollpos-control-extracted.js new file mode 100644 index 0000000..7b38c2d --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/app-scrollpos-control-extracted.js
@@ -0,0 +1,54 @@ +Polymer({ + is: 'app-scrollpos-control', + + properties: { + /** + * The selected page. + */ + selected: { + type: String, + observer: '_selectedChanged' + }, + + /** + * Reset the scroll position to 0. + */ + reset: { + type: Boolean, + value: false + } + }, + + observers: [ + '_updateScrollPos(selected, reset)' + ], + + created: function() { + this._scrollposMap = {}; + }, + + _selectedChanged: function(selected, old) { + if (old != null) { + this._scrollposMap[old] = {x: window.pageXOffset, y: window.pageYOffset}; + } + }, + + _updateScrollPos: function(selected, reset) { + this.debounce('_updateScrollPos', function() { + var pos = this._scrollposMap[this.selected]; + if (pos != null && !this.reset) { + this._scrollTo(pos.x, pos.y); + } else { + this._scrollTo(0, 0); + } + }); + }, + + _scrollTo: function(x, y) { + Polymer.AppLayout.scroll({ + left: x, + top: y, + behavior: 'silent' + }); + } + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/app-scrollpos-control.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/app-scrollpos-control.html new file mode 100644 index 0000000..6e2e29b --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/app-scrollpos-control.html
@@ -0,0 +1,54 @@ +<!-- +@license +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../../polymer/polymer.html"> +<link rel="import" href="../helpers/helpers.html"> + +<!-- +app-scrollpos-control is a manager for saving and restoring the scroll position when multiple +pages are sharing the same document scroller. + +Example: + +```html +<app-scrollpos-control selected="{{page}}"></app-scrollpos-control> + +<app-drawer-layout> + + <app-drawer> + <paper-menu selected="{{page}}"> + <paper-item>Home</paper-item> + <paper-item>About</paper-item> + <paper-item>Schedule</paper-item> + <paper-item>Account</paper-item> + </paper-menu> + </app-drawer> + + <div> + <app-toolbar> + <paper-icon-button icon="menu" drawer-toggle></paper-icon-button> + </app-toolbar> + <iron-pages selected="{{page}}"> + <sample-content size="100"></sample-content> + <sample-content size="100"></sample-content> + <sample-content size="100"></sample-content> + <sample-content size="100"></sample-content> + </iron-pages> + </div> + +</app-drawer-layout> +``` + +@group App Elements +@element app-scrollpos-control +@demo app-scrollpos-control/demo/index.html +--> + +</head><body><dom-module id="app-scrollpos-control"> + </dom-module> +<script src="app-scrollpos-control-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/compiled_resources2.gyp new file mode 100644 index 0000000..b99a4ac --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/compiled_resources2.gyp
@@ -0,0 +1,16 @@ +# 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. +# +# NOTE: Created with generate_compiled_resources_gyp.py, please do not edit. +{ + 'targets': [ + { + 'target_name': 'app-scrollpos-control-extracted', + 'dependencies': [ + '../helpers/compiled_resources2.gyp:helpers-extracted', + ], + 'includes': ['../../../../../closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-toolbar/app-toolbar-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-toolbar/app-toolbar-extracted.js new file mode 100644 index 0000000..2c63eb0e --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-toolbar/app-toolbar-extracted.js
@@ -0,0 +1,3 @@ +Polymer({ + is: 'app-toolbar' + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-toolbar/app-toolbar.html b/third_party/polymer/v1_0/components-chromium/app-layout/app-toolbar/app-toolbar.html new file mode 100644 index 0000000..aafe9fe5 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-toolbar/app-toolbar.html
@@ -0,0 +1,115 @@ +<!-- +@license +Copyright (c) 2015 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../../polymer/polymer.html"> +<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html"> + +<!-- +app-toolbar is a horizontal toolbar containing items that can be used for +label, navigation, search and actions. + +### Example + +Add a title to the toolbar. + +```html +<app-toolbar> + <div title>App name</div> +</app-toolbar> +``` + +Add a button to the left and right side of the toolbar. + +```html +<app-toolbar> + <paper-icon-button icon="menu"></paper-icon-button> + <div title>App name</div> + <paper-icon-button icon="search"></paper-icon-button> +</app-toolbar> +``` + +You can use the attributes `top-item` or `bottom-item` to completely fit an element +to the top or bottom of the toolbar respectively. + +### Content attributes + +Attribute | Description +---------------------|--------------------------------------------------------- +`title` | The main title element. +`condensed-title` | The title element if used inside a condensed app-header. +`spacer` | Adds a left margin of `64px`. +`bottom-item` | Sticks the element to the bottom of the toolbar. +`top-item` | Sticks the element to the top of the toolbar. + +### Styling + +Custom property | Description | Default +-----------------------------|------------------------------|----------------------- +`--app-toolbar-font-size` | Toolbar font size | 20px + +@group App Elements +@element app-toolbar +@demo app-toolbar/demo/index.html +--> + +</head><body><dom-module id="app-toolbar"> + <template> + <style> + :host { + position: relative; + + @apply(--layout-horizontal); + @apply(--layout-center); + + height: 64px; + padding: 0 16px; + + pointer-events: none; + + font-size: var(--app-toolbar-font-size, 20px); + } + + :host > ::content > * { + pointer-events: auto; + } + + :host > ::content > paper-icon-button { + /* paper-icon-button/issues/33 */ + font-size: 0; + } + + :host > ::content > [title], + :host > ::content > [condensed-title] { + pointer-events: none; + @apply(--layout-flex); + } + + :host > ::content > [bottom-item] { + position: absolute; + right: 0; + bottom: 0; + left: 0; + } + + :host > ::content > [top-item] { + position: absolute; + top: 0; + right: 0; + left: 0; + } + + :host > ::content > [spacer] { + margin-left: 64px; + } + </style> + + <content></content> + </template> + + </dom-module> +<script src="app-toolbar-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-toolbar/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-layout/app-toolbar/compiled_resources2.gyp new file mode 100644 index 0000000..1c187ed4 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-toolbar/compiled_resources2.gyp
@@ -0,0 +1,13 @@ +# 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. +# +# NOTE: Created with generate_compiled_resources_gyp.py, please do not edit. +{ + 'targets': [ + { + 'target_name': 'app-toolbar-extracted', + 'includes': ['../../../../../closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/bower.json b/third_party/polymer/v1_0/components-chromium/app-layout/bower.json new file mode 100644 index 0000000..674ea3b --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/bower.json
@@ -0,0 +1,48 @@ +{ + "name": "app-layout", + "version": "0.9.0", + "description": "A set of layout elements for your app", + "authors": [ + "The Polymer Authors" + ], + "private": true, + "homepage": "https://github.com/PolymerLabs/app-layout", + "repository": { + "type": "git", + "url": "git://github.com/PolymerLabs/app-layout" + }, + "main": "app-layout.html", + "license": "http://polymer.github.io/LICENSE.txt", + "ignore": [], + "dependencies": { + "polymer": "polymer/polymer#^1.0.0", + "iron-flex-layout": "polymerelements/iron-flex-layout#^1.0.0", + "iron-media-query": "polymerelements/iron-media-query#^1.0.0", + "iron-resizable-behavior": "polymerelements/iron-resizable-behavior#^1.0.0", + "iron-scroll-target-behavior": "polymerelements/iron-scroll-target-behavior#^1.0.0" + }, + "devDependencies": { + "app-route": "polymerelements/app-route#^0.9.0", + "font-roboto": "polymerelements/font-roboto#^1.0.0", + "iron-component-page": "polymerelements/iron-component-page#^1.0.0", + "iron-icon": "polymerelements/iron-icon#^1.0.0", + "iron-icons": "polymerelements/iron-icons#^1.0.0", + "iron-list": "polymerelements/iron-list#^1.0.0", + "iron-pages": "polymerelements/iron-pages#^1.0.0", + "iron-page-url": "polymerelements/iron-page-url#^0.7.0", + "paper-card": "polymerelements/paper-card#^1.0.0", + "paper-checkbox": "polymerelements/paper-checkbox#^1.0.0", + "paper-fab": "polymerelements/paper-fab#^1.0.0", + "paper-icon-button": "polymerelements/paper-icon-button#^1.0.0", + "paper-item": "polymerelements/paper-item#^1.0.0", + "paper-listbox": "polymerelements/paper-listbox#^1.0.0", + "paper-menu": "polymerelements/paper-menu#^1.0.0", + "paper-menu-button": "polymerelements/paper-menu-button#^1.0.0", + "paper-tabs": "polymerelements/paper-tabs#^1.0.0", + "paper-progress": "polymerelements/paper-progress#~1.0.2", + "paper-styles": "polymerelements/paper-styles#^1.0.0", + "test-fixture": "polymerelements/test-fixture#^1.0.0", + "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0", + "web-component-tester": "^4.0.0" + } +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-layout/compiled_resources2.gyp new file mode 100644 index 0000000..1d70b5c1 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/compiled_resources2.gyp
@@ -0,0 +1,23 @@ +# 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. +# +# NOTE: Created with generate_compiled_resources_gyp.py, please do not edit. +{ + 'targets': [ + { + 'target_name': 'app-layout-extracted', + 'dependencies': [ + 'app-box/compiled_resources2.gyp:app-box-extracted', + 'app-drawer-layout/compiled_resources2.gyp:app-drawer-layout-extracted', + 'app-drawer/compiled_resources2.gyp:app-drawer-extracted', + 'app-header-layout/compiled_resources2.gyp:app-header-layout-extracted', + 'app-header/compiled_resources2.gyp:app-header-extracted', + 'app-scrollpos-control/compiled_resources2.gyp:app-scrollpos-control-extracted', + 'app-toolbar/compiled_resources2.gyp:app-toolbar-extracted', + 'helpers/compiled_resources2.gyp:helpers-extracted', + ], + 'includes': ['../../../../closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/helpers/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-layout/helpers/compiled_resources2.gyp new file mode 100644 index 0000000..7f576fc --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/helpers/compiled_resources2.gyp
@@ -0,0 +1,13 @@ +# 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. +# +# NOTE: Created with generate_compiled_resources_gyp.py, please do not edit. +{ + 'targets': [ + { + 'target_name': 'helpers-extracted', + 'includes': ['../../../../../closure_compiler/compile_js2.gypi'], + }, + ], +}
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/helpers/helpers-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/helpers/helpers-extracted.js new file mode 100644 index 0000000..bb84915 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/helpers/helpers-extracted.js
@@ -0,0 +1,114 @@ +Polymer.AppLayout = Polymer.AppLayout || {}; + + Polymer.AppLayout._scrollEffects = Polymer.AppLayout._scrollEffects || {}; + + Polymer.AppLayout.scrollTimingFunction = function easeOutQuad(t, b, c, d) { + t /= d; + return -c * t*(t-2) + b; + }; + + /** + * Registers a scroll effect to be used in elements that implement the + * `Polymer.AppScrollEffectsBehavior` behavior. + * + * @param {string} effectName The effect name. + * @param {Object} effectDef The effect definition. + */ + Polymer.AppLayout.registerEffect = function registerEffect(effectName, effectDef) { + if (Polymer.AppLayout._scrollEffects[effectName] != null) { + throw new Error('effect `'+ effectName + '` is already registered.'); + } + Polymer.AppLayout._scrollEffects[effectName] = effectDef; + }; + + /** + * Scrolls to a particular set of coordinates in a scroll target. + * If the scroll target is not defined, then it would use the main document as the target. + * + * To scroll in a smooth fashion, you can set the option `behavior: 'smooth'`. e.g. + * + * ```js + * Polymer.AppLayout.scroll({top: 0, behavior: 'smooth'}); + * ``` + * + * To scroll in a silent mode, without notifying scroll changes to any app-layout elements, + * you can set the option `behavior: 'silent'`. This is particularly useful we you are using + * `app-header` and you desire to scroll to the top of a scrolling region without running + * scroll effects. e.g. + * + * ```js + * Polymer.AppLayout.scroll({top: 0, behavior: 'silent'}); + * ``` + * + * @param {Object} options {top: Number, left: Number, behavior: String(smooth | silent)} + */ + Polymer.AppLayout.scroll = function scroll(options) { + options = options || {}; + + var docEl = document.documentElement; + var target = options.target || docEl; + var hasNativeScrollBehavior = 'scrollBehavior' in target.style && target.scroll; + var scrollClassName = 'app-layout-silent-scroll'; + var scrollTop = options.top || 0; + var scrollLeft = options.left || 0; + var scrollTo = target === docEl ? window.scrollTo : + function scrollTo(scrollLeft, scrollTop) { + target.scrollLeft = scrollLeft; + target.scrollTop = scrollTop; + }; + + if (options.behavior === 'smooth') { + + if (hasNativeScrollBehavior) { + + target.scroll(options); + + } else { + + var timingFn = Polymer.AppLayout.scrollTimingFunction; + var startTime = Date.now(); + var currentScrollTop = target === docEl ? window.pageYOffset : target.scrollTop; + var currentScrollLeft = target === docEl ? window.pageXOffset : target.scrollLeft; + var deltaScrollTop = scrollTop - currentScrollTop; + var deltaScrollLeft = scrollLeft - currentScrollLeft; + var duration = 300; + + (function updateFrame() { + var now = Date.now(); + var elapsedTime = now - startTime; + + if (elapsedTime < duration) { + scrollTo( + timingFn(elapsedTime, currentScrollLeft, deltaScrollLeft, duration), + timingFn(elapsedTime, currentScrollTop, deltaScrollTop, duration) + ); + requestAnimationFrame(updateFrame.bind(this)); + } + }).call(this); + } + + } else if (options.behavior === 'silent') { + + docEl.classList.add(scrollClassName); + + // Browsers keep the scroll momentum even if the bottom of the scrolling content + // was reached. This means that calling scroll({top: 0, behavior: 'silent'}) when + // the momentum is still going will result in more scroll events and thus scroll effects. + // This seems to only apply when using document scrolling. + // Therefore, when should we remove the class from the document element? + + clearInterval(Polymer.AppLayout._scrollTimer); + + Polymer.AppLayout._scrollTimer = setTimeout(function() { + docEl.classList.remove(scrollClassName); + Polymer.AppLayout._scrollTimer = null; + }, 100); + + scrollTo(scrollLeft, scrollTop); + + } else { + + scrollTo(scrollLeft, scrollTop); + + } + }; \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/helpers/helpers.html b/third_party/polymer/v1_0/components-chromium/app-layout/helpers/helpers.html new file mode 100644 index 0000000..b5020839 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-layout/helpers/helpers.html
@@ -0,0 +1,11 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../../polymer/polymer.html"> + +</head><body><script src="helpers-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-location-extracted.js b/third_party/polymer/v1_0/components-chromium/app-route/app-location-extracted.js similarity index 76% rename from third_party/polymer/v1_0/components-chromium/carbon-route/carbon-location-extracted.js rename to third_party/polymer/v1_0/components-chromium/app-route/app-location-extracted.js index 881fad1e..4d0c4bd 100644 --- a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-location-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/app-route/app-location-extracted.js
@@ -1,7 +1,7 @@ 'use strict'; Polymer({ - is: 'carbon-location', + is: 'app-location', properties: { /** @@ -74,20 +74,37 @@ */ __hash: { type: String + }, + + /** + * The route path, which will be either the hash or the path, depending + * on useHashAsPath. + */ + path: { + type: String, + observer: '__onPathChanged' } }, - __computeRoutePath: function(path, hash, useHashAsPath) { - return useHashAsPath ? hash : path; + behaviors: [Polymer.AppRouteConverterBehavior], + + observers: [ + '__computeRoutePath(useHashAsPath, __hash, __path)' + ], + + __computeRoutePath: function() { + this.path = this.useHashAsPath ? this.__hash : this.__path; }, - __onPathChanged: function(event) { - var path = event.detail.value; + __onPathChanged: function() { + if (!this._readied) { + return; + } if (this.useHashAsPath) { - this.__hash = path; + this.__hash = this.path; } else { - this.__path = path; + this.__path = this.path; } } }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-route/app-location.html b/third_party/polymer/v1_0/components-chromium/app-route/app-location.html new file mode 100644 index 0000000..4cfc108 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-route/app-location.html
@@ -0,0 +1,58 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../polymer/polymer.html"> +<link rel="import" href="../iron-location/iron-location.html"> +<link rel="import" href="../iron-location/iron-query-params.html"> +<link rel="import" href="app-route-converter-behavior.html"> + +<!-- +`app-location` is an element that provides synchronization between the +browser location bar and the state of an app. When created, `app-location` +elements will automatically watch the global location for changes. As changes +occur, `app-location` produces and updates an object called `route`. This +`route` object is suitable for passing into a `app-route`, and other similar +elements. + +An example of the public API of a route object that describes the URL +`https://elements.polymer-project.org/elements/app-route-converter?foo=bar&baz=qux`: + + { + prefix: '', + path: '/elements/app-route-converter' + } + +Example Usage: + + <app-location route="{{route}}"></app-location> + <app-route route="{{route}}" pattern="/:page" data="{{data}}"></app-route> + +As you can see above, the `app-location` element produces a `route` and that +property is then bound into the `app-route` element. The bindings are two- +directional, so when changes to the `route` object occur within `app-route`, +they automatically reflect back to the global location. + +A `app-location` can be configured to use the hash part of a URL as the +canonical source for path information. + +Example: + + <app-location route="{{route}}" use-hash-as-path></app-location> + +@element app-location +@demo demo/index.html +--> +</head><body><dom-module id="app-location"> + <template> + <iron-location path="{{__path}}" query="{{__query}}" hash="{{__hash}}" url-space-regex="{{urlSpaceRegex}}"> + </iron-location> + <iron-query-params params-string="{{__query}}" params-object="{{queryParams}}"> + </iron-query-params> + </template> + </dom-module> +<script src="app-location-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route-converter-extracted.js b/third_party/polymer/v1_0/components-chromium/app-route/app-route-converter-behavior-extracted.js similarity index 70% rename from third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route-converter-extracted.js rename to third_party/polymer/v1_0/components-chromium/app-route/app-route-converter-behavior-extracted.js index 299c1bcf..20fcfc7f 100644 --- a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route-converter-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/app-route/app-route-converter-behavior-extracted.js
@@ -1,21 +1,26 @@ 'use strict'; - Polymer({ - is: 'carbon-route-converter', - + /** + * Provides bidirectional mapping between `path` and `queryParams` and a + * app-route compatible `route` object. + * + * For more information, see the docs for `app-route-converter`. + * + * @polymerBehavior + */ + Polymer.AppRouteConverterBehavior = { properties: { /** * A model representing the deserialized path through the route tree, as * well as the current queryParams. * * A route object is the kernel of the routing system. It is intended to - * be fed into consuming elements such as `carbon-route`. + * be fed into consuming elements such as `app-route`. * * @type {?Object} */ route: { type: Object, - value: null, notify: true }, @@ -27,7 +32,6 @@ */ queryParams: { type: Object, - value: null, notify: true }, @@ -39,7 +43,6 @@ path: { type: String, notify: true, - value: '' } }, @@ -56,32 +59,29 @@ /** * Handler called when the path or queryParams change. - * - * @param {!string} path The serialized path through the route tree. - * @param {Object} queryParams A set of key/value pairs that are - * universally accessible to branches of the route tree. */ - _locationChanged: function(path, queryParams) { + _locationChanged: function() { + if (this.route && + this.route.path === this.path && + this.queryParams === this.route.__queryParams) { + return; + } this.route = { prefix: '', - path: path, - __queryParams: queryParams + path: this.path, + __queryParams: this.queryParams }; }, /** * Handler called when the route prefix and route path change. - * - * @param {!string} prefix The fragment of the pathname that precedes the - * path. - * @param {!string} path The serialized path through the route tree. */ - _routeChanged: function(prefix, path) { + _routeChanged: function() { if (!this.route) { return; } - this.path = prefix + path; + this.path = this.route.prefix + this.route.path; }, /** @@ -96,4 +96,4 @@ } this.queryParams = queryParams; } - }); \ No newline at end of file + }; \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-route/app-route-converter-behavior.html b/third_party/polymer/v1_0/components-chromium/app-route/app-route-converter-behavior.html new file mode 100644 index 0000000..adc3b8a --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-route/app-route-converter-behavior.html
@@ -0,0 +1,9 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head></head><body><script src="app-route-converter-behavior-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-route/app-route-converter-extracted.js b/third_party/polymer/v1_0/components-chromium/app-route/app-route-converter-extracted.js new file mode 100644 index 0000000..d5f4993 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-route/app-route-converter-extracted.js
@@ -0,0 +1,7 @@ +'use strict'; + + Polymer({ + is: 'app-route-converter', + + behaviors: [Polymer.AppRouteConverterBehavior] + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-route/app-route-converter.html b/third_party/polymer/v1_0/components-chromium/app-route/app-route-converter.html new file mode 100644 index 0000000..613931b9 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-route/app-route-converter.html
@@ -0,0 +1,67 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../polymer/polymer.html"> +<link rel="import" href="./app-route-converter-behavior.html"> + +<!-- +`app-route-converter` provides a means to convert a path and query +parameters into a route object and vice versa. This produced route object +is to be fed into route-consuming elements such as `app-route`. + +> n.b. This element is intended to be a primitive of the routing system and for +creating bespoke routing solutions from scratch. To simply include routing in +an app, please refer to [app-location](https://github.com/PolymerElements/app-route/blob/master/app-location.html) +and [app-route](https://github.com/PolymerElements/app-route/blob/master/app-route.html). + +An example of a route object that describes +`https://elements.polymer-project.org/elements/app-route-converter?foo=bar&baz=qux` +and should be passed to other `app-route` elements: + + { + prefix: '', + path: '/elements/app-route-converter', + __queryParams: { + foo: 'bar', + baz: 'qux' + } + } + +`__queryParams` is private to discourage directly data-binding to it. This is so +that routing elements like `app-route` can intermediate changes to the query +params and choose whether to propagate them upstream or not. `app-route` for +example will not propagate changes to its `queryParams` property if it is not +currently active. A public queryParams object will also be produced in which you +should perform data-binding operations. + +Example Usage: + + <iron-location path="{{path}}" query="{{query}}"></iron-location> + <iron-query-params + params-string="{{query}}" + params-object="{{queryParams}}"> + </iron-query-params> + <app-route-converter + path="{{path}}" + query-params="{{queryParams}}" + route="{{route}}"> + </app-route-converter> + <app-route route='{{route}}' pattern='/:page' data='{{data}}'> + </app-route> + +This is a simplified implementation of the `app-location` element. Here the +`iron-location` produces a path and a query, the `iron-query-params` consumes +the query and produces a queryParams object, and the `app-route-converter` +consumes the path and the query params and converts it into a route which is in +turn is consumed by the `app-route`. + +@element app-route-converter +@demo demo/index.html +--> + +</head><body><script src="app-route-converter-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route-extracted.js b/third_party/polymer/v1_0/components-chromium/app-route/app-route-extracted.js similarity index 61% rename from third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route-extracted.js rename to third_party/polymer/v1_0/components-chromium/app-route/app-route-extracted.js index 8188f98..39f4230 100644 --- a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/app-route/app-route-extracted.js
@@ -1,7 +1,7 @@ 'use strict'; Polymer({ - is: 'carbon-route', + is: 'app-route', properties: { /** @@ -60,7 +60,7 @@ readOnly: true }, - _skipMatch: { + _queryParamsUpdating: { type: Boolean, value: false }, @@ -89,6 +89,9 @@ // IE Object.assign polyfill __assign: function(target, source) { + if (Object.assign) { + return Object.assign(target, source); + } if (source != null) { for (var key in source) { target[key] = source[key]; @@ -98,38 +101,38 @@ return target; }, - // Deal with the query params object being assigned to wholesale + /** + * Deal with the query params object being assigned to wholesale. + * @export + */ __routeQueryParamsChanged: function(queryParams) { if (queryParams && this.tail) { this.set('tail.__queryParams', queryParams); - if (!this.active || this._skipMatch) { + if (!this.active || this._queryParamsUpdating) { return; } - this._skipMatch = true; - - var qp; - - if (Object.assign) { - qp = Object.assign({}, queryParams); - } else { - qp = this.__assign({}, queryParams); - } - - this.set('queryParams', qp); - this._skipMatch = false; + this._queryParamsUpdating = true; + this.set('queryParams', this.__assign({}, queryParams)); + this._queryParamsUpdating = false; } }, + /** + * @export + */ __tailQueryParamsChanged: function(queryParams) { if (queryParams && this.route) { this.set('route.__queryParams', queryParams); } }, + /** + * @export + */ __queryParamsChanged: function(changes) { - if (!this.active || this._skipMatch) { + if (!this.active || this._queryParamsUpdating) { return; } @@ -143,8 +146,16 @@ //this.data = {}; }, - __tryToMatch: function(path, pattern) { - if (this._skipMatch || !pattern) { + /** + * @export + */ + __tryToMatch: function() { + if (!this.route) { + return; + } + var path = this.route.path; + var pattern = this.pattern; + if (!pattern) { return; } @@ -181,54 +192,77 @@ } } - matched = matched.join('/'); + this._matched = matched.join('/'); + + // Properties that must be updated atomically. + var propertyUpdates = {}; + + //this.active + if (!this.active) { + propertyUpdates.active = true; + } + + // this.tail + var tailPrefix = this.route.prefix + this._matched; var tailPath = remainingPieces.join('/'); if (remainingPieces.length > 0) { tailPath = '/' + tailPath; } - - this._skipMatch = true; - this._matched = matched; - this.data = namedMatches; - var tailPrefix = this.route.prefix + matched; - - if (!this.tail || this.tail.prefix !== tailPrefix || this.tail.path !== tailPath) { - this.tail = { + if (!this.tail || + this.tail.prefix !== tailPrefix || + this.tail.path !== tailPath) { + propertyUpdates.tail = { prefix: tailPrefix, path: tailPath, __queryParams: this.route.__queryParams }; } - this._setActive(true); - this._skipMatch = false; + + // this.data + propertyUpdates.data = namedMatches; + this._dataInUrl = {}; + for (var key in namedMatches) { + this._dataInUrl[key] = namedMatches[key]; + } + + this.__setMulti(propertyUpdates); }, - __tailPathChanged: function(path) { - if (!this.active || this._skipMatch) { + /** + * @export + */ + __tailPathChanged: function() { + if (!this.active) { return; } + var tailPath = this.tail.path; var newPath = this._matched; - if (path) { - if (path.charAt(0) !== '/') { - path = '/' + path; + if (tailPath) { + if (tailPath.charAt(0) !== '/') { + tailPath = '/' + tailPath; } - newPath += path; + newPath += tailPath; } this.set('route.path', newPath); }, + /** + * @export + */ __updatePathOnDataChange: function() { - if (!this.route || this._skipMatch || !this.active) { + if (!this.route || !this.active) { return; } - this._skipMatch = true; - this.tail = {path: null, prefix: null, queryParams: null}; - this.set('route.path', this.__getLink({})); - this._skipMatch = false; + var newPath = this.__getLink({}); + var oldPath = this.__getLink(this._dataInUrl); + if (newPath === oldPath) { + return; + } + this.set('route.path', newPath); }, __getLink: function(overrideValues) { - var values = {tail: this.tail}; + var values = {tail: null}; for (var key in this.data) { values[key] = this.data[key]; } @@ -243,8 +277,34 @@ return value; }, this); if (values.tail && values.tail.path) { - interp.push(values.tail.path); + if (interp.length > 0 && values.tail.path.charAt(0) === '/') { + interp.push(values.tail.path.slice(1)); + } else { + interp.push(values.tail.path); + } } return interp.join('/'); + }, + + __setMulti: function(setObj) { + // HACK(rictic): skirting around 1.0's lack of a setMulti by poking at + // internal data structures. I would not advise that you copy this + // example. + // + // In the future this will be a feature of Polymer itself. + // See: https://github.com/Polymer/polymer/issues/3640 + // + // Hacking around with private methods like this is juggling footguns, + // and is likely to have unexpected and unsupported rough edges. + // + // Be ye so warned. + for (var property in setObj) { + this._propertySetter(property, setObj[property]); + } + + for (var property in setObj) { + this._pathEffector(property, this[property]); + this._notifyPathUp(property, this[property]); + } } }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/app-route/app-route.html b/third_party/polymer/v1_0/components-chromium/app-route/app-route.html new file mode 100644 index 0000000..f9126fc9 --- /dev/null +++ b/third_party/polymer/v1_0/components-chromium/app-route/app-route.html
@@ -0,0 +1,82 @@ +<!-- +@license +Copyright (c) 2016 The Polymer Project Authors. All rights reserved. +This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt +The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt +The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt +Code distributed by Google as part of the polymer project is also +subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt +--><html><head><link rel="import" href="../polymer/polymer.html"> + +<!-- +`app-route` is an element that enables declarative, self-describing routing +for a web app. + +> *n.b. app-route is still in beta. We expect it will need some changes. We're counting on your feedback!* + +In its typical usage, a `app-route` element consumes an object that describes +some state about the current route, via the `route` property. It then parses +that state using the `pattern` property, and produces two artifacts: some `data` +related to the `route`, and a `tail` that contains the rest of the `route` that +did not match. + +Here is a basic example, when used with `app-location`: + + <app-location route="{{route}}"></app-location> + <app-route + route="{{route}}" + pattern="/:page" + data="{{data}}" + tail="{{tail}}"> + </app-route> + +In the above example, the `app-location` produces a `route` value. Then, the +`route.path` property is matched by comparing it to the `pattern` property. If +the `pattern` property matches `route.path`, the `app-route` will set or update +its `data` property with an object whose properties correspond to the parameters +in `pattern`. So, in the above example, if `route.path` was `'/about'`, the value +of `data` would be `{"page": "about"}`. + +The `tail` property represents the remaining part of the route state after the +`pattern` has been applied to a matching `route`. + +Here is another example, where `tail` is used: + + <app-location route="{{route}}"></app-location> + <app-route + route="{{route}}" + pattern="/:page" + data="{{routeData}}" + tail="{{subroute}}"> + </app-route> + <app-route + route="{{subroute}}" + pattern="/:id" + data="{{subrouteData}}"> + </app-route> + +In the above example, there are two `app-route` elements. The first +`app-route` consumes a `route`. When the `route` is matched, the first +`app-route` also produces `routeData` from its `data`, and `subroute` from +its `tail`. The second `app-route` consumes the `subroute`, and when it +matches, it produces an object called `subrouteData` from its `data`. + +So, when `route.path` is `'/about'`, the `routeData` object will look like +this: `{ page: 'about' }` + +And `subrouteData` will be null. However, if `route.path` changes to +`'/article/123'`, the `routeData` object will look like this: +`{ page: 'article' }` + +And the `subrouteData` will look like this: `{ id: '123' }` + +`app-route` is responsive to bi-directional changes to the `data` objects +they produce. So, if `routeData.page` changed from `'article'` to `'about'`, +the `app-route` will update `route.path`. This in-turn will update the +`app-location`, and cause the global location bar to change its value. + +@element app-route +@demo demo/index.html +--> + +</head><body><script src="app-route-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/carbon-route/bower.json b/third_party/polymer/v1_0/components-chromium/app-route/bower.json similarity index 84% rename from third_party/polymer/v1_0/components-chromium/carbon-route/bower.json rename to third_party/polymer/v1_0/components-chromium/app-route/bower.json index 8ab8b66..0e5f81f 100644 --- a/third_party/polymer/v1_0/components-chromium/carbon-route/bower.json +++ b/third_party/polymer/v1_0/components-chromium/app-route/bower.json
@@ -1,17 +1,17 @@ { - "name": "carbon-route", - "version": "0.8.4", + "name": "app-route", + "version": "0.9.1", "authors": [ "The Polymer Authors" ], "description": "App routing expressed as Polymer Custom Elements.", "main": [ - "carbon-route.html", - "carbon-location.html", - "carbon-route-converter.html" + "app-route.html", + "app-location.html", + "app-route-converter.html" ], "license": "http://polymer.github.io/LICENSE.txt", - "homepage": "https://github.com/PolymerElements/carbon-route", + "homepage": "https://github.com/PolymerElements/app-route", "private": true, "ignore": [], "devDependencies": {
diff --git a/third_party/polymer/v1_0/components-chromium/carbon-route/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/app-route/compiled_resources2.gyp similarity index 61% rename from third_party/polymer/v1_0/components-chromium/carbon-route/compiled_resources2.gyp rename to third_party/polymer/v1_0/components-chromium/app-route/compiled_resources2.gyp index d6d8aabd..c2952942 100644 --- a/third_party/polymer/v1_0/components-chromium/carbon-route/compiled_resources2.gyp +++ b/third_party/polymer/v1_0/components-chromium/app-route/compiled_resources2.gyp
@@ -6,20 +6,27 @@ { 'targets': [ { - 'target_name': 'carbon-location-extracted', + 'target_name': 'app-location-extracted', 'dependencies': [ '../iron-location/compiled_resources2.gyp:iron-location-extracted', '../iron-location/compiled_resources2.gyp:iron-query-params-extracted', - 'carbon-route-converter-extracted', + 'app-route-converter-behavior-extracted', ], 'includes': ['../../../../closure_compiler/compile_js2.gypi'], }, { - 'target_name': 'carbon-route-converter-extracted', + 'target_name': 'app-route-converter-behavior-extracted', 'includes': ['../../../../closure_compiler/compile_js2.gypi'], }, { - 'target_name': 'carbon-route-extracted', + 'target_name': 'app-route-converter-extracted', + 'dependencies': [ + './compiled_resources2.gyp:app-route-converter-behavior-extracted', + ], + 'includes': ['../../../../closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'app-route-extracted', 'includes': ['../../../../closure_compiler/compile_js2.gypi'], }, ],
diff --git a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-location.html b/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-location.html deleted file mode 100644 index d5af13e..0000000 --- a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-location.html +++ /dev/null
@@ -1,61 +0,0 @@ -<!-- -@license -Copyright (c) 2016 The Polymer Project Authors. All rights reserved. -This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt -The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt -The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt -Code distributed by Google as part of the polymer project is also -subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt ---><html><head><link rel="import" href="../polymer/polymer.html"> -<link rel="import" href="../iron-location/iron-location.html"> -<link rel="import" href="../iron-location/iron-query-params.html"> -<link rel="import" href="carbon-route-converter.html"> - -<!-- -`carbon-location` is an element that provides synchronization between the -browser location bar and the state of an app. When created, `carbon-location` -elements will automatically watch the global location for changes. As changes -occur, `carbon-location` produces and updates an object called `route`. This -`route` object is suitable for passing into a `carbon-route`, and other similar -elements. - -An example of a route object that describes the URL -`https://elements.polymer-project.org/elements/carbon-route-converter?foo=bar&baz=qux`: - - { - prefix: '', - path: '/elements/carbon-route-converter' - } - -Example Usage: - - <carbon-location route="{{route}}"></carbon-location> - <carbon-route route="{{route}}" pattern="/:page" data="{{data}}"></carbon-route> - -As you can see above, the `carbon-location` element produces a `route` and that -property is then bound into the `carbon-route` element. The bindings are two- -directional, so when changes to the `route` object occur within `carbon-route`, -they automatically reflect back to the global location. - -A `carbon-location` can be configured to use the hash part of a URL as the -canonical source for path information. - -Example: - - <carbon-location route="{{route}}" use-hash-as-path></carbon-location> - -@element carbon-location -@demo demo/index.html ---> - -</head><body><dom-module id="carbon-location"> - <template> - <iron-location path="{{__path}}" query="{{__query}}" hash="{{__hash}}" url-space-regex="{{urlSpaceRegex}}"> - </iron-location> - <iron-query-params params-string="{{__query}}" params-object="{{__queryParams}}"> - </iron-query-params> - <carbon-route-converter on-path-changed="__onPathChanged" path="[[__computeRoutePath(__path, __hash, useHashAsPath)]]" query-params="{{__queryParams}}" route="{{route}}"> - </carbon-route-converter> - </template> - </dom-module> -<script src="carbon-location-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route-converter.html b/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route-converter.html deleted file mode 100644 index 3924cfd..0000000 --- a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route-converter.html +++ /dev/null
@@ -1,58 +0,0 @@ -<!-- -@license -Copyright (c) 2016 The Polymer Project Authors. All rights reserved. -This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt -The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt -The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt -Code distributed by Google as part of the polymer project is also -subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt ---><html><head><link rel="import" href="../polymer/polymer.html"> - -<!-- -`carbon-route-converter` provides a means to convert a path and query -parameters into a route object and vice versa. This produced route object -is to be fed into route-consuming elements such as `carbon-route`. - -> n.b. This element is intended to be a primitive of the routing system and for -creating bespoke routing solutions from scratch. To simply include routing in -an app, please refer to [carbon-location](https://github.com/PolymerElements/carbon-route/blob/master/carbon-location.html) -and [carbon-route](https://github.com/PolymerElements/carbon-route/blob/master/carbon-route.html). - -An example of a route element that describes -`https://elements.polymer-project.org/elements/carbon-route-converter?foo=bar&baz=qux`: - - { - prefix: '', - path: '/elements/carbon-route-converter', - queryParams: { - foo: 'bar', - baz: 'qux' - } - } - -Example Usage: - - <iron-location path="{{path}}" query="{{query}}"></iron-location> - <iron-query-params - params-string="{{query}}" - params-object="{{queryParams}}"> - </iron-query-params> - <carbon-route-converter - path="{{path}}" - query-params="{{queryParams}}" - route="{{route}}"> - </carbon-route-converter> - <carbon-route route='{{route}}' pattern='/:page' data='{{data}}'> - </carbon-route> - -This is a simplified implementation of the `carbon-location` element. Here the -`iron-location` produces a path and a query, the `iron-query-params` consumes -the query and produces a queryParams object, and the `carbon-route-converter` -consumes the path and the query params and converts it into a route which is in -turn is consumed by the `carbon-route`. - -@element carbon-route-converter -@demo demo/index.html ---> - -</head><body><script src="carbon-route-converter-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route.html b/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route.html deleted file mode 100644 index dd311fe..0000000 --- a/third_party/polymer/v1_0/components-chromium/carbon-route/carbon-route.html +++ /dev/null
@@ -1,82 +0,0 @@ -<!-- -@license -Copyright (c) 2016 The Polymer Project Authors. All rights reserved. -This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt -The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt -The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt -Code distributed by Google as part of the polymer project is also -subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt ---><html><head><link rel="import" href="../polymer/polymer.html"> - -<!-- -`carbon-route` is an element that enables declarative, self-describing routing -for a web app. - -> *n.b. carbon-route is still in beta. We expect it will need some changes. We're counting on your feedback!* - -In its typical usage, a `carbon-route` element consumes an object that describes -some state about the current route, via the `route` property. It then parses -that state using the `pattern` property, and produces two artifacts: some `data` -related to the `route`, and a `tail` that contains the rest of the `route` that -did not match. - -Here is a basic example, when used with `carbon-location`: - - <carbon-location route="{{route}}"></carbon-location> - <carbon-route - route="{{route}}" - pattern="/:page" - data="{{data}}" - tail="{{tail}}"> - </carbon-route> - -In the above example, the `carbon-location` produces a `route` value. Then, the -`route.path` property is matched by comparing it to the `pattern` property. If -the `pattern` property matches `route.path`, the `carbon-route` will set or update -its `data` property with an object whose properties correspond to the parameters -in `pattern`. So, in the above example, if `route.path` was `'/about'`, the value -of `data` would be `{"page": "about"}`. - -The `tail` property represents the remaining part of the route state after the -`pattern` has been applied to a matching `route`. - -Here is another example, where `tail` is used: - - <carbon-location route="{{route}}"></carbon-location> - <carbon-route - route="{{route}}" - pattern="/:page" - data="{{routeData}}" - tail="{{subroute}}"> - </carbon-route> - <carbon-route - route="{{subroute}}" - pattern="/:id" - data="{{subrouteData}}"> - </carbon-route> - -In the above example, there are two `carbon-route` elements. The first -`carbon-route` consumes a `route`. When the `route` is matched, the first -`carbon-route` also produces `routeData` from its `data`, and `subroute` from -its `tail`. The second `carbon-route` consumes the `subroute`, and when it -matches, it produces an object called `subrouteData` from its `tail`. - -So, when `route.path` is `'/about'`, the `routeData` object will look like -this: `{ page: 'about' }` - -And `subrouteData` will be null. However, if `route.path` changes to -`'/article/123'`, the `routeData` object will look like this: -`{ page: 'article' }` - -And the `subrouteData` will look like this: `{ id: '123' }` - -`carbon-route` is responsive to bi-directional changes to the `data` objects -they produce. So, if `routeData.page` changed from `'article'` to `'about'`, -the `carbon-route` will update `route.path`. This in-turn will update the -`carbon-location`, and cause the global location bar to change its value. - -@element carbon-route -@demo demo/index.html ---> - -</head><body><script src="carbon-route-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/iron-a11y-keys/bower.json b/third_party/polymer/v1_0/components-chromium/iron-a11y-keys/bower.json index ca79f0a..5cdaf486 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-a11y-keys/bower.json +++ b/third_party/polymer/v1_0/components-chromium/iron-a11y-keys/bower.json
@@ -1,6 +1,6 @@ { "name": "iron-a11y-keys", - "version": "1.0.4", + "version": "1.0.5", "description": "A basic element implementation of iron-a11y-keys-behavior, matching the legacy core-a11y-keys.", "keywords": [ "web-components", @@ -27,7 +27,7 @@ "iron-component-page": "polymerelements/iron-component-page#^1.0.0", "test-fixture": "polymerelements/test-fixture#^1.0.0", "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0", - "web-component-tester": "polymer/web-component-tester#^3.4.0", + "web-component-tester": "^4.0.0", "iron-test-helpers": "polymerelements/iron-test-helpers#^1.0.0" }, "ignore": []
diff --git a/third_party/polymer/v1_0/components-chromium/iron-a11y-keys/iron-a11y-keys-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-a11y-keys/iron-a11y-keys-extracted.js index 2b46b92..46f0ffc 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-a11y-keys/iron-a11y-keys-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/iron-a11y-keys/iron-a11y-keys-extracted.js
@@ -1,13 +1,13 @@ -/* -`iron-a11y-keys` provides a cross-browser interface for processing -keyboard commands. The interface adheres to [WAI-ARIA best -practices](http://www.w3.org/TR/wai-aria-practices/#kbd_general_binding). +/** +`iron-a11y-keys` provides a cross-browser interface for processing +keyboard commands. The interface adheres to [WAI-ARIA best +practices](http://www.w3.org/TR/wai-aria-practices/#kbd_general_binding). It uses an expressive syntax to filter key presses. ## Basic usage The sample code below is a portion of a custom element. The goal is to call -the `onEnter` method whenever the `paper-input` element is in focus and +the `onEnter` method whenever the `paper-input` element is in focus and the `Enter` key is pressed. <iron-a11y-keys id="a11y" target="[[target]]" keys="enter" @@ -16,14 +16,14 @@ placeholder="Type something. Press enter. Check console." value="{{userInput::input}}"></paper-input> -The custom element declares an `iron-a11y-keys` element that is bound to a +The custom element declares an `iron-a11y-keys` element that is bound to a property called `target`. The `target` property -needs to evaluate to the `paper-input` node. `iron-a11y-keys` registers +needs to evaluate to the `paper-input` node. `iron-a11y-keys` registers an event handler for the target node using Polymer's [annotated event handler -syntax](https://www.polymer-project.org/1.0/docs/devguide/events.html#annotated-listeners). `{{userInput::input}}` sets the `userInput` property to the -user's input on each keystroke. +syntax](https://www.polymer-project.org/1.0/docs/devguide/events.html#annotated-listeners). `{{userInput::input}}` sets the `userInput` property to the +user's input on each keystroke. -The last step is to link the two elements within the custom element's +The last step is to link the two elements within the custom element's registration. ... @@ -48,71 +48,72 @@ The `keys` attribute expresses what combination of keys triggers the event. -The attribute accepts a space-separated, plus-sign-concatenated +The attribute accepts a space-separated, plus-sign-concatenated set of modifier keys and some common keyboard keys. -The common keys are: `a-z`, `0-9` (top row and number pad), `*` (shift 8 and +The common keys are: `a-z`, `0-9` (top row and number pad), `*` (shift 8 and number pad), `F1-F12`, `Page Up`, `Page Down`, `Left Arrow`, `Right Arrow`, `Down Arrow`, `Up Arrow`, `Home`, `End`, `Escape`, `Space`, `Tab`, `Enter`. -The modifier keys are: `Shift`, `Control`, `Alt`. +The modifier keys are: `Shift`, `Control`, `Alt`, `Meta`. All keys are expected to be lowercase and shortened. E.g. -`Left Arrow` is `left`, `Page Down` is `pagedown`, `Control` is `ctrl`, +`Left Arrow` is `left`, `Page Down` is `pagedown`, `Control` is `ctrl`, `F1` is `f1`, `Escape` is `esc`, etc. ### Grammar -Below is the [EBNF](http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form) +Below is the [EBNF](http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form) Grammar of the `keys` attribute. - modifier = "shift" | "ctrl" | "alt"; + modifier = "shift" | "ctrl" | "alt" | "meta"; ascii = ? /[a-z0-9]/ ? ; fnkey = ? f1 through f12 ? ; arrow = "up" | "down" | "left" | "right" ; - key = "tab" | "esc" | "space" | "*" | "pageup" | "pagedown" | + key = "tab" | "esc" | "space" | "*" | "pageup" | "pagedown" | "home" | "end" | arrow | ascii | fnkey; keycombo = { modifier, "+" }, key ; keys = keycombo, { " ", keycombo } ; ### Example -Given the following value for `keys`: +Given the following value for `keys`: `ctrl+shift+f7 up pagedown esc space alt+m` -The event is fired if any of the following key combinations are fired: -`Control` and `Shift` and `F7` keys, `Up Arrow` key, `Page Down` key, +The event is fired if any of the following key combinations are fired: +`Control` and `Shift` and `F7` keys, `Up Arrow` key, `Page Down` key, `Escape` key, `Space` key, `Alt` and `M` keys. ### WAI-ARIA Slider Example -The following is an example of the set of keys that fulfills WAI-ARIA's +The following is an example of the set of keys that fulfills WAI-ARIA's "slider" role [best practices](http://www.w3.org/TR/wai-aria-practices/#slider): - <iron-a11y-keys target="[[target]]" keys="left pagedown down" + <iron-a11y-keys target="[[target]]" keys="left pagedown down" on-keys-pressed="decrement"></iron-a11y-keys> - <iron-a11y-keys target=""[[target]] keys="right pageup up" + <iron-a11y-keys target="[[target]]" keys="right pageup up" on-keys-pressed="increment"></iron-a11y-keys> - <iron-a11y-keys target="[[target]]" keys="home" + <iron-a11y-keys target="[[target]]" keys="home" on-keys-pressed="setMin"></iron-a11y-keys> - <iron-a11y-keys target=""[[target]] keys="end" + <iron-a11y-keys target=""[[target]] keys="end" on-keys-pressed="setMax"></iron-a11y-keys> -The `target` properties must evaluate to a node. See the basic usage +The `target` properties must evaluate to a node. See the basic usage example above. Each of the values for the `on-keys-pressed` attributes must evalute -to methods. The `increment` method should move the slider a set amount -toward the maximum value. `decrement` should move the slider a set amount -toward the minimum value. `setMin` should move the slider to the minimum +to methods. The `increment` method should move the slider a set amount +toward the maximum value. `decrement` should move the slider a set amount +toward the minimum value. `setMin` should move the slider to the minimum value. `setMax` should move the slider to the maximum value. @demo demo/index.html */ + Polymer({ is: 'iron-a11y-keys',
diff --git a/third_party/polymer/v1_0/components-chromium/iron-dropdown/bower.json b/third_party/polymer/v1_0/components-chromium/iron-dropdown/bower.json index 1318a2a4..0cc2bc5 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-dropdown/bower.json +++ b/third_party/polymer/v1_0/components-chromium/iron-dropdown/bower.json
@@ -1,6 +1,6 @@ { "name": "iron-dropdown", - "version": "1.4.0", + "version": "1.4.1", "description": "An unstyled element that works similarly to a native browser select", "authors": [ "The Polymer Authors"
diff --git a/third_party/polymer/v1_0/components-chromium/iron-dropdown/iron-dropdown-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-dropdown/iron-dropdown-extracted.js index 2c42d844..9e55e8e 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-dropdown/iron-dropdown-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/iron-dropdown/iron-dropdown-extracted.js
@@ -102,6 +102,11 @@ return this.focusTarget || this.containedElement; }, + detached: function() { + this.cancelAnimation(); + Polymer.IronDropdownScrollManager.removeScrollLock(this); + }, + /** * Called when the value of `opened` changes. * Overridden from `IronOverlayBehavior` @@ -126,10 +131,7 @@ * Overridden from `IronOverlayBehavior`. */ _renderOpened: function() { - if (!this.noAnimations && this.animationConfig && this.animationConfig.open) { - if (this.withBackdrop) { - this.backdropElement.open(); - } + if (!this.noAnimations && this.animationConfig.open) { this.$.contentWrapper.classList.add('animating'); this.playAnimation('open'); } else { @@ -141,10 +143,7 @@ * Overridden from `IronOverlayBehavior`. */ _renderClosed: function() { - if (!this.noAnimations && this.animationConfig && this.animationConfig.close) { - if (this.withBackdrop) { - this.backdropElement.close(); - } + if (!this.noAnimations && this.animationConfig.close) { this.$.contentWrapper.classList.add('animating'); this.playAnimation('close'); } else { @@ -161,9 +160,9 @@ _onNeonAnimationFinish: function() { this.$.contentWrapper.classList.remove('animating'); if (this.opened) { - Polymer.IronOverlayBehaviorImpl._finishRenderOpened.apply(this); + this._finishRenderOpened(); } else { - Polymer.IronOverlayBehaviorImpl._finishRenderClosed.apply(this); + this._finishRenderClosed(); } }, @@ -172,30 +171,14 @@ * to configure specific parts of the opening and closing animations. */ _updateAnimationConfig: function() { - var animationConfig = {}; - var animations = []; - - if (this.openAnimationConfig) { - // NOTE(cdata): When making `display:none` elements visible in Safari, - // the element will paint once in a fully visible state, causing the - // dropdown to flash before it fades in. We prepend an - // `opaque-animation` to fix this problem: - animationConfig.open = [{ - name: 'opaque-animation', - }].concat(this.openAnimationConfig); - animations = animations.concat(animationConfig.open); + var animations = (this.openAnimationConfig || []).concat(this.closeAnimationConfig || []); + for (var i = 0; i < animations.length; i++) { + animations[i].node = this.containedElement; } - - if (this.closeAnimationConfig) { - animationConfig.close = this.closeAnimationConfig; - animations = animations.concat(animationConfig.close); - } - - animations.forEach(function(animation) { - animation.node = this.containedElement; - }, this); - - this.animationConfig = animationConfig; + this.animationConfig = { + open: this.openAnimationConfig, + close: this.closeAnimationConfig + }; }, /** @@ -210,30 +193,6 @@ }, /** - * Useful to call this after the element, the window, or the `fitInfo` - * element has been resized. Will maintain the scroll position. - */ - refit: function () { - if (!this.opened) { - return - } - var containedElement = this.containedElement; - var scrollTop; - var scrollLeft; - - if (containedElement) { - scrollTop = containedElement.scrollTop; - scrollLeft = containedElement.scrollLeft; - } - Polymer.IronFitBehavior.refit.apply(this, arguments); - - if (containedElement) { - containedElement.scrollTop = scrollTop; - containedElement.scrollLeft = scrollLeft; - } - }, - - /** * Apply focus to focusTarget or containedElement */ _applyFocus: function () {
diff --git a/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/bower.json b/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/bower.json index f8569cd..673212f 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/bower.json +++ b/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/bower.json
@@ -1,6 +1,6 @@ { "name": "iron-fit-behavior", - "version": "1.2.0", + "version": "1.2.2", "license": "http://polymer.github.io/LICENSE.txt", "description": "Fits an element inside another element", "private": true,
diff --git a/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/iron-fit-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/iron-fit-behavior-extracted.js index 7b4a711..e0d634c 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/iron-fit-behavior-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/iron-fit-behavior-extracted.js
@@ -304,10 +304,15 @@ * Equivalent to calling `resetFit()` and `fit()`. Useful to call this after * the element or the `fitInto` element has been resized, or if any of the * positioning properties (e.g. `horizontalAlign, verticalAlign`) is updated. + * It preserves the scroll position of the sizingTarget. */ refit: function() { + var scrollLeft = this.sizingTarget.scrollLeft; + var scrollTop = this.sizingTarget.scrollTop; this.resetFit(); this.fit(); + this.sizingTarget.scrollLeft = scrollLeft; + this.sizingTarget.scrollTop = scrollTop; }, /** @@ -531,37 +536,41 @@ var position; for (var i = 0; i < positions.length; i++) { var pos = positions[i]; - // Align is ok if: - // - Horizontal AND vertical are required and match, or - // - Only vertical is required and matches, or - // - Only horizontal is required and matches. - var alignOk = (pos.verticalAlign === vAlign && pos.horizontalAlign === hAlign) || - (pos.verticalAlign === vAlign && !hAlign) || - (pos.horizontalAlign === hAlign && !vAlign); // If both vAlign and hAlign are defined, return exact match. // For dynamicAlign and noOverlap we'll have more than one candidate, so // we'll have to check the croppedArea to make the best choice. - if (!this.dynamicAlign && !this.noOverlap && vAlign && hAlign && alignOk) { + if (!this.dynamicAlign && !this.noOverlap && + pos.verticalAlign === vAlign && pos.horizontalAlign === hAlign) { position = pos; break; } + // Align is ok if alignment preferences are respected. If no preferences, + // it is considered ok. + var alignOk = (!vAlign || pos.verticalAlign === vAlign) && + (!hAlign || pos.horizontalAlign === hAlign); + // Filter out elements that don't match the alignment (if defined). // With dynamicAlign, we need to consider all the positions to find the // one that minimizes the cropped area. - if (!this.dynamicAlign && (vAlign || hAlign) && !alignOk) { + if (!this.dynamicAlign && !alignOk) { continue; } position = position || pos; pos.croppedArea = this.__getCroppedArea(pos, size, fitRect); var diff = pos.croppedArea - position.croppedArea; - // Check which crops less. If it crops equally, - // check for alignment preferences. + // Check which crops less. If it crops equally, check if align is ok. if (diff < 0 || (diff === 0 && alignOk)) { position = pos; } + // If not cropped and respects the align requirements, keep it. + // This allows to prefer positions overlapping horizontally over the + // ones overlapping vertically. + if (position.croppedArea === 0 && alignOk) { + break; + } } return position;
diff --git a/third_party/polymer/v1_0/components-chromium/iron-location/bower.json b/third_party/polymer/v1_0/components-chromium/iron-location/bower.json index 5b03c54..6eb4fbe 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-location/bower.json +++ b/third_party/polymer/v1_0/components-chromium/iron-location/bower.json
@@ -1,6 +1,6 @@ { "name": "iron-location", - "version": "0.8.2", + "version": "0.8.3", "description": "Bidirectional data binding into the page's URL.", "private": true, "authors": [
diff --git a/third_party/polymer/v1_0/components-chromium/iron-location/iron-location-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-location/iron-location-extracted.js index 85ea5f3..4f2f1c76 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-location/iron-location-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/iron-location/iron-location-extracted.js
@@ -191,10 +191,6 @@ * is clicking on, if we can and should override the resulting full * page navigation. Returns null otherwise. * - * This method is separated away from _globalOnClick for testability, - * as we can't test that a clicked link should have resulted in navigating - * away from the test page. - * * @param {MouseEvent} event . * @return {string?} . */ @@ -209,19 +205,33 @@ return null; } var eventPath = Polymer.dom(event).path; - var href = null; + var anchor = null; for (var i = 0; i < eventPath.length; i++) { var element = eventPath[i]; if (element.tagName === 'A' && element.href) { - href = element.href; + anchor = element; break; } } + // If there's no link there's nothing to do. - if (!href) { - return null; + if (!anchor) { + return; } + // Target blank is a new tab, don't intercept. + if (anchor.target === '_blank') { + return; + } + // If the link is for an existing parent frame, don't intercept. + if ((anchor.target === '_top' || + anchor.target === '_parent') && + window.top !== window) { + return; + } + + var href = anchor.href; + // It only makes sense for us to intercept same-origin navigations. // pushState/replaceState don't work with cross-origin links. var url;
diff --git a/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/bower.json b/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/bower.json index e303ad2..921662c 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/bower.json +++ b/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/bower.json
@@ -1,6 +1,6 @@ { "name": "iron-menu-behavior", - "version": "1.1.6", + "version": "1.1.7", "description": "Provides accessible menu behavior", "authors": "The Polymer Authors", "keywords": [
diff --git a/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js index 55c59dd..b340403 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/iron-menu-behavior/iron-menu-behavior-extracted.js
@@ -112,7 +112,7 @@ var attr = this.attrForItemTitle || 'textContent'; var title = item[attr] || item.getAttribute(attr); - if (!item.hasAttribute('disabled') && title && + if (!item.hasAttribute('disabled') && title && title.trim().charAt(0).toLowerCase() === String.fromCharCode(event.keyCode).toLowerCase()) { this._setFocusedItem(item); break; @@ -193,17 +193,8 @@ * detail. */ _onIronItemsChanged: function(event) { - var mutations = event.detail; - var mutation; - var index; - - for (index = 0; index < mutations.length; ++index) { - mutation = mutations[index]; - - if (mutation.addedNodes.length) { - this._resetTabindices(); - break; - } + if (event.detail.addedNodes.length) { + this._resetTabindices(); } },
diff --git a/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/bower.json b/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/bower.json index ed622b3..4cccb36c 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/bower.json +++ b/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/bower.json
@@ -1,6 +1,6 @@ { "name": "iron-overlay-behavior", - "version": "1.7.3", + "version": "1.7.6", "license": "http://polymer.github.io/LICENSE.txt", "description": "Provides a behavior for making an element an overlay", "private": true,
diff --git a/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-behavior-extracted.js index 536a85b..4bd7a4c 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-behavior-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-behavior-extracted.js
@@ -300,12 +300,17 @@ return; } - this._manager.addOrRemoveOverlay(this); - if (this.__openChangedAsync) { window.cancelAnimationFrame(this.__openChangedAsync); } + // Synchronously remove the overlay. + // The adding is done asynchronously to go out of the scope of the event + // which might have generated the opening. + if (!this.opened) { + this._manager.removeOverlay(this); + } + // Defer any animation-related code on attached // (_openedChanged gets called again on attached). if (!this.isAttached) { @@ -318,6 +323,7 @@ this.__openChangedAsync = window.requestAnimationFrame(function() { this.__openChangedAsync = null; if (this.opened) { + this._manager.addOverlay(this); this._prepareRenderOpened(); this._renderOpened(); } else { @@ -340,7 +346,7 @@ this.removeAttribute('tabindex'); this.__shouldRemoveTabIndex = false; } - if (this.opened) { + if (this.opened && this.isAttached) { this._manager.trackBackdrop(); } }, @@ -390,6 +396,12 @@ this.notifyResize(); this.__isAnimating = false; + + // Store it so we don't query too much. + var focusableNodes = this._focusableNodes; + this.__firstFocusableNode = focusableNodes[0]; + this.__lastFocusableNode = focusableNodes[focusableNodes.length - 1]; + this.fire('iron-overlay-opened'); }, @@ -494,12 +506,32 @@ * @protected */ _onCaptureTab: function(event) { + if (!this.withBackdrop) { + return; + } // TAB wraps from last to first focusable. // Shift + TAB wraps from first to last focusable. var shift = event.shiftKey; var nodeToCheck = shift ? this.__firstFocusableNode : this.__lastFocusableNode; var nodeToSet = shift ? this.__lastFocusableNode : this.__firstFocusableNode; - if (this.withBackdrop && this._focusedChild === nodeToCheck) { + var shouldWrap = false; + if (nodeToCheck === nodeToSet) { + // If nodeToCheck is the same as nodeToSet, it means we have an overlay + // with 0 or 1 focusables; in either case we still need to trap the + // focus within the overlay. + shouldWrap = true; + } else { + // In dom=shadow, the manager will receive focus changes on the main + // root but not the ones within other shadow roots, so we can't rely on + // _focusedChild, but we should check the deepest active element. + var focusedNode = this._manager.deepActiveElement; + // If the active element is not the nodeToCheck but the overlay itself, + // it means the focus is about to go outside the overlay, hence we + // should prevent that (e.g. user opens the overlay and hit Shift+TAB). + shouldWrap = (focusedNode === nodeToCheck || focusedNode === this); + } + + if (shouldWrap) { // When the overlay contains the last focusable element of the document // and it's already focused, pressing TAB would move the focus outside // the document (e.g. to the browser search bar). Similarly, when the @@ -542,10 +574,6 @@ if (this.opened && !this.__isAnimating) { this.notifyResize(); } - // Store it so we don't query too much. - var focusableNodes = this._focusableNodes; - this.__firstFocusableNode = focusableNodes[0]; - this.__lastFocusableNode = focusableNodes[focusableNodes.length - 1]; } };
diff --git a/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js index 40af738..dc46523f 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js
@@ -23,10 +23,10 @@ */ this._backdropElement = null; - // Listen to mousedown or touchstart to be sure to be the first to capture - // clicks outside the overlay. - var clickEvent = ('ontouchstart' in window) ? 'touchstart' : 'mousedown'; - document.addEventListener(clickEvent, this._onCaptureClick.bind(this), true); + // Enable document-wide tap recognizer. + Polymer.Gestures.add(document, 'tap', null); + // Need to have useCapture=true, Polymer.Gestures doesn't offer that. + document.addEventListener('tap', this._onCaptureClick.bind(this), true); document.addEventListener('focus', this._onCaptureFocus.bind(this), true); document.addEventListener('keydown', this._onCaptureKeyDown.bind(this), true); }; @@ -106,7 +106,6 @@ } else { this.removeOverlay(overlay); } - this.trackBackdrop(); }, /** @@ -118,6 +117,7 @@ var i = this._overlays.indexOf(overlay); if (i >= 0) { this._bringOverlayAtIndexToFront(i); + this.trackBackdrop(); return; } var insertionIndex = this._overlays.length; @@ -144,6 +144,7 @@ // Get focused node. var element = this.deepActiveElement; overlay.restoreFocusNode = this._overlayParent(element) ? null : element; + this.trackBackdrop(); }, /** @@ -162,6 +163,7 @@ if (node && Polymer.dom(document.body).deepContains(node)) { node.focus(); } + this.trackBackdrop(); }, /** @@ -330,12 +332,6 @@ var overlay = /** @type {?} */ (this.currentOverlay()); // Check if clicked outside of top overlay. if (overlay && this._overlayInPath(Polymer.dom(event).path) !== overlay) { - if (overlay.withBackdrop) { - // There's no need to stop the propagation as the backdrop element - // already got this mousedown/touchstart event. Calling preventDefault - // on this event ensures that click/tap won't be triggered at all. - event.preventDefault(); - } overlay._onCaptureClick(event); } },
diff --git a/third_party/polymer/v1_0/components-chromium/iron-range-behavior/bower.json b/third_party/polymer/v1_0/components-chromium/iron-range-behavior/bower.json index b4967a7..a58ad63f 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-range-behavior/bower.json +++ b/third_party/polymer/v1_0/components-chromium/iron-range-behavior/bower.json
@@ -1,6 +1,6 @@ { "name": "iron-range-behavior", - "version": "1.0.4", + "version": "1.0.5", "license": "http://polymer.github.io/LICENSE.txt", "description": "Provides a behavior for something with a minimum and maximum value", "authors": "The Polymer Authors", @@ -9,9 +9,7 @@ "polymer", "behavior" ], - "main": [ - "iron-range-behavior.html" - ], + "main": "iron-range-behavior.html", "private": true, "repository": { "type": "git", @@ -24,7 +22,8 @@ "iron-component-page": "PolymerElements/iron-component-page#^1.0.0", "iron-input": "PolymerElements/iron-input#^1.0.0", "test-fixture": "PolymerElements/test-fixture#^1.0.0", - "web-component-tester": "*", + "web-component-tester": "^4.0.0", "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" - } + }, + "ignore": [] }
diff --git a/third_party/polymer/v1_0/components-chromium/iron-range-behavior/iron-range-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-range-behavior/iron-range-behavior-extracted.js index 1db5ff6..838693e 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-range-behavior/iron-range-behavior-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/iron-range-behavior/iron-range-behavior-extracted.js
@@ -69,18 +69,27 @@ }, _calcStep: function(value) { - /** - * if we calculate the step using - * `Math.round(value / step) * step` we may hit a precision point issue - * eg. 0.1 * 0.2 = 0.020000000000000004 - * http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html - * - * as a work around we can divide by the reciprocal of `step` - */ // polymer/issues/2493 value = parseFloat(value); - return this.step ? (Math.round((value + this.min) / this.step) - - (this.min / this.step)) / (1 / this.step) : value; + + if (!this.step) { + return value; + } + + var numSteps = Math.round((value - this.min) / this.step); + if (this.step < 1) { + /** + * For small values of this.step, if we calculate the step using + * `Math.round(value / step) * step` we may hit a precision point issue + * eg. 0.1 * 0.2 = 0.020000000000000004 + * http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html + * + * as a work around we can divide by the reciprocal of `step` + */ + return numSteps / (1 / this.step) + this.min; + } else { + return numSteps * this.step + this.min; + } }, _validateValue: function() {
diff --git a/third_party/polymer/v1_0/components-chromium/iron-selector/bower.json b/third_party/polymer/v1_0/components-chromium/iron-selector/bower.json index ea97938..8aad3d4 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-selector/bower.json +++ b/third_party/polymer/v1_0/components-chromium/iron-selector/bower.json
@@ -1,6 +1,6 @@ { "name": "iron-selector", - "version": "1.5.1", + "version": "1.5.2", "description": "Manages a set of elements that can be selected", "private": true, "license": "http://polymer.github.io/LICENSE.txt",
diff --git a/third_party/polymer/v1_0/components-chromium/iron-selector/iron-selectable-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-selector/iron-selectable-extracted.js index f19678b..78223d3 100644 --- a/third_party/polymer/v1_0/components-chromium/iron-selector/iron-selectable-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/iron-selector/iron-selectable-extracted.js
@@ -23,8 +23,8 @@ /** * Fired when the list of selectable items changes (e.g., items are - * added or removed). The detail of the event is a list of mutation - * records that describe what changed. + * added or removed). The detail of the event is a mutation record that + * describes what changed. * * @event iron-items-changed */ @@ -331,7 +331,7 @@ // observe items change under the given node. _observeItems: function(node) { - return Polymer.dom(node).observeNodes(function(mutations) { + return Polymer.dom(node).observeNodes(function(mutation) { this._updateItems(); if (this._shouldUpdateSelection) { @@ -340,7 +340,7 @@ // Let other interested parties know about the change so that // we don't have to recreate mutation observers everywhere. - this.fire('iron-items-changed', mutations, { + this.fire('iron-items-changed', mutation, { bubbles: false, cancelable: false });
diff --git a/third_party/polymer/v1_0/components-chromium/paper-button/bower.json b/third_party/polymer/v1_0/components-chromium/paper-button/bower.json index bcb07a8..71a919d 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-button/bower.json +++ b/third_party/polymer/v1_0/components-chromium/paper-button/bower.json
@@ -1,6 +1,6 @@ { "name": "paper-button", - "version": "1.0.11", + "version": "1.0.12", "description": "Material design button", "authors": [ "The Polymer Authors" @@ -16,27 +16,26 @@ "private": true, "repository": { "type": "git", - "url": "git://github.com/PolymerElements/paper-button" + "url": "git://github.com/PolymerElements/paper-button.git" }, "license": "http://polymer.github.io/LICENSE.txt", "homepage": "https://github.com/PolymerElements/paper-button", "dependencies": { "polymer": "Polymer/polymer#^1.1.0", - "paper-ripple": "polymerelements/paper-ripple#^1.0.0", - "paper-material": "polymerelements/paper-material#^1.0.0", - "paper-behaviors": "polymerelements/paper-behaviors#^1.0.0", - "iron-flex-layout": "polymerelements/iron-flex-layout#^1.0.0" + "iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0", + "paper-behaviors": "PolymerElements/paper-behaviors#^1.0.0", + "paper-material": "PolymerElements/paper-material#^1.0.0" }, "devDependencies": { - "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0", - "web-component-tester": "polymer/web-component-tester#^3.4.0", - "test-fixture": "polymerelements/test-fixture#^1.0.0", - "iron-component-page": "polymerelements/iron-component-page#^1.0.0", + "iron-component-page": "PolymerElements/iron-component-page#^1.0.0", "iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0", - "iron-icon": "polymerelements/iron-icon#^1.0.0", - "iron-icons": "polymerelements/iron-icons#^1.0.0", - "iron-test-helpers": "polymerelements/iron-test-helpers#^1.0.0", - "paper-styles": "polymerelements/paper-styles#^1.0.0" + "iron-icon": "PolymerElements/iron-icon#^1.0.0", + "iron-icons": "PolymerElements/iron-icons#^1.0.0", + "iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0", + "paper-styles": "PolymerElements/paper-styles#^1.0.0", + "test-fixture": "PolymerElements/test-fixture#^1.0.0", + "web-component-tester": "^4.0.0", + "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" }, "ignore": [] }
diff --git a/third_party/polymer/v1_0/components-chromium/paper-button/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/paper-button/compiled_resources2.gyp index 2d94155a..dcbfc92b 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-button/compiled_resources2.gyp +++ b/third_party/polymer/v1_0/components-chromium/paper-button/compiled_resources2.gyp
@@ -10,7 +10,6 @@ 'dependencies': [ '../paper-behaviors/compiled_resources2.gyp:paper-button-behavior-extracted', '../paper-material/compiled_resources2.gyp:paper-material-extracted', - '../paper-ripple/compiled_resources2.gyp:paper-ripple-extracted', ], 'includes': ['../../../../closure_compiler/compile_js2.gypi'], },
diff --git a/third_party/polymer/v1_0/components-chromium/paper-button/paper-button-extracted.js b/third_party/polymer/v1_0/components-chromium/paper-button/paper-button-extracted.js index defbf02..5dddd75 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-button/paper-button-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/paper-button/paper-button-extracted.js
@@ -1,36 +1,36 @@ Polymer({ - is: 'paper-button', + is: 'paper-button', - behaviors: [ - Polymer.PaperButtonBehavior - ], + behaviors: [ + Polymer.PaperButtonBehavior + ], - properties: { + properties: { + /** + * If true, the button should be styled with a shadow. + */ + raised: { + type: Boolean, + reflectToAttribute: true, + value: false, + observer: '_calculateElevation' + } + }, + + _calculateElevation: function() { + if (!this.raised) { + this._setElevation(0); + } else { + Polymer.PaperButtonBehaviorImpl._calculateElevation.apply(this); + } + } + /** - * If true, the button should be styled with a shadow. - */ - raised: { - type: Boolean, - reflectToAttribute: true, - value: false, - observer: '_calculateElevation' - } - }, + Fired when the animation finishes. + This is useful if you want to wait until + the ripple animation finishes to perform some action. - _calculateElevation: function() { - if (!this.raised) { - this._setElevation(0); - } else { - Polymer.PaperButtonBehaviorImpl._calculateElevation.apply(this); - } - } - /** - - Fired when the animation finishes. - This is useful if you want to wait until - the ripple animation finishes to perform some action. - - @event transitionend - @param {{node: Object}} detail Contains the animated node. - */ - }); \ No newline at end of file + @event transitionend + Event param: {{node: Object}} detail Contains the animated node. + */ + }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/paper-button/paper-button.html b/third_party/polymer/v1_0/components-chromium/paper-button/paper-button.html index 1bc3f15..03c07ac 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-button/paper-button.html +++ b/third_party/polymer/v1_0/components-chromium/paper-button/paper-button.html
@@ -7,10 +7,9 @@ Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt --><html><head><link rel="import" href="../polymer/polymer.html"> -<link rel="import" href="../paper-material/paper-material.html"> -<link rel="import" href="../paper-ripple/paper-ripple.html"> -<link rel="import" href="../paper-behaviors/paper-button-behavior.html"> <link rel="import" href="../iron-flex-layout/iron-flex-layout.html"> +<link rel="import" href="../paper-behaviors/paper-button-behavior.html"> +<link rel="import" href="../paper-material/paper-material.html"> <!-- Material design: [Buttons](https://www.google.com/design/spec/components/buttons.html) @@ -38,6 +37,14 @@ custom button content </paper-button> +To use `paper-button` as a link, wrap it in an anchor tag. Since `paper-button` will already +receive focus, you may want to prevent the anchor tag from receiving focus as well by setting +its tabindex to -1. + + <a href="https://www.polymer-project.org/" tabindex="-1"> + <paper-button raised>Polymer Project</paper-button> + </a> + ### Styling Style the button with CSS as you would a normal DOM element. @@ -74,16 +81,17 @@ </head><body><dom-module id="paper-button"> <template strip-whitespace=""> - <style include="paper-material"> :host { - display: inline-block; + @apply(--layout-inline); + @apply(--layout-center-center); position: relative; box-sizing: border-box; min-width: 5.14em; margin: 0 0.29em; background: transparent; - text-align: center; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); + -webkit-tap-highlight-color: transparent; font: inherit; text-transform: uppercase; outline-width: 0; @@ -96,6 +104,7 @@ z-index: 0; padding: 0.7em 0.57em; + @apply(--paper-font-common-base); @apply(--paper-button); } @@ -121,13 +130,10 @@ paper-ripple { color: var(--paper-button-ink-color); } - - :host > ::content * { - text-transform: inherit; - } </style> + <content></content> </template> -</dom-module> + </dom-module> <script src="paper-button-extracted.js"></script></body></html> \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/paper-checkbox/bower.json b/third_party/polymer/v1_0/components-chromium/paper-checkbox/bower.json index 8fb8d63..a9b874b 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-checkbox/bower.json +++ b/third_party/polymer/v1_0/components-chromium/paper-checkbox/bower.json
@@ -1,6 +1,6 @@ { "name": "paper-checkbox", - "version": "1.1.3", + "version": "1.2.0", "description": "A material design checkbox", "authors": [ "The Polymer Authors"
diff --git a/third_party/polymer/v1_0/components-chromium/paper-checkbox/paper-checkbox.html b/third_party/polymer/v1_0/components-chromium/paper-checkbox/paper-checkbox.html index caba70f..5a14d2b 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-checkbox/paper-checkbox.html +++ b/third_party/polymer/v1_0/components-chromium/paper-checkbox/paper-checkbox.html
@@ -38,9 +38,12 @@ `--paper-checkbox-checked-ink-color` | Selected/focus ripple color when the input is checked | `--primary-color` `--paper-checkbox-checkmark-color` | Checkmark color | `white` `--paper-checkbox-label-color` | Label color | `--primary-text-color` +`--paper-checkbox-label-checked-color` | Label color when the input is checked | `--paper-checkbox-label-color` `--paper-checkbox-label-spacing` | Spacing between the label and the checkbox | `8px` `--paper-checkbox-error-color` | Checkbox color when invalid | `--error-color` `--paper-checkbox-size` | Size of the checkbox | `18px` +`--paper-checkbox-margin` | Margin around the checkbox container | `initial` +`--paper-checkbox-vertical-align` | Vertical alignment of the checkbox container | `middle` This element applies the mixin `--paper-font-common-base` but does not import `paper-styles/typography.html`. In order to apply the `Roboto` font to this element, make sure you've imported `paper-styles/typography.html`. @@ -74,7 +77,8 @@ width: var(--calculated-paper-checkbox-size); height: var(--calculated-paper-checkbox-size); min-width: var(--calculated-paper-checkbox-size); - vertical-align: middle; + margin: var(--paper-checkbox-margin, initial); + vertical-align: var(--paper-checkbox-vertical-align, middle); background-color: var(--paper-checkbox-unchecked-background-color, transparent); } @@ -173,6 +177,10 @@ color: var(--paper-checkbox-label-color, --primary-text-color); } + :host([checked]) #checkboxLabel { + color: var(--paper-checkbox-label-checked-color, --paper-checkbox-label-color); + } + :host-context([dir="rtl"]) #checkboxLabel { padding-right: var(--paper-checkbox-label-spacing, 8px); padding-left: 0;
diff --git a/third_party/polymer/v1_0/components-chromium/paper-radio-button/bower.json b/third_party/polymer/v1_0/components-chromium/paper-radio-button/bower.json index d65439a..286366d 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-radio-button/bower.json +++ b/third_party/polymer/v1_0/components-chromium/paper-radio-button/bower.json
@@ -1,6 +1,6 @@ { "name": "paper-radio-button", - "version": "1.1.2", + "version": "1.2.0", "description": "A material design radio button", "authors": [ "The Polymer Authors" @@ -21,6 +21,7 @@ "ignore": [], "dependencies": { "iron-checked-element-behavior": "PolymerElements/iron-checked-element-behavior#^1.0.0", + "iron-flex-layout": "PolymerElements/iron-flex-layout#~1.3.0", "paper-behaviors": "PolymerElements/paper-behaviors#^1.0.0", "paper-styles": "PolymerElements/paper-styles#^1.1.0", "polymer": "Polymer/polymer#^1.1.0"
diff --git a/third_party/polymer/v1_0/components-chromium/paper-radio-button/paper-radio-button.html b/third_party/polymer/v1_0/components-chromium/paper-radio-button/paper-radio-button.html index 4afdf10c..64a2051 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-radio-button/paper-radio-button.html +++ b/third_party/polymer/v1_0/components-chromium/paper-radio-button/paper-radio-button.html
@@ -9,6 +9,7 @@ --><html><head><link rel="import" href="../polymer/polymer.html"> <link rel="import" href="../paper-behaviors/paper-checked-element-behavior.html"> <link rel="import" href="../paper-styles/default-theme.html"> +<link rel="import" href="../iron-flex-layout/iron-flex-layout.html"> <!-- Material design: [Radio button](https://www.google.com/design/spec/components/selection-controls.html#selection-controls-radio-button) @@ -36,6 +37,7 @@ `--paper-radio-button-unchecked-ink-color` | Selected/focus ripple color when the input is not checked | `--primary-text-color` `--paper-radio-button-checked-color` | Radio button color when the input is checked | `--primary-color` `--paper-radio-button-checked-ink-color` | Selected/focus ripple color when the input is checked | `--primary-color` +`--paper-radio-button-size` | Size of the radio button | `16px` `--paper-radio-button-label-color` | Label color | `--primary-text-color` `--paper-radio-button-label-spacing` | Spacing between the label and the button | `10px` @@ -53,9 +55,11 @@ <style> :host { display: inline-block; + line-height: 0; white-space: nowrap; cursor: pointer; @apply(--paper-font-common-base); + --calculated-paper-radio-button-size: var(--paper-radio-button-size, 16px); } :host(:focus) { @@ -63,27 +67,26 @@ } #radioContainer { - display: inline-block; + @apply(--layout-inline); + @apply(--layout-center-center); position: relative; - width: 16px; - height: 16px; + width: var(--calculated-paper-radio-button-size); + height: var(--calculated-paper-radio-button-size); vertical-align: middle; } #ink { position: absolute; - top: -16px; - left: -16px; - width: 48px; - height: 48px; + top: 50%; + left: 50%; + right: auto; + width: calc(3 * var(--calculated-paper-radio-button-size)); + height: calc(3 * var(--calculated-paper-radio-button-size)); color: var(--paper-radio-button-unchecked-ink-color, --primary-text-color); opacity: 0.6; pointer-events: none; - } - - :host-context([dir="rtl"]) #ink { - right: -15px; - left: auto; + -webkit-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); } #ink[checked] { @@ -92,12 +95,12 @@ #offRadio { position: absolute; - box-sizing: content-box; - top: 0px; - left: 0px; - right: 0px; - width: 12px; - height: 12px; + box-sizing: border-box; + top: 0; + left: 0; + right: 0; + width: 100%; + height: 100%; border-radius: 50%; border: solid 2px; background-color: var(--paper-radio-button-unchecked-background-color, transparent); @@ -106,13 +109,9 @@ } #onRadio { - position: absolute; box-sizing: content-box; - top: 4px; - left: 4px; - right: 4px; - width: 8px; - height: 8px; + width: 50%; + height: 50%; border-radius: 50%; background-color: var(--paper-radio-button-checked-color, --primary-color); -webkit-transform: scale(0); @@ -132,6 +131,7 @@ } #radioLabel { + line-height: normal; position: relative; display: inline-block; vertical-align: middle; @@ -141,7 +141,7 @@ } :host-context([dir="rtl"]) #radioLabel { - margin-left: 0px; + margin-left: 0; margin-right: var(--paper-radio-button-label-spacing, 10px); }
diff --git a/third_party/polymer/v1_0/components-chromium/paper-radio-group/bower.json b/third_party/polymer/v1_0/components-chromium/paper-radio-group/bower.json index 38b25a8..a26b81f2 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-radio-group/bower.json +++ b/third_party/polymer/v1_0/components-chromium/paper-radio-group/bower.json
@@ -1,6 +1,6 @@ { "name": "paper-radio-group", - "version": "1.1.0", + "version": "1.2.0", "description": "A group of material design radio buttons", "authors": [ "The Polymer Authors" @@ -20,9 +20,8 @@ "homepage": "https://github.com/PolymerElements/paper-radio-group", "ignore": [], "dependencies": { - "iron-a11y-keys-behavior": "PolymerElements/iron-a11y-keys-behavior#^1.0.0", - "iron-selector": "PolymerElements/iron-selector#^1.0.0", - "polymer": "Polymer/polymer#^1.1.0" + "polymer": "Polymer/polymer#^1.1.0", + "iron-menu-behavior": "PolymerElements/iron-menu-behavior#^1.1.7" }, "devDependencies": { "iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
diff --git a/third_party/polymer/v1_0/components-chromium/paper-radio-group/compiled_resources2.gyp b/third_party/polymer/v1_0/components-chromium/paper-radio-group/compiled_resources2.gyp index 67391b7a..4b5ab72 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-radio-group/compiled_resources2.gyp +++ b/third_party/polymer/v1_0/components-chromium/paper-radio-group/compiled_resources2.gyp
@@ -9,7 +9,7 @@ 'target_name': 'paper-radio-group-extracted', 'dependencies': [ '../iron-a11y-keys-behavior/compiled_resources2.gyp:iron-a11y-keys-behavior-extracted', - '../iron-selector/compiled_resources2.gyp:iron-selectable-extracted', + '../iron-menu-behavior/compiled_resources2.gyp:iron-menubar-behavior-extracted', '../paper-radio-button/compiled_resources2.gyp:paper-radio-button-extracted', ], 'includes': ['../../../../closure_compiler/compile_js2.gypi'],
diff --git a/third_party/polymer/v1_0/components-chromium/paper-radio-group/paper-radio-group-extracted.js b/third_party/polymer/v1_0/components-chromium/paper-radio-group/paper-radio-group-extracted.js index 4306410..642f8ec 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-radio-group/paper-radio-group-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/paper-radio-group/paper-radio-group-extracted.js
@@ -2,8 +2,7 @@ is: 'paper-radio-group', behaviors: [ - Polymer.IronA11yKeysBehavior, - Polymer.IronSelectableBehavior + Polymer.IronMenubarBehavior ], hostAttributes: { @@ -51,15 +50,15 @@ } }, - keyBindings: { - 'left up': 'selectPrevious', - 'right down': 'selectNext', - }, - /** * Selects the given value. */ select: function(value) { + var newItem = this._valueToItem(value); + if (newItem && newItem.hasAttribute('disabled')) { + return; + } + if (this.selected) { var oldItem = this._valueToItem(this.selected); @@ -84,33 +83,29 @@ this.fire('paper-radio-group-changed'); }, - /** - * Selects the previous item. If the previous item is disabled, then it is - * skipped, and its previous item is selected - */ - selectPrevious: function() { - var length = this.items.length; - var newIndex = Number(this._valueToIndex(this.selected)); - - do { - newIndex = (newIndex - 1 + length) % length; - } while (this.items[newIndex].disabled) - - this._itemActivate(this._indexToValue(newIndex), this.items[newIndex]); + _activateFocusedItem: function() { + this._itemActivate(this._valueForItem(this.focusedItem), this.focusedItem); }, - /** - * Selects the next item. If the next item is disabled, then it is - * skipped, and the next item after it is selected. - */ - selectNext: function() { - var length = this.items.length; - var newIndex = Number(this._valueToIndex(this.selected)); - - do { - newIndex = (newIndex + 1 + length) % length; - } while (this.items[newIndex].disabled) - - this._itemActivate(this._indexToValue(newIndex), this.items[newIndex]); + _onUpKey: function(event) { + this._focusPrevious(); + event.preventDefault(); + this._activateFocusedItem(); }, + + _onDownKey: function(event) { + this._focusNext(); + event.preventDefault(); + this._activateFocusedItem(); + }, + + _onLeftKey: function(event) { + Polymer.IronMenubarBehaviorImpl._onLeftKey.apply(this, arguments); + this._activateFocusedItem(); + }, + + _onRightKey: function(event) { + Polymer.IronMenubarBehaviorImpl._onRightKey.apply(this, arguments); + this._activateFocusedItem(); + } }); \ No newline at end of file
diff --git a/third_party/polymer/v1_0/components-chromium/paper-radio-group/paper-radio-group.html b/third_party/polymer/v1_0/components-chromium/paper-radio-group/paper-radio-group.html index 7fe8dbe..41c406b 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-radio-group/paper-radio-group.html +++ b/third_party/polymer/v1_0/components-chromium/paper-radio-group/paper-radio-group.html
@@ -8,7 +8,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt --><html><head><link rel="import" href="../polymer/polymer.html"> <link rel="import" href="../iron-a11y-keys-behavior/iron-a11y-keys-behavior.html"> -<link rel="import" href="../iron-selector/iron-selectable.html"> +<link rel="import" href="../iron-menu-behavior/iron-menubar-behavior.html"> <link rel="import" href="../paper-radio-button/paper-radio-button.html"> <!--
diff --git a/third_party/polymer/v1_0/components-chromium/paper-slider/bower.json b/third_party/polymer/v1_0/components-chromium/paper-slider/bower.json index 8c713867..9504c0e 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-slider/bower.json +++ b/third_party/polymer/v1_0/components-chromium/paper-slider/bower.json
@@ -1,6 +1,6 @@ { "name": "paper-slider", - "version": "1.0.10", + "version": "1.0.11", "description": "A material design-style slider", "license": "http://polymer.github.io/LICENSE.txt", "authors": "The Polymer Authors",
diff --git a/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider-extracted.js b/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider-extracted.js index 03e72d88..d495c5a 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider-extracted.js +++ b/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider-extracted.js
@@ -65,8 +65,7 @@ maxMarkers: { type: Number, value: 0, - notify: true, - observer: '_maxMarkersChanged' + notify: true }, /** @@ -103,7 +102,8 @@ observers: [ '_updateKnob(value, min, max, snaps, step)', '_valueChanged(value)', - '_immediateValueChanged(immediateValue)' + '_immediateValueChanged(immediateValue)', + '_updateMarkers(maxMarkers, min, max, snaps)' ], hostAttributes: { @@ -116,13 +116,6 @@ 'right up pageup end': '_incrementKey' }, - ready: function() { - // issue polymer/polymer#1305 - this.async(function() { - this._updateKnob(this.value); - }, 1); - }, - /** * Increases value by `step` but not above `max`. * @method increment @@ -289,11 +282,11 @@ } }, - _maxMarkersChanged: function(maxMarkers) { - if (!this.snaps) { + _updateMarkers: function(maxMarkers, min, max, snaps) { + if (!snaps) { this._setMarkers([]); } - var steps = Math.round((this.max - this.min) / this.step); + var steps = Math.round((max - min) / this.step); if (steps > maxMarkers) { steps = maxMarkers; } @@ -383,7 +376,12 @@ */ /** - * Fired when the slider's immediateValue changes. + * Fired when the slider's immediateValue changes. Only occurs while the + * user is dragging. + * + * To detect changes to immediateValue that happen for any input (i.e. + * dragging, tapping, clicking, etc.) listen for immediate-value-changed + * instead. * * @event immediate-value-change */
diff --git a/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider.html b/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider.html index 9863185..365efcd 100644 --- a/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider.html +++ b/third_party/polymer/v1_0/components-chromium/paper-slider/paper-slider.html
@@ -40,6 +40,7 @@ Custom property | Description | Default ----------------|-------------|---------- +`--paper-slider-container-color` | The background color of the bar | `--paper-grey-400` `--paper-slider-bar-color` | The background color of the slider | `transparent` `--paper-slider-active-color` | The progress bar color | `--google-blue-700` `--paper-slider-secondary-color` | The secondary progress bar color | `--google-blue-300` @@ -129,7 +130,7 @@ padding: 15px 0; width: 100%; background-color: var(--paper-slider-bar-color, transparent); - --paper-progress-container-color: var(--paper-grey-400); + --paper-progress-container-color: var(--paper-slider-container-color, --paper-grey-400); --paper-progress-height: var(--paper-slider-height, 2px); } @@ -298,7 +299,6 @@ </style> <div id="sliderContainer" class$="[[_getClassNames(disabled, pin, snaps, immediateValue, min, expand, dragging, transiting, editable)]]"> - <div class="bar-container"> <paper-progress disabled$="[[disabled]]" id="sliderBar" aria-hidden="true" min="[[min]]" max="[[max]]" step="[[step]]" value="[[immediateValue]]" secondary-progress="[[secondaryProgress]]" on-down="_bardown" on-up="_resetKnob" on-track="_onTrack"> </paper-progress>
diff --git a/third_party/polymer/v1_0/components_summary.txt b/third_party/polymer/v1_0/components_summary.txt index ecd17915..8b2b553 100644 --- a/third_party/polymer/v1_0/components_summary.txt +++ b/third_party/polymer/v1_0/components_summary.txt
@@ -1,9 +1,16 @@ -Name: carbon-route -Version: 0.8.4 -Repository: git://github.com/PolymerElements/carbon-route.git -Tag: v0.8.4 -Revision: 8045361d4e158d6e4126ecf9c14b172317b0f1fa -Tree link: https://github.com/PolymerElements/carbon-route/tree/v0.8.4 +Name: app-layout +Version: 0.9.0 +Repository: git://github.com/PolymerElements/app-layout.git +Tag: v0.9.0 +Revision: 60f3e7fc8d0dcd9e824b47d768fc68c6e553618c +Tree link: https://github.com/PolymerElements/app-layout/tree/v0.9.0 + +Name: app-route +Version: 0.9.1 +Repository: git://github.com/PolymerElements/app-route.git +Tag: v0.9.1 +Revision: d51b0bfd216720a4c4900547a2793c1927294127 +Tree link: https://github.com/PolymerElements/app-route/tree/v0.9.1 Name: font-roboto Version: 1.0.1 @@ -20,11 +27,11 @@ Tree link: https://github.com/PolymerElements/iron-a11y-announcer/tree/v1.0.4 Name: iron-a11y-keys -Version: 1.0.4 +Version: 1.0.5 Repository: git://github.com/PolymerElements/iron-a11y-keys.git -Tag: v1.0.4 -Revision: 51a34396a392bcfb45592900973c35eceb11f0d7 -Tree link: https://github.com/PolymerElements/iron-a11y-keys/tree/v1.0.4 +Tag: v1.0.5 +Revision: e3369954dec2daa5037515aad9d1cb46eb78258b +Tree link: https://github.com/PolymerElements/iron-a11y-keys/tree/v1.0.5 Name: iron-a11y-keys-behavior Version: 1.1.2 @@ -62,18 +69,18 @@ Tree link: https://github.com/PolymerElements/iron-collapse/tree/v1.0.8 Name: iron-dropdown -Version: 1.4.0 +Version: 1.4.1 Repository: git://github.com/PolymerElements/iron-dropdown.git -Tag: v1.4.0 -Revision: 8e14da0aaeb791983ee4b254890c7263644f7851 -Tree link: https://github.com/PolymerElements/iron-dropdown/tree/v1.4.0 +Tag: v1.4.1 +Revision: fc5ce3d2ee6be97beef00b9456e6e06498408401 +Tree link: https://github.com/PolymerElements/iron-dropdown/tree/v1.4.1 Name: iron-fit-behavior -Version: 1.2.0 +Version: 1.2.2 Repository: git://github.com/PolymerElements/iron-fit-behavior.git -Tag: v1.2.0 -Revision: 9f170448fc76b0051e1a4d36c87e33346ee1ce67 -Tree link: https://github.com/PolymerElements/iron-fit-behavior/tree/v1.2.0 +Tag: v1.2.2 +Revision: 1f325ea7d109a3bb88927f825ed1014e7041aa7d +Tree link: https://github.com/PolymerElements/iron-fit-behavior/tree/v1.2.2 Name: iron-flex-layout Version: 1.3.1 @@ -125,11 +132,11 @@ Tree link: https://github.com/PolymerElements/iron-list/tree/v1.3.1 Name: iron-location -Version: 0.8.2 +Version: 0.8.3 Repository: git://github.com/PolymerElements/iron-location.git -Tag: v0.8.2 -Revision: 9ab0b3bf4b30e00d1f80dcb1cf9e00bd17cce4a5 -Tree link: https://github.com/PolymerElements/iron-location/tree/v0.8.2 +Tag: v0.8.3 +Revision: cb124aa740c07d2b65af1d7e05a3cf8fd6a25f87 +Tree link: https://github.com/PolymerElements/iron-location/tree/v0.8.3 Name: iron-media-query Version: 1.0.8 @@ -139,11 +146,11 @@ Tree link: https://github.com/PolymerElements/iron-media-query/tree/v1.0.8 Name: iron-menu-behavior -Version: 1.1.6 +Version: 1.1.7 Repository: git://github.com/PolymerElements/iron-menu-behavior.git -Tag: v1.1.6 -Revision: 940c2769c7d6fefd5685e0200c3dfd0742c2a52f -Tree link: https://github.com/PolymerElements/iron-menu-behavior/tree/v1.1.6 +Tag: v1.1.7 +Revision: ea59e6ce5644d8f7a20c22f13f614ea60604a812 +Tree link: https://github.com/PolymerElements/iron-menu-behavior/tree/v1.1.7 Name: iron-meta Version: 1.1.1 @@ -153,11 +160,11 @@ Tree link: https://github.com/PolymerElements/iron-meta/tree/v1.1.1 Name: iron-overlay-behavior -Version: 1.7.3 +Version: 1.7.6 Repository: git://github.com/PolymerElements/iron-overlay-behavior.git -Tag: v1.7.3 -Revision: eba25fe58215aca5545e7d32fefa74d8b25b49c2 -Tree link: https://github.com/PolymerElements/iron-overlay-behavior/tree/v1.7.3 +Tag: v1.7.6 +Revision: cd7f5ed66e4cde517646eec921331efe7d9d8544 +Tree link: https://github.com/PolymerElements/iron-overlay-behavior/tree/v1.7.6 Name: iron-pages Version: 1.0.7 @@ -167,11 +174,11 @@ Tree link: https://github.com/PolymerElements/iron-pages/tree/v1.0.7 Name: iron-range-behavior -Version: 1.0.4 +Version: 1.0.5 Repository: git://github.com/PolymerElements/iron-range-behavior.git -Tag: v1.0.4 -Revision: 71774a7d8a8c377496bfe05e60b754e91216e0b9 -Tree link: https://github.com/PolymerElements/iron-range-behavior/tree/v1.0.4 +Tag: v1.0.5 +Revision: 645ffc6b39ae4fb0efd23b97016a9c4aac777978 +Tree link: https://github.com/PolymerElements/iron-range-behavior/tree/v1.0.5 Name: iron-resizable-behavior Version: 1.0.3 @@ -195,11 +202,11 @@ Tree link: https://github.com/PolymerElements/iron-scroll-threshold/tree/v1.0.1 Name: iron-selector -Version: 1.5.1 +Version: 1.5.2 Repository: git://github.com/PolymerElements/iron-selector.git -Tag: v1.5.1 -Revision: e3e34408fad8f7cde59c4255cf3fe90f7dcf91d8 -Tree link: https://github.com/PolymerElements/iron-selector/tree/v1.5.1 +Tag: v1.5.2 +Revision: 18e8e12dcd9a4560de480562f65935feed334b86 +Tree link: https://github.com/PolymerElements/iron-selector/tree/v1.5.2 Name: iron-test-helpers Version: 1.2.5 @@ -230,18 +237,18 @@ Tree link: https://github.com/PolymerElements/paper-behaviors/tree/v1.0.11 Name: paper-button -Version: 1.0.11 +Version: 1.0.12 Repository: git://github.com/PolymerElements/paper-button.git -Tag: v1.0.11 -Revision: 7d0f75300372d91835ae7298593d50987d4a610f -Tree link: https://github.com/PolymerElements/paper-button/tree/v1.0.11 +Tag: v1.0.12 +Revision: 96c3a2661c355223d0b41e1d34126f9c62d544dc +Tree link: https://github.com/PolymerElements/paper-button/tree/v1.0.12 Name: paper-checkbox -Version: 1.1.3 +Version: 1.2.0 Repository: git://github.com/PolymerElements/paper-checkbox.git -Tag: v1.1.3 -Revision: b2698fd0d34153e89369f116f306bc8e8203a460 -Tree link: https://github.com/PolymerElements/paper-checkbox/tree/v1.1.3 +Tag: v1.2.0 +Revision: 0a0b623b5d6356a24e1a00095f0d58b05341cf49 +Tree link: https://github.com/PolymerElements/paper-checkbox/tree/v1.2.0 Name: paper-dialog Version: 1.0.4 @@ -342,18 +349,18 @@ Tree link: https://github.com/PolymerElements/paper-progress/tree/v1.0.9 Name: paper-radio-button -Version: 1.1.2 +Version: 1.2.0 Repository: git://github.com/PolymerElements/paper-radio-button.git -Tag: v1.1.2 -Revision: e757d45011d2fe9ccc91b5e28f68656a8dff1730 -Tree link: https://github.com/PolymerElements/paper-radio-button/tree/v1.1.2 +Tag: v1.2.0 +Revision: 2c21e738ad9e4338399e53254c506fb825b11098 +Tree link: https://github.com/PolymerElements/paper-radio-button/tree/v1.2.0 Name: paper-radio-group -Version: 1.1.0 +Version: 1.2.0 Repository: git://github.com/PolymerElements/paper-radio-group.git -Tag: v1.1.0 -Revision: 1e918232809e7c6dca422b038be60b63bf09ade6 -Tree link: https://github.com/PolymerElements/paper-radio-group/tree/v1.1.0 +Tag: v1.2.0 +Revision: 1505d1a57fbeabcb779de3e9f0e9857acd8b5f13 +Tree link: https://github.com/PolymerElements/paper-radio-group/tree/v1.2.0 Name: paper-ripple Version: 1.0.5 @@ -363,11 +370,11 @@ Tree link: https://github.com/PolymerElements/paper-ripple/tree/v1.0.5 Name: paper-slider -Version: 1.0.10 +Version: 1.0.11 Repository: git://github.com/PolymerElements/paper-slider.git -Tag: v1.0.10 -Revision: 9b71cd988af6b000403a6f59c51ea6c789ded930 -Tree link: https://github.com/PolymerElements/paper-slider/tree/v1.0.10 +Tag: v1.0.11 +Revision: 855e3ed20d12b4545175317536adca7897928537 +Tree link: https://github.com/PolymerElements/paper-slider/tree/v1.0.11 Name: paper-spinner Version: 1.1.1
diff --git a/third_party/polymer/v1_0/find_unused_elements.py b/third_party/polymer/v1_0/find_unused_elements.py index a928c1b..202eca7 100755 --- a/third_party/polymer/v1_0/find_unused_elements.py +++ b/third_party/polymer/v1_0/find_unused_elements.py
@@ -20,8 +20,10 @@ # Unused elements to ignore because we plan to use them soon. __WHITELIST = ( + # TODO(tsergeant): Use element or remove from whitelist. + 'app-layout', # TODO(dschuyler): Use element or remove from whitelist. - 'carbon-route', + 'app-route', # Necessary for closure. 'polymer-externs', )
diff --git a/third_party/polymer/v1_0/rsync_exclude.txt b/third_party/polymer/v1_0/rsync_exclude.txt index 8ed53df..19f9628 100644 --- a/third_party/polymer/v1_0/rsync_exclude.txt +++ b/third_party/polymer/v1_0/rsync_exclude.txt
@@ -1,9 +1,11 @@ .bower.json build.log +build.sh compiled_resources*.gyp */demo/ demo*.html */demos/ +docs.html .github .gitignore hero.svg @@ -13,3 +15,8 @@ */test/ */tests/ .travis.yml + +# app-layout specific +*/patterns/ +*/site/ +*/templates/
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index c5d4dc0..6f6c7e1 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -133,7 +133,7 @@ 'ClangToTAndroidASan': 'android_clang_tot_asan', 'ClangToTAndroidASan tester': 'none', 'ClangToTLinux': - 'swarming_gyp_clang_tot_linux_dump_symbols_shared_release', + 'swarming_gn_clang_tot_linux_full_symbols_shared_release', 'ClangToTLinux tester': 'none', 'ClangToTLinux (dbg)': 'swarming_clang_tot_shared_debug', 'ClangToTLinuxASan': 'swarming_gyp_clang_tot_asan_lsan_static_release', @@ -714,7 +714,7 @@ 'linux_chromium_archive_rel_ng': 'noswarming_gn_release_bot', 'linux_chromium_asan_rel_ng': 'swarming_asan_lsan_gyp_release_trybot', 'linux_chromium_asan_variable': 'findit', - 'linux_chromium_browser_side_navigation_rel': 'gyp_release_trybot', + 'linux_chromium_browser_side_navigation_rel': 'gn_release_trybot', 'linux_chromium_cast_variable': 'findit', 'linux_chromium_cfi_rel_ng': 'gn_cfi_release_static_dcheck_always_on', 'linux_chromium_chromeos_asan_rel_ng': @@ -1342,10 +1342,6 @@ 'gyp', 'release_bot_minimal_symbols', 'x86' ], - 'gyp_release_trybot': [ - 'gyp', 'release_trybot', - ], - 'gyp_release_trybot_x64': [ 'gyp', 'release_trybot', 'x64', ], @@ -1738,11 +1734,10 @@ 'static', 'release', ], - 'swarming_gyp_clang_tot_linux_dump_symbols_shared_release': [ + 'swarming_gn_clang_tot_linux_full_symbols_shared_release': [ # Enable debug info, as on official builders, to catch issues with # optimized debug info. - 'swarming', 'gyp', 'clang_tot', 'linux_dump_symbols', - 'shared', 'release', + 'swarming', 'gn', 'clang_tot', 'full_symbols', 'shared', 'release', ], 'swarming_gyp_clang_tot_minimal_symbols_shared_debug': [ @@ -2102,11 +2097,6 @@ 'gyp_defines': 'debug_extra_cflags="-gline-tables-only"', }, - 'linux_dump_symbols': { - 'gn_args': 'error', # TODO(crbug.com/605819): implement this. - 'gyp_defines': 'linux_dump_symbols=1', - }, - 'ubsan_security': { 'gn_args': 'is_ubsan_security=true' }, 'lsan': {
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 65eca50a..58e7a6dc 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -3434,6 +3434,11 @@ </summary> </histogram> +<histogram name="Blink.Binding.InitializeWindowProxy" units="ms"> + <owner>peria@chromium.org</owner> + <summary>Time spent initializing WindowProxy during a page loading.</summary> +</histogram> + <histogram name="Blink.Compositing.UpdateTime" units="microseconds"> <owner>paint-dev@chromium.org</owner> <summary> @@ -3441,11 +3446,54 @@ </summary> </histogram> +<histogram name="Blink.DecodedImage.CanvasExpanded" + enum="BooleanCanvasExpanded"> + <owner>ryansturm@chromium.org</owner> + <owner>bengr@google.com</owner> + <summary> + The original canvas dimensions were sufficient to determine image size. This + is logged once per image header decode, which happens typically twice per + image on the page. + </summary> +</histogram> + +<histogram name="Blink.DecodedImage.EffectiveDimensionsLocation" units="bytes"> + <owner>ryansturm@chromium.org</owner> + <owner>bengr@google.com</owner> + <summary> + How many bytes of the file were read before an image width and height were + determined. This is logged once per image header decode, which happens + typically twice per image on the page. + </summary> +</histogram> + <histogram name="Blink.DecodedImage.Orientation" enum="DecodedImageOrientation"> <owner>rob.buis@samsung.org</owner> <summary>Image orientation inferred during decode.</summary> </histogram> +<histogram name="Blink.DecodedImage.XCanvasExpansion" units="bytes"> + <owner>ryansturm@chromium.org</owner> + <owner>bengr@google.com</owner> + <summary> + How much the canvas width needed to be expanded as a result of the first + frame's width and x-offset being larger than the initial canvas width. This + is logged once per image header decode, which happens typically twice per + image on the page. + </summary> +</histogram> + +<histogram name="Blink.DecodedImage.YCanvasExpansion" units="bytes"> + <owner>ryansturm@chromium.org</owner> + <owner>bengr@google.com</owner> + <summary> + How much the canvas height needed to be expanded as a result of the first + frame's height and y-offset being larger than the initial canvas height. + This is logged once per image header decode, which happens typically twice + per image on the page. + </summary> +</histogram> + <histogram name="Blink.DecodedImageType" enum="DecodedImageType"> <owner>urvang@chromium.org</owner> <summary>Image codec inferred during decode.</summary> @@ -33762,6 +33810,26 @@ </summary> </histogram> +<histogram name="NewTabPage.Snippets.CardClickedAge" units="min"> + <owner>jkrcal@chromium.org</owner> + <summary> + Android: The age of the snippets card on the NTP, that is clicked through to + the host website of the content. The age is measured from the moment the + content has been published. In each "_x_y" suffix of the + histogram, only snippets on positions \gt;=x and \lt;=y are tracked. + </summary> +</histogram> + +<histogram name="NewTabPage.Snippets.CardClickedScore" units="score"> + <owner>jkrcal@chromium.org</owner> + <summary> + Android: The score of the snippets card on the NTP, that is clicked through + to the host website of the content. The recorded score is from the moment + the snippet was fetched, it could have changed since. In each "_x" + suffix of the histogram, only snippets on positions \lt;=x are tracked. + </summary> +</histogram> + <histogram name="NewTabPage.Snippets.CardExpanded"> <owner>knn@chromium.org</owner> <summary> @@ -37219,6 +37287,44 @@ </summary> </histogram> +<histogram name="Permissions.Prompt.Accepted" enum="PermissionBubbleType"> + <owner>benwells@chromium.org</owner> + <owner>tsergeant@chromium.org</owner> + <summary> + Tracks the permission bubbles (merged and non-merged) that are accepted. + Merged bubbles are considered accepted if all permissions are allowed. + </summary> +</histogram> + +<histogram name="Permissions.Prompt.Denied" enum="PermissionBubbleType"> + <owner>benwells@chromium.org</owner> + <owner>tsergeant@chromium.org</owner> + <summary> + Tracks the permission bubbles (merged and non-merged) that are denied. + Merged bubbles are considered denied if any permission is denied. + </summary> +</histogram> + +<histogram name="Permissions.Prompt.MergedBubbleAccepted" + enum="PermissionBubbleType"> + <owner>benwells@chromium.org</owner> + <owner>tsergeant@chromium.org</owner> + <summary> + Tracks acceptance of permission bubble request types that have been merged + into coalesced bubbles. + </summary> +</histogram> + +<histogram name="Permissions.Prompt.MergedBubbleDenied" + enum="PermissionBubbleType"> + <owner>benwells@chromium.org</owner> + <owner>tsergeant@chromium.org</owner> + <summary> + Tracks denial of permission bubble request types that have been merged into + coalesced bubbles. + </summary> +</histogram> + <histogram name="Permissions.Prompt.MergedBubbleTypes" enum="PermissionBubbleType"> <owner>benwells@chromium.org</owner> @@ -64472,6 +64578,11 @@ <int value="1" label="Can check"/> </enum> +<enum name="BooleanCanvasExpanded" type="int"> + <int value="0" label="Original canvas dimensions were sufficient"/> + <int value="1" label="First image frame dimension were needed"/> +</enum> + <enum name="BooleanChanged" type="int"> <int value="0" label="Not changed"/> <int value="1" label="Changed"/> @@ -71578,6 +71689,10 @@ <int value="1129" label="BLUETOOTHLOWENERGY_REMOVESERVICE"/> <int value="1130" label="AUTOFILLPRIVATE_GETADDRESSLIST"/> <int value="1131" label="AUTOFILLPRIVATE_GETCREDITCARDLIST"/> + <int value="1132" label="SYSTEM_DISPLAY_OVERSCANCALIBRATIONSTART"/> + <int value="1133" label="SYSTEM_DISPLAY_OVERSCANCALIBRATIONADJUST"/> + <int value="1134" label="SYSTEM_DISPLAY_OVERSCANCALIBRATIONRESET"/> + <int value="1135" label="SYSTEM_DISPLAY_OVERSCANCALIBRATIONCOMPLETE"/> </enum> <enum name="ExtensionInstallCause" type="int"> @@ -78201,6 +78316,7 @@ <int value="-1497338981" label="disable-accelerated-overflow-scroll"/> <int value="-1490298774" label="enable-captive-portal-bypass-proxy-option"/> <int value="-1482685863" label="enable-request-tablet-site"/> + <int value="-1478876902" label="disable-permission-action-reporting"/> <int value="-1467332609" label="tab-management-experiment-type-anise"/> <int value="-1460462432" label="disable-media-source"/> <int value="-1440152291" label="disable-gesture-typing"/> @@ -78483,6 +78599,7 @@ <int value="610545308" label="enable-potentially-annoying-security-features"/> <int value="625273056" label="disable-boot-animation"/> <int value="630947363" label="touch-events"/> + <int value="636425179" label="mhtml-generator-option"/> <int value="643725031" label="disable-touch-feedback"/> <int value="646738320" label="disable-gesture-editing"/> <int value="650602639" label="enable-autofill-keyboard-accessory-view"/> @@ -78561,6 +78678,7 @@ <int value="1150622273" label="enable-apps-file-associations"/> <int value="1163255347" label="ash-enable-touch-view-touch-feedback"/> <int value="1166169237" label="disable-delay-agnostic-aec"/> + <int value="1167613030" label="enable-permission-action-reporting"/> <int value="1174088940" label="enable-wasm"/> <int value="1181056275" label="enable-cloud-backup"/> <int value="1183431946" label="v8-cache-options"/> @@ -92591,6 +92709,18 @@ <affected-histogram name="PLT.BeginToFinish_NormalLoad"/> </histogram_suffixes> +<histogram_suffixes name="ImageDecoderFileTypes" separator="."> + <suffix name="BMP" label="Image decoded as BMP"/> + <suffix name="GIF" label="Image decoded as GIF"/> + <suffix name="ICO" label="Image decoded as ICO"/> + <suffix name="JPEG" label="Image decoded as JPEG"/> + <suffix name="PNG" label="Image decoded as PNG"/> + <affected-histogram name="Blink.DecodedImage.CanvasExpanded"/> + <affected-histogram name="Blink.DecodedImage.EffectiveDimensionsLocation"/> + <affected-histogram name="Blink.DecodedImage.XCanvasExpansion"/> + <affected-histogram name="Blink.DecodedImage.YCanvasExpansion"/> +</histogram_suffixes> + <histogram_suffixes name="IMEAutoCorrect" separator="."> <suffix name="AC0" label="The auto-correct level is 0"/> <suffix name="AC1" label="The auto-correct level is 1"/> @@ -95052,6 +95182,15 @@ <affected-histogram name="NaCl.Perf.Size.PNaClTranslatedNexe"/> </histogram_suffixes> +<histogram_suffixes name="PositionVariants"> + <suffix name="0_0" label="Only snippets on position 0"/> + <suffix name="1_2" label="Only snippets on position 1-2"/> + <suffix name="3_4" label="Only snippets on position 3-4"/> + <suffix name="5_9" label="Only snippets on position 5-9"/> + <affected-histogram name="NewTabPage.Snippets.CardClickedAge"/> + <affected-histogram name="NewTabPage.Snippets.CardClickedScore"/> +</histogram_suffixes> + <histogram_suffixes name="PpapiPluginName"> <suffix name="libpepflashplayer.so" label="Flash player on Linux or Cros"/> <suffix name="libwidevinecdmadapter.so"
diff --git a/tools/perf/benchmarks/page_cycler_v2.py b/tools/perf/benchmarks/page_cycler_v2.py new file mode 100644 index 0000000..f6654e99 --- /dev/null +++ b/tools/perf/benchmarks/page_cycler_v2.py
@@ -0,0 +1,43 @@ +# 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. + +"""The page cycler v2. + +For details, see design doc: +https://docs.google.com/document/d/1EZQX-x3eEphXupiX-Hq7T4Afju5_sIdxPWYetj7ynd0 +""" + +from core import perf_benchmark +import page_sets + +from telemetry.page import cache_temperature +from telemetry.timeline import tracing_category_filter +from telemetry.web_perf import timeline_based_measurement + +class _PageCyclerV2(perf_benchmark.PerfBenchmark): + def CreateTimelineBasedMeasurementOptions(self): + cat_filter = tracing_category_filter.TracingCategoryFilter( + filter_string='*,blink.console,navigation,blink.user_timing,loading') + + tbm_options = timeline_based_measurement.Options( + overhead_level=cat_filter) + tbm_options.SetTimelineBasedMetric('firstPaintMetric') + return tbm_options + +class PageCyclerTypical25(_PageCyclerV2): + """Page load time benchmark for a 25 typical web pages. + + Designed to represent typical, not highly optimized or highly popular web + sites. Runs against pages recorded in June, 2014. + """ + options = {'pageset_repeat': 3} + + @classmethod + def Name(cls): + return 'page_cycler_v2.typical_25' + + def CreateStorySet(self, options): + return page_sets.Typical25PageSet(run_no_page_interactions=True, + cache_temperatures=[ + cache_temperature.PCV1_COLD, cache_temperature.PCV1_WARM])
diff --git a/tools/perf/page_sets/typical_25.py b/tools/perf/page_sets/typical_25.py index f871ede..8f056c1 100644 --- a/tools/perf/page_sets/typical_25.py +++ b/tools/perf/page_sets/typical_25.py
@@ -6,6 +6,7 @@ from profile_creators import profile_generator from telemetry.page import page as page_module +from telemetry.page import cache_temperature as cache_temperature_module from telemetry.page import shared_page_state from telemetry import story @@ -39,10 +40,12 @@ class Typical25Page(page_module.Page): def __init__(self, url, page_set, run_no_page_interactions, - shared_page_state_class=shared_page_state.SharedDesktopPageState): + shared_page_state_class=shared_page_state.SharedDesktopPageState, + cache_temperature=None): super(Typical25Page, self).__init__( url=url, page_set=page_set, - shared_page_state_class=shared_page_state_class) + shared_page_state_class=shared_page_state_class, + cache_temperature=cache_temperature) self._run_no_page_interactions = run_no_page_interactions def RunPageInteractions(self, action_runner): @@ -57,10 +60,13 @@ """ Pages designed to represent the median, not highly optimized web """ def __init__(self, run_no_page_interactions=False, - page_class=Typical25Page): + page_class=Typical25Page, + cache_temperatures=None): super(Typical25PageSet, self).__init__( archive_data_file='data/typical_25.json', cloud_storage_bucket=story.PARTNER_BUCKET) + if cache_temperatures is None: + cache_temperatures = [cache_temperature_module.ANY] urls_list = [ # Why: Alexa games #48 @@ -104,5 +110,6 @@ ] for url in urls_list: - self.AddStory( - page_class(url, self, run_no_page_interactions)) + for temp in cache_temperatures: + self.AddStory(page_class( + url, self, run_no_page_interactions, cache_temperature=temp))
diff --git a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js index 4e8cea50..d365830 100644 --- a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js +++ b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js
@@ -1022,7 +1022,7 @@ }); /** - * Displays open with dialog for current selection. + * Displays "open with"/"more actions" dialog for current selection. * @type {Command} */ CommandHandler.COMMANDS_['open-with'] = /** @type {Command} */ ({ @@ -1033,7 +1033,7 @@ execute: function(event, fileManager) { fileManager.taskController.getFileTasks().then(function(tasks) { tasks.showTaskPicker(fileManager.ui.defaultTaskPicker, - str('OPEN_WITH_BUTTON_LABEL'), + str('MORE_ACTIONS_BUTTON_LABEL'), '', function(task) { tasks.execute(task.taskId); @@ -1050,7 +1050,7 @@ * @param {!FileManager} fileManager FileManager to use. */ canExecute: function(event, fileManager) { - var canExecute = fileManager.taskController.canExecuteOpenWith(); + var canExecute = fileManager.taskController.canExecuteMoreActions(); event.canExecute = canExecute; event.command.setHidden(!canExecute); }
diff --git a/ui/file_manager/file_manager/foreground/js/file_tasks.js b/ui/file_manager/file_manager/foreground/js/file_tasks.js index 10962151..89f5402 100644 --- a/ui/file_manager/file_manager/foreground/js/file_tasks.js +++ b/ui/file_manager/file_manager/foreground/js/file_tasks.js
@@ -141,19 +141,7 @@ }); var defaultTaskPromise = tasksPromise.then(function(tasks) { - for (var i = 0; i < tasks.length; i++) { - if (tasks[i].isDefault) { - return tasks[i]; - } - } - // If we haven't picked a default task yet, then just pick the first one - // which is not generic file handler. - for (var i = 0; i < tasks.length; i++) { - if (!tasks[i].isGenericFileHandler) { - return tasks[i]; - } - } - return null; + return FileTasks.getDefaultTask(tasks); }); return Promise.all([tasksPromise, defaultTaskPromise]).then( @@ -380,6 +368,29 @@ if (!task.iconType && taskParts[1] === 'web-intent') { task.iconType = 'generic'; } + + // Add verb to title. + if (task.verb) { + var verb_button_label = 'OPEN_WITH_VERB_BUTTON_LABEL'; // Default. + switch (task.verb) { + case chrome.fileManagerPrivate.Verb.ADD_TO: + verb_button_label = 'ADD_TO_VERB_BUTTON_LABEL'; + break; + case chrome.fileManagerPrivate.Verb.PACK_WITH: + verb_button_label = 'PACK_WITH_VERB_BUTTON_LABEL'; + break; + case chrome.fileManagerPrivate.Verb.SHARE_WITH: + verb_button_label = 'SHARE_WITH_VERB_BUTTON_LABEL'; + break; + case chrome.fileManagerPrivate.Verb.OPEN_WITH: + // Nothing to do as same as initialization button label. + break; + default: + console.error('Invalid task verb: ' + task.verb + '.'); + } + task.title = loadTimeData.getStringF(verb_button_label, task.title); + } + result.push(task); } @@ -720,7 +731,7 @@ } else { combobutton.defaultItem = { type: FileTasks.TaskMenuButtonItemType.ShowMenu, - label: str('OPEN_WITH_BUTTON_LABEL') + label: str('MORE_ACTIONS_BUTTON_LABEL') }; } @@ -846,3 +857,31 @@ onSuccess(item.task); }); }; + +/** + * Gets the default task from tasks. In case there is no such task (i.e. all + * tasks are generic file handlers), then return opt_taskToUseIfNoDefault or + * null. + * + * @param {!Array<!Object>} tasks The list of tasks from where to choose the + * default task. + * @param {!Object=} opt_taskToUseIfNoDefault The task to return in case there + * is no default task available in tasks. + * @return {Object} opt_taskToUseIfNoDefault or null in case + * opt_taskToUseIfNoDefault is undefined. + */ +FileTasks.getDefaultTask = function(tasks, opt_taskToUseIfNoDefault) { + for (var i = 0; i < tasks.length; i++) { + if (tasks[i].isDefault) { + return tasks[i]; + } + } + // If we haven't picked a default task yet, then just pick the first one + // which is not generic file handler. + for (var i = 0; i < tasks.length; i++) { + if (!tasks[i].isGenericFileHandler) { + return tasks[i]; + } + } + return opt_taskToUseIfNoDefault || null; +};
diff --git a/ui/file_manager/file_manager/foreground/js/task_controller.js b/ui/file_manager/file_manager/foreground/js/task_controller.js index e011fa0..0ecdef30 100644 --- a/ui/file_manager/file_manager/foreground/js/task_controller.js +++ b/ui/file_manager/file_manager/foreground/js/task_controller.js
@@ -67,7 +67,7 @@ /** * @private {boolean} */ - this.canExecuteOpenWith_ = false; + this.canExecuteMoreActions_ = false; /** * @private {!cr.ui.Command} @@ -77,10 +77,12 @@ document.querySelector('#default-task'), cr.ui.Command); /** + * More actions command that uses #open-with as selector due to the open-with + * command used previously for the same task. * @private {!cr.ui.Command} * @const */ - this.openWithCommand_ = + this.moreActionsCommand_ = assertInstanceof(document.querySelector('#open-with'), cr.ui.Command); /** @@ -332,8 +334,8 @@ * Returns whether open with command can be executed or not. * @return {boolean} True if open with command is executable. */ -TaskController.prototype.canExecuteOpenWith = function() { - return this.canExecuteOpenWith_; +TaskController.prototype.canExecuteMoreActions = function() { + return this.canExecuteMoreActions_; }; /** @@ -343,34 +345,37 @@ * @private */ TaskController.prototype.updateContextMenuTaskItems_ = function(items) { - // When only one task is available, show it as default item. - if (items.length === 1) { - var taskItem = items[0]; + // Always show a default item in case at least one task is available, even + // if there is no corresponding default task (i.e. the available task is + // a generic handler). + if (items.length >= 1) { + var defaultTask = FileTasks.getDefaultTask( + items, items[0] /* task to use in case of no default */); - if (taskItem.iconType) { + if (defaultTask.iconType) { this.ui_.fileContextMenu.defaultTaskMenuItem.style.backgroundImage = ''; this.ui_.fileContextMenu.defaultTaskMenuItem.setAttribute( - 'file-type-icon', taskItem.iconType); - } else if (taskItem.iconUrl) { + 'file-type-icon', defaultTask.iconType); + } else if (defaultTask.iconUrl) { this.ui_.fileContextMenu.defaultTaskMenuItem.style.backgroundImage = - 'url(' + taskItem.iconUrl + ')'; + 'url(' + defaultTask.iconUrl + ')'; } else { this.ui_.fileContextMenu.defaultTaskMenuItem.style.backgroundImage = ''; } this.ui_.fileContextMenu.defaultTaskMenuItem.label = - taskItem.taskId === FileTasks.ZIP_UNPACKER_TASK_ID ? - str('TASK_OPEN') : taskItem.title; + defaultTask.taskId === FileTasks.ZIP_UNPACKER_TASK_ID ? + str('TASK_OPEN') : defaultTask.title; this.ui_.fileContextMenu.defaultTaskMenuItem.disabled = - !!taskItem.disabled; - this.ui_.fileContextMenu.defaultTaskMenuItem.taskId = taskItem.taskId; + !!defaultTask.disabled; + this.ui_.fileContextMenu.defaultTaskMenuItem.taskId = defaultTask.taskId; } - this.canExecuteDefaultTask_ = items.length === 1; + this.canExecuteDefaultTask_ = items.length >= 1; this.defaultTaskCommand_.canExecuteChange(this.ui_.listContainer.element); - this.canExecuteOpenWith_ = items.length > 1; - this.openWithCommand_.canExecuteChange(this.ui_.listContainer.element); + this.canExecuteMoreActions_ = items.length > 1; + this.moreActionsCommand_.canExecuteChange(this.ui_.listContainer.element); this.ui_.fileContextMenu.tasksSeparator.hidden = items.length === 0; };
diff --git a/ui/file_manager/file_manager/main.html b/ui/file_manager/file_manager/main.html index fdc366dc..97c5867b 100644 --- a/ui/file_manager/file_manager/main.html +++ b/ui/file_manager/file_manager/main.html
@@ -91,7 +91,7 @@ shortcut="U+00BE-Ctrl" hide-shortcut-text> <command id="default-task"> - <command id="open-with" i18n-values="label:OPEN_WITH_BUTTON_LABEL"> + <command id="open-with" i18n-values="label:MORE_ACTIONS_BUTTON_LABEL"> <command id="zip-selection" i18n-values="label:ZIP_SELECTION_BUTTON_LABEL"> <command id="set-wallpaper"
diff --git a/ui/platform_window/stub/stub_window.cc b/ui/platform_window/stub/stub_window.cc index 33a06064..a46f89d6 100644 --- a/ui/platform_window/stub/stub_window.cc +++ b/ui/platform_window/stub/stub_window.cc
@@ -4,15 +4,12 @@ #include "ui/platform_window/stub/stub_window.h" -#include "ui/gfx/native_widget_types.h" #include "ui/platform_window/platform_window_delegate.h" namespace ui { -StubWindow::StubWindow( - PlatformWindowDelegate* delegate, gfx::AcceleratedWidget accelerated_widget) - : delegate_(delegate) { - delegate_->OnAcceleratedWidgetAvailable(accelerated_widget, 1.f); +StubWindow::StubWindow(PlatformWindowDelegate* delegate) : delegate_(delegate) { + delegate_->OnAcceleratedWidgetAvailable(gfx::kNullAcceleratedWidget, 1.f); } StubWindow::~StubWindow() {
diff --git a/ui/platform_window/stub/stub_window.h b/ui/platform_window/stub/stub_window.h index 029d946..13fa2b7 100644 --- a/ui/platform_window/stub/stub_window.h +++ b/ui/platform_window/stub/stub_window.h
@@ -8,7 +8,6 @@ #include "base/compiler_specific.h" #include "base/macros.h" #include "ui/gfx/geometry/rect.h" -#include "ui/gfx/native_widget_types.h" #include "ui/platform_window/platform_window.h" #include "ui/platform_window/stub/stub_window_export.h" @@ -16,8 +15,7 @@ class STUB_WINDOW_EXPORT StubWindow : NON_EXPORTED_BASE(public PlatformWindow) { public: - StubWindow(PlatformWindowDelegate* delegate, - gfx::AcceleratedWidget accelerated_widget); + explicit StubWindow(PlatformWindowDelegate* delegate); ~StubWindow() override; private:
diff --git a/ui/views/mus/BUILD.gn b/ui/views/mus/BUILD.gn index 53f1a33..dd67361 100644 --- a/ui/views/mus/BUILD.gn +++ b/ui/views/mus/BUILD.gn
@@ -24,6 +24,8 @@ "mus_export.h", "native_widget_mus.cc", "native_widget_mus.h", + "platform_window_mus.cc", + "platform_window_mus.h", "screen_mus.cc", "screen_mus.h", "screen_mus_delegate.h", @@ -82,7 +84,6 @@ "//ui/mojo/ime:interfaces_cpp_sources", "//ui/native_theme", "//ui/platform_window", - "//ui/platform_window/stub", "//ui/views", "//ui/wm", ]
diff --git a/ui/views/mus/native_widget_mus.cc b/ui/views/mus/native_widget_mus.cc index 9488084c..ff20192 100644 --- a/ui/views/mus/native_widget_mus.cc +++ b/ui/views/mus/native_widget_mus.cc
@@ -28,10 +28,10 @@ #include "ui/base/hit_test.h" #include "ui/events/event.h" #include "ui/gfx/canvas.h" -#include "ui/gfx/native_widget_types.h" #include "ui/gfx/path.h" #include "ui/native_theme/native_theme_aura.h" #include "ui/platform_window/platform_window_delegate.h" +#include "ui/views/mus/platform_window_mus.h" #include "ui/views/mus/surface_context_factory.h" #include "ui/views/mus/window_manager_constants_converters.h" #include "ui/views/mus/window_manager_frame_values.h" @@ -639,7 +639,6 @@ void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) { NativeWidgetAura::RegisterNativeWidgetForWindow(this, content_); - aura::Window* hosted_window = window_tree_host_->window(); ownership_ = params.ownership; window_->SetCanFocus(params.activatable == @@ -647,16 +646,17 @@ window_tree_host_->AddObserver(this); window_tree_host_->InitHost(); - hosted_window->SetProperty(kMusWindow, window_); + window_tree_host_->window()->SetProperty(kMusWindow, window_); focus_client_.reset( - new wm::FocusController(new FocusRulesImpl(hosted_window))); + new wm::FocusController(new FocusRulesImpl(window_tree_host_->window()))); - aura::client::SetFocusClient(hosted_window, focus_client_.get()); - aura::client::SetActivationClient(hosted_window, + aura::client::SetFocusClient(window_tree_host_->window(), + focus_client_.get()); + aura::client::SetActivationClient(window_tree_host_->window(), focus_client_.get()); screen_position_client_.reset(new ScreenPositionClientMus(window_)); - aura::client::SetScreenPositionClient(hosted_window, + aura::client::SetScreenPositionClient(window_tree_host_->window(), screen_position_client_.get()); // TODO(erg): Remove this check when mash/wm/frame/move_event_handler.cc's @@ -665,17 +665,17 @@ if (surface_type_ == mus::mojom::SurfaceType::DEFAULT) { cursor_manager_.reset(new wm::CursorManager( base::WrapUnique(new NativeCursorManagerMus(window_)))); - aura::client::SetCursorClient(hosted_window, + aura::client::SetCursorClient(window_tree_host_->window(), cursor_manager_.get()); } window_tree_client_.reset( - new NativeWidgetMusWindowTreeClient(hosted_window)); - hosted_window->AddPreTargetHandler(focus_client_.get()); - hosted_window->SetLayoutManager( - new ContentWindowLayoutManager(hosted_window, content_)); + new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); + window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); + window_tree_host_->window()->SetLayoutManager( + new ContentWindowLayoutManager(window_tree_host_->window(), content_)); capture_client_.reset( - new MusCaptureClient(hosted_window, content_, window_)); + new MusCaptureClient(window_tree_host_->window(), content_, window_)); content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); content_->Init(ui::LAYER_TEXTURED); @@ -683,7 +683,7 @@ content_->Show(); content_->SetTransparent(true); content_->SetFillsBoundsCompletely(false); - hosted_window->AddChild(content_); + window_tree_host_->window()->AddChild(content_); // Set-up transiency if appropriate. if (params.parent && !params.child) { @@ -1030,11 +1030,11 @@ } void NativeWidgetMus::SetFullscreen(bool fullscreen) { - if (IsFullscreen() == fullscreen) + if (!window_tree_host_ || IsFullscreen() == fullscreen) return; if (fullscreen) { show_state_before_fullscreen_ = mus_window_observer_->show_state(); - // TODO(markdittmer): Fullscreen not implemented in mus::Window. + window_tree_host_->platform_window()->ToggleFullscreen(); } else { switch (show_state_before_fullscreen_) { case mus::mojom::ShowState::MAXIMIZED:
diff --git a/ui/views/mus/native_widget_mus_unittest.cc b/ui/views/mus/native_widget_mus_unittest.cc index 17db5428..53f9338 100644 --- a/ui/views/mus/native_widget_mus_unittest.cc +++ b/ui/views/mus/native_widget_mus_unittest.cc
@@ -418,6 +418,58 @@ EXPECT_EQ(1, handler.num_mouse_events()); } +// Tests that an incoming UI event is acked with the handled status. +TEST_F(NativeWidgetMusTest, EventAcked) { + std::unique_ptr<Widget> widget(CreateWidget(nullptr)); + widget->Show(); + + View* content = new HandleMousePressView; + content->SetBounds(10, 20, 90, 180); + widget->GetContentsView()->AddChildView(content); + + // Dispatch an input event to the window and view. + std::unique_ptr<ui::MouseEvent> event = CreateMouseEvent(); + std::unique_ptr<base::Callback<void(EventResult)>> ack_callback( + new base::Callback<void(EventResult)>(base::Bind( + &NativeWidgetMusTest::AckCallback, base::Unretained(this)))); + OnWindowInputEvent( + static_cast<NativeWidgetMus*>(widget->native_widget_private()), + *event, + &ack_callback); + + // The test took ownership of the callback and called it. + EXPECT_FALSE(ack_callback); + EXPECT_EQ(1, ack_callback_count()); +} + +// Tests that a window that is deleted during event handling properly acks the +// event. +TEST_F(NativeWidgetMusTest, EventAckedWithWindowDestruction) { + std::unique_ptr<Widget> widget(CreateWidget(nullptr)); + widget->Show(); + + View* content = new DeleteWidgetView(&widget); + content->SetBounds(10, 20, 90, 180); + widget->GetContentsView()->AddChildView(content); + + // Dispatch an input event to the window and view. + std::unique_ptr<ui::MouseEvent> event = CreateMouseEvent(); + std::unique_ptr<base::Callback<void(EventResult)>> ack_callback( + new base::Callback<void(EventResult)>(base::Bind( + &NativeWidgetMusTest::AckCallback, base::Unretained(this)))); + OnWindowInputEvent( + static_cast<NativeWidgetMus*>(widget->native_widget_private()), + *event, + &ack_callback); + + // The widget was deleted. + EXPECT_FALSE(widget.get()); + + // The test took ownership of the callback and called it. + EXPECT_FALSE(ack_callback); + EXPECT_EQ(1, ack_callback_count()); +} + TEST_F(NativeWidgetMusTest, SetAndReleaseCapture) { std::unique_ptr<Widget> widget(CreateWidget(nullptr)); widget->Show();
diff --git a/ui/views/mus/platform_window_mus.cc b/ui/views/mus/platform_window_mus.cc new file mode 100644 index 0000000..bacc15d --- /dev/null +++ b/ui/views/mus/platform_window_mus.cc
@@ -0,0 +1,109 @@ +// Copyright 2015 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 "ui/views/mus/platform_window_mus.h" + +#include "build/build_config.h" +#include "components/bitmap_uploader/bitmap_uploader.h" +#include "components/mus/public/cpp/property_type_converters.h" +#include "components/mus/public/cpp/window_property.h" +#include "components/mus/public/interfaces/window_manager.mojom.h" +#include "mojo/converters/input_events/input_events_type_converters.h" +#include "ui/base/view_prop.h" +#include "ui/platform_window/platform_window_delegate.h" +#include "ui/views/mus/window_manager_connection.h" + +using mus::mojom::EventResult; + +namespace views { + +namespace { + +static uint32_t accelerated_widget_count = 1; + +} // namespace + +PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, + shell::Connector* connector, + mus::Window* mus_window) + : delegate_(delegate), + mus_window_(mus_window), + mus_window_destroyed_(false) { + DCHECK(delegate_); + DCHECK(mus_window_); + + // We need accelerated widget numbers to be different for each + // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t + // has this property. +#if defined(OS_WIN) || defined(OS_ANDROID) + gfx::AcceleratedWidget accelerated_widget = + reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); +#else + gfx::AcceleratedWidget accelerated_widget = + static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); +#endif + delegate_->OnAcceleratedWidgetAvailable( + accelerated_widget, mus_window_->viewport_metrics().device_pixel_ratio); + + if (connector) { + bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(mus_window_)); + bitmap_uploader_->Init(connector); + prop_.reset( + new ui::ViewProp(accelerated_widget, + bitmap_uploader::kBitmapUploaderForAcceleratedWidget, + bitmap_uploader_.get())); + } +} + +PlatformWindowMus::~PlatformWindowMus() {} + +void PlatformWindowMus::Show() {} + +void PlatformWindowMus::Hide() {} + +void PlatformWindowMus::Close() { + NOTIMPLEMENTED(); +} + +void PlatformWindowMus::SetBounds(const gfx::Rect& bounds) {} + +gfx::Rect PlatformWindowMus::GetBounds() { + return mus_window_->bounds(); +} + +void PlatformWindowMus::SetTitle(const base::string16& title) { + NOTIMPLEMENTED(); +} + +void PlatformWindowMus::SetCapture() {} + +void PlatformWindowMus::ReleaseCapture() {} + +void PlatformWindowMus::ToggleFullscreen() { + NOTIMPLEMENTED(); +} + +void PlatformWindowMus::Maximize() {} + +void PlatformWindowMus::Minimize() {} + +void PlatformWindowMus::Restore() {} + +void PlatformWindowMus::SetCursor(ui::PlatformCursor cursor) { + NOTIMPLEMENTED(); +} + +void PlatformWindowMus::MoveCursorTo(const gfx::Point& location) { + NOTIMPLEMENTED(); +} + +void PlatformWindowMus::ConfineCursorToBounds(const gfx::Rect& bounds) { + NOTIMPLEMENTED(); +} + +ui::PlatformImeController* PlatformWindowMus::GetPlatformImeController() { + return nullptr; +} + +} // namespace views
diff --git a/ui/views/mus/platform_window_mus.h b/ui/views/mus/platform_window_mus.h new file mode 100644 index 0000000..c17b9c80 --- /dev/null +++ b/ui/views/mus/platform_window_mus.h
@@ -0,0 +1,80 @@ +// Copyright 2015 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 UI_VIEWS_MUS_PLATFORM_WINDOW_MUS_H_ +#define UI_VIEWS_MUS_PLATFORM_WINDOW_MUS_H_ + +#include <stdint.h> + +#include <string> +#include <vector> + +#include "base/macros.h" +#include "components/mus/public/cpp/window_observer.h" +#include "ui/platform_window/platform_window.h" +#include "ui/views/mus/mus_export.h" + +namespace bitmap_uploader { +class BitmapUploader; +} + +namespace shell { +class Connector; +} + +namespace ui { +class ViewProp; +} + +namespace views { + +// This class has been marked for deletion. Its implementation is being rolled +// into views::NativeWidgetMus. See crbug.com/609555 for details. +class VIEWS_MUS_EXPORT PlatformWindowMus + : public NON_EXPORTED_BASE(ui::PlatformWindow) { + public: + PlatformWindowMus(ui::PlatformWindowDelegate* delegate, + shell::Connector* connector, + mus::Window* mus_window); + ~PlatformWindowMus() override; + + // ui::PlatformWindow: + void Show() override; + void Hide() override; + void Close() override; + void SetBounds(const gfx::Rect& bounds) override; + gfx::Rect GetBounds() override; + void SetTitle(const base::string16& title) override; + void SetCapture() override; + void ReleaseCapture() override; + void ToggleFullscreen() override; + void Maximize() override; + void Minimize() override; + void Restore() override; + void SetCursor(ui::PlatformCursor cursor) override; + void MoveCursorTo(const gfx::Point& location) override; + void ConfineCursorToBounds(const gfx::Rect& bounds) override; + ui::PlatformImeController* GetPlatformImeController() override; + + private: + friend class PlatformWindowMusTest; + + ui::PlatformWindowDelegate* delegate_; + mus::Window* mus_window_; + + // True if OnWindowDestroyed() has been received. + bool mus_window_destroyed_; + + std::unique_ptr<bitmap_uploader::BitmapUploader> bitmap_uploader_; + std::unique_ptr<ui::ViewProp> prop_; +#ifndef NDEBUG + std::unique_ptr<base::WeakPtrFactory<PlatformWindowMus>> weak_factory_; +#endif + + DISALLOW_COPY_AND_ASSIGN(PlatformWindowMus); +}; + +} // namespace views + +#endif // UI_VIEWS_MUS_PLATFORM_WINDOW_MUS_H_
diff --git a/ui/views/mus/window_tree_host_mus.cc b/ui/views/mus/window_tree_host_mus.cc index 7aacf28..e360eb05 100644 --- a/ui/views/mus/window_tree_host_mus.cc +++ b/ui/views/mus/window_tree_host_mus.cc
@@ -5,21 +5,15 @@ #include "ui/views/mus/window_tree_host_mus.h" #include "base/memory/ptr_util.h" -#include "components/bitmap_uploader/bitmap_uploader.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" -#include "ui/base/view_prop.h" #include "ui/events/event.h" -#include "ui/platform_window/stub/stub_window.h" #include "ui/views/mus/input_method_mus.h" #include "ui/views/mus/native_widget_mus.h" +#include "ui/views/mus/platform_window_mus.h" namespace views { -namespace { -static uint32_t accelerated_widget_count = 1; -} - //////////////////////////////////////////////////////////////////////////////// // WindowTreeHostMus, public: @@ -27,35 +21,8 @@ NativeWidgetMus* native_widget, mus::Window* window) : native_widget_(native_widget) { - // We need accelerated widget numbers to be different for each - // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t - // has this property. -#if defined(OS_WIN) || defined(OS_ANDROID) - gfx::AcceleratedWidget accelerated_widget = - reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); -#else - gfx::AcceleratedWidget accelerated_widget = - static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); -#endif - - // TODO(markdittmer): StubWindow will call |OnAcceleratedWidgetAvailable| with - // device pixel ratio = 1. Really, this ratio should be consistent with that - // of |window|. - SetPlatformWindow(base::WrapUnique( - new ui::StubWindow(this, accelerated_widget))); - - // If no connector was passed, then it's entirely possible that mojo has not - // been initialized and BitmapUploader will not work. This occurs, for - // example, in some unit test contexts. - if (connector) { - bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(window)); - bitmap_uploader_->Init(connector); - prop_.reset(new ui::ViewProp( - accelerated_widget, - bitmap_uploader::kBitmapUploaderForAcceleratedWidget, - bitmap_uploader_.get())); - } - + SetPlatformWindow( + base::WrapUnique(new PlatformWindowMus(this, connector, window))); // The location of events is already transformed, and there is no way to // correctly determine the reverse transform. So, don't attempt to transform // event locations, else the root location is wrong. @@ -72,6 +39,11 @@ DestroyDispatcher(); } +PlatformWindowMus* WindowTreeHostMus::platform_window() { + return static_cast<PlatformWindowMus*>( + WindowTreeHostPlatform::platform_window()); +} + void WindowTreeHostMus::DispatchEvent(ui::Event* event) { if (event->IsKeyEvent() && GetInputMethod()) { GetInputMethod()->DispatchKeyEvent(event->AsKeyEvent());
diff --git a/ui/views/mus/window_tree_host_mus.h b/ui/views/mus/window_tree_host_mus.h index e1930c3..30da7ed2 100644 --- a/ui/views/mus/window_tree_host_mus.h +++ b/ui/views/mus/window_tree_host_mus.h
@@ -11,10 +11,6 @@ class SkBitmap; -namespace bitmap_uploader { - class BitmapUploader; -} - namespace mus { class Window; } @@ -23,10 +19,6 @@ class Connector; } -namespace ui { -class ViewProp; -} - namespace views { class InputMethodMUS; @@ -40,6 +32,8 @@ mus::Window* window); ~WindowTreeHostMus() override; + PlatformWindowMus* platform_window(); + private: // aura::WindowTreeHostPlatform: void DispatchEvent(ui::Event* event) override; @@ -50,10 +44,6 @@ NativeWidgetMus* native_widget_; std::unique_ptr<InputMethodMUS> input_method_; - // Bitmap management. - std::unique_ptr<bitmap_uploader::BitmapUploader> bitmap_uploader_; - std::unique_ptr<ui::ViewProp> prop_; - DISALLOW_COPY_AND_ASSIGN(WindowTreeHostMus); };