diff --git a/lgpl/sources/chromium/src/chrome/test/data/android/subresource_filter/page-with-img.html b/lgpl/sources/chromium/src/chrome/test/data/android/subresource_filter/page-with-img.html new file mode 100644 index 0000000000..00bfe565e8 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/android/subresource_filter/page-with-img.html @@ -0,0 +1,7 @@ + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/android/test.mht b/lgpl/sources/chromium/src/chrome/test/data/android/test.mht new file mode 100644 index 0000000000..a57f6ec5a4 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/android/test.mht @@ -0,0 +1,17 @@ +From: +Subject: Test +Date: Mon, Nov 21 2011 10:59:06 GMT-0800 +MIME-Version: 1.0 +Content-Type: multipart/related; + boundary="----=_NextPart_000_0000_0324C3DC.A3C79392"; + type="text/html" + +------=_NextPart_000_0000_0324C3DC.A3C79392 +Content-Type: text/html; charset="UTF-8" +Content-Transfer-Encoding: quoted-printable +Content-Location: http://www.example.com + + +Welcome! + +------=_NextPart_000_0000_0324C3DC.A3C79392-- diff --git a/lgpl/sources/chromium/src/chrome/test/data/autofill/label_change.html b/lgpl/sources/chromium/src/chrome/test/data/autofill/label_change.html new file mode 100644 index 0000000000..0e03710238 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/autofill/label_change.html @@ -0,0 +1,28 @@ + + + + + + + +
+ + + +

Address 1

+ + +
+ + diff --git a/lgpl/sources/chromium/src/chrome/test/data/banners/main.js b/lgpl/sources/chromium/src/chrome/test/data/banners/main.js index 1cc2aa902e..c0e1ee0033 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/banners/main.js +++ b/lgpl/sources/chromium/src/chrome/test/data/banners/main.js @@ -2,19 +2,92 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -function initialize() { - navigator.serviceWorker.register('service_worker.js'); +const Action = { + VERIFY_APPINSTALLED: "verify_appinstalled", + VERIFY_PROMPT_APPINSTALLED: "verify_prompt_appinstalled", + VERIFY_BEFOREINSTALLPROMPT: "verify_beforeinstallprompt", + CALL_PROMPT_DELAYED: "call_prompt_delayed", + CALL_PROMPT_IN_HANDLER: "call_prompt_in_handler", + CALL_PROMPT_NO_USERCHOICE: "call_prompt_no_userchoice", + CANCEL_PROMPT_AND_NAVIGATE: "cancel_prompt_and_navigate", + CANCEL_PROMPT: "cancel_prompt", + STASH_EVENT: "stash_event", +}; + +const LISTENER = "listener"; +const ATTR = "attr"; + +// These blanks will get filled in when each event comes through. +let gotEventsFrom = ['_'.repeat(LISTENER.length), '_'.repeat(ATTR.length)]; + +let stashedEvent = null; + +function startWorker(worker) { + navigator.serviceWorker.register(worker); +} - window.addEventListener('appinstalled', () => { - window.document.title = 'Got appinstalled'; +function verifyEvents(eventName) { + function setTitle() { + window.document.title = 'Got ' + eventName + ': ' + + gotEventsFrom.join(', '); + } + + window.addEventListener(eventName, () => { + gotEventsFrom[0] = LISTENER; + setTitle(); + }); + window['on' + eventName] = () => { + gotEventsFrom[1] = ATTR; + setTitle(); + }; +} + +function callPrompt(event) { + event.prompt(); + event.userChoice.then(function(choiceResult) { + window.document.title = 'Got userChoice: ' + choiceResult.outcome; + }); +} + +function callStashedPrompt() { + if (stashedEvent === null) { + throw new Error('No event was previously stashed'); + } + stashedEvent.prompt(); +} + +function addPromptListener(action) { + window.addEventListener('beforeinstallprompt', function(e) { + e.preventDefault(); + + switch (action) { + case Action.CALL_PROMPT_DELAYED: + setTimeout(callPrompt, 0, e); + break; + case Action.CALL_PROMPT_IN_HANDLER: + callPrompt(e); + break; + case Action.CALL_PROMPT_NO_USERCHOICE: + setTimeout(() => e.prompt(), 0); + break; + case Action.CANCEL_PROMPT_AND_NAVIGATE: + // Navigate the window to trigger cancellation in the renderer. + window.location.href = "/"; + break; + case Action.STASH_EVENT: + stashedEvent = e; + break; + } }); } function addManifestLinkTag() { - var url = window.location.href; - var manifestIndex = url.indexOf("?manifest="); - var manifestUrl = - (manifestIndex >= 0) ? url.slice(manifestIndex + 10) : 'manifest.json'; + const url = new URL(window.location.href); + let manifestUrl = url.searchParams.get('manifest'); + if (!manifestUrl) { + manifestUrl = 'manifest.json'; + } + var linkTag = document.createElement("link"); linkTag.id = "manifest"; linkTag.rel = "manifest"; @@ -22,6 +95,42 @@ function addManifestLinkTag() { document.head.append(linkTag); } +function initialize() { + const url = new URL(window.location.href); + const action = url.searchParams.get('action'); + if (!action) { + return; + } + + switch (action) { + case Action.VERIFY_APPINSTALLED: + verifyEvents('appinstalled'); + break; + case Action.VERIFY_PROMPT_APPINSTALLED: + addPromptListener(Action.CALL_PROMPT_NO_USERCHOICE); + verifyEvents('appinstalled'); + break; + case Action.VERIFY_BEFOREINSTALLPROMPT: + verifyEvents('beforeinstallprompt'); + break; + case Action.CALL_PROMPT_DELAYED: + case Action.CALL_PROMPT_IN_HANDLER: + case Action.CALL_PROMPT_NO_USERCHOICE: + case Action.CANCEL_PROMPT_AND_NAVIGATE: + case Action.CANCEL_PROMPT: + case Action.STASH_EVENT: + addPromptListener(action); + break; + default: + throw new Error("Unrecognised action: " + action); + } +} + +function initializeWithWorker(worker) { + startWorker(worker); + initialize(); +} + function changeManifestUrl(newManifestUrl) { var linkTag = document.getElementById("manifest"); linkTag.href = newManifestUrl; diff --git a/lgpl/sources/chromium/src/chrome/test/data/banners/manifest_no_service_worker.html b/lgpl/sources/chromium/src/chrome/test/data/banners/manifest_no_service_worker.html index 6db2a5fb36..a8f23d40cf 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/banners/manifest_no_service_worker.html +++ b/lgpl/sources/chromium/src/chrome/test/data/banners/manifest_no_service_worker.html @@ -1,9 +1,15 @@ Web app banner test page - + + - + Do-nothing page with a manifest but no service worker. diff --git a/lgpl/sources/chromium/src/chrome/test/data/banners/manifest_test_page.html b/lgpl/sources/chromium/src/chrome/test/data/banners/manifest_test_page.html index 2bf79dc205..1897fbafd5 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/banners/manifest_test_page.html +++ b/lgpl/sources/chromium/src/chrome/test/data/banners/manifest_test_page.html @@ -9,7 +9,7 @@ addManifestLinkTag(); - - Do-nothing page with a service worker. + + Do-nothing page with a manifest and a service worker. diff --git a/lgpl/sources/chromium/src/chrome/test/data/banners/no_manifest_test_page.html b/lgpl/sources/chromium/src/chrome/test/data/banners/no_manifest_test_page.html index 3d4e8d701c..16a505cf9d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/banners/no_manifest_test_page.html +++ b/lgpl/sources/chromium/src/chrome/test/data/banners/no_manifest_test_page.html @@ -3,7 +3,10 @@ Web app banner test page - - Do-nothing page with a service worker, but no manifest. + + + Do-nothing page with a service worker, but no manifest. - \ No newline at end of file + diff --git a/lgpl/sources/chromium/src/chrome/test/data/banners/no_sw_fetch_handler_test_page.html b/lgpl/sources/chromium/src/chrome/test/data/banners/no_sw_fetch_handler_test_page.html index e1003799f0..198656e327 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/banners/no_sw_fetch_handler_test_page.html +++ b/lgpl/sources/chromium/src/chrome/test/data/banners/no_sw_fetch_handler_test_page.html @@ -1,11 +1,15 @@ - + Web app banner test page + - - Page with a service worker missing a fetch handler. + + Do-nothing page with a manifest and a service worker missing a fetch handler. diff --git a/lgpl/sources/chromium/src/chrome/test/data/browsing_data/a.html b/lgpl/sources/chromium/src/chrome/test/data/browsing_data/a.html new file mode 100644 index 0000000000..b32e46a77e --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/browsing_data/a.html @@ -0,0 +1,5 @@ + + +

A

+ + diff --git a/lgpl/sources/chromium/src/chrome/test/data/browsing_data/b.html b/lgpl/sources/chromium/src/chrome/test/data/browsing_data/b.html new file mode 100644 index 0000000000..1493e08aa6 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/browsing_data/b.html @@ -0,0 +1,5 @@ + + +

B

+ + diff --git a/lgpl/sources/chromium/src/chrome/test/data/browsing_data/c.html b/lgpl/sources/chromium/src/chrome/test/data/browsing_data/c.html new file mode 100644 index 0000000000..93a4b9d849 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/browsing_data/c.html @@ -0,0 +1,5 @@ + + +

C

+ + diff --git a/lgpl/sources/chromium/src/chrome/test/data/browsing_data/d.html b/lgpl/sources/chromium/src/chrome/test/data/browsing_data/d.html new file mode 100644 index 0000000000..03d043508a --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/browsing_data/d.html @@ -0,0 +1,5 @@ + + +

D

+ + diff --git a/lgpl/sources/chromium/src/chrome/test/data/captive_portal/redirect_to_mock_https.html b/lgpl/sources/chromium/src/chrome/test/data/captive_portal/redirect_to_mock_https.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lgpl/sources/chromium/src/chrome/test/data/captive_portal/redirect_to_mock_https.html.mock-http-headers b/lgpl/sources/chromium/src/chrome/test/data/captive_portal/redirect_to_mock_https.html.mock-http-headers new file mode 100644 index 0000000000..58c54e4d61 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/captive_portal/redirect_to_mock_https.html.mock-http-headers @@ -0,0 +1,2 @@ +HTTP/1.0 301 Moved permanently +Location: https://mock.captive.portal.long.timeout/title2.html diff --git a/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/primary_app/key.pem b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/primary_app/key.pem new file mode 100644 index 0000000000..611da2727a --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/primary_app/key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC3aFAcHk8yszLB +n+3LtibvlyPBmh2BLKq7t9A03LKx7zbFVCxxX9N+KMfXFvAW+craT/yyAYV3KOsF +V6hyTr4QnSJ4WP8u9HRgLLkrbHgnnlzsd74NKz0IpwREd4AG/AhAtA2znX9wZFdN +3//vLzTp1+QLbqvj5dWGJatgXKXwuaHyL8S2UrtmwZEBMrMH1ju9QpltWatYdAv5 +73x950hBTh6ow6S3qMlOAGuJEtrk++7opMn4FLO3dhYrPv7zDX6RHiaqYMQpAaDe +BQmMgV4gUeiZAYvgbra7T/KI7EgmKwvu0lypcpUIOCy2tIwMVjzvnH4xRk+ljbxA +Yo39jYX7AgMBAAECggEAK2A4vgWvDlsSMHfN6gVI3RYeJz33J2M0d9PnonDltC5S +gkW/gwq6PpaPeL+chZqLDqmnJkQ01/Mt7iQGmw4jZlN7YQIPTAAVe99n5aywGBKc +gHJrWLr2otK5MCYg+cXmf8L1kJq5lo+slCbbZSqBdaKQ9OE2Nt5W6vSCvPX8attd +Y+K7mSFsOqchVGKNj2x6TKNt2W0MNRgNqR3dZlf4qRw/JhRgUrJLQjy+NeUaZFM4 +OZK4tS2Riq8b2ROBi4agio1lGc9nY5wKwl7zsV83bPEmWYL0t0PnL0muBRlVrRG6 +1LnGdeOMGg7XU8JI6xSxHdnBRLsVyC0XqTV0FIUphQKBgQDr6uB8w2p846XWcU6P +KWsN74AjvXyEZCgOtppDYcl6Am8Z5A/zGc+fd/lkxgHrS4V9/ZM15REHSF7B4jaF +qstvHu0crocrn1K3mCW0bKXcDP4tiNVTnGZyIL/jLK6PbDHX7dux631MhcWzjf9H +PeFmFqDTglCevsZZCBv58Ut/nwKBgQDHBSK+f9wsPlO2V4FWndzXyHZVqd66MJHx +AT22Gr9nk6DBOfHuIefDz+ZVIZozgCphi24It3Mduc9dmP4fwuyo6nmm57uMev4p +C5LG2DWtCGASdVtlWCXK1vugwHut5sBtw2VbyifTCpQUDPVPKAhe/mU7I23sgXv3 +iNNYVRNsJQKBgQDWD0tbyVBxO3n5JtxaSAGMJnlFdKRr2BkEqKk2ZJ8UZur6OhZC +xXO/RXPz/To2jlL068XMDCm0SvU3xRMlm8B09kG9WZrqeOjsD1B+8mpYTS3AkTzH +Xc0S1yZlceB94HUlcPx75qnNaj/l2Pz9XmeLYxLQd5jBQWbl19bSph+UDwKBgQCJ +B9w4Vkj+nZt9/RoszVz1piz0JpYYlMCntDcNX7VSV69j28XcNLQjes4Y554Iv8Ju +j1Yf4k/8s6c3xtOSgt/4HhnM9dmIjFbbZACXsN6kWRPtIajgSqUa2JNAx8dgoXT1 +Hoh3fuWUxb/XXmS5L9MztO12nppdMXptoWQDefB5kQKBgEZLaz4xukznI6YpKy5R +pA2iHpLzHEcDW8dmvKq93LGqfrvq+hs5vXW5UXWHFopkjb1sRkQ0apNuaD7QeQ0S +eNdEc5c7lLW2krDP64mpHfGVSKmsuvqBuVHkMONp6h8YAbuOkB2Rw594FBz3Xwuo +FW8WIqaeB/5nmx/emYZD/TsV +-----END PRIVATE KEY----- diff --git a/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/primary_app/src/main.js b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/primary_app/src/main.js new file mode 100644 index 0000000000..4cfc6764cb --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/primary_app/src/main.js @@ -0,0 +1,125 @@ +// Copyright 2018 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. + +chrome.app.runtime.onLaunched.addListener(function() { + var kSecondaryAppId = 'lfaidgolgikbpapkmdhoppddflhaocnf'; + var kNotAllowedError = 'Not allowed in kiosk.'; + + chrome.test.runTests([ + function getSelf() { + chrome.management.getSelf(chrome.test.callbackPass(function(info) { + chrome.test.assertEq(chrome.runtime.id, info.id); + })); + }, + + function getAll() { + chrome.management.getAll(chrome.test.callbackPass(function(result) { + chrome.test.assertEq(2, result.length); + var self = result.find(entry => entry.id == chrome.runtime.id); + chrome.test.assertTrue(!!self); + + var secondary = result.find(entry => entry.id == kSecondaryAppId); + chrome.test.assertTrue(!!secondary); + })); + }, + + function getSecondary() { + chrome.management.get( + kSecondaryAppId, chrome.test.callbackPass(function(info) { + chrome.test.assertEq(kSecondaryAppId, info.id); + chrome.test.assertTrue(info.enabled); + })); + }, + + function disableSelf() { + chrome.management.setEnabled( + chrome.runtime.id, false, + chrome.test.callbackFail( + 'Cannot change the primary kiosk app state.')); + }, + + function disableSecondary() { + chrome.test.listenOnce(chrome.management.onDisabled, function(info) { + chrome.test.assertEq(kSecondaryAppId, info.id); + chrome.test.assertFalse(info.enabled); + }); + + chrome.management.setEnabled( + kSecondaryAppId, false, chrome.test.callbackPass(function() { + chrome.management.get( + kSecondaryAppId, chrome.test.callbackPass(function(info) { + chrome.test.assertFalse(info.enabled); + chrome.test.assertTrue(info.mayEnable); + })); + })); + }, + + function enableSecondary() { + chrome.test.listenOnce(chrome.management.onEnabled, function(info) { + chrome.test.assertEq(kSecondaryAppId, info.id); + chrome.test.assertTrue(info.enabled); + }); + + chrome.management.setEnabled( + kSecondaryAppId, true, chrome.test.callbackPass(function() { + chrome.management.get( + kSecondaryAppId, chrome.test.callbackPass(function(info) { + chrome.test.assertTrue(info.enabled); + })); + })); + }, + + function uninstallSelf() { + chrome.management.uninstallSelf( + chrome.test.callbackFail(kNotAllowedError)); + }, + + function uninstallSecondary() { + chrome.management.uninstall( + kSecondaryAppId, chrome.test.callbackFail(kNotAllowedError)); + }, + + function launchSecondary() { + chrome.management.launchApp( + kSecondaryAppId, chrome.test.callbackFail(kNotAllowedError)); + }, + + function createAppShortcut() { + chrome.management.createAppShortcut( + kSecondaryAppId, chrome.test.callbackFail(kNotAllowedError)); + }, + + function setLaunchType() { + chrome.management.setLaunchType( + kSecondaryAppId, 'OPEN_AS_WINDOW', + chrome.test.callbackFail(kNotAllowedError)); + }, + + function generateAppForLink() { + chrome.management.generateAppForLink( + 'https://test.test', 'Test app', + chrome.test.callbackFail(kNotAllowedError)); + }, + + function testSecondaryApp() { + chrome.runtime.sendMessage( + kSecondaryAppId, 'runTests', function(response) { + // If tests in secondary app failed to run, notify test runner of + // failure before continuing tests in primary app - the test runner + // expects two test results. + if (chrome.runtime.lastError) { + chrome.test.notifyFail( + 'Secondary app tests failed to run: ' + + chrome.runtime.lastError.message); + } else if (response != 'ok') { + chrome.test.notifyFail( + 'Secondary app tests failed to run: app responded: ' + + response); + } + + chrome.test.succeed(); + }); + }, + ]); +}); diff --git a/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/primary_app/src/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/primary_app/src/manifest.json new file mode 100644 index 0000000000..c2099bcad3 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/primary_app/src/manifest.json @@ -0,0 +1,17 @@ +{ + "name": "Kiosk app testing management API", + "manifest_version": 2, + "version": "1.0.0", + "app": { + "background": { + "scripts": ["main.js"] + } + }, + "kiosk_enabled": true, + "permissions": [ + "management" + ], + "kiosk_secondary_apps": [ + {"id": "lfaidgolgikbpapkmdhoppddflhaocnf"} + ] +} diff --git a/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/secondary_app/key.pem b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/secondary_app/key.pem new file mode 100644 index 0000000000..58b1ad7a18 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/secondary_app/key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCVdTSbM2/zS/qt +6kwc7FsJjUtbQ1t6FtwCR7wXbw8dcPH+EyzxOj56mNXPPYqPTBcC2n04AO0oCSLq +s8SlBsJedO3kOg9Syc4x51+rXMkBTnIRGHXZbE6myFvJHmZPOaqpfwIuW5ESZMJR +RtpgVZz/x7ydBt0nm05iDwhuuHVmPtEio02sRkCLQkDj1YGxinTdZWWOCLseQoVj +6Q7G8/pojF5PGv6k6TuYj03NIGx1FDhsGjHY/wNzH4KdI9xD8FpdlgSC2Qt/Dzum +WnypxHH6neheKZ8shw3T6O4RF2u4pK0cOnV8D+2deOiHfpKEnAhlqBIHMMKbLhTp +TyHAP/3VAgMBAAECggEAAMY0KQ+pp01/9XGuxkGVMSX5u3XMXgQLTLm5aDerkN/6 +aPIJfBBsrW7oQKQVeSuQPPQLzQP4Nophk2yt+prf2+RoLRP961RfTJPhw33+DpMs +9Ri215L/j06fZxnQtt1aHHmrdbkEtd8uwIQI8pHO9+Y9fGTCNYfQ7qIcTZKIDSkJ +HQ22hEqoYNPKKRFIT3rlweDLMpVOdptMktJmHkZFDEs4/LZ76ijRrRCysih+E50N +TBm2jBt4g39FvK7G8fIFczqIjRrUdlOQ5xuTJFrMtR2eArdHgHcjp1Z23hto7hIl +roxX3g7o32w6HDoaWhZCAiS3iFd2HjS2R0LKo6jMAQKBgQDSyCGSg5IuAQ1H+n7B +cgwaAMgWCWPYEOjLn+egP39hASOuebn+awGgx8fFgJmZQGL//a//lLcO5nRq2+CT +aE9ERS6ezSYOyK9zC/YIvm3ncouaERddSeyzfymlNCS/pGCMMU6txH0Q1oQd1+nC +Y6tFsR/jlXI1NrYf0mHguDuT1QKBgQC1hT3QRNlFEpA4vIQWAwNECE+WHVYNuLLx +2eTSr+GxfFF597W8QORV6D/7xurvx6KVcQvUJVn2FO+I5XJQ/BQoYY8mpHIWm/YL +NJzReYU+0DcouW+YappDWY8/YjSfpt7lM0p6H8z57zkCJKziFSuBLWMZqez08rw1 +9VGeMYnCAQKBgHNChsE0ezH210ld3ARyFdX+SWtrdRKIpJP8e89wCXqFAfr9i0xp +PTmrJT2Fxfg8ciZjleMfcj6OnGh2lcZlirrdTdH+gmohKXeyubYsU7L1OwtjfzA/ +JVU+GwrAibvV6gmfSNPSl0Um2JXtJGFs2RJB+hsb9JjOsyaRh343oDSFAoGBAIkB +VUNyA69vsG0yVFus0HUz9KXv5Hic1GtYs64V1Do7A+AUCBZbwDva/RgS7lYmjt9O +oMfxnTHwYU8pJxxa9vf3kq1u5zGLa6zPfCFbICflzgwt0j3vEBoPaeBERkXOFGRY +TzlX8UUfux6UAezuX5SzZh4DtHa5EzeCvqSw7TIBAoGATmIBZLt/udfYyX3HDvM8 +CyTRldT77T0XhSXQTKhBMWhdvGcrdbWnpv1cqKNbCLNm8SaGCKSPy0/arTEAlwXM +d5Dyw259qs2uXt47HVkYox4oF3yDCdQtIXtTfyEaGzmRh3F9hcPfXKXQdHboI54P +6vNKgnPozOy5+2TkqXXMvQI= +-----END PRIVATE KEY----- diff --git a/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/secondary_app/src/main.js b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/secondary_app/src/main.js new file mode 100644 index 0000000000..f86e1fdf37 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/secondary_app/src/main.js @@ -0,0 +1,91 @@ +// Copyright 2018 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. + +chrome.runtime.onMessageExternal.addListener(function( + message, sender, callback) { + var kPrimaryAppId = 'faiboenfkkoaedoehhkjmenkhidadgje'; + var kNotAllowedError = 'Not allowed in kiosk.'; + var kChangingPrimaryAppError = 'Cannot change the primary kiosk app state.'; + + if (!sender || sender.id != kPrimaryAppId) + return; + + if (message != 'runTests') { + callback('invalidMessage: ' + message); + return; + } + + callback('ok'); + + chrome.test.runTests([ + function getSelf() { + chrome.management.getSelf(chrome.test.callbackPass(function(info) { + chrome.test.assertEq(chrome.runtime.id, info.id); + })); + }, + + function getAll() { + chrome.management.getAll(chrome.test.callbackPass(function(result) { + chrome.test.assertEq(2, result.length); + var self = result.find(entry => entry.id == chrome.runtime.id); + chrome.test.assertTrue(!!self); + + var secondary = result.find(entry => entry.id == kPrimaryAppId); + chrome.test.assertTrue(!!secondary); + })); + }, + + function getPrimary() { + chrome.management.get( + kPrimaryAppId, chrome.test.callbackPass(function(info) { + chrome.test.assertEq(kPrimaryAppId, info.id); + chrome.test.assertTrue(info.enabled); + })); + }, + + function disablePrimary() { + chrome.management.setEnabled( + kPrimaryAppId, false, + chrome.test.callbackFail(kChangingPrimaryAppError)); + }, + + function enablePrimary() { + chrome.management.setEnabled( + kPrimaryAppId, true, + chrome.test.callbackFail(kChangingPrimaryAppError)); + }, + + function uninstallSelf() { + chrome.management.uninstallSelf( + chrome.test.callbackFail(kNotAllowedError)); + }, + + function uninstallPrimary() { + chrome.management.uninstall( + kPrimaryAppId, chrome.test.callbackFail(kNotAllowedError)); + }, + + function launchPrimary() { + chrome.management.launchApp( + kPrimaryAppId, chrome.test.callbackFail(kNotAllowedError)); + }, + + function createAppShortcut() { + chrome.management.createAppShortcut( + chrome.runtime.id, chrome.test.callbackFail(kNotAllowedError)); + }, + + function setLaunchType() { + chrome.management.setLaunchType( + chrome.runtime.id, 'OPEN_AS_WINDOW', + chrome.test.callbackFail(kNotAllowedError)); + }, + + function generateAppForLink() { + chrome.management.generateAppForLink( + 'https://test.test', 'Test app', + chrome.test.callbackFail(kNotAllowedError)); + } + ]); +}); diff --git a/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/secondary_app/src/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/secondary_app/src/manifest.json new file mode 100644 index 0000000000..b2c15614f8 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/management_api/secondary_app/src/manifest.json @@ -0,0 +1,10 @@ +{ + "name": "Secondary kiosk app for management API tests.", + "version": "1.0.0", + "manifest_version": 2, + "background": { + "scripts": ["main.js"], + "persistent": false + }, + "permissions": ["management"] +} diff --git a/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/webstore/downloads/faiboenfkkoaedoehhkjmenkhidadgje.crx b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/webstore/downloads/faiboenfkkoaedoehhkjmenkhidadgje.crx new file mode 100644 index 0000000000..dd6ab4658c Binary files /dev/null and b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/webstore/downloads/faiboenfkkoaedoehhkjmenkhidadgje.crx differ diff --git a/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/webstore/downloads/lfaidgolgikbpapkmdhoppddflhaocnf.crx b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/webstore/downloads/lfaidgolgikbpapkmdhoppddflhaocnf.crx new file mode 100644 index 0000000000..c5ba8b379f Binary files /dev/null and b/lgpl/sources/chromium/src/chrome/test/data/chromeos/app_mode/webstore/downloads/lfaidgolgikbpapkmdhoppddflhaocnf.crx differ diff --git a/lgpl/sources/chromium/src/chrome/test/data/chromeos/wallpaper_manager/unit_tests/api_mock.js b/lgpl/sources/chromium/src/chrome/test/data/chromeos/wallpaper_manager/unit_tests/api_mock.js index 61da30a5c5..5b885e0158 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/chromeos/wallpaper_manager/unit_tests/api_mock.js +++ b/lgpl/sources/chromium/src/chrome/test/data/chromeos/wallpaper_manager/unit_tests/api_mock.js @@ -5,11 +5,13 @@ var TestConstants = { isPowerwashed: 0, - wallpaperURL: 'https://test.com/test.jpg', + isUsingNewWallpaperPicker: false, + wallpaperUrl: 'https://test.com/test.jpg', + highResolutionSuffix: 'suffix', // A dummy string which is used to mock an image. IMAGE: '*#*@#&', // A dummy array which is used to mock the file content. - FILESTRING: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] + FILESTRING: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] }; // mock FileReader object in HTML5 File System @@ -210,7 +212,7 @@ var chrome = { items[Constants.AccessLocalWallpaperInfoKey] = null; } else { items[Constants.AccessLocalWallpaperInfoKey] = { - 'url': 'dummy', + 'url': TestConstants.wallpaperUrl, 'layout': 'dummy', 'source': Constants.WallpaperSourceEnum.Custom }; @@ -218,20 +220,17 @@ var chrome = { break; case Constants.AccessLocalManifestKey: items[Constants.AccessLocalManifestKey] = { - 'wallpaper_list': [ - { - 'available_for_surprise_me': true, - 'base_url': 'dummy', - 'default_layout': 'dummy' - } - ] + 'wallpaper_list': [{ + 'available_for_surprise_me': true, + 'base_url': TestConstants.wallpaperUrl, + 'default_layout': 'dummy' + }] }; break; } callback(items); }, - set: function(items, callback) { - } + set: function(items, callback) {} }, sync: { get: function(key, callback) { @@ -247,8 +246,7 @@ var chrome = { } callback(items); }, - set: function(items, callback) { - } + set: function(items, callback) {} }, onChanged: { addListener: function(listener) { @@ -266,39 +264,35 @@ var chrome = { } } }, - app: { - runtime: { - onLaunched: { - addListener: function(listener) { - } - } - } - }, - alarms: { - onAlarm: { - addListener: function(listener) { - } - } - }, + app: {runtime: {onLaunched: {addListener: function(listener) {}}}}, + alarms: {onAlarm: {addListener: function(listener) {}}}, wallpaperPrivate: { getStrings: function(callback) { - callback({isExperimental: false}); - }, - setCustomWallpaper: function(data, layout, isGenerateThumbnail, fileName, - callback) { + callback({ + useNewWallpaperPicker: TestConstants.isUsingNewWallpaperPicker, + highResolutionSuffix: TestConstants.highResolutionSuffix + }); }, + setCustomWallpaper: function( + data, layout, isGenerateThumbnail, fileName, callback) {}, getSyncSetting: function(callback) { var setting = {}; setting.syncThemes = true; callback(setting); }, - onWallpaperChangedBy3rdParty: { - addListener: function(listener) { - } + onWallpaperChangedBy3rdParty: {addListener: function(listener) {}}, + getCollectionsInfo: function(callback) { + callback([{collectionId: 'dummyId'}]); + }, + getImagesInfo: function(collectionId, callback) { + callback([{imageUrl: TestConstants.wallpaperUrl}]); } }, - runtime: { - lastError: null + runtime: {lastError: null}, + commandLinePrivate: { + hasSwitch: function(arg, callback) { + callback(TestConstants.isUsingNewWallpaperPicker); + } } }; diff --git a/lgpl/sources/chromium/src/chrome/test/data/chromeos/wallpaper_manager/unit_tests/event_page_unittest.js b/lgpl/sources/chromium/src/chrome/test/data/chromeos/wallpaper_manager/unit_tests/event_page_unittest.js index c79515aeb5..fe6eae129a 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/chromeos/wallpaper_manager/unit_tests/event_page_unittest.js +++ b/lgpl/sources/chromium/src/chrome/test/data/chromeos/wallpaper_manager/unit_tests/event_page_unittest.js @@ -23,15 +23,13 @@ function tearDown() { function testSyncCustomWallpaperSet() { var mockSetCustomWallpaper = mockController.createFunctionMock( chrome.wallpaperPrivate, 'setCustomWallpaper'); - mockSetCustomWallpaper.addExpectation(TestConstants.FILESTRING, - 'dummy', - true, - 'dummy'); + mockSetCustomWallpaper.addExpectation( + TestConstants.FILESTRING, 'dummy', true, TestConstants.wallpaperUrl); var syncFSChanges = {}; syncFSChanges.status = 'synced'; syncFSChanges.direction = 'remote_to_local'; syncFSChanges.action = 'added'; - syncFSChanges.fileEntry = mockSyncFS.mockTestFile('dummy'); + syncFSChanges.fileEntry = mockSyncFS.mockTestFile(TestConstants.wallpaperUrl); chrome.syncFileSystem.onFileStatusChanged.dispatch(syncFSChanges); } @@ -98,7 +96,7 @@ function testSyncOnlineWallpaper() { var changes = {}; changes[Constants.AccessSyncWallpaperInfoKey] = {}; changes[Constants.AccessSyncWallpaperInfoKey].newValue = { - 'url': TestConstants.wallpaperURL, + 'url': TestConstants.wallpaperUrl, 'layout': 'custom', 'source': Constants.WallpaperSourceEnum.Online }; @@ -122,11 +120,11 @@ function testSyncOnlineWallpaper() { // Test the surprise wallpaper's UMA stats is recorded correctly. function testSurpriseWallpaper() { + TestConstants.isUsingNewWallpaperPicker = false; var mockSetWallpaperIfExists = mockController.createFunctionMock( chrome.wallpaperPrivate, 'setWallpaperIfExists'); mockSetWallpaperIfExists.addExpectation( - 'dummy_high_resolution.jpg', - 'dummy'); + TestConstants.wallpaperUrl + TestConstants.highResolutionSuffix, 'dummy'); mockSetWallpaperIfExists.callbackData = [true]; var mockRecordWallpaperUMA = mockController.createFunctionMock( @@ -135,4 +133,15 @@ function testSurpriseWallpaper() { var dateString = new Date().toDateString(); SurpriseWallpaper.getInstance().setRandomWallpaper_(dateString); + + // Repeat the above process for the new wallpaper picker. Test that the UMA + // stats is also recorded correctly. + TestConstants.isUsingNewWallpaperPicker = true; + mockSetWallpaperIfExists.addExpectation( + TestConstants.wallpaperUrl + TestConstants.highResolutionSuffix, + 'CENTER_CROPPED'); + mockRecordWallpaperUMA.addExpectation(Constants.WallpaperSourceEnum.Daily); + + var dateString = new Date().toDateString(); + SurpriseWallpaper.getInstance().setRandomWallpaper_(dateString); } diff --git a/lgpl/sources/chromium/src/chrome/test/data/client_hints/accept_ch_without_lifetime_img_localhost.html b/lgpl/sources/chromium/src/chrome/test/data/client_hints/accept_ch_without_lifetime_img_localhost.html new file mode 100644 index 0000000000..883d30859b --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/client_hints/accept_ch_without_lifetime_img_localhost.html @@ -0,0 +1,8 @@ + + + +Empty file which uses link-rel to disable favicon fetches. The corresponding +.mock-http-headers sets client hints. + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/client_hints/accept_ch_without_lifetime_img_localhost.html.mock-http-headers b/lgpl/sources/chromium/src/chrome/test/data/client_hints/accept_ch_without_lifetime_img_localhost.html.mock-http-headers new file mode 100644 index 0000000000..42ffdfff57 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/client_hints/accept_ch_without_lifetime_img_localhost.html.mock-http-headers @@ -0,0 +1,2 @@ +HTTP/1.1 200 OK +Accept-CH: dpr,device-memory \ No newline at end of file diff --git a/lgpl/sources/chromium/src/chrome/test/data/client_hints/accept_ch_without_lifetime_with_iframe.html b/lgpl/sources/chromium/src/chrome/test/data/client_hints/accept_ch_without_lifetime_with_iframe.html new file mode 100644 index 0000000000..3fdd5cdb60 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/client_hints/accept_ch_without_lifetime_with_iframe.html @@ -0,0 +1,7 @@ + + + +Empty file which uses link-rel to disable favicon fetches. The corresponding +.mock-http-headers sets client hints. + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/client_hints/without_accept_ch_without_lifetime_img_foo_com.html b/lgpl/sources/chromium/src/chrome/test/data/client_hints/without_accept_ch_without_lifetime_img_foo_com.html new file mode 100644 index 0000000000..ce0197f072 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/client_hints/without_accept_ch_without_lifetime_img_foo_com.html @@ -0,0 +1,6 @@ + + + +File which uses link-rel to disable favicon fetches. + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/client_hints/without_accept_ch_without_lifetime_img_localhost.html b/lgpl/sources/chromium/src/chrome/test/data/client_hints/without_accept_ch_without_lifetime_img_localhost.html new file mode 100644 index 0000000000..47610455d5 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/client_hints/without_accept_ch_without_lifetime_img_localhost.html @@ -0,0 +1,6 @@ + + + +File which uses link-rel to disable favicon fetches. + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/content_setting_bubble/geolocation.html b/lgpl/sources/chromium/src/chrome/test/data/content_setting_bubble/geolocation.html new file mode 100644 index 0000000000..667642e03f --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/content_setting_bubble/geolocation.html @@ -0,0 +1,8 @@ + + + + + + geolocation test page + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/content_setting_bubble/geolocation.js b/lgpl/sources/chromium/src/chrome/test/data/content_setting_bubble/geolocation.js new file mode 100644 index 0000000000..751692d283 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/content_setting_bubble/geolocation.js @@ -0,0 +1,9 @@ +// Copyright 2018 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. + +function geolocate() { + navigator.geolocation.getCurrentPosition(function (p) { + console.log("result: " + p); + }); +}; diff --git a/lgpl/sources/chromium/src/chrome/test/data/devtools/emulate_network_conditions.html b/lgpl/sources/chromium/src/chrome/test/data/devtools/emulate_network_conditions.html index f820d58b39..425b173e56 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/devtools/emulate_network_conditions.html +++ b/lgpl/sources/chromium/src/chrome/test/data/devtools/emulate_network_conditions.html @@ -3,7 +3,9 @@ diff --git a/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif-input-iframe.html b/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif-input-iframe.html new file mode 100644 index 0000000000..bbecef68b1 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif-input-iframe.html @@ -0,0 +1,4 @@ + + +Hello World! + diff --git a/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif-input.html b/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif-input.html new file mode 100644 index 0000000000..6009800a3c --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif-input.html @@ -0,0 +1,10 @@ + + + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif-input.js b/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif-input.js new file mode 100644 index 0000000000..7ee4bb101e --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif-input.js @@ -0,0 +1,47 @@ +// Copyright 2018 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. + +var logs = []; +function log(text) { + logs.push(text); +} + +function logMouseEvent(event) { + log('Event'); + log('type: ' + event.type); + log('button: ' + event.button); + if (event.shiftKey) + log('shiftKey'); + log('x: ' + event.x); + log('y: ' + event.y); + if (event.type === 'mousewheel') { + log('deltaX: ' + event.deltaX); + log('deltaY: ' + event.deltaY); + } + event.preventDefault(); +} + +function logKeyEvent(event) { + log('Event'); + log('type: ' + event.type); + event.preventDefault(); +} + +function logTouchEvent(event) { + log('Event'); + log('type: ' + event.type); + for (var touch of event.touches) { + log('touch x: ' + touch.pageX); + log('touch y: ' + touch.pageY); + } + event.preventDefault(); +} + +window.addEventListener('mousedown', logMouseEvent); +window.addEventListener('mouseup', logMouseEvent); +window.addEventListener('contextmenu', logMouseEvent); +window.addEventListener('mousewheel', logMouseEvent); +window.addEventListener('keydown', logKeyEvent); +window.addEventListener('touchstart', logTouchEvent); +window.addEventListener('touchend', event => event.preventDefault()); diff --git a/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif.html b/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif.html new file mode 100644 index 0000000000..26c45df188 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif.html @@ -0,0 +1,9 @@ + + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif_frame.html b/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif_frame.html new file mode 100644 index 0000000000..73e5d664a0 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/devtools/oopif_frame.html @@ -0,0 +1 @@ +some content diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/activity_log_app/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/activity_log_app/manifest.json index 92bb0a59ca..01a922b34a 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/activity_log_app/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/activity_log_app/manifest.json @@ -1,5 +1,6 @@ { "name": "Activity Log Test APP", + "manifest_version": 2, "description": "Used to test Activity Log with an app", "version": "0.1", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/activity_log_private/test/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/activity_log_private/test/test.js index d4ea2bccf5..ff0a0b5224 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/activity_log_private/test/test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/activity_log_private/test/test.js @@ -58,9 +58,12 @@ testCases.push({ chrome.runtime.sendMessage(FRIEND_EXTENSION_ID, 'message_self', function response() { }); }, - expected_activity: [ + expected_activity_js: [ 'runtime.connect', 'runtime.sendMessage' + ], + expected_activity_native: [ + 'runtime.sendMessage' ] }); testCases.push({ @@ -68,9 +71,12 @@ testCases.push({ chrome.runtime.sendMessage(FRIEND_EXTENSION_ID, 'message_other', function response() { }); }, - expected_activity: [ + expected_activity_js: [ 'runtime.connect', 'runtime.sendMessage' + ], + expected_activity_native: [ + 'runtime.sendMessage' ] }); testCases.push({ @@ -176,7 +182,7 @@ testCases.push({ chrome.runtime.sendMessage(FRIEND_EXTENSION_ID, 'api_tab_updated', function response() { }); }, - expected_activity: [ + expected_activity_js: [ 'tabs.onUpdated', 'tabs.onUpdated', 'tabs.onUpdated', @@ -185,6 +191,15 @@ testCases.push({ 'tabs.executeScript', 'tabs.executeScript', 'tabs.remove' + ], + expected_activity_native: [ + 'tabs.onUpdated', + 'tabs.onUpdated', + 'tabs.onUpdated', + 'tabs.sendMessage', + 'tabs.executeScript', + 'tabs.executeScript', + 'tabs.remove' ] }); testCases.push({ @@ -194,7 +209,7 @@ testCases.push({ function response() { }); }, is_incognito: true, - expected_activity: [ + expected_activity_js: [ 'windows.create', 'tabs.onUpdated', 'tabs.onUpdated', @@ -204,6 +219,16 @@ testCases.push({ 'tabs.executeScript', 'tabs.executeScript', 'tabs.remove' + ], + expected_activity_native: [ + 'windows.create', + 'tabs.onUpdated', + 'tabs.onUpdated', + 'tabs.onUpdated', + 'tabs.sendMessage', + 'tabs.executeScript', + 'tabs.executeScript', + 'tabs.remove' ] }); testCases.push({ @@ -511,32 +536,45 @@ chrome.activityLogPrivate.onExtensionActivity.addListener( ); function setupTestCasesAndRun() { - chrome.runtime.getPlatformInfo(function(info) { - var tests = []; - for (var i = 0; i < testCases.length; i++) { - // Ignore test case if disabled for this OS. - if (testCases[i].disabled != undefined && - info.os in testCases[i].disabled && - testCases[i].disabled[info.os]) { - console.log('Test case disabled for this OS: ' + info.os); - continue; - } + chrome.test.getConfig(function(config) { + chrome.runtime.getPlatformInfo(function(info) { + var tests = []; + for (var i = 0; i < testCases.length; i++) { + // Ignore test case if disabled for this OS. + if (testCases[i].disabled != undefined && + info.os in testCases[i].disabled && + testCases[i].disabled[info.os]) { + console.log('Test case disabled for this OS: ' + info.os); + continue; + } - // Add the test case to the enabled list and set the expected activity - // appriorate for this OS. - if (testCases[i].func != undefined) { - tests.push(testCases[i].func); - var enabledTestCase = testCases[i]; - var activityListForOS = 'expected_activity_' + info.os; - if (activityListForOS in enabledTestCase) { - console.log('Expecting OS specific activity for: ' + info.os); - enabledTestCase.expected_activity = - enabledTestCase[activityListForOS]; + // Add the test case to the enabled list and set the expected activity + // appriorate for this OS. + if (testCases[i].func != undefined) { + tests.push(testCases[i].func); + var enabledTestCase = testCases[i]; + var activityListForOS = 'expected_activity_' + info.os; + if (activityListForOS in enabledTestCase) { + console.log('Expecting OS specific activity for: ' + info.os); + enabledTestCase.expected_activity = + enabledTestCase[activityListForOS]; + } else if ('expected_activity_js' in enabledTestCase) { + // Some tests have different activity depending on whether native + // bindings are being used. This is in the case of the extension + // using the sendMessage() API. With JS bindings, this is + // implemented using connect(), so both API calls are seen. With + // native bindings, we fix this, and only the sendMessage call is + // seen. + var key = config.nativeCrxBindingsEnabled ? + 'expected_activity_native' : 'expected_activity_js'; + enabledTestCase.expected_activity = enabledTestCase[key]; + } + + enabledTestCases.push(enabledTestCase); } - enabledTestCases.push(enabledTestCase); } - } - chrome.test.runTests(tests); + chrome.test.runTests(tests); + }); }); } diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/sites/reverse_relations.html b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/sites/reverse_relations.html new file mode 100644 index 0000000000..2cc5e5b83f --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/sites/reverse_relations.html @@ -0,0 +1,20 @@ + + + +Automation Tests - Relations + + + + +

DetailsTo

+ + +

Label1

+

Label2

+ + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/desktop/focus_iframe.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/desktop/focus_iframe.js index ee69b37a62..5e6a4beb53 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/desktop/focus_iframe.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/desktop/focus_iframe.js @@ -18,7 +18,8 @@ var allTests = [ // Wait for the inner frame to load, then find the button inside it // and focus it. rootNode.addEventListener('loadComplete', function(event) { - if (event.target.url.indexOf('iframe_inner.html') >= 0) { + if (event.target.url && + event.target.url.indexOf('iframe_inner.html') >= 0) { chrome.automation.getFocus(function(focus) { // Assert that the outer frame has focus. assertTrue(focus.url.indexOf('iframe_outer') >= 0); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/desktop/hit_test_iframe.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/desktop/hit_test_iframe.js index bb2ec89bf5..f24ba5978e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/desktop/hit_test_iframe.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/desktop/hit_test_iframe.js @@ -18,7 +18,8 @@ var allTests = [ // Wait for the inner frame to load, then find the button inside it // and do a hit test on it. rootNode.addEventListener(EventType.LOAD_COMPLETE, function(event) { - if (event.target.url.indexOf('iframe_inner.html') >= 0) { + if (event.target.url && + event.target.url.indexOf('iframe_inner.html') >= 0) { // Find the inner button. var innerButton = event.target.find( { attributes: { name: 'Inner' } }); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/tabs/reverse_relations.html b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/tabs/reverse_relations.html new file mode 100644 index 0000000000..8f46032e78 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/tabs/reverse_relations.html @@ -0,0 +1,7 @@ + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/tabs/reverse_relations.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/tabs/reverse_relations.js new file mode 100644 index 0000000000..e9f4755fcc --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/automation/tests/tabs/reverse_relations.js @@ -0,0 +1,30 @@ +// Copyright 2017 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. + +var allTests = [ + function testDetailsReverseRelations() { + var detailsFrom = rootNode.find({attributes: {name: 'DetailsFrom'}}); + var detailsTo = rootNode.find({attributes: {name: 'DetailsTo'}}); + assertEq(detailsFrom.details, detailsTo); + assertEq(detailsTo.detailsFor.length, 1); + assertEq(detailsTo.detailsFor[0], detailsFrom); + chrome.test.succeed(); + }, + + function testLabelledByReverseRelations() { + var input = rootNode.find({role: RoleType.TEXT_FIELD}); + var label1 = rootNode.find({attributes: {name: 'Label1'}}); + var label2 = rootNode.find({attributes: {name: 'Label2'}}); + assertEq(input.labelledBy.length, 2); + assertEq(input.labelledBy[0], label1); + assertEq(input.labelledBy[1], label2); + assertEq(label1.labelFor.length, 1); + assertEq(label1.labelFor[0], input); + assertEq(label2.labelFor.length, 1); + assertEq(label2.labelFor[0], input); + chrome.test.succeed(); + }, +]; + +setUpAndRunTests(allTests, 'reverse_relations.html'); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/bindings/invalidate_context/background.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/bindings/invalidate_context/background.js index cf04170c65..4f58c60abe 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/bindings/invalidate_context/background.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/bindings/invalidate_context/background.js @@ -7,30 +7,77 @@ var frameRuntime; var frameStorage; var frameTabs; -chrome.test.runTests([ - function createFrame() { - frame = document.createElement('iframe'); - frame.src = chrome.runtime.getURL('frame.html'); - frame.onload = chrome.test.succeed; +function createFrame() { + frame = document.createElement('iframe'); + frame.src = chrome.runtime.getURL('frame.html'); + return new Promise((resolve) => { + frame.onload = resolve; document.body.appendChild(frame); - }, + }); +} + +function testPort(port) { + var result = { + disconnectThrow: false, + postMessageThrow: false, + onMessageEvent: undefined, + onDisconnectEvent: undefined, + getOnMessageThrow: false, + getOnDisconnectThrow: false, + }; + + try { + port.postMessage('hello'); + } catch (e) { + result.postMessageThrow = true; + } + + try { + result.onMessageEvent = port.onMessage; + } catch (e) { + result.getOnMessageThrow = true; + } + + try { + result.onDisconnect = port.onDisconnect; + } catch (e) { + result.getOnDisconnectThrow = true; + } + + try { + port.disconnect(); + } catch (e) { + result.disconnectThrow = true; + } + + chrome.test.assertTrue(result.postMessageThrow); + chrome.test.assertTrue(result.disconnectThrow); + chrome.test.assertTrue(result.getOnMessageThrow); + chrome.test.assertTrue(result.getOnDisconnectThrow); + chrome.test.assertFalse(!!result.onMessageEvent); + chrome.test.assertFalse(!!result.onDisconnectEvent); +} + +chrome.test.runTests([ function useFrameStorageAndRuntime() { - frameRuntime = frame.contentWindow.chrome.runtime; - chrome.test.assertTrue(!!frameRuntime); - frameStorage = frame.contentWindow.chrome.storage.local; - chrome.test.assertTrue(!!frameStorage); - frameTabs = frame.contentWindow.chrome.tabs; - chrome.test.assertTrue(!!frameTabs); - chrome.test.assertEq(chrome.runtime.getURL('background.js'), - frameRuntime.getURL('background.js')); - frameStorage.set({foo: 'bar'}, function() { - chrome.test.assertFalse(!!chrome.runtime.lastError); - chrome.test.assertFalse(!!frameRuntime.lastError); - chrome.storage.local.get('foo', function(vals) { + createFrame().then(() => { + frameRuntime = frame.contentWindow.chrome.runtime; + chrome.test.assertTrue(!!frameRuntime); + frameStorage = frame.contentWindow.chrome.storage.local; + chrome.test.assertTrue(!!frameStorage); + frameTabs = frame.contentWindow.chrome.tabs; + chrome.test.assertTrue(!!frameTabs); + chrome.test.assertEq(chrome.runtime.getURL('background.js'), + frameRuntime.getURL('background.js')); + frameStorage.set({foo: 'bar'}, function() { chrome.test.assertFalse(!!chrome.runtime.lastError); chrome.test.assertFalse(!!frameRuntime.lastError); - chrome.test.assertEq('bar', vals.foo); - chrome.test.succeed(); + chrome.storage.local.get('foo', function(vals) { + chrome.test.assertFalse(!!chrome.runtime.lastError); + chrome.test.assertFalse(!!frameRuntime.lastError); + chrome.test.assertEq('bar', vals.foo); + chrome.test.succeed(); + }); }); }); }, @@ -46,4 +93,46 @@ chrome.test.runTests([ chrome.test.succeed(); }, + function usePortAfterInvalidation() { + var listener = function() {}; + chrome.runtime.onConnect.addListener(listener); + createFrame().then(() => { + var frameRuntime = frame.contentWindow.chrome.runtime; + var port = frameRuntime.connect(); + chrome.test.assertTrue(!!port); + + port.postMessage; + document.body.removeChild(frame); + + testPort(port); + chrome.test.succeed(); + }); + }, + function usePortAfterInvalidationAndDisconnect() { + createFrame().then(() => { + var frameRuntime = frame.contentWindow.chrome.runtime; + var port = frameRuntime.connect(); + chrome.test.assertTrue(!!port); + + port.disconnect(); + document.body.removeChild(frame); + + testPort(port); + chrome.test.succeed(); + }); + }, + function usePortAfterInvalidationAndEventsCreated() { + createFrame().then(() => { + var frameRuntime = frame.contentWindow.chrome.runtime; + var port = frameRuntime.connect(); + chrome.test.assertTrue(!!port); + + port.onMessage; + port.onDisconnect; + document.body.removeChild(frame); + + testPort(port); + chrome.test.succeed(); + }); + }, ]); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/bookmarks/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/bookmarks/test.js index 0dde79bf6a..8d52d498d5 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/bookmarks/test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/bookmarks/test.js @@ -473,17 +473,24 @@ chrome.test.runTests([ }, function getRecentSetup() { + Promise.all([removeAllChildren('1'), removeAllChildren('2')]).then( + pass(afterRemove)); + + function removeTreePromise(id) { + return new Promise(pass(function(resolve) { + chrome.bookmarks.removeTree(id, resolve); + })); + } + // Clean up tree - ["1", "2"].forEach(function(id) { - chrome.bookmarks.getChildren(id, pass(function(children) { - children.forEach(function(child, i) { - chrome.bookmarks.removeTree(child.id, pass(function() {})); - // When we have removed the last child we can continue. - if (id == "2" && i == children.length - 1) - afterRemove(); - }); + function removeAllChildren(id) { + return new Promise(pass(function(resolve) { + chrome.bookmarks.getChildren(id, pass(function(children) { + Promise.all(children.map((child) => removeTreePromise(child.id))) + .then(resolve); + })); })); - }); + } function afterRemove() { // Once done add 3 nodes diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/content_script.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/content_script.js new file mode 100644 index 0000000000..bed686ba4e --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/content_script.js @@ -0,0 +1,19 @@ +// Copyright 2018 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. + +function doSendMessage(message) { + return new Promise(resolve => { + chrome.runtime.sendMessage(chrome.runtime.id, message, {}, resolve); + }); +} + +// This is the content script part of testBlobUrlFromContentScript(). We ask the +// background page to generate a blob:chrome-extension:// URL, then fetch() it +// here in the content script, and pass the response back to the background +// page, which passes the test if we were able to successfully fetch the blob. +doSendMessage('kindly_reply_with_blob_url') + .then(blob_url_from_background_page => fetch(blob_url_from_background_page)) + .then(http_response_from_fetch => http_response_from_fetch.text()) + .then(blob_contents_as_text => doSendMessage(blob_contents_as_text)) + .catch(error => doSendMessage(error)); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/manifest.json new file mode 100644 index 0000000000..355f16c75a --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/manifest.json @@ -0,0 +1,17 @@ +{ + "name": "content_script_blob_fetch", + "version": "1.0", + "manifest_version": 2, + "description": "Tests the behavior of fetching a blob:chrome-extension:// URL from a content script.", + "background": { + "persistent": true, + "page": "test.html" + }, + "permissions": ["tabs"], + "content_scripts": [ + { + "matches": ["http://localhost:*/extensions/test_file.html"], + "js": ["content_script.js"] + } + ] +} diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/test.html b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/test.html new file mode 100644 index 0000000000..d0e57a588b --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/test.html @@ -0,0 +1,6 @@ + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/test.js new file mode 100644 index 0000000000..a343badf6b --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/blob_fetch/test.js @@ -0,0 +1,33 @@ +// Copyright 2018 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. + +// We load a page that our content script runs in. The content script responds +// asking the background page (i.e., this page) to generate a blob: URL in the +// chrome-extension:// origin. This URL is sent back to the content script, +// which attempts to fetch it. +chrome.test.runTests([ + // Tests receiving a request from a content script and responding. + function testBlobUrlFromContentScript() { + chrome.extension.onMessage.addListener(function( + request, sender, sendResponse) { + if (request == 'kindly_reply_with_blob_url') { + let blob_url = URL.createObjectURL(new Blob(['success_payload'])); + sendResponse(blob_url); + } else if (request == 'success_payload') { + chrome.test.succeed(); + } else { + chrome.test.fail('Unexpected request: ' + JSON.stringify(request)); + } + }); + } +]); + +chrome.test.getConfig(function(config) { + chrome.test.log('Creating tab...'); + + var test_url = 'http://localhost:PORT/extensions/test_file.html'.replace( + /PORT/, config.testServer.port); + + chrome.tabs.create({url: test_url}); +}); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/ntp/background.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/ntp/background.js index b1f8ea29b7..d31eb379f3 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/ntp/background.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/content_scripts/ntp/background.js @@ -2,12 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +var newTabUrls = [ + 'chrome://newtab/', + // The tab URL will be redirected to the Local New Tab Page if + // features::kUseGoogleLocalNtp is not enabled. + 'chrome-search://local-ntp/local-ntp.html', +]; + function testExecuteScriptInNewTab() { // Create a new tab to chrome://newtab and wait for the loading to complete. // Then, try to inject a script into that tab. The injection should fail. chrome.tabs.onUpdated.addListener(function listener(tabId, changeInfo, tab) { - if (tab.url != 'chrome://newtab/' || changeInfo.status != 'complete') + if (!newTabUrls.includes(tab.url) || changeInfo.status != 'complete') { return; + } chrome.tabs.onUpdated.removeListener(listener); chrome.tabs.executeScript(tab.id, {file: 'script.js'}, function() { chrome.test.assertTrue(!!chrome.runtime.lastError); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/crazy_extension/background.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/crazy_extension/background.js index 02e9a5ffd0..f276198e16 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/crazy_extension/background.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/crazy_extension/background.js @@ -42,7 +42,17 @@ chrome.test.runTests([ // renderer if the frame doesn't exist anymore. var iframeChromeApp = iframe.contentWindow.chrome.app; document.body.removeChild(iframe); - chrome.test.assertEq(undefined, iframeChromeApp.getDetails()); + var getDetailsResult; + // Note: native bindings throw an error when accessed after + // invalidation (to let the script know something when wrong); JS + // bindings just return undefined. + try { + getDetailsResult = iframeChromeApp.getDetails(); + } catch (e) { + chrome.test.assertTrue(e.message.includes('context invalidated'), + e.message); + } + chrome.test.assertEq(undefined, getDetailsResult); chrome.test.succeed(); break; } diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/debugger/background.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/debugger/background.js index 87ec46d4a6..1f62b41ff1 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/debugger/background.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/debugger/background.js @@ -7,8 +7,8 @@ var fail = chrome.test.callbackFail; var tabId; var debuggee; -var protocolVersion = "1.2"; -var protocolPreviousVersion = "1.1"; +var protocolVersion = "1.3"; +var protocolPreviousVersion = "1.2"; var unsupportedMinorProtocolVersion = "1.5"; var unsupportedMajorProtocolVersion = "100.0"; @@ -215,6 +215,27 @@ chrome.test.runTests([ debuggee, "Page.navigate", {url:"about:blank"}, onNavigateDone); } + chrome.debugger.attach(debuggee, protocolVersion, onAttach); + }); + }, + + function sendCommandToDataUri() { + chrome.tabs.create({url:"data:text/html,

hi

"}, function(tab) { + var debuggee = {tabId: tab.id}; + + function checkError() { + if (chrome.runtime.lastError) { + chrome.test.fail(chrome.runtime.lastError.message); + } else { + chrome.tabs.remove(tab.id); + chrome.test.succeed(); + } + } + + function onAttach() { + chrome.debugger.sendCommand(debuggee, "Page.enable", null, checkError); + } + chrome.debugger.attach(debuggee, protocolVersion, onAttach); }); } diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/debugger_extension/background.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/debugger_extension/background.js index 6a22290f61..eddff726d4 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/debugger_extension/background.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/debugger_extension/background.js @@ -6,7 +6,7 @@ var pass = chrome.test.callbackPass; var fail = chrome.test.callbackFail; var debuggee; -var protocolVersion = "1.2"; +var protocolVersion = "1.3"; chrome.test.runTests([ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/desktop_capture/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/desktop_capture/test.js index e69e9fc6fd..7b19cd7cfe 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/desktop_capture/test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/desktop_capture/test.js @@ -135,10 +135,11 @@ chrome.test.runTests([ // 6. To actually get audio track, getUserMedia() should set audio // constraint. - function tabShareWithAudioPermissionGetStream() { - chrome.desktopCapture.chooseDesktopMedia( - ["tab", "audio"], onPickerResult.bind(undefined, 1)); - }, + // TODO(crbug.com/805145): Test fails; invalid device IDs being generated. + // function tabShareWithAudioPermissionGetStream() { + // chrome.desktopCapture.chooseDesktopMedia( + // ["tab", "audio"], onPickerResult.bind(undefined, 1)); + // }, function windowShareWithAudioPermissionGetStream() { chrome.desktopCapture.chooseDesktopMedia( @@ -152,10 +153,11 @@ chrome.test.runTests([ expected_audio_tracks_for_screen_share)); }, - function tabShareWithoutAudioPermissionGetStream() { - chrome.desktopCapture.chooseDesktopMedia( - ["tab", "audio"], onPickerResult.bind(undefined, 0)); - }, + // TODO(crbug.com/805145): Test fails; invalid device IDs being generated. + // function tabShareWithoutAudioPermissionGetStream() { + // chrome.desktopCapture.chooseDesktopMedia( + // ["tab", "audio"], onPickerResult.bind(undefined, 0)); + // }, function windowShareWithoutAudioPermissionGetStream() { chrome.desktopCapture.chooseDesktopMedia( diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/enterprise_device_attributes.crx b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/enterprise_device_attributes.crx index dc7f893278..6230850af0 100644 Binary files a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/enterprise_device_attributes.crx and b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/enterprise_device_attributes.crx differ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/enterprise_device_attributes/basic.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/enterprise_device_attributes/basic.js index 9678b5f595..9a3783e68a 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/enterprise_device_attributes/basic.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/enterprise_device_attributes/basic.js @@ -5,17 +5,41 @@ // Must be packed to ../enterprise_device_attributes.crx using the private key // ../enterprise_device_attributes.pem . -// The expected directory device id, that is passed by caller. -var expected_value = location.search.substring(1); +chrome.test.getConfig(function(config) { + var customArg = JSON.parse(config.customArg); + var expectedDirectoryDeviceId = customArg.expectedDirectoryDeviceId; + var expectedSerialNumber = customArg.expectedSerialNumber; + var expectedAssetId = customArg.expectedAssetId; + var expectedAnnotatedLocation = customArg.expectedAnnotatedLocation; -var assertEq = chrome.test.assertEq; -var assertTrue = chrome.test.assertTrue; -var callbackPass = chrome.test.callbackPass -var succeed = chrome.test.succeed; + chrome.test.runTests([ + function testDirectoryDeviceId() { + chrome.enterprise.deviceAttributes.getDirectoryDeviceId(function( + deviceId) { + chrome.test.assertEq(expectedDirectoryDeviceId, deviceId); + chrome.test.succeed(); + }); + }, + function testDeviceSerialNumber() { + chrome.enterprise.deviceAttributes.getDeviceSerialNumber(function( + serialNumber) { + chrome.test.assertEq(expectedSerialNumber, serialNumber); + chrome.test.succeed(); + }); -assertTrue(chrome.enterprise.deviceAttributes.getDirectoryDeviceId( - callbackPass(function(device_id) { - assertEq(expected_value, device_id); - }))); - -succeed(); + }, + function testDeviceAssetId() { + chrome.enterprise.deviceAttributes.getDeviceAssetId(function(assetId) { + chrome.test.assertEq(expectedAssetId, assetId); + chrome.test.succeed(); + }); + }, + function testDeviceAnnotatedLocation() { + chrome.enterprise.deviceAttributes.getDeviceAnnotatedLocation(function( + annotatedLocation) { + chrome.test.assertEq(expectedAnnotatedLocation, annotatedLocation); + chrome.test.succeed(); + }); + } + ]); +}); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/events/webview_events/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/events/webview_events/manifest.json index 01f5dba7a1..0f8cd1e662 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/events/webview_events/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/events/webview_events/manifest.json @@ -1,5 +1,6 @@ { "name": "Test webview events", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/b.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/b.js new file mode 100644 index 0000000000..653fedc3a3 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/b.js @@ -0,0 +1,13 @@ +// Copyright 2017 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. + +chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { + var element = document.getElementById(message.id); + var style = getComputedStyle(element); + var response = { + color: style.getPropertyValue('color'), + backgroundColor: style.getPropertyValue('background-color') + }; + sendResponse(response); +}); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/manifest.json new file mode 100644 index 0000000000..bfbdf151ee --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/manifest.json @@ -0,0 +1,16 @@ +{ + "version": "1.0.0.0", + "manifest_version": 2, + "name": "css_origin test", + "description": "Test the css_origin property of insertCSS", + "background": { + "scripts": ["test.js"] + }, + "permissions": ["tabs", "http://b.com/"], + "content_scripts": [ + { + "matches": ["http://*/*"], + "js": ["b.js"] + } + ] +} diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/test.html b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/test.html new file mode 100644 index 0000000000..a806a791be --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/test.html @@ -0,0 +1,16 @@ + + +
+ Hello. +
+
+ Hello. +
+
+ Hello. +
+ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/test.js new file mode 100644 index 0000000000..78047330af --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/executescript/css_origin/test.js @@ -0,0 +1,92 @@ +// Copyright 2017 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. + +chrome.test.getConfig(function(config) { + var testUrl = 'http://b.com:' + config.testServer.port + + '/extensions/api_test/executescript/css_origin/test.html'; + chrome.tabs.onUpdated.addListener(function listener(tabId, changeInfo, tab) { + if (changeInfo.status != 'complete') + return; + chrome.tabs.onUpdated.removeListener(listener); + chrome.test.runTests([ + // Until we have tabs.removeCSS we just have to target a different + // element on the page for each test. + function authorOriginShouldSucceed() { + var injectDetails = {}; + injectDetails.code = '#author {' + + ' color: blue !important;' + + ' background-color: white !important;' + + '}'; + injectDetails.cssOrigin = 'author'; + chrome.tabs.insertCSS(tabId, injectDetails, + chrome.test.callbackPass(function() { + chrome.tabs.sendMessage(tabId, { id: 'author' }, + chrome.test.callbackPass(function(response) { + chrome.test.assertEq('rgb(0, 0, 255)', response.color); + // !important rules in author style sheets do not override inline + // !important rules. + chrome.test.assertEq('rgb(0, 0, 0)', response.backgroundColor); + })); + })); + }, + function userOriginShouldSucceed() { + var injectDetails = {}; + injectDetails.code = '#user {' + + ' color: blue !important;' + + ' background-color: white !important;' + + '}'; + injectDetails.cssOrigin = 'user'; + chrome.tabs.insertCSS(tabId, injectDetails, + chrome.test.callbackPass(function() { + chrome.tabs.sendMessage(tabId, { id: 'user' }, + chrome.test.callbackPass(function(response) { + chrome.test.assertEq('rgb(0, 0, 255)', response.color); + // !important rules in user style sheets do override inline + // !important rules. + chrome.test.assertEq('rgb(255, 255, 255)', + response.backgroundColor); + })); + })); + }, + function noneOriginShouldSucceed() { + // When no CSS origin is specified, it should default to author origin. + var injectDetails = {}; + injectDetails.code = '#none {' + + ' color: blue !important;' + + ' background-color: white !important;' + + '}'; + chrome.tabs.insertCSS(tabId, injectDetails, + chrome.test.callbackPass(function() { + chrome.tabs.sendMessage(tabId, { id: 'none' }, + chrome.test.callbackPass(function(response) { + chrome.test.assertEq('rgb(0, 0, 255)', response.color); + // !important rules in author style sheets do not override inline + // !important rules. + chrome.test.assertEq('rgb(0, 0, 0)', response.backgroundColor); + })); + })); + }, + function unknownOriginShouldFail() { + var injectDetails = {}; + injectDetails.code = '#unknown { color: black !important }'; + injectDetails.cssOrigin = 'unknown'; + try { + chrome.tabs.insertCSS(tabId, injectDetails); + chrome.test.fail('Unknown CSS origin should throw an error'); + } catch (e) { + chrome.test.succeed(); + } + }, + function originInExecuteScriptShouldFail() { + var injectDetails = {}; + injectDetails.code = '(function(){})();'; + injectDetails.cssOrigin = 'author'; + chrome.tabs.executeScript(tabId, injectDetails, + chrome.test.callbackFail( + 'CSS origin should be specified only for CSS code.')); + } + ]); + }); + chrome.tabs.create({ url: testUrl }); +}); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/extension_resource_request_policy/hosted_app/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/extension_resource_request_policy/hosted_app/manifest.json index 9e4f339504..d5cf47efe3 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/extension_resource_request_policy/hosted_app/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/extension_resource_request_policy/hosted_app/manifest.json @@ -1,5 +1,6 @@ { "description": "Hosted app", + "manifest_version": 2, "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDPOziAf8MbTjdUo6DysZ4nAU/2f/kwYnftyKkxI1GyTlbStprGy+Y2ek4/59QbE3xEE+dIIuYeObM4QTptpcFMg956ZLFoeDg41Pg3tzUrbltgG8hXTbBxN852FJx2kdaqa/MKUUsJKGSD5hkUmvZRADGGWhMWzvz64ao1h02xJQIDAQAD", "name": "test", "version": "0.1", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_display_path/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_display_path/manifest.json index bd7b062ab8..e3d80ebd1d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_display_path/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_display_path/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem get display path", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.getDisplayPath", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_display_path_prettify/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_display_path_prettify/manifest.json index 5f3cf900f5..b4ad590b2e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_display_path_prettify/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_display_path_prettify/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem get display path, prettify", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.getDisplayPath", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_volume_list/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_volume_list/manifest.json index af3d483088..167ccd5242 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_volume_list/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_volume_list/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.getVolumeList test", + "manifest_version": 2, "version": "0.1", "description": "Test for getting a list of available volumes via chrome.fileSystem.getVolumeList.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_volume_list_not_kiosk_session/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_volume_list_not_kiosk_session/manifest.json index 3a3705371e..fd98f74388 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_volume_list_not_kiosk_session/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_volume_list_not_kiosk_session/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.getVolumeList not in kiosk session test", + "manifest_version": 2, "version": "0.1", "description": "Test for getting a list of available volumes via chrome.fileSystem.getVolumeList when not running in the kiosk session.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_file_entry/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_file_entry/manifest.json index 283fcf8f23..1c1cfca22c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_file_entry/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_file_entry/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem get writable file entry", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.getWritableFileEntry", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_file_entry_with_write/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_file_entry_with_write/manifest.json index 4d197db556..ef145a2dbb 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_file_entry_with_write/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_file_entry_with_write/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem get writable file entry with write.", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.getWritableFileEntry.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_root_entry/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_root_entry/manifest.json index 2ebd009381..7cf8bb79d3 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_root_entry/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/get_writable_root_entry/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem get writable file entry", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.getWritableFileEntry", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/invalid_choose_file_type/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/invalid_choose_file_type/manifest.json index e8c664eec0..b3adce4b60 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/invalid_choose_file_type/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/invalid_choose_file_type/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem invalid choose file.", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile invalid type.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/is_writable_file_entry/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/is_writable_file_entry/manifest.json index 106929eae5..57bab54c14 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/is_writable_file_entry/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/is_writable_file_entry/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem is writable file entry", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.isWritableFileEntry", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/is_writable_file_entry_with_write/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/is_writable_file_entry_with_write/manifest.json index 2588137c4a..a5af7f3138 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/is_writable_file_entry_with_write/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/is_writable_file_entry_with_write/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem is writable file entry", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.isWritableFileEntry", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/on_volume_list_changed/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/on_volume_list_changed/manifest.json index 63c7f80650..1945200b0d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/on_volume_list_changed/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/on_volume_list_changed/manifest.json @@ -1,5 +1,6 @@ { // chrome-extension://pkplfbidichfdicaijlchgnapepdginl + "manifest_version": 2, "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtDfX9dHNh948bt00YhZBm3P6E5QLaOt+v8kXVtibQfiPtOD2FTScB/f0wX/EQWVO7BkaSOsRkTPcPIgocyMPYr2FLgqGLFlYT9nQpKJZUFNF5oJ5rG6Nv7ppf4zEB3j6da1IBRTz2yOZ+6O1TMZxol/V62/QcqrJeggsHTEPGLdr9Ua4b1Ka0xKJnJngZljsbw93FI1o+P9dAh5BS6wTPiZI/vmJVjvMTkSTnaZ3n9Go2t7A0XLcSxLcVyuLAd2mAvSN0mIviOukdM66wr7llif71nKuUt+4qvlr/r9HfwzN6pA4jkwhtS1UD+3CmB+wsHwsnohNcuu4FIQ6rgq/7QIDAQAB", "name": "chrome.fileSystem.onVolumeListChanged test", "version": "0.1", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_background/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_background/manifest.json index a92c1aea39..3742d76f7d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_background/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_background/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open from background.", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile open from background.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_cancel/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_cancel/manifest.json index 8c5e11c813..cfbad94362 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_cancel/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_cancel/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open cancel.", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile opening cancelled.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory/manifest.json index 00d7e5a718..46e62db8e9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open existing directory", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseEntry opening existing directory.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_cancel/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_cancel/manifest.json index 2ff26d7f93..18f9c8ca89 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_cancel/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_cancel/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open cancel.", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile opening cancelled.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_with_only_write/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_with_only_write/manifest.json index 4fb466243a..2b6c320fc7 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_with_only_write/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_with_only_write/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open directory", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile opening a directory.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_with_write/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_with_write/manifest.json index f634f5e41b..4fd90fe8ef 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_with_write/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_with_write/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open existing directory", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseEntry opening existing directory.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_without_permission/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_without_permission/manifest.json index b8758b57b3..f947da8666 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_without_permission/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_directory_without_permission/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open directory", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile opening a directory.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_existing/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_existing/manifest.json index 13d737636e..4a26271579 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_existing/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_existing/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open existing file", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile opening existing file.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_existing_with_write/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_existing_with_write/manifest.json index e483ac1ff5..61bc563f11 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_existing_with_write/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_existing_with_write/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open existing file with write", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile opening existing file.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_existing/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_existing/manifest.json index 89aaa98083..8dd34acd53 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_existing/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_existing/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open existing files", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile opening multiple existing files.", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_with_suggested_name/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_with_suggested_name/manifest.json index 89aaa98083..8dd34acd53 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_with_suggested_name/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_with_suggested_name/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open existing files", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile opening multiple existing files.", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_writable_existing_with_write/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_writable_existing_with_write/manifest.json index 3ae9cd98e2..8c0df11513 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_writable_existing_with_write/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_multiple_writable_existing_with_write/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open writable files with write", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile opening multiple writable files.", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_writable_existing/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_writable_existing/manifest.json index 90eeeae654..839f24a905 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_writable_existing/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_writable_existing/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open writable file", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile opening writable file.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_writable_existing_with_write/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_writable_existing_with_write/manifest.json index 2e880d869c..68ea8298a2 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_writable_existing_with_write/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/open_writable_existing_with_write/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem open writable file with write", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile opening writable file.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_background/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_background/manifest.json index 6f3c6b5a5c..a5c36f300e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_background/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_background/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.requestFileSystem background page test", + "manifest_version": 2, "version": "0.1", "description": "Test for requesting file systems via chrome.fileSystem.requestFileSystem.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_chromeos/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_chromeos/manifest.json index 19ff1bdbb5..6c76741741 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_chromeos/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_chromeos/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.requestFileSystem not on Chrome OS", + "manifest_version": 2, "version": "0.1", "description": "Test for requesting file systems via chrome.fileSystem.requestFileSystem when not running on Chrome OS", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_kiosk_session/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_kiosk_session/manifest.json index bda3ad99ff..efeac1c1d8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_kiosk_session/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_kiosk_session/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.requestFileSystem not in kiosk session test", + "manifest_version": 2, "version": "0.1", "description": "Test for requesting file systems via chrome.fileSystem.requestFileSystem when not running in a kiosk session.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_whitelisted_component/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_whitelisted_component/manifest.json index bf06562efa..a1fd0668ed 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_whitelisted_component/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_not_whitelisted_component/manifest.json @@ -1,5 +1,6 @@ { // chrome-extension://gghcjiikahhfcomeldkboleljjelaced + "manifest_version": 2, "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2sQqHgYxfQtvhcTnFVoDUHpC52VHlzKwLw9avxEylJ3uGNAHi0toR8OOe4ENd93KNhOEUdwLGxNMahw615kJySfR6PocCioNCCO/SDTmLURLK/S4hnuXeSHs62mGfalUFhfTg6Mw//y4yUyjKNSlji5bJyYvdXXZeMc2lGXbawazMrvWFr/5qt9XT6NXV7XinSD9KZd47dS72ONYmLzneyRpXdMMsXEVGq/v0NN47gdzUkC3bhCinp2RpJNjMeBaIe8NJ5ZGs6SIgv76GJqN48RBxIfSOORpmSLqbK8r7jBTgR8UuzD4zB/uFNjRwD/lctC8s0vnXG3YfGZpyEVm6wIDAQAB", "name": "chrome.fileSystem.requestFileSystem test for not whitelisted components", "version": "0.1", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_read_only/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_read_only/manifest.json index 26ed02f5eb..ee8f7a3815 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_read_only/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_read_only/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.requestFileSystem read only test", + "manifest_version": 2, "version": "0.1", "description": "Test for requesting read only file systems via chrome.fileSystem.requestFileSystem.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_user_reject/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_user_reject/manifest.json index e80b3a7303..88c527f6d2 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_user_reject/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_user_reject/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.requestFileSystem user consent rejection test", + "manifest_version": 2, "version": "0.1", "description": "Test for requesting a file system via chrome.fileSystem.requestFileSystem with a rejection user consent.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_whitelisted_component/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_whitelisted_component/manifest.json index 908c73ce31..c74ba52e23 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_whitelisted_component/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_whitelisted_component/manifest.json @@ -1,5 +1,6 @@ { // chrome-extension://pkplfbidichfdicaijlchgnapepdginl + "manifest_version": 2, "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtDfX9dHNh948bt00YhZBm3P6E5QLaOt+v8kXVtibQfiPtOD2FTScB/f0wX/EQWVO7BkaSOsRkTPcPIgocyMPYr2FLgqGLFlYT9nQpKJZUFNF5oJ5rG6Nv7ppf4zEB3j6da1IBRTz2yOZ+6O1TMZxol/V62/QcqrJeggsHTEPGLdr9Ua4b1Ka0xKJnJngZljsbw93FI1o+P9dAh5BS6wTPiZI/vmJVjvMTkSTnaZ3n9Go2t7A0XLcSxLcVyuLAd2mAvSN0mIviOukdM66wr7llif71nKuUt+4qvlr/r9HfwzN6pA4jkwhtS1UD+3CmB+wsHwsnohNcuu4FIQ6rgq/7QIDAQAB", "name": "chrome.fileSystem.requestFileSystem test for whitelisted components", "version": "0.1", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_writable/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_writable/manifest.json index e6ab0a089f..8310ab97dd 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_writable/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/request_file_system_writable/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.requestFileSystem writable test", + "manifest_version": 2, "version": "0.1", "description": "Test for requesting writable file systems via chrome.fileSystem.requestFileSystem.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/restore_directory/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/restore_directory/manifest.json index afa32cdeea..7b7fd29486 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/restore_directory/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/restore_directory/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.restoreEntry test", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.restoreEntry", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/restore_entry/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/restore_entry/manifest.json index dedc50f4cc..3270e8b04e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/restore_entry/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/restore_entry/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.restoreEntry test", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.restoreEntry", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/retain_directory/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/retain_directory/manifest.json index c424ddb8be..41464f0fe4 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/retain_directory/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/retain_directory/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.retainEntry test", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.retainEntry", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/retain_entry/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/retain_entry/manifest.json index 77f237db6e..3f60c1a998 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/retain_entry/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/retain_entry/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem.retainEntry test", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.retainEntry", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_background/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_background/manifest.json index e0d8f0741e..357a7f46bf 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_background/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_background/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem save from background.", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile save from background.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_cancel/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_cancel/manifest.json index b80bf1bc11..3c2159a494 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_cancel/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_cancel/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem save cancel.", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile saving cancelled.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_existing/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_existing/manifest.json index 8615a71969..dca79aaf3c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_existing/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_existing/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem save existing file", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile saving existing file.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_existing_with_write/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_existing_with_write/manifest.json index cf0712bd7f..b04893c889 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_existing_with_write/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_existing_with_write/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem save existing file with write", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile saving existing file.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_multiple/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_multiple/manifest.json index ed9ba6b899..d207eba609 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_multiple/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_multiple/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem save multiple files", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile saving multiple files.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_new/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_new/manifest.json index 1334a9b044..769f42e563 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_new/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_new/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem save new file", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile saving new file.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_new_with_write/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_new_with_write/manifest.json index 1d671c071b..a8041f32ca 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_new_with_write/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/file_system/save_new_with_write/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.fileSystem save new file with write", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.fileSystem.chooseFile saving new file.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/image_writer_private/list_devices/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/image_writer_private/list_devices/manifest.json index bb7d82959e..1a59eeefc5 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/image_writer_private/list_devices/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/image_writer_private/list_devices/manifest.json @@ -1,5 +1,6 @@ { "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6aedfP5QXnA176+/EKXFwbBoXl3smca9uaO1ytfLCRsH8Ja0xrjJG+/2tvcCL1JzBbc8/31cwWIOiNFawJiIc+nfZAi4rO27yakn4W83kHOhjr7hA4/a+CtmOPTTgpK1DCIpo0Xy+lpzQuqHBKL9/sXMCN4bKqcXMe7XA09VJYD6Rv+CTDfKkgN3oNYhm0KBOwkvJ/P7x7KeBUCusd+UOzJygBP4p2mDgIX/WfUZAuRGq1ty/Eu9dBm29Jhe1YBctFaARyR5FnMsr57Kw/mWrNXkZ2iewrLUzNh1FWLQUbiL4QdqaP9//Xxhsrf+LG1UcJN1HBnn/b0xYLfcH9W7RQIDAQAB", + "manifest_version": 2, "name": "Image Writer Private", "version": "0.1", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/image_writer_private/write_from_file/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/image_writer_private/write_from_file/manifest.json index f95644ab28..8e3b4cb4e7 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/image_writer_private/write_from_file/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/image_writer_private/write_from_file/manifest.json @@ -1,5 +1,6 @@ { "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6aedfP5QXnA176+/EKXFwbBoXl3smca9uaO1ytfLCRsH8Ja0xrjJG+/2tvcCL1JzBbc8/31cwWIOiNFawJiIc+nfZAi4rO27yakn4W83kHOhjr7hA4/a+CtmOPTTgpK1DCIpo0Xy+lpzQuqHBKL9/sXMCN4bKqcXMe7XA09VJYD6Rv+CTDfKkgN3oNYhm0KBOwkvJ/P7x7KeBUCusd+UOzJygBP4p2mDgIX/WfUZAuRGq1ty/Eu9dBm29Jhe1YBctFaARyR5FnMsr57Kw/mWrNXkZ2iewrLUzNh1FWLQUbiL4QdqaP9//Xxhsrf+LG1UcJN1HBnn/b0xYLfcH9W7RQIDAQAB", + "manifest_version": 2, "name": "Image Writer Private", "version": "0.1", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/new_event_in_new_version/v1/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/new_event_in_new_version/v1/manifest.json index b9295e9f92..1afe89637d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/new_event_in_new_version/v1/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/new_event_in_new_version/v1/manifest.json @@ -1,5 +1,6 @@ { "version": "1", + "manifest_version": 2, "name": "Lazy events test: tabs.onCreated added in version 2", "background": {"scripts": ["background.js"]} } diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/new_event_in_new_version/v2/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/new_event_in_new_version/v2/manifest.json index 4fab435845..a9f12152b1 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/new_event_in_new_version/v2/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/new_event_in_new_version/v2/manifest.json @@ -1,5 +1,6 @@ { "version": "2", + "manifest_version": 2, "name": "Lazy events test: tabs.onCreated added in version 2", "background": {"scripts": ["background.js"]} } diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed/v1/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed/v1/manifest.json index 7772d073e2..fce102f2e6 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed/v1/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed/v1/manifest.json @@ -1,5 +1,6 @@ { "version": "1", + "manifest_version": 2, "name": "Lazy events test: runtime.onInstalled", "background": {"scripts": ["background.js"]} } diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed/v2/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed/v2/manifest.json index 61eaebf8bb..79419e0b02 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed/v2/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed/v2/manifest.json @@ -1,5 +1,6 @@ { "version": "2", + "manifest_version": 2, "name": "Lazy events test: runtime.onInstalled", "background": {"scripts": ["background.js"]} } diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed_permissions_increase/v1/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed_permissions_increase/v1/manifest.json index a833cfc01c..8cb4c0b69f 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed_permissions_increase/v1/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed_permissions_increase/v1/manifest.json @@ -1,5 +1,6 @@ { "version": "1", + "manifest_version": 2, "name": "Lazy events test: runtime.onInstalled with permissions increase", "background": {"scripts": ["background.js"]} } diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed_permissions_increase/v2/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed_permissions_increase/v2/manifest.json index 65e4ab3b2a..fbe76739cf 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed_permissions_increase/v2/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/lazy_events/on_installed_permissions_increase/v2/manifest.json @@ -1,5 +1,6 @@ { "version": "2", + "manifest_version": 2, "name": "Lazy events test: runtime.onInstalled with permissions increase", "background": {"scripts": ["background.js"]}, "permissions": [""] diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/management/packaged_app/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/management/packaged_app/manifest.json index 6898e1c521..b0fc877e63 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/management/packaged_app/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/management/packaged_app/manifest.json @@ -1,5 +1,6 @@ { "name": "packaged_app", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/access_attached/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/access_attached/manifest.json index 0387951777..1247c98f20 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/access_attached/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/access_attached/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.mediaGalleries.access_attached", + "manifest_version": 2, "version": "0.1", "description": "test access of attached storage for chrome.mediaGalleries.getMediaFileSystems", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/copy_to_access/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/copy_to_access/manifest.json index 9e311d6377..84339fffcd 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/copy_to_access/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/copy_to_access/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.mediaGalleries.copyTo_access", + "manifest_version": 2, "version": "0.1", "description": "test copyTo access for chrome.mediaGalleries.getMediaFileSystems", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/delete_access/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/delete_access/manifest.json index dbd2b62991..209416995f 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/delete_access/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/delete_access/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.mediaGalleries.delete_access", + "manifest_version": 2, "version": "0.1", "description": "test delete access for chrome.mediaGalleries.getMediaFileSystems", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/gallerywatch/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/gallerywatch/manifest.json index d2f9bae677..88660d9116 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/gallerywatch/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/gallerywatch/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.mediaGalleries.gallery_watch", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.mediaGalleries.addGalleryWatch, chrome.mediaGalleries.removeGalleryWatch, chrome.mediaGalleries.getAllGalleryWatch, and chrome.mediaGalleries.removeAllGalleryWatch functions, and onGalleryChanged events.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/media_metadata/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/media_metadata/manifest.json index 7ec75ecae8..279147ba99 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/media_metadata/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/media_metadata/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.mediaGalleries.media_metadata", + "manifest_version": 2, "version": "0.1", "description": "test chrome.mediaGalleries.getMetadata", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_access/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_access/manifest.json index 04660e14ef..5c96f4a928 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_access/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_access/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.mediaGalleries.no_access", + "manifest_version": 2, "version": "0.1", "description": "test having no access for chrome.mediaGalleries.getMediaFileSystems fails appropriately", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_galleries/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_galleries/manifest.json index 3903b7b79d..2703442013 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_galleries/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_galleries/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.mediaGalleries.no_galleries", + "manifest_version": 2, "version": "0.1", "description": "Test that without the allGalleries permission, no galleries are present.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_galleries_copy_to/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_galleries_copy_to/manifest.json index 2c982f2afe..819e22905c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_galleries_copy_to/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/no_galleries_copy_to/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.mediaGalleries.no_galleries_copy_to", + "manifest_version": 2, "version": "0.1", "description": "Test that without the allGalleries permission, no galleries are present with only other permissions.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/read_access/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/read_access/manifest.json index dc091f00bd..2dd1cfef38 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/read_access/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/read_access/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.mediaGalleries.read_access", + "manifest_version": 2, "version": "0.1", "description": "test read access for chrome.mediaGalleries.getMediaFileSystems", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/tourl/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/tourl/manifest.json index ee63b202c6..b140549ce2 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/tourl/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/media_galleries/tourl/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.mediaGalleries.tourl", + "manifest_version": 2, "version": "0.1", "description": "test url access for chrome.mediaGalleries", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/connect/page.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/connect/page.js index eef9fc6dda..f349a3553b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/connect/page.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/connect/page.js @@ -2,21 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -JSON.parse = function() { - return "JSON.parse clobbered by content script."; -}; +function clobberJSON() { + JSON.parse = function() { + return "JSON.parse clobbered by content script."; + }; -JSON.stringify = function() { - return "JSON.stringify clobbered by content script."; -}; + JSON.stringify = function() { + return "JSON.stringify clobbered by content script."; + }; -Array.prototype.toJSON = function() { - return "Array.prototype.toJSON clobbered by content script."; -}; + Array.prototype.toJSON = function() { + return "Array.prototype.toJSON clobbered by content script."; + }; -Object.prototype.toJSON = function() { - return "Object.prototype.toJSON clobbered by content script."; -}; + Object.prototype.toJSON = function() { + return "Object.prototype.toJSON clobbered by content script."; + }; +} + +chrome.test.getConfig((config) => { + // We don't clobber JSON with native bindings. See https://crbug.com/792602. + if (!config.nativeCrxBindingsEnabled) + clobberJSON(); +}); // For complex connect tests. chrome.runtime.onConnect.addListener(function onConnect(port) { @@ -99,10 +107,13 @@ function testConnectChildFrameAndNavigateSetup() { // Test will continue in frame.js } +// Use a potentially-valid extension id. +var fakeExtensionId = 'c'.repeat(32); + // Tests sendMessage to an invalid extension. function testSendMessageFromTabError() { // try sending a request to a bad extension id - chrome.runtime.sendMessage("bad-extension-id", {m: 1}, function(response) { + chrome.runtime.sendMessage(fakeExtensionId, {m: 1}, function(response) { var success = (response === undefined && chrome.runtime.lastError); chrome.runtime.sendMessage({success: success}); }); @@ -110,7 +121,7 @@ function testSendMessageFromTabError() { // Tests connecting to an invalid extension. function testConnectFromTabError() { - var port = chrome.runtime.connect("bad-extension-id"); + var port = chrome.runtime.connect(fakeExtensionId); port.onDisconnect.addListener(function() { var success = (chrome.runtime.lastError ? true : false); chrome.runtime.sendMessage({success: success}); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/connect/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/connect/test.js index 604beef872..48d5be4c6d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/connect/test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/connect/test.js @@ -5,21 +5,23 @@ var listenOnce = chrome.test.listenOnce; var listenForever = chrome.test.listenForever; -JSON.parse = function() { - return "JSON.parse clobbered by extension."; -}; +function clobberJSON() { + JSON.parse = function() { + return "JSON.parse clobbered by extension."; + }; -JSON.stringify = function() { - return "JSON.stringify clobbered by extension."; -}; + JSON.stringify = function() { + return "JSON.stringify clobbered by extension."; + }; -Array.prototype.toJSON = function() { - return "Array.prototype.toJSON clobbered by extension."; -}; + Array.prototype.toJSON = function() { + return "Array.prototype.toJSON clobbered by extension."; + }; -Object.prototype.toJSON = function() { - return "Object.prototype.toJSON clobbered by extension."; -}; + Object.prototype.toJSON = function() { + return "Object.prototype.toJSON clobbered by extension."; + }; +} // Keep track of the tab that we're running tests in, for simplicity. var testTab = null; @@ -43,6 +45,10 @@ function compareSenders(expected, actual) { } chrome.test.getConfig(function(config) { + // We don't clobber JSON with native bindings. See https://crbug.com/792602. + if (!config.nativeCrxBindingsEnabled) + clobberJSON(); + chrome.test.runTests([ function setupTestTab() { chrome.test.log("Creating tab..."); @@ -76,6 +82,7 @@ chrome.test.getConfig(function(config) { function portName() { var portName = "lemonjello"; var port = chrome.tabs.connect(testTab.id, {name: portName}); + chrome.test.assertEq(portName, port.name); port.postMessage({testPortName: true}); listenOnce(port.onMessage, function(msg) { chrome.test.assertEq(msg.portName, portName); @@ -267,16 +274,20 @@ chrome.test.getConfig(function(config) { // Tests that a message which fails to serialize prints an error and // doesn't send (http://crbug.com/263077). function unserializableMessage() { + // Unserializable messages throw an error with native bindings, and only + // log a warning with JS bindings. + var expectThrow = config.nativeCrxBindingsEnabled; try { chrome.tabs.connect(testTab.id).postMessage(function() { // This shouldn't ever be called, so it's a bit pointless. chrome.test.fail(); }); // Didn't crash. - chrome.test.succeed(); + chrome.test.assertFalse(expectThrow); } catch (e) { - chrome.test.fail(e.stack); + chrome.test.assertTrue(expectThrow); } + chrome.test.succeed(); }, // Tests that reloading a child frame disconnects the port if it was the diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/large_messages/background.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/large_messages/background.js index 8fb59567b5..b8ae4f130d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/large_messages/background.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/messaging/large_messages/background.js @@ -8,7 +8,7 @@ try { chrome.runtime.sendMessage('a'.repeat(tooLarge)); chrome.test.notifyFail(); } catch (e) { - chrome.test.assertEq("Message length exceeded maximum allowed length.", - e.message); + let expected = /Message length exceeded maximum allowed length/; + chrome.test.assertTrue(expected.test(e.message), e.message); chrome.test.notifyPass(); } diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/mime_handler_view/index.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/mime_handler_view/index.js index b3187d2ade..747554a3f4 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/mime_handler_view/index.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/mime_handler_view/index.js @@ -20,13 +20,17 @@ var streamDetails; function fetchUrl(url) { return new Promise(function(resolve, reject) { var request = new XMLHttpRequest(); - request.onreadystatechange = function() { - if (request.readyState == 4) { - resolve({ - status: request.status, - data: request.responseText, - }); - } + request.onload = function() { + resolve({ + status: request.status, + data: request.responseText, + }); + }; + request.onerror = function() { + resolve({ + status: request.status, + data: 'error', + }); }; request.open('GET', streamDetails.streamUrl, true); request.send(); @@ -88,8 +92,8 @@ var tests = [ checkStreamDetails('testAbort.csv', false); chrome.mimeHandlerPrivate.abortStream(function() { fetchUrl(streamDetails.streamUrl).then(function(response) { - chrome.test.assertEq(404, response.status); - chrome.test.assertEq('', response.data); + chrome.test.assertEq(0, response.status); + chrome.test.assertEq('error', response.data); chrome.test.succeed(); }); }); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/native_bindings/instance_of/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/native_bindings/instance_of/manifest.json index ddbcec2d41..14e941c3c6 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/native_bindings/instance_of/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/native_bindings/instance_of/manifest.json @@ -1,5 +1,6 @@ { "name": "instanceof test", + "manifest_version": 2, "version": "1", "description": "instanceof test", "permissions": ["fileSystem"], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/native_bindings/platform_app/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/native_bindings/platform_app/manifest.json index a1e637cec1..6801bb38eb 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/native_bindings/platform_app/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/native_bindings/platform_app/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: minimal platform app", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/networking_private/alias/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/networking_private/alias/test.js index b631362a74..2989c1e647 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/networking_private/alias/test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/networking_private/alias/test.js @@ -44,7 +44,12 @@ chrome.test.runTests([ ModelID:"test_model_id", NetworkTechnology: 'GSM', RoamingState: 'Home', - SIMLockStatus: {LockEnabled: true, LockType: '', RetriesLeft: 3} + SIMLockStatus: { + LockEnabled: true, + LockType: '', + RetriesLeft: 3, + }, + Scanning: false, }, ConnectionState: 'NotConnected', GUID: 'stub_cellular1_guid', diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js index 10d093e3b1..c5e0ac4807 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/networking_private/chromeos/test.js @@ -180,7 +180,7 @@ var availableTests = [ chrome.networkingPrivate.createNetwork( false, // shared { Type: NetworkType.WI_FI, - GUID: 'ignored_guid', + GUID: 'some_guid', WiFi: { SSID: 'wifi_created', Security: 'WEP-PSK' @@ -188,7 +188,7 @@ var availableTests = [ }, callbackPass(function(guid) { assertFalse(guid == ''); - assertFalse(guid == 'ignored_guid'); + assertEq('some_guid', guid); chrome.networkingPrivate.getProperties( guid, callbackPass(function(properties) { assertEq(NetworkType.WI_FI, properties.Type); @@ -592,7 +592,8 @@ var availableTests = [ ModelID:"test_model_id", NetworkTechnology: 'GSM', RoamingState: 'Home', - SIMLockStatus: {LockEnabled: true, LockType: '', RetriesLeft: 3} + SIMLockStatus: {LockEnabled: true, LockType: '', RetriesLeft: 3}, + Scanning: false, }, ConnectionState: ConnectionStateType.NOT_CONNECTED, GUID: kCellularGuid, @@ -624,6 +625,7 @@ var availableTests = [ MIN: "test_min", ModelID:"test_model_id", SIMLockStatus: {LockEnabled: true, LockType: '', RetriesLeft: 3}, + Scanning: false, SignalStrength: 0, }, Connectable: false, diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/basic_usage/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/basic_usage/manifest.json index ffed6e8f02..e3e59b1737 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/basic_usage/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/basic_usage/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.notifications", + "manifest_version": 2, "version": "0.1", "description": "chrome.notifications API events", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/by_user/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/by_user/manifest.json index 7c450017d9..193049895c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/by_user/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/by_user/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.notifications", + "manifest_version": 2, "version": "0.1", "description": "chrome.notifications API byUser", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/csp/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/csp/manifest.json index 2d6d41e63f..d72d099d58 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/csp/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/csp/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.notifications", + "manifest_version": 2, "version": "0.1", "description": "chrome.notifications API CSP", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/events/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/events/manifest.json index ffed6e8f02..e3e59b1737 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/events/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/events/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.notifications", + "manifest_version": 2, "version": "0.1", "description": "chrome.notifications API events", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/partial_update/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/partial_update/manifest.json index ffed6e8f02..e3e59b1737 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/partial_update/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/partial_update/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.notifications", + "manifest_version": 2, "version": "0.1", "description": "chrome.notifications API events", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/permission/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/permission/manifest.json index 47067bbda4..07489cf37b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/permission/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/permission/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.notifications", + "manifest_version": 2, "version": "0.1", "description": "chrome.notifications API permissionLevelChanged", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/require_interaction/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/require_interaction/manifest.json index ff80edc7f4..3572f0c6fd 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/require_interaction/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/require_interaction/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.notifications", + "manifest_version": 2, "version": "0.1", "description": "chrome.notifications API requireInteraction", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/unload/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/unload/manifest.json index ffed6e8f02..e3e59b1737 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/unload/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/unload/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.notifications", + "manifest_version": 2, "version": "0.1", "description": "chrome.notifications API events", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/user_gesture/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/user_gesture/manifest.json index 47067bbda4..07489cf37b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/user_gesture/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/notifications/api/user_gesture/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.notifications", + "manifest_version": 2, "version": "0.1", "description": "chrome.notifications API permissionLevelChanged", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/passwords_private/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/passwords_private/test.js index f94312ae52..22900269ce 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/passwords_private/test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/passwords_private/test.js @@ -118,9 +118,32 @@ var availableTests = [ }, function exportPasswords() { - chrome.passwordsPrivate.exportPasswords(); + let callback = function() { + chrome.test.assertNoLastError(); + + // Ensure that the callback is invoked. + chrome.test.succeed(); + }; + + chrome.passwordsPrivate.exportPasswords(callback); + }, + + function cancelExportPasswords() { + chrome.passwordsPrivate.cancelExportPasswords(); chrome.test.succeed(); }, + + function requestExportProgressStatus() { + let callback = function(status) { + chrome.test.assertEq( + chrome.passwordsPrivate.ExportProgressStatus.IN_PROGRESS, status); + + // Ensure that the callback is invoked. + chrome.test.succeed(); + }; + + chrome.passwordsPrivate.requestExportProgressStatus(callback); + }, ]; var testToRun = window.location.search.substring(1); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/permissions/optional_retain_gesture/background.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/permissions/optional_retain_gesture/background.js index e521552424..e523d0bd87 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/permissions/optional_retain_gesture/background.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/permissions/optional_retain_gesture/background.js @@ -6,11 +6,6 @@ var fail = chrome.test.callbackFail; var GESTURE_ERROR = "This function must be called during a user gesture"; -function busyLoop(milliseconds) { - var startTime = new Date().getTime(); - while (new Date().getTime() - startTime < milliseconds) {} -} - chrome.test.getConfig(function(config) { chrome.test.runTests([ function testPermissionsRetainGesture() { @@ -39,41 +34,6 @@ chrome.test.getConfig(function(config) { } ); }); - }, - - function testPermissionsRetainGestureExpire() { - chrome.test.runWithUserGesture(function() { - chrome.permissions.request( - {permissions: ['bookmarks']}, - function(granted) { - chrome.test.assertTrue(granted); - - var request = function() { - // The following request will fail if the user gesture is - // expired. - chrome.permissions.request( - {permissions: ['bookmarks']}, - function(granted1) { - if (chrome.runtime.lastError) { - chrome.test.assertFalse(!!granted1); - chrome.test.assertEq(chrome.runtime.lastError.message, - GESTURE_ERROR); - chrome.test.succeed(); - } else { - console.log("Retrying permissions.request in 3 " + - "seconds"); - busyLoop(3000); - request(); - } - }); - }; - - // Wait 2s since the user gesture timeout is 1s. - busyLoop(2000); - request(); - } - ); - }); } ]); }); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/runtime/get_package_directory/app/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/runtime/get_package_directory/app/manifest.json index cb16c1050f..ba46cd8d5c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/runtime/get_package_directory/app/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/runtime/get_package_directory/app/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.runtime get package directory entry", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.runtime.getPackageDirectoryEntry.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/runtime/on_restart_required/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/runtime/on_restart_required/manifest.json index 1d52e8f62d..390be5e9a9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/runtime/on_restart_required/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/runtime/on_restart_required/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.runtime.onRestartRequired test app", + "manifest_version": 2, "version": "0.1", "description": "Test for chrome.runtime.onRestartRequired.", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/api/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/api/manifest.json index 207c900807..e774f6d74e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/api/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/api/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.serial", + "manifest_version": 2, "version": "0.1", "description": "end-to-end browser test for chrome.serial API", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/real_hardware/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/real_hardware/manifest.json index a38b718641..00b264e00f 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/real_hardware/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/real_hardware/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.serial real hardware", + "manifest_version": 2, "version": "0.1", "description": "end-to-end real-hardware test for chrome.serial API", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/real_hardware_fail/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/real_hardware_fail/manifest.json index 384550cd90..8702c5f2c5 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/real_hardware_fail/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/serial/real_hardware_fail/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.serial.getDevices failure test", + "manifest_version": 2, "version": "0.1", "description": "end-to-end test getDevices returns empty list for failure", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/background.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/background.js new file mode 100644 index 0000000000..5e22d01d85 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/background.js @@ -0,0 +1,34 @@ +// Copyright 2018 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. + +var seenPathsByServiceWorker = []; + +// Called by mime_handler.js at the end of the test: +chrome.runtime.onMessage.addListener(function(msg) { + chrome.test.assertEq('finish test by checking SW URLs', msg); + chrome.test.assertEq([ + '/page_with_embed.html', + // "/well-known-mime.ics" is loaded by page_with_embed.html, but it should + // not have dispatched the "fetch" event in the Service Worker because it is + // a plugin resource. + '/mime_handler.html', + '/mime_handler.js', + ], seenPathsByServiceWorker, 'expected extension URLs'); + chrome.test.notifyPass(); +}); + +navigator.serviceWorker.addEventListener('message', function(event) { + seenPathsByServiceWorker.push(event.data.replace(location.origin, '')); + event.ports[0].postMessage('ACK'); +}); + +navigator.serviceWorker.register('sw.js').then(function() { + return navigator.serviceWorker.ready; +}).then(function() { + chrome.tabs.create({ + url: chrome.extension.getURL('page_with_embed.html'), + }); +}).catch(function(e) { + chrome.test.fail('Unexpected error: ' + e); +}); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/manifest.json new file mode 100644 index 0000000000..240176f11d --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/manifest.json @@ -0,0 +1,13 @@ +{ + "name": "Test MIMEHandlerView + Service Worker", + "version": "1", + "manifest_version": 2, + "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJ8Hl8K6R+n/hrPsN1ienxRU3GbL00wFHLJNML45MHwT+3PstgWf4EgC3wbyyTXFtbvJC+Hn14Hyltfhsa+cSraldNHeL+rl+FL04kE4uYHq8YhOYEtzUfg380+o7XV9oESKu9oLTeG9QuQCjmlp3MUqC9wm7ICjxR9flODClOkQIDAQAB", + "background": { + "scripts": ["background.js"] + }, + "mime_types": [ + "text/calendar" + ], + "mime_types_handler": "mime_handler.html" +} diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/mime_handler.html b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/mime_handler.html new file mode 100644 index 0000000000..0e35fcab71 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/mime_handler.html @@ -0,0 +1,6 @@ + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/mime_handler.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/mime_handler.js new file mode 100644 index 0000000000..e6d4b4a84f --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/mime_handler.js @@ -0,0 +1,16 @@ +// Copyright 2018 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. + +chrome.mimeHandlerPrivate.getStreamInfo(function(streamInfo) { + chrome.test.assertEq( + chrome.extension.getURL('well-known-mime.ics'), streamInfo.originalUrl); + var x = new XMLHttpRequest(); + x.open('GET', streamInfo.streamUrl); + x.onloadend = function() { + chrome.test.assertEq( + 'This is a well-known MIME (text/calendar).\n', x.responseText); + chrome.runtime.sendMessage('finish test by checking SW URLs'); + }; + x.send(); +}); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/page_with_embed.html b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/page_with_embed.html new file mode 100644 index 0000000000..4db3cd3609 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/page_with_embed.html @@ -0,0 +1,10 @@ + +The "ics" extension is hard-coded as "text/calendar" by net::MimeUtil. +So, regardless of the platform's MIME type for the "ics" file extension, +the resource will always be served as "text/calendar" and therefore be handled +by the test extension. + diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/sw.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/sw.js new file mode 100644 index 0000000000..adc3b61f07 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/sw.js @@ -0,0 +1,16 @@ +// Copyright 2018 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. + +self.addEventListener('fetch', function(event) { + event.waitUntil( + chrome.runtime.getBackgroundClient().then(function(client) { + // Ensure that the "seenUrls" list in the background page is updated + // before the response is served. + return new Promise(function(resolve) { + var chan = new MessageChannel(); + chan.port1.onmessage = resolve; + client.postMessage(event.request.url, [chan.port2]); + }); + })); +}); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/well-known-mime.ics b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/well-known-mime.ics new file mode 100644 index 0000000000..0952ba62cf --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/service_worker/mime_handler_view/well-known-mime.ics @@ -0,0 +1 @@ +This is a well-known MIME (text/calendar). diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/socket/api/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/socket/api/manifest.json index 38570644c5..1267b27bf9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/socket/api/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/socket/api/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.socket", + "manifest_version": 2, "version": "0.1", "description": "end-to-end browser test for chrome.socket API", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/socket/unload/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/socket/unload/manifest.json index 1a647f2c3f..ec6b683872 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/socket/unload/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/socket/unload/manifest.json @@ -1,5 +1,6 @@ { "name": "chrome.socket", + "manifest_version": 2, "version": "0.1", "description": "browser test for chrome.socket API to make sure sockets are free'd when extension is reloaded", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/streams_private/handle_mime_type/background.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/streams_private/handle_mime_type/background.js index 347a150069..5c2b77385e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/streams_private/handle_mime_type/background.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/streams_private/handle_mime_type/background.js @@ -75,14 +75,15 @@ chrome.streamsPrivate.onExecuteMimeTypeHandler.addListener( chrome.streamsPrivate.abort(params.streamUrl, function() { var xhr = new XMLHttpRequest(); xhr.open("GET", params.streamUrl, false); - xhr.send(null); - if (xhr.status == 404) { + try { + xhr.send(null); + } catch (e) { chrome.test.notifyPass(); - } else { - chrome.test.notifyFail( - 'Expected a stream URL response of 404, got ' + xhr.status + '.'); - hasFailed = true; + return; } + chrome.test.notifyFail( + 'Expected a network error, got ' + xhr.status + '.'); + hasFailed = true; }); } return; diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/system/get_update_status/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/system/get_update_status/manifest.json index 8d750eecc8..9be37a8bdc 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/system/get_update_status/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/system/get_update_status/manifest.json @@ -1,5 +1,6 @@ { "key": "MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDFFBqmJf6+xgNeQhSwunB7Vdi+peXwR6uf09DKBmStju73Cjhggl3x+i7jfeRvGguJA1nnxK45dHktx5ppyy2w16nFKFcfIAN9dP6RrfPWuHVxw1AzNCRm/VutRLje1e9Kk3xtXAw9Vj3N0/txZ3u8HOr62YUDIyFcS87+Yo/a9QIBIw==", + "manifest_version": 2, "name": "chrome.systemPrivate.getUpdateStatus", "version": "0.1", "description": "browser test for chrome.systemPriavte.getUpdateStatus API", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tab_capture/offscreen_end_to_end.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tab_capture/offscreen_end_to_end.js index e073d0704e..8361fd868f 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tab_capture/offscreen_end_to_end.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tab_capture/offscreen_end_to_end.js @@ -37,7 +37,9 @@ function waitForExpectedColorsAndEndTest(stream) { // Elements from this array are removed as each color is observed. When it // becomes empty, the test succeeds. var remainingColors = [[255, 0, 0], [0, 255, 0], [0, 0, 255]]; - var colorDeviation = 10; + // TODO(crbug/758057): Determine why color accuracy went down in this test + // with the new VIZ-based tab capturer. + var colorDeviation = 50; function onMatchedNextColor(idx) { chrome.test.assertTrue(idx < remainingColors.length); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/basics/crud2.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/basics/crud2.js index 09fa0cb579..d0f37879cf 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/basics/crud2.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/basics/crud2.js @@ -2,6 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +var newTabUrls = [ + 'chrome://newtab/', + // The tab URL will be redirected to the Local New Tab Page if + // features::kUseGoogleLocalNtp is not enabled. + 'chrome-search://local-ntp/local-ntp.html', +]; + var secondWindowId; var thirdWindowId; var testTabId; @@ -39,7 +46,7 @@ chrome.test.runTests([ assertEq((i == 0), tabs[i].active && tabs[i].selected); } assertEq("about:blank", tabs[0].url); - assertEq("chrome://newtab/", tabs[1].url); + assertTrue(newTabUrls.includes(tabs[1].url)); assertEq(pageUrl("a"), tabs[2].url); })); @@ -50,7 +57,7 @@ chrome.test.runTests([ assertEq(thirdWindowId, tabs[i].windowId); assertEq(i, tabs[i].index); } - assertEq("chrome://newtab/", tabs[0].url); + assertTrue(newTabUrls.includes(tabs[0].url)); assertEq(pageUrl("b"), tabs[1].url); })); }, diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/basics/move.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/basics/move.js index aefe4265ff..e64c15f213 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/basics/move.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/basics/move.js @@ -7,6 +7,13 @@ var secondWindowId; var moveTabIds = {}; var kChromeUINewTabURL = "chrome://newtab/"; +var newTabUrls = [ + kChromeUINewTabURL, + // The tab URL will be redirected to the Local New Tab Page if + // features::kUseGoogleLocalNtp is not enabled. + 'chrome-search://local-ntp/local-ntp.html', +]; + chrome.test.runTests([ // Do a series of moves and removes so that we get the following // @@ -32,7 +39,8 @@ chrome.test.runTests([ })); chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) { assertEq(pages.length, tabs.length); - for (var i in tabs) { + assertTrue(newTabUrls.includes(tabs[0].url)); + for (var i = 1; i < tabs.length; i++) { assertEq(pages[i], tabs[i].url); } })); @@ -44,7 +52,7 @@ chrome.test.runTests([ function checkMoveResults() { chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) { assertEq(4, tabs.length); - assertEq(kChromeUINewTabURL, tabs[0].url); + assertTrue(newTabUrls.includes(tabs[0].url)); assertEq(pageUrl("a"), tabs[1].url); assertEq(pageUrl("e"), tabs[2].url); assertEq(pageUrl("c"), tabs[3].url); @@ -52,7 +60,7 @@ chrome.test.runTests([ chrome.tabs.getAllInWindow(secondWindowId, pass(function(tabs) { assertEq(3, tabs.length); assertEq(pageUrl("b"), tabs[0].url); - assertEq(kChromeUINewTabURL, tabs[1].url); + assertTrue(newTabUrls.includes(tabs[1].url)); assertEq(pageUrl("d"), tabs[2].url); })); })); @@ -78,14 +86,14 @@ chrome.test.runTests([ function checkMoveResults() { chrome.tabs.getAllInWindow(firstWindowId, pass(function(tabs) { assertEq(3, tabs.length); - assertEq(kChromeUINewTabURL, tabs[0].url); + assertTrue(newTabUrls.includes(tabs[0].url)); assertEq(pageUrl("a"), tabs[1].url); assertEq(pageUrl("c"), tabs[2].url); chrome.tabs.getAllInWindow(secondWindowId, pass(function(tabs) { assertEq(4, tabs.length); assertEq(pageUrl("b"), tabs[0].url); - assertEq(kChromeUINewTabURL, tabs[1].url); + assertTrue(newTabUrls.includes(tabs[1].url)); assertEq(pageUrl("d"), tabs[2].url); assertEq(pageUrl("e"), tabs[3].url); })); @@ -106,7 +114,7 @@ chrome.test.runTests([ pass(function(tabs) { assertEq(3, tabs.length); assertEq(pageUrl("b"), tabs[0].url); - assertEq(kChromeUINewTabURL, tabs[1].url); + assertTrue(newTabUrls.includes(tabs[1].url)); assertEq(pageUrl("e"), tabs[2].url); })); })); @@ -135,7 +143,7 @@ chrome.test.runTests([ assertEq(3, tabs.length); assertEq(pageUrl("b"), tabs[0].url); assertEq(pageUrl("a"), tabs[1].url); - assertEq(kChromeUINewTabURL, tabs[2].url); + assertTrue(newTabUrls.includes(tabs[2].url)); })); })); }, diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/capture_visible_tab_null_window/background.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/capture_visible_tab_null_window/background.js new file mode 100644 index 0000000000..ccaee20100 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/capture_visible_tab_null_window/background.js @@ -0,0 +1,17 @@ +// Copyright 2018 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. + +// API test for chrome.tabs.captureVisibleTab(), when current window is null +// browser_tests.exe --gtest_filter=ExtensionApiTest.CaptureNullWindow + +var fail = chrome.test.callbackFail; + +chrome.test.runTests([function captureNullWindow() { + // Create a new window so we don't close the only active window. + chrome.windows.create(function(newWindow) { + chrome.windows.remove(newWindow.id); + chrome.tabs.captureVisibleTab( + newWindow.id, fail('Failed to capture tab: view is invisible')); + }); +}]); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/capture_visible_tab_null_window/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/capture_visible_tab_null_window/manifest.json new file mode 100644 index 0000000000..d7aef991d9 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/capture_visible_tab_null_window/manifest.json @@ -0,0 +1,10 @@ +{ + "name": "chrome.tabs.captureVisibleTab test: nullWindow", + "version": "0.1", + "manifest_version": 2, + "description": "end-to-end browser test for chrome.tabs.captureVisibleTab", + "permissions": [ "tabs", "" ], + "background": { + "scripts": [ "background.js" ] + } +} diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/on_updated/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/on_updated/test.js index 7fcd443f89..039905899e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/on_updated/test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tabs/on_updated/test.js @@ -47,19 +47,15 @@ chrome.test.runTests([ chrome.tabs.create({ url: getURL('browserThenRendererInitiated/a.html') }); }, - function newTab() { + function chromeUrls() { // Test for crbug.com/27208. - // - // Note the two title settings. That is expected and due to the unusual way - // the NTP code ensures a set title. expect([ - { status: 'loading', url: 'chrome://newtab/' }, - { title : "New Tab" }, - { title : "New Tab" }, + { status: 'loading', url: 'chrome://chrome-urls/' }, + { title : "Chrome URLs" }, { status: 'complete' } ]); - chrome.tabs.create({ url: 'chrome://newtab/' }); + chrome.tabs.create({ url: 'chrome://chrome-urls/' }); }, /* diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tts_engine/update_voices_api/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tts_engine/update_voices_api/manifest.json new file mode 100644 index 0000000000..1a02e8dfc9 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tts_engine/update_voices_api/manifest.json @@ -0,0 +1,20 @@ +{ + "name": "chrome.ttsEngine", + "version": "0.1", + "manifest_version": 2, + "description": "browser test for chrome.ttsEngine.updateVoices API", + "background": { + "scripts": ["test.js"] + }, + "tts_engine": { + "voices": [ + { + "voice_name": "Zach", + "lang": "en-US", + "event_types": [ "end", "error" ] + } + ] + }, + "permissions": ["tts", "ttsEngine"], + "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtDfX9dHNh948bt00YhZBm3P6E5QLaOt+v8kXVtibQfiPtOD2FTScB/f0wX/EQWVO7BkaSOsRkTPcPIgocyMPYr2FLgqGLFlYT9nQpKJZUFNF5oJ5rG6Nv7ppf4zEB3j6da1IBRTz2yOZ+6O1TMZxol/V62/QcqrJeggsHTEPGLdr9Ua4b1Ka0xKJnJngZljsbw93FI1o+P9dAh5BS6wTPiZI/vmJVjvMTkSTnaZ3n9Go2t7A0XLcSxLcVyuLAd2mAvSN0mIviOukdM66wr7llif71nKuUt+4qvlr/r9HfwzN6pA4jkwhtS1UD+3CmB+wsHwsnohNcuu4FIQ6rgq/7QIDAQAB" +} diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tts_engine/update_voices_api/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tts_engine/update_voices_api/test.js new file mode 100644 index 0000000000..ff697d9322 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/tts_engine/update_voices_api/test.js @@ -0,0 +1,85 @@ +// Copyright 2018 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. + +var testVoiceData = [ + { + eventTypes: ['start'], + extensionId: 'pkplfbidichfdicaijlchgnapepdginl', + gender: 'male', + lang: 'zh-TW', + remote: false, + voiceName: 'David' + }, + { + eventTypes: ['end', 'interrupted', 'cancelled'], + extensionId: 'pkplfbidichfdicaijlchgnapepdginl', + gender: 'female', + lang: 'en-GB', + remote: false, + voiceName: 'Laura' + } +]; + +function setup() { + var speakListener = function(utterance, options, sendTtsEvent) {}; + var stopListener = function() {}; + chrome.ttsEngine.onSpeak.addListener(speakListener); + chrome.ttsEngine.onStop.addListener(stopListener); +} + +chrome.test.runTests([ + function testGetVoices() { + setup(); + chrome.tts.getVoices(function(voices) { + chrome.test.assertEq(1, voices.length); + chrome.test.assertEq({ + eventTypes: [ 'end', 'interrupted', 'cancelled', 'error'], + extensionId: 'pkplfbidichfdicaijlchgnapepdginl', + lang: 'en-US', + remote: false, + voiceName: 'Zach' + }, voices[0]); + chrome.ttsEngine.updateVoices(testVoiceData); + chrome.tts.getVoices(function(runtimeVoices) { + chrome.test.assertEq(testVoiceData.length, runtimeVoices.length); + for (var i = 0; i < runtimeVoices.length; i++) { + chrome.test.assertEq(testVoiceData[i], runtimeVoices[i]); + chrome.test.assertEq(runtimeVoices[i], testVoiceData[i]); + } + chrome.test.assertNoLastError(); + chrome.test.succeed(); + }); + }); + }, + function testExtensionIdMismatch() { + setup(); + chrome.ttsEngine.updateVoices([{ + eventTypes: [ 'end', 'interrupted', 'cancelled', 'error'], + extensionId: 'interloper', + lang: 'en-US', + remote: false, + voiceName: 'Zach' + }]); + + chrome.tts.getVoices(function(voices) { + chrome.test.assertEq(0, voices.length); + chrome.test.succeed(); + }); + }, + function testInvalidLang() { + setup(); + chrome.ttsEngine.updateVoices([{ + eventTypes: [ 'end', 'interrupted', 'cancelled', 'error'], + extensionId: 'pkplfbidichfdicaijlchgnapepdginl', + lang: 'bad lang syntax', + remote: false, + voiceName: 'Zach' + }]); + + chrome.tts.getVoices(function(voices) { + chrome.test.assertEq(0, voices.length); + chrome.test.succeed(); + }); + } +]); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/usb_manual/list_interfaces/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/usb_manual/list_interfaces/manifest.json index 092357da2b..bf68876d7e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/usb_manual/list_interfaces/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/usb_manual/list_interfaces/manifest.json @@ -1,5 +1,6 @@ { "name": "USB Manual List Interface", + "manifest_version": 2, "version": "0.1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/framework.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/framework.js index ec2a03f435..eb4b3cb311 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/framework.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/framework.js @@ -8,6 +8,7 @@ var expectedEventData; var capturedEventData; var capturedUnexpectedData; var expectedEventOrder; +var networkServiceState = "unknown"; var tabId; var tabIdMap; var frameIdMap; @@ -58,14 +59,22 @@ function runTestsForTab(tests, tab) { // Creates an "about:blank" tab and runs |tests| with this tab as default. function runTests(tests) { - var waitForAboutBlank = function(_, info, tab) { - if (info.status == "complete" && tab.url == "about:blank") { - chrome.tabs.onUpdated.removeListener(waitForAboutBlank); - runTestsForTab(tests, tab); - } - }; - chrome.tabs.onUpdated.addListener(waitForAboutBlank); - chrome.tabs.create({url: "about:blank"}); + chrome.test.getConfig(function(config) { + var waitForAboutBlank = function(_, info, tab) { + if (info.status == "complete" && tab.url == "about:blank") { + chrome.tabs.onUpdated.removeListener(waitForAboutBlank); + runTestsForTab(tests, tab); + } + }; + + if (config.customArg === "NetworkServiceEnabled") + networkServiceState = "enabled"; + else if (config.customArg === "NetworkServiceDisabled") + networkServiceState = "disabled"; + + chrome.tabs.onUpdated.addListener(waitForAboutBlank); + chrome.tabs.create({url: "about:blank"}); + }); } // Returns an URL from the test server, fixing up the port. Must be called @@ -140,6 +149,24 @@ function expect(data, order, filter, extraInfoSpec) { capturedEventData = []; capturedUnexpectedData = []; expectedEventOrder = order || []; + + expectedEventData = expectedEventData.filter(function(event) { + if (!event.details.requiredNetworkServiceState) + return true; + + if (networkServiceState == "unknown") { + chrome.test.fail("Test expectations specify a Network Service " + + "requirement, but the Network Service was neither explicitly set " + + "as enabled or disabled by the test runner. This test should be " + + "run with the custom argument NetworkServiceEnabled or " + + "NetworkServiceDisabled."); + } + + var requiredState = event.details.requiredNetworkServiceState; + delete event.details.requiredNetworkServiceState; + return networkServiceState === requiredState; + }); + if (expectedEventData.length > 0) { eventsCaptured = chrome.test.callbackAdded(); } diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/test_devtools.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/test_devtools.js index acbd44270b..d7c9795f25 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/test_devtools.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/test_devtools.js @@ -221,6 +221,38 @@ function expectMockedTabNavigationEvents(url) { initiator: getServerDomain(initiators.BROWSER_INITIATED) } }, + { + label: 'onBeforeSendHeaders-1', + event: 'onBeforeSendHeaders', + details: { + type: 'main_frame', + url, + initiator: getServerDomain(initiators.BROWSER_INITIATED), + requiredNetworkServiceState: "enabled" + } + }, + { + label: 'onSendHeaders-1', + event: 'onSendHeaders', + details: { + type: 'main_frame', + url, + initiator: getServerDomain(initiators.BROWSER_INITIATED), + requiredNetworkServiceState: "enabled" + } + }, + { + label: 'onHeadersReceived-1', + event: 'onHeadersReceived', + details: { + type: 'main_frame', + url, + statusCode: 200, + statusLine: 'HTTP/1.0 200 OK', + initiator: getServerDomain(initiators.BROWSER_INITIATED), + requiredNetworkServiceState: "enabled" + } + }, { label: 'onResponseStarted-1', event: 'onResponseStarted', @@ -257,6 +289,38 @@ function expectMockedTabNavigationEvents(url) { initiator: frontendOrigin } }, + { + label: 'onBeforeSendHeaders-2', + event: 'onBeforeSendHeaders', + details: { + type: 'script', + url: scriptUrl, + initiator: frontendOrigin, + requiredNetworkServiceState: "enabled" + } + }, + { + label: 'onSendHeaders-2', + event: 'onSendHeaders', + details: { + type: 'script', + url: scriptUrl, + initiator: frontendOrigin, + requiredNetworkServiceState: "enabled" + } + }, + { + label: 'onHeadersReceived-2', + event: 'onHeadersReceived', + details: { + type: 'script', + url: scriptUrl, + statusCode: 200, + statusLine: 'HTTP/1.0 200 OK', + initiator: frontendOrigin, + requiredNetworkServiceState: "enabled" + } + }, { label: 'onResponseStarted-2', event: 'onResponseStarted', diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/test_types.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/test_types.js index bbbf877be2..5790a278f8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/test_types.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webrequest/test_types.js @@ -152,6 +152,7 @@ runTests([ // tabId 0 = tab opened by test runner; // tabId 1 = this tab. tabId: 1, + initiator: "null", } }, { label: 'onBeforeSendHeaders', @@ -162,6 +163,7 @@ runTests([ frameId: 1, parentFrameId: 0, tabId: 1, + initiator: "null", }, }, { label: 'onSendHeaders', @@ -172,6 +174,7 @@ runTests([ frameId: 1, parentFrameId: 0, tabId: 1, + initiator: "null", }, }, { label: 'onHeadersReceived', @@ -184,6 +187,7 @@ runTests([ tabId: 1, statusLine: 'HTTP/1.1 200 OK', statusCode: 200, + initiator: "null", }, }, { label: 'onResponseStarted', @@ -198,6 +202,7 @@ runTests([ fromCache: false, statusLine: 'HTTP/1.1 200 OK', statusCode: 200, + initiator: "null", }, }, { label: 'onCompleted', @@ -212,6 +217,7 @@ runTests([ fromCache: false, statusLine: 'HTTP/1.1 200 OK', statusCode: 200, + initiator: "null", }, }], [['onBeforeRequest', 'onBeforeSendHeaders', 'onSendHeaders', diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/app/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/app/manifest.json index b343e16846..83e4d50a59 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/app/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/app/manifest.json @@ -1,5 +1,6 @@ { "name": "Test App", + "manifest_version": 2, "version": "0.5", "app": { "urls": [ "http://www.testapp.com" ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/extension/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/extension/manifest.json index d1aeebe2cf..d746cc576b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/extension/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/extension/manifest.json @@ -1,5 +1,6 @@ { "name": "WebstorePrivate API Test extension", + "manifest_version": 2, "version": "0.1", "icons": { "128": "icon.png" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/incorrect_manifest1.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/incorrect_manifest1.js index 9d485b49d6..310af9093a 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/incorrect_manifest1.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/incorrect_manifest1.js @@ -18,7 +18,6 @@ chrome.webstorePrivate.beginInstallWithManifest3( assertNoLastError(); assertEq("", result); - var expectedError = "Manifest file is invalid."; chrome.webstorePrivate.completeInstall(extensionId, callbackPass()); }); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/incorrect_manifest2.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/incorrect_manifest2.js index 7ded8183ef..88d03941b2 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/incorrect_manifest2.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/incorrect_manifest2.js @@ -17,7 +17,7 @@ chrome.webstorePrivate.beginInstallWithManifest3( assertNoLastError(); assertEq("", result); - var expectedError = "Manifest file is invalid."; + var expectedError = "Manifest file is invalid"; chrome.webstorePrivate.completeInstall(extensionId, callbackFail(expectedError)); }); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/localized_extension/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/localized_extension/manifest.json index 4bb197f19f..e3e197fc45 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/localized_extension/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/webstore_private/localized_extension/manifest.json @@ -1,5 +1,6 @@ { "name":"__MSG_title__", + "manifest_version": 2, "version": "0.1", "default_locale": "en" } diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/windows/events/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/windows/events/test.js index a10aaf72a3..e8e9841fd9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/windows/events/test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/api_test/windows/events/test.js @@ -73,8 +73,11 @@ chrome.test.sendMessage('ready', function (message) { chrome.test.assertTrue(win.focus == true, 'Missing focus event for ' + win.type); } - chrome.test.assertEq(3, unfilteredCount); - chrome.test.assertTrue(includes_app && includes_devtools, + chrome.test.assertEq(2, unfilteredCount); + chrome.test.assertFalse( + includes_app, + 'Should not include windows for a separate platform app.'); + chrome.test.assertTrue(includes_devtools, 'Could not find app or devtools windows'); chrome.test.notifyPass(); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/app_update/v1/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/app_update/v1/manifest.json index 6436f27b78..0bded6109a 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/app_update/v1/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/app_update/v1/manifest.json @@ -1,5 +1,6 @@ { "name": "Test App", + "manifest_version": 2, "version": "1", "app": { "urls": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/app_update/v2/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/app_update/v2/manifest.json index d2228dd245..6806ec817b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/app_update/v2/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/app_update/v2/manifest.json @@ -1,5 +1,6 @@ { "name": "Test App", + "manifest_version": 2, "version": "2", "app": { "urls": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v1/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v1/manifest.json index d54b083237..8ea5d35b16 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v1/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v1/manifest.json @@ -1,5 +1,6 @@ { "description": "Extension for Auto-Update testing", + "manifest_version": 2, "name": "Auto-Update Test", "version": "1.0", "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v2/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v2/manifest.json index 776825e16c..b86c8561d4 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v2/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v2/manifest.json @@ -1,5 +1,6 @@ { "description": "Extension for Auto-Update testing", + "manifest_version": 2, "name": "Auto-Update Test", "version": "2.0", "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v3/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v3/manifest.json index 6c747b06e1..1cf78d557b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v3/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/autoupdate/v3/manifest.json @@ -1,5 +1,6 @@ { "description": "Extension for Auto-Update testing", + "manifest_version": 2, "name": "Auto-Update Test", "version": "3.0", "update_url": "http://localhost/autoupdate/manifest" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/bad/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/bad/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/manifest.json index 8706e1f3d6..fd3b773a27 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/bad/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/bad/Extensions/bjafgdebaacbbbecmhlhpofkepfkgcpa/1.0/manifest.json @@ -1,5 +1,6 @@ { "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDRS2GUBOUAO5VZ2CMRId/eRR8/e9V42nUvY5XG+0sZ+JDHEjIQdq8qQy7HqdqEpCXKPMSPuMiC2t2HE9/hpL89SblNn3mwYPtSJGQdZvAzuv6SB0oA6jZ66V7+h/k0noGD3Tcu+Ko/vfkt5wCx2uHVK29k5JR/vGr0klaoVezGlwIDAQAB", + "manifest_version": 2, "version": "1.0", "name": "My extension 3", "content_scripts": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/bad/bad_encoding/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/bad/bad_encoding/manifest.json index 8caaec2ad9..b8f1a0ba17 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/bad/bad_encoding/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/bad/bad_encoding/manifest.json @@ -1,5 +1,6 @@ { "name": "nevermind", + "manifest_version": 2, "version": "1", "content_scripts": [ { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/browsertest/browser_action_popup/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/browsertest/browser_action_popup/manifest.json index 974217bb09..53ada7af29 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/browsertest/browser_action_popup/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/browsertest/browser_action_popup/manifest.json @@ -1,5 +1,6 @@ { "name": "PageAction Test", + "manifest_version": 2, "version": "1.0", "browser_action": { "default_icon": "icon.png", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/browsertest/page_action_popup/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/browsertest/page_action_popup/manifest.json index e1d3f9061c..da0beb8e64 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/browsertest/page_action_popup/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/browsertest/page_action_popup/manifest.json @@ -1,5 +1,6 @@ { "name": "PageAction Test", + "manifest_version": 2, "version": "1.0", "page_action": { "default_icon": "icon.png", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/declarative_net_request/page_with_four_frames.html b/lgpl/sources/chromium/src/chrome/test/data/extensions/declarative_net_request/page_with_four_frames.html new file mode 100644 index 0000000000..4238fe17b5 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/declarative_net_request/page_with_four_frames.html @@ -0,0 +1,46 @@ + + + + + + + + + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/fullscreen_app/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/fullscreen_app/manifest.json index 1fe58c337c..2952abca85 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/fullscreen_app/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/fullscreen_app/manifest.json @@ -1,5 +1,6 @@ { "name": "App that attempts to open a fullscreen window", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/https_app_no_www/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/https_app_no_www/manifest.json new file mode 100644 index 0000000000..3d42c5c6eb --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/https_app_no_www/manifest.json @@ -0,0 +1,10 @@ +{ + "name": "App Test", + "version": "1", + "manifest_version": 2, + "app": { + "launch": { + "web_url": "https://example.com/" + } + } +} diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_older_version/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_older_version/manifest.json index 286ad52c4a..1370ada7e9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_older_version/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_older_version/manifest.json @@ -1,5 +1,6 @@ { "name": "Extension v0.9", + "manifest_version": 2, "version": "0.9", "background": { "page": "bg.html" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_same_version/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_same_version/manifest.json index 016fac0864..f894162950 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_same_version/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_same_version/manifest.json @@ -1,5 +1,6 @@ { "name": "Extension v1 again", + "manifest_version": 2, "version": "1.0", "background": { "page": "bg.html" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_v2/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_v2/manifest.json index 2d589cb0c2..8bbe432018 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_v2/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/install/install_v2/manifest.json @@ -1,5 +1,6 @@ { "name": "Extension v2", + "manifest_version": 2, "version": "2.0", "background": { "page": "bg.html" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/kiosk/kiosk_only/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/kiosk/kiosk_only/manifest.json index 79796b018e..f09bf54a12 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/kiosk/kiosk_only/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/kiosk/kiosk_only/manifest.json @@ -1,5 +1,6 @@ { "name": "Kiosk Only Test", + "manifest_version": 2, "description": "Test for 'kiosk_only' manifest attribute", "version": "1", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/cdakfjkehipfnofphlponafnbnglaafl/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/cdakfjkehipfnofphlponafnbnglaafl/1.0/manifest.json index 50e3833b0e..def309ced8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/cdakfjkehipfnofphlponafnbnglaafl/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/cdakfjkehipfnofphlponafnbnglaafl/1.0/manifest.json @@ -1,5 +1,6 @@ { "default_locale": "sr", + "manifest_version": 2, "description": "__MSG_description__", "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLhmwQdiLz55o8IA8RW9n39Ry9IOmvjCysN6zLiP3yZtPx9pA+0cL/P/8YUtE33F5uq9iKZq2ZhqVHT1qKPQyff865862qFq56TfKC3GePL77TKaipUXOWBWzzkRHXc0bmY1zOfEe7leG06Ch+kaqJ5FYbWZZSuCaGpQ/AOercjQIDAQAB", "name": "__MSG_name__", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/jhkccedbcahooljabgejipmdkcojbijg/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/jhkccedbcahooljabgejipmdkcojbijg/1.0/manifest.json index 82462f7a01..719c5580a9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/jhkccedbcahooljabgejipmdkcojbijg/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/jhkccedbcahooljabgejipmdkcojbijg/1.0/manifest.json @@ -1,5 +1,6 @@ { "default_locale": "sr", + "manifest_version": 2, "description": "__MSG_description__", "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHWgEsMgJlIp7Jl4ZxuCsdxusR131dG382PWvzF85t13YSUElkFdbbIWp5jFWzfiubvKeqb7HrHQ1btLu531bmZpRWJjNSwlum2cNVX9D2SFgKA/rs74EyUQFF+ZXvgQUyAtIrEgR95oW7RlA8KlzHSlXIOFaMtF3OybtZEvvYqQIDAQAB", "name": "__MSG_name__", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/lgpnlbnlajcjdkakbbnfcgkdfggonpic/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/lgpnlbnlajcjdkakbbnfcgkdfggonpic/1.0/manifest.json index b774243257..8ca3d6c7f4 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/lgpnlbnlajcjdkakbbnfcgkdfggonpic/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/l10n/lgpnlbnlajcjdkakbbnfcgkdfggonpic/1.0/manifest.json @@ -1,5 +1,6 @@ { "description": "This extension is not localized.", + "manifest_version": 2, "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLHCpwAVTPqZQMcK/Oe1X643ASGGbJ1n5whpszRvPF+NJBvFcfbgPzXIRt1zsnLi12YgYwe10NbM0pEKp/M5+hp2DDUL44J8mcwZr3u4B95UZvtdk8b6LSDB8R5iA94yIkNxIjjdBgbMJHJ3Db5jCVWTPIznyL5C2/ajUHT4IW9wIDAQAB", "name": "no l10n", "version": "1.0" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/packaged_app/component_oauth2/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/packaged_app/component_oauth2/manifest.json index 9ba99d06cc..35fc44304e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/packaged_app/component_oauth2/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/packaged_app/component_oauth2/manifest.json @@ -1,5 +1,6 @@ { // chrome-extension://mdbihdcgjmagbcapkhhkjbbdlkflmbfo + "manifest_version": 2, "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCV9PlZjcTIXfnlB3HXo50OlM/CnIq0y7jmKfPVyStaWsmFB7NaVnqUXoGb9swBDfVnZ6BrupwnxL76TWEJPo+KQMJ6uz0PPdJWi2jQfZiGiheDiKH5Gv+dVd67qf7ly8QWW0o8qmFpqBZQpksm1hOGbfsupv9W4c42tMEIicDMLQIDAQAB", "name": "Packaged Component App Test: OAuth2 component app", "version": "2", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_icon/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_icon/manifest.json index 09c242dbe8..15e56b38e6 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_icon/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_icon/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: app icon test", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_icon/test.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_icon/test.js index bebd82e090..8c3de2fec7 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_icon/test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_icon/test.js @@ -8,18 +8,20 @@ var shelfWindow; function processNextCommand() { chrome.test.sendMessage('ready', function(response) { - if (response == 'Exit') { + if (response == 'exit') { return; } if (response == 'createPanelWindow') { chrome.app.window.create('main.html', { type: 'panel' }, function (win) { panelWindow = win; + // To avoid race condition get next command only after the window is + // actually created. + processNextCommand(); }); - } - if (response == 'setPanelWindowIcon') { + } else if (response == 'setPanelWindowIcon') { panelWindow.setIcon('icon64.png') - } - if (response == 'createNonShelfWindow') { + processNextCommand(); + } else if (response == 'createNonShelfWindow') { // Create the shell window; it should use the app icon, and not affect // the panel icon. chrome.app.window.create( @@ -27,23 +29,36 @@ function processNextCommand() { type: 'shell' }, function (win) { nonShelfWindow = win; + processNextCommand(); }); - } - if (response == 'createShelfWindow') { - // Create the shell window which is shown in shelf; it should use - // another custom app icon. + } else if (response == 'createShelfWindow') { + // Create the shell window which is shown in shelf; it should use the + // default custom app icon. chrome.app.window.create( 'main.html', { id: 'win_with_icon', type: 'shell', showInShelf: true }, function (win) { shelfWindow = win; + processNextCommand(); }); - } - if (response == 'setShelfWindowIcon') { + } else if (response == 'setShelfWindowIcon') { shelfWindow.setIcon('icon32.png') + processNextCommand(); + } else if (response == 'createShelfWindowWithCustomIcon') { + // Create the shell window which is shown in shelf; it should use + // another custom app icon. + chrome.app.window.create( + 'main.html', { id: 'win_with_custom_icon', + type: 'shell', + icon: 'icon32.png', + showInShelf: true }, + function (win) { + processNextCommand(); + }); + } else { + console.error('Unrecognized command: ' + response); } - processNextCommand(); }); }; diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/bad_app/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/bad_app/manifest.json index e107a2ec6b..df3450285c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/bad_app/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/bad_app/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform API Test: Bad Application", + "manifest_version": 2, "version": "1.0", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/guest_app/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/guest_app/manifest.json index 5b7dfa06c9..ef06d0a1fb 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/guest_app/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/guest_app/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform API Test: Guest Application", + "manifest_version": 2, "version": "1.0", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/host_app/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/host_app/manifest.json index b5e884d3a6..77fd32cd96 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/host_app/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/host_app/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform API Test: Host Application", + "manifest_version": 2, "version": "1.0", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/shim/main.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/shim/main.js index 595c69c890..d91f2400ce 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/shim/main.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/shim/main.js @@ -162,6 +162,34 @@ function testAppViewMultipleConnects(appToEmbed) { appview.connect(appToEmbed, { 'foo': 'bleep' }, callback); }; +function testAppViewConnectFollowingPreviousConnect(appToEmbed) { + var appview = new AppView(); + LOG('appToEmbed ' + appToEmbed); + document.body.appendChild(appview); + + var connections = 0; + + function doAppViewConnect() { + return new Promise(function(resolve, reject) { + appview.connect(appToEmbed, {'foo': 'bleep'}, function(success) { + if (success) { + ++connections; + LOG('CONNECTED. (' + connections + ' / 3)'); + resolve(); + } else { + LOG('FAILED TO CONNECT.'); + reject(); + } + }); + }); + }; + + doAppViewConnect() + .then(doAppViewConnect) + .then(doAppViewConnect) + .then(embedder.test.succeed, embedder.test.fail); +}; + function testAppViewEmbedSelfShouldFail(appToEmbed) { var appview = new AppView(); var currentapp_id = chrome.runtime.id; @@ -185,6 +213,8 @@ embedder.test.testList = { 'testAppViewRefusedDataShouldFail': testAppViewRefusedDataShouldFail, 'testAppViewGoodDataShouldSucceed': testAppViewGoodDataShouldSucceed, 'testAppViewMultipleConnects': testAppViewMultipleConnects, + 'testAppViewConnectFollowingPreviousConnect': + testAppViewConnectFollowingPreviousConnect, 'testAppViewEmbedSelfShouldFail': testAppViewEmbedSelfShouldFail }; diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/shim/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/shim/manifest.json index 5e0e32ca0e..7daf458f61 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/shim/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/app_view/shim/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: ", + "manifest_version": 2, "version": "2", "permissions": [ "appview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/background_page_navigation/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/background_page_navigation/manifest.json index 84ec22b2fa..0c5089f3bd 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/background_page_navigation/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/background_page_navigation/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: window.open() to local resource is disallowed", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/component/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/component/manifest.json index f84588fdce..7e94d16926 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/component/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/component/manifest.json @@ -1,5 +1,6 @@ { // Key from minimal_platform_app.pem. + "manifest_version": 2, // chrome-extension://jjeoclcdfjddkdjokiejckgcildcflpp "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+uU63MD6T82Ldq5wjrDFn5mGmPnnnjWZBWxYXfpG4kVf0s+p24VkXwTXsxeI12bRm8/ft9sOq0XiLfgQEh5JrVUZqvFlaZYoS+giZfUqzKFGMLa4uiSMDnvv+byxrqAepKz5G8XX/q5Wm5cvpdjwgiu9z9iM768xJy+Ca/G5qQwIDAQAB", "name": "Platform App Test: component platform app", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/context_menu/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/context_menu/manifest.json index 75696f9f2f..a6dffe95ab 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/context_menu/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/context_menu/manifest.json @@ -1,5 +1,6 @@ { "name" : "Platform App Context Menus Test Extension", + "manifest_version": 2, "version" : "0.1", "permissions": [ "contextMenus" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/context_menu_click/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/context_menu_click/manifest.json index 75696f9f2f..a6dffe95ab 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/context_menu_click/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/context_menu_click/manifest.json @@ -1,5 +1,6 @@ { "name" : "Platform App Context Menus Test Extension", + "manifest_version": 2, "version" : "0.1", "permissions": [ "contextMenus" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/disabled_window_properties/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/disabled_window_properties/manifest.json index 9dafd10f18..bdaa370e06 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/disabled_window_properties/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/disabled_window_properties/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: disabled window properties test", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/creation/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/creation/manifest.json index 0b44798e82..058baa5f89 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/creation/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/creation/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: ", + "manifest_version": 2, // gdloliindgbiccapnoiglhjmghmdaofi "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArNspoDDn0ez3ogchmKtGS7euFSoIDfZ/8yX2IDROLGbvUmosnP6dr2jhTjhTGXLF5rVgQRysRGDamiNznWV4Kz2CZWiSGbDG5/u2EBOtXLYSISIjCZAzuvi1/yUBBKGgURaiRJ3iWQfndRM+zuMEHrqUGriM2bbLv9/XvxoB+l76dCIAvob3y6EMmMiP8EB3qxpZKkPhhtXDLFKqt8LSfWc2YRTrXKEHcN/VY/GxlbVKYKXl4lsDXNPYQbUWo7mfgMlYaycFD2dRw2iRMZU9RS7B8Eo2FRDtXjEWCv1JKvbF8ShCw7j5Gkkg8PQ7nftymenoM1+gdeAbpUGCS1pi3QIDAQAB", "version": "1", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/extension_attribute/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/extension_attribute/manifest.json index d6d6f75ce8..915d2b4fd8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/extension_attribute/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/extension_attribute/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: extension", + "manifest_version": 2, // gdloliindgbiccapnoiglhjmghmdaofi "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArNspoDDn0ez3ogchmKtGS7euFSoIDfZ/8yX2IDROLGbvUmosnP6dr2jhTjhTGXLF5rVgQRysRGDamiNznWV4Kz2CZWiSGbDG5/u2EBOtXLYSISIjCZAzuvi1/yUBBKGgURaiRJ3iWQfndRM+zuMEHrqUGriM2bbLv9/XvxoB+l76dCIAvob3y6EMmMiP8EB3qxpZKkPhhtXDLFKqt8LSfWc2YRTrXKEHcN/VY/GxlbVKYKXl4lsDXNPYQbUWo7mfgMlYaycFD2dRw2iRMZU9RS7B8Eo2FRDtXjEWCv1JKvbF8ShCw7j5Gkkg8PQ7nftymenoM1+gdeAbpUGCS1pi3QIDAQAB", "version": "1", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/load_api/main.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/load_api/main.js index 140190b02f..33e5565ff9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/load_api/main.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/load_api/main.js @@ -114,9 +114,9 @@ function testLoadAPILoadOtherExtension(extensionIdOne, extensionIdTwo) { extensionScheme + extensionIdOne + '/' + srcOne); }) .then(function() { - checkExtensionAttribute(extensionview, extensionIdTwo); + checkExtensionAttribute(extensionview, extensionIdOne); checkSrcAttribute( - extensionview, extensionScheme + extensionIdTwo + '/' + srcOne); + extensionview, extensionScheme + extensionIdOne + '/' + srcOne); }) .then(embedder.test.succeed, embedder.test.fail); }; diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/load_api/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/load_api/manifest.json index 3bdb4a46eb..14f791cc68 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/load_api/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/load_api/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: load api call", + "manifest_version": 2, // gdloliindgbiccapnoiglhjmghmdaofi "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArNspoDDn0ez3ogchmKtGS7euFSoIDfZ/8yX2IDROLGbvUmosnP6dr2jhTjhTGXLF5rVgQRysRGDamiNznWV4Kz2CZWiSGbDG5/u2EBOtXLYSISIjCZAzuvi1/yUBBKGgURaiRJ3iWQfndRM+zuMEHrqUGriM2bbLv9/XvxoB+l76dCIAvob3y6EMmMiP8EB3qxpZKkPhhtXDLFKqt8LSfWc2YRTrXKEHcN/VY/GxlbVKYKXl4lsDXNPYQbUWo7mfgMlYaycFD2dRw2iRMZU9RS7B8Eo2FRDtXjEWCv1JKvbF8ShCw7j5Gkkg8PQ7nftymenoM1+gdeAbpUGCS1pi3QIDAQAB", "version": "1", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/src_attribute/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/src_attribute/manifest.json index 1c9da2ccae..1da99bcdc7 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/src_attribute/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/extension_view/src_attribute/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: src", + "manifest_version": 2, // gdloliindgbiccapnoiglhjmghmdaofi "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArNspoDDn0ez3ogchmKtGS7euFSoIDfZ/8yX2IDROLGbvUmosnP6dr2jhTjhTGXLF5rVgQRysRGDamiNznWV4Kz2CZWiSGbDG5/u2EBOtXLYSISIjCZAzuvi1/yUBBKGgURaiRJ3iWQfndRM+zuMEHrqUGriM2bbLv9/XvxoB+l76dCIAvob3y6EMmMiP8EB3qxpZKkPhhtXDLFKqt8LSfWc2YRTrXKEHcN/VY/GxlbVKYKXl4lsDXNPYQbUWo7mfgMlYaycFD2dRw2iRMZU9RS7B8Eo2FRDtXjEWCv1JKvbF8ShCw7j5Gkkg8PQ7nftymenoM1+gdeAbpUGCS1pi3QIDAQAB", "version": "1", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/get_display_path/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/get_display_path/manifest.json index 5c5e2d7884..c7097dc6cc 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/get_display_path/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/get_display_path/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App fileSystem.getDisplayPath test", + "manifest_version": 2, "version": "1", "file_handlers": { "text": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/iframes/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/iframes/manifest.json index 8e186a2640..7561458073 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/iframes/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/iframes/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: local iframes are allowed", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/isolation/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/isolation/manifest.json index 82d6128b00..3f9b00f15a 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/isolation/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/isolation/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: isolated storage", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch/manifest.json index 4e30588f1a..c6a69b47b9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: onLaunched event test", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_2/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_2/manifest.json index d464753c0b..7d211bc705 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_2/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_2/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: onLaunched event test2", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_application_octet_stream/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_application_octet_stream/manifest.json index fd412e49cc..119c78cb4c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_application_octet_stream/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_application_octet_stream/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "unknown": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file/manifest.json index e709a375ec..8c1b5f2bcc 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "text": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_by_extension/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_by_extension/manifest.json index 7d40d07dd1..ed168dfa4e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_by_extension/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_by_extension/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "text": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_by_extension_and_type/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_by_extension_and_type/manifest.json index 2963fc8d35..a0797eb77b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_by_extension_and_type/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_by_extension_and_type/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "text": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_with_any_extension/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_with_any_extension/manifest.json index 8c4479ddc4..0b6476c38e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_with_any_extension/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_with_any_extension/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "text": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_with_no_extension/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_with_no_extension/manifest.json index 5b466e4aec..6e86a7807c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_with_no_extension/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_file_with_no_extension/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "text": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_invalid/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_invalid/manifest.json index 9f6f051f00..a00adb316d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_invalid/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_invalid/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "text": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_new_file/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_new_file/manifest.json index 47e851801a..10b16cf58f 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_new_file/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_new_file/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "text": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_no_intent/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_no_intent/manifest.json index 77d6fc34cd..95e90f8463 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_no_intent/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_no_intent/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_nothing/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_nothing/manifest.json index 9f6f051f00..a00adb316d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_nothing/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_nothing/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "text": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_wrong_extension/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_wrong_extension/manifest.json index 6d566e53b6..e513a5a6bf 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_wrong_extension/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_wrong_extension/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "image": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_wrong_type/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_wrong_type/manifest.json index ee9c21d5f5..19716b251e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_wrong_type/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/launch_wrong_type/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "image": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/leave_fullscreen/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/leave_fullscreen/manifest.json index 5bf766f7a8..61faba6763 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/leave_fullscreen/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/leave_fullscreen/manifest.json @@ -1,5 +1,6 @@ { "name": "Test app for leaving fullscreen rules", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/load_and_launch_file/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/load_and_launch_file/manifest.json index e709a375ec..8c1b5f2bcc 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/load_and_launch_file/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/load_and_launch_file/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Launch Test", + "manifest_version": 2, "version": "1", "file_handlers": { "text": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/messaging/app1/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/messaging/app1/manifest.json index fc3a3a7bcf..f5adcc29a8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/messaging/app1/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/messaging/app1/manifest.json @@ -1,5 +1,6 @@ { "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChIkos4QMuz7xmtnVIPCRZmcKzLyyvChW508KvpVWhdJZjnMShxVqH5QwrEzwtRhK1bTX/Y+7kmKGb9z49O//4KY/gFZQyiRNDnqv85L7fz7ceobLozwQWkhTFafYS39VMs00G0FvgQvEM1gO/Kg3eWVTFRUJCHHrMkO1De2Xd+wIDAQAB", + "manifest_version": 2, "name": "Messaging Test App 1", "version": "0.5", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/messaging/app2/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/messaging/app2/manifest.json index e3d86d2f52..2c2df4bb90 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/messaging/app2/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/messaging/app2/manifest.json @@ -1,5 +1,6 @@ { "key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDbh1pj7Q+vZzotbfPfe1Q4AIeJc3gU1xhTSMtjB0UZH+G3ckScJYTnFCTkFAn/mEOtn7e+SZ9rhDf4k6X7Qf6BzK3PLNn3+2Hb/F0NC57hiWI2UyhXY2dl2ry6VENkuyo1QpEMGH5FB5tC2rcuivG8ipBbUWLoQLMbegUdOLXoNK4tGvKwlGa1B0QPAMIkEw3ZlerckC8e+tWC38WvHxy1EM5VeK8k4GcrDEltoVByprTe/8VTzvEsFFYljpIzbSTi6mKOhY2sdl0EfCpXT4dSCeSe81O8liMU1yYKBQCbzguASV7yzZMX08tb96MOpx0NYbYXt03Zyj3xlbep5n4l", + "manifest_version": 2, "name": "Messaging Test App 2", "version": "0.5", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/minimal/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/minimal/manifest.json index 3f5c332cd9..59fda50e90 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/minimal/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/minimal/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: minimal platform app", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/minimal_id/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/minimal_id/manifest.json index 2f5697812b..b86124ead4 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/minimal_id/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/minimal_id/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: minimal platform app with window ID 'minimal_id'", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/mutation_events/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/mutation_events/manifest.json index f4a2fa6c17..61116ed4e3 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/mutation_events/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/mutation_events/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: MutationEvents Disabled", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/navigation/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/navigation/manifest.json index 0a9a53451a..64d41724b9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/navigation/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/navigation/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: navigation is disallowed", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/oauth2/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/oauth2/manifest.json index 56164d4ade..f9845b9b33 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/oauth2/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/oauth2/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: OAuth2 platform app", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/open_link/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/open_link/manifest.json index 3f5c332cd9..59fda50e90 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/open_link/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/open_link/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: minimal platform app", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/optional_permission_request/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/optional_permission_request/manifest.json index 42f1d6bc5c..0b7281b7e0 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/optional_permission_request/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/optional_permission_request/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: optional permission request test", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/outer_bounds/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/outer_bounds/manifest.json index 86fc75688c..770762c14c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/outer_bounds/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/outer_bounds/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: outer bounds platform app", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen/manifest.json index a573389263..01cedeba42 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen/manifest.json @@ -1,5 +1,6 @@ { "name": "Test app for leaving fullscreen rules", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen_old/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen_old/manifest.json index 8cd9d23a82..8cfb7f3be8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen_old/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen_old/manifest.json @@ -1,5 +1,6 @@ { "name": "Test app for leaving fullscreen rules", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/print_api/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/print_api/manifest.json index 96cfd3e683..241adf2a6b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/print_api/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/print_api/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: window.print() API", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/reinstall_data_cleanup/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/reinstall_data_cleanup/manifest.json index b7e5c097f1..6f8a16355b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/reinstall_data_cleanup/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/reinstall_data_cleanup/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: reinstall data cleanup", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/reload/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/reload/manifest.json index 182af04403..8c3771c933 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/reload/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/reload/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: runtime.reload API", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restart_device/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restart_device/manifest.json index 4b964cf339..78d200abe3 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restart_device/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restart_device/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: runtime.restart API", + "manifest_version": 2, "version": "1", "kiosk_enabled": true, "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restore_state/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restore_state/manifest.json index 1d8f040b75..38142dee78 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restore_state/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restore_state/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: restore window state", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restrictions/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restrictions/manifest.json index dda6f5b922..3b95dfcb84 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restrictions/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/restrictions/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: various document, window, and API restrictions", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/speech/background_page/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/speech/background_page/manifest.json index 55144e3b22..11d64e3b6b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/speech/background_page/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/speech/background_page/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: Speech recognition", + "manifest_version": 2, "description": "webkitSpeechRecognition test from background page of an app.", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/speech/background_page_no_permission/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/speech/background_page_no_permission/manifest.json index f60627e519..1d3a36d038 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/speech/background_page_no_permission/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/speech/background_page_no_permission/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: Speech recognition", + "manifest_version": 2, "description": "webkitSpeechRecognition test from background page of an app, app doesn't have audioCapture permission.", "version": "1", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/storage/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/storage/manifest.json index 869f57edae..00d069746b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/storage/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/storage/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: localStorage/WebSQL are disallowed", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/navigate_webview_to_url/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/navigate_webview_to_url/manifest.json index 797fb8e68c..fab1a9cc03 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/navigate_webview_to_url/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/navigate_webview_to_url/manifest.json @@ -1,5 +1,6 @@ { "name": "Handler: navigate webview", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/simple/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/simple/manifest.json index 60c6ee840c..e5ce490833 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/simple/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/simple/manifest.json @@ -1,5 +1,6 @@ { "name": "Handler: simple", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/steal_xhr_target/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/steal_xhr_target/manifest.json index fa101c42a8..1217eea9c1 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/steal_xhr_target/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/handlers/steal_xhr_target/manifest.json @@ -1,5 +1,6 @@ { "name": "Handler: steal XHR targets", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/call_mismatching_window_open/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/call_mismatching_window_open/manifest.json index ecf82665b6..087d6372fc 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/call_mismatching_window_open/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/call_mismatching_window_open/manifest.json @@ -1,5 +1,6 @@ { "name": "Launcher: mismatching blank link", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/call_window_open/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/call_window_open/manifest.json index 52fcb8dce3..af4c927671 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/call_window_open/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/call_window_open/manifest.json @@ -1,5 +1,6 @@ { "name": "Launcher: window.open()", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/click_blank_link/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/click_blank_link/manifest.json index 764a60f409..0fc2045df1 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/click_blank_link/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/click_blank_link/manifest.json @@ -1,5 +1,6 @@ { "name": "Launcher: blank link", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/click_mismatching_blank_link/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/click_mismatching_blank_link/manifest.json index 764a60f409..0fc2045df1 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/click_mismatching_blank_link/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/url_handlers/launchers/click_mismatching_blank_link/manifest.json @@ -1,5 +1,6 @@ { "name": "Launcher: blank link", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/accept_touch_events/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/accept_touch_events/manifest.json index 79c79dffb6..457d5de9ab 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/accept_touch_events/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/accept_touch_events/manifest.json @@ -1,5 +1,6 @@ { "name": " touch handler registration test.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/addremove/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/addremove/manifest.json index c11815c1d4..cad6975782 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/addremove/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/addremove/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: src", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/app_creates_webview/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/app_creates_webview/manifest.json index e72e938c3b..a1fafe54f9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/app_creates_webview/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/app_creates_webview/manifest.json @@ -1,5 +1,6 @@ { "name": " test that allows WebView to be created after app has started.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/audio_state_api/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/audio_state_api/manifest.json index 602f34cc23..7c95dbadef 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/audio_state_api/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/audio_state_api/manifest.json @@ -1,5 +1,6 @@ { "name": " audio state api tests.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/autoplay/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/autoplay/manifest.json index 951d381164..4712785eb3 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/autoplay/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/autoplay/manifest.json @@ -1,5 +1,6 @@ { "name": " autoplay policy api tests.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/autosize/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/autosize/manifest.json index 8182fb25b4..4ba13440d9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/autosize/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/autosize/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: ", + "manifest_version": 2, "description": "Checks autosize on ", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/background/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/background/manifest.json index bd464a14fd..102e135304 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/background/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/background/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: background page access", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/clear_data_cache/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/clear_data_cache/manifest.json index 43553d2632..2df3c4d13e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/clear_data_cache/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/clear_data_cache/manifest.json @@ -1,5 +1,6 @@ { "name": "Packaged App Test: clearData API, clearing cache", + "manifest_version": 2, "description": "Verifies clearing http cache of .", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/close_on_loadcommit/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/close_on_loadcommit/manifest.json index 944fa0ee6d..9441ab3abd 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/close_on_loadcommit/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/close_on_loadcommit/manifest.json @@ -1,5 +1,6 @@ { "name": " close on loadcommit", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/common/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/common/manifest.json index 61ceb3fd61..17b8d77122 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/common/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/common/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: New Window", + "manifest_version": 2, "description": "Loads a an to run WebViewTest and WebViewInteractive tests.", "version": "1", /** diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/content_script_fetch/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/content_script_fetch/manifest.json index 4e2d233649..caa7db67f4 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/content_script_fetch/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/content_script_fetch/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: content script fetch", + "manifest_version": 2, "description": "Loads a guest which does a fetch from a content script", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/content_script_whitelisted/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/content_script_whitelisted/manifest.json index bd594682f4..5335d6a71f 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/content_script_whitelisted/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/content_script_whitelisted/manifest.json @@ -1,5 +1,6 @@ { "name": " with forced embedder content script.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/context_menus/basic/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/context_menus/basic/manifest.json index e5cc686b48..bc9bd2febd 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/context_menus/basic/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/context_menus/basic/manifest.json @@ -1,5 +1,6 @@ { "name": "Packaged App Test: contextMenus API", + "manifest_version": 2, "description": "Verifies basic functionality of contextMenus API.", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/context_menus/coordinates/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/context_menus/coordinates/manifest.json index 3a785881af..e63ef19b50 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/context_menus/coordinates/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/context_menus/coordinates/manifest.json @@ -1,5 +1,6 @@ { "name": "Packaged App Test: context menu param coordinates", + "manifest_version": 2, "description": "Helper app to verify context menu param's coordinates", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/cookie_isolation/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/cookie_isolation/manifest.json index c732097c87..dfb6b93786 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/cookie_isolation/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/cookie_isolation/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform API Test: Cookie Isolation Across Multiple webviews", + "manifest_version": 2, "version": "0.0.1", "permissions": ["webview"], "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dialog/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dialog/manifest.json index 6b7bf97970..c9e8b1d7d7 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dialog/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dialog/manifest.json @@ -1,5 +1,6 @@ { "name": "Packaged App Test: JavaScript Dialogs", + "manifest_version": 2, "description": "Verifies that the Dialog API works as expected.", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/display_none_set_src/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/display_none_set_src/manifest.json index 1413e28b1d..9e0c096455 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/display_none_set_src/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/display_none_set_src/manifest.json @@ -1,5 +1,6 @@ { "name": " check set src multiple times while display: none.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dnd_within_webview/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dnd_within_webview/manifest.json index 1bf2622b81..7632a2f2d8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dnd_within_webview/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dnd_within_webview/manifest.json @@ -1,5 +1,6 @@ { "name": " drag and drop", + "manifest_version": 2, "description": "Drag and drop within a webview, currently requires --enable-browser-tag-drag-drop flag to work", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/document_interactive/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/document_interactive/manifest.json index 3da412bbe6..fe94517703 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/document_interactive/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/document_interactive/manifest.json @@ -1,5 +1,6 @@ { "name": " property setting on document interactive", + "manifest_version": 2, "description": "Checks webview property setting when document.readyState changes to interactive", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/document_ready/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/document_ready/manifest.json index 0a0ce64d85..a6ddf7b2d6 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/document_ready/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/document_ready/manifest.json @@ -1,5 +1,6 @@ { "name": " partition attribute.", + "manifest_version": 2, "description": "Checks setting .property on webview on document.DOMContentLoaded", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dom_storage_isolation/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dom_storage_isolation/manifest.json index 59d3d10367..153ecc6a78 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dom_storage_isolation/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/dom_storage_isolation/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform API Test: DOM Storage Isolation", + "manifest_version": 2, "version": "1.0", "permissions": ["webview"], "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/download/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/download/manifest.json index d639fe397a..8163a93064 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/download/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/download/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: download permission API", + "manifest_version": 2, "description": "Loads a guest which initiates download", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/download_cookie_isolation/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/download_cookie_isolation/manifest.json index c732097c87..dfb6b93786 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/download_cookie_isolation/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/download_cookie_isolation/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform API Test: Cookie Isolation Across Multiple webviews", + "manifest_version": 2, "version": "0.0.1", "permissions": ["webview"], "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/edit_commands/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/edit_commands/manifest.json index c570d408dd..e43467118e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/edit_commands/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/edit_commands/manifest.json @@ -1,5 +1,6 @@ { "name": "Packaged App Test: Focus", + "manifest_version": 2, "description": "Loads a guest which monitors focus", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/edit_commands_no_menu/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/edit_commands_no_menu/manifest.json index c570d408dd..e43467118e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/edit_commands_no_menu/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/edit_commands_no_menu/manifest.json @@ -1,5 +1,6 @@ { "name": "Packaged App Test: Focus", + "manifest_version": 2, "description": "Loads a guest which monitors focus", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/main/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/main/manifest.json index 9f046ab388..3367d3aca9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/main/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/main/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: filesystem", + "manifest_version": 2, "description": "Loads a guest which requests filesystem", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/shared_worker/multiple/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/shared_worker/multiple/manifest.json index 9f046ab388..3367d3aca9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/shared_worker/multiple/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/shared_worker/multiple/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: filesystem", + "manifest_version": 2, "description": "Loads a guest which requests filesystem", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/shared_worker/single/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/shared_worker/single/manifest.json index 9f046ab388..3367d3aca9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/shared_worker/single/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/shared_worker/single/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: filesystem", + "manifest_version": 2, "description": "Loads a guest which requests filesystem", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/manifest.json index 9f046ab388..3367d3aca9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/filesystem/worker/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: filesystem", + "manifest_version": 2, "description": "Loads a guest which requests filesystem", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/findability_isolation/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/findability_isolation/manifest.json index be8b2546d6..e3060add32 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/findability_isolation/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/findability_isolation/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform API Test: Findability Isolation", + "manifest_version": 2, "version": "1.0", "permissions": ["webview"], "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus/manifest.json index c570d408dd..e43467118e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus/manifest.json @@ -1,5 +1,6 @@ { "name": "Packaged App Test: Focus", + "manifest_version": 2, "description": "Loads a guest which monitors focus", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_accessibility/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_accessibility/manifest.json index e47038020d..e5b2c4d012 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_accessibility/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_accessibility/manifest.json @@ -1,5 +1,6 @@ { "name": " focus accessibility test.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_sync/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_sync/manifest.json index 836e611172..d409ae7e6d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_sync/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_sync/manifest.json @@ -1,5 +1,6 @@ { "name": "Packaged App Test: Focus Sync", + "manifest_version": 2, "description": "Loads and focuses a guest which will focus one of its elements", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_visibility/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_visibility/manifest.json index 028478e77d..a6591965ab 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_visibility/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/focus_visibility/manifest.json @@ -1,5 +1,6 @@ { "name": "App Test: Hidden not Focusable", + "manifest_version": 2, "description": "Loads a guest which monitors tabs", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/fullscreen/embedder_has_no_permission/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/fullscreen/embedder_has_no_permission/manifest.json index c49263450c..6653f06f95 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/fullscreen/embedder_has_no_permission/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/fullscreen/embedder_has_no_permission/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: fullscreen", + "manifest_version": 2, "description": "Loads a guest which requests fullscreen, hosting embedder does not have fullscreen permission", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/fullscreen/embedder_has_permission/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/fullscreen/embedder_has_permission/manifest.json index cd3fb24bbb..07d08b3648 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/fullscreen/embedder_has_permission/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/fullscreen/embedder_has_permission/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: fullscreen", + "manifest_version": 2, "description": "Loads a guest which requests fullscreen, the embedder has fullscreen permission", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/cancel_request/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/cancel_request/manifest.json index 56f9481de8..8c76aa6b3f 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/cancel_request/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/cancel_request/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: geolocation cancelRequest test", + "manifest_version": 2, "description": "Loads a guest that has an iframe and the iframe requests geolocation, before deciding the geolocation permission, the iframe navigates away, canceling the permisison request", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/embedder_has_no_permission/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/embedder_has_no_permission/manifest.json index c30ec57a4d..d42c54d134 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/embedder_has_no_permission/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/embedder_has_no_permission/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: geolocation", + "manifest_version": 2, "description": "Loads a guest which requests geolocation", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/embedder_has_permission/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/embedder_has_permission/manifest.json index 74ad74aed5..ccdbd62dba 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/embedder_has_permission/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/embedder_has_permission/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: geolocation", + "manifest_version": 2, "description": "Loads a guest which requests geolocation", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/geolocation_request_gone/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/geolocation_request_gone/manifest.json index 540beddb73..60b14d2129 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/geolocation_request_gone/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/geolocation/geolocation_request_gone/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: geolocation", + "manifest_version": 2, "description": "Loads a guest that makes a geolocation request. The request is kept around for some time in the embedder then garbage collected.", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/guest_focus_test/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/guest_focus_test/manifest.json index 77c2ec05e4..fc94c746aa 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/guest_focus_test/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/guest_focus_test/manifest.json @@ -1,5 +1,6 @@ { "name": " guest focus test.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/ime/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/ime/manifest.json index bcf75c58ef..a12eba7aa6 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/ime/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/ime/manifest.json @@ -1,5 +1,6 @@ { "name": " IME tests.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/inside_iframe/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/inside_iframe/manifest.json index d76390bc46..7067e2bc77 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/inside_iframe/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/inside_iframe/manifest.json @@ -1,5 +1,6 @@ { "name": " inside iframe.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/interstitial_teardown/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/interstitial_teardown/manifest.json index 43f0ea6a2f..3550be65e6 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/interstitial_teardown/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/interstitial_teardown/manifest.json @@ -1,5 +1,6 @@ { "name": " interstitial page check.", + "manifest_version": 2, "description": "Check teardown path of guest while interstitial page is shown", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/isolation_indexeddb/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/isolation_indexeddb/manifest.json index c05ddf74e7..5eadf4adca 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/isolation_indexeddb/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/isolation_indexeddb/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: web view Indexed DB isolation", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/load_webview_inside_iframe/embedder.html b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/load_webview_inside_iframe/embedder.html index 9c8fe135a1..c76d3e246c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/load_webview_inside_iframe/embedder.html +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/load_webview_inside_iframe/embedder.html @@ -6,6 +6,12 @@ --> + diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/load_webview_inside_iframe/embedder.js b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/load_webview_inside_iframe/embedder.js index f6997b1e49..6980d8086c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/load_webview_inside_iframe/embedder.js +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/load_webview_inside_iframe/embedder.js @@ -18,13 +18,20 @@ function testLoadWebviewInsideIframe() { var iframe = document.querySelector('iframe'); var webview = iframe.contentDocument.querySelector('webview'); - webview.addEventListener('loadstop', function () { - window.addEventListener('message', function (e) { - if(e.data == 'TEST_PASSED') { - chrome.test.sendMessage('TEST_PASSED'); - } else { - chrome.test.sendMessage('TEST_FAILED'); - }}); + if (webview.contentWindow === undefined) { + window.console.log('The webview was not initialized.'); + chrome.test.sendMessage('TEST_FAILED'); + return; + } + + webview.addEventListener('loadstop', function() { + window.addEventListener('message', function(e) { + if (e.data == 'TEST_PASSED') { + chrome.test.sendMessage('TEST_PASSED'); + } else { + chrome.test.sendMessage('TEST_FAILED'); + } + }); webview.contentWindow.postMessage('TEST_START', '*'); }); diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/allow/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/allow/manifest.json index ea2ad294cb..990ff99fb8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/allow/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/allow/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: media", + "manifest_version": 2, "description": "Loads a guest which requests media access permission", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/check/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/check/manifest.json index d7488e988a..092aa68681 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/check/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/check/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: media", + "manifest_version": 2, "description": "Loads a guest which requests media sources, this triggers checking existing permission", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/deny/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/deny/manifest.json index ea2ad294cb..990ff99fb8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/deny/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/media_access/deny/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: media", + "manifest_version": 2, "description": "Loads a guest which requests media access permission", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/navigation/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/navigation/manifest.json index 7bb498865e..35884c4066 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/navigation/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/navigation/manifest.json @@ -1,5 +1,6 @@ { "name": "Packaged App Test: Navigation", + "manifest_version": 2, "description": "Verifies that the Navigation works as expected.", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/newwindow/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/newwindow/manifest.json index 0cb7a64b72..b31834869a 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/newwindow/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/newwindow/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: New Window", + "manifest_version": 2, "description": "Loads a guest which opens a new window", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/nopermission/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/nopermission/manifest.json index 8dbd7c659b..0390e97a1d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/nopermission/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/nopermission/manifest.json @@ -1,5 +1,6 @@ { "name": "", + "manifest_version": 2, "description": "Checks that elements lack an API without the webview permission", "version": "2", "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/noprerenderer/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/noprerenderer/manifest.json index 22a5f3b5ab..1d50753be8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/noprerenderer/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/noprerenderer/manifest.json @@ -1,5 +1,6 @@ { "name": " disabled prerenderer test", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointer_lock/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointer_lock/manifest.json index 7f46590fd5..56993fa06a 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointer_lock/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointer_lock/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: src", + "manifest_version": 2, "version": "1", "permissions": [ "webview", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointer_lock_focus/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointer_lock_focus/manifest.json index 7f46590fd5..56993fa06a 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointer_lock_focus/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointer_lock_focus/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: src", + "manifest_version": 2, "version": "1", "permissions": [ "webview", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointerlock/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointerlock/manifest.json index 8cada9400f..661099498a 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointerlock/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/pointerlock/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: Pointer Lock", + "manifest_version": 2, "description": "Loads a guest which requests a pointer lock", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/popup_positioning/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/popup_positioning/manifest.json index 63ce917ed1..d261174381 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/popup_positioning/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/popup_positioning/manifest.json @@ -1,5 +1,6 @@ { "name": " html5 popup.", + "manifest_version": 2, "description": "Test that checks popup positioning correctness", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/manifest.json index 7a90b2cd71..9eb5aad5f3 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/post_message/basic/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: basic postMessage", + "manifest_version": 2, "version": "1", "permissions": ["webview"], "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/rules_registry/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/rules_registry/manifest.json index 98bb9963d0..c7f57b6bf1 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/rules_registry/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/rules_registry/manifest.json @@ -1,5 +1,6 @@ { "name": " rules registry tests.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/scrollable_embedder_and_guest/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/scrollable_embedder_and_guest/manifest.json index fcd0c4e82d..f70fb7161c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/scrollable_embedder_and_guest/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/scrollable_embedder_and_guest/manifest.json @@ -1,5 +1,6 @@ { "name": " scroll bubbling test.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/select/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/select/manifest.json index dacdc5f251..19f54bb0b9 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/select/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/select/manifest.json @@ -1,5 +1,6 @@ { "name": " select tag test.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/shim/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/shim/manifest.json index ab2fb956f0..bb1ff2f1a8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/shim/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/shim/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: ", + "manifest_version": 2, "version": "2", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/simple/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/simple/manifest.json index 2844633401..c96c03a0ac 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/simple/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/simple/manifest.json @@ -1,5 +1,6 @@ { "name": " simple test.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/speech_recognition_api/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/speech_recognition_api/manifest.json index 543bc66b50..e56f85cf96 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/speech_recognition_api/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/speech_recognition_api/manifest.json @@ -1,5 +1,6 @@ { "name": " Web Speech API.", + "manifest_version": 2, "version": "1", "permissions": [ "audioCapture", diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/src_attribute/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/src_attribute/manifest.json index c11815c1d4..cad6975782 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/src_attribute/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/src_attribute/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: src", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/storage_persistence/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/storage_persistence/manifest.json index d61d117b8d..a3884de152 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/storage_persistence/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/storage_persistence/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform API Test: Storage Persistence", + "manifest_version": 2, "version": "1.0", "permissions": ["webview"], "app": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/task_manager/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/task_manager/manifest.json index aa262661d1..de65be15f3 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/task_manager/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/task_manager/manifest.json @@ -1,5 +1,6 @@ { "name": " task manager test", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/text_selection/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/text_selection/manifest.json index e1dca4a93c..3567501c38 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/text_selection/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/text_selection/manifest.json @@ -1,5 +1,6 @@ { "name": "Packaged App Test: text selection", + "manifest_version": 2, "description": "Verifies that selecting text in works properly, particularly for Speak and Dictionary commands.", "version": "1", "permissions": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/touch_accessibility/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/touch_accessibility/manifest.json index e47038020d..e5b2c4d012 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/touch_accessibility/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/touch_accessibility/manifest.json @@ -1,5 +1,6 @@ { "name": " focus accessibility test.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/visibility_changed/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/visibility_changed/manifest.json index 585c11e818..c7b117190f 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/visibility_changed/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/web_view/visibility_changed/manifest.json @@ -1,5 +1,6 @@ { "name": " visibility checking tests.", + "manifest_version": 2, "version": "1", "permissions": [ "webview" diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/window_api/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/window_api/manifest.json index 9440b7705d..eee931fc17 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/window_api/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/window_api/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: Window API", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/window_api_interactive/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/window_api_interactive/manifest.json index 327c7dceaf..3b97d9fb45 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/window_api_interactive/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/window_api_interactive/manifest.json @@ -1,5 +1,6 @@ { "name": "Platform App Test: Window API Interative", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/windows_api_properties/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/windows_api_properties/manifest.json index ce09a2d76b..d64a92870c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/windows_api_properties/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/windows_api_properties/manifest.json @@ -1,5 +1,6 @@ { "name": "app.windows properties", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/windows_api_set_icon/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/windows_api_set_icon/manifest.json index e0db6ee3e4..f5b0f94946 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/windows_api_set_icon/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/platform_apps/windows_api_set_icon/manifest.json @@ -1,5 +1,6 @@ { "name": "app.windows setIcon", + "manifest_version": 2, "version": "1", "app": { "background": { diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json index 56fdb6c68f..18f94d4f34 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json @@ -1,5 +1,6 @@ { "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDuUZGKCDbff6IRaxa4Pue7PPkxwPaNhGT3JEqppEsNWFjM80imEdqMbf3lrWqEfaHgaNku7nlpwPO1mu3/4Hr+XdNa5MhfnOnuPee4hyTLwOs3Vzz81wpbdzUxZSi2OmqMyI5oTaBYICfNHLwcuc65N5dbt6WKGeKgTpp4v7j7zwIDAQAB", + "manifest_version": 2, "version": "1.0.0.0", "name": "1 content script", "content_scripts": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ahbojlbmpfcbogfblmekncilheldhjga/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ahbojlbmpfcbogfblmekncilheldhjga/1.0/manifest.json index ebb23bbd49..1e34a34e66 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ahbojlbmpfcbogfblmekncilheldhjga/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ahbojlbmpfcbogfblmekncilheldhjga/1.0/manifest.json @@ -1,5 +1,6 @@ { "content_scripts": [ { + "manifest_version": 2, "js": [ "script.js" ], "matches": [ "file://*", "http://*/*" ] } ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/coomonpcecmahbfkifeohkbgicpcfdgf/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/coomonpcecmahbfkifeohkbgicpcfdgf/1.0/manifest.json index a325a891ff..3a0564d0d8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/coomonpcecmahbfkifeohkbgicpcfdgf/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/coomonpcecmahbfkifeohkbgicpcfdgf/1.0/manifest.json @@ -1,5 +1,6 @@ { "content_scripts": [ { + "manifest_version": 2, "js": [ "script.js" ], "matches": [ "file://*", "http://*/*" ] } ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/dhminefdpfgdedodgdilagiencggdcpm/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/dhminefdpfgdedodgdilagiencggdcpm/1.0/manifest.json index 80ba6292a2..4cedb34290 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/dhminefdpfgdedodgdilagiencggdcpm/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/dhminefdpfgdedodgdilagiencggdcpm/1.0/manifest.json @@ -1,5 +1,6 @@ { "content_scripts": [ { + "manifest_version": 2, "js": [ "script.js" ], "matches": [ "file://*", "http://*/*" ] } ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/kgfhjcinicjnlcbnbacbkbjdbafnlckn/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/kgfhjcinicjnlcbnbacbkbjdbafnlckn/1.0/manifest.json index 25293e9863..f5571d88f3 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/kgfhjcinicjnlcbnbacbkbjdbafnlckn/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/kgfhjcinicjnlcbnbacbkbjdbafnlckn/1.0/manifest.json @@ -1,5 +1,6 @@ { "content_scripts": [ { + "manifest_version": 2, "js": [ "script.js" ], "matches": [ "file://*", "http://*/*" ] } ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ledhkldokbafdcbmepdigjmkabmombel/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ledhkldokbafdcbmepdigjmkabmombel/1.0/manifest.json index 8e18a65f90..896c76b61d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ledhkldokbafdcbmepdigjmkabmombel/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ledhkldokbafdcbmepdigjmkabmombel/1.0/manifest.json @@ -1,5 +1,6 @@ { "content_scripts": [ { + "manifest_version": 2, "js": [ "script.js" ], "matches": [ "file://*", "http://*/*" ] } ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/lgmapeiimomfdbfphldobhhpoaoafaci/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/lgmapeiimomfdbfphldobhhpoaoafaci/1.0/manifest.json index 7bfe9d3d0d..5112b77db8 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/lgmapeiimomfdbfphldobhhpoaoafaci/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/lgmapeiimomfdbfphldobhhpoaoafaci/1.0/manifest.json @@ -1,5 +1,6 @@ { "content_scripts": [ { + "manifest_version": 2, "js": [ "script.js" ], "matches": [ "file://*", "http://*/*" ] } ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/maemolkcfjifpmigoecmpfphmebnebpk/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/maemolkcfjifpmigoecmpfphmebnebpk/1.0/manifest.json index f6b40f0767..80bbddbe8e 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/maemolkcfjifpmigoecmpfphmebnebpk/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/maemolkcfjifpmigoecmpfphmebnebpk/1.0/manifest.json @@ -1,5 +1,6 @@ { "content_scripts": [ { + "manifest_version": 2, "js": [ "script.js" ], "matches": [ "file://*", "http://*/*" ] } ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/mdeggakgacjccnbfbhbihfchoidihkaf/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/mdeggakgacjccnbfbhbihfchoidihkaf/1.0/manifest.json index c5e5e16aad..4beec175cd 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/mdeggakgacjccnbfbhbihfchoidihkaf/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/mdeggakgacjccnbfbhbihfchoidihkaf/1.0/manifest.json @@ -1,5 +1,6 @@ { "content_scripts": [ { + "manifest_version": 2, "js": [ "script.js" ], "matches": [ "file://*", "http://*/*" ] } ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/mgonfebmjopdoipblbijejncibmgmcol/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/mgonfebmjopdoipblbijejncibmgmcol/1.0/manifest.json index da1f2eece6..a532842127 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/mgonfebmjopdoipblbijejncibmgmcol/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/mgonfebmjopdoipblbijejncibmgmcol/1.0/manifest.json @@ -1,5 +1,6 @@ { "content_scripts": [ { + "manifest_version": 2, "js": [ "script.js" ], "matches": [ "file://*", "http://*/*" ] } ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ohmmlgjlmaadhojogadklhlidfpdeoca/1.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ohmmlgjlmaadhojogadklhlidfpdeoca/1.0/manifest.json index a2840206f7..b4a4994594 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ohmmlgjlmaadhojogadklhlidfpdeoca/1.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts10/Default/Extensions/ohmmlgjlmaadhojogadklhlidfpdeoca/1.0/manifest.json @@ -1,5 +1,6 @@ { "content_scripts": [ { + "manifest_version": 2, "js": [ "script.js" ], "matches": [ "file://*", "http://*/*" ] } ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json index d1f993b3a4..5924b0b630 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/content_scripts50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json @@ -1,5 +1,6 @@ { "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDuUZGKCDbff6IRaxa4Pue7PPkxwPaNhGT3JEqppEsNWFjM80imEdqMbf3lrWqEfaHgaNku7nlpwPO1mu3/4Hr+XdNa5MhfnOnuPee4hyTLwOs3Vzz81wpbdzUxZSi2OmqMyI5oTaBYICfNHLwcuc65N5dbt6WKGeKgTpp4v7j7zwIDAQAB", + "manifest_version": 2, "version": "1.0.0.0", "name": "50 content scripts", "content_scripts": [ diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/extension_webrequest/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/extension_webrequest/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json index 835bc4403c..10dc76c674 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/extension_webrequest/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/profiles/extension_webrequest/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json @@ -1,5 +1,6 @@ { "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDuUZGKCDbff6IRaxa4Pue7PPkxwPaNhGT3JEqppEsNWFjM80imEdqMbf3lrWqEfaHgaNku7nlpwPO1mu3/4Hr+XdNa5MhfnOnuPee4hyTLwOs3Vzz81wpbdzUxZSi2OmqMyI5oTaBYICfNHLwcuc65N5dbt6WKGeKgTpp4v7j7zwIDAQAB", + "manifest_version": 2, "version": "1.0.0.0", "name": "Webrequest", "permissions": ["experimental", "webRequest"], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/theme2/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/theme2/manifest.json index d263c0aa68..59d0b6e0f5 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/extensions/theme2/manifest.json +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/theme2/manifest.json @@ -1,5 +1,6 @@ { "name": "snowflake theme", + "manifest_version": 2, "theme": { "colors": { "frame": [ 158, 210, 242 ], diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/web_accessible_resources/extension_page.html b/lgpl/sources/chromium/src/chrome/test/data/extensions/web_accessible_resources/extension_page.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/web_accessible_resources/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/extensions/web_accessible_resources/manifest.json new file mode 100644 index 0000000000..03649ef994 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/extensions/web_accessible_resources/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "test", + "version": "1", + "manifest_version": 2, + "description" : "An extension with a web accessible resource", + "web_accessible_resources": ["web_accessible_page.html"] +} diff --git a/lgpl/sources/chromium/src/chrome/test/data/extensions/web_accessible_resources/web_accessible_page.html b/lgpl/sources/chromium/src/chrome/test/data/extensions/web_accessible_resources/web_accessible_page.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lgpl/sources/chromium/src/chrome/test/data/favicon/page_with_favicon_by_url.html b/lgpl/sources/chromium/src/chrome/test/data/favicon/page_with_favicon_by_url.html new file mode 100644 index 0000000000..9e8587fb5e --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/favicon/page_with_favicon_by_url.html @@ -0,0 +1,15 @@ + + + + + + +This page will load a favicon in JavaScript via the query parameter 'url'. + + \ No newline at end of file diff --git a/lgpl/sources/chromium/src/chrome/test/data/installer/courgette_archive.diff b/lgpl/sources/chromium/src/chrome/test/data/installer/courgette_archive.diff new file mode 100644 index 0000000000..361781ce2a Binary files /dev/null and b/lgpl/sources/chromium/src/chrome/test/data/installer/courgette_archive.diff differ diff --git a/lgpl/sources/chromium/src/chrome/test/data/installer/zucchini_archive.diff b/lgpl/sources/chromium/src/chrome/test/data/installer/zucchini_archive.diff new file mode 100644 index 0000000000..f7bb9b1fc4 Binary files /dev/null and b/lgpl/sources/chromium/src/chrome/test/data/installer/zucchini_archive.diff differ diff --git a/lgpl/sources/chromium/src/chrome/test/data/media/engagement/engagement_autoplay_iframe_delegation.html b/lgpl/sources/chromium/src/chrome/test/data/media/engagement/engagement_autoplay_iframe_delegation.html new file mode 100644 index 0000000000..7b4c4ea8ef --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/media/engagement/engagement_autoplay_iframe_delegation.html @@ -0,0 +1,9 @@ + + +Media Engagement Test + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/media/unified_autoplay.html b/lgpl/sources/chromium/src/chrome/test/data/media/unified_autoplay.html index cfefabc493..f4ddc4e8e6 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/media/unified_autoplay.html +++ b/lgpl/sources/chromium/src/chrome/test/data/media/unified_autoplay.html @@ -1,7 +1,7 @@ -Simple autopaly test page +Simple autoplay test page + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/password/navigate_to_same_url_empty_actions.html b/lgpl/sources/chromium/src/chrome/test/data/password/navigate_to_same_url_empty_actions.html new file mode 100644 index 0000000000..cbe882fa0e --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/password/navigate_to_same_url_empty_actions.html @@ -0,0 +1,35 @@ + + + + + + + + + \ No newline at end of file diff --git a/lgpl/sources/chromium/src/chrome/test/data/password/password_form_action_mutation.html b/lgpl/sources/chromium/src/chrome/test/data/password/password_form_action_mutation.html new file mode 100644 index 0000000000..454b3523d5 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/password/password_form_action_mutation.html @@ -0,0 +1,44 @@ + + + + + + + + + +
+ + + +
+ + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/pdf/navigator_test.js b/lgpl/sources/chromium/src/chrome/test/data/pdf/navigator_test.js index 1e86f23b5f..55da969c73 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/pdf/navigator_test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/pdf/navigator_test.js @@ -112,10 +112,10 @@ var tests = [ function() {}, function() {}, function() {}, 0, 1, 0); - var paramsParser = new OpenPDFParamsParser(function(name) { - if (name == 'US') + var paramsParser = new OpenPDFParamsParser(function(message) { + if (message.namedDestination == 'US') paramsParser.onNamedDestinationReceived(0); - else if (name == 'UY') + else if (message.namedDestination == 'UY') paramsParser.onNamedDestinationReceived(2); else paramsParser.onNamedDestinationReceived(-1); diff --git a/lgpl/sources/chromium/src/chrome/test/data/pdf/params_parser_test.js b/lgpl/sources/chromium/src/chrome/test/data/pdf/params_parser_test.js index b3675f2c9b..5bb91a542c 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/pdf/params_parser_test.js +++ b/lgpl/sources/chromium/src/chrome/test/data/pdf/params_parser_test.js @@ -7,12 +7,13 @@ var tests = [ * Test named destinations. */ function testParamsParser() { - var paramsParser = new OpenPDFParamsParser(function(name) { - if (name == 'RU') + var paramsParser = new OpenPDFParamsParser(function(message) { + chrome.test.assertEq('getNamedDestination', message.type); + if (message.namedDestination == 'RU') paramsParser.onNamedDestinationReceived(26); - else if (name == 'US') + else if (message.namedDestination == 'US') paramsParser.onNamedDestinationReceived(0); - else if (name == 'UY') + else if (message.namedDestination == 'UY') paramsParser.onNamedDestinationReceived(22); else paramsParser.onNamedDestinationReceived(-1); diff --git a/lgpl/sources/chromium/src/chrome/test/data/policy/policy_test_cases.json b/lgpl/sources/chromium/src/chrome/test/data/policy/policy_test_cases.json index 577938fb83..b92400ca1b 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/policy/policy_test_cases.json +++ b/lgpl/sources/chromium/src/chrome/test/data/policy/policy_test_cases.json @@ -1,5 +1,6 @@ { "-- Template --": { + "intro": "Tests that policies map to prefs properly and whether the corresponding Chrome settings UI behaves properly, e.g. if a policy is managed, the UI should be readonly and an icon with a properly worded tooltip should show up.", "intro": "Top-level entries map a policy name to its test parameters, described below. The name of the top level entry should be of the form [.suffix]. The optional suffix is used for defining multiple test cases for a single policy.", "os": ["List of operating systems that support this policy. Valid values:", "win", "linux", "mac", "chromeos", "android", "Defaults to empty if not specified."], @@ -751,10 +752,14 @@ }, "EnableCommonNameFallbackForLocalAnchors": { + "note": "This policy is deprecated and removed since Chrome 66." + }, + + "EnableSymantecLegacyInfrastructure": { "os": ["win", "linux", "mac", "chromeos", "android"], - "test_policy": { "EnableCommonNameFallbackForLocalAnchors": true }, + "test_policy": { "EnableSymantecLegacyInfrastructure": true }, "pref_mappings": [ - { "pref": "ssl.common_name_fallback_enabled_for_local_anchors", + { "pref": "ssl.enable_symantec_legacy_infrastructure", "local_state": true } ] @@ -912,6 +917,7 @@ "ThirdPartyBlockingEnabled": { "os": ["win"], + "official_only": true, "test_policy": { "ThirdPartyBlockingEnabled": false }, "pref_mappings": [ { "pref": "third_party_blocking_enabled", @@ -2015,6 +2021,7 @@ }, "SafeBrowsingExtendedReportingOptInAllowed": { + "note": "This policy is being deprecated.", "os": ["win", "linux", "mac", "chromeos"], "test_policy": { "SafeBrowsingExtendedReportingOptInAllowed": true }, "pref_mappings": [ @@ -2165,8 +2172,24 @@ ] }, + "MachineLevelUserCloudPolicyEnrollmentToken": { + "os": ["win", "linux", "mac"], + "test_policy": {"MachineLevelUserCloudPolicyEnrollmentToken": ""}, + "pref_mappings": [ + { "pref": "policy.machine_level_user_cloud_policy_enrollment_token", + "local_state": true + } + ] + }, + "SSLVersionMin": { - "note": "This policy is retired, see https://crbug.com/487730." + "os": ["win", "linux", "mac", "chromeos"], + "test_policy": { "SSLVersionMin": "tls1.1" }, + "pref_mappings": [ + { "pref": "ssl.version_min", + "local_state": true + } + ] }, "SSLVersionFallbackMin": { @@ -2307,6 +2330,19 @@ ] }, + "RelaunchNotification": { + "os": ["win", "linux", "mac"], + "test_policy": { "RelaunchNotification": 1}, + "pref_mappings": [ + { "pref": "browser.relaunch_notification", + "local_state": true + } + ] + }, + + "RelaunchNotificationPeriod": { + "note": "This policy is waiting for M67; see https://crbug.com/807072." + }, "----- Chrome OS policies ------------------------------------------------": {}, @@ -3119,6 +3155,14 @@ "DeviceAutoUpdateP2PEnabled": { }, + "DeviceRollbackAllowedMilestones": { + "note": "Chrome OS device policy used by update_engine only, not used in Chrome. TODO(hunyadym): add os field when M67 in dev." + }, + + "DeviceRollbackToTargetVersion": { + "note": "Chrome OS device policy used by update_engine only, not used in Chrome. TODO(hunyadym): add os field when M67 in dev." + }, + "DeviceTargetVersionPrefix": { }, @@ -3469,9 +3513,81 @@ ] }, + "SafeBrowsingExtendedReportingEnabled": { + "os": ["win", "linux", "mac", "chromeos"], + "test_policy": { "SafeBrowsingExtendedReportingEnabled": true }, + "pref_mappings": [ + { "pref": "safebrowsing.scout_reporting_enabled" } + ] + }, + + "RestrictAccountsToPatterns": { }, + "PasswordProtectionWarningTrigger": { + }, + + "PasswordProtectionRiskTrigger": { + }, + + "DeviceOffHours": { + "os": ["chromeos"], + "test_policy": {"DeviceOffHours": {"intervals": [{"start" : {"day_of_week" : 1, "time": 12840000}, "end": {"day_of_week" : 1, "time": 21720000}}], "timezone" : "GMT", "ignored_policy_proto_tags": [8, 3]}} + }, + + "DeviceKerberosEncryptionTypes": { + "os": ["chromeos"], + "note": "Chrome OS device policy used by authpolicyd only, not used in Chrome" + }, + + "DeviceUserPolicyLoopbackProcessingMode": { + "os": ["chromeos"], + "note": "Chrome OS device policy used by authpolicyd only, not used in Chrome" + }, + + "DeviceMachinePasswordChangeRate": { + "os": ["chromeos"], + "note": "Chrome OS device policy used by authpolicyd only, not used in Chrome" + }, + + "DeviceLoginScreenIsolateOrigins": { + "os": ["chromeos"], + "note": "Chrome OS device policy used by session_manager only" + }, + + "DeviceLoginScreenSitePerProcess": { + "os": ["chromeos"], + "note": "Chrome OS device policy used by session_manager only" + }, + + "VirtualMachinesAllowed": { + "os": ["chromeos"], + "test_policy": { + "virtual_machines_allowed": false + }, + "pref_mappings": [ + { "pref": "cros.virtual_machines_allowed"} + ] + }, + + "SafeBrowsingWhitelistDomains": { + }, + + "PasswordProtectionLoginURLs": { + }, + + "PasswordProtectionChangePasswordURL": { + }, + + "AutoplayAllowed": { + "os": ["win", "linux", "mac", "chromeos"], + "test_policy": { "AutoplayAllowed": false }, + "pref_mappings": [ + { "pref": "media.autoplay_allowed" } + ] + }, + "----- Chrome Frame policies -------------------------------------------": {}, "ChromeFrameRendererSettings": { @@ -3496,10 +3612,5 @@ }, "SkipMetadataCheck": { - }, - - "DeviceOffHours": { - "os": ["chromeos"], - "test_policy": {"DeviceOffHours": {"intervals": [{"start" : {"day_of_week" : 1, "time": 12840000}, "end": {"day_of_week" : 1, "time": 21720000}}], "timezone" : "GMT", "ignored_policy_proto_tags": [8, 3]}} } } diff --git a/lgpl/sources/chromium/src/chrome/test/data/printing/chain_child_iframe.html b/lgpl/sources/chromium/src/chrome/test/data/printing/chain_child_iframe.html new file mode 100644 index 0000000000..7649fc20e5 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/printing/chain_child_iframe.html @@ -0,0 +1,14 @@ + + + + A child frame of an iframe + + +

+ This is a test page. +

+
+ + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_iframe.html b/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_iframe.html new file mode 100644 index 0000000000..5d530a29cc --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_iframe.html @@ -0,0 +1,14 @@ + + + + Test printing iframe content + + +

+ This is a test page. +

+
+ + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_iframe_chain.html b/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_iframe_chain.html new file mode 100644 index 0000000000..e6b1adb137 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_iframe_chain.html @@ -0,0 +1,14 @@ + + + + Test printing with an iframe chain + + +

+ This is a test page with an iframe chain. +

+
+ + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_iframe_loop.html b/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_iframe_loop.html new file mode 100644 index 0000000000..9c69cf6145 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_iframe_loop.html @@ -0,0 +1,14 @@ + + + + Test printing with an iframe loop + + +

+ This is a test page whose content forms an iframe loop. +

+
+ + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_same_site_iframe.html b/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_same_site_iframe.html new file mode 100644 index 0000000000..f11e5b7cee --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/printing/content_with_same_site_iframe.html @@ -0,0 +1,15 @@ + + + + Test printing isolated iframe + + +

+ This is a test page. +

+
+ +
+ + diff --git a/lgpl/sources/chromium/src/chrome/test/data/printing/loop_child_iframe.html b/lgpl/sources/chromium/src/chrome/test/data/printing/loop_child_iframe.html new file mode 100644 index 0000000000..855800b915 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/printing/loop_child_iframe.html @@ -0,0 +1,14 @@ + + + + A child frame of an iframe + + +

+ This is a test page. +

+
+ + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/printing/test_extension/manifest.json b/lgpl/sources/chromium/src/chrome/test/data/printing/test_extension/manifest.json new file mode 100644 index 0000000000..78b732301a --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/printing/test_extension/manifest.json @@ -0,0 +1,13 @@ +{ + "name": "Test Extensions", + "description" : "Base Level Extension", + "version": "1.0", + "manifest_version": 2, + "browser_action": { + "default_popup": "test_extension.html" + }, + "options_ui": { + "page": "options.html", + "chrome_style": true + } +} diff --git a/lgpl/sources/chromium/src/chrome/test/data/printing/test_extension/options.html b/lgpl/sources/chromium/src/chrome/test/data/printing/test_extension/options.html new file mode 100644 index 0000000000..7866c31fff --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/printing/test_extension/options.html @@ -0,0 +1,6 @@ + + +

Test Extension's Option Page

+

No content here, for test only.

+ + diff --git a/lgpl/sources/chromium/src/chrome/test/data/printing/test_extension/test_extension.html b/lgpl/sources/chromium/src/chrome/test/data/printing/test_extension/test_extension.html new file mode 100644 index 0000000000..c138e4345b --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/printing/test_extension/test_extension.html @@ -0,0 +1,5 @@ + + +

Test Extensions

+ + diff --git a/lgpl/sources/chromium/src/chrome/test/data/ssl/browser_use_client_cert_store.html b/lgpl/sources/chromium/src/chrome/test/data/ssl/browser_use_client_cert_store.html new file mode 100644 index 0000000000..ed3f9e2c4a --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/ssl/browser_use_client_cert_store.html @@ -0,0 +1,12 @@ + + + page title + + + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/ssl/page_with_form_targeting_insecure_url.html b/lgpl/sources/chromium/src/chrome/test/data/ssl/page_with_form_targeting_insecure_url.html new file mode 100644 index 0000000000..6ecb358420 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/ssl/page_with_form_targeting_insecure_url.html @@ -0,0 +1,10 @@ + +Page with form that targets an insecure URL + + +
+ + +
+ + diff --git a/lgpl/sources/chromium/src/chrome/test/data/two_iframes_blank.html b/lgpl/sources/chromium/src/chrome/test/data/two_iframes_blank.html new file mode 100644 index 0000000000..5b9928a846 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/two_iframes_blank.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/generic_webxr_page.html b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/generic_webxr_page.html new file mode 100644 index 0000000000..e76777a154 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/generic_webxr_page.html @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_navigation_2d_page2.html b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_navigation_2d_page2.html new file mode 100644 index 0000000000..2b9b3b0941 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_navigation_2d_page2.html @@ -0,0 +1,9 @@ + + + + + Fullscreen + + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_navigation_webxr_page.html b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_navigation_webxr_page.html new file mode 100644 index 0000000000..6f5f4c1bbb --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_navigation_webxr_page.html @@ -0,0 +1,11 @@ + + + + + Fullscreen + + + + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_nfc_fires_vrdisplayactivate.html b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_nfc_fires_vrdisplayactivate.html index 62fecb8940..3dd794361d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_nfc_fires_vrdisplayactivate.html +++ b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_nfc_fires_vrdisplayactivate.html @@ -6,6 +6,7 @@ + diff --git a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_presentation_locks_focus.html b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_presentation_locks_focus.html index 651fa016bf..e3bbe2a2c4 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_presentation_locks_focus.html +++ b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_presentation_locks_focus.html @@ -15,12 +15,13 @@ diff --git a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_screen_taps_not_registered.html b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_screen_taps_not_registered.html index 1cde6075b4..fbd09cd90d 100644 --- a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_screen_taps_not_registered.html +++ b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_screen_taps_not_registered.html @@ -13,8 +13,6 @@ + + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_webxr_reentry_from_vr_browser.html b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_webxr_reentry_from_vr_browser.html new file mode 100644 index 0000000000..809299e2d3 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/test_webxr_reentry_from_vr_browser.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/webxr_page_submits_once.html b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/webxr_page_submits_once.html new file mode 100644 index 0000000000..691c08503d --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/webxr_page_submits_once.html @@ -0,0 +1,24 @@ + + + + + + + + + + + + + diff --git a/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/webxr_test_presentation_locks_focus.html b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/webxr_test_presentation_locks_focus.html new file mode 100644 index 0000000000..b8c72d5413 --- /dev/null +++ b/lgpl/sources/chromium/src/chrome/test/data/vr/e2e_test_files/html/webxr_test_presentation_locks_focus.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + + diff --git a/lgpl/sources/chromium/src/third_party/WebKit/PRESUBMIT.py b/lgpl/sources/chromium/src/third_party/WebKit/PRESUBMIT.py index 42dbdf47af..95a0aba1ab 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/PRESUBMIT.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/PRESUBMIT.py @@ -36,7 +36,11 @@ def _CheckForWrongMojomIncludes(input_api, output_api): # used to avoid exporting Blink types outside Blink. def source_file_filter(path): return input_api.FilterSourceFile(path, - black_list=[r'third_party/WebKit/common/']) + black_list=[r'third_party/WebKit/common/', r'third_party/WebKit/public/common']) + + # The list of files that we specifically want to allow including + # -blink variant files (e.g. because it has #if INSIDE_BLINK). + allow_blink_files = [r'third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerRequest.h'] pattern = input_api.re.compile(r'#include\s+.+\.mojom(.*)\.h[>"]') public_folder = input_api.os_path.normpath('third_party/WebKit/public/') @@ -45,10 +49,14 @@ def source_file_filter(path): for f in input_api.AffectedFiles(file_filter=source_file_filter): for line_num, line in f.ChangedContents(): error_list = None + # This is not super precise as we don't check endif, but allow + # including Blink variant mojom files if the file has + # '#if INSIDE_BLINK'. match = pattern.match(line) if match: if match.group(1) != '-shared': - if f.LocalPath().startswith(public_folder): + if f.LocalPath().startswith(public_folder) and \ + not f.LocalPath() in allow_blink_files: error_list = public_blink_mojom_errors elif match.group(1) != '-blink': # Neither -shared.h, nor -blink.h. @@ -93,10 +101,16 @@ def _CheckStyle(input_api, output_api): style_checker_path = input_api.os_path.join(input_api.PresubmitLocalPath(), 'Tools', 'Scripts', 'check-webkit-style') args = [input_api.python_executable, style_checker_path, '--diff-files'] - files = [input_api.os_path.join('..', '..', f.LocalPath()) - for f in input_api.AffectedFiles() - # Filter out files that follow Chromium's coding style. - if not re_chromium_style_file.search(f.LocalPath())] + files = [] + for f in input_api.AffectedFiles(): + file_path = f.LocalPath() + # Filter out files that follow Chromium's coding style. + if re_chromium_style_file.search(file_path): + continue + # Filter out changes in LayoutTests. + if 'LayoutTests' + input_api.os_path.sep in file_path and 'TestExpectations' not in file_path: + continue + files.append(input_api.os_path.join('..', '..', file_path)) # Do not call check-webkit-style with empty affected file list if all # input_api.AffectedFiles got filtered. if not files: @@ -143,9 +157,6 @@ def _CheckForForbiddenChromiumCode(input_api, output_api): results = [] for f in input_api.AffectedFiles(): path = f.LocalPath() - _, ext = os.path.splitext(path) - if ext not in ('.cc', '.cpp', '.h', '.mm'): - continue errors = audit_non_blink_usage.check(path, [(i + 1, l) for i, l in enumerate(f.NewContents())]) if errors: errors = audit_non_blink_usage.check(path, f.ChangedContents()) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/PRESUBMIT_test.py b/lgpl/sources/chromium/src/third_party/WebKit/PRESUBMIT_test.py index cd48b2077e..c1ff0b0917 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/PRESUBMIT_test.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/PRESUBMIT_test.py @@ -41,10 +41,12 @@ def testCheckChangeOnUploadWithWebKitAndChromiumFiles(self, _): """ diff_file_webkit_h = ['some diff'] diff_file_chromium_h = ['another diff'] + diff_file_test_expectations = ['more diff'] mock_input_api = MockInputApi() mock_input_api.files = [ MockAffectedFile('FileWebkit.h', diff_file_webkit_h), - MockAffectedFile('file_chromium.h', diff_file_chromium_h) + MockAffectedFile('file_chromium.h', diff_file_chromium_h), + MockAffectedFile('LayoutTests/TestExpectations', diff_file_test_expectations) ] # Access to a protected member _CheckStyle # pylint: disable=W0212 @@ -52,8 +54,9 @@ def testCheckChangeOnUploadWithWebKitAndChromiumFiles(self, _): capture = Capture() # pylint: disable=E1101 subprocess.Popen.assert_called_with(capture, stderr=-1) - self.assertEqual(4, len(capture.value)) + self.assertEqual(5, len(capture.value)) self.assertEqual('../../FileWebkit.h', capture.value[3]) + self.assertEqual('../../LayoutTests/TestExpectations', capture.value[4]) @mock.patch('subprocess.Popen') def testCheckChangeOnUploadWithEmptyAffectedFileList(self, _): @@ -62,10 +65,12 @@ def testCheckChangeOnUploadWithEmptyAffectedFileList(self, _): """ diff_file_chromium1_h = ['some diff'] diff_file_chromium2_h = ['another diff'] + diff_file_layout_test_html = ['more diff'] mock_input_api = MockInputApi() mock_input_api.files = [ MockAffectedFile('first_file_chromium.h', diff_file_chromium1_h), - MockAffectedFile('second_file_chromium.h', diff_file_chromium2_h) + MockAffectedFile('second_file_chromium.h', diff_file_chromium2_h), + MockAffectedFile('LayoutTests/some_tests.html', diff_file_layout_test_html) ] # Access to a protected member _CheckStyle # pylint: disable=W0212 @@ -121,7 +126,6 @@ class CxxDependencyTest(unittest.TestCase): disallow_list = [ 'GURL', 'base::Callback', - 'base::OnceCallback', 'content::RenderFrame', 'gfx::Point', 'gfx::Rect', @@ -151,6 +155,17 @@ def testCheckCommentsIgnored(self): errors = self.runCheck(filename, ['// %s' % item]) self.assertEqual([], errors) + # References in Test files should never be checked. + def testCheckTestsIgnored(self): + filename = 'third_party/WebKit/Source/core/frame/FrameTest.cc' + for item in self.allow_list: + errors = self.runCheck(filename, ['// %s' % item]) + self.assertEqual([], errors) + + for item in self.disallow_list: + errors = self.runCheck(filename, ['// %s' % item]) + self.assertEqual([], errors) + # core, modules, public, et cetera should all have dependency enforcement. def testCheckCoreEnforcement(self): filename = 'third_party/WebKit/Source/core/frame/frame.cc' diff --git a/lgpl/sources/chromium/src/third_party/WebKit/PerformanceTests/Paint/move-text-with-mask.html b/lgpl/sources/chromium/src/third_party/WebKit/PerformanceTests/Paint/move-text-with-mask.html new file mode 100644 index 0000000000..7f598a81eb --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/PerformanceTests/Paint/move-text-with-mask.html @@ -0,0 +1,35 @@ + + + + +
+ +
+ + diff --git a/lgpl/sources/chromium/src/third_party/WebKit/PerformanceTests/Paint/resources/mask.png b/lgpl/sources/chromium/src/third_party/WebKit/PerformanceTests/Paint/resources/mask.png new file mode 100644 index 0000000000..b7957e1343 Binary files /dev/null and b/lgpl/sources/chromium/src/third_party/WebKit/PerformanceTests/Paint/resources/mask.png differ diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/BUILD.gn b/lgpl/sources/chromium/src/third_party/WebKit/Source/BUILD.gn index b0296209ee..1e970fa214 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/BUILD.gn +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/BUILD.gn @@ -24,6 +24,10 @@ declare_args() { # a class has an empty destructor which would be unnecessarily invoked # when finalized. blink_gc_plugin_option_warn_unneeded_finalizer = false + + # Set to true to have the clang Blink GC plugin additionally check if a + # TraceWrappers method also dispatches to all its base classes. + blink_gc_plugin_option_warn_trace_wrappers_missing_base_dispatch = false } # features --------------------------------------------------------------------- @@ -140,6 +144,14 @@ config("config") { "warn-unneeded-finalizer", ] } + if (blink_gc_plugin_option_warn_trace_wrappers_missing_base_dispatch) { + cflags += [ + "-Xclang", + "-plugin-arg-blink-gc-plugin", + "-Xclang", + "warn_trace_wrappers_missing_base_dispatch", + ] + } } } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/DEPS b/lgpl/sources/chromium/src/third_party/WebKit/Source/DEPS index 8cf10da980..8d9ac227e7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/DEPS +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/DEPS @@ -8,12 +8,14 @@ include_rules = [ "+base/macros.h", "+base/memory/ptr_util.h", "+base/memory/weak_ptr.h", + "+base/single_thread_task_runner.h", + "+base/thread_annotations.h", + "+base/time/time.h", "+build", "+services/service_manager/public/cpp/connector.h", "+services/service_manager/public/cpp/interface_provider.h", "+testing/gmock/include/gmock", "+testing/gtest/include/gtest", - "+third_party/WebKit/common", "+v8", ] diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/SpecMapping.md b/lgpl/sources/chromium/src/third_party/WebKit/Source/SpecMapping.md index 6be98b8b9c..5702433a82 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/SpecMapping.md +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/SpecMapping.md @@ -29,13 +29,6 @@ using `SecurityOrigin::canAccess` and for [same-origin domain] using [same-origin domain]: https://html.spec.whatwg.org/multipage/browsers.html#same-origin-domain -The [Suborigins spec] extends HTML's definition of origins. To check for -same-origin corresponds to `SecurityOrigin::isSameSchemeHostPortAndSuborigin` -while the check for same-origin domain already takes the suborigin into -account. - -[Suborigins spec]: https://w3c.github.io/webappsec-suborigins/ - ### [Window object](https://html.spec.whatwg.org/#window) A Window object corresponds to the [DOMWindow] interface where the main diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/DEPS b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/DEPS index 6d95688768..e11836d4ee 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/DEPS +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/DEPS @@ -6,6 +6,6 @@ include_rules = [ "+modules", "+platform", "+public/platform", - "+services/network/public/interfaces/fetch_api.mojom-blink.h", + "+services/network/public/mojom/fetch_api.mojom-blink.h", "+web/api", ] diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/IDLUnionTypes.md b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/IDLUnionTypes.md index 244a82885c..050c2ca071 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/IDLUnionTypes.md +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/IDLUnionTypes.md @@ -25,7 +25,7 @@ name, but we use some aliases to avoid too-long file names Currently we use following alias(es). ``` -CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrImageBitmapRenderingContext -> RenderingContext +CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrImageBitmapRenderingContextOrXRPresentationContext -> RenderingContext ``` The paths for generated classes depend on the places union types are diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/bindings.gni b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/bindings.gni index 4afa9a8f42..b3cc6b8358 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/bindings.gni +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/bindings.gni @@ -53,7 +53,6 @@ bindings_core_v8_files = "core/v8/Maplike.h", "core/v8/NativeValueTraits.h", "core/v8/NativeValueTraitsImpl.h", - "core/v8/Nullable.h", "core/v8/ReferrerScriptInfo.cpp", "core/v8/ReferrerScriptInfo.h", "core/v8/RejectedPromises.cpp", @@ -93,8 +92,6 @@ bindings_core_v8_files = "core/v8/ScriptStreamer.h", "core/v8/ScriptStreamerThread.cpp", "core/v8/ScriptStreamerThread.h", - "core/v8/ScriptString.cpp", - "core/v8/ScriptString.h", "core/v8/ScriptValue.cpp", "core/v8/ScriptValue.h", "core/v8/SourceLocation.cpp", @@ -113,6 +110,8 @@ bindings_core_v8_files = "core/v8/V8CrossOriginSetterInfo.h", "core/v8/V8DOMConfiguration.cpp", "core/v8/V8DOMConfiguration.h", + "core/v8/V8EmbedderGraphBuilder.cpp", + "core/v8/V8EmbedderGraphBuilder.h", "core/v8/V8ErrorHandler.cpp", "core/v8/V8ErrorHandler.h", "core/v8/V8EventListener.cpp", @@ -141,6 +140,8 @@ bindings_core_v8_files = "core/v8/V8NodeFilterCondition.h", "core/v8/V8ObjectBuilder.cpp", "core/v8/V8ObjectBuilder.h", + "core/v8/V8ObjectParser.cpp", + "core/v8/V8ObjectParser.h", "core/v8/V8PagePopupControllerBinding.cpp", "core/v8/V8PagePopupControllerBinding.h", "core/v8/V8PersistentValueVector.h", @@ -151,6 +152,8 @@ bindings_core_v8_files = "core/v8/V8StringResource.h", "core/v8/V8V0CustomElementLifecycleCallbacks.cpp", "core/v8/V8V0CustomElementLifecycleCallbacks.h", + "core/v8/V8WasmResponseExtensions.cpp", + "core/v8/V8WasmResponseExtensions.h", "core/v8/V8WorkerOrWorkletEventListener.cpp", "core/v8/V8WorkerOrWorkletEventListener.h", "core/v8/WindowProxy.cpp", @@ -197,7 +200,7 @@ bindings_unittest_files = "core/v8/ScriptPromiseResolverTest.cpp", "core/v8/ScriptPromiseTest.cpp", "core/v8/ScriptStreamerTest.cpp", - "core/v8/ScriptWrappableVisitorTest.cpp", + "core/v8/ScriptWrappableMarkingVisitorTest.cpp", "core/v8/ToV8Test.cpp", "core/v8/TraceWrapperMemberTest.cpp", "core/v8/V8BindingForTesting.cpp", diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/BUILD.gn b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/BUILD.gn index 4cfaf201d1..49f5445928 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/BUILD.gn +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/BUILD.gn @@ -23,10 +23,8 @@ bindings_core_generated_union_type_files = [ "$bindings_core_v8_output_dir/boolean_or_byte_string_byte_string_record.h", "$bindings_core_v8_output_dir/byte_string_sequence_sequence_or_byte_string_byte_string_record.cc", "$bindings_core_v8_output_dir/byte_string_sequence_sequence_or_byte_string_byte_string_record.h", - "$bindings_core_v8_output_dir/composite_operation_or_composite_operation_sequence.cc", - "$bindings_core_v8_output_dir/composite_operation_or_composite_operation_sequence.h", - "$bindings_core_v8_output_dir/css_style_value_or_css_style_value_sequence.cc", - "$bindings_core_v8_output_dir/css_style_value_or_css_style_value_sequence.h", + "$bindings_core_v8_output_dir/composite_operation_or_composite_operation_or_null_sequence.cc", + "$bindings_core_v8_output_dir/composite_operation_or_composite_operation_or_null_sequence.h", "$bindings_core_v8_output_dir/css_style_value_or_string.cc", "$bindings_core_v8_output_dir/css_style_value_or_string.h", "$bindings_core_v8_output_dir/double_or_auto_keyword.cc", @@ -66,6 +64,8 @@ bindings_core_generated_union_type_files = [ "$bindings_core_v8_output_dir/node_list_or_element.h", "$bindings_core_v8_output_dir/html_collection_or_element.cc", "$bindings_core_v8_output_dir/html_collection_or_element.h", + "$bindings_core_v8_output_dir/media_list_or_string.cc", + "$bindings_core_v8_output_dir/media_list_or_string.h", "$bindings_core_v8_output_dir/node_or_string.cc", "$bindings_core_v8_output_dir/node_or_string.h", "$bindings_core_v8_output_dir/radio_node_list_or_element.cc", @@ -142,8 +142,8 @@ generated_core_callback_function_files = [ "$bindings_core_v8_output_dir/v8_reporting_observer_callback.h", "$bindings_core_v8_output_dir/v8_resize_observer_callback.cc", "$bindings_core_v8_output_dir/v8_resize_observer_callback.h", - "$bindings_core_v8_output_dir/v8_update_function.cc", - "$bindings_core_v8_output_dir/v8_update_function.h", + "$bindings_core_v8_output_dir/v8_scroll_state_callback.cc", + "$bindings_core_v8_output_dir/v8_scroll_state_callback.h", "$bindings_core_v8_output_dir/v8_void_function.cc", "$bindings_core_v8_output_dir/v8_void_function.h", ] @@ -271,10 +271,8 @@ source_set("testing") { generated_core_testing_callback_function_files configs -= core_config_remove - configs += [ - "//third_party/WebKit/Source:inside_blink", - "//third_party/WebKit/Source:config", - ] + configs += core_config_add + [ "//third_party/WebKit/Source:inside_blink" ] - + [ "//third_party/WebKit/Source/core:config" ] deps = [ ":bindings_core_impl_generated", diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorldTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorldTest.cpp index eacb6d5d9e..afbc4d4a3a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorldTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorldTest.cpp @@ -4,12 +4,12 @@ #include "platform/bindings/DOMWrapperWorld.h" +#include "base/single_thread_task_runner.h" #include "bindings/core/v8/V8BindingForTesting.h" #include "bindings/core/v8/V8Initializer.h" #include "core/workers/WorkerBackingThread.h" #include "core/workers/WorkerBackingThreadStartupData.h" #include "platform/CrossThreadFunctional.h" -#include "platform/WebTaskRunner.h" #include "platform/WebThreadSupportingGC.h" #include "platform/bindings/V8PerIsolateData.h" #include "platform/testing/UnitTestHelpers.h" @@ -52,8 +52,9 @@ Vector> CreateWorlds(v8::Isolate* isolate) { return worlds; } -void WorkerThreadFunc(WorkerBackingThread* thread, - scoped_refptr main_thread_task_runner) { +void WorkerThreadFunc( + WorkerBackingThread* thread, + scoped_refptr main_thread_task_runner) { thread->InitializeOnBackingThread( WorkerBackingThreadStartupData::CreateDefault()); @@ -116,10 +117,11 @@ TEST(DOMWrapperWorldTest, Basic) { retrieved_worlds.clear(); // Start a worker thread and create worlds on that. - std::unique_ptr thread = - WorkerBackingThread::Create("DOMWrapperWorld test thread"); - scoped_refptr main_thread_task_runner = - Platform::Current()->CurrentThread()->GetWebTaskRunner(); + std::unique_ptr thread = WorkerBackingThread::Create( + WebThreadCreationParams(WebThreadType::kTestThread) + .SetThreadName("DOMWrapperWorld test thread")); + scoped_refptr main_thread_task_runner = + Platform::Current()->CurrentThread()->GetTaskRunner(); thread->BackingThread().PostTask( FROM_HERE, CrossThreadBind(&WorkerThreadFunc, CrossThreadUnretained(thread.get()), diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/IDLTypes.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/IDLTypes.h index d05bdd4268..add6d92f2a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/IDLTypes.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/IDLTypes.h @@ -8,6 +8,7 @@ #include #include "bindings/core/v8/IDLTypesBase.h" #include "bindings/core/v8/NativeValueTraits.h" +#include "bindings/core/v8/V8StringResource.h" #include "platform/heap/Handle.h" #include "platform/wtf/Optional.h" #include "platform/wtf/Vector.h" @@ -31,9 +32,19 @@ struct IDLLongLong final : public IDLBaseHelper {}; struct IDLUnsignedLongLong final : public IDLBaseHelper {}; // Strings -struct IDLByteString final : public IDLBaseHelper {}; -struct IDLString final : public IDLBaseHelper {}; -struct IDLUSVString final : public IDLBaseHelper {}; +// The "Base" classes are always templatized and require users to specify how JS +// null and/or undefined are supposed to be handled. +template +struct IDLByteStringBase final : public IDLBaseHelper {}; +template +struct IDLStringBase final : public IDLBaseHelper {}; +template +struct IDLUSVStringBase final : public IDLBaseHelper {}; + +// Define non-template versions of the above for simplicity. +using IDLByteString = IDLByteStringBase; +using IDLString = IDLStringBase; +using IDLUSVString = IDLUSVStringBase; // Double struct IDLDouble final : public IDLBaseHelper {}; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp index 3790f65afd..33d958fb31 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp @@ -44,6 +44,7 @@ #include "core/frame/csp/ContentSecurityPolicy.h" #include "core/html/DocumentNameCollection.h" #include "core/html/HTMLIFrameElement.h" +#include "core/inspector/InspectorTaskRunner.h" #include "core/inspector/MainThreadDebugger.h" #include "core/loader/FrameLoader.h" #include "core/script/Modulator.h" @@ -131,7 +132,7 @@ void LocalWindowProxy::Initialize() { // evaluation is forbiden during creating of snapshot, we should ignore any // inspector interruption to avoid JavaScript execution. InspectorTaskRunner::IgnoreInterruptsScope inspector_ignore_interrupts( - MainThreadDebugger::Instance()->TaskRunner()); + GetFrame()->GetInspectorTaskRunner()); v8::HandleScope handle_scope(GetIsolate()); CreateContext(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h index 85a6acbe54..234eab6ad7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h @@ -169,29 +169,40 @@ struct CORE_EXPORT NativeValueTraits }; // Strings -template <> -struct CORE_EXPORT NativeValueTraits - : public NativeValueTraitsBase { +template +struct NativeValueTraits> + : public NativeValueTraitsBase> { + // http://heycam.github.io/webidl/#es-ByteString static String NativeValue(v8::Isolate* isolate, v8::Local value, ExceptionState& exception_state) { - return ToByteString(isolate, value, exception_state); + V8StringResource string_resource(value); + // 1. Let x be ToString(v) + if (!string_resource.Prepare(isolate, exception_state)) + return String(); + String x = string_resource; + // 2. If the value of any element of x is greater than 255, then throw a + // TypeError. + if (!x.ContainsOnlyLatin1()) { + exception_state.ThrowTypeError("Value is not a valid ByteString."); + return String(); + } + + // 3. Return an IDL ByteString value whose length is the length of x, and + // where the value of each element is the value of the corresponding + // element of x. + // Blink: A ByteString is simply a String with a range constrained per + // the above, so this is the identity operation. + return x; } static String NullValue() { return String(); } }; -template <> -struct CORE_EXPORT NativeValueTraits - : public NativeValueTraitsBase { - static String NativeValue(v8::Isolate* isolate, - v8::Local value, - ExceptionState& exception_state) { - return NativeValue(isolate, value, - exception_state); - } - - template +template +struct NativeValueTraits> + : public NativeValueTraitsBase> { + // https://heycam.github.io/webidl/#es-DOMString static String NativeValue(v8::Isolate* isolate, v8::Local value, ExceptionState& exception_state) { @@ -204,13 +215,20 @@ struct CORE_EXPORT NativeValueTraits static String NullValue() { return String(); } }; -template <> -struct CORE_EXPORT NativeValueTraits - : public NativeValueTraitsBase { +template +struct NativeValueTraits> + : public NativeValueTraitsBase> { + // http://heycam.github.io/webidl/#es-USVString static String NativeValue(v8::Isolate* isolate, v8::Local value, ExceptionState& exception_state) { - return ToUSVString(isolate, value, exception_state); + // 1. Let string be the result of converting V to a DOMString. + V8StringResource string(value); + if (!string.Prepare(isolate, exception_state)) + return String(); + // 2. Return an IDL USVString value that is the result of converting string + // to a sequence of Unicode scalar values. + return ReplaceUnmatchedSurrogates(string); } static String NullValue() { return String(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ReferrerScriptInfo.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ReferrerScriptInfo.h index 85bc6c10c4..d7df300b2c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ReferrerScriptInfo.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ReferrerScriptInfo.h @@ -12,7 +12,7 @@ #include "platform/wtf/text/TextPosition.h" #include "platform/wtf/text/WTFString.h" #include "public/platform/WebURLRequest.h" -#include "services/network/public/interfaces/fetch_api.mojom-blink.h" +#include "services/network/public/mojom/fetch_api.mojom-blink.h" #include "v8/include/v8.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/RejectedPromises.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/RejectedPromises.cpp index dd86e28f92..fd6df0bcc6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/RejectedPromises.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/RejectedPromises.cpp @@ -13,7 +13,6 @@ #include "core/dom/events/EventTarget.h" #include "core/events/PromiseRejectionEvent.h" #include "core/inspector/ThreadDebugger.h" -#include "platform/WebTaskRunner.h" #include "platform/bindings/ScopedPersistent.h" #include "platform/bindings/ScriptState.h" #include "platform/bindings/V8PerIsolateData.h" @@ -148,6 +147,10 @@ class RejectedPromises::Message final { return v8::Local::Cast(value)->HasHandler(); } + ExecutionContext* GetContext() { + return ExecutionContext::From(script_state_); + } + private: Message(ScriptState* script_state, v8::Local promise, @@ -217,10 +220,8 @@ void RejectedPromises::HandlerAdded(v8::PromiseRejectMessage data) { std::unique_ptr& message = reported_as_errors_.at(i); if (!message->IsCollected() && message->HasPromise(data.GetPromise())) { message->MakePromiseStrong(); - Platform::Current() - ->CurrentThread() - ->Scheduler() - ->TimerTaskRunner() + message->GetContext() + ->GetTaskRunner(TaskType::kDOMManipulation) ->PostTask(FROM_HERE, WTF::Bind(&RejectedPromises::RevokeNow, scoped_refptr(this), WTF::Passed(std::move(message)))); @@ -230,16 +231,11 @@ void RejectedPromises::HandlerAdded(v8::PromiseRejectMessage data) { } } -std::unique_ptr -RejectedPromises::CreateMessageQueue() { - return std::make_unique(); -} - void RejectedPromises::Dispose() { if (queue_.IsEmpty()) return; - std::unique_ptr queue = CreateMessageQueue(); + std::unique_ptr queue = std::make_unique(); queue->Swap(queue_); ProcessQueueNow(std::move(queue)); } @@ -248,15 +244,24 @@ void RejectedPromises::ProcessQueue() { if (queue_.IsEmpty()) return; - std::unique_ptr queue = CreateMessageQueue(); - queue->Swap(queue_); - Platform::Current() - ->CurrentThread() - ->Scheduler() - ->TimerTaskRunner() - ->PostTask(FROM_HERE, WTF::Bind(&RejectedPromises::ProcessQueueNow, - scoped_refptr(this), - WTF::Passed(std::move(queue)))); + std::map> queues; + while (!queue_.IsEmpty()) { + std::unique_ptr message = queue_.TakeFirst(); + ExecutionContext* context = message->GetContext(); + if (queues.find(context) == queues.end()) { + queues.emplace(context, std::make_unique()); + } + queues[context]->emplace_back(std::move(message)); + } + + for (auto& kv : queues) { + std::unique_ptr queue = std::make_unique(); + queue->Swap(*kv.second); + kv.first->GetTaskRunner(blink::TaskType::kDOMManipulation) + ->PostTask(FROM_HERE, WTF::Bind(&RejectedPromises::ProcessQueueNow, + scoped_refptr(this), + WTF::Passed(std::move(queue)))); + } } void RejectedPromises::ProcessQueueNow(std::unique_ptr queue) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/RejectedPromises.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/RejectedPromises.h index 54c54fc75b..23a27df030 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/RejectedPromises.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/RejectedPromises.h @@ -47,7 +47,6 @@ class RejectedPromises final : public RefCounted { RejectedPromises(); using MessageQueue = Deque>; - std::unique_ptr CreateMessageQueue(); void ProcessQueueNow(std::unique_ptr); void RevokeNow(std::unique_ptr); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp index c4e7f6ac81..3b920e6e61 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp @@ -134,16 +134,33 @@ v8::Local ScriptController::ExecuteScriptAndReturnValue( v8::Local script; + v8::ScriptCompiler::CompileOptions compile_options; + V8ScriptRunner::ProduceCacheOptions produce_cache_options; + v8::ScriptCompiler::NoCacheReason no_cache_reason; + std::tie(compile_options, produce_cache_options, no_cache_reason) = + V8ScriptRunner::GetCompileOptions(v8_cache_options, source); if (!V8ScriptRunner::CompileScript(ScriptState::From(context), source, - access_control_status, v8_cache_options, - referrer_info) + access_control_status, compile_options, + no_cache_reason, referrer_info) .ToLocal(&script)) return result; - if (!V8ScriptRunner::RunCompiledScript(GetIsolate(), script, - GetFrame()->GetDocument()) - .ToLocal(&result)) + v8::MaybeLocal maybe_result; + if (RuntimeEnabledFeatures::CodeCacheAfterExecuteEnabled()) { + maybe_result = V8ScriptRunner::RunCompiledScript( + GetIsolate(), script, GetFrame()->GetDocument()); + V8ScriptRunner::ProduceCache(GetIsolate(), script, source, + produce_cache_options, compile_options); + } else { + V8ScriptRunner::ProduceCache(GetIsolate(), script, source, + produce_cache_options, compile_options); + maybe_result = V8ScriptRunner::RunCompiledScript( + GetIsolate(), script, GetFrame()->GetDocument()); + } + + if (!maybe_result.ToLocal(&result)) { return result; + } } return result; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp index e6458ef082..1ca48a7ac9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp @@ -139,7 +139,7 @@ HTMLElement* ScriptCustomElementDefinition::HandleCreateElementSyncException( return CustomElement::CreateFailedElement(document, tag_name); } -HTMLElement* ScriptCustomElementDefinition::CreateElementSync( +HTMLElement* ScriptCustomElementDefinition::CreateAutonomousCustomElementSync( Document& document, const QualifiedName& tag_name) { if (!script_state_->ContextIsValid()) @@ -188,6 +188,9 @@ HTMLElement* ScriptCustomElementDefinition::CreateElementSync( return HandleCreateElementSyncException(document, tag_name, isolate, exception_state); } + // 6.1.10. Set result’s namespace prefix to prefix. + if (element->prefix() != tag_name.Prefix()) + element->SetTagNameForCreateElementNS(tag_name); DCHECK_EQ(element->GetCustomElementState(), CustomElementState::kCustom); return ToHTMLElement(element); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.h index 3b9c325208..2de9ee5d2e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.h @@ -46,7 +46,8 @@ class CORE_EXPORT ScriptCustomElementDefinition final v8::Local Constructor() const; - HTMLElement* CreateElementSync(Document&, const QualifiedName&) override; + HTMLElement* CreateAutonomousCustomElementSync(Document&, + const QualifiedName&) override; bool HasConnectedCallback() const override; bool HasDisconnectedCallback() const override; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp index cdc7be3534..15f3c1fed5 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp @@ -506,7 +506,7 @@ ScriptStreamer::ScriptStreamer( Type script_type, ScriptState* script_state, v8::ScriptCompiler::CompileOptions compile_options, - scoped_refptr loading_task_runner) + scoped_refptr loading_task_runner) : pending_script_(script), detached_(false), stream_(nullptr), @@ -568,7 +568,7 @@ void ScriptStreamer::StartStreaming( Type script_type, Settings* settings, ScriptState* script_state, - scoped_refptr loading_task_runner) { + scoped_refptr loading_task_runner) { DCHECK(IsMainThread()); DCHECK(script_state->ContextIsValid()); ScriptResource* resource = ToScriptResource(script->GetResource()); @@ -597,16 +597,9 @@ void ScriptStreamer::StartStreaming( // to arrive: the Content-Length HTTP header is not sent for chunked // downloads. - // Decide what kind of cached data we should produce while streaming. Only - // produce parser cache if the non-streaming compile takes advantage of it. - v8::ScriptCompiler::CompileOptions compile_option = - v8::ScriptCompiler::kNoCompileOptions; - if (settings->GetV8CacheOptions() == kV8CacheOptionsParse) - compile_option = v8::ScriptCompiler::kProduceParserCache; - - ScriptStreamer* streamer = - new ScriptStreamer(script, script_type, script_state, compile_option, - std::move(loading_task_runner)); + ScriptStreamer* streamer = new ScriptStreamer( + script, script_type, script_state, v8::ScriptCompiler::kNoCompileOptions, + std::move(loading_task_runner)); // If this script was ready when streaming began, no callbacks will be // received to populate the data for the ScriptStreamer, so send them now. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h index fce566b858..24d26b86ed 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h @@ -7,8 +7,8 @@ #include +#include "base/single_thread_task_runner.h" #include "core/CoreExport.h" -#include "platform/WebTaskRunner.h" #include "platform/heap/Handle.h" #include "platform/wtf/Noncopyable.h" #include "platform/wtf/text/WTFString.h" @@ -45,7 +45,7 @@ class CORE_EXPORT ScriptStreamer final Type, Settings*, ScriptState*, - scoped_refptr); + scoped_refptr); // Returns false if we cannot stream the given encoding. static bool ConvertEncoding(const char* encoding_name, @@ -97,7 +97,7 @@ class CORE_EXPORT ScriptStreamer final Type, ScriptState*, v8::ScriptCompiler::CompileOptions, - scoped_refptr); + scoped_refptr); void StreamingComplete(); void NotifyFinishedToClient(); @@ -136,7 +136,7 @@ class CORE_EXPORT ScriptStreamer final // Encoding of the streamed script. Saved for sanity checking purposes. v8::ScriptCompiler::StreamedSource::Encoding encoding_; - scoped_refptr loading_task_runner_; + scoped_refptr loading_task_runner_; }; } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp index 812faca28f..31d22ee463 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp @@ -21,7 +21,6 @@ #include "platform/loader/fetch/ResourceLoader.h" #include "platform/loader/fetch/ScriptFetchOptions.h" #include "platform/scheduler/child/web_scheduler.h" -#include "platform/scheduler/child/web_task_runner_impl.h" #include "platform/testing/UnitTestHelpers.h" #include "platform/wtf/text/TextEncoding.h" #include "public/platform/Platform.h" @@ -37,7 +36,7 @@ namespace { class ScriptStreamingTest : public ::testing::Test { public: ScriptStreamingTest() - : loading_task_runner_(scheduler::CreateWebTaskRunnerForTesting()), + : loading_task_runner_(scheduler::GetSingleThreadTaskRunnerForTesting()), dummy_page_holder_(DummyPageHolder::Create(IntSize(800, 600))) { dummy_page_holder_->GetPage().GetSettings().SetScriptEnabled(true); MockScriptElementBase* element = MockScriptElementBase::Create(); @@ -115,7 +114,7 @@ class ScriptStreamingTest : public ::testing::Test { testing::RunPendingTasks(); } - scoped_refptr loading_task_runner_; + scoped_refptr loading_task_runner_; // The PendingScript where we stream from. These don't really // fetch any data outside the test; the test controls the data by calling // ScriptResource::AppendData. @@ -167,9 +166,14 @@ TEST_F(ScriptStreamingTest, CompilingStreamedScript) { EXPECT_TRUE(source_code.Streamer()); v8::TryCatch try_catch(scope.GetIsolate()); v8::Local script; + v8::ScriptCompiler::CompileOptions compile_options; + V8ScriptRunner::ProduceCacheOptions produce_cache_options; + v8::ScriptCompiler::NoCacheReason no_cache_reason; + std::tie(compile_options, produce_cache_options, no_cache_reason) = + V8ScriptRunner::GetCompileOptions(kV8CacheOptionsDefault, source_code); EXPECT_TRUE(V8ScriptRunner::CompileScript( scope.GetScriptState(), source_code, kSharableCrossOrigin, - kV8CacheOptionsDefault, ReferrerScriptInfo()) + compile_options, no_cache_reason, ReferrerScriptInfo()) .ToLocal(&script)); EXPECT_FALSE(try_catch.HasCaught()); } @@ -207,9 +211,14 @@ TEST_F(ScriptStreamingTest, CompilingStreamedScriptWithParseError) { EXPECT_TRUE(source_code.Streamer()); v8::TryCatch try_catch(scope.GetIsolate()); v8::Local script; + v8::ScriptCompiler::CompileOptions compile_options; + V8ScriptRunner::ProduceCacheOptions produce_cache_options; + v8::ScriptCompiler::NoCacheReason no_cache_reason; + std::tie(compile_options, produce_cache_options, no_cache_reason) = + V8ScriptRunner::GetCompileOptions(kV8CacheOptionsDefault, source_code); EXPECT_FALSE(V8ScriptRunner::CompileScript( scope.GetScriptState(), source_code, kSharableCrossOrigin, - kV8CacheOptionsDefault, ReferrerScriptInfo()) + compile_options, no_cache_reason, ReferrerScriptInfo()) .ToLocal(&script)); EXPECT_TRUE(try_catch.HasCaught()); } @@ -359,9 +368,14 @@ TEST_F(ScriptStreamingTest, ScriptsWithSmallFirstChunk) { EXPECT_TRUE(source_code.Streamer()); v8::TryCatch try_catch(scope.GetIsolate()); v8::Local script; + v8::ScriptCompiler::CompileOptions compile_options; + V8ScriptRunner::ProduceCacheOptions produce_cache_options; + v8::ScriptCompiler::NoCacheReason no_cache_reason; + std::tie(compile_options, produce_cache_options, no_cache_reason) = + V8ScriptRunner::GetCompileOptions(kV8CacheOptionsDefault, source_code); EXPECT_TRUE(V8ScriptRunner::CompileScript( scope.GetScriptState(), source_code, kSharableCrossOrigin, - kV8CacheOptionsDefault, ReferrerScriptInfo()) + compile_options, no_cache_reason, ReferrerScriptInfo()) .ToLocal(&script)); EXPECT_FALSE(try_catch.HasCaught()); } @@ -396,9 +410,14 @@ TEST_F(ScriptStreamingTest, EncodingChanges) { EXPECT_TRUE(source_code.Streamer()); v8::TryCatch try_catch(scope.GetIsolate()); v8::Local script; + v8::ScriptCompiler::CompileOptions compile_options; + V8ScriptRunner::ProduceCacheOptions produce_cache_options; + v8::ScriptCompiler::NoCacheReason no_cache_reason; + std::tie(compile_options, produce_cache_options, no_cache_reason) = + V8ScriptRunner::GetCompileOptions(kV8CacheOptionsDefault, source_code); EXPECT_TRUE(V8ScriptRunner::CompileScript( scope.GetScriptState(), source_code, kSharableCrossOrigin, - kV8CacheOptionsDefault, ReferrerScriptInfo()) + compile_options, no_cache_reason, ReferrerScriptInfo()) .ToLocal(&script)); EXPECT_FALSE(try_catch.HasCaught()); } @@ -434,9 +453,14 @@ TEST_F(ScriptStreamingTest, EncodingFromBOM) { EXPECT_TRUE(source_code.Streamer()); v8::TryCatch try_catch(scope.GetIsolate()); v8::Local script; + v8::ScriptCompiler::CompileOptions compile_options; + V8ScriptRunner::ProduceCacheOptions produce_cache_options; + v8::ScriptCompiler::NoCacheReason no_cache_reason; + std::tie(compile_options, produce_cache_options, no_cache_reason) = + V8ScriptRunner::GetCompileOptions(kV8CacheOptionsDefault, source_code); EXPECT_TRUE(V8ScriptRunner::CompileScript( scope.GetScriptState(), source_code, kSharableCrossOrigin, - kV8CacheOptionsDefault, ReferrerScriptInfo()) + compile_options, no_cache_reason, ReferrerScriptInfo()) .ToLocal(&script)); EXPECT_FALSE(try_catch.HasCaught()); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerThread.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerThread.cpp index 309535d09f..2c5ce53ab1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerThread.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerThread.cpp @@ -38,7 +38,7 @@ void ScriptStreamerThread::PostTask(CrossThreadClosure task) { MutexLocker locker(mutex_); DCHECK(!running_task_); running_task_ = true; - PostCrossThreadTask(*PlatformThread().GetWebTaskRunner(), FROM_HERE, + PostCrossThreadTask(*PlatformThread().GetTaskRunner(), FROM_HERE, std::move(task)); } @@ -50,7 +50,8 @@ void ScriptStreamerThread::TaskDone() { WebThread& ScriptStreamerThread::PlatformThread() { if (!IsRunning()) { - thread_ = Platform::Current()->CreateThread("ScriptStreamerThread"); + thread_ = Platform::Current()->CreateThread( + WebThreadCreationParams(WebThreadType::kScriptStreamerThread)); } return *thread_; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableMarkingVisitorTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableMarkingVisitorTest.cpp new file mode 100644 index 0000000000..78da3da92a --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableMarkingVisitorTest.cpp @@ -0,0 +1,535 @@ +// 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 "platform/bindings/ScriptWrappableMarkingVisitor.h" + +#include "bindings/core/v8/ToV8ForCore.h" +#include "bindings/core/v8/V8BindingForTesting.h" +#include "bindings/core/v8/V8GCController.h" +#include "core/testing/DeathAwareScriptWrappable.h" +#include "platform/bindings/TraceWrapperV8Reference.h" +#include "platform/bindings/V8PerIsolateData.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace blink { + +static void PreciselyCollectGarbage() { + ThreadState::Current()->CollectAllGarbage(); +} + +static void RunV8Scavenger(v8::Isolate* isolate) { + V8GCController::CollectGarbage(isolate, true); +} + +static void RunV8FullGc(v8::Isolate* isolate) { + V8GCController::CollectGarbage(isolate, false); +} + +TEST(ScriptWrappableMarkingVisitorTest, + ScriptWrappableMarkingVisitorTracesWrappers) { + V8TestingScope scope; + ScriptWrappableMarkingVisitor* visitor = + V8PerIsolateData::From(scope.GetIsolate()) + ->GetScriptWrappableMarkingVisitor(); + DeathAwareScriptWrappable* target = DeathAwareScriptWrappable::Create(); + DeathAwareScriptWrappable* dependency = DeathAwareScriptWrappable::Create(); + target->SetWrappedDependency(dependency); + + // The graph needs to be set up before starting tracing as otherwise the + // conservative write barrier would trigger. + visitor->TracePrologue(); + + HeapObjectHeader* target_header = HeapObjectHeader::FromPayload(target); + HeapObjectHeader* dependency_header = + HeapObjectHeader::FromPayload(dependency); + + EXPECT_TRUE(visitor->MarkingDeque()->IsEmpty()); + EXPECT_FALSE(target_header->IsWrapperHeaderMarked()); + EXPECT_FALSE(dependency_header->IsWrapperHeaderMarked()); + + std::pair pair = std::make_pair( + const_cast(target->GetWrapperTypeInfo()), target); + visitor->RegisterV8Reference(pair); + EXPECT_EQ(visitor->MarkingDeque()->size(), 1ul); + + visitor->AdvanceTracing( + 0, v8::EmbedderHeapTracer::AdvanceTracingActions( + v8::EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION)); + EXPECT_EQ(visitor->MarkingDeque()->size(), 0ul); + EXPECT_TRUE(target_header->IsWrapperHeaderMarked()); + EXPECT_TRUE(dependency_header->IsWrapperHeaderMarked()); + + visitor->AbortTracing(); +} + +TEST(ScriptWrappableMarkingVisitorTest, + OilpanCollectObjectsNotReachableFromV8) { + V8TestingScope scope; + v8::Isolate* isolate = scope.GetIsolate(); + + { + v8::HandleScope handle_scope(isolate); + DeathAwareScriptWrappable* object = DeathAwareScriptWrappable::Create(); + DeathAwareScriptWrappable::ObserveDeathsOf(object); + + // Creates new V8 wrapper and associates it with global scope + ToV8(object, scope.GetContext()->Global(), isolate); + } + + RunV8Scavenger(isolate); + RunV8FullGc(isolate); + PreciselyCollectGarbage(); + + EXPECT_TRUE(DeathAwareScriptWrappable::HasDied()); +} + +TEST(ScriptWrappableMarkingVisitorTest, + OilpanDoesntCollectObjectsReachableFromV8) { + V8TestingScope scope; + v8::Isolate* isolate = scope.GetIsolate(); + v8::HandleScope handle_scope(isolate); + DeathAwareScriptWrappable* object = DeathAwareScriptWrappable::Create(); + DeathAwareScriptWrappable::ObserveDeathsOf(object); + + // Creates new V8 wrapper and associates it with global scope + ToV8(object, scope.GetContext()->Global(), isolate); + + RunV8Scavenger(isolate); + RunV8FullGc(isolate); + PreciselyCollectGarbage(); + + EXPECT_FALSE(DeathAwareScriptWrappable::HasDied()); +} + +TEST(ScriptWrappableMarkingVisitorTest, V8ReportsLiveObjectsDuringScavenger) { + V8TestingScope scope; + v8::Isolate* isolate = scope.GetIsolate(); + v8::HandleScope handle_scope(isolate); + DeathAwareScriptWrappable* object = DeathAwareScriptWrappable::Create(); + DeathAwareScriptWrappable::ObserveDeathsOf(object); + + v8::Local wrapper = + ToV8(object, scope.GetContext()->Global(), isolate); + EXPECT_TRUE(wrapper->IsObject()); + v8::Local wrapper_object = wrapper->ToObject(); + // V8 collects wrappers with unmodified maps (as they can be recreated + // without loosing any data if needed). We need to create some property on + // wrapper so V8 will not see it as unmodified. + EXPECT_TRUE(wrapper_object->CreateDataProperty(scope.GetContext(), 1, wrapper) + .IsJust()); + + RunV8Scavenger(isolate); + PreciselyCollectGarbage(); + + EXPECT_FALSE(DeathAwareScriptWrappable::HasDied()); +} + +TEST(ScriptWrappableMarkingVisitorTest, V8ReportsLiveObjectsDuringFullGc) { + V8TestingScope scope; + v8::Isolate* isolate = scope.GetIsolate(); + v8::HandleScope handle_scope(isolate); + DeathAwareScriptWrappable* object = DeathAwareScriptWrappable::Create(); + DeathAwareScriptWrappable::ObserveDeathsOf(object); + + ToV8(object, scope.GetContext()->Global(), isolate); + + RunV8Scavenger(isolate); + RunV8FullGc(isolate); + PreciselyCollectGarbage(); + + EXPECT_FALSE(DeathAwareScriptWrappable::HasDied()); +} + +TEST(ScriptWrappableMarkingVisitorTest, OilpanClearsHeadersWhenObjectDied) { + V8TestingScope scope; + + DeathAwareScriptWrappable* object = DeathAwareScriptWrappable::Create(); + ScriptWrappableMarkingVisitor* visitor = + V8PerIsolateData::From(scope.GetIsolate()) + ->GetScriptWrappableMarkingVisitor(); + visitor->TracePrologue(); + auto header = HeapObjectHeader::FromPayload(object); + visitor->HeadersToUnmark()->push_back(header); + + PreciselyCollectGarbage(); + + EXPECT_FALSE(visitor->HeadersToUnmark()->Contains(header)); + visitor->AbortTracing(); +} + +TEST(ScriptWrappableMarkingVisitorTest, + OilpanClearsMarkingDequeWhenObjectDied) { + V8TestingScope scope; + + DeathAwareScriptWrappable* object = DeathAwareScriptWrappable::Create(); + ScriptWrappableMarkingVisitor* visitor = + V8PerIsolateData::From(scope.GetIsolate()) + ->GetScriptWrappableMarkingVisitor(); + visitor->TracePrologue(); + + visitor->TraceWrappersWithManualWriteBarrier(object); + + EXPECT_EQ(visitor->MarkingDeque()->front().RawObjectPointer(), object); + + PreciselyCollectGarbage(); + + EXPECT_EQ(visitor->MarkingDeque()->front().RawObjectPointer(), nullptr); + + visitor->AbortTracing(); +} + +TEST(ScriptWrappableMarkingVisitorTest, + MarkedObjectDoesNothingOnWriteBarrierHitWhenDependencyIsMarkedToo) { + V8TestingScope scope; + + ScriptWrappableMarkingVisitor* visitor = + V8PerIsolateData::From(scope.GetIsolate()) + ->GetScriptWrappableMarkingVisitor(); + visitor->TracePrologue(); + + DeathAwareScriptWrappable* target = DeathAwareScriptWrappable::Create(); + DeathAwareScriptWrappable* dependencies[] = { + DeathAwareScriptWrappable::Create(), DeathAwareScriptWrappable::Create(), + DeathAwareScriptWrappable::Create(), DeathAwareScriptWrappable::Create()}; + + HeapObjectHeader::FromPayload(target)->MarkWrapperHeader(); + for (int i = 0; i < 4; i++) { + HeapObjectHeader::FromPayload(dependencies[i])->MarkWrapperHeader(); + } + + EXPECT_TRUE(visitor->MarkingDeque()->IsEmpty()); + + target->SetWrappedDependency(dependencies[0]); + target->AddWrappedVectorDependency(dependencies[1]); + target->AddWrappedHashMapDependency(dependencies[2], dependencies[3]); + + EXPECT_TRUE(visitor->MarkingDeque()->IsEmpty()); + visitor->AbortTracing(); +} + +TEST(ScriptWrappableMarkingVisitorTest, + MarkedObjectMarksDependencyOnWriteBarrierHitWhenNotMarked) { + V8TestingScope scope; + + ScriptWrappableMarkingVisitor* visitor = + V8PerIsolateData::From(scope.GetIsolate()) + ->GetScriptWrappableMarkingVisitor(); + visitor->TracePrologue(); + + DeathAwareScriptWrappable* target = DeathAwareScriptWrappable::Create(); + DeathAwareScriptWrappable* dependencies[] = { + DeathAwareScriptWrappable::Create(), DeathAwareScriptWrappable::Create(), + DeathAwareScriptWrappable::Create(), DeathAwareScriptWrappable::Create()}; + + HeapObjectHeader::FromPayload(target)->MarkWrapperHeader(); + + EXPECT_TRUE(visitor->MarkingDeque()->IsEmpty()); + + target->SetWrappedDependency(dependencies[0]); + target->AddWrappedVectorDependency(dependencies[1]); + target->AddWrappedHashMapDependency(dependencies[2], dependencies[3]); + + for (int i = 0; i < 4; i++) { + EXPECT_TRUE(visitor->MarkingDequeContains(dependencies[i])); + } + + visitor->AbortTracing(); +} + +namespace { + +class HandleContainer + : public blink::GarbageCollectedFinalized, + blink::TraceWrapperBase { + public: + static HandleContainer* Create() { return new HandleContainer(); } + virtual ~HandleContainer() = default; + + void Trace(blink::Visitor* visitor) {} + void TraceWrappers(const ScriptWrappableVisitor* visitor) const { + visitor->TraceWrappers(handle_.Cast()); + } + + void SetValue(v8::Isolate* isolate, v8::Local string) { + handle_.Set(isolate, string); + } + + private: + HandleContainer() = default; + + TraceWrapperV8Reference handle_; +}; + +class InterceptingScriptWrappableMarkingVisitor + : public blink::ScriptWrappableMarkingVisitor { + public: + InterceptingScriptWrappableMarkingVisitor(v8::Isolate* isolate) + : ScriptWrappableMarkingVisitor(isolate), + marked_wrappers_(new size_t(0)) {} + ~InterceptingScriptWrappableMarkingVisitor() { delete marked_wrappers_; } + + void Visit(const TraceWrapperV8Reference&) const override { + *marked_wrappers_ += 1; + // Do not actually mark this visitor, as this would call into v8, which + // would require executing an actual GC. + } + + size_t NumberOfMarkedWrappers() const { return *marked_wrappers_; } + + void Start() { TracePrologue(); } + + void end() { + // Gracefully terminate tracing. + AdvanceTracing( + 0, + v8::EmbedderHeapTracer::AdvanceTracingActions( + v8::EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION)); + AbortTracing(); + } + + private: + size_t* marked_wrappers_; // Indirection required because of const override. +}; + +class InterceptingScriptWrappableMarkingVisitorScope + : public V8PerIsolateData::TemporaryScriptWrappableVisitorScope { + WTF_MAKE_NONCOPYABLE(InterceptingScriptWrappableMarkingVisitorScope); + STACK_ALLOCATED(); + + public: + InterceptingScriptWrappableMarkingVisitorScope(v8::Isolate* isolate) + : V8PerIsolateData::TemporaryScriptWrappableVisitorScope( + isolate, + std::unique_ptr( + new InterceptingScriptWrappableMarkingVisitor(isolate))) { + Visitor()->Start(); + } + + virtual ~InterceptingScriptWrappableMarkingVisitorScope() { + Visitor()->end(); + } + + InterceptingScriptWrappableMarkingVisitor* Visitor() { + return reinterpret_cast( + CurrentVisitor()); + } +}; + +} // namespace + +TEST(ScriptWrappableMarkingVisitorTest, WriteBarrierOnUnmarkedContainer) { + V8TestingScope scope; + InterceptingScriptWrappableMarkingVisitorScope visitor_scope( + scope.GetIsolate()); + auto* raw_visitor = visitor_scope.Visitor(); + + v8::Local str = + v8::String::NewFromUtf8(scope.GetIsolate(), "teststring", + v8::NewStringType::kNormal, sizeof("teststring")) + .ToLocalChecked(); + HandleContainer* container = HandleContainer::Create(); + CHECK_EQ(0u, raw_visitor->NumberOfMarkedWrappers()); + container->SetValue(scope.GetIsolate(), str); + // The write barrier is conservative and does not check the mark bits of the + // source container. + CHECK_EQ(1u, raw_visitor->NumberOfMarkedWrappers()); +} + +TEST(ScriptWrappableMarkingVisitorTest, WriteBarrierTriggersOnMarkedContainer) { + V8TestingScope scope; + InterceptingScriptWrappableMarkingVisitorScope visitor_scope( + scope.GetIsolate()); + auto* raw_visitor = visitor_scope.Visitor(); + + v8::Local str = + v8::String::NewFromUtf8(scope.GetIsolate(), "teststring", + v8::NewStringType::kNormal, sizeof("teststring")) + .ToLocalChecked(); + HandleContainer* container = HandleContainer::Create(); + HeapObjectHeader::FromPayload(container)->MarkWrapperHeader(); + CHECK_EQ(0u, raw_visitor->NumberOfMarkedWrappers()); + container->SetValue(scope.GetIsolate(), str); + CHECK_EQ(1u, raw_visitor->NumberOfMarkedWrappers()); +} + +TEST(ScriptWrappableMarkingVisitorTest, VtableAtObjectStart) { + // This test makes sure that the subobject v8::EmbedderHeapTracer is placed + // at the start of a ScriptWrappableMarkingVisitor object. We do this to + // mitigate potential problems that could be caused by LTO when passing + // v8::EmbedderHeapTracer across the API boundary. + V8TestingScope scope; + std::unique_ptr visitor( + new ScriptWrappableMarkingVisitor(scope.GetIsolate())); + CHECK_EQ( + static_cast(visitor.get()), + static_cast(dynamic_cast(visitor.get()))); +} + +TEST(ScriptWrappableMarkingVisitor, WriteBarrierForScriptWrappable) { + // Regression test for crbug.com/702490. + V8TestingScope scope; + InterceptingScriptWrappableMarkingVisitorScope visitor_scope( + scope.GetIsolate()); + auto* raw_visitor = visitor_scope.Visitor(); + + // Mark the ScriptWrappable. + DeathAwareScriptWrappable* target = DeathAwareScriptWrappable::Create(); + HeapObjectHeader::FromPayload(target)->MarkWrapperHeader(); + + // Create a 'wrapper' object. + v8::Local t = v8::ObjectTemplate::New(scope.GetIsolate()); + t->SetInternalFieldCount(2); + v8::Local obj = + t->NewInstance(scope.GetContext()).ToLocalChecked(); + + // Upon setting the wrapper we should have executed the write barrier. + CHECK_EQ(0u, raw_visitor->NumberOfMarkedWrappers()); + bool success = + target->SetWrapper(scope.GetIsolate(), target->GetWrapperTypeInfo(), obj); + CHECK(success); + CHECK_EQ(1u, raw_visitor->NumberOfMarkedWrappers()); +} + +TEST(ScriptWrappableMarkingVisitorTest, WriteBarrierOnHeapVectorSwap1) { + V8TestingScope scope; + ScriptWrappableMarkingVisitor* visitor = + V8PerIsolateData::From(scope.GetIsolate()) + ->GetScriptWrappableMarkingVisitor(); + + HeapVector vector1; + DeathAwareScriptWrappable* entry1 = DeathAwareScriptWrappable::Create(); + vector1.push_back(entry1); + HeapVector vector2; + DeathAwareScriptWrappable* entry2 = DeathAwareScriptWrappable::Create(); + vector2.push_back(entry2); + + visitor->TracePrologue(); + + EXPECT_TRUE(visitor->MarkingDeque()->IsEmpty()); + swap(vector1, vector2); + + EXPECT_TRUE(visitor->MarkingDequeContains(entry1)); + EXPECT_TRUE(visitor->MarkingDequeContains(entry2)); + + visitor->AbortTracing(); +} + +TEST(ScriptWrappableMarkingVisitorTest, WriteBarrierOnHeapVectorSwap2) { + V8TestingScope scope; + ScriptWrappableMarkingVisitor* visitor = + V8PerIsolateData::From(scope.GetIsolate()) + ->GetScriptWrappableMarkingVisitor(); + + HeapVector vector1; + DeathAwareScriptWrappable* entry1 = DeathAwareScriptWrappable::Create(); + vector1.push_back(entry1); + HeapVector> vector2; + DeathAwareScriptWrappable* entry2 = DeathAwareScriptWrappable::Create(); + vector2.push_back(entry2); + + visitor->TracePrologue(); + + EXPECT_TRUE(visitor->MarkingDeque()->IsEmpty()); + swap(vector1, vector2); + + // Only entry2 is held alive by TraceWrapperMember, so we only expect this + // barrier to fire. + EXPECT_TRUE(visitor->MarkingDequeContains(entry2)); + + visitor->AbortTracing(); +} + +namespace { + +class Mixin : public GarbageCollectedMixin { + public: + explicit Mixin(DeathAwareScriptWrappable* wrapper_in_mixin) + : wrapper_in_mixin_(wrapper_in_mixin) {} + + void TraceWrappers(const ScriptWrappableVisitor* visitor) const { + visitor->TraceWrappers(wrapper_in_mixin_); + } + + protected: + DeathAwareScriptWrappable::Wrapper wrapper_in_mixin_; +}; + +class ClassWithField { + protected: + int field_; +}; + +class Base : public blink::GarbageCollected, + public blink::TraceWrapperBase, + public ClassWithField, + public Mixin { + USING_GARBAGE_COLLECTED_MIXIN(Base); + + public: + static Base* Create(DeathAwareScriptWrappable* wrapper_in_base, + DeathAwareScriptWrappable* wrapper_in_mixin) { + return new Base(wrapper_in_base, wrapper_in_mixin); + } + + virtual void TraceWrappers(const ScriptWrappableVisitor* visitor) const { + visitor->TraceWrappers(wrapper_in_base_); + Mixin::TraceWrappers(visitor); + } + + protected: + Base(DeathAwareScriptWrappable* wrapper_in_base, + DeathAwareScriptWrappable* wrapper_in_mixin) + : Mixin(wrapper_in_mixin), wrapper_in_base_(wrapper_in_base) { + // Use field_; + field_ = 0; + } + + DeathAwareScriptWrappable::Wrapper wrapper_in_base_; +}; + +} // namespace + +TEST(ScriptWrappableMarkingVisitorTest, MixinTracing) { + V8TestingScope scope; + ScriptWrappableMarkingVisitor* visitor = + V8PerIsolateData::From(scope.GetIsolate()) + ->GetScriptWrappableMarkingVisitor(); + + DeathAwareScriptWrappable* base_wrapper = DeathAwareScriptWrappable::Create(); + DeathAwareScriptWrappable* mixin_wrapper = + DeathAwareScriptWrappable::Create(); + Base* base = Base::Create(base_wrapper, mixin_wrapper); + Mixin* mixin = static_cast(base); + + HeapObjectHeader* base_header = HeapObjectHeader::FromPayload(base); + EXPECT_FALSE(base_header->IsWrapperHeaderMarked()); + + // Make sure that mixin does not point to the object header. + EXPECT_NE(static_cast(base), static_cast(mixin)); + + visitor->TracePrologue(); + + EXPECT_TRUE(visitor->MarkingDeque()->IsEmpty()); + + // TraceWrapperMember itself is not required to live in an Oilpan object. + TraceWrapperMember mixin_handle = mixin; + EXPECT_TRUE(base_header->IsWrapperHeaderMarked()); + EXPECT_FALSE(visitor->MarkingDeque()->IsEmpty()); + EXPECT_TRUE(visitor->MarkingDequeContains(mixin)); + + visitor->AdvanceTracing( + 0, v8::EmbedderHeapTracer::AdvanceTracingActions( + v8::EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION)); + EXPECT_EQ(visitor->MarkingDeque()->size(), 0ul); + EXPECT_TRUE(base_header->IsWrapperHeaderMarked()); + EXPECT_TRUE( + HeapObjectHeader::FromPayload(base_wrapper)->IsWrapperHeaderMarked()); + EXPECT_TRUE( + HeapObjectHeader::FromPayload(mixin_wrapper)->IsWrapperHeaderMarked()); + + mixin_handle = nullptr; + visitor->AbortTracing(); +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.cpp index 5bebdb8862..351c9d8d6a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.cpp @@ -503,51 +503,10 @@ double ToRestrictedDouble(v8::Isolate* isolate, return number_value; } -String ToByteString(v8::Isolate* isolate, - v8::Local value, - ExceptionState& exception_state) { - // Handle null default value. - if (value.IsEmpty()) - return String(); - - // From the Web IDL spec: http://heycam.github.io/webidl/#es-ByteString - if (value.IsEmpty()) - return String(); - - // 1. Let x be ToString(v) - v8::Local string_object; - if (value->IsString()) { - string_object = value.As(); - } else { - v8::TryCatch block(isolate); - if (!value->ToString(isolate->GetCurrentContext()) - .ToLocal(&string_object)) { - exception_state.RethrowV8Exception(block.Exception()); - return String(); - } - } - - String x = ToCoreString(string_object); - - // 2. If the value of any element of x is greater than 255, then throw a - // TypeError. - if (!x.ContainsOnlyLatin1()) { - exception_state.ThrowTypeError("Value is not a valid ByteString."); - return String(); - } - - // 3. Return an IDL ByteString value whose length is the length of x, and - // where the value of each element is the value of the corresponding - // element of x. - // Blink: A ByteString is simply a String with a range constrained per the - // above, so this is the identity operation. - return x; -} - static bool HasUnmatchedSurrogates(const String& string) { // By definition, 8-bit strings are confined to the Latin-1 code page and // have no surrogates, matched or otherwise. - if (string.Is8Bit()) + if (string.IsEmpty() || string.Is8Bit()) return false; const UChar* characters = string.Characters16(); @@ -571,7 +530,7 @@ static bool HasUnmatchedSurrogates(const String& string) { } // Replace unmatched surrogates with REPLACEMENT CHARACTER U+FFFD. -static String ReplaceUnmatchedSurrogates(const String& string) { +String ReplaceUnmatchedSurrogates(const String& string) { // This roughly implements http://heycam.github.io/webidl/#dfn-obtain-unicode // but since Blink strings are 16-bits internally, the output is simply // re-encoded to UTF-16. @@ -646,32 +605,6 @@ static String ReplaceUnmatchedSurrogates(const String& string) { return u.ToString(); } -String ToUSVString(v8::Isolate* isolate, - v8::Local value, - ExceptionState& exception_state) { - // http://heycam.github.io/webidl/#es-USVString - if (value.IsEmpty()) - return String(); - - v8::Local string_object; - if (value->IsString()) { - string_object = value.As(); - } else { - v8::TryCatch block(isolate); - if (!value->ToString(isolate->GetCurrentContext()) - .ToLocal(&string_object)) { - exception_state.RethrowV8Exception(block.Exception()); - return String(); - } - } - - // USVString is identical to DOMString except that "convert a - // DOMString to a sequence of Unicode characters" is used subsequently - // when converting to an IDL value - String x = ToCoreString(string_object); - return ReplaceUnmatchedSurrogates(x); -} - XPathNSResolver* ToXPathNSResolver(ScriptState* script_state, v8::Local value) { XPathNSResolver* resolver = nullptr; @@ -807,6 +740,8 @@ v8::Local ToV8Context(LocalFrame* frame, DOMWrapperWorld& world) { v8::Local ToV8ContextEvenIfDetached(LocalFrame* frame, DOMWrapperWorld& world) { + // TODO(yukishiino): this method probably should not force context creation, + // but it does through WindowProxy() call. DCHECK(frame); return frame->WindowProxy(world)->ContextIfInitialized(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.h index 61079058bf..0987798f42 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8BindingForCore.h @@ -73,6 +73,16 @@ class LocalDOMWindow; class LocalFrame; class XPathNSResolver; +// Determines how a V8 -> C++ union conversion should be performed: when the +// JavaScript value being converted is either undefined or null, kNullable will +// stop the conversion attempt and the union's IsNull() method will return true. +// If kNotNullable is used, the other conversion steps listed in +// https://heycam.github.io/webidl/#es-union will continue being attempted. +enum class UnionTypeConversionMode { + kNullable, + kNotNullable, +}; + template inline void V8SetReturnValue(const CallbackInfo& callback_info, DOMWindow* impl) { @@ -364,17 +374,6 @@ CORE_EXPORT float ToRestrictedFloat(v8::Isolate*, v8::Local, ExceptionState&); -// Converts a value to a String, throwing if any code unit is outside 0-255. -CORE_EXPORT String ToByteString(v8::Isolate*, - v8::Local, - ExceptionState&); - -// Converts a value to a String, replacing unmatched UTF-16 surrogates with -// replacement characters. -CORE_EXPORT String ToUSVString(v8::Isolate*, - v8::Local, - ExceptionState&); - inline double ToCoreDate(v8::Isolate* isolate, v8::Local object, ExceptionState& exception_state) { @@ -387,6 +386,9 @@ inline double ToCoreDate(v8::Isolate* isolate, return object.As()->ValueOf(); } +// USVString conversion helper. +CORE_EXPORT String ReplaceUnmatchedSurrogates(const String&); + // FIXME: Remove the special casing for XPathNSResolver. XPathNSResolver* ToXPathNSResolver(ScriptState*, v8::Local); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8CacheOptions.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8CacheOptions.h index 6d0c8779bd..2ce154eb72 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8CacheOptions.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8CacheOptions.h @@ -36,7 +36,6 @@ namespace blink { enum V8CacheOptions { kV8CacheOptionsDefault, // Use whatever the current default is. kV8CacheOptionsNone, // V8 caching turned off. - kV8CacheOptionsParse, // Use parser caching. kV8CacheOptionsCode, // Use code caching. // Generate the code cache in the first load. kV8CacheOptionsCodeWithoutHeatCheck, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp index 0779861752..dd5bf5c536 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp @@ -168,8 +168,8 @@ bool V8ContextSnapshot::InstallConditionalFeatures( v8::Local prototype = interface->Get(context, prototype_str) .ToLocalChecked() .As(); - V8Window::install_runtime_enabled_features_function_( - isolate, world, window_wrapper, prototype, interface); + V8Window::InstallRuntimeEnabledFeatures(isolate, world, window_wrapper, + prototype, interface); type->InstallConditionalFeatures(context, world, window_wrapper, prototype, interface, type->domTemplate(isolate, world)); @@ -405,7 +405,7 @@ void V8ContextSnapshot::EnsureInterfaceTemplatesForWorld( const WrapperTypeInfo* wrapper_type_info = snapshot_interface.wrapper_type_info; v8::Local interface_template = - v8::FunctionTemplate::FromSnapshot(isolate, index_offset + i) + isolate->GetDataFromSnapshotOnce(index_offset + i) .ToLocalChecked(); snapshot_interface.install_function(isolate, world, interface_template); CHECK(!interface_template.IsEmpty()); @@ -466,7 +466,7 @@ void V8ContextSnapshot::TakeSnapshotForWorld(v8::SnapshotCreator* creator, } for (auto& interface_template : interface_templates) { - creator->AddTemplate(interface_template); + creator->AddData(interface_template); } creator->AddContext(context, SerializeInternalField); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8EmbedderGraphBuilder.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8EmbedderGraphBuilder.cpp new file mode 100644 index 0000000000..ecf0a5af7d --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8EmbedderGraphBuilder.cpp @@ -0,0 +1,130 @@ +// Copyright 2018 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/V8EmbedderGraphBuilder.h" + +#include "bindings/core/v8/ActiveScriptWrappable.h" +#include "bindings/core/v8/V8Node.h" +#include "platform/bindings/DOMWrapperMap.h" +#include "platform/bindings/ScriptWrappable.h" +#include "platform/bindings/ScriptWrappableVisitor.h" +#include "platform/bindings/WrapperTypeInfo.h" + +namespace blink { + +V8EmbedderGraphBuilder::V8EmbedderGraphBuilder(v8::Isolate* isolate, + Graph* graph) + : isolate_(isolate), current_parent_(nullptr), graph_(graph) {} + +void V8EmbedderGraphBuilder::BuildEmbedderGraphCallback( + v8::Isolate* isolate, + v8::EmbedderGraph* graph) { + V8EmbedderGraphBuilder builder(isolate, graph); + builder.BuildEmbedderGraph(); +} + +void V8EmbedderGraphBuilder::BuildEmbedderGraph() { + isolate_->VisitHandlesWithClassIds(this); + VisitPendingActivities(); + VisitTransitiveClosure(); +} + +void V8EmbedderGraphBuilder::VisitPersistentHandle( + v8::Persistent* value, + uint16_t class_id) { + if (class_id != WrapperTypeInfo::kNodeClassId && + class_id != WrapperTypeInfo::kObjectClassId) + return; + v8::Local v8_value = v8::Local::New( + isolate_, v8::Persistent::Cast(*value)); + ScriptWrappable* traceable = ToScriptWrappable(v8_value); + if (traceable) { + // Add v8_value => traceable edge. + Graph::Node* graph_node = + GraphNode(traceable, traceable->NameInHeapSnapshot()); + graph_->AddEdge(GraphNode(v8_value), graph_node); + // Visit traceable members. This will also add traceable => v8_value edge. + ParentScope parent(this, graph_node); + traceable->TraceWrappers(this); + } +} + +void V8EmbedderGraphBuilder::Visit( + const TraceWrapperV8Reference& traced_wrapper) const { + const v8::PersistentBase* value = &traced_wrapper.Get(); + // Add an edge from the current parent to the V8 object. + v8::Local v8_value = v8::Local::New(isolate_, *value); + if (!v8_value.IsEmpty()) { + graph_->AddEdge(current_parent_, GraphNode(v8_value)); + } +} + +void V8EmbedderGraphBuilder::Visit( + const WrapperDescriptor& wrapper_descriptor) const { + // Add an edge from the current parent to this object. + // Also push the object to the worklist in order to process its members. + const void* traceable = wrapper_descriptor.traceable; + Graph::Node* graph_node = + GraphNode(traceable, wrapper_descriptor.name_callback(traceable)); + graph_->AddEdge(current_parent_, graph_node); + if (!visited_.Contains(traceable)) { + visited_.insert(traceable); + worklist_.push_back(ToWorklistItem(graph_node, wrapper_descriptor)); + } +} + +void V8EmbedderGraphBuilder::Visit(DOMWrapperMap* wrapper_map, + const ScriptWrappable* key) const { + // Add an edge from the current parent to the V8 object. + v8::Local v8_value = + wrapper_map->NewLocal(isolate_, const_cast(key)); + if (!v8_value.IsEmpty()) + graph_->AddEdge(current_parent_, GraphNode(v8_value)); +} + +v8::EmbedderGraph::Node* V8EmbedderGraphBuilder::GraphNode( + const v8::Local& value) const { + return graph_->V8Node(value); +} + +v8::EmbedderGraph::Node* V8EmbedderGraphBuilder::GraphNode( + Traceable traceable, + const char* name) const { + auto iter = graph_node_.find(traceable); + if (iter != graph_node_.end()) + return iter->value; + // Ownership of the new node is transferred to the graph_. + // graph_node_.at(tracable) is valid for all BuildEmbedderGraph execution. + auto node = + graph_->AddNode(std::unique_ptr(new EmbedderNode(name))); + graph_node_.insert(traceable, node); + return node; +} + +void V8EmbedderGraphBuilder::VisitPendingActivities() { + // Ownership of the new node is transferred to the graph_. + Graph::Node* root = graph_->AddNode( + std::unique_ptr(new EmbedderRootNode("Pending activities"))); + ParentScope parent(this, root); + ActiveScriptWrappableBase::TraceActiveScriptWrappables(isolate_, this); +} + +V8EmbedderGraphBuilder::WorklistItem V8EmbedderGraphBuilder::ToWorklistItem( + Graph::Node* node, + const WrapperDescriptor& wrapper_descriptor) const { + return {node, wrapper_descriptor.traceable, + wrapper_descriptor.trace_wrappers_callback}; +} + +void V8EmbedderGraphBuilder::VisitTransitiveClosure() { + // Depth-first search. + while (!worklist_.empty()) { + auto item = worklist_.back(); + worklist_.pop_back(); + ParentScope parent(this, item.node); + item.trace_wrappers_callback(this, item.traceable); + } +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8EmbedderGraphBuilder.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8EmbedderGraphBuilder.h new file mode 100644 index 0000000000..9ab8f8992f --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8EmbedderGraphBuilder.h @@ -0,0 +1,95 @@ +// Copyright 2018 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 V8EmbedderGraphBuilder_h +#define V8EmbedderGraphBuilder_h + +#include "platform/bindings/ScriptWrappableVisitor.h" +#include "v8/include/v8-profiler.h" +#include "v8/include/v8.h" + +namespace blink { + +class V8EmbedderGraphBuilder : public ScriptWrappableVisitor, + public v8::PersistentHandleVisitor { + public: + using Traceable = const void*; + using Graph = v8::EmbedderGraph; + + V8EmbedderGraphBuilder(v8::Isolate*, Graph*); + + static void BuildEmbedderGraphCallback(v8::Isolate*, v8::EmbedderGraph*); + void BuildEmbedderGraph(); + + // v8::PersistentHandleVisitor override. + void VisitPersistentHandle(v8::Persistent*, + uint16_t class_id) override; + + protected: + // ScriptWrappableVisitor overrides. + void Visit(const TraceWrapperV8Reference&) const final; + void Visit(const WrapperDescriptor&) const final; + void Visit(DOMWrapperMap*, + const ScriptWrappable*) const final; + + private: + class EmbedderNode : public Graph::Node { + public: + explicit EmbedderNode(const char* name) : name_(name) {} + + // Graph::Node overrides. + const char* Name() override { return name_; } + size_t SizeInBytes() override { return 0; } + + private: + const char* name_; + }; + + class EmbedderRootNode : public EmbedderNode { + public: + explicit EmbedderRootNode(const char* name) : EmbedderNode(name) {} + // Graph::Node override. + bool IsRootNode() { return true; } + }; + + class ParentScope { + STACK_ALLOCATED(); + + public: + ParentScope(V8EmbedderGraphBuilder* visitor, Graph::Node* parent) + : visitor_(visitor) { + DCHECK_EQ(visitor->current_parent_, nullptr); + visitor->current_parent_ = parent; + } + ~ParentScope() { visitor_->current_parent_ = nullptr; } + + private: + V8EmbedderGraphBuilder* visitor_; + }; + + struct WorklistItem { + Graph::Node* node; + Traceable traceable; + TraceWrappersCallback trace_wrappers_callback; + }; + + WorklistItem ToWorklistItem(Graph::Node*, const WrapperDescriptor&) const; + + Graph::Node* GraphNode(const v8::Local&) const; + Graph::Node* GraphNode(Traceable, const char* name) const; + + void VisitPendingActivities(); + void VisitTransitiveClosure(); + + v8::Isolate* isolate_; + Graph::Node* current_parent_; + mutable Graph* graph_; + mutable HashSet visited_; + mutable HashMap graph_node_; + mutable Deque worklist_; +}; + +} // namespace blink + +#endif // V8EmbedderGraphBuilder_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp index 7dc184828c..5298acc8f4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp @@ -46,7 +46,7 @@ #include "core/html/imports/HTMLImportsController.h" #include "core/inspector/InspectorTraceEvents.h" #include "platform/Histogram.h" -#include "platform/bindings/ScriptWrappableVisitor.h" +#include "platform/bindings/ScriptWrappableMarkingVisitor.h" #include "platform/bindings/WrapperTypeInfo.h" #include "platform/instrumentation/tracing/TraceEvent.h" #include "platform/wtf/allocator/Partitions.h" @@ -123,11 +123,13 @@ class MinorGCUnmodifiedWrapperVisitor : public v8::PersistentHandleVisitor { v8::Isolate* isolate_; }; -class HeapSnaphotWrapperVisitor : public ScriptWrappableVisitor, +// TODO(ulan): Refactor this class to derive from ScriptWrappableVisitor +// and not rely on marking infrastructure. +class HeapSnaphotWrapperVisitor : public ScriptWrappableMarkingVisitor, public v8::PersistentHandleVisitor { public: explicit HeapSnaphotWrapperVisitor(v8::Isolate* isolate) - : ScriptWrappableVisitor(isolate), + : ScriptWrappableMarkingVisitor(isolate), current_parent_(nullptr), only_trace_single_level_(false), first_script_wrappable_traced_(false) { @@ -193,15 +195,7 @@ class HeapSnaphotWrapperVisitor : public ScriptWrappableVisitor, // ScriptWrappableVisitor overrides. - void MarkWrappersInAllWorlds( - const ScriptWrappable* traceable) const override { - // Only mark the main thread wrapper as we cannot properly intercept - // DOMWrapperMap::markWrapper. This means that edges from the isolated - // worlds are missing in the snapshot. - traceable->MarkWrapper(this); - } - - void DispatchTraceWrappers(const TraceWrapperBase* traceable) const override { + void DispatchTraceWrappers(const TraceWrapperBase* traceable) const final { if (!only_trace_single_level_ || !traceable->IsScriptWrappable() || !reinterpret_cast(traceable) ->ContainsWrapper() || @@ -214,13 +208,21 @@ class HeapSnaphotWrapperVisitor : public ScriptWrappableVisitor, protected: // ScriptWrappableVisitor override. void Visit( - const TraceWrapperV8Reference& traced_wrapper) const override { + const TraceWrapperV8Reference& traced_wrapper) const final { const v8::PersistentBase* value = &traced_wrapper.Get(); if (current_parent_ && current_parent_ != value) edges_.push_back(std::make_pair(current_parent_, value)); found_v8_wrappers_.insert(value); } + void Visit(DOMWrapperMap*, + const ScriptWrappable* key) const final { + // The found_v8_wrappers are PersistentBase pointers. We only mark the + // main world wrapper as we cannot properly record DOMWrapperMap values. + // This means that edges from the isolated worlds are missing in the + // snapshot. This will be fixed with crbug.com/749490. + } + private: inline v8::PersistentBase* PersistentForWrappable( ScriptWrappable* wrappable) { @@ -235,7 +237,7 @@ class HeapSnaphotWrapperVisitor : public ScriptWrappableVisitor, current_parent_ = PersistentForWrappable(traceable); TracePrologue(); - traceable->GetWrapperTypeInfo()->TraceWrappers(this, traceable); + traceable->TraceWrappers(this); AdvanceTracing( 0, v8::EmbedderHeapTracer::AdvanceTracingActions( @@ -492,8 +494,8 @@ class DOMWrapperTracer : public v8::PersistentHandleVisitor { const v8::Persistent& wrapper = v8::Persistent::Cast(*value); - if (ScriptWrappable* script_wrappable = ToScriptWrappable(wrapper)) - ToWrapperTypeInfo(wrapper)->Trace(visitor_, script_wrappable); + ScriptWrappable* script_wrappable = ToScriptWrappable(wrapper); + visitor_->Trace(script_wrappable); } private: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.cpp index 516e16cfd8..8ca3b3f29b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.cpp @@ -34,6 +34,7 @@ #include "platform/Histogram.h" #include "platform/MemoryCoordinator.h" #include "platform/bindings/V8PerIsolateData.h" +#include "platform/scheduler/child/web_scheduler.h" #include "platform/wtf/ProcessMetrics.h" #include "platform/wtf/StdLibExtras.h" #include "platform/wtf/Time.h" @@ -54,7 +55,10 @@ size_t GetMemoryUsage() { namespace blink { V8GCForContextDispose::V8GCForContextDispose() - : pseudo_idle_timer_(this, &V8GCForContextDispose::PseudoIdleTimerFired) { + : pseudo_idle_timer_( + Platform::Current()->MainThread()->Scheduler()->V8TaskRunner(), + this, + &V8GCForContextDispose::PseudoIdleTimerFired) { Reset(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.h index b9fd253a54..df074a11f1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.h @@ -51,7 +51,7 @@ class V8GCForContextDispose { void PseudoIdleTimerFired(TimerBase*); void Reset(); - Timer pseudo_idle_timer_; + TaskRunnerTimer pseudo_idle_timer_; bool did_dispose_context_for_main_frame_; double last_context_disposal_time_; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8HTMLConstructor.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8HTMLConstructor.cpp index d58533221b..93ef535fa6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8HTMLConstructor.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8HTMLConstructor.cpp @@ -47,8 +47,7 @@ void V8HTMLConstructor::HtmlConstructor( // 2. If NewTarget is equal to the active function object, then // throw a TypeError and abort these steps. v8::Local active_function_object = - script_state->PerContextData()->ConstructorForType( - &V8HTMLElement::wrapperTypeInfo); + script_state->PerContextData()->ConstructorForType(&wrapper_type_info); if (new_target == active_function_object) { V8ThrowException::ThrowTypeError(isolate, "Illegal constructor"); return; @@ -110,8 +109,7 @@ void V8HTMLConstructor::HtmlConstructor( if (!prototype->IsObject()) { if (V8PerContextData* per_context_data = V8PerContextData::From( new_target.As()->CreationContext())) { - prototype = - per_context_data->PrototypeForType(&V8HTMLElement::wrapperTypeInfo); + prototype = per_context_data->PrototypeForType(&wrapper_type_info); } else { V8ThrowException::ThrowError(isolate, "The context has been destroyed"); return; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp index c5a1eccdcc..ff61ebc230 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp @@ -40,10 +40,12 @@ #include "bindings/core/v8/V8BindingForCore.h" #include "bindings/core/v8/V8ContextSnapshot.h" #include "bindings/core/v8/V8DOMException.h" +#include "bindings/core/v8/V8EmbedderGraphBuilder.h" #include "bindings/core/v8/V8ErrorEvent.h" #include "bindings/core/v8/V8ErrorHandler.h" #include "bindings/core/v8/V8GCController.h" #include "bindings/core/v8/V8IdleTaskRunner.h" +#include "bindings/core/v8/V8WasmResponseExtensions.h" #include "bindings/core/v8/WorkerOrWorkletScriptController.h" #include "core/dom/Document.h" #include "core/dom/ExecutionContext.h" @@ -55,7 +57,7 @@ #include "core/workers/WorkerGlobalScope.h" #include "platform/EventDispatchForbiddenScope.h" #include "platform/bindings/DOMWrapperWorld.h" -#include "platform/bindings/ScriptWrappableVisitor.h" +#include "platform/bindings/ScriptWrappableMarkingVisitor.h" #include "platform/bindings/V8PerContextData.h" #include "platform/bindings/V8PrivateProperty.h" #include "platform/instrumentation/tracing/TraceEvent.h" @@ -70,7 +72,6 @@ #include "platform/wtf/typed_arrays/ArrayBufferContents.h" #include "public/platform/Platform.h" #include "public/platform/WebThread.h" -#include "v8/include/v8-debug.h" #include "v8/include/v8-profiler.h" namespace blink { @@ -254,8 +255,7 @@ static void PromiseRejectHandler(v8::PromiseRejectMessage data, DCHECK_EQ(data.GetEvent(), v8::kPromiseRejectWithNoHandler); - v8::Local promise = data.GetPromise(); - v8::Isolate* isolate = promise->GetIsolate(); + v8::Isolate* isolate = script_state->GetIsolate(); ExecutionContext* context = ExecutionContext::From(script_state); v8::Local exception = data.GetValue(); @@ -515,12 +515,12 @@ static void HostGetImportMetaProperties(v8::Local context, static void InitializeV8Common(v8::Isolate* isolate) { isolate->AddGCPrologueCallback(V8GCController::GcPrologue); isolate->AddGCEpilogueCallback(V8GCController::GcEpilogue); - std::unique_ptr visitor( - new ScriptWrappableVisitor(isolate)); - V8PerIsolateData::From(isolate)->SetScriptWrappableVisitor( + std::unique_ptr visitor( + new ScriptWrappableMarkingVisitor(isolate)); + V8PerIsolateData::From(isolate)->SetScriptWrappableMarkingVisitor( std::move(visitor)); isolate->SetEmbedderHeapTracer( - V8PerIsolateData::From(isolate)->GetScriptWrappableVisitor()); + V8PerIsolateData::From(isolate)->GetScriptWrappableMarkingVisitor()); isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped); @@ -537,6 +537,8 @@ static void InitializeV8Common(v8::Isolate* isolate) { } V8ContextSnapshot::EnsureInterfaceTemplates(isolate); + + WasmResponseExtensions::Initialize(isolate); } namespace { @@ -558,38 +560,6 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { void Free(void* data, size_t size) override { WTF::ArrayBufferContents::FreeMemory(data); } - - void* Reserve(size_t length) override { - return WTF::ArrayBufferContents::ReserveMemory(length); - } - - void Free(void* data, size_t length, AllocationMode mode) override { - switch (mode) { - case AllocationMode::kNormal: - Free(data, length); - return; - case AllocationMode::kReservation: - WTF::ArrayBufferContents::ReleaseReservedMemory(data, length); - return; - default: - NOTREACHED(); - } - } - - void SetProtection(void* data, - size_t length, - Protection protection) override { - switch (protection) { - case Protection::kNoAccess: - CHECK(WTF::SetSystemPagesAccess(data, length, WTF::PageInaccessible)); - return; - case Protection::kReadWrite: - CHECK(WTF::SetSystemPagesAccess(data, length, WTF::PageReadWrite)); - return; - default: - NOTREACHED(); - } - } }; } // namespace @@ -643,9 +613,8 @@ void V8Initializer::InitializeMainThread(const intptr_t* reference_table) { #endif // USE_V8_CONTEXT_SNAPSHOT v8::Isolate* isolate = V8PerIsolateData::Initialize( - scheduler - ? scheduler->V8TaskRunner() - : Platform::Current()->CurrentThread()->GetSingleThreadTaskRunner(), + scheduler ? scheduler->V8TaskRunner() + : Platform::Current()->CurrentThread()->GetTaskRunner(), v8_context_snapshot_mode); InitializeV8Common(isolate); @@ -674,13 +643,15 @@ void V8Initializer::InitializeMainThread(const intptr_t* reference_table) { profiler->SetWrapperClassInfoProvider( WrapperTypeInfo::kNodeClassId, &RetainedDOMInfo::CreateRetainedDOMInfo); profiler->SetGetRetainerInfosCallback(&V8GCController::GetRetainerInfos); + profiler->SetBuildEmbedderGraphCallback( + &V8EmbedderGraphBuilder::BuildEmbedderGraphCallback); } DCHECK(ThreadState::MainThreadState()); ThreadState::MainThreadState()->RegisterTraceDOMWrappers( isolate, V8GCController::TraceDOMWrappers, - ScriptWrappableVisitor::InvalidateDeadObjectsInMarkingDeque, - ScriptWrappableVisitor::PerformCleanup); + ScriptWrappableMarkingVisitor::InvalidateDeadObjectsInMarkingDeque, + ScriptWrappableMarkingVisitor::PerformCleanup); V8PerIsolateData::From(isolate)->SetThreadDebugger( std::make_unique(isolate)); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8LazyEventListener.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8LazyEventListener.cpp index c180d8efc3..c1462e44de 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8LazyEventListener.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8LazyEventListener.cpp @@ -190,10 +190,10 @@ void V8LazyEventListener::CompileScript(ScriptState* script_state, // exception because we're not running any program code. Instead, // it should be reported as an ErrorEvent. v8::TryCatch block(GetIsolate()); - wrapped_function = v8::ScriptCompiler::CompileFunctionInContext( - GetIsolate(), &source, script_state->GetContext(), 1, ¶meter_name, - 3, scopes); - if (block.HasCaught()) { + v8::MaybeLocal maybe_result = + v8::ScriptCompiler::CompileFunctionInContext( + script_state->GetContext(), &source, 1, ¶meter_name, 3, scopes); + if (!maybe_result.ToLocal(&wrapped_function)) { was_compilation_failed_ = true; // Do not compile the same code twice. FireErrorEvent(script_state->GetContext(), execution_context, block.Message()); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ObjectParser.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ObjectParser.cpp new file mode 100644 index 0000000000..f9c2b9f6f5 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ObjectParser.cpp @@ -0,0 +1,148 @@ +// Copyright 2018 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/V8ObjectParser.h" + +#include "bindings/core/v8/ExceptionState.h" +#include "bindings/core/v8/IDLTypes.h" +#include "bindings/core/v8/NativeValueTraitsImpl.h" +#include "platform/bindings/V8Binding.h" + +namespace blink { + +bool V8ObjectParser::ParsePrototype(v8::Local context, + v8::Local constructor, + v8::Local* prototype, + ExceptionState* exception_state) { + v8::Isolate* isolate = context->GetIsolate(); + v8::TryCatch block(isolate); + + v8::Local prototype_value; + if (!constructor->Get(context, V8AtomicString(isolate, "prototype")) + .ToLocal(&prototype_value)) { + exception_state->RethrowV8Exception(block.Exception()); + return false; + } + + if (prototype_value->IsNullOrUndefined()) { + exception_state->ThrowTypeError( + "The 'prototype' object on the class does not exist."); + return false; + } + + if (!prototype_value->IsObject()) { + exception_state->ThrowTypeError( + "The 'prototype' property on the class is not an object."); + return false; + } + + *prototype = v8::Local::Cast(prototype_value); + return true; +} + +bool V8ObjectParser::ParseFunction(v8::Local context, + v8::Local prototype, + const AtomicString function_name, + v8::Local* function, + ExceptionState* exception_state) { + v8::Isolate* isolate = context->GetIsolate(); + v8::TryCatch block(isolate); + + v8::Local function_value; + if (!prototype->Get(context, V8AtomicString(isolate, function_name)) + .ToLocal(&function_value)) { + exception_state->RethrowV8Exception(block.Exception()); + return false; + } + + if (function_value->IsNullOrUndefined()) { + exception_state->ThrowTypeError( + "The '" + function_name + + "' property on the prototype does not exist."); + return false; + } + + if (!function_value->IsFunction()) { + exception_state->ThrowTypeError( + "The '" + function_name + + "' property on the prototype is not a function."); + return false; + } + + *function = v8::Local::Cast(function_value); + return true; +} + +bool V8ObjectParser::ParseGeneratorFunction(v8::Local context, + v8::Local prototype, + const AtomicString function_name, + v8::Local* function, + ExceptionState* exception_state) { + v8::Isolate* isolate = context->GetIsolate(); + v8::TryCatch block(isolate); + + v8::Local function_value; + if (!prototype->Get(context, V8AtomicString(isolate, function_name)) + .ToLocal(&function_value)) { + exception_state->RethrowV8Exception(block.Exception()); + return false; + } + + if (function_value->IsNullOrUndefined()) { + exception_state->ThrowTypeError( + "The '" + function_name + + "' property on the prototype does not exist."); + return false; + } + + if (!function_value->IsGeneratorFunction()) { + exception_state->ThrowTypeError( + "The '" + function_name + + "' property on the prototype is not a generator function."); + return false; + } + + *function = v8::Local::Cast(function_value); + return true; +} + +bool V8ObjectParser::ParseCSSPropertyList( + v8::Local context, + v8::Local constructor, + const AtomicString list_name, + Vector* native_properties, + Vector* custom_properties, + ExceptionState* exception_state) { + v8::Isolate* isolate = context->GetIsolate(); + v8::TryCatch block(isolate); + + v8::Local list_value; + if (!constructor->Get(context, V8AtomicString(isolate, list_name)) + .ToLocal(&list_value)) { + exception_state->RethrowV8Exception(block.Exception()); + return false; + } + + if (!list_value->IsNullOrUndefined()) { + Vector properties = + NativeValueTraits>::NativeValue( + isolate, list_value, *exception_state); + + if (exception_state->HadException()) + return false; + + for (const auto& property : properties) { + CSSPropertyID property_id = cssPropertyID(property); + if (property_id == CSSPropertyVariable) { + custom_properties->push_back(std::move(property)); + } else if (property_id != CSSPropertyInvalid) { + native_properties->push_back(std::move(property_id)); + } + } + } + + return true; +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ObjectParser.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ObjectParser.h new file mode 100644 index 0000000000..40b90d2acb --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ObjectParser.h @@ -0,0 +1,59 @@ +// Copyright 2018 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 V8ObjectParser_h +#define V8ObjectParser_h + +#include "core/CSSPropertyNames.h" +#include "core/CoreExport.h" +#include "platform/wtf/Allocator.h" +#include "platform/wtf/text/AtomicString.h" +#include "v8/include/v8.h" + +namespace blink { + +class ExceptionState; + +class CORE_EXPORT V8ObjectParser final { + STATIC_ONLY(V8ObjectParser); + + public: + // Retrieves the prototype object off a class constructor function. Returns + // true if the prototype exists, and is an object. + static bool ParsePrototype(v8::Local, + v8::Local constructor, + v8::Local* prototype, + ExceptionState*); + + // Retrieves the specified function off a class prototype. Returns true if + // the object exists, and is a function. + static bool ParseFunction(v8::Local, + v8::Local prototype, + const AtomicString function_name, + v8::Local*, + ExceptionState*); + + // Retrieves the specified generator function off a class prototype. Returns + // true if the object exists, and is a generator function. + static bool ParseGeneratorFunction(v8::Local, + v8::Local prototype, + const AtomicString function_name, + v8::Local*, + ExceptionState*); + + // Retrieves and parses a CSS property list off the class constructor + // function. Returns true if the list exists, and successfully converted to a + // Vector type. It does not fail if the list contains invalid CSS + // properties, to ensure forward compatibility. + static bool ParseCSSPropertyList(v8::Local, + v8::Local constructor, + const AtomicString list_name, + Vector* native_properties, + Vector* custom_properties, + ExceptionState*); +}; + +} // namespace blink + +#endif // V8ObjectParser_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp index add5cc7dc2..657bb9e577 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp @@ -112,6 +112,19 @@ v8::MaybeLocal CompileWithoutOptions( no_cache_reason); } +// Compile a script eagerly so that we can produce full code cache. +v8::MaybeLocal CompileEager( + v8::ScriptCompiler::NoCacheReason no_cache_reason, + v8::Isolate* isolate, + v8::Local code, + v8::ScriptOrigin origin, + InspectorCompileScriptEvent::V8CacheResult*) { + v8::ScriptCompiler::Source source(code, origin); + return v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &source, + v8::ScriptCompiler::kEagerCompile, + no_cache_reason); +} + // Compile a script, and consume a V8 cache that was generated previously. static v8::MaybeLocal CompileAndConsumeCache( CachedMetadataHandler* cache_handler, @@ -121,8 +134,7 @@ static v8::MaybeLocal CompileAndConsumeCache( v8::Local code, v8::ScriptOrigin origin, InspectorCompileScriptEvent::V8CacheResult* cache_result) { - DCHECK(consume_options == v8::ScriptCompiler::kConsumeParserCache || - consume_options == v8::ScriptCompiler::kConsumeCodeCache); + DCHECK(consume_options == v8::ScriptCompiler::kConsumeCodeCache); const char* data = cached_metadata->Data(); int length = cached_metadata->size(); v8::ScriptCompiler::CachedData* cached_data = @@ -142,54 +154,9 @@ static v8::MaybeLocal CompileAndConsumeCache( return script; } -// Compile a script, and produce a V8 cache for future use. -v8::MaybeLocal CompileAndProduceCache( - CachedMetadataHandler* cache_handler, - uint32_t tag, - v8::ScriptCompiler::CompileOptions produce_options, - CachedMetadataHandler::CacheType cache_type, - v8::Isolate* isolate, - v8::Local code, - v8::ScriptOrigin origin, - InspectorCompileScriptEvent::V8CacheResult* cache_result) { - DCHECK(produce_options == v8::ScriptCompiler::kProduceParserCache || - produce_options == v8::ScriptCompiler::kProduceCodeCache || - produce_options == v8::ScriptCompiler::kProduceFullCodeCache); - v8::ScriptCompiler::Source source(code, origin); - v8::MaybeLocal script = v8::ScriptCompiler::Compile( - isolate->GetCurrentContext(), &source, produce_options); - const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData(); - if (cached_data) { - const char* data = reinterpret_cast(cached_data->data); - int length = cached_data->length; - if (length > 1024) { - // Omit histogram samples for small cache data to avoid outliers. - int cache_size_ratio = static_cast(100.0 * length / code->Length()); - DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, - code_cache_size_histogram, - ("V8.CodeCacheSizeRatio", 0, 10000, 50)); - code_cache_size_histogram.Count(cache_size_ratio); - } - cache_handler->ClearCachedMetadata(CachedMetadataHandler::kCacheLocally); - cache_handler->SetCachedMetadata(tag, data, length, cache_type); - } - - if (cache_result) { - cache_result->produce_result = WTF::make_optional( - InspectorCompileScriptEvent::V8CacheResult::ProduceResult( - produce_options, cached_data ? cached_data->length : 0)); - } - return script; -} - -enum CacheTagKind { - kCacheTagParser = 0, - kCacheTagCode = 1, - kCacheTagTimeStamp = 3, - kCacheTagLast -}; +enum CacheTagKind { kCacheTagCode = 0, kCacheTagTimeStamp = 1, kCacheTagLast }; -static const int kCacheTagKindSize = 2; +static const int kCacheTagKindSize = 1; uint32_t CacheTag(CacheTagKind kind, const String& encoding) { static_assert((1 << kCacheTagKindSize) >= kCacheTagLast, @@ -210,9 +177,9 @@ uint32_t CacheTag(CacheTagKind kind, const String& encoding) { bool IsResourceHotForCaching(CachedMetadataHandler* cache_handler, int hot_hours) { const double cache_within_seconds = hot_hours * 60 * 60; - uint32_t tag = CacheTag(kCacheTagTimeStamp, cache_handler->Encoding()); scoped_refptr cached_metadata = - cache_handler->GetCachedMetadata(tag); + cache_handler->GetCachedMetadata( + V8ScriptRunner::TagForTimeStamp(cache_handler)); if (!cached_metadata) return false; double time_stamp; @@ -222,10 +189,9 @@ bool IsResourceHotForCaching(CachedMetadataHandler* cache_handler, return (WTF::CurrentTime() - time_stamp) < cache_within_seconds; } -// Final compile call for a streamed compilation. Most decisions have already -// been made, but we need to write back data into the cache. +// Final compile call for a streamed compilation. v8::MaybeLocal PostStreamCompile( - V8CacheOptions cache_options, + v8::ScriptCompiler::CompileOptions compile_options, CachedMetadataHandler* cache_handler, ScriptStreamer* streamer, v8::Isolate* isolate, @@ -234,47 +200,6 @@ v8::MaybeLocal PostStreamCompile( InspectorCompileScriptEvent::V8CacheResult* cache_result) { v8::MaybeLocal script = v8::ScriptCompiler::Compile( isolate->GetCurrentContext(), streamer->Source(), code, origin); - - if (!cache_handler) - return script; - - // If the non-streaming compiler uses the parser cache, retrieve and store - // the cache data. If the code cache uses time stamp as heuristic, set that - // time stamp. - switch (cache_options) { - case kV8CacheOptionsParse: { - const v8::ScriptCompiler::CachedData* new_cached_data = - streamer->Source()->GetCachedData(); - if (!new_cached_data) - break; - CachedMetadataHandler::CacheType cache_type = - CachedMetadataHandler::kSendToPlatform; - cache_handler->ClearCachedMetadata(cache_type); - cache_handler->SetCachedMetadata( - V8ScriptRunner::TagForParserCache(cache_handler), - reinterpret_cast(new_cached_data->data), - new_cached_data->length, cache_type); - if (cache_result) { - cache_result->produce_result = WTF::make_optional( - InspectorCompileScriptEvent::V8CacheResult::ProduceResult( - v8::ScriptCompiler::kProduceParserCache, - new_cached_data->length)); - } - break; - } - - case kV8CacheOptionsDefault: - case kV8CacheOptionsCode: - V8ScriptRunner::SetCacheTimeStamp(cache_handler); - break; - - case kV8CacheOptionsCodeWithoutHeatCheck: - case kV8CacheOptionsFullCodeWithoutHeatCheck: - // Currently WithoutHeatCheck doesn't support streaming. - NOTREACHED(); - case kV8CacheOptionsNone: - break; - } return script; } @@ -285,80 +210,132 @@ typedef base::OnceCallback( InspectorCompileScriptEvent::V8CacheResult*)> CompileFn; -// Select a compile function from any of the above, mainly depending on -// cacheOptions. +// Select a compile function from any of the above depending on compile_options. static CompileFn SelectCompileFunction( - V8CacheOptions cache_options, + v8::ScriptCompiler::CompileOptions compile_options, CachedMetadataHandler* cache_handler, - v8::Local code, - v8::ScriptCompiler::NoCacheReason no_handler_reason) { + v8::ScriptCompiler::NoCacheReason no_cache_reason) { + switch (compile_options) { + case v8::ScriptCompiler::kNoCompileOptions: + return WTF::Bind(CompileWithoutOptions, no_cache_reason); + case v8::ScriptCompiler::kEagerCompile: + return WTF::Bind(CompileEager, no_cache_reason); + case v8::ScriptCompiler::kConsumeCodeCache: { + uint32_t code_cache_tag = V8ScriptRunner::TagForCodeCache(cache_handler); + scoped_refptr code_cache = + cache_handler->GetCachedMetadata(code_cache_tag); + DCHECK(code_cache); + return WTF::Bind(CompileAndConsumeCache, WrapPersistent(cache_handler), + std::move(code_cache), + v8::ScriptCompiler::kConsumeCodeCache); + } + case v8::ScriptCompiler::kProduceCodeCache: + case v8::ScriptCompiler::kProduceFullCodeCache: + case v8::ScriptCompiler::kProduceParserCache: + case v8::ScriptCompiler::kConsumeParserCache: + NOTREACHED(); + } + + // All switch branches should return and we should never get here. + // But some compilers aren't sure, hence this default. + NOTREACHED(); + return WTF::Bind(CompileWithoutOptions, v8::ScriptCompiler::kNoCacheNoReason); +} + +// Select a compile function for a streaming compile. +CompileFn SelectCompileFunction( + v8::ScriptCompiler::CompileOptions compile_options, + CachedMetadataHandler* cache_handler, + ScriptStreamer* streamer) { + DCHECK(streamer->IsFinished()); + DCHECK(!streamer->StreamingSuppressed()); + + // Streaming compilation may involve use of code cache. + // TODO(leszeks): Add compile timer to streaming compilation. + return WTF::Bind(PostStreamCompile, compile_options, + WrapPersistent(cache_handler), WrapPersistent(streamer)); +} +} // namespace + +std::tuple +V8ScriptRunner::GetCompileOptions(V8CacheOptions cache_options, + const ScriptSourceCode& source) { static const int kMinimalCodeLength = 1024; static const int kHotHours = 72; + v8::ScriptCompiler::NoCacheReason no_cache_reason; - // Caching is not available in this case. + switch (source.SourceLocationType()) { + case ScriptSourceLocationType::kInline: + no_cache_reason = v8::ScriptCompiler::kNoCacheBecauseInlineScript; + break; + case ScriptSourceLocationType::kInlineInsideDocumentWrite: + no_cache_reason = v8::ScriptCompiler::kNoCacheBecauseInDocumentWrite; + break; + case ScriptSourceLocationType::kExternalFile: + no_cache_reason = + v8::ScriptCompiler::kNoCacheBecauseResourceWithNoCacheHandler; + break; + // TODO(leszeks): Possibly differentiate between the other kinds of script + // origin also. + default: + no_cache_reason = v8::ScriptCompiler::kNoCacheBecauseNoResource; + break; + } + + CachedMetadataHandler* cache_handler = source.CacheHandler(); if (!cache_handler) { - return WTF::Bind(CompileWithoutOptions, no_handler_reason); + return std::make_tuple(v8::ScriptCompiler::kNoCompileOptions, + ProduceCacheOptions::kNoProduceCache, + no_cache_reason); } if (cache_options == kV8CacheOptionsNone) { - return WTF::Bind(CompileWithoutOptions, - v8::ScriptCompiler::kNoCacheBecauseCachingDisabled); + no_cache_reason = v8::ScriptCompiler::kNoCacheBecauseCachingDisabled; + return std::make_tuple(v8::ScriptCompiler::kNoCompileOptions, + ProduceCacheOptions::kNoProduceCache, + no_cache_reason); } - // Caching is not worthwhile for small scripts. Do not use caching - // unless explicitly expected, indicated by the cache option. - if (code->Length() < kMinimalCodeLength) { - return WTF::Bind(CompileWithoutOptions, - v8::ScriptCompiler::kNoCacheBecauseScriptTooSmall); + if (source.Source().length() < kMinimalCodeLength) { + no_cache_reason = v8::ScriptCompiler::kNoCacheBecauseScriptTooSmall; + return std::make_tuple(v8::ScriptCompiler::kNoCompileOptions, + ProduceCacheOptions::kNoProduceCache, + no_cache_reason); } - // The cacheOptions will guide our strategy: - switch (cache_options) { - case kV8CacheOptionsParse: { - // Use parser-cache; in-memory only. - uint32_t parser_tag = V8ScriptRunner::TagForParserCache(cache_handler); - scoped_refptr parser_cache( - cache_handler->GetCachedMetadata(parser_tag)); - if (parser_cache) { - return WTF::Bind(CompileAndConsumeCache, WrapPersistent(cache_handler), - std::move(parser_cache), - v8::ScriptCompiler::kConsumeParserCache); - } - return WTF::Bind(CompileAndProduceCache, WrapPersistent(cache_handler), - parser_tag, v8::ScriptCompiler::kProduceParserCache, - CachedMetadataHandler::kCacheLocally); - } + uint32_t code_cache_tag = V8ScriptRunner::TagForCodeCache(cache_handler); + scoped_refptr code_cache = + cache_handler->GetCachedMetadata(code_cache_tag); + if (code_cache) { + return std::make_tuple(v8::ScriptCompiler::kConsumeCodeCache, + ProduceCacheOptions::kNoProduceCache, + no_cache_reason); + } + switch (cache_options) { case kV8CacheOptionsDefault: case kV8CacheOptionsCode: - case kV8CacheOptionsCodeWithoutHeatCheck: - case kV8CacheOptionsFullCodeWithoutHeatCheck: { - uint32_t code_cache_tag = V8ScriptRunner::TagForCodeCache(cache_handler); - // Use code caching for recently seen resources. - // Use compression depending on the cache option. - scoped_refptr code_cache = - cache_handler->GetCachedMetadata(code_cache_tag); - if (code_cache) { - return WTF::Bind(CompileAndConsumeCache, WrapPersistent(cache_handler), - std::move(code_cache), - v8::ScriptCompiler::kConsumeCodeCache); - } - if (cache_options != kV8CacheOptionsCodeWithoutHeatCheck && - cache_options != kV8CacheOptionsFullCodeWithoutHeatCheck && - !IsResourceHotForCaching(cache_handler, kHotHours)) { - V8ScriptRunner::SetCacheTimeStamp(cache_handler); - return WTF::Bind(CompileWithoutOptions, - v8::ScriptCompiler::kNoCacheBecauseCacheTooCold); + if (!IsResourceHotForCaching(cache_handler, kHotHours)) { + return std::make_tuple(v8::ScriptCompiler::kNoCompileOptions, + ProduceCacheOptions::kSetTimeStamp, + v8::ScriptCompiler::kNoCacheBecauseCacheTooCold); } - return WTF::Bind( - CompileAndProduceCache, WrapPersistent(cache_handler), code_cache_tag, - (cache_options == kV8CacheOptionsFullCodeWithoutHeatCheck) - ? v8::ScriptCompiler::kProduceFullCodeCache - : v8::ScriptCompiler::kProduceCodeCache, - CachedMetadataHandler::kSendToPlatform); - break; - } - + return std::make_tuple( + v8::ScriptCompiler::kNoCompileOptions, + ProduceCacheOptions::kProduceCodeCache, + v8::ScriptCompiler::kNoCacheBecauseDeferredProduceCodeCache); + case kV8CacheOptionsCodeWithoutHeatCheck: + return std::make_tuple( + v8::ScriptCompiler::kNoCompileOptions, + ProduceCacheOptions::kProduceCodeCache, + v8::ScriptCompiler::kNoCacheBecauseDeferredProduceCodeCache); + case kV8CacheOptionsFullCodeWithoutHeatCheck: + return std::make_tuple( + v8::ScriptCompiler::kEagerCompile, + ProduceCacheOptions::kProduceCodeCache, + v8::ScriptCompiler::kNoCacheBecauseDeferredProduceCodeCache); case kV8CacheOptionsNone: // Shouldn't happen, as this is handled above. // Case is here so that compiler can check all cases are handled. @@ -369,28 +346,17 @@ static CompileFn SelectCompileFunction( // All switch branches should return and we should never get here. // But some compilers aren't sure, hence this default. NOTREACHED(); - return WTF::Bind(CompileWithoutOptions, v8::ScriptCompiler::kNoCacheNoReason); -} - -// Select a compile function for a streaming compile. -CompileFn SelectCompileFunction(V8CacheOptions cache_options, - CachedMetadataHandler* cache_handler, - ScriptStreamer* streamer) { - DCHECK(streamer->IsFinished()); - DCHECK(!streamer->StreamingSuppressed()); - - // Streaming compilation may involve use of code cache. - // TODO(leszeks): Add compile timer to streaming compilation. - return WTF::Bind(PostStreamCompile, cache_options, - WrapPersistent(cache_handler), WrapPersistent(streamer)); + return std::make_tuple(v8::ScriptCompiler::kNoCompileOptions, + ProduceCacheOptions::kNoProduceCache, + v8::ScriptCompiler::kNoCacheNoReason); } -} // namespace v8::MaybeLocal V8ScriptRunner::CompileScript( ScriptState* script_state, const ScriptSourceCode& source, AccessControlStatus access_control_status, - V8CacheOptions cache_options, + v8::ScriptCompiler::CompileOptions compile_options, + v8::ScriptCompiler::NoCacheReason no_cache_reason, const ReferrerScriptInfo& referrer_info) { v8::Isolate* isolate = script_state->GetIsolate(); if (source.Source().length() >= v8::String::kMaxLength) { @@ -424,29 +390,10 @@ v8::MaybeLocal V8ScriptRunner::CompileScript( v8::False(isolate), // is_module referrer_info.ToV8HostDefinedOptions(isolate)); - v8::ScriptCompiler::NoCacheReason no_handler_reason; - switch (source.SourceLocationType()) { - case ScriptSourceLocationType::kInline: - no_handler_reason = v8::ScriptCompiler::kNoCacheBecauseInlineScript; - break; - case ScriptSourceLocationType::kInlineInsideDocumentWrite: - no_handler_reason = v8::ScriptCompiler::kNoCacheBecauseInDocumentWrite; - break; - case ScriptSourceLocationType::kExternalFile: - no_handler_reason = - v8::ScriptCompiler::kNoCacheBecauseResourceWithNoCacheHandler; - break; - // TODO(leszeks): Possibly differentiate between the other kinds of script - // origin also. - default: - no_handler_reason = v8::ScriptCompiler::kNoCacheBecauseNoResource; - break; - } - CompileFn compile_fn = - streamer ? SelectCompileFunction(cache_options, cache_handler, streamer) - : SelectCompileFunction(cache_options, cache_handler, code, - no_handler_reason); + streamer ? SelectCompileFunction(compile_options, cache_handler, streamer) + : SelectCompileFunction(compile_options, cache_handler, + no_cache_reason); if (!*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(kTraceEventCategoryGroup)) return std::move(compile_fn).Run(isolate, code, origin, nullptr); @@ -522,19 +469,86 @@ v8::MaybeLocal V8ScriptRunner::RunCompiledScript( return result; } +void V8ScriptRunner::ProduceCache( + v8::Isolate* isolate, + v8::Local script, + const ScriptSourceCode& source, + ProduceCacheOptions produce_cache_options, + v8::ScriptCompiler::CompileOptions compile_options) { + TRACE_EVENT0("v8", "v8.run"); + RuntimeCallStatsScopedTracer rcs_scoped_tracer(isolate); + RUNTIME_CALL_TIMER_SCOPE(isolate, RuntimeCallStats::CounterId::kV8); + + switch (produce_cache_options) { + case ProduceCacheOptions::kSetTimeStamp: + V8ScriptRunner::SetCacheTimeStamp(source.CacheHandler()); + break; + case ProduceCacheOptions::kProduceCodeCache: { + constexpr const char* kTraceEventCategoryGroup = "v8,devtools.timeline"; + TRACE_EVENT_BEGIN1(kTraceEventCategoryGroup, "v8.compile", "fileName", + source.Url().GetString().Utf8()); + + std::unique_ptr cached_data( + v8::ScriptCompiler::CreateCodeCache( + script->GetUnboundScript(), V8String(isolate, source.Source()))); + if (cached_data) { + const char* data = reinterpret_cast(cached_data->data); + int length = cached_data->length; + if (length > 1024) { + // Omit histogram samples for small cache data to avoid outliers. + int cache_size_ratio = + static_cast(100.0 * length / source.Source().length()); + DEFINE_THREAD_SAFE_STATIC_LOCAL( + CustomCountHistogram, code_cache_size_histogram, + ("V8.CodeCacheSizeRatio", 0, 10000, 50)); + code_cache_size_histogram.Count(cache_size_ratio); + } + CachedMetadataHandler* cache_handler = source.CacheHandler(); + cache_handler->ClearCachedMetadata( + CachedMetadataHandler::kCacheLocally); + cache_handler->SetCachedMetadata( + V8ScriptRunner::TagForCodeCache(cache_handler), data, length, + CachedMetadataHandler::kSendToPlatform); + } + + TRACE_EVENT_END1( + kTraceEventCategoryGroup, "v8.compile", "data", + InspectorCompileScriptEvent::Data( + source.Url().GetString(), source.StartPosition(), + InspectorCompileScriptEvent::V8CacheResult( + InspectorCompileScriptEvent::V8CacheResult::ProduceResult( + compile_options, cached_data ? cached_data->length : 0), + Optional()), + source.Streamer())); + break; + } + case ProduceCacheOptions::kNoProduceCache: + break; + } +} + v8::MaybeLocal V8ScriptRunner::CompileAndRunInternalScript( v8::Isolate* isolate, ScriptState* script_state, const ScriptSourceCode& source_code) { DCHECK_EQ(isolate, script_state->GetIsolate()); + v8::ScriptCompiler::CompileOptions compile_options; + V8ScriptRunner::ProduceCacheOptions produce_cache_options; + v8::ScriptCompiler::NoCacheReason no_cache_reason; + std::tie(compile_options, produce_cache_options, no_cache_reason) = + V8ScriptRunner::GetCompileOptions(kV8CacheOptionsDefault, source_code); + // Currently internal scripts don't have cache handlers. So we should not + // produce cache for them. + DCHECK_EQ(produce_cache_options, ProduceCacheOptions::kNoProduceCache); v8::Local script; // Use default ScriptReferrerInfo here: // - nonce: empty for internal script, and // - parser_state: always "not parser inserted" for internal scripts. - if (!V8ScriptRunner::CompileScript( - script_state, source_code, kSharableCrossOrigin, - kV8CacheOptionsDefault, ReferrerScriptInfo()) + if (!V8ScriptRunner::CompileScript(script_state, source_code, + kSharableCrossOrigin, compile_options, + no_cache_reason, ReferrerScriptInfo()) .ToLocal(&script)) return v8::MaybeLocal(); @@ -669,22 +683,20 @@ v8::MaybeLocal V8ScriptRunner::EvaluateModule( return module->Evaluate(context); } -uint32_t V8ScriptRunner::TagForParserCache( - CachedMetadataHandler* cache_handler) { - return CacheTag(kCacheTagParser, cache_handler->Encoding()); -} - uint32_t V8ScriptRunner::TagForCodeCache(CachedMetadataHandler* cache_handler) { return CacheTag(kCacheTagCode, cache_handler->Encoding()); } +uint32_t V8ScriptRunner::TagForTimeStamp(CachedMetadataHandler* cache_handler) { + return CacheTag(kCacheTagTimeStamp, cache_handler->Encoding()); +} + // Store a timestamp to the cache as hint. void V8ScriptRunner::SetCacheTimeStamp(CachedMetadataHandler* cache_handler) { double now = WTF::CurrentTime(); - uint32_t tag = CacheTag(kCacheTagTimeStamp, cache_handler->Encoding()); cache_handler->ClearCachedMetadata(CachedMetadataHandler::kCacheLocally); - cache_handler->SetCachedMetadata(tag, reinterpret_cast(&now), - sizeof(now), + cache_handler->SetCachedMetadata(TagForTimeStamp(cache_handler), + reinterpret_cast(&now), sizeof(now), CachedMetadataHandler::kSendToPlatform); } @@ -749,13 +761,14 @@ scoped_refptr V8ScriptRunner::GenerateFullCodeCache( v8::Local code(V8String(isolate, script_string)); v8::ScriptCompiler::Source source(code, origin); scoped_refptr cached_metadata; - const v8::ScriptCompiler::CachedData* cached_data = nullptr; + std::unique_ptr cached_data; v8::Local unbound_script; if (v8::ScriptCompiler::CompileUnboundScript( - isolate, &source, v8::ScriptCompiler::kProduceFullCodeCache) + isolate, &source, v8::ScriptCompiler::kEagerCompile) .ToLocal(&unbound_script)) { - cached_data = source.GetCachedData(); + cached_data.reset( + v8::ScriptCompiler::CreateCodeCache(unbound_script, code)); if (cached_data && cached_data->length) { cached_metadata = CachedMetadata::Create( CacheTag(kCacheTagCode, encoding.GetName()), @@ -770,7 +783,7 @@ scoped_refptr V8ScriptRunner::GenerateFullCodeCache( file_name, TextPosition(), InspectorCompileScriptEvent::V8CacheResult( InspectorCompileScriptEvent::V8CacheResult::ProduceResult( - v8::ScriptCompiler::kProduceFullCodeCache, + v8::ScriptCompiler::kEagerCompile, cached_data ? cached_data->length : 0), Optional< InspectorCompileScriptEvent::V8CacheResult::ConsumeResult>()), @@ -781,7 +794,6 @@ scoped_refptr V8ScriptRunner::GenerateFullCodeCache( STATIC_ASSERT_ENUM(WebSettings::kV8CacheOptionsDefault, kV8CacheOptionsDefault); STATIC_ASSERT_ENUM(WebSettings::kV8CacheOptionsNone, kV8CacheOptionsNone); -STATIC_ASSERT_ENUM(WebSettings::kV8CacheOptionsParse, kV8CacheOptionsParse); STATIC_ASSERT_ENUM(WebSettings::kV8CacheOptionsCode, kV8CacheOptionsCode); } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h index a370fc45c8..660bf59676 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h @@ -61,14 +61,22 @@ class CORE_EXPORT V8ScriptRunner final { kNotOpaque, }; + enum class ProduceCacheOptions { + kNoProduceCache, + kSetTimeStamp, + kProduceCodeCache, + }; + // For the following methods, the caller sites have to hold // a HandleScope and a ContextScope. // CachedMetadataHandler is set when metadata caching is supported. - static v8::MaybeLocal CompileScript(ScriptState*, - const ScriptSourceCode&, - AccessControlStatus, - V8CacheOptions, - const ReferrerScriptInfo&); + static v8::MaybeLocal CompileScript( + ScriptState*, + const ScriptSourceCode&, + AccessControlStatus, + v8::ScriptCompiler::CompileOptions, + v8::ScriptCompiler::NoCacheReason, + const ReferrerScriptInfo&); static v8::MaybeLocal CompileModule(v8::Isolate*, const String& source, const String& file_name, @@ -107,6 +115,17 @@ class CORE_EXPORT V8ScriptRunner final { v8::Local, v8::Local); + static std::tuple + GetCompileOptions(V8CacheOptions, const ScriptSourceCode&); + + static void ProduceCache(v8::Isolate*, + v8::Local, + const ScriptSourceCode&, + ProduceCacheOptions, + v8::ScriptCompiler::CompileOptions); + // Only to be used from ScriptModule::ReportException(). static void ReportExceptionForModule(v8::Isolate*, v8::Local exception, @@ -115,6 +134,7 @@ class CORE_EXPORT V8ScriptRunner final { static uint32_t TagForParserCache(CachedMetadataHandler*); static uint32_t TagForCodeCache(CachedMetadataHandler*); + static uint32_t TagForTimeStamp(CachedMetadataHandler*); static void SetCacheTimeStamp(CachedMetadataHandler*); // Utilities for calling functions added to the V8 extras binding object. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunnerTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunnerTest.cpp index 3b4c6779cf..c36ee37b3e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunnerTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunnerTest.cpp @@ -42,23 +42,54 @@ class V8ScriptRunnerTest : public ::testing::Test { KURL Url() const { return KURL(WTF::String::Format("http://bla.com/bla%d", counter_)); } - unsigned TagForParserCache(CachedMetadataHandler* cache_handler) const { - return V8ScriptRunner::TagForParserCache(cache_handler); - } unsigned TagForCodeCache(CachedMetadataHandler* cache_handler) const { return V8ScriptRunner::TagForCodeCache(cache_handler); } + unsigned TagForTimeStamp(CachedMetadataHandler* cache_handler) const { + return V8ScriptRunner::TagForTimeStamp(cache_handler); + } void SetCacheTimeStamp(CachedMetadataHandler* cache_handler) { V8ScriptRunner::SetCacheTimeStamp(cache_handler); } - bool CompileScript(ScriptState* script_state, + bool CompileScript(v8::Isolate* isolate, + ScriptState* script_state, const ScriptSourceCode& source_code, V8CacheOptions cache_options) { - return !V8ScriptRunner::CompileScript(script_state, source_code, - kNotSharableCrossOrigin, - cache_options, ReferrerScriptInfo()) - .IsEmpty(); + v8::ScriptCompiler::CompileOptions compile_options; + V8ScriptRunner::ProduceCacheOptions produce_cache_options; + v8::ScriptCompiler::NoCacheReason no_cache_reason; + std::tie(compile_options, produce_cache_options, no_cache_reason) = + V8ScriptRunner::GetCompileOptions(cache_options, source_code); + v8::MaybeLocal compiled_script = V8ScriptRunner::CompileScript( + script_state, source_code, kNotSharableCrossOrigin, compile_options, + no_cache_reason, ReferrerScriptInfo()); + if (compiled_script.IsEmpty()) { + return false; + } + V8ScriptRunner::ProduceCache(isolate, compiled_script.ToLocalChecked(), + source_code, produce_cache_options, + compile_options); + return true; + } + + bool CompileScript( + v8::Isolate* isolate, + ScriptState* script_state, + const ScriptSourceCode& source_code, + v8::ScriptCompiler::CompileOptions compile_options, + v8::ScriptCompiler::NoCacheReason no_cache_reason, + V8ScriptRunner::ProduceCacheOptions produce_cache_options) { + v8::MaybeLocal compiled_script = V8ScriptRunner::CompileScript( + script_state, source_code, kNotSharableCrossOrigin, compile_options, + no_cache_reason, ReferrerScriptInfo()); + if (compiled_script.IsEmpty()) { + return false; + } + V8ScriptRunner::ProduceCache(isolate, compiled_script.ToLocalChecked(), + source_code, produce_cache_options, + compile_options); + return true; } ScriptResource* CreateEmptyResource() { @@ -86,12 +117,10 @@ TEST_F(V8ScriptRunnerTest, resourcelessShouldPass) { V8TestingScope scope; ScriptSourceCode source_code(Code(), ScriptSourceLocationType::kInternal, nullptr /* cache_handler */, Url()); - EXPECT_TRUE( - CompileScript(scope.GetScriptState(), source_code, kV8CacheOptionsNone)); - EXPECT_TRUE( - CompileScript(scope.GetScriptState(), source_code, kV8CacheOptionsParse)); - EXPECT_TRUE( - CompileScript(scope.GetScriptState(), source_code, kV8CacheOptionsCode)); + EXPECT_TRUE(CompileScript(scope.GetIsolate(), scope.GetScriptState(), + source_code, kV8CacheOptionsNone)); + EXPECT_TRUE(CompileScript(scope.GetIsolate(), scope.GetScriptState(), + source_code, kV8CacheOptionsCode)); } TEST_F(V8ScriptRunnerTest, emptyResourceDoesNotHaveCacheHandler) { @@ -99,40 +128,84 @@ TEST_F(V8ScriptRunnerTest, emptyResourceDoesNotHaveCacheHandler) { EXPECT_FALSE(resource->CacheHandler()); } -TEST_F(V8ScriptRunnerTest, parseOption) { +TEST_F(V8ScriptRunnerTest, codeOption) { V8TestingScope scope; ScriptSourceCode source_code(nullptr, CreateResource(UTF8Encoding())); - EXPECT_TRUE( - CompileScript(scope.GetScriptState(), source_code, kV8CacheOptionsParse)); CachedMetadataHandler* cache_handler = source_code.CacheHandler(); - EXPECT_TRUE( - cache_handler->GetCachedMetadata(TagForParserCache(cache_handler))); - EXPECT_FALSE( - cache_handler->GetCachedMetadata(TagForCodeCache(cache_handler))); + SetCacheTimeStamp(cache_handler); + + EXPECT_TRUE(CompileScript(scope.GetIsolate(), scope.GetScriptState(), + source_code, kV8CacheOptionsCode)); + + EXPECT_TRUE(cache_handler->GetCachedMetadata(TagForCodeCache(cache_handler))); // The cached data is associated with the encoding. ScriptResource* another_resource = CreateResource(UTF16LittleEndianEncoding()); EXPECT_FALSE(cache_handler->GetCachedMetadata( - TagForParserCache(another_resource->CacheHandler()))); + TagForCodeCache(another_resource->CacheHandler()))); } -TEST_F(V8ScriptRunnerTest, codeOption) { +TEST_F(V8ScriptRunnerTest, consumeCodeOption) { V8TestingScope scope; ScriptSourceCode source_code(nullptr, CreateResource(UTF8Encoding())); + // Set timestamp to simulate a warm run. CachedMetadataHandler* cache_handler = source_code.CacheHandler(); SetCacheTimeStamp(cache_handler); - EXPECT_TRUE( - CompileScript(scope.GetScriptState(), source_code, kV8CacheOptionsCode)); + // Warm run - should produce code cache. + EXPECT_TRUE(CompileScript(scope.GetIsolate(), scope.GetScriptState(), + source_code, kV8CacheOptionsCode)); + + // Check the produced cache is for code cache. + EXPECT_TRUE(cache_handler->GetCachedMetadata(TagForCodeCache(cache_handler))); + // Hot run - should consume code cache. + v8::ScriptCompiler::CompileOptions compile_options; + V8ScriptRunner::ProduceCacheOptions produce_cache_options; + v8::ScriptCompiler::NoCacheReason no_cache_reason; + std::tie(compile_options, produce_cache_options, no_cache_reason) = + V8ScriptRunner::GetCompileOptions(kV8CacheOptionsDefault, source_code); + EXPECT_EQ(produce_cache_options, + V8ScriptRunner::ProduceCacheOptions::kNoProduceCache); + EXPECT_EQ(compile_options, + v8::ScriptCompiler::CompileOptions::kConsumeCodeCache); + EXPECT_TRUE(CompileScript(scope.GetIsolate(), scope.GetScriptState(), + source_code, compile_options, no_cache_reason, + produce_cache_options)); + EXPECT_TRUE(cache_handler->GetCachedMetadata(TagForCodeCache(cache_handler))); +} + +TEST_F(V8ScriptRunnerTest, produceAndConsumeCodeOption) { + V8TestingScope scope; + ScriptSourceCode source_code(nullptr, CreateResource(UTF8Encoding())); + CachedMetadataHandler* cache_handler = source_code.CacheHandler(); + + // Cold run - should set the timestamp + EXPECT_TRUE(CompileScript(scope.GetIsolate(), scope.GetScriptState(), + source_code, kV8CacheOptionsDefault)); + EXPECT_TRUE(cache_handler->GetCachedMetadata(TagForTimeStamp(cache_handler))); EXPECT_FALSE( - cache_handler->GetCachedMetadata(TagForParserCache(cache_handler))); + cache_handler->GetCachedMetadata(TagForCodeCache(cache_handler))); + + // Warm run - should produce code cache + EXPECT_TRUE(CompileScript(scope.GetIsolate(), scope.GetScriptState(), + source_code, kV8CacheOptionsDefault)); + EXPECT_TRUE(cache_handler->GetCachedMetadata(TagForCodeCache(cache_handler))); + + // Hot run - should consume code cache + v8::ScriptCompiler::CompileOptions compile_options; + V8ScriptRunner::ProduceCacheOptions produce_cache_options; + v8::ScriptCompiler::NoCacheReason no_cache_reason; + std::tie(compile_options, produce_cache_options, no_cache_reason) = + V8ScriptRunner::GetCompileOptions(kV8CacheOptionsDefault, source_code); + EXPECT_EQ(produce_cache_options, + V8ScriptRunner::ProduceCacheOptions::kNoProduceCache); + EXPECT_EQ(compile_options, + v8::ScriptCompiler::CompileOptions::kConsumeCodeCache); + EXPECT_TRUE(CompileScript(scope.GetIsolate(), scope.GetScriptState(), + source_code, compile_options, no_cache_reason, + produce_cache_options)); EXPECT_TRUE(cache_handler->GetCachedMetadata(TagForCodeCache(cache_handler))); - // The cached data is associated with the encoding. - ScriptResource* another_resource = - CreateResource(UTF16LittleEndianEncoding()); - EXPECT_FALSE(cache_handler->GetCachedMetadata( - TagForCodeCache(another_resource->CacheHandler()))); } } // namespace diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h index e151c4fb29..2f84b6d4e2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h @@ -27,7 +27,6 @@ #define V8StringResource_h #include "bindings/core/v8/ExceptionState.h" -#include "core/CoreExport.h" #include "platform/bindings/StringResource.h" #include "platform/wtf/Allocator.h" #include "platform/wtf/Threading.h" diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8WasmResponseExtensions.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8WasmResponseExtensions.cpp new file mode 100644 index 0000000000..3ed7621771 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8WasmResponseExtensions.cpp @@ -0,0 +1,221 @@ +// Copyright 2017 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/V8WasmResponseExtensions.h" + +#include "base/memory/scoped_refptr.h" +#include "bindings/core/v8/ExceptionState.h" +#include "bindings/core/v8/ScriptPromise.h" +#include "bindings/core/v8/ScriptPromiseResolver.h" +#include "bindings/core/v8/V8Response.h" +#include "core/dom/ExecutionContext.h" +#include "core/fetch/BodyStreamBuffer.h" +#include "core/fetch/FetchDataLoader.h" +#include "platform/bindings/ScriptState.h" +#include "platform/bindings/V8PerIsolateData.h" +#include "platform/heap/Handle.h" + +namespace blink { + +namespace { + +class FetchDataLoaderAsWasmModule final : public FetchDataLoader, + public BytesConsumer::Client { + USING_GARBAGE_COLLECTED_MIXIN(FetchDataLoaderAsWasmModule); + + public: + FetchDataLoaderAsWasmModule(ScriptState* script_state) + : builder_(script_state->GetIsolate()), script_state_(script_state) {} + + void Start(BytesConsumer* consumer, + FetchDataLoader::Client* client) override { + DCHECK(!consumer_); + DCHECK(!client_); + client_ = client; + consumer_ = consumer; + consumer_->SetClient(this); + OnStateChange(); + } + + v8::Local GetPromise() { return builder_.GetPromise(); } + + void OnStateChange() override { + while (true) { + // {buffer} is owned by {m_consumer}. + const char* buffer = nullptr; + size_t available = 0; + BytesConsumer::Result result = consumer_->BeginRead(&buffer, &available); + + if (result == BytesConsumer::Result::kShouldWait) + return; + if (result == BytesConsumer::Result::kOk) { + if (available > 0) { + DCHECK_NE(buffer, nullptr); + builder_.OnBytesReceived(reinterpret_cast(buffer), + available); + } + result = consumer_->EndRead(available); + } + switch (result) { + case BytesConsumer::Result::kShouldWait: + NOTREACHED(); + return; + case BytesConsumer::Result::kOk: { + break; + } + case BytesConsumer::Result::kDone: { + ScriptState::Scope scope(script_state_.get()); + builder_.Finish(); + client_->DidFetchDataLoadedCustomFormat(); + return; + } + case BytesConsumer::Result::kError: { + return AbortCompilation(); + } + } + } + } + + String DebugName() const override { return "FetchDataLoaderAsWasmModule"; } + + void Cancel() override { + consumer_->Cancel(); + return AbortCompilation(); + } + + void Trace(blink::Visitor* visitor) { + visitor->Trace(consumer_); + visitor->Trace(client_); + FetchDataLoader::Trace(visitor); + BytesConsumer::Client::Trace(visitor); + } + + private: + // TODO(mtrofin): replace with spec-ed error types, once spec clarifies + // what they are. + void AbortCompilation() { + ScriptState::Scope scope(script_state_.get()); + if (!ExecutionContext::From(script_state_.get())->IsContextDestroyed()) { + builder_.Abort(V8ThrowException::CreateTypeError( + script_state_->GetIsolate(), "Could not download wasm module")); + } else { + // We are not allowed to execute a script, which indicates that we should + // not reject the promise of the streaming compilation. By passing no + // abort reason, we indicate the V8 side that the promise should not get + // rejected. + builder_.Abort(v8::Local()); + } + } + Member consumer_; + Member client_; + v8::WasmModuleObjectBuilderStreaming builder_; + const scoped_refptr script_state_; +}; + +// TODO(mtrofin): WasmDataLoaderClient is necessary so we may provide an +// argument to BodyStreamBuffer::startLoading, however, it fulfills +// a very small role. Consider refactoring to avoid it. +class WasmDataLoaderClient final + : public GarbageCollectedFinalized, + public FetchDataLoader::Client { + WTF_MAKE_NONCOPYABLE(WasmDataLoaderClient); + USING_GARBAGE_COLLECTED_MIXIN(WasmDataLoaderClient); + + public: + explicit WasmDataLoaderClient() = default; + void DidFetchDataLoadedCustomFormat() override {} + void DidFetchDataLoadFailed() override { NOTREACHED(); } +}; + +// This callback may be entered as a promise is resolved, or directly +// from the overload callback. +// See +// https://github.com/WebAssembly/design/blob/master/Web.md#webassemblycompile +void CompileFromResponseCallback( + const v8::FunctionCallbackInfo& args) { + ExceptionState exception_state(args.GetIsolate(), + ExceptionState::kExecutionContext, + "WebAssembly", "compile"); + ExceptionToRejectPromiseScope reject_promise_scope(args, exception_state); + + ScriptState* script_state = ScriptState::ForCurrentRealm(args); + if (!ExecutionContext::From(script_state)) { + V8SetReturnValue(args, ScriptPromise().V8Value()); + return; + } + + Response* response = + V8Response::ToImplWithTypeCheck(args.GetIsolate(), args[0]); + if (!response) { + exception_state.ThrowTypeError( + "An argument must be provided, which must be a " + "Response or Promise object"); + return; + } + + if (response->MimeType() != "application/wasm") { + exception_state.ThrowTypeError( + "Incorrect response MIME type. Expected 'application/wasm'."); + return; + } + + if (response->IsBodyLocked() || response->bodyUsed()) { + exception_state.ThrowTypeError( + "Cannot compile WebAssembly.Module from an already read Response"); + return; + } + + if (!response->BodyBuffer()) { + exception_state.ThrowTypeError("Response object has a null body."); + return; + } + + FetchDataLoaderAsWasmModule* loader = + new FetchDataLoaderAsWasmModule(script_state); + v8::Local promise = loader->GetPromise(); + response->BodyBuffer()->StartLoading(loader, new WasmDataLoaderClient()); + + V8SetReturnValue(args, promise); +} + +// See https://crbug.com/708238 for tracking avoiding the hand-generated code. +void WasmCompileStreamingImpl(const v8::FunctionCallbackInfo& args) { + ScriptState* script_state = ScriptState::ForCurrentRealm(args); + V8PerIsolateData* per_isolate_data = + V8PerIsolateData::From(script_state->GetIsolate()); + + // An unique key of the v8::FunctionTemplate cache in V8PerIsolateData. + // Everyone uses address of something as a key, so the address of |unique_key| + // is guaranteed to be unique for the function template cache. + static const int unique_key = 0; + v8::Local function_template = + per_isolate_data->FindOrCreateOperationTemplate( + script_state->World(), &unique_key, CompileFromResponseCallback, + v8::Local(), v8::Local(), 1); + v8::Local compile_callback; + if (!function_template->GetFunction(script_state->GetContext()) + .ToLocal(&compile_callback)) { + return; // Throw an exception. + } + + // treat either case of parameter as + // Promise.resolve(parameter) + // as per https://www.w3.org/2001/tag/doc/promises-guide#resolve-arguments + + // Ending with: + // return Promise.resolve(parameter).then(compileCallback); + V8SetReturnValue(args, ScriptPromise::Cast(script_state, args[0]) + .Then(compile_callback) + .V8Value()); +} + +} // namespace + +void WasmResponseExtensions::Initialize(v8::Isolate* isolate) { + if (RuntimeEnabledFeatures::WebAssemblyStreamingEnabled()) { + isolate->SetWasmCompileStreamingCallback(WasmCompileStreamingImpl); + } +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8WasmResponseExtensions.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8WasmResponseExtensions.h new file mode 100644 index 0000000000..f685b74ecf --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/V8WasmResponseExtensions.h @@ -0,0 +1,25 @@ +// Copyright 2017 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 V8WasmResponseExtensions_h +#define V8WasmResponseExtensions_h + +#include "core/CoreExport.h" +#include "platform/wtf/Allocator.h" +#include "v8/include/v8.h" + +namespace blink { + +// Injects Web Platform - specific overloads for WebAssembly APIs. +// See https://github.com/WebAssembly/design/blob/master/Web.md +class CORE_EXPORT WasmResponseExtensions { + STATIC_ONLY(WasmResponseExtensions); + + public: + static void Initialize(v8::Isolate*); +}; + +} // namespace blink + +#endif // V8WasmResponseextensions_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp index e851064b18..030dc6e415 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp @@ -271,12 +271,27 @@ ScriptValue WorkerOrWorkletScriptController::EvaluateInternal( // - A work{er,let} script doesn't have a nonce, and // - a work{er,let} script is always "not parser inserted". ReferrerScriptInfo referrer_info; + v8::ScriptCompiler::CompileOptions compile_options; + V8ScriptRunner::ProduceCacheOptions produce_cache_options; + v8::ScriptCompiler::NoCacheReason no_cache_reason; + std::tie(compile_options, produce_cache_options, no_cache_reason) = + V8ScriptRunner::GetCompileOptions(v8_cache_options, source_code); if (V8ScriptRunner::CompileScript(script_state_.get(), source_code, - kSharableCrossOrigin, v8_cache_options, - referrer_info) - .ToLocal(&compiled_script)) - maybe_result = V8ScriptRunner::RunCompiledScript(isolate_, compiled_script, - global_scope_); + kSharableCrossOrigin, compile_options, + no_cache_reason, referrer_info) + .ToLocal(&compiled_script)) { + if (RuntimeEnabledFeatures::CodeCacheAfterExecuteEnabled()) { + maybe_result = V8ScriptRunner::RunCompiledScript( + isolate_, compiled_script, global_scope_); + V8ScriptRunner::ProduceCache(isolate_, compiled_script, source_code, + produce_cache_options, compile_options); + } else { + V8ScriptRunner::ProduceCache(isolate_, compiled_script, source_code, + produce_cache_options, compile_options); + maybe_result = V8ScriptRunner::RunCompiledScript( + isolate_, compiled_script, global_scope_); + } + } if (!block.CanContinue()) { ForbidExecution(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLAllCollectionCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLAllCollectionCustom.cpp index 78a4e462ef..6fa89a43d1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLAllCollectionCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLAllCollectionCustom.cpp @@ -31,120 +31,52 @@ #include "bindings/core/v8/V8HTMLAllCollection.h" #include "bindings/core/v8/V8BindingForCore.h" -#include "bindings/core/v8/V8Element.h" -#include "bindings/core/v8/V8NodeList.h" -#include "core/dom/StaticNodeList.h" -#include "core/frame/UseCounter.h" -#include "core/html/HTMLAllCollection.h" namespace blink { -template -static v8::Local GetNamedItems(HTMLAllCollection* collection, - AtomicString name, - const CallbackInfo& info) { - HeapVector> named_items; - collection->NamedItems(name, named_items); - - if (!named_items.size()) - return V8Undefined(); - - if (named_items.size() == 1) - return ToV8(named_items.at(0).Release(), info.Holder(), info.GetIsolate()); - - // FIXME: HTML5 specification says this should be a HTMLCollection. - // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlallcollection - return ToV8(StaticElementList::Adopt(named_items), info.Holder(), - info.GetIsolate()); -} - -template -static v8::Local GetItem( - HTMLAllCollection* collection, - v8::Local argument, - const CallbackInfo& info, - WebFeature named_feature, - WebFeature indexed_feature, - WebFeature indexed_with_non_number_feature) { - v8::Local index; - if (!argument->ToArrayIndex(info.GetIsolate()->GetCurrentContext()) - .ToLocal(&index)) { - UseCounter::Count(CurrentExecutionContext(info.GetIsolate()), - named_feature); - TOSTRING_DEFAULT(V8StringResource<>, name, argument, - v8::Undefined(info.GetIsolate())); - v8::Local result = GetNamedItems(collection, name, info); - - if (result.IsEmpty()) - return v8::Undefined(info.GetIsolate()); - - return result; +// https://html.spec.whatwg.org/#the-htmlallcollection-interface +// +// The only part of the spec expressed in terms of ECMAScript values instead of +// IDL values is the [[Call]] internal method. However, the way the +// |item(nameOrIndex)| method is defined makes it indistinguishable. This +// implementation does not match step-for-step the definition or [[Call]] or +// |item(nameOrIndex)|, but should produce the same result. + +void GetIndexedOrNamed(const v8::FunctionCallbackInfo& info) { + if (info.Length() == 0 || info[0]->IsUndefined()) { + V8SetReturnValueNull(info); + return; } - UseCounter::Count(CurrentExecutionContext(info.GetIsolate()), - indexed_feature); - if (!argument->IsNumber()) { - UseCounter::Count(CurrentExecutionContext(info.GetIsolate()), - indexed_with_non_number_feature); - } - Element* result = collection->item(index->Value()); - return ToV8(result, info.Holder(), info.GetIsolate()); -} + HTMLAllCollection* impl = V8HTMLAllCollection::ToImpl(info.Holder()); -void V8HTMLAllCollection::itemMethodCustom( - const v8::FunctionCallbackInfo& info) { - if (info.Length() < 1) { - UseCounter::Count(CurrentExecutionContext(info.GetIsolate()), - WebFeature::kDocumentAllItemNoArguments); + v8::Local index; + if (info[0] + ->ToArrayIndex(info.GetIsolate()->GetCurrentContext()) + .ToLocal(&index)) { + Element* result = impl->AnonymousIndexedGetter(index->Value()); + V8SetReturnValue(info, result); return; } - HTMLAllCollection* impl = V8HTMLAllCollection::ToImpl(info.Holder()); - V8SetReturnValue( - info, GetItem(impl, info[0], info, WebFeature::kDocumentAllItemNamed, - WebFeature::kDocumentAllItemIndexed, - WebFeature::kDocumentAllItemIndexedWithNonNumber)); + TOSTRING_VOID(V8StringResource<>, name, info[0]); + HTMLCollectionOrElement result; + impl->NamedGetter(name, result); + V8SetReturnValue(info, result); } void V8HTMLAllCollection::legacyCallCustom( const v8::FunctionCallbackInfo& info) { RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT( info.GetIsolate(), "Blink_V8HTMLAllCollection_legacyCallCustom"); - if (info.Length() < 1) { - UseCounter::Count(CurrentExecutionContext(info.GetIsolate()), - WebFeature::kDocumentAllLegacyCallNoArguments); - return; - } - - UseCounter::Count(CurrentExecutionContext(info.GetIsolate()), - WebFeature::kDocumentAllLegacyCall); - - HTMLAllCollection* impl = V8HTMLAllCollection::ToImpl(info.Holder()); - - if (info.Length() == 1) { - V8SetReturnValue( - info, - GetItem(impl, info[0], info, WebFeature::kDocumentAllLegacyCallNamed, - WebFeature::kDocumentAllLegacyCallIndexed, - WebFeature::kDocumentAllLegacyCallIndexedWithNonNumber)); - return; - } - - UseCounter::Count(CurrentExecutionContext(info.GetIsolate()), - WebFeature::kDocumentAllLegacyCallTwoArguments); - - // If there is a second argument it is the index of the item we want. - TOSTRING_VOID(V8StringResource<>, name, info[0]); - v8::Local index; - if (!info[1] - ->ToArrayIndex(info.GetIsolate()->GetCurrentContext()) - .ToLocal(&index)) - return; + GetIndexedOrNamed(info); +} - if (Node* node = impl->NamedItemWithIndex(name, index->Value())) { - V8SetReturnValueFast(info, node, impl); - return; - } +void V8HTMLAllCollection::itemMethodCustom( + const v8::FunctionCallbackInfo& info) { + RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT( + info.GetIsolate(), "Blink_V8HTMLAllCollection_itemMethodCustom"); + GetIndexedOrNamed(info); } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp index 59cf532ffb..e542d6af03 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp @@ -101,6 +101,12 @@ void V8MessageEvent::initMessageEventMethodCustom( ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "MessageEvent", "initMessageEvent"); + if (UNLIKELY(info.Length() < 1)) { + exception_state.ThrowTypeError( + ExceptionMessages::NotEnoughArguments(1, info.Length())); + return; + } + MessageEvent* event = V8MessageEvent::ToImpl(info.Holder()); TOSTRING_VOID(V8StringResource<>, type_arg, info[0]); bool can_bubble_arg = false; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp index 3dd087eec1..3a594cf233 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp @@ -133,21 +133,6 @@ void V8Window::eventAttributeGetterCustom( V8SetReturnValue(info, js_event); } -void V8Window::eventAttributeSetterCustom( - v8::Local value, - const v8::FunctionCallbackInfo& info) { - LocalDOMWindow* impl = ToLocalDOMWindow(V8Window::ToImpl(info.Holder())); - v8::Isolate* isolate = info.GetIsolate(); - ExceptionState exception_state(isolate, ExceptionState::kSetterContext, - "Window", "event"); - if (!BindingSecurity::ShouldAllowAccessTo(CurrentDOMWindow(isolate), impl, - exception_state)) { - return; - } - - V8PrivateProperty::GetGlobalEvent(isolate).Set(info.Holder(), value); -} - void V8Window::frameElementAttributeGetterCustom( const v8::FunctionCallbackInfo& info) { LocalDOMWindow* impl = ToLocalDOMWindow(V8Window::ToImpl(info.Holder())); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8XMLHttpRequestCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8XMLHttpRequestCustom.cpp index 28990df78b..dee33f7e17 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8XMLHttpRequestCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/custom/V8XMLHttpRequestCustom.cpp @@ -53,12 +53,12 @@ void V8XMLHttpRequest::responseTextAttributeGetterCustom( ExceptionState exception_state(info.GetIsolate(), ExceptionState::kGetterContext, "XMLHttpRequest", "responseText"); - ScriptString text = xml_http_request->responseText(exception_state); + v8::Local text = xml_http_request->responseText(exception_state); if (text.IsEmpty()) { V8SetReturnValueString(info, g_empty_string, info.GetIsolate()); return; } - V8SetReturnValue(info, text.V8Value()); + V8SetReturnValue(info, text); } void V8XMLHttpRequest::responseAttributeGetterCustom( @@ -77,7 +77,8 @@ void V8XMLHttpRequest::responseAttributeGetterCustom( case XMLHttpRequest::kResponseTypeJSON: { v8::Isolate* isolate = info.GetIsolate(); - ScriptString json_source = xml_http_request->ResponseJSONSource(); + v8::Local json_source = + xml_http_request->ResponseJSONSource(); if (json_source.IsEmpty()) { V8SetReturnValue(info, v8::Null(isolate)); return; @@ -87,7 +88,7 @@ void V8XMLHttpRequest::responseAttributeGetterCustom( // spec says. https://xhr.spec.whatwg.org/#response-body v8::Local json = FromJSONString(isolate, isolate->GetCurrentContext(), - ToCoreString(json_source.V8Value()), exception_state); + ToCoreString(json_source), exception_state); if (exception_state.HadException()) { exception_state.ClearException(); V8SetReturnValue(info, v8::Null(isolate)); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.cpp index c8fbe34d5d..de495030a6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.cpp @@ -370,6 +370,24 @@ void SerializedScriptValue::TransferArrayBuffers( TransferArrayBufferContents(isolate, array_buffers, exception_state); } +void SerializedScriptValue::CloneSharedArrayBuffers( + SharedArrayBufferArray& array_buffers) { + if (!array_buffers.size()) + return; + + HeapHashSet> visited; + shared_array_buffers_contents_.Grow(array_buffers.size()); + size_t i = 0; + for (auto it = array_buffers.begin(); it != array_buffers.end(); ++it) { + DOMSharedArrayBuffer* shared_array_buffer = *it; + if (visited.Contains(shared_array_buffer)) + continue; + visited.insert(shared_array_buffer); + shared_array_buffer->ShareContentsWith(shared_array_buffers_contents_[i]); + i++; + } +} + v8::Local SerializedScriptValue::Deserialize( v8::Isolate* isolate, const DeserializeOptions& options) { @@ -391,6 +409,7 @@ UnpackedSerializedScriptValue* SerializedScriptValue::Unpack( bool SerializedScriptValue::HasPackedContents() const { return !array_buffer_contents_array_.IsEmpty() || + !shared_array_buffers_contents_.IsEmpty() || !image_bitmap_contents_array_.IsEmpty(); } @@ -535,15 +554,10 @@ SerializedScriptValue::TransferArrayBufferContents( size_t index = std::distance(array_buffers.begin(), it); if (array_buffer_base->IsShared()) { - DOMSharedArrayBuffer* shared_array_buffer = - static_cast(array_buffer_base); - if (!shared_array_buffer->ShareContentsWith(contents.at(index))) { - exception_state.ThrowDOMException(kDataCloneError, - "SharedArrayBuffer at index " + - String::Number(index) + - " could not be transferred."); - return ArrayBufferContentsArray(); - } + exception_state.ThrowDOMException( + kDataCloneError, "SharedArrayBuffer at index " + + String::Number(index) + " is not transferable."); + return ArrayBufferContentsArray(); } else { DOMArrayBuffer* array_buffer = static_cast(array_buffer_base); @@ -572,6 +586,8 @@ void SerializedScriptValue:: if (!transferables_need_external_allocation_registration_) { for (auto& buffer : array_buffer_contents_array_) buffer.UnregisterExternalAllocationWithCurrentContext(); + for (auto& buffer : shared_array_buffers_contents_) + buffer.UnregisterExternalAllocationWithCurrentContext(); transferables_need_external_allocation_registration_ = true; } } @@ -590,6 +606,8 @@ void SerializedScriptValue::RegisterMemoryAllocatedWithCurrentScriptContext() { if (transferables_need_external_allocation_registration_) { for (auto& buffer : array_buffer_contents_array_) buffer.RegisterExternalAllocationWithCurrentContext(); + for (auto& buffer : shared_array_buffers_contents_) + buffer.RegisterExternalAllocationWithCurrentContext(); } } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.h index 6761d24568..0b78c4083f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.h @@ -38,6 +38,7 @@ #include "bindings/core/v8/ScriptValue.h" #include "bindings/core/v8/serialization/Transferables.h" #include "core/CoreExport.h" +#include "core/imagebitmap/ImageBitmap.h" #include "platform/wtf/Allocator.h" #include "platform/wtf/HashMap.h" #include "platform/wtf/Optional.h" @@ -53,17 +54,19 @@ class BlobDataHandle; class Transferables; class ExceptionState; class SharedBuffer; -class StaticBitmapImage; class UnpackedSerializedScriptValue; class WebBlobInfo; +class DOMSharedArrayBuffer; typedef HashMap> BlobDataHandleMap; typedef Vector WebBlobInfoArray; +typedef HeapVector> SharedArrayBufferArray; class CORE_EXPORT SerializedScriptValue : public ThreadSafeRefCounted { public: using ArrayBufferContentsArray = Vector; + using SharedArrayBufferContentsArray = Vector; using ImageBitmapContentsArray = Vector, 1>; using TransferredWasmModulesArray = WTF::Vector; @@ -224,7 +227,22 @@ class CORE_EXPORT SerializedScriptValue size_t DataLengthInBytes() const { return data_buffer_size_; } TransferredWasmModulesArray& WasmModules() { return wasm_modules_; } + SharedArrayBufferContentsArray& SharedArrayBuffersContents() { + return shared_array_buffers_contents_; + } BlobDataHandleMap& BlobDataHandles() { return blob_data_handles_; } + ArrayBufferContentsArray& GetArrayBufferContentsArray() { + return array_buffer_contents_array_; + } + void SetArrayBufferContentsArray(ArrayBufferContentsArray contents) { + array_buffer_contents_array_ = std::move(contents); + } + ImageBitmapContentsArray& GetImageBitmapContentsArray() { + return image_bitmap_contents_array_; + } + void SetImageBitmapContentsArray(ImageBitmapContentsArray contents) { + image_bitmap_contents_array_ = std::move(contents); + } private: friend class ScriptValueSerializer; @@ -255,7 +273,7 @@ class CORE_EXPORT SerializedScriptValue void TransferOffscreenCanvas(v8::Isolate*, const OffscreenCanvasArray&, ExceptionState&); - + void CloneSharedArrayBuffers(SharedArrayBufferArray&); DataBufferPtr data_buffer_; size_t data_buffer_size_ = 0; @@ -267,6 +285,7 @@ class CORE_EXPORT SerializedScriptValue // These do not have one-use transferred contents, like the above. TransferredWasmModulesArray wasm_modules_; BlobDataHandleMap blob_data_handles_; + SharedArrayBufferContentsArray shared_array_buffers_contents_; bool has_registered_external_allocation_; bool transferables_need_external_allocation_registration_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValueFuzzer.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValueFuzzer.cpp index cbb2e293bb..cd229bc499 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValueFuzzer.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValueFuzzer.cpp @@ -44,10 +44,11 @@ int LLVMFuzzerInitialize(int* argc, char*** argv) { g_page_holder = DummyPageHolder::Create().release(); g_page_holder->GetFrame().GetSettings()->SetScriptEnabled(true); g_blob_info_array = new WebBlobInfoArray(); - g_blob_info_array->emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", - "text/plain", 12); - g_blob_info_array->emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", - "/native/path", "path", "text/plain"); + g_blob_info_array->emplace_back(WebBlobInfo::BlobForTesting( + "d875dfc2-4505-461b-98fe-0cf6cc5eaf44", "text/plain", 12)); + g_blob_info_array->emplace_back( + WebBlobInfo::FileForTesting("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", + "/native/path", "path", "text/plain")); return 0; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueDeserializer.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueDeserializer.cpp index eaa5826afa..6ec4ee6770 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueDeserializer.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueDeserializer.cpp @@ -612,4 +612,30 @@ V8ScriptValueDeserializer::GetWasmModuleFromId(v8::Isolate* isolate, return v8::MaybeLocal(); } +v8::MaybeLocal +V8ScriptValueDeserializer::GetSharedArrayBufferFromId(v8::Isolate* isolate, + uint32_t id) { + auto& shared_array_buffers_contents = + serialized_script_value_->SharedArrayBuffersContents(); + if (id < shared_array_buffers_contents.size()) { + WTF::ArrayBufferContents& contents = shared_array_buffers_contents.at(id); + DOMSharedArrayBuffer* shared_array_buffer = + DOMSharedArrayBuffer::Create(contents); + v8::Local creation_context = + script_state_->GetContext()->Global(); + v8::Local wrapper = + ToV8(shared_array_buffer, creation_context, isolate); + DCHECK(wrapper->IsSharedArrayBuffer()); + return v8::Local::Cast(wrapper); + } + ExceptionState exception_state(isolate, ExceptionState::kUnknownContext, + nullptr, nullptr); + exception_state.ThrowDOMException(kDataCloneError, + "Unable to deserialize SharedArrayBuffer."); + // If the id does not map to a valid index, it is expected that the + // SerializedScriptValue emptied its shared ArrayBufferContents when crossing + // a process boundary. + CHECK(shared_array_buffers_contents.IsEmpty()); + return v8::MaybeLocal(); +} } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueDeserializer.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueDeserializer.h index 3e01a1f98b..73cc88c541 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueDeserializer.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueDeserializer.h @@ -99,6 +99,9 @@ class CORE_EXPORT V8ScriptValueDeserializer v8::MaybeLocal ReadHostObject(v8::Isolate*) override; v8::MaybeLocal GetWasmModuleFromId(v8::Isolate*, uint32_t) override; + v8::MaybeLocal GetSharedArrayBufferFromId( + v8::Isolate*, + uint32_t) override; scoped_refptr script_state_; Member unpacked_value_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp index ba4ae12893..afb4c2c1a2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp @@ -102,6 +102,8 @@ scoped_refptr V8ScriptValueSerializer::Serialize( if (exception_state.HadException()) return nullptr; + serialized_script_value_->CloneSharedArrayBuffers(shared_array_buffers_); + // Finalize the results. std::pair buffer = serializer_.Release(); serialized_script_value_->SetData( @@ -136,12 +138,9 @@ void V8ScriptValueSerializer::FinalizeTransfer( v8::Isolate* isolate = script_state_->GetIsolate(); - // The order of ArrayBuffers and SharedArrayBuffers matters; we use the index - // into this array for deserialization. ArrayBufferArray array_buffers; if (transferables_) array_buffers.AppendVector(transferables_->array_buffers); - array_buffers.AppendVector(shared_array_buffers_); if (!array_buffers.IsEmpty()) { serialized_script_value_->TransferArrayBuffers(isolate, array_buffers, @@ -528,23 +527,12 @@ v8::Maybe V8ScriptValueSerializer::GetSharedArrayBufferId( // The index returned from this function will be serialized into the data // stream. When deserializing, this will be used to index into the - // arrayBufferContents array of the SerializedScriptValue. - // - // The v8::ValueSerializer will use the same index space for transferred - // ArrayBuffers, but those will all occur first, because their indexes are - // generated in order via v8::ValueSerializer::TransferArrayBuffer (see - // prepareTransfer above). - // - // So we offset all SharedArrayBuffer indexes by the number of transferred - // ArrayBuffers. + // sharedArrayBufferContents array of the SerializedScriptValue. size_t index = shared_array_buffers_.Find(shared_array_buffer); if (index == kNotFound) { shared_array_buffers_.push_back(shared_array_buffer); index = shared_array_buffers_.size() - 1; } - if (transferables_) { - index += transferables_->array_buffers.size(); - } return v8::Just(index); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.h index 16c09351ae..17c99964a4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.h @@ -105,7 +105,7 @@ class CORE_EXPORT V8ScriptValueSerializer const Transferables* transferables_ = nullptr; const ExceptionState* exception_state_ = nullptr; WebBlobInfoArray* blob_info_array_ = nullptr; - ArrayBufferArray shared_array_buffers_; + SharedArrayBufferArray shared_array_buffers_; Options::WasmSerializationPolicy wasm_policy_; bool for_storage_ = false; #if DCHECK_IS_ON() diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializerTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializerTest.cpp index a2ed648f65..f610b833fb 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializerTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializerTest.cpp @@ -963,6 +963,7 @@ TEST(V8ScriptValueSerializerTest, RoundTripImageBitmap) { surface->getCanvas()->clear(SK_ColorRED); ImageBitmap* image_bitmap = ImageBitmap::Create( StaticBitmapImage::Create(surface->makeImageSnapshot())); + ASSERT_TRUE(image_bitmap->BitmapImage()); // Serialize and deserialize it. v8::Local wrapper = ToV8(image_bitmap, scope.GetScriptState()); @@ -970,6 +971,7 @@ TEST(V8ScriptValueSerializerTest, RoundTripImageBitmap) { ASSERT_TRUE(V8ImageBitmap::hasInstance(result, scope.GetIsolate())); ImageBitmap* new_image_bitmap = V8ImageBitmap::ToImpl(result.As()); + ASSERT_TRUE(new_image_bitmap->BitmapImage()); ASSERT_EQ(IntSize(10, 7), new_image_bitmap->Size()); // Check that the pixel at (3, 3) is red. @@ -997,6 +999,7 @@ TEST(V8ScriptValueSerializerTest, RoundTripImageBitmapWithColorSpaceInfo) { surface->getCanvas()->clear(SK_ColorRED); ImageBitmap* image_bitmap = ImageBitmap::Create( StaticBitmapImage::Create(surface->makeImageSnapshot())); + ASSERT_TRUE(image_bitmap->BitmapImage()); // Serialize and deserialize it. v8::Local wrapper = ToV8(image_bitmap, scope.GetScriptState()); @@ -1004,6 +1007,7 @@ TEST(V8ScriptValueSerializerTest, RoundTripImageBitmapWithColorSpaceInfo) { ASSERT_TRUE(V8ImageBitmap::hasInstance(result, scope.GetIsolate())); ImageBitmap* new_image_bitmap = V8ImageBitmap::ToImpl(result.As()); + ASSERT_TRUE(new_image_bitmap->BitmapImage()); ASSERT_EQ(IntSize(10, 7), new_image_bitmap->Size()); // Check the color settings. @@ -1224,6 +1228,7 @@ TEST(V8ScriptValueSerializerTest, TransferImageBitmap) { sk_sp image = surface->makeImageSnapshot(); ImageBitmap* image_bitmap = ImageBitmap::Create(StaticBitmapImage::Create(image)); + ASSERT_TRUE(image_bitmap->BitmapImage()); v8::Local wrapper = ToV8(image_bitmap, scope.GetScriptState()); Transferables transferables; @@ -1233,6 +1238,7 @@ TEST(V8ScriptValueSerializerTest, TransferImageBitmap) { ASSERT_TRUE(V8ImageBitmap::hasInstance(result, scope.GetIsolate())); ImageBitmap* new_image_bitmap = V8ImageBitmap::ToImpl(result.As()); + ASSERT_TRUE(new_image_bitmap->BitmapImage()); ASSERT_EQ(IntSize(10, 7), new_image_bitmap->Size()); // Check that the pixel at (3, 3) is red. @@ -1337,8 +1343,8 @@ TEST(V8ScriptValueSerializerTest, DecodeBlobIndex) { scoped_refptr input = SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x69, 0x00}); WebBlobInfoArray blob_info_array; - blob_info_array.emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", - "text/plain", 12); + blob_info_array.emplace_back(WebBlobInfo::BlobForTesting( + "d875dfc2-4505-461b-98fe-0cf6cc5eaf44", "text/plain", 12)); V8ScriptValueDeserializer::Options options; options.blob_info = &blob_info_array; V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input, @@ -1361,8 +1367,8 @@ TEST(V8ScriptValueSerializerTest, DecodeBlobIndexOutOfRange) { } { WebBlobInfoArray blob_info_array; - blob_info_array.emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", - "text/plain", 12); + blob_info_array.emplace_back(WebBlobInfo::BlobForTesting( + "d875dfc2-4505-461b-98fe-0cf6cc5eaf44", "text/plain", 12)); V8ScriptValueDeserializer::Options options; options.blob_info = &blob_info_array; V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input, @@ -1596,8 +1602,9 @@ TEST(V8ScriptValueSerializerTest, DecodeFileIndex) { scoped_refptr input = SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x65, 0x00}); WebBlobInfoArray blob_info_array; - blob_info_array.emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", - "/native/path", "path", "text/plain"); + blob_info_array.emplace_back( + WebBlobInfo::FileForTesting("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", + "/native/path", "path", "text/plain")); V8ScriptValueDeserializer::Options options; options.blob_info = &blob_info_array; V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input, @@ -1621,8 +1628,9 @@ TEST(V8ScriptValueSerializerTest, DecodeFileIndexOutOfRange) { } { WebBlobInfoArray blob_info_array; - blob_info_array.emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", - "/native/path", "path", "text/plain"); + blob_info_array.emplace_back( + WebBlobInfo::FileForTesting("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", + "/native/path", "path", "text/plain")); V8ScriptValueDeserializer::Options options; options.blob_info = &blob_info_array; V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input, @@ -1753,8 +1761,9 @@ TEST(V8ScriptValueSerializerTest, DecodeFileListIndex) { scoped_refptr input = SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x4c, 0x01, 0x00, 0x00}); WebBlobInfoArray blob_info_array; - blob_info_array.emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", - "/native/path", "name", "text/plain"); + blob_info_array.emplace_back( + WebBlobInfo::FileForTesting("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", + "/native/path", "name", "text/plain")); V8ScriptValueDeserializer::Options options; options.blob_info = &blob_info_array; V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/BUILD.gn b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/BUILD.gn index fde12177f5..68f4b95f84 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/BUILD.gn +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/BUILD.gn @@ -96,6 +96,25 @@ action("bindings_modules_v8_generated_init_partial") { ] } +# Note that this intentionally depends on the generator target of the mojom +# target instead of the mojom target itself directly. This is to ensure that the +# dependencies are header-only and don't link against any bindings code. +group("generate_mojo_bindings") { + visibility = [] # Allow re-assignment of list. + visibility = [ ":*" ] + + deps = [ + "//device/gamepad/public/mojom:mojom_blink__generator", + "//device/usb/public/mojom:mojom_blink__generator", + "//device/vr/public/mojom:mojom_blink__generator", + "//media//capture/mojo:image_capture_blink__generator", + "//services/device/public/mojom:generic_sensor__generator", + "//services/device/public/mojom:mojom_blink__generator", + "//services/shape_detection/public/mojom:mojom_blink__generator", + "//third_party/WebKit/public:media_devices_mojo_bindings_blink__generator", + ] +} + blink_modules_sources("bindings_modules_impl") { # ":generate_bindings_modules_v8_partial_interfaces_for_testing" is not # included here. @@ -109,6 +128,7 @@ blink_modules_sources("bindings_modules_impl") { deps = [ ":bindings_modules_origin_trial_features", ":bindings_modules_v8_generated", + ":generate_mojo_bindings", ] if (!is_component_build && is_win) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/ModuleBindingsInitializer.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/ModuleBindingsInitializer.cpp index 8e419c468a..593da3db6a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/ModuleBindingsInitializer.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/ModuleBindingsInitializer.cpp @@ -6,7 +6,6 @@ #include "bindings/modules/v8/OriginTrialFeaturesForModules.h" #include "bindings/modules/v8/serialization/SerializedScriptValueForModulesFactory.h" -#include "bindings/modules/v8/wasm/WasmResponseExtensions.h" #include "platform/bindings/V8PerIsolateData.h" namespace blink { @@ -20,7 +19,6 @@ void ModuleBindingsInitializer::Init() { InitPartialInterfacesInModules(); SerializedScriptValueFactory::Initialize( new SerializedScriptValueForModulesFactory); - WasmResponseExtensions::Initialize(V8PerIsolateData::MainThreadIsolate()); } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp index 6b3d0e73a3..63e7e71143 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp @@ -146,10 +146,6 @@ v8::Local ToV8(const IDBAny* impl, return ToV8(impl->IdbCursorWithValue(), creation_context, isolate); case IDBAny::kIDBDatabaseType: return ToV8(impl->IdbDatabase(), creation_context, isolate); - case IDBAny::kIDBIndexType: - return ToV8(impl->IdbIndex(), creation_context, isolate); - case IDBAny::kIDBObjectStoreType: - return ToV8(impl->IdbObjectStore(), creation_context, isolate); case IDBAny::kIDBValueType: return DeserializeIDBValue(isolate, creation_context, impl->Value()); case IDBAny::kIDBValueArrayType: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/custom/custom.gni b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/custom/custom.gni index be3af4ac9a..c82423d32d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/custom/custom.gni +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/custom/custom.gni @@ -4,8 +4,4 @@ # Make the files absolute so they can be imported to anywhere. bindings_modules_v8_custom_files = - get_path_info([ - "V8CustomSQLStatementErrorCallback.cpp", - "V8ExtendableMessageEventCustom.cpp", - ], - "abspath") + get_path_info([ "V8ExtendableMessageEventCustom.cpp" ], "abspath") diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/v8.gni b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/v8.gni index 1465206e83..e6c6150bf3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/v8.gni +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/modules/v8/v8.gni @@ -19,8 +19,6 @@ bindings_modules_v8_files = "V8BindingForModules.cpp", "V8BindingForModules.h", "V8ContextSnapshotExternalReferences.h", - "wasm/WasmResponseExtensions.cpp", - "wasm/WasmResponseExtensions.h", "WebGLAny.cpp", "WebGLAny.h", ], diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/code_generator_v8.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/code_generator_v8.py index 0f3a7d50b3..7512222abc 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/code_generator_v8.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/code_generator_v8.py @@ -217,6 +217,9 @@ def generate_interface_code(self, definitions, interface_name, interface): # Add the include for interface itself if IdlType(interface_name).is_typed_array: template_context['header_includes'].add('core/typed_arrays/DOMTypedArray.h') + elif interface.is_callback: + if len(interface.constants) > 0: # legacy callback interface + includes.add(interface_info['include_path']) else: template_context['header_includes'].add(interface_info['include_path']) template_context['header_includes'].update( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/generate_v8_context_snapshot_external_references.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/generate_v8_context_snapshot_external_references.py index 1fa3fae33d..28c52285ed 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/generate_v8_context_snapshot_external_references.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/generate_v8_context_snapshot_external_references.py @@ -74,10 +74,12 @@ def create_interface_context(self, interface, interfaces): name = '%s%s' % (v8_utilities.cpp_name(interface), 'Partial' if interface.is_partial else '') # Constructors - constructors = any(constructor.name == 'Constructor' for constructor in interface.constructors) - custom_constructors = interface.custom_constructors - html_constructor = 'HTMLConstructor' in interface.extended_attributes - has_constructor_callback = constructors or custom_constructors or html_constructor + has_constructor_callback = False + if not interface.is_partial: + constructors = any(constructor.name == 'Constructor' for constructor in interface.constructors) + custom_constructors = interface.custom_constructors + html_constructor = 'HTMLConstructor' in interface.extended_attributes + has_constructor_callback = constructors or custom_constructors or html_constructor attributes = [] methods = [] diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/idl_definitions.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/idl_definitions.py index f2f0e543e3..b333dee970 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/idl_definitions.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/idl_definitions.py @@ -71,7 +71,7 @@ from idl_types import IdlType from idl_types import IdlUnionType -SPECIAL_KEYWORD_LIST = ['LEGACYCALLER', 'GETTER', 'SETTER', 'DELETER'] +SPECIAL_KEYWORD_LIST = ['GETTER', 'SETTER', 'DELETER'] ################################################################################ diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/idl_types.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/idl_types.py index d4f4acb964..4c645d47b3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/idl_types.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/idl_types.py @@ -560,6 +560,16 @@ def is_nullable(self): def name(self): return self.inner_type.name + 'OrNull' + @property + def enum_values(self): + # Nullable enums are handled by preprending a None value to the list of + # enum values. This None value is converted to nullptr on the C++ side, + # which matches the JavaScript 'null' in the enum parsing code. + inner_values = self.inner_type.enum_values + if inner_values: + return [None] + inner_values + return None + def resolve_typedefs(self, typedefs): self.inner_type = self.inner_type.resolve_typedefs(typedefs) return self diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm.py index 6425a84412..6e819d5b33 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm.py @@ -32,7 +32,7 @@ def effective_overload_set(F): # pylint: disable=invalid-name Formally: An effective overload set represents the allowable invocations for a particular operation, constructor (specified with [Constructor] or - [NamedConstructor]), legacy caller or callback function. + [NamedConstructor]), or callback function. An additional argument N (argument count) is needed when overloading variadics, but we don't use that currently. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/utilities.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/utilities.py index b641b42b64..b3b4359743 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/utilities.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/utilities.py @@ -433,7 +433,7 @@ def shorten_union_name(union_type): # modules/canvas2d/CanvasRenderingContext2D.idl 'CSSImageValueOrHTMLImageElementOrSVGImageElementOrHTMLVideoElementOrHTMLCanvasElementOrImageBitmapOrOffscreenCanvas': 'CanvasImageSource', # modules/canvas/HTMLCanvasElementModule.idl - 'CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrImageBitmapRenderingContext': 'RenderingContext', + 'CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrImageBitmapRenderingContextOrXRPresentationContext': 'RenderingContext', # core/imagebitmap/ImageBitmapFactories.idl 'HTMLImageElementOrSVGImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOrImageBitmapOrOffscreenCanvas': 'ImageBitmapSource', # bindings/tests/idls/core/TestTypedefs.idl diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_callback_function.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_callback_function.py index b53f494f49..03433c0ffc 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_callback_function.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_callback_function.py @@ -68,11 +68,11 @@ def find_forward_declaration(idl_type): return find_forward_declaration(idl_type.element_type) return None - declarations = ['ScriptWrappable'] + declarations = set(['ScriptWrappable']) for argument in callback_function.arguments: name = find_forward_declaration(argument.idl_type) if name: - declarations.append(name) + declarations.add(name) return declarations @@ -89,9 +89,7 @@ def argument_context(argument): 'v8_name': 'v8_%s' % argument.name, } - argument_declarations = [ - 'ScriptWrappable* callback_this_value', - ] + argument_declarations = ['ScriptWrappable* callback_this_value'] argument_declarations.extend( '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) for argument in arguments) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_callback_interface.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_callback_interface.py index 1c692dd926..53c54de53e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_callback_interface.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_callback_interface.py @@ -94,11 +94,12 @@ def callback_interface_context(callback_interface, _): return { 'cpp_class': callback_interface.name, - 'v8_class': v8_utilities.v8_class_name(callback_interface), + 'forward_declarations': sorted(forward_declarations(callback_interface)), 'header_includes': set(CALLBACK_INTERFACE_H_INCLUDES), 'is_single_operation_callback_interface': is_single_operation, 'methods': [method_context(operation) for operation in callback_interface.operations], + 'v8_class': v8_utilities.v8_class_name(callback_interface), } @@ -116,6 +117,23 @@ def legacy_callback_interface_context(callback_interface, _): } +def forward_declarations(callback_interface): + def find_forward_declaration(idl_type): + if idl_type.is_interface_type or idl_type.is_dictionary: + return idl_type.implemented_as + elif idl_type.is_array_or_sequence_type: + return find_forward_declaration(idl_type.element_type) + return None + + declarations = set() + for operation in callback_interface.operations: + for argument in operation.arguments: + name = find_forward_declaration(argument.idl_type) + if name: + declarations.add(name) + return declarations + + def add_includes_for_operation(operation): operation.idl_type.add_includes_for_type() for argument in operation.arguments: @@ -128,16 +146,13 @@ def method_context(operation): idl_type_str = str(idl_type) if idl_type_str not in ['boolean', 'void']: raise Exception('We only support callbacks that return boolean or void values.') - is_custom = 'Custom' in extended_attributes - if not is_custom: - add_includes_for_operation(operation) + add_includes_for_operation(operation) call_with = extended_attributes.get('CallWith') call_with_this_handle = v8_utilities.extended_attribute_value_contains(call_with, 'ThisValue') context = { 'call_with_this_handle': call_with_this_handle, 'cpp_type': idl_type.callback_cpp_type, 'idl_type': idl_type_str, - 'is_custom': is_custom, 'name': operation.name, } context.update(arguments_context(operation.arguments, @@ -148,13 +163,14 @@ def method_context(operation): def arguments_context(arguments, call_with_this_handle): def argument_context(argument): return { - 'handle': '%sHandle' % argument.name, 'cpp_value_to_v8_value': argument.idl_type.cpp_value_to_v8_value( argument.name, isolate='GetIsolate()', creation_context='argument_creation_context'), + 'handle': '%sHandle' % argument.name, + 'name': argument.name, } - argument_declarations = ['ScriptValue thisValue'] if call_with_this_handle else [] + argument_declarations = ['ScriptWrappable* callback_this_value'] argument_declarations.extend( '%s %s' % (argument.idl_type.callback_cpp_type, argument.name) for argument in arguments) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_dictionary.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_dictionary.py index c3a7d36dc2..e314ba985d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_dictionary.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_dictionary.py @@ -142,13 +142,14 @@ def default_values(): extended_attributes=extended_attributes), 'deprecate_as': v8_utilities.deprecate_as(member), 'enum_type': idl_type.enum_type, - 'enum_values': unwrapped_idl_type.enum_values, + 'enum_values': idl_type.enum_values, 'getter_name': getter_name, 'has_method_name': has_method_name_for_dictionary_member(member), 'idl_type': idl_type.base_type, 'is_interface_type': idl_type.is_interface_type and not is_deprecated_dictionary, 'is_nullable': idl_type.is_nullable, 'is_object': unwrapped_idl_type.name == 'Object' or is_deprecated_dictionary, + 'is_string_type': idl_type.preprocessed_type.is_string_type, 'is_required': member.is_required, 'name': member.name, 'origin_trial_feature_name': v8_utilities.origin_trial_feature_name(member), # [OriginTrialEnabled] @@ -156,7 +157,7 @@ def default_values(): 'setter_name': setter_name_for_dictionary_member(member), 'null_setter_name': null_setter_name_for_dictionary_member(member), 'v8_default_value': v8_default_value, - 'v8_value_to_local_cpp_value': unwrapped_idl_type.v8_value_to_local_cpp_value( + 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( extended_attributes, member.name + 'Value', member.name + 'CppValue', isolate='isolate', use_exception_state=True), } @@ -219,7 +220,9 @@ def has_method_expression(): return nullable_indicator_name if idl_type.is_union_type or idl_type.is_enum or idl_type.is_string_type: return '!%s_.IsNull()' % cpp_name - if idl_type.name in ['Any', 'Object']: + if idl_type.name == 'Any': + return '!({0}_.IsEmpty() || {0}_.IsUndefined())'.format(cpp_name) + if idl_type.name == 'Object': return '!({0}_.IsEmpty() || {0}_.IsNull() || {0}_.IsUndefined())'.format(cpp_name) if idl_type.name == 'Dictionary': return '!%s_.IsUndefinedOrNull()' % cpp_name diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_interface.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_interface.py index 887374cd4d..385c6e428d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_interface.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_interface.py @@ -453,7 +453,6 @@ def interface_context(interface, interfaces): }) context.update({ - 'legacy_caller': legacy_caller(interface.legacy_caller, interface), 'indexed_property_getter': property_getter(interface.indexed_property_getter, ['index']), 'indexed_property_setter': property_setter(interface.indexed_property_setter, interface), 'indexed_property_deleter': property_deleter(interface.indexed_property_deleter), @@ -1383,12 +1382,6 @@ def interface_length(constructors): # http://heycam.github.io/webidl/#idl-special-operations ################################################################################ -def legacy_caller(caller, interface): - if not caller: - return None - - return v8_methods.method_context(interface, caller) - def property_getter(getter, cpp_arguments): if not getter: return None diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_methods.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_methods.py index 1cc0bedfdd..91c02b3b4c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_methods.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_methods.py @@ -178,7 +178,7 @@ def method_context(interface, method, is_visible=True): return { 'activity_logging_world_list': v8_utilities.activity_logging_world_list(method), # [ActivityLogging] 'arguments': argument_contexts, - 'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type) + 'cpp_type': (v8_types.cpp_template_type('Optional', idl_type.cpp_type) if idl_type.is_explicit_nullable else idl_type.cpp_type), 'cpp_value': this_cpp_value, 'cpp_type_initializer': idl_type.cpp_type_initializer, @@ -264,7 +264,7 @@ def argument_context(interface, method, argument, index, is_visible=True): used_as_variadic_argument=argument.is_variadic) context = { 'cpp_type': ( - v8_types.cpp_template_type('Nullable', this_cpp_type) + v8_types.cpp_template_type('Optional', this_cpp_type) if idl_type.is_explicit_nullable and not argument.is_variadic else this_cpp_type), 'cpp_value': this_cpp_value, @@ -365,8 +365,8 @@ def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False) # [CallWith=ScriptState], [RaisesException] if use_local_result(method): if idl_type.is_explicit_nullable: - # result is of type Nullable - cpp_value = 'result.Get()' + # result is of type WTF::Optional + cpp_value = 'result.value()' else: cpp_value = 'result' @@ -374,9 +374,10 @@ def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False) return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_wrappable=script_wrappable, for_main_world=for_main_world, is_static=method.is_static) -def v8_value_to_local_cpp_variadic_value(method, argument, index, return_promise): +def v8_value_to_local_cpp_variadic_value(argument, index): assert argument.is_variadic - idl_type = v8_types.native_value_traits_type_name(argument.idl_type, True) + idl_type = v8_types.native_value_traits_type_name(argument.idl_type, + argument.extended_attributes, True) return { 'assign_expression': 'ToImplArguments<%s>(info, %s, exceptionState)' % (idl_type, index), @@ -411,7 +412,7 @@ def v8_value_to_local_cpp_ssv_value(extended_attributes, idl_type, v8_value, var } -def v8_value_to_local_cpp_value(interface_name, method, argument, index, return_promise=False): +def v8_value_to_local_cpp_value(interface_name, method, argument, index): extended_attributes = argument.extended_attributes idl_type = argument.idl_type name = argument.name @@ -428,7 +429,7 @@ def v8_value_to_local_cpp_value(interface_name, method, argument, index, return_ for_storage=for_storage) if argument.is_variadic: - return v8_value_to_local_cpp_variadic_value(method, argument, index, return_promise) + return v8_value_to_local_cpp_variadic_value(argument, index) return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, name, declare_variable=False, use_exception_state=method.returns_promise) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_types.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_types.py index 121e35646c..0785548994 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_types.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_types.py @@ -135,6 +135,35 @@ class methods. } +def string_resource_mode(idl_type, extended_attributes=None): + """Returns a V8StringResourceMode value corresponding to the IDL type. + + Args: + idl_type: + A string IdlType. + extended_attributes: + A mapping type with extended attribute names and values. + """ + extended_attributes = extended_attributes or {} + + if idl_type.is_nullable: + return 'kTreatNullAndUndefinedAsNullString' + # TODO(lisabelle): Remove these 4 lines when we have fully supported + # annoteted types. (crbug.com/714866) + # It is because at that time 'TreatNullAs' will only appear in + # type_extended_attributes, not in extended_attributes. + if extended_attributes.get('TreatNullAs') == 'EmptyString': + return 'kTreatNullAsEmptyString' + if extended_attributes.get('TreatNullAs') == 'NullString': + return 'kTreatNullAsNullString' + type_extended_attributes = idl_type.extended_attributes or {} + if type_extended_attributes.get('TreatNullAs') == 'EmptyString': + return 'kTreatNullAsEmptyString' + if type_extended_attributes.get('TreatNullAs') == 'NullString': + return 'kTreatNullAsNullString' + return '' + + def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_rvalue_type=False, used_as_variadic_argument=False, used_in_cpp_sequence=False): """Returns C++ type corresponding to IDL type. @@ -155,24 +184,6 @@ def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_rvalue_ Containers can be an array, a sequence, a dictionary or a record. """ - def string_mode(): - if idl_type.is_nullable: - return 'kTreatNullAndUndefinedAsNullString' - # TODO(lisabelle): Remove these 4 lines when we have fully supported - # annoteted types. (crbug.com/714866) - # It is because at that time 'TreatNullAs' will only appear in - # type_extended_attributes, not in extended_attributes. - if extended_attributes.get('TreatNullAs') == 'EmptyString': - return 'kTreatNullAsEmptyString' - if extended_attributes.get('TreatNullAs') == 'NullString': - return 'kTreatNullAsNullString' - type_extended_attributes = idl_type.extended_attributes or {} - if type_extended_attributes.get('TreatNullAs') == 'EmptyString': - return 'kTreatNullAsEmptyString' - if type_extended_attributes.get('TreatNullAs') == 'NullString': - return 'kTreatNullAsNullString' - return '' - extended_attributes = extended_attributes or {} idl_type = idl_type.preprocessed_type @@ -234,7 +245,7 @@ def needs_optional_wrapper(): if idl_type.is_string_type: if not raw_type: return 'const String&' if used_as_rvalue_type else 'String' - return 'V8StringResource<%s>' % string_mode() + return 'V8StringResource<%s>' % string_resource_mode(idl_type, extended_attributes) if base_idl_type == 'ArrayBufferView' and 'FlexibleArrayBufferView' in extended_attributes: return 'FlexibleArrayBufferView' @@ -602,23 +613,35 @@ def v8_conversion_is_trivial(idl_type): IdlType.v8_conversion_is_trivial = property(v8_conversion_is_trivial) -def native_value_traits_type_name(idl_type, in_sequence_or_record=False): +def native_value_traits_type_name(idl_type, extended_attributes, in_sequence_or_record=False): idl_type = idl_type.preprocessed_type - if idl_type.is_nullable: - inner_type = native_value_traits_type_name(idl_type.inner_type) + if idl_type.is_string_type: + # Strings are handled separately because null and/or undefined are + # processed by V8StringResource due to the [TreatNullAs] extended + # attribute (it also handles nullable string types). + name = 'IDL%s' % (idl_type.inner_type.name if idl_type.is_nullable else idl_type.name) + resource_mode = string_resource_mode(idl_type, extended_attributes) + if resource_mode: + name = cpp_template_type('%sBase' % name, resource_mode) + elif idl_type.is_nullable: + inner_type = native_value_traits_type_name(idl_type.inner_type, extended_attributes) # IDLNullable is only required for sequences and such. # The IDL compiler already has special cases for nullable operation # parameters, dictionary fields, etc. if in_sequence_or_record: - name = 'IDLNullable<%s>' % native_value_traits_type_name(idl_type.inner_type) + name = 'IDLNullable<%s>' % native_value_traits_type_name(idl_type.inner_type, + extended_attributes) else: name = inner_type elif idl_type.native_array_element_type: - name = 'IDLSequence<%s>' % native_value_traits_type_name(idl_type.native_array_element_type, True) + name = 'IDLSequence<%s>' % native_value_traits_type_name(idl_type.native_array_element_type, + extended_attributes, True) elif idl_type.is_record_type: - name = 'IDLRecord<%s, %s>' % (native_value_traits_type_name(idl_type.key_type), - native_value_traits_type_name(idl_type.value_type, True)) + name = 'IDLRecord<%s, %s>' % (native_value_traits_type_name(idl_type.key_type, + extended_attributes), + native_value_traits_type_name(idl_type.value_type, + extended_attributes, True)) elif idl_type.is_basic_type or idl_type.name == 'Promise': name = 'IDL%s' % idl_type.name elif idl_type.implemented_as is not None: @@ -698,7 +721,7 @@ def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, variable_name elif idl_type.v8_conversion_needs_exception_state: # Effectively, this if branch means everything with v8_conversion_needs_exception_state == True # except for unions and dictionary interfaces. - base_idl_type = native_value_traits_type_name(idl_type) + base_idl_type = native_value_traits_type_name(idl_type, extended_attributes) cpp_expression_format = ( 'NativeValueTraits<{idl_type}>::NativeValue({isolate}, {arguments})') else: @@ -766,7 +789,7 @@ def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl 'cpp_type': this_cpp_type, 'cpp_name': variable_name, 'declare_variable': declare_variable, - 'return_expression': bailout_return_value, + 'return_expression': return_expression, 'set_expression': set_expression, } @@ -939,8 +962,8 @@ def v8_conversion_type(idl_type, extended_attributes): 'Dictionary': 'V8SetReturnValue(info, {cpp_value})', 'DictionaryStatic': '#error not implemented yet', # Nullable dictionaries - 'NullableDictionary': 'V8SetReturnValue(info, result.Get())', - 'NullableDictionaryStatic': 'V8SetReturnValue(info, result.Get(), info.GetIsolate()->GetCurrentContext()->Global())', + 'NullableDictionary': 'V8SetReturnValue(info, result.value())', + 'NullableDictionaryStatic': 'V8SetReturnValue(info, result.value(), info.GetIsolate()->GetCurrentContext()->Global())', # Union types or dictionaries 'DictionaryOrUnion': 'V8SetReturnValue(info, result)', 'DictionaryOrUnionStatic': 'V8SetReturnValue(info, result, info.GetIsolate()->GetCurrentContext()->Global())', @@ -1120,7 +1143,7 @@ def is_implicit_nullable(idl_type): def is_explicit_nullable(idl_type): # Nullable type that isn't implicit nullable (see above.) For such types, - # we use Nullable or similar explicit ways to represent a null value. + # we use WTF::Optional or similar explicit ways to represent a null value. return idl_type.is_nullable and not idl_type.is_implicit_nullable IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_union.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_union.py index 8352fa1245..0353d3e10e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_union.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_union.py @@ -15,9 +15,9 @@ 'bindings/core/v8/Dictionary.h', 'bindings/core/v8/ExceptionState.h', 'bindings/core/v8/NativeValueTraits.h', - 'bindings/core/v8/Nullable.h', 'bindings/core/v8/V8BindingForCore.h', 'platform/heap/Handle.h', + 'platform/wtf/Optional.h', ]) @@ -151,6 +151,7 @@ def member_context(member, info_provider): 'cpp_value_to_v8_value': member.cpp_value_to_v8_value( cpp_value='impl.GetAs%s()' % member.name, isolate='isolate', creation_context='creationContext'), + 'enum_type': member.enum_type, 'enum_values': member.enum_values, 'is_array_buffer_or_view_type': member.is_array_buffer_or_view, 'is_array_buffer_view_or_typed_array': member.is_array_buffer_view_or_typed_array, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_utilities.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_utilities.py index 0a05b807ec..ab27d73122 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_utilities.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/v8_utilities.py @@ -535,27 +535,6 @@ def on_interface(interface, member): return False -################################################################################ -# Legacy callers -# https://heycam.github.io/webidl/#idl-legacy-callers -################################################################################ - -def legacy_caller(interface): - try: - # Find legacy caller, if present; has form: - # legacycaller TYPE [OPTIONAL_IDENTIFIER](OPTIONAL_ARGUMENTS) - caller = next( - method - for method in interface.operations - if 'legacycaller' in method.specials) - if not caller.name: - raise Exception('legacycaller with no identifier is not supported: ' - '%s' % interface.name) - return caller - except StopIteration: - return None - - ################################################################################ # Indexed properties # http://heycam.github.io/webidl/#idl-indexed-properties @@ -652,7 +631,6 @@ def named_property_deleter(interface): return None -IdlInterface.legacy_caller = property(legacy_caller) IdlInterface.indexed_property_getter = property(indexed_property_getter) IdlInterface.indexed_property_setter = property(indexed_property_setter) IdlInterface.indexed_property_deleter = property(indexed_property_deleter) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/web_idl/idl_definition_builder.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/web_idl/idl_definition_builder.py index 45d40a83ae..fbfb93a619 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/web_idl/idl_definition_builder.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/web_idl/idl_definition_builder.py @@ -296,7 +296,7 @@ def create_operation(node, ext_attrs=None): identifier = node.GetName() is_static = bool(node.GetProperty('STATIC')) properties = node.GetProperties() - for special_keyword in ['DELETER', 'GETTER', 'LEGACYCALLER', 'SETTER']: + for special_keyword in ['DELETER', 'GETTER', 'SETTER']: if special_keyword in properties: special_keywords.append(special_keyword.lower()) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/web_idl/operation.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/web_idl/operation.py index ab56382271..df46bc219e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/web_idl/operation.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/scripts/web_idl/operation.py @@ -9,7 +9,7 @@ # https://heycam.github.io/webidl/#idl-operations class Operation(object): # https://www.w3.org/TR/WebIDL-1/#idl-special-operations - _SPECIAL_KEYWORDS = frozenset(['deleter', 'getter', 'legacycaller', 'setter', 'stringifier', 'serializer']) + _SPECIAL_KEYWORDS = frozenset(['deleter', 'getter', 'setter', 'stringifier', 'serializer']) def __init__(self, **kwargs): self._identifier = kwargs.pop('identifier') diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl index 743edb3e6b..7fcb144304 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl @@ -150,6 +150,28 @@ void {{cpp_class}}::InvokeAndReportException({{argument_declarations | join(', ' } {% endif %} +{{exported|replace('_EXPORT', '_TEMPLATE_EXPORT')|trim}} +v8::Maybe<{{return_cpp_type}}> V8PersistentCallbackFunction<{{cpp_class}}>::Invoke({{argument_declarations | join(', ')}}) { + return Proxy()->Invoke( + {{ + (['callback_this_value'] + + (arguments|map(attribute='name')|list) + )|join(', ') + }}); +} + +{% if idl_type == 'void' %} +{{exported|replace('_EXPORT', '_TEMPLATE_EXPORT')|trim}} +void V8PersistentCallbackFunction<{{cpp_class}}>::InvokeAndReportException({{argument_declarations | join(', ')}}) { + Proxy()->InvokeAndReportException( + {{ + (['callback_this_value'] + + (arguments|map(attribute='name')|list) + )|join(', ') + }}); +} +{% endif %} + } // namespace blink {% endfilter %}{# format_blink_cpp_source_code #} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_function.h.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_function.h.tmpl index 1f768fff8a..e43b7d5cf1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_function.h.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_function.h.tmpl @@ -38,6 +38,43 @@ class {{exported}}{{cpp_class}} final : public CallbackFunctionBase { : CallbackFunctionBase(callback_function) {} }; +template <> +class {{exported|replace('_EXPORT', '_TEMPLATE_CLASS_EXPORT')}}V8PersistentCallbackFunction<{{cpp_class}}> final : public V8PersistentCallbackFunctionBase { + using V8CallbackFunction = {{cpp_class}}; + + public: + ~V8PersistentCallbackFunction() override = default; + + // Returns a wrapper-tracing version of this callback function. + V8CallbackFunction* ToNonV8Persistent() { return Proxy(); } + + {{exported|replace('_EXPORT', '_EXTERN_TEMPLATE_EXPORT')|trim}} + v8::Maybe<{{return_cpp_type}}> Invoke({{argument_declarations | join(', ')}}) WARN_UNUSED_RESULT; +{% if idl_type == 'void' %} + {{exported|replace('_EXPORT', '_EXTERN_TEMPLATE_EXPORT')|trim}} + void InvokeAndReportException({{argument_declarations | join(', ')}}); +{% endif %} + + private: + explicit V8PersistentCallbackFunction(V8CallbackFunction* callback_function) + : V8PersistentCallbackFunctionBase(callback_function) {} + + V8CallbackFunction* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackFunction* + ToV8PersistentCallbackFunction(V8CallbackFunction*); +}; + +// {{cpp_class}} is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback functions is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackFunction*). +Persistent<{{cpp_class}}> WrapPersistent({{cpp_class}}*) = delete; + } // namespace blink #endif // {{cpp_class}}_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_interface.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_interface.cpp.tmpl index 9b34872e79..76bddeb95a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_interface.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_interface.cpp.tmpl @@ -10,24 +10,26 @@ namespace blink { -{# TODO(yukishiino): Remove |method.is_custom| once we support the author - function\'s return value. #} -{% for method in methods if not method.is_custom %} +{% for method in methods %} -{% set return_success = 'return' if method.cpp_type == 'void' else 'return true' %} -{% set return_failure = 'return' if method.cpp_type == 'void' else 'return false' %} - -{{method.cpp_type}} {{v8_class}}::{{method.name}}({{method.argument_declarations | join(', ')}}) { +v8::Maybe<{{method.cpp_type}}> {{v8_class}}::{{method.name}}({{method.argument_declarations | join(', ')}}) { // This function implements "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - {# TODO(yukishiino): Add |ScriptWrappable* callback_this_value| as the first - argument of the IDL operations. The callsites must pass callback_this_value - explicitly. #} - ScriptWrappable* callback_this_value = nullptr; - if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { - {{return_success}}; + // Wrapper-tracing for the callback function makes the function object and + // its creation context alive. Thus it's safe to use the creation context + // of the callback function here. + v8::HandleScope handle_scope(GetIsolate()); + CHECK(!CallbackObject().IsEmpty()); + v8::Context::Scope context_scope(CallbackObject()->CreationContext()); + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "{{method.name}}", + "{{cpp_class}}", + "The provided callback is no longer runnable.")); + return v8::Nothing<{{method.cpp_type}}>(); } // step 7. Prepare to run script with relevant settings. @@ -37,14 +39,17 @@ namespace blink { {# TODO(yukishiino): Callback interface type value must make the incumbent environment alive, i.e. the reference to v8::Context must be strong. #} if (IncumbentScriptState()->GetContext().IsEmpty()) { - {{return_success}}; + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "{{method.name}}", + "{{cpp_class}}", + "The provided callback is no longer runnable.")); + return v8::Nothing<{{method.cpp_type}}>(); } v8::Context::BackupIncumbentScope backup_incumbent_scope( IncumbentScriptState()->GetContext()); - v8::TryCatch try_catch(GetIsolate()); - try_catch.SetVerbose(true); - v8::Local function; if (IsCallbackObjectCallable()) { // step 9.1. If value's interface is a single operation callback interface @@ -58,7 +63,7 @@ namespace blink { if (!CallbackObject()->Get(CallbackRelevantScriptState()->GetContext(), V8String(GetIsolate(), "{{method.name}}")) .ToLocal(&value)) { - {{return_failure}}; + return v8::Nothing<{{method.cpp_type}}>(); } // step 10. If !IsCallable(X) is false, then set completion to a new // Completion{[[Type]]: throw, [[Value]]: a newly created TypeError @@ -70,7 +75,7 @@ namespace blink { "{{method.name}}", "{{cpp_class}}", "The provided callback is not callable.")); - {{return_failure}}; + return v8::Nothing<{{method.cpp_type}}>(); } } @@ -99,7 +104,7 @@ namespace blink { "{{method.name}}"); if (!IsValidEnum({{argument.name}}, {{valid_enum_variables}}, WTF_ARRAY_LENGTH({{valid_enum_variables}}), "{{argument.enum_type}}", exception_state)) { NOTREACHED(); - return false; + return v8::Nothing<{{method.cpp_type}}>(); } } #endif @@ -134,14 +139,13 @@ namespace blink { GetIsolate()).ToLocal(&call_result)) { // step 14. If callResult is an abrupt completion, set completion to // callResult and jump to the step labeled return. - {{return_failure}}; + return v8::Nothing<{{method.cpp_type}}>(); } // step 15. Set completion to the result of converting callResult.[[Value]] to // an IDL value of the same type as the operation's return type. {% if method.idl_type == 'void' %} - ALLOW_UNUSED_LOCAL(call_result); - return; + return v8::JustVoid(); {% else %} { ExceptionState exception_state(GetIsolate(), @@ -152,14 +156,57 @@ namespace blink { auto native_result = NativeValueTraits<{{idl_return_type}}>::NativeValue( GetIsolate(), call_result, exception_state); - ALLOW_UNUSED_LOCAL(native_result); - return !exception_state.HadException(); + if (exception_state.HadException()) + return v8::Nothing<{{method.cpp_type}}>(); + else + return v8::Just<{{method.cpp_type}}>(native_result); } {% endif %} } {% endfor %} +{% if methods|length == 1 and methods[0].idl_type == 'void' %} +void {{v8_class}}::InvokeAndReportException({{methods[0].argument_declarations | join(', ')}}) { + v8::TryCatch try_catch(GetIsolate()); + try_catch.SetVerbose(true); + + v8::Maybe maybe_result = + {{methods[0].name}}({{ + (['callback_this_value'] + + (methods[0].arguments|map(attribute='name')|list) + )|join(', ') + }}); + // An exception if any is killed with the v8::TryCatch above. + ALLOW_UNUSED_LOCAL(maybe_result); +} +{% endif %} + +{% for method in methods %} +{{exported|replace('_EXPORT', '_EXTERN_TEMPLATE_EXPORT')|trim}} +v8::Maybe<{{method.cpp_type}}> V8PersistentCallbackInterface<{{v8_class}}>::{{method.name}}({{method.argument_declarations | join(', ')}}) { + return Proxy()->{{method.name}}( + {{ + (['callback_this_value'] + + (method.arguments|map(attribute='name')|list) + )|join(', ') + }}); +} + +{% endfor %} + +{% if methods|length == 1 and methods[0].idl_type == 'void' %} +{{exported|replace('_EXPORT', '_EXTERN_TEMPLATE_EXPORT')|trim}} +void V8PersistentCallbackInterface<{{v8_class}}>::InvokeAndReportException({{methods[0].argument_declarations | join(', ')}}) { + Proxy()->InvokeAndReportException( + {{ + (['callback_this_value'] + + (methods[0].arguments|map(attribute='name')|list) + )|join(', ') + }}); +} +{% endif %} + } // namespace blink {% endfilter %}{# format_blink_cpp_source_code #} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_interface.h.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_interface.h.tmpl index 6a1f1e81f8..98aee21d8e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_interface.h.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/callback_interface.h.tmpl @@ -11,12 +11,11 @@ namespace blink { -{# TODO(yukishiino): Stop inheriting {{cpp_class}} as it\'s not necessary for - most cases. Those who need a common base class between this class and - another class should define an adapter class for themselves. #} -class {{exported}}{{v8_class}} final - : public {{cpp_class}}, - public CallbackInterfaceBase { +{% for forward_declaration in forward_declarations %} +class {{forward_declaration}}; +{% endfor %} + +class {{exported}}{{v8_class}} final : public CallbackInterfaceBase { public: static {{v8_class}}* Create(v8::Local callback_object) { return new {{v8_class}}(callback_object); @@ -25,17 +24,18 @@ class {{exported}}{{v8_class}} final ~{{v8_class}}() override = default; {% for method in methods %} - {# TODO(yukishiino): Add |ScriptWrappable* callback_this_value| as the first - argument of the IDL operations. The callsites must pass callback_this_value - explicitly. #} - {# TODO(yukishiino): Change the return type to v8::Maybe so that the - function returns a return value or throws an exception. #} // Performs "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - {{method.cpp_type}} {{method.name}}({{method.argument_declarations | join(', ')}}) override; + v8::Maybe<{{method.cpp_type}}> {{method.name}}({{method.argument_declarations | join(', ')}}) WARN_UNUSED_RESULT; {% endfor %} +{% if methods|length == 1 and methods[0].idl_type == 'void' %} + // Performs "call a user object's operation", and then reports an exception, + // if any, to the global error handler such as DevTools' console. + void InvokeAndReportException({{methods[0].argument_declarations | join(', ')}}); +{% endif %} + private: {% set single_operation_enum_value = 'kSingleOperation' if is_single_operation_callback_interface else @@ -44,6 +44,46 @@ class {{exported}}{{v8_class}} final : CallbackInterfaceBase(callback_object, {{single_operation_enum_value}}) {} }; +template <> +class {{exported|replace('_EXPORT', '_TEMPLATE_CLASS_EXPORT')}}V8PersistentCallbackInterface<{{v8_class}}> final : public V8PersistentCallbackInterfaceBase { + using V8CallbackInterface = {{v8_class}}; + + public: + ~V8PersistentCallbackInterface() override = default; + +{% for method in methods %} + {{exported|replace('_EXPORT', '_EXTERN_TEMPLATE_EXPORT')|trim}} + v8::Maybe<{{method.cpp_type}}> {{method.name}}({{method.argument_declarations | join(', ')}}) WARN_UNUSED_RESULT; +{% endfor %} +{% if methods|length == 1 and methods[0].idl_type == 'void' %} + {{exported|replace('_EXPORT', '_EXTERN_TEMPLATE_EXPORT')|trim}} + void InvokeAndReportException({{methods[0].argument_declarations | join(', ')}}); +{% endif %} + + private: + explicit V8PersistentCallbackInterface(V8CallbackInterface* callback_interface) + : V8PersistentCallbackInterfaceBase(callback_interface) {} + + V8CallbackInterface* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackInterface* + ToV8PersistentCallbackInterface(V8CallbackInterface*); +}; + +// {{v8_class}} is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback interfaces is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackInterface*). +#if 0 +// TODO(yukishiino): Enable this deletion once CallbackInterfaceBase transitions +// to wrapper-tracing. +Persistent<{{v8_class}}> WrapPersistent({{v8_class}}*) = delete; +#endif + } // namespace blink #endif // {{v8_class}}_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/dictionary_v8.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/dictionary_v8.cpp.tmpl index 272b6e93ed..9f5d989a7e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/dictionary_v8.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/dictionary_v8.cpp.tmpl @@ -75,7 +75,7 @@ void {{v8_class}}::ToImpl(v8::Isolate* isolate, v8::Local v8Value, {{ {% else %} // Do nothing. {% endif %} - {% if member.is_nullable %} + {% if member.is_nullable and not member.is_string_type %}{# String types handle null via V8StringResource #} } else if ({{member.name}}Value->IsNull()) { impl.{{member.null_setter_name}}(); {% endif %} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl index 4d82d7c3fc..6acfe5e421 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl @@ -726,8 +726,6 @@ void {{v8_class_or_partial}}::{{cpp_class}}OriginSafeMethodSetterCallback(v8::Lo const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedderBlink, {{v8_class}}Constructor::domTemplate, - {{v8_class}}::Trace, - {{v8_class}}::TraceWrappers, {{install_conditional_features_func or 'nullptr'}}, "{{interface_name}}", nullptr, @@ -1141,7 +1139,7 @@ v8::Local {{v8_class}}::findInstanceInPrototypeChain(v8::LocalTraceFromGeneratedCode(scriptWrappable->ToImpl<{{cpp_class}}>()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl<{{cpp_class}}>()); - } {% for method in methods %} {% if method.is_custom %} static void {{method.name}}MethodCustom(const v8::FunctionCallbackInfo&); @@ -272,11 +266,6 @@ class {{v8_class}} { v8::Local instance, v8::Local prototype, v8::Local interface); - - {% if has_partial_interface %} - static InstallRuntimeEnabledFeaturesFunction - install_runtime_enabled_features_function_; - {% endif %} {% endif %}{# needs_runtime_enabled_installer #} {% if not is_array_buffer_or_view %} @@ -290,9 +279,23 @@ class {{v8_class}} { {% endif %} {% endif %}{# not is_array_buffer_or_view #} - {% if has_partial_interface %} + {% if needs_runtime_enabled_installer or has_partial_interface %} private: + {% if needs_runtime_enabled_installer %} + static void InstallRuntimeEnabledFeaturesImpl( + v8::Isolate*, + const DOMWrapperWorld& world, + v8::Local instance, + v8::Local prototype, + v8::Local interface); + {% endif %}{# needs_runtime_enabled_installer #} + {% if has_partial_interface %} static InstallTemplateFunction install{{v8_class}}TemplateFunction; + {% if needs_runtime_enabled_installer %} + static InstallRuntimeEnabledFeaturesFunction + install_runtime_enabled_features_function_; + {% endif %} + {% endif %}{# has_partial_interface #} {% endif %} }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl index 0d0f53a4f6..501b4bf3c7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl @@ -27,8 +27,6 @@ namespace blink { {{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin::kEmbedderBlink, {{dom_template}}, - {{v8_class}}::Trace, - {{v8_class}}::TraceWrappers, {{install_conditional_features_func or 'nullptr'}}, "{{interface_name}}", {{parent_wrapper_type_info}}, @@ -646,9 +644,7 @@ static void install{{v8_class}}Template( v8::ReadOnly | v8::DontEnum | v8::DontDelete)); {% endif %} - {% if legacy_caller and not is_partial %} - instanceTemplate->SetCallAsFunctionHandler({{cpp_class_or_partial}}V8Internal::{{legacy_caller.name}}MethodCallback); - {% elif has_custom_legacy_call_as_function and not is_partial %} + {% if has_custom_legacy_call_as_function and not is_partial %} instanceTemplate->SetCallAsFunctionHandler({{v8_class}}::legacyCallCustom); {% endif %} @@ -789,11 +785,10 @@ void {{v8_class_or_partial}}::InstallRuntimeEnabledFeaturesOnTemplate( {##############################################################################} {% block install_runtime_enabled %} {% if needs_runtime_enabled_installer %} -{% from 'attributes.cpp.tmpl' import accessor_configuration, - attribute_configuration, - with context %} +{% from 'attributes.cpp.tmpl' import accessor_configuration, attribute_configuration with context %} {% from 'methods.cpp.tmpl' import install_custom_signature with context %} -void {{v8_class_or_partial}}::InstallRuntimeEnabledFeatures( +{% if not is_partial %} +void {{v8_class}}::InstallRuntimeEnabledFeatures( v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local instance, @@ -803,8 +798,23 @@ void {{v8_class_or_partial}}::InstallRuntimeEnabledFeatures( #error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to have InstallRuntimeEnabledFeatures()." {% endif %} - {% if is_partial %} - {{v8_class}}::InstallRuntimeEnabledFeatures(isolate, world, instance, prototype, interface); + InstallRuntimeEnabledFeaturesImpl(isolate, world, instance, prototype, interface); + {% if has_partial_interface %} + + // Call partial interface's installer. + install_runtime_enabled_features_function_(isolate, world, instance, prototype, interface); + {% endif %} +} +{% endif %}{# not is_partial #} + +void {{v8_class_or_partial}}::InstallRuntimeEnabledFeaturesImpl( + v8::Isolate* isolate, + const DOMWrapperWorld& world, + v8::Local instance, + v8::Local prototype, + v8::Local interface) { + {% if runtime_enabled_feature_name %} +#error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to have InstallRuntimeEnabledFeatures()." {% endif %} v8::Local interface_template = {{v8_class}}::wrapperTypeInfo.domTemplate(isolate, world); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/legacy_callback_interface.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/legacy_callback_interface.cpp.tmpl index db4b2ebab2..0f67d02d6f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/legacy_callback_interface.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/legacy_callback_interface.cpp.tmpl @@ -19,8 +19,6 @@ const WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin::kEmbedderBlink, {{v8_class}}::DomTemplate, nullptr, - nullptr, - nullptr, "{{interface_name}}", nullptr, WrapperTypeInfo::kWrapperTypeNoPrototype, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl index 0bdd0a0c78..891aed7cca 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl @@ -303,7 +303,7 @@ DCHECK(!result || DOMDataStore::GetWrapper(result, info.GetIsolate()).IsEmpty()) {{generate_constructor_wrapper(method)}} {%- elif v8_set_return_value %} {% if method.is_explicit_nullable %} -if (result.IsNull()) +if (!result) V8SetReturnValueNull(info); else {{v8_set_return_value}}; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/partial_interface.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/partial_interface.cpp.tmpl index 2498f900b3..e318f6120b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/partial_interface.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/partial_interface.cpp.tmpl @@ -7,7 +7,7 @@ void {{v8_class_or_partial}}::initialize() { {{v8_class}}::UpdateWrapperTypeInfo( &{{v8_class_or_partial}}::install{{v8_class}}Template, {% if needs_runtime_enabled_installer %} - &{{v8_class_or_partial}}::InstallRuntimeEnabledFeatures, + &{{v8_class_or_partial}}::InstallRuntimeEnabledFeaturesImpl, {% else %} nullptr, {% endif %} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/partial_interface.h.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/partial_interface.h.tmpl index 5ae58db632..e8b0055ef6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/partial_interface.h.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/partial_interface.h.tmpl @@ -47,14 +47,6 @@ class {{v8_class_or_partial}} { {% endif %} {% endfor %} - {% if needs_runtime_enabled_installer %} - static void InstallRuntimeEnabledFeatures( - v8::Isolate*, - const DOMWrapperWorld&, - v8::Local instance, - v8::Local prototype, - v8::Local interface); - {% endif %} static void InstallRuntimeEnabledFeaturesOnTemplate( v8::Isolate*, const DOMWrapperWorld&, @@ -113,6 +105,15 @@ class {{v8_class_or_partial}} { {% endif %} private: + {% if needs_runtime_enabled_installer %} + static void InstallRuntimeEnabledFeaturesImpl( + v8::Isolate*, + const DOMWrapperWorld&, + v8::Local instance, + v8::Local prototype, + v8::Local interface); + + {% endif %} static void install{{v8_class}}Template(v8::Isolate*, const DOMWrapperWorld&, v8::Local interfaceTemplate); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/union_container.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/union_container.cpp.tmpl index 7bf5836f1d..c6b74e650f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/union_container.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/union_container.cpp.tmpl @@ -42,7 +42,7 @@ void {{cpp_class}}::Set{{member.type_name}}({{member.rvalue_cpp_type}} value) { {% if member.enum_values %} NonThrowableExceptionState exceptionState; {{declare_enum_validation_variable(member.enum_values) | indent(2)}} - if (!IsValidEnum(value, validValues, WTF_ARRAY_LENGTH(validValues), "{{member.type_name}}", exceptionState)) { + if (!IsValidEnum(value, validValues, WTF_ARRAY_LENGTH(validValues), "{{member.enum_type}}", exceptionState)) { NOTREACHED(); return; } @@ -113,7 +113,7 @@ void {{v8_class}}::ToImpl(v8::Isolate* isolate, v8::Local v8Value, {{ {{v8_value_to_local_cpp_value(array_or_sequence_type) | indent}} {% if array_or_sequence_type.enum_values %} {{declare_enum_validation_variable(array_or_sequence_type.enum_values) | indent(4)}} - if (!IsValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{array_or_sequence_type.type_name}}", exceptionState)) + if (!IsValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{array_or_sequence_type.enum_type}}", exceptionState)) return; {% endif %} impl.Set{{array_or_sequence_type.type_name}}(cppValue); @@ -174,7 +174,7 @@ void {{v8_class}}::ToImpl(v8::Isolate* isolate, v8::Local v8Value, {{ {{v8_value_to_local_cpp_value(string_type) | indent}} {% if string_type.enum_values %} {{declare_enum_validation_variable(string_type.enum_values) | indent}} - if (!IsValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{string_type.type_name}}", exceptionState)) + if (!IsValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{string_type.enum_type}}", exceptionState)) return; {% endif %} impl.Set{{string_type.type_name}}(cppValue); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/utilities.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/utilities.cpp.tmpl index b91635aa89..b5ae1c892c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/utilities.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/templates/utilities.cpp.tmpl @@ -34,7 +34,11 @@ if ({{item.check_expression}}) {% macro declare_enum_validation_variable(enum_values, enum_variable='validValues') %} const char* {{enum_variable}}[] = { {% for enum_value in enum_values %} +{% if enum_value is none %} + nullptr, +{% else %} "{{enum_value}}", +{% endif %} {% endfor %} }; {%-endmacro %} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestDictionary.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestDictionary.idl index 07b1955e54..1aa57c3acc 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestDictionary.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestDictionary.idl @@ -7,6 +7,8 @@ dictionary TestDictionary { long longMember = 1; DOMString stringMember; TestInterface testInterfaceMember; + [TreatNullAs=EmptyString] ByteString byteStringMember; + USVString? usvStringOrNullMember = null; double? doubleOrNullMember = null; double restrictedDoubleMember = 3.14; unrestricted double unrestrictedDoubleMember = 3.14; @@ -20,6 +22,7 @@ dictionary TestDictionary { sequence testObjectSequenceMember; sequence testInterfaceGarbageCollectedSequenceMember = []; TestEnum enumMember = "foo"; + TestEnum? enumOrNullMember; sequence enumSequenceMember; Element? elementOrNullMember; object objectMember; @@ -50,6 +53,8 @@ dictionary TestDictionary { [TreatNullAs=EmptyString] DOMString applicableToTypeStringMember; (double or sequence) unionMemberWithSequenceDefault = []; (TestEnum or sequence) testEnumOrTestEnumSequenceMember; + (TestEnum? or sequence) testEnumOrNullOrTestEnumSequenceMember; + (TestEnum or sequence) testEnumOrTestEnumOrNullSequenceMember; sequence doubleOrNullSequenceMember; (double? or sequence) doubleOrNullOrDoubleOrNullSequenceMember; sequence stringOrNullSequenceMember; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterface.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterface.idl index a302011367..97bb5baae2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterface.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterface.idl @@ -54,6 +54,7 @@ attribute unrestricted double unrestrictedDoubleAttribute; attribute unrestricted float unrestrictedFloatAttribute; attribute TestEnum testEnumAttribute; + attribute TestEnum? testEnumOrNullAttribute; attribute DOMStringOrDouble stringOrDoubleAttribute; attribute [EnforceRange] long withExtendedAttributeStringAttribute; [ImplementedAs=CapitalImplementation] attribute Implementation uncapitalAttribute; @@ -66,6 +67,9 @@ [RuntimeEnabled=FeatureName] static readonly attribute long staticConditionalReadOnlyLongAttribute; [LegacyInterfaceTypeChecking] attribute TestInterfaceEmpty legacyInterfaceTypeCheckingAttribute; + attribute [TreatNullAs=EmptyString] DOMString stringNullAsEmptyAttribute; + attribute USVString? usvStringOrNullAttribute; + void voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty testInterfaceEmptyArg); void voidMethodDoubleArgFloatArg(double doubleArg, float floatArg); void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg(unrestricted double unrestrictedDoubleArg, unrestricted float unrestrictedFloatArg); @@ -120,17 +124,17 @@ [LegacyInterfaceTypeChecking] void legacyInterfaceTypeCheckingMethod(TestInterfaceEmpty testInterfaceEmptyArg); [SecureContext] void secureContextMethod(); - [SecureContext] attribute bool secureContextAttribute; + [SecureContext] attribute boolean secureContextAttribute; [SecureContext,RuntimeEnabled=SecureFeature] void secureContextRuntimeEnabledMethod(); - [SecureContext,RuntimeEnabled=SecureFeature] attribute bool secureContextRuntimeEnabledAttribute; + [SecureContext,RuntimeEnabled=SecureFeature] attribute boolean secureContextRuntimeEnabledAttribute; [SecureContext,Exposed=Window] void secureContextWindowExposedMethod(); - [SecureContext,Exposed=Window] attribute bool secureContextWindowExposedAttribute; + [SecureContext,Exposed=Window] attribute boolean secureContextWindowExposedAttribute; [SecureContext,Exposed=Worker] void secureContextWorkerExposedMethod(); - [SecureContext,Exposed=Worker] attribute bool secureContextWorkerExposedAttribute; + [SecureContext,Exposed=Worker] attribute boolean secureContextWorkerExposedAttribute; [SecureContext,Exposed=Window,RuntimeEnabled=SecureFeature] void secureContextWindowExposedRuntimeEnabledMethod(); - [SecureContext,Exposed=Window,RuntimeEnabled=SecureFeature] attribute bool secureContextWindowExposedRuntimeEnabledAttribute; + [SecureContext,Exposed=Window,RuntimeEnabled=SecureFeature] attribute boolean secureContextWindowExposedRuntimeEnabledAttribute; [SecureContext,Exposed=Worker,RuntimeEnabled=SecureFeature] void secureContextWorkerExposedRuntimeEnabledMethod(); - [SecureContext,Exposed=Worker,RuntimeEnabled=SecureFeature] attribute bool secureContextWorkerExposedRuntimeEnabledAttribute; + [SecureContext,Exposed=Worker,RuntimeEnabled=SecureFeature] attribute boolean secureContextWorkerExposedRuntimeEnabledAttribute; // Arguments that are sequences or records of nullable types. void methodWithNullableSequences(sequence numbers, sequence strings, sequence elements, sequence<(double or DOMString)?> unions); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterface2.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterface2.idl index 921a2b4248..39f0c26d8b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterface2.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterface2.idl @@ -43,9 +43,6 @@ // This interface has only runtime enabled constants. [RuntimeEnabled=FeatureName] const unsigned short CONST_VALUE_1 = 1; - // Legacy caller with an identifier - legacycaller TestInterfaceEmpty legacyCaller(unsigned long index); - // Indexed property operations with an identifier [RaisesException] getter TestInterfaceEmpty item(unsigned long index); [RaisesException] setter TestInterfaceEmpty setItem(unsigned long index, TestInterfaceEmpty value); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfaceConstructor.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfaceConstructor.idl index e60065d587..c82b6eb074 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfaceConstructor.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfaceConstructor.idl @@ -39,6 +39,7 @@ sequence sequenceStringArg, sequence sequenceDictionaryArg, sequence<(long or TestDictionary)> sequenceLongOrTestDictionaryArg, + optional USVString? optionalUSVStringArg, optional Dictionary optionalDictionaryArg, [Default=Undefined] optional TestInterfaceEmpty optionalTestInterfaceEmptyArg), Constructor(DOMString arg, optional DOMString optArg), diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfacePartial2.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfacePartial2.idl index 59993ef535..51b63dbc1b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfacePartial2.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfacePartial2.idl @@ -40,5 +40,5 @@ static void partial2StaticVoidMethod(); [SecureContext] void partial2SecureContextMethod(); - [SecureContext] attribute bool partial2SecureContextAttribute; + [SecureContext] attribute boolean partial2SecureContextAttribute; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfacePartialSecureContext.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfacePartialSecureContext.idl index 8b22d7974c..e23496aeaf 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfacePartialSecureContext.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfacePartialSecureContext.idl @@ -8,15 +8,15 @@ ImplementedAs=TestInterfacePartialSecureContext // Conflicts with default partial interface class name ] partial interface TestInterface { void partialSecureContextMethod(); - attribute bool partialSecureContextAttribute; + attribute boolean partialSecureContextAttribute; [RuntimeEnabled=SecureFeature] void partialSecureContextRuntimeEnabledMethod(); - [RuntimeEnabled=SecureFeature] attribute bool partialSecureContextRuntimeEnabledAttribute; + [RuntimeEnabled=SecureFeature] attribute boolean partialSecureContextRuntimeEnabledAttribute; [Exposed=Window] void partialSecureContextWindowExposedMethod(); - [Exposed=Window] attribute bool partialSecureContextWindowExposedAttribute; + [Exposed=Window] attribute boolean partialSecureContextWindowExposedAttribute; [Exposed=Worker] void partialSecureContextWorkerExposedMethod(); - [Exposed=Worker] attribute bool partialSecureContextWorkerExposedAttribute; + [Exposed=Worker] attribute boolean partialSecureContextWorkerExposedAttribute; [Exposed=Window,RuntimeEnabled=SecureFeature] void partialSecureContextWindowExposedRuntimeEnabledMethod(); - [Exposed=Window,RuntimeEnabled=SecureFeature] attribute bool partialSecureContextWindowExposedRuntimeEnabledAttribute; + [Exposed=Window,RuntimeEnabled=SecureFeature] attribute boolean partialSecureContextWindowExposedRuntimeEnabledAttribute; [Exposed=Worker,RuntimeEnabled=SecureFeature] void partialSecureContextWorkerExposedRuntimeEnabledMethod(); - [Exposed=Worker,RuntimeEnabled=SecureFeature] attribute bool partialSecureContextWorkerExposedRuntimeEnabledAttribute; + [Exposed=Worker,RuntimeEnabled=SecureFeature] attribute boolean partialSecureContextWorkerExposedRuntimeEnabledAttribute; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfaceSecureContext.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfaceSecureContext.idl index e43c2b2ec9..0f503bc821 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfaceSecureContext.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestInterfaceSecureContext.idl @@ -7,15 +7,15 @@ Exposed=(Window,Worker) ] interface TestInterfaceSecureContext { void secureContextMethod(); - attribute bool secureContextAttribute; + attribute boolean secureContextAttribute; [RuntimeEnabled=SecureFeature] void secureContextRuntimeEnabledMethod(); - [RuntimeEnabled=SecureFeature] attribute bool secureContextRuntimeEnabledAttribute; + [RuntimeEnabled=SecureFeature] attribute boolean secureContextRuntimeEnabledAttribute; [Exposed=Window] void secureContextWindowExposedMethod(); - [Exposed=Window] attribute bool secureContextWindowExposedAttribute; + [Exposed=Window] attribute boolean secureContextWindowExposedAttribute; [Exposed=Worker] void secureContextWorkerExposedMethod(); - [Exposed=Worker] attribute bool secureContextWorkerExposedAttribute; + [Exposed=Worker] attribute boolean secureContextWorkerExposedAttribute; [Exposed=Window,RuntimeEnabled=SecureFeature] void secureContextWindowExposedRuntimeEnabledMethod(); - [Exposed=Window,RuntimeEnabled=SecureFeature] attribute bool secureContextWindowExposedRuntimeEnabledAttribute; + [Exposed=Window,RuntimeEnabled=SecureFeature] attribute boolean secureContextWindowExposedRuntimeEnabledAttribute; [Exposed=Worker,RuntimeEnabled=SecureFeature] void secureContextWorkerExposedRuntimeEnabledMethod(); - [Exposed=Worker,RuntimeEnabled=SecureFeature] attribute bool secureContextWorkerExposedRuntimeEnabledAttribute; + [Exposed=Worker,RuntimeEnabled=SecureFeature] attribute boolean secureContextWorkerExposedRuntimeEnabledAttribute; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestObject.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestObject.idl index f31b0364b9..0f3135466c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestObject.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/idls/core/TestObject.idl @@ -364,6 +364,7 @@ interface TestObject { // Arguments void voidMethodStringArgLongArg(DOMString stringArg, long longArg); // Optional arguments + void voidMethodByteStringOrNullOptionalUSVStringArg(ByteString? byteStringArg, optional USVString usvStringArg); void voidMethodOptionalStringArg(optional DOMString optionalStringArg); void voidMethodOptionalTestInterfaceEmptyArg(optional TestInterfaceEmpty optionalTestInterfaceEmptyArg); void voidMethodOptionalLongArg(optional long optionalLongArg); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/TestDictionary.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/TestDictionary.cpp index 642a9debea..ba92e2ec92 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/TestDictionary.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/TestDictionary.cpp @@ -136,6 +136,14 @@ void TestDictionary::setStringSequenceMember(const Vector& value) { has_string_sequence_member_ = true; } +void TestDictionary::setTestEnumOrNullOrTestEnumSequenceMember(const TestEnumOrTestEnumSequence& value) { + test_enum_or_null_or_test_enum_sequence_member_ = value; +} + +void TestDictionary::setTestEnumOrTestEnumOrNullSequenceMember(const TestEnumOrTestEnumOrNullSequence& value) { + test_enum_or_test_enum_or_null_sequence_member_ = value; +} + void TestDictionary::setTestEnumOrTestEnumSequenceMember(const TestEnumOrTestEnumSequence& value) { test_enum_or_test_enum_sequence_member_ = value; } @@ -198,6 +206,8 @@ void TestDictionary::Trace(blink::Visitor* visitor) { visitor->Trace(garbage_collected_record_member_); visitor->Trace(internal_dictionary_sequence_member_); visitor->Trace(other_double_or_string_member_); + visitor->Trace(test_enum_or_null_or_test_enum_sequence_member_); + visitor->Trace(test_enum_or_test_enum_or_null_sequence_member_); visitor->Trace(test_enum_or_test_enum_sequence_member_); visitor->Trace(test_interface_2_or_uint8_array_member_); visitor->Trace(test_interface_garbage_collected_member_); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/TestDictionary.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/TestDictionary.h index 4924330152..247fb8b1d9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/TestDictionary.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/TestDictionary.h @@ -19,6 +19,7 @@ #include "bindings/core/v8/double_or_string.h" #include "bindings/core/v8/float_or_boolean.h" #include "bindings/core/v8/long_or_boolean.h" +#include "bindings/core/v8/test_enum_or_test_enum_or_null_sequence.h" #include "bindings/core/v8/test_enum_or_test_enum_sequence.h" #include "bindings/core/v8/test_interface_2_or_uint8_array.h" #include "bindings/tests/idls/core/TestInterface2.h" @@ -53,7 +54,7 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase { } void setAnyInRecordMember(const Vector>&); - bool hasAnyMember() const { return !(any_member_.IsEmpty() || any_member_.IsNull() || any_member_.IsUndefined()); } + bool hasAnyMember() const { return !(any_member_.IsEmpty() || any_member_.IsUndefined()); } ScriptValue anyMember() const { return any_member_; } @@ -79,6 +80,12 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase { } inline void setBooleanMember(bool); + bool hasByteStringMember() const { return !byte_string_member_.IsNull(); } + const String& byteStringMember() const { + return byte_string_member_; + } + inline void setByteStringMember(const String&); + bool hasCreateMember() const { return has_create_member_; } bool createMember() const { DCHECK(has_create_member_); @@ -160,6 +167,13 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase { } inline void setEnumMember(const String&); + bool hasEnumOrNullMember() const { return !enum_or_null_member_.IsNull(); } + const String& enumOrNullMember() const { + return enum_or_null_member_; + } + inline void setEnumOrNullMember(const String&); + inline void setEnumOrNullMemberToNull(); + bool hasEnumSequenceMember() const { return has_enum_sequence_member_; } const Vector& enumSequenceMember() const { DCHECK(has_enum_sequence_member_); @@ -296,6 +310,18 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase { } void setStringSequenceMember(const Vector&); + bool hasTestEnumOrNullOrTestEnumSequenceMember() const { return !test_enum_or_null_or_test_enum_sequence_member_.IsNull(); } + const TestEnumOrTestEnumSequence& testEnumOrNullOrTestEnumSequenceMember() const { + return test_enum_or_null_or_test_enum_sequence_member_; + } + void setTestEnumOrNullOrTestEnumSequenceMember(const TestEnumOrTestEnumSequence&); + + bool hasTestEnumOrTestEnumOrNullSequenceMember() const { return !test_enum_or_test_enum_or_null_sequence_member_.IsNull(); } + const TestEnumOrTestEnumOrNullSequence& testEnumOrTestEnumOrNullSequenceMember() const { + return test_enum_or_test_enum_or_null_sequence_member_; + } + void setTestEnumOrTestEnumOrNullSequenceMember(const TestEnumOrTestEnumOrNullSequence&); + bool hasTestEnumOrTestEnumSequenceMember() const { return !test_enum_or_test_enum_sequence_member_.IsNull(); } const TestEnumOrTestEnumSequence& testEnumOrTestEnumSequenceMember() const { return test_enum_or_test_enum_sequence_member_; @@ -408,6 +434,13 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase { } inline void setUnrestrictedDoubleMember(double); + bool hasUsvStringOrNullMember() const { return !usv_string_or_null_member_.IsNull(); } + const String& usvStringOrNullMember() const { + return usv_string_or_null_member_; + } + inline void setUsvStringOrNullMember(const String&); + inline void setUsvStringOrNullMemberToNull(); + v8::Local ToV8Impl(v8::Local, v8::Isolate*) const override; virtual void Trace(blink::Visitor*); @@ -450,6 +483,7 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase { int32_t applicable_to_type_long_member_; String applicable_to_type_string_member_; bool boolean_member_; + String byte_string_member_; bool create_member_; Dictionary dictionary_member_; double double_or_null_member_; @@ -462,6 +496,7 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase { HeapVector>> element_or_null_record_member_; HeapVector> element_or_null_sequence_member_; String enum_member_; + String enum_or_null_member_; Vector enum_sequence_member_; Member event_target_member_; HeapVector>> garbage_collected_record_member_; @@ -482,6 +517,8 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase { Vector> string_or_null_record_member_; Vector string_or_null_sequence_member_; Vector string_sequence_member_; + TestEnumOrTestEnumSequence test_enum_or_null_or_test_enum_sequence_member_; + TestEnumOrTestEnumOrNullSequence test_enum_or_test_enum_or_null_sequence_member_; TestEnumOrTestEnumSequence test_enum_or_test_enum_sequence_member_; TestInterface2OrUint8Array test_interface_2_or_uint8_array_member_; Member test_interface_garbage_collected_member_; @@ -499,6 +536,7 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase { HeapVector union_or_null_sequence_member_; FloatOrBoolean union_with_typedefs_; double unrestricted_double_member_; + String usv_string_or_null_member_; friend class V8TestDictionary; }; @@ -517,6 +555,10 @@ void TestDictionary::setBooleanMember(bool value) { has_boolean_member_ = true; } +void TestDictionary::setByteStringMember(const String& value) { + byte_string_member_ = value; +} + void TestDictionary::setCreateMember(bool value) { create_member_ = value; has_create_member_ = true; @@ -541,6 +583,13 @@ void TestDictionary::setEnumMember(const String& value) { enum_member_ = value; } +void TestDictionary::setEnumOrNullMember(const String& value) { + enum_or_null_member_ = value; +} +void TestDictionary::setEnumOrNullMemberToNull() { + enum_or_null_member_ = String(); +} + void TestDictionary::setEventTargetMember(EventTarget* value) { event_target_member_ = value; } @@ -622,6 +671,13 @@ void TestDictionary::setUnrestrictedDoubleMember(double value) { has_unrestricted_double_member_ = true; } +void TestDictionary::setUsvStringOrNullMember(const String& value) { + usv_string_or_null_member_ = value; +} +void TestDictionary::setUsvStringOrNullMemberToNull() { + usv_string_or_null_member_ = String(); +} + } // namespace blink #endif // TestDictionary_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.cpp index 6df7ae78e9..d51b69000d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.cpp @@ -33,8 +33,6 @@ namespace blink { const WrapperTypeInfo V8ArrayBuffer::wrapperTypeInfo = { gin::kEmbedderBlink, nullptr, - V8ArrayBuffer::Trace, - V8ArrayBuffer::TraceWrappers, nullptr, "ArrayBuffer", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.h index 61e90570bb..280de600c0 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBuffer.h @@ -30,12 +30,6 @@ class V8ArrayBuffer { CORE_EXPORT static TestArrayBuffer* ToImpl(v8::Local object); CORE_EXPORT static TestArrayBuffer* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.cpp index 6dcd98c57e..774d821086 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.cpp @@ -44,8 +44,6 @@ namespace blink { const WrapperTypeInfo V8ArrayBufferView::wrapperTypeInfo = { gin::kEmbedderBlink, nullptr, - V8ArrayBufferView::Trace, - V8ArrayBufferView::TraceWrappers, nullptr, "ArrayBufferView", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.h index 158d5fb080..c6cdff9cd6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8ArrayBufferView.h @@ -30,12 +30,6 @@ class V8ArrayBufferView { CORE_EXPORT static TestArrayBufferView* ToImpl(v8::Local object); CORE_EXPORT static TestArrayBufferView* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.cpp index 27504e1f07..4203820c10 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.cpp @@ -33,8 +33,6 @@ namespace blink { const WrapperTypeInfo V8DataView::wrapperTypeInfo = { gin::kEmbedderBlink, nullptr, - V8DataView::Trace, - V8DataView::TraceWrappers, nullptr, "DataView", &V8ArrayBufferView::wrapperTypeInfo, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.h index 458760cd06..7ea9aa400e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8DataView.h @@ -33,12 +33,6 @@ class V8DataView { CORE_EXPORT static TestDataView* ToImpl(v8::Local object); CORE_EXPORT static TestDataView* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.cpp index ff59738a22..1ce0380036 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.cpp @@ -33,8 +33,6 @@ namespace blink { const WrapperTypeInfo V8SVGTestInterface::wrapperTypeInfo = { gin::kEmbedderBlink, V8SVGTestInterface::domTemplate, - V8SVGTestInterface::Trace, - V8SVGTestInterface::TraceWrappers, nullptr, "SVGTestInterface", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.h index 737bf6cf7b..097e48be21 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8SVGTestInterface.h @@ -35,12 +35,6 @@ class V8SVGTestInterface { } CORE_EXPORT static SVGTestInterface* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestAttributeGetters.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestAttributeGetters.cpp index 2556be0398..2fa9cd6f0d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestAttributeGetters.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestAttributeGetters.cpp @@ -32,8 +32,6 @@ namespace blink { const WrapperTypeInfo V8TestAttributeGetters::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestAttributeGetters::domTemplate, - V8TestAttributeGetters::Trace, - V8TestAttributeGetters::TraceWrappers, nullptr, "TestAttributeGetters", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestAttributeGetters.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestAttributeGetters.h index 0d0b29972c..5660986e1a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestAttributeGetters.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestAttributeGetters.h @@ -35,12 +35,6 @@ class V8TestAttributeGetters { } CORE_EXPORT static TestAttributeGetters* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.cpp index 8a39d15580..5c164704b1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.cpp @@ -35,8 +35,6 @@ namespace blink { const WrapperTypeInfo V8TestCallbackFunctions::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestCallbackFunctions::domTemplate, - V8TestCallbackFunctions::Trace, - V8TestCallbackFunctions::TraceWrappers, nullptr, "TestCallbackFunctions", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.h index 53b785ac0c..f7fd401676 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackFunctions.h @@ -35,12 +35,6 @@ class V8TestCallbackFunctions { } CORE_EXPORT static TestCallbackFunctions* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackInterface.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackInterface.cpp index bb11296e6d..c4c8302cd1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackInterface.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackInterface.cpp @@ -20,14 +20,24 @@ namespace blink { -void V8TestCallbackInterface::voidMethod() { +v8::Maybe V8TestCallbackInterface::voidMethod(ScriptWrappable* callback_this_value) { // This function implements "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - ScriptWrappable* callback_this_value = nullptr; - if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { - return; + // Wrapper-tracing for the callback function makes the function object and + // its creation context alive. Thus it's safe to use the creation context + // of the callback function here. + v8::HandleScope handle_scope(GetIsolate()); + CHECK(!CallbackObject().IsEmpty()); + v8::Context::Scope context_scope(CallbackObject()->CreationContext()); + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethod", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } // step 7. Prepare to run script with relevant settings. @@ -35,14 +45,17 @@ void V8TestCallbackInterface::voidMethod() { CallbackRelevantScriptState()); // step 8. Prepare to run a callback with stored settings. if (IncumbentScriptState()->GetContext().IsEmpty()) { - return; + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethod", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } v8::Context::BackupIncumbentScope backup_incumbent_scope( IncumbentScriptState()->GetContext()); - v8::TryCatch try_catch(GetIsolate()); - try_catch.SetVerbose(true); - v8::Local function; if (IsCallbackObjectCallable()) { // step 9.1. If value's interface is a single operation callback interface @@ -56,7 +69,7 @@ void V8TestCallbackInterface::voidMethod() { if (!CallbackObject()->Get(CallbackRelevantScriptState()->GetContext(), V8String(GetIsolate(), "voidMethod")) .ToLocal(&value)) { - return; + return v8::Nothing(); } // step 10. If !IsCallable(X) is false, then set completion to a new // Completion{[[Type]]: throw, [[Value]]: a newly created TypeError @@ -68,7 +81,7 @@ void V8TestCallbackInterface::voidMethod() { "voidMethod", "TestCallbackInterface", "The provided callback is not callable.")); - return; + return v8::Nothing(); } } @@ -105,23 +118,32 @@ void V8TestCallbackInterface::voidMethod() { GetIsolate()).ToLocal(&call_result)) { // step 14. If callResult is an abrupt completion, set completion to // callResult and jump to the step labeled return. - return; + return v8::Nothing(); } // step 15. Set completion to the result of converting callResult.[[Value]] to // an IDL value of the same type as the operation's return type. - ALLOW_UNUSED_LOCAL(call_result); - return; + return v8::JustVoid(); } -bool V8TestCallbackInterface::booleanMethod() { +v8::Maybe V8TestCallbackInterface::booleanMethod(ScriptWrappable* callback_this_value) { // This function implements "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - ScriptWrappable* callback_this_value = nullptr; - if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { - return true; + // Wrapper-tracing for the callback function makes the function object and + // its creation context alive. Thus it's safe to use the creation context + // of the callback function here. + v8::HandleScope handle_scope(GetIsolate()); + CHECK(!CallbackObject().IsEmpty()); + v8::Context::Scope context_scope(CallbackObject()->CreationContext()); + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "booleanMethod", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } // step 7. Prepare to run script with relevant settings. @@ -129,14 +151,17 @@ bool V8TestCallbackInterface::booleanMethod() { CallbackRelevantScriptState()); // step 8. Prepare to run a callback with stored settings. if (IncumbentScriptState()->GetContext().IsEmpty()) { - return true; + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "booleanMethod", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } v8::Context::BackupIncumbentScope backup_incumbent_scope( IncumbentScriptState()->GetContext()); - v8::TryCatch try_catch(GetIsolate()); - try_catch.SetVerbose(true); - v8::Local function; if (IsCallbackObjectCallable()) { // step 9.1. If value's interface is a single operation callback interface @@ -150,7 +175,7 @@ bool V8TestCallbackInterface::booleanMethod() { if (!CallbackObject()->Get(CallbackRelevantScriptState()->GetContext(), V8String(GetIsolate(), "booleanMethod")) .ToLocal(&value)) { - return false; + return v8::Nothing(); } // step 10. If !IsCallable(X) is false, then set completion to a new // Completion{[[Type]]: throw, [[Value]]: a newly created TypeError @@ -162,7 +187,7 @@ bool V8TestCallbackInterface::booleanMethod() { "booleanMethod", "TestCallbackInterface", "The provided callback is not callable.")); - return false; + return v8::Nothing(); } } @@ -199,7 +224,7 @@ bool V8TestCallbackInterface::booleanMethod() { GetIsolate()).ToLocal(&call_result)) { // step 14. If callResult is an abrupt completion, set completion to // callResult and jump to the step labeled return. - return false; + return v8::Nothing(); } // step 15. Set completion to the result of converting callResult.[[Value]] to @@ -212,19 +237,31 @@ bool V8TestCallbackInterface::booleanMethod() { auto native_result = NativeValueTraits::NativeValue( GetIsolate(), call_result, exception_state); - ALLOW_UNUSED_LOCAL(native_result); - return !exception_state.HadException(); + if (exception_state.HadException()) + return v8::Nothing(); + else + return v8::Just(native_result); } } -void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg) { +v8::Maybe V8TestCallbackInterface::voidMethodBooleanArg(ScriptWrappable* callback_this_value, bool boolArg) { // This function implements "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - ScriptWrappable* callback_this_value = nullptr; - if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { - return; + // Wrapper-tracing for the callback function makes the function object and + // its creation context alive. Thus it's safe to use the creation context + // of the callback function here. + v8::HandleScope handle_scope(GetIsolate()); + CHECK(!CallbackObject().IsEmpty()); + v8::Context::Scope context_scope(CallbackObject()->CreationContext()); + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethodBooleanArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } // step 7. Prepare to run script with relevant settings. @@ -232,14 +269,17 @@ void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg) { CallbackRelevantScriptState()); // step 8. Prepare to run a callback with stored settings. if (IncumbentScriptState()->GetContext().IsEmpty()) { - return; + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethodBooleanArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } v8::Context::BackupIncumbentScope backup_incumbent_scope( IncumbentScriptState()->GetContext()); - v8::TryCatch try_catch(GetIsolate()); - try_catch.SetVerbose(true); - v8::Local function; if (IsCallbackObjectCallable()) { // step 9.1. If value's interface is a single operation callback interface @@ -253,7 +293,7 @@ void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg) { if (!CallbackObject()->Get(CallbackRelevantScriptState()->GetContext(), V8String(GetIsolate(), "voidMethodBooleanArg")) .ToLocal(&value)) { - return; + return v8::Nothing(); } // step 10. If !IsCallable(X) is false, then set completion to a new // Completion{[[Type]]: throw, [[Value]]: a newly created TypeError @@ -265,7 +305,7 @@ void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg) { "voidMethodBooleanArg", "TestCallbackInterface", "The provided callback is not callable.")); - return; + return v8::Nothing(); } } @@ -303,23 +343,32 @@ void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg) { GetIsolate()).ToLocal(&call_result)) { // step 14. If callResult is an abrupt completion, set completion to // callResult and jump to the step labeled return. - return; + return v8::Nothing(); } // step 15. Set completion to the result of converting callResult.[[Value]] to // an IDL value of the same type as the operation's return type. - ALLOW_UNUSED_LOCAL(call_result); - return; + return v8::JustVoid(); } -void V8TestCallbackInterface::voidMethodSequenceArg(const HeapVector>& sequenceArg) { +v8::Maybe V8TestCallbackInterface::voidMethodSequenceArg(ScriptWrappable* callback_this_value, const HeapVector>& sequenceArg) { // This function implements "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - ScriptWrappable* callback_this_value = nullptr; - if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { - return; + // Wrapper-tracing for the callback function makes the function object and + // its creation context alive. Thus it's safe to use the creation context + // of the callback function here. + v8::HandleScope handle_scope(GetIsolate()); + CHECK(!CallbackObject().IsEmpty()); + v8::Context::Scope context_scope(CallbackObject()->CreationContext()); + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethodSequenceArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } // step 7. Prepare to run script with relevant settings. @@ -327,14 +376,17 @@ void V8TestCallbackInterface::voidMethodSequenceArg(const HeapVectorGetContext().IsEmpty()) { - return; + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethodSequenceArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } v8::Context::BackupIncumbentScope backup_incumbent_scope( IncumbentScriptState()->GetContext()); - v8::TryCatch try_catch(GetIsolate()); - try_catch.SetVerbose(true); - v8::Local function; if (IsCallbackObjectCallable()) { // step 9.1. If value's interface is a single operation callback interface @@ -348,7 +400,7 @@ void V8TestCallbackInterface::voidMethodSequenceArg(const HeapVectorGet(CallbackRelevantScriptState()->GetContext(), V8String(GetIsolate(), "voidMethodSequenceArg")) .ToLocal(&value)) { - return; + return v8::Nothing(); } // step 10. If !IsCallable(X) is false, then set completion to a new // Completion{[[Type]]: throw, [[Value]]: a newly created TypeError @@ -360,7 +412,7 @@ void V8TestCallbackInterface::voidMethodSequenceArg(const HeapVector(); } } @@ -398,23 +450,32 @@ void V8TestCallbackInterface::voidMethodSequenceArg(const HeapVector(); } // step 15. Set completion to the result of converting callResult.[[Value]] to // an IDL value of the same type as the operation's return type. - ALLOW_UNUSED_LOCAL(call_result); - return; + return v8::JustVoid(); } -void V8TestCallbackInterface::voidMethodFloatArg(float floatArg) { +v8::Maybe V8TestCallbackInterface::voidMethodFloatArg(ScriptWrappable* callback_this_value, float floatArg) { // This function implements "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - ScriptWrappable* callback_this_value = nullptr; - if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { - return; + // Wrapper-tracing for the callback function makes the function object and + // its creation context alive. Thus it's safe to use the creation context + // of the callback function here. + v8::HandleScope handle_scope(GetIsolate()); + CHECK(!CallbackObject().IsEmpty()); + v8::Context::Scope context_scope(CallbackObject()->CreationContext()); + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethodFloatArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } // step 7. Prepare to run script with relevant settings. @@ -422,14 +483,17 @@ void V8TestCallbackInterface::voidMethodFloatArg(float floatArg) { CallbackRelevantScriptState()); // step 8. Prepare to run a callback with stored settings. if (IncumbentScriptState()->GetContext().IsEmpty()) { - return; + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethodFloatArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } v8::Context::BackupIncumbentScope backup_incumbent_scope( IncumbentScriptState()->GetContext()); - v8::TryCatch try_catch(GetIsolate()); - try_catch.SetVerbose(true); - v8::Local function; if (IsCallbackObjectCallable()) { // step 9.1. If value's interface is a single operation callback interface @@ -443,7 +507,7 @@ void V8TestCallbackInterface::voidMethodFloatArg(float floatArg) { if (!CallbackObject()->Get(CallbackRelevantScriptState()->GetContext(), V8String(GetIsolate(), "voidMethodFloatArg")) .ToLocal(&value)) { - return; + return v8::Nothing(); } // step 10. If !IsCallable(X) is false, then set completion to a new // Completion{[[Type]]: throw, [[Value]]: a newly created TypeError @@ -455,7 +519,7 @@ void V8TestCallbackInterface::voidMethodFloatArg(float floatArg) { "voidMethodFloatArg", "TestCallbackInterface", "The provided callback is not callable.")); - return; + return v8::Nothing(); } } @@ -493,23 +557,32 @@ void V8TestCallbackInterface::voidMethodFloatArg(float floatArg) { GetIsolate()).ToLocal(&call_result)) { // step 14. If callResult is an abrupt completion, set completion to // callResult and jump to the step labeled return. - return; + return v8::Nothing(); } // step 15. Set completion to the result of converting callResult.[[Value]] to // an IDL value of the same type as the operation's return type. - ALLOW_UNUSED_LOCAL(call_result); - return; + return v8::JustVoid(); } -void V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty* testInterfaceEmptyArg) { +v8::Maybe V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg) { // This function implements "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - ScriptWrappable* callback_this_value = nullptr; - if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { - return; + // Wrapper-tracing for the callback function makes the function object and + // its creation context alive. Thus it's safe to use the creation context + // of the callback function here. + v8::HandleScope handle_scope(GetIsolate()); + CHECK(!CallbackObject().IsEmpty()); + v8::Context::Scope context_scope(CallbackObject()->CreationContext()); + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethodTestInterfaceEmptyArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } // step 7. Prepare to run script with relevant settings. @@ -517,14 +590,17 @@ void V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty CallbackRelevantScriptState()); // step 8. Prepare to run a callback with stored settings. if (IncumbentScriptState()->GetContext().IsEmpty()) { - return; + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethodTestInterfaceEmptyArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } v8::Context::BackupIncumbentScope backup_incumbent_scope( IncumbentScriptState()->GetContext()); - v8::TryCatch try_catch(GetIsolate()); - try_catch.SetVerbose(true); - v8::Local function; if (IsCallbackObjectCallable()) { // step 9.1. If value's interface is a single operation callback interface @@ -538,7 +614,7 @@ void V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty if (!CallbackObject()->Get(CallbackRelevantScriptState()->GetContext(), V8String(GetIsolate(), "voidMethodTestInterfaceEmptyArg")) .ToLocal(&value)) { - return; + return v8::Nothing(); } // step 10. If !IsCallable(X) is false, then set completion to a new // Completion{[[Type]]: throw, [[Value]]: a newly created TypeError @@ -550,7 +626,7 @@ void V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty "voidMethodTestInterfaceEmptyArg", "TestCallbackInterface", "The provided callback is not callable.")); - return; + return v8::Nothing(); } } @@ -588,23 +664,32 @@ void V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty GetIsolate()).ToLocal(&call_result)) { // step 14. If callResult is an abrupt completion, set completion to // callResult and jump to the step labeled return. - return; + return v8::Nothing(); } // step 15. Set completion to the result of converting callResult.[[Value]] to // an IDL value of the same type as the operation's return type. - ALLOW_UNUSED_LOCAL(call_result); - return; + return v8::JustVoid(); } -void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg) { +v8::Maybe V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg) { // This function implements "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - ScriptWrappable* callback_this_value = nullptr; - if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { - return; + // Wrapper-tracing for the callback function makes the function object and + // its creation context alive. Thus it's safe to use the creation context + // of the callback function here. + v8::HandleScope handle_scope(GetIsolate()); + CHECK(!CallbackObject().IsEmpty()); + v8::Context::Scope context_scope(CallbackObject()->CreationContext()); + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethodTestInterfaceEmptyStringArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } // step 7. Prepare to run script with relevant settings. @@ -612,14 +697,17 @@ void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfac CallbackRelevantScriptState()); // step 8. Prepare to run a callback with stored settings. if (IncumbentScriptState()->GetContext().IsEmpty()) { - return; + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "voidMethodTestInterfaceEmptyStringArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } v8::Context::BackupIncumbentScope backup_incumbent_scope( IncumbentScriptState()->GetContext()); - v8::TryCatch try_catch(GetIsolate()); - try_catch.SetVerbose(true); - v8::Local function; if (IsCallbackObjectCallable()) { // step 9.1. If value's interface is a single operation callback interface @@ -633,7 +721,7 @@ void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfac if (!CallbackObject()->Get(CallbackRelevantScriptState()->GetContext(), V8String(GetIsolate(), "voidMethodTestInterfaceEmptyStringArg")) .ToLocal(&value)) { - return; + return v8::Nothing(); } // step 10. If !IsCallable(X) is false, then set completion to a new // Completion{[[Type]]: throw, [[Value]]: a newly created TypeError @@ -645,7 +733,7 @@ void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfac "voidMethodTestInterfaceEmptyStringArg", "TestCallbackInterface", "The provided callback is not callable.")); - return; + return v8::Nothing(); } } @@ -684,23 +772,32 @@ void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfac GetIsolate()).ToLocal(&call_result)) { // step 14. If callResult is an abrupt completion, set completion to // callResult and jump to the step labeled return. - return; + return v8::Nothing(); } // step 15. Set completion to the result of converting callResult.[[Value]] to // an IDL value of the same type as the operation's return type. - ALLOW_UNUSED_LOCAL(call_result); - return; + return v8::JustVoid(); } -void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptValue thisValue, const String& stringArg) { +v8::Maybe V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptWrappable* callback_this_value, const String& stringArg) { // This function implements "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - ScriptWrappable* callback_this_value = nullptr; - if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { - return; + // Wrapper-tracing for the callback function makes the function object and + // its creation context alive. Thus it's safe to use the creation context + // of the callback function here. + v8::HandleScope handle_scope(GetIsolate()); + CHECK(!CallbackObject().IsEmpty()); + v8::Context::Scope context_scope(CallbackObject()->CreationContext()); + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "callbackWithThisValueVoidMethodStringArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } // step 7. Prepare to run script with relevant settings. @@ -708,14 +805,17 @@ void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptVal CallbackRelevantScriptState()); // step 8. Prepare to run a callback with stored settings. if (IncumbentScriptState()->GetContext().IsEmpty()) { - return; + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "callbackWithThisValueVoidMethodStringArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); } v8::Context::BackupIncumbentScope backup_incumbent_scope( IncumbentScriptState()->GetContext()); - v8::TryCatch try_catch(GetIsolate()); - try_catch.SetVerbose(true); - v8::Local function; if (IsCallbackObjectCallable()) { // step 9.1. If value's interface is a single operation callback interface @@ -729,7 +829,7 @@ void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptVal if (!CallbackObject()->Get(CallbackRelevantScriptState()->GetContext(), V8String(GetIsolate(), "callbackWithThisValueVoidMethodStringArg")) .ToLocal(&value)) { - return; + return v8::Nothing(); } // step 10. If !IsCallable(X) is false, then set completion to a new // Completion{[[Type]]: throw, [[Value]]: a newly created TypeError @@ -741,7 +841,7 @@ void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptVal "callbackWithThisValueVoidMethodStringArg", "TestCallbackInterface", "The provided callback is not callable.")); - return; + return v8::Nothing(); } } @@ -779,13 +879,173 @@ void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptVal GetIsolate()).ToLocal(&call_result)) { // step 14. If callResult is an abrupt completion, set completion to // callResult and jump to the step labeled return. - return; + return v8::Nothing(); + } + + // step 15. Set completion to the result of converting callResult.[[Value]] to + // an IDL value of the same type as the operation's return type. + return v8::JustVoid(); +} + +v8::Maybe V8TestCallbackInterface::customVoidMethodTestInterfaceEmptyArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg) { + // This function implements "call a user object's operation". + // https://heycam.github.io/webidl/#call-a-user-objects-operation + + if (!IsCallbackFunctionRunnable(CallbackRelevantScriptState())) { + // Wrapper-tracing for the callback function makes the function object and + // its creation context alive. Thus it's safe to use the creation context + // of the callback function here. + v8::HandleScope handle_scope(GetIsolate()); + CHECK(!CallbackObject().IsEmpty()); + v8::Context::Scope context_scope(CallbackObject()->CreationContext()); + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "customVoidMethodTestInterfaceEmptyArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); + } + + // step 7. Prepare to run script with relevant settings. + ScriptState::Scope callback_relevant_context_scope( + CallbackRelevantScriptState()); + // step 8. Prepare to run a callback with stored settings. + if (IncumbentScriptState()->GetContext().IsEmpty()) { + V8ThrowException::ThrowError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "customVoidMethodTestInterfaceEmptyArg", + "TestCallbackInterface", + "The provided callback is no longer runnable.")); + return v8::Nothing(); + } + v8::Context::BackupIncumbentScope backup_incumbent_scope( + IncumbentScriptState()->GetContext()); + + v8::Local function; + if (IsCallbackObjectCallable()) { + // step 9.1. If value's interface is a single operation callback interface + // and !IsCallable(O) is true, then set X to O. + function = CallbackObject().As(); + } else { + // step 9.2.1. Let getResult be Get(O, opName). + // step 9.2.2. If getResult is an abrupt completion, set completion to + // getResult and jump to the step labeled return. + v8::Local value; + if (!CallbackObject()->Get(CallbackRelevantScriptState()->GetContext(), + V8String(GetIsolate(), "customVoidMethodTestInterfaceEmptyArg")) + .ToLocal(&value)) { + return v8::Nothing(); + } + // step 10. If !IsCallable(X) is false, then set completion to a new + // Completion{[[Type]]: throw, [[Value]]: a newly created TypeError + // object, [[Target]]: empty}, and jump to the step labeled return. + if (!value->IsFunction()) { + V8ThrowException::ThrowTypeError( + GetIsolate(), + ExceptionMessages::FailedToExecute( + "customVoidMethodTestInterfaceEmptyArg", + "TestCallbackInterface", + "The provided callback is not callable.")); + return v8::Nothing(); + } + } + + v8::Local this_arg; + if (!IsCallbackObjectCallable()) { + // step 11. If value's interface is not a single operation callback + // interface, or if !IsCallable(O) is false, set thisArg to O (overriding + // the provided value). + this_arg = CallbackObject(); + } else if (!callback_this_value) { + // step 2. If thisArg was not given, let thisArg be undefined. + this_arg = v8::Undefined(GetIsolate()); + } else { + this_arg = ToV8(callback_this_value, CallbackRelevantScriptState()); + } + + // step 12. Let esArgs be the result of converting args to an ECMAScript + // arguments list. If this throws an exception, set completion to the + // completion value representing the thrown exception and jump to the step + // labeled return. + v8::Local argument_creation_context = + CallbackRelevantScriptState()->GetContext()->Global(); + ALLOW_UNUSED_LOCAL(argument_creation_context); + v8::Local testInterfaceEmptyArgHandle = ToV8(testInterfaceEmptyArg, argument_creation_context, GetIsolate()); + v8::Local argv[] = { testInterfaceEmptyArgHandle }; + + // step 13. Let callResult be Call(X, thisArg, esArgs). + v8::Local call_result; + if (!V8ScriptRunner::CallFunction( + function, + ExecutionContext::From(CallbackRelevantScriptState()), + this_arg, + 1, + argv, + GetIsolate()).ToLocal(&call_result)) { + // step 14. If callResult is an abrupt completion, set completion to + // callResult and jump to the step labeled return. + return v8::Nothing(); } // step 15. Set completion to the result of converting callResult.[[Value]] to // an IDL value of the same type as the operation's return type. - ALLOW_UNUSED_LOCAL(call_result); - return; + return v8::JustVoid(); +} + +CORE_EXTERN_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackInterface::voidMethod(ScriptWrappable* callback_this_value) { + return Proxy()->voidMethod( + callback_this_value); +} + +CORE_EXTERN_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackInterface::booleanMethod(ScriptWrappable* callback_this_value) { + return Proxy()->booleanMethod( + callback_this_value); +} + +CORE_EXTERN_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackInterface::voidMethodBooleanArg(ScriptWrappable* callback_this_value, bool boolArg) { + return Proxy()->voidMethodBooleanArg( + callback_this_value, boolArg); +} + +CORE_EXTERN_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackInterface::voidMethodSequenceArg(ScriptWrappable* callback_this_value, const HeapVector>& sequenceArg) { + return Proxy()->voidMethodSequenceArg( + callback_this_value, sequenceArg); +} + +CORE_EXTERN_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackInterface::voidMethodFloatArg(ScriptWrappable* callback_this_value, float floatArg) { + return Proxy()->voidMethodFloatArg( + callback_this_value, floatArg); +} + +CORE_EXTERN_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackInterface::voidMethodTestInterfaceEmptyArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg) { + return Proxy()->voidMethodTestInterfaceEmptyArg( + callback_this_value, testInterfaceEmptyArg); +} + +CORE_EXTERN_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackInterface::voidMethodTestInterfaceEmptyStringArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg) { + return Proxy()->voidMethodTestInterfaceEmptyStringArg( + callback_this_value, testInterfaceEmptyArg, stringArg); +} + +CORE_EXTERN_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptWrappable* callback_this_value, const String& stringArg) { + return Proxy()->callbackWithThisValueVoidMethodStringArg( + callback_this_value, stringArg); +} + +CORE_EXTERN_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackInterface::customVoidMethodTestInterfaceEmptyArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg) { + return Proxy()->customVoidMethodTestInterfaceEmptyArg( + callback_this_value, testInterfaceEmptyArg); } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackInterface.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackInterface.h index c41dfba421..1d7b3f8075 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackInterface.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestCallbackInterface.h @@ -12,15 +12,14 @@ #ifndef V8TestCallbackInterface_h #define V8TestCallbackInterface_h -#include "bindings/tests/idls/core/TestCallbackInterface.h" #include "core/CoreExport.h" #include "platform/bindings/CallbackInterfaceBase.h" namespace blink { -class CORE_EXPORT V8TestCallbackInterface final - : public TestCallbackInterface, - public CallbackInterfaceBase { +class TestInterfaceEmpty; + +class CORE_EXPORT V8TestCallbackInterface final : public CallbackInterfaceBase { public: static V8TestCallbackInterface* Create(v8::Local callback_object) { return new V8TestCallbackInterface(callback_object); @@ -30,45 +29,95 @@ class CORE_EXPORT V8TestCallbackInterface final // Performs "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - void voidMethod() override; + v8::Maybe voidMethod(ScriptWrappable* callback_this_value) WARN_UNUSED_RESULT; // Performs "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - bool booleanMethod() override; + v8::Maybe booleanMethod(ScriptWrappable* callback_this_value) WARN_UNUSED_RESULT; // Performs "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - void voidMethodBooleanArg(bool boolArg) override; + v8::Maybe voidMethodBooleanArg(ScriptWrappable* callback_this_value, bool boolArg) WARN_UNUSED_RESULT; // Performs "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - void voidMethodSequenceArg(const HeapVector>& sequenceArg) override; + v8::Maybe voidMethodSequenceArg(ScriptWrappable* callback_this_value, const HeapVector>& sequenceArg) WARN_UNUSED_RESULT; // Performs "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - void voidMethodFloatArg(float floatArg) override; + v8::Maybe voidMethodFloatArg(ScriptWrappable* callback_this_value, float floatArg) WARN_UNUSED_RESULT; // Performs "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - void voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty* testInterfaceEmptyArg) override; + v8::Maybe voidMethodTestInterfaceEmptyArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg) WARN_UNUSED_RESULT; // Performs "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - void voidMethodTestInterfaceEmptyStringArg(TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg) override; + v8::Maybe voidMethodTestInterfaceEmptyStringArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg) WARN_UNUSED_RESULT; // Performs "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - void callbackWithThisValueVoidMethodStringArg(ScriptValue thisValue, const String& stringArg) override; + v8::Maybe callbackWithThisValueVoidMethodStringArg(ScriptWrappable* callback_this_value, const String& stringArg) WARN_UNUSED_RESULT; // Performs "call a user object's operation". // https://heycam.github.io/webidl/#call-a-user-objects-operation - void customVoidMethodTestInterfaceEmptyArg(TestInterfaceEmpty* testInterfaceEmptyArg) override; + v8::Maybe customVoidMethodTestInterfaceEmptyArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg) WARN_UNUSED_RESULT; private: explicit V8TestCallbackInterface(v8::Local callback_object) : CallbackInterfaceBase(callback_object, kNotSingleOperation) {} }; +template <> +class CORE_TEMPLATE_CLASS_EXPORT V8PersistentCallbackInterface final : public V8PersistentCallbackInterfaceBase { + using V8CallbackInterface = V8TestCallbackInterface; + + public: + ~V8PersistentCallbackInterface() override = default; + + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe voidMethod(ScriptWrappable* callback_this_value) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe booleanMethod(ScriptWrappable* callback_this_value) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe voidMethodBooleanArg(ScriptWrappable* callback_this_value, bool boolArg) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe voidMethodSequenceArg(ScriptWrappable* callback_this_value, const HeapVector>& sequenceArg) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe voidMethodFloatArg(ScriptWrappable* callback_this_value, float floatArg) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe voidMethodTestInterfaceEmptyArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe voidMethodTestInterfaceEmptyStringArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe callbackWithThisValueVoidMethodStringArg(ScriptWrappable* callback_this_value, const String& stringArg) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe customVoidMethodTestInterfaceEmptyArg(ScriptWrappable* callback_this_value, TestInterfaceEmpty* testInterfaceEmptyArg) WARN_UNUSED_RESULT; + + private: + explicit V8PersistentCallbackInterface(V8CallbackInterface* callback_interface) + : V8PersistentCallbackInterfaceBase(callback_interface) {} + + V8CallbackInterface* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackInterface* + ToV8PersistentCallbackInterface(V8CallbackInterface*); +}; + +// V8TestCallbackInterface is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback interfaces is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackInterface*). +#if 0 +// TODO(yukishiino): Enable this deletion once CallbackInterfaceBase transitions +// to wrapper-tracing. +Persistent WrapPersistent(V8TestCallbackInterface*) = delete; +#endif + } // namespace blink #endif // V8TestCallbackInterface_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.cpp index e22b2528e8..e78c019d76 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.cpp @@ -33,8 +33,6 @@ namespace blink { const WrapperTypeInfo V8TestConstants::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestConstants::domTemplate, - V8TestConstants::Trace, - V8TestConstants::TraceWrappers, nullptr, "TestConstants", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.h index 83a77421ea..f0d663b8e3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestConstants.h @@ -36,12 +36,6 @@ class V8TestConstants { } CORE_EXPORT static TestConstants* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; static void installFeatureName1(v8::Isolate*, const DOMWrapperWorld&, v8::Local instance, v8::Local prototype, v8::Local interface); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp index bfea7af785..3b2f5e1d75 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp @@ -39,6 +39,7 @@ static const v8::Eternal* eternalV8TestDictionaryKeys(v8::Isolate* iso "applicableToTypeLongMember", "applicableToTypeStringMember", "booleanMember", + "byteStringMember", "create", "deprecatedCreateMember", "dictionaryMember", @@ -52,6 +53,7 @@ static const v8::Eternal* eternalV8TestDictionaryKeys(v8::Isolate* iso "elementOrNullRecordMember", "elementOrNullSequenceMember", "enumMember", + "enumOrNullMember", "enumSequenceMember", "eventTargetMember", "garbageCollectedRecordMember", @@ -72,6 +74,8 @@ static const v8::Eternal* eternalV8TestDictionaryKeys(v8::Isolate* iso "stringOrNullRecordMember", "stringOrNullSequenceMember", "stringSequenceMember", + "testEnumOrNullOrTestEnumSequenceMember", + "testEnumOrTestEnumOrNullSequenceMember", "testEnumOrTestEnumSequenceMember", "testInterface2OrUint8ArrayMember", "testInterfaceGarbageCollectedMember", @@ -89,6 +93,7 @@ static const v8::Eternal* eternalV8TestDictionaryKeys(v8::Isolate* iso "unionOrNullSequenceMember", "unionWithTypedefs", "unrestrictedDoubleMember", + "usvStringOrNullMember", }; return V8PerIsolateData::From(isolate)->FindOrCreateEternalNameCache( kKeys, kKeys, WTF_ARRAY_LENGTH(kKeys)); @@ -178,8 +183,22 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value impl.setBooleanMember(booleanMemberCppValue); } + v8::Local byteStringMemberValue; + if (!v8Object->Get(context, keys[5].Get(isolate)).ToLocal(&byteStringMemberValue)) { + exceptionState.RethrowV8Exception(block.Exception()); + return; + } + if (byteStringMemberValue.IsEmpty() || byteStringMemberValue->IsUndefined()) { + // Do nothing. + } else { + V8StringResource byteStringMemberCppValue = NativeValueTraits>::NativeValue(isolate, byteStringMemberValue, exceptionState); + if (exceptionState.HadException()) + return; + impl.setByteStringMember(byteStringMemberCppValue); + } + v8::Local createValue; - if (!v8Object->Get(context, keys[5].Get(isolate)).ToLocal(&createValue)) { + if (!v8Object->Get(context, keys[6].Get(isolate)).ToLocal(&createValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -193,7 +212,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local deprecatedCreateMemberValue; - if (!v8Object->Get(context, keys[6].Get(isolate)).ToLocal(&deprecatedCreateMemberValue)) { + if (!v8Object->Get(context, keys[7].Get(isolate)).ToLocal(&deprecatedCreateMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -208,7 +227,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local dictionaryMemberValue; - if (!v8Object->Get(context, keys[7].Get(isolate)).ToLocal(&dictionaryMemberValue)) { + if (!v8Object->Get(context, keys[8].Get(isolate)).ToLocal(&dictionaryMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -226,7 +245,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local doubleOrNullMemberValue; - if (!v8Object->Get(context, keys[8].Get(isolate)).ToLocal(&doubleOrNullMemberValue)) { + if (!v8Object->Get(context, keys[9].Get(isolate)).ToLocal(&doubleOrNullMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -242,7 +261,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local doubleOrNullOrDoubleOrNullSequenceMemberValue; - if (!v8Object->Get(context, keys[9].Get(isolate)).ToLocal(&doubleOrNullOrDoubleOrNullSequenceMemberValue)) { + if (!v8Object->Get(context, keys[10].Get(isolate)).ToLocal(&doubleOrNullOrDoubleOrNullSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -257,7 +276,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local doubleOrNullRecordMemberValue; - if (!v8Object->Get(context, keys[10].Get(isolate)).ToLocal(&doubleOrNullRecordMemberValue)) { + if (!v8Object->Get(context, keys[11].Get(isolate)).ToLocal(&doubleOrNullRecordMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -271,7 +290,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local doubleOrNullSequenceMemberValue; - if (!v8Object->Get(context, keys[11].Get(isolate)).ToLocal(&doubleOrNullSequenceMemberValue)) { + if (!v8Object->Get(context, keys[12].Get(isolate)).ToLocal(&doubleOrNullSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -285,7 +304,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local doubleOrStringMemberValue; - if (!v8Object->Get(context, keys[12].Get(isolate)).ToLocal(&doubleOrStringMemberValue)) { + if (!v8Object->Get(context, keys[13].Get(isolate)).ToLocal(&doubleOrStringMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -300,7 +319,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local doubleOrStringSequenceMemberValue; - if (!v8Object->Get(context, keys[13].Get(isolate)).ToLocal(&doubleOrStringSequenceMemberValue)) { + if (!v8Object->Get(context, keys[14].Get(isolate)).ToLocal(&doubleOrStringSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -314,7 +333,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local elementOrNullMemberValue; - if (!v8Object->Get(context, keys[14].Get(isolate)).ToLocal(&elementOrNullMemberValue)) { + if (!v8Object->Get(context, keys[15].Get(isolate)).ToLocal(&elementOrNullMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -332,7 +351,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local elementOrNullRecordMemberValue; - if (!v8Object->Get(context, keys[15].Get(isolate)).ToLocal(&elementOrNullRecordMemberValue)) { + if (!v8Object->Get(context, keys[16].Get(isolate)).ToLocal(&elementOrNullRecordMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -346,7 +365,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local elementOrNullSequenceMemberValue; - if (!v8Object->Get(context, keys[16].Get(isolate)).ToLocal(&elementOrNullSequenceMemberValue)) { + if (!v8Object->Get(context, keys[17].Get(isolate)).ToLocal(&elementOrNullSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -360,7 +379,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local enumMemberValue; - if (!v8Object->Get(context, keys[17].Get(isolate)).ToLocal(&enumMemberValue)) { + if (!v8Object->Get(context, keys[18].Get(isolate)).ToLocal(&enumMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -381,8 +400,31 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value impl.setEnumMember(enumMemberCppValue); } + v8::Local enumOrNullMemberValue; + if (!v8Object->Get(context, keys[19].Get(isolate)).ToLocal(&enumOrNullMemberValue)) { + exceptionState.RethrowV8Exception(block.Exception()); + return; + } + if (enumOrNullMemberValue.IsEmpty() || enumOrNullMemberValue->IsUndefined()) { + // Do nothing. + } else { + V8StringResource enumOrNullMemberCppValue = enumOrNullMemberValue; + if (!enumOrNullMemberCppValue.Prepare(exceptionState)) + return; + const char* validValues[] = { + nullptr, + "", + "EnumValue1", + "EnumValue2", + "EnumValue3", + }; + if (!IsValidEnum(enumOrNullMemberCppValue, validValues, WTF_ARRAY_LENGTH(validValues), "TestEnum", exceptionState)) + return; + impl.setEnumOrNullMember(enumOrNullMemberCppValue); + } + v8::Local enumSequenceMemberValue; - if (!v8Object->Get(context, keys[18].Get(isolate)).ToLocal(&enumSequenceMemberValue)) { + if (!v8Object->Get(context, keys[20].Get(isolate)).ToLocal(&enumSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -404,7 +446,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local eventTargetMemberValue; - if (!v8Object->Get(context, keys[19].Get(isolate)).ToLocal(&eventTargetMemberValue)) { + if (!v8Object->Get(context, keys[21].Get(isolate)).ToLocal(&eventTargetMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -420,7 +462,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local garbageCollectedRecordMemberValue; - if (!v8Object->Get(context, keys[20].Get(isolate)).ToLocal(&garbageCollectedRecordMemberValue)) { + if (!v8Object->Get(context, keys[22].Get(isolate)).ToLocal(&garbageCollectedRecordMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -434,7 +476,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local internalDictionarySequenceMemberValue; - if (!v8Object->Get(context, keys[21].Get(isolate)).ToLocal(&internalDictionarySequenceMemberValue)) { + if (!v8Object->Get(context, keys[23].Get(isolate)).ToLocal(&internalDictionarySequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -448,7 +490,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local longMemberValue; - if (!v8Object->Get(context, keys[22].Get(isolate)).ToLocal(&longMemberValue)) { + if (!v8Object->Get(context, keys[24].Get(isolate)).ToLocal(&longMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -462,7 +504,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local objectMemberValue; - if (!v8Object->Get(context, keys[23].Get(isolate)).ToLocal(&objectMemberValue)) { + if (!v8Object->Get(context, keys[25].Get(isolate)).ToLocal(&objectMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -478,7 +520,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local objectOrNullMemberValue; - if (!v8Object->Get(context, keys[24].Get(isolate)).ToLocal(&objectOrNullMemberValue)) { + if (!v8Object->Get(context, keys[26].Get(isolate)).ToLocal(&objectOrNullMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -496,7 +538,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local otherDoubleOrStringMemberValue; - if (!v8Object->Get(context, keys[27].Get(isolate)).ToLocal(&otherDoubleOrStringMemberValue)) { + if (!v8Object->Get(context, keys[29].Get(isolate)).ToLocal(&otherDoubleOrStringMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -511,7 +553,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local publicValue; - if (!v8Object->Get(context, keys[28].Get(isolate)).ToLocal(&publicValue)) { + if (!v8Object->Get(context, keys[30].Get(isolate)).ToLocal(&publicValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -525,7 +567,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local recordMemberValue; - if (!v8Object->Get(context, keys[29].Get(isolate)).ToLocal(&recordMemberValue)) { + if (!v8Object->Get(context, keys[31].Get(isolate)).ToLocal(&recordMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -539,7 +581,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local restrictedDoubleMemberValue; - if (!v8Object->Get(context, keys[30].Get(isolate)).ToLocal(&restrictedDoubleMemberValue)) { + if (!v8Object->Get(context, keys[32].Get(isolate)).ToLocal(&restrictedDoubleMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -553,7 +595,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local stringMemberValue; - if (!v8Object->Get(context, keys[33].Get(isolate)).ToLocal(&stringMemberValue)) { + if (!v8Object->Get(context, keys[35].Get(isolate)).ToLocal(&stringMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -567,51 +609,49 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local stringOrNullMemberValue; - if (!v8Object->Get(context, keys[34].Get(isolate)).ToLocal(&stringOrNullMemberValue)) { + if (!v8Object->Get(context, keys[36].Get(isolate)).ToLocal(&stringOrNullMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } if (stringOrNullMemberValue.IsEmpty() || stringOrNullMemberValue->IsUndefined()) { // Do nothing. - } else if (stringOrNullMemberValue->IsNull()) { - impl.setStringOrNullMemberToNull(); } else { - V8StringResource<> stringOrNullMemberCppValue = stringOrNullMemberValue; + V8StringResource stringOrNullMemberCppValue = stringOrNullMemberValue; if (!stringOrNullMemberCppValue.Prepare(exceptionState)) return; impl.setStringOrNullMember(stringOrNullMemberCppValue); } v8::Local stringOrNullRecordMemberValue; - if (!v8Object->Get(context, keys[35].Get(isolate)).ToLocal(&stringOrNullRecordMemberValue)) { + if (!v8Object->Get(context, keys[37].Get(isolate)).ToLocal(&stringOrNullRecordMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } if (stringOrNullRecordMemberValue.IsEmpty() || stringOrNullRecordMemberValue->IsUndefined()) { // Do nothing. } else { - Vector> stringOrNullRecordMemberCppValue = NativeValueTraits>>::NativeValue(isolate, stringOrNullRecordMemberValue, exceptionState); + Vector> stringOrNullRecordMemberCppValue = NativeValueTraits>>::NativeValue(isolate, stringOrNullRecordMemberValue, exceptionState); if (exceptionState.HadException()) return; impl.setStringOrNullRecordMember(stringOrNullRecordMemberCppValue); } v8::Local stringOrNullSequenceMemberValue; - if (!v8Object->Get(context, keys[36].Get(isolate)).ToLocal(&stringOrNullSequenceMemberValue)) { + if (!v8Object->Get(context, keys[38].Get(isolate)).ToLocal(&stringOrNullSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } if (stringOrNullSequenceMemberValue.IsEmpty() || stringOrNullSequenceMemberValue->IsUndefined()) { // Do nothing. } else { - Vector stringOrNullSequenceMemberCppValue = NativeValueTraits>>::NativeValue(isolate, stringOrNullSequenceMemberValue, exceptionState); + Vector stringOrNullSequenceMemberCppValue = NativeValueTraits>>::NativeValue(isolate, stringOrNullSequenceMemberValue, exceptionState); if (exceptionState.HadException()) return; impl.setStringOrNullSequenceMember(stringOrNullSequenceMemberCppValue); } v8::Local stringSequenceMemberValue; - if (!v8Object->Get(context, keys[37].Get(isolate)).ToLocal(&stringSequenceMemberValue)) { + if (!v8Object->Get(context, keys[39].Get(isolate)).ToLocal(&stringSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -624,8 +664,38 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value impl.setStringSequenceMember(stringSequenceMemberCppValue); } + v8::Local testEnumOrNullOrTestEnumSequenceMemberValue; + if (!v8Object->Get(context, keys[40].Get(isolate)).ToLocal(&testEnumOrNullOrTestEnumSequenceMemberValue)) { + exceptionState.RethrowV8Exception(block.Exception()); + return; + } + if (testEnumOrNullOrTestEnumSequenceMemberValue.IsEmpty() || testEnumOrNullOrTestEnumSequenceMemberValue->IsUndefined()) { + // Do nothing. + } else { + TestEnumOrTestEnumSequence testEnumOrNullOrTestEnumSequenceMemberCppValue; + V8TestEnumOrTestEnumSequence::ToImpl(isolate, testEnumOrNullOrTestEnumSequenceMemberValue, testEnumOrNullOrTestEnumSequenceMemberCppValue, UnionTypeConversionMode::kNullable, exceptionState); + if (exceptionState.HadException()) + return; + impl.setTestEnumOrNullOrTestEnumSequenceMember(testEnumOrNullOrTestEnumSequenceMemberCppValue); + } + + v8::Local testEnumOrTestEnumOrNullSequenceMemberValue; + if (!v8Object->Get(context, keys[41].Get(isolate)).ToLocal(&testEnumOrTestEnumOrNullSequenceMemberValue)) { + exceptionState.RethrowV8Exception(block.Exception()); + return; + } + if (testEnumOrTestEnumOrNullSequenceMemberValue.IsEmpty() || testEnumOrTestEnumOrNullSequenceMemberValue->IsUndefined()) { + // Do nothing. + } else { + TestEnumOrTestEnumOrNullSequence testEnumOrTestEnumOrNullSequenceMemberCppValue; + V8TestEnumOrTestEnumOrNullSequence::ToImpl(isolate, testEnumOrTestEnumOrNullSequenceMemberValue, testEnumOrTestEnumOrNullSequenceMemberCppValue, UnionTypeConversionMode::kNotNullable, exceptionState); + if (exceptionState.HadException()) + return; + impl.setTestEnumOrTestEnumOrNullSequenceMember(testEnumOrTestEnumOrNullSequenceMemberCppValue); + } + v8::Local testEnumOrTestEnumSequenceMemberValue; - if (!v8Object->Get(context, keys[38].Get(isolate)).ToLocal(&testEnumOrTestEnumSequenceMemberValue)) { + if (!v8Object->Get(context, keys[42].Get(isolate)).ToLocal(&testEnumOrTestEnumSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -640,7 +710,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local testInterface2OrUint8ArrayMemberValue; - if (!v8Object->Get(context, keys[39].Get(isolate)).ToLocal(&testInterface2OrUint8ArrayMemberValue)) { + if (!v8Object->Get(context, keys[43].Get(isolate)).ToLocal(&testInterface2OrUint8ArrayMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -655,7 +725,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local testInterfaceGarbageCollectedMemberValue; - if (!v8Object->Get(context, keys[40].Get(isolate)).ToLocal(&testInterfaceGarbageCollectedMemberValue)) { + if (!v8Object->Get(context, keys[44].Get(isolate)).ToLocal(&testInterfaceGarbageCollectedMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -671,7 +741,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local testInterfaceGarbageCollectedOrNullMemberValue; - if (!v8Object->Get(context, keys[41].Get(isolate)).ToLocal(&testInterfaceGarbageCollectedOrNullMemberValue)) { + if (!v8Object->Get(context, keys[45].Get(isolate)).ToLocal(&testInterfaceGarbageCollectedOrNullMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -689,7 +759,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local testInterfaceGarbageCollectedSequenceMemberValue; - if (!v8Object->Get(context, keys[42].Get(isolate)).ToLocal(&testInterfaceGarbageCollectedSequenceMemberValue)) { + if (!v8Object->Get(context, keys[46].Get(isolate)).ToLocal(&testInterfaceGarbageCollectedSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -703,7 +773,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local testInterfaceMemberValue; - if (!v8Object->Get(context, keys[43].Get(isolate)).ToLocal(&testInterfaceMemberValue)) { + if (!v8Object->Get(context, keys[47].Get(isolate)).ToLocal(&testInterfaceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -719,7 +789,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local testInterfaceOrNullMemberValue; - if (!v8Object->Get(context, keys[44].Get(isolate)).ToLocal(&testInterfaceOrNullMemberValue)) { + if (!v8Object->Get(context, keys[48].Get(isolate)).ToLocal(&testInterfaceOrNullMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -737,7 +807,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local testInterfaceSequenceMemberValue; - if (!v8Object->Get(context, keys[45].Get(isolate)).ToLocal(&testInterfaceSequenceMemberValue)) { + if (!v8Object->Get(context, keys[49].Get(isolate)).ToLocal(&testInterfaceSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -751,7 +821,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local testObjectSequenceMemberValue; - if (!v8Object->Get(context, keys[46].Get(isolate)).ToLocal(&testObjectSequenceMemberValue)) { + if (!v8Object->Get(context, keys[50].Get(isolate)).ToLocal(&testObjectSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -765,21 +835,21 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local treatNullAsStringSequenceMemberValue; - if (!v8Object->Get(context, keys[47].Get(isolate)).ToLocal(&treatNullAsStringSequenceMemberValue)) { + if (!v8Object->Get(context, keys[51].Get(isolate)).ToLocal(&treatNullAsStringSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } if (treatNullAsStringSequenceMemberValue.IsEmpty() || treatNullAsStringSequenceMemberValue->IsUndefined()) { // Do nothing. } else { - Vector treatNullAsStringSequenceMemberCppValue = NativeValueTraits>::NativeValue(isolate, treatNullAsStringSequenceMemberValue, exceptionState); + Vector treatNullAsStringSequenceMemberCppValue = NativeValueTraits>>::NativeValue(isolate, treatNullAsStringSequenceMemberValue, exceptionState); if (exceptionState.HadException()) return; impl.setTreatNullAsStringSequenceMember(treatNullAsStringSequenceMemberCppValue); } v8::Local uint8ArrayMemberValue; - if (!v8Object->Get(context, keys[48].Get(isolate)).ToLocal(&uint8ArrayMemberValue)) { + if (!v8Object->Get(context, keys[52].Get(isolate)).ToLocal(&uint8ArrayMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -797,7 +867,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local unionInRecordMemberValue; - if (!v8Object->Get(context, keys[49].Get(isolate)).ToLocal(&unionInRecordMemberValue)) { + if (!v8Object->Get(context, keys[53].Get(isolate)).ToLocal(&unionInRecordMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -811,7 +881,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local unionMemberWithSequenceDefaultValue; - if (!v8Object->Get(context, keys[50].Get(isolate)).ToLocal(&unionMemberWithSequenceDefaultValue)) { + if (!v8Object->Get(context, keys[54].Get(isolate)).ToLocal(&unionMemberWithSequenceDefaultValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -826,7 +896,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local unionOrNullRecordMemberValue; - if (!v8Object->Get(context, keys[51].Get(isolate)).ToLocal(&unionOrNullRecordMemberValue)) { + if (!v8Object->Get(context, keys[55].Get(isolate)).ToLocal(&unionOrNullRecordMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -840,7 +910,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local unionOrNullSequenceMemberValue; - if (!v8Object->Get(context, keys[52].Get(isolate)).ToLocal(&unionOrNullSequenceMemberValue)) { + if (!v8Object->Get(context, keys[56].Get(isolate)).ToLocal(&unionOrNullSequenceMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -854,7 +924,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local unionWithTypedefsValue; - if (!v8Object->Get(context, keys[53].Get(isolate)).ToLocal(&unionWithTypedefsValue)) { + if (!v8Object->Get(context, keys[57].Get(isolate)).ToLocal(&unionWithTypedefsValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -869,7 +939,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local unrestrictedDoubleMemberValue; - if (!v8Object->Get(context, keys[54].Get(isolate)).ToLocal(&unrestrictedDoubleMemberValue)) { + if (!v8Object->Get(context, keys[58].Get(isolate)).ToLocal(&unrestrictedDoubleMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -882,9 +952,23 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value impl.setUnrestrictedDoubleMember(unrestrictedDoubleMemberCppValue); } + v8::Local usvStringOrNullMemberValue; + if (!v8Object->Get(context, keys[59].Get(isolate)).ToLocal(&usvStringOrNullMemberValue)) { + exceptionState.RethrowV8Exception(block.Exception()); + return; + } + if (usvStringOrNullMemberValue.IsEmpty() || usvStringOrNullMemberValue->IsUndefined()) { + // Do nothing. + } else { + V8StringResource usvStringOrNullMemberCppValue = NativeValueTraits>::NativeValue(isolate, usvStringOrNullMemberValue, exceptionState); + if (exceptionState.HadException()) + return; + impl.setUsvStringOrNullMember(usvStringOrNullMemberCppValue); + } + if (RuntimeEnabledFeatures::RuntimeFeatureEnabled()) { v8::Local runtimeMemberValue; - if (!v8Object->Get(context, keys[31].Get(isolate)).ToLocal(&runtimeMemberValue)) { + if (!v8Object->Get(context, keys[33].Get(isolate)).ToLocal(&runtimeMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -898,7 +982,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value } v8::Local runtimeSecondMemberValue; - if (!v8Object->Get(context, keys[32].Get(isolate)).ToLocal(&runtimeSecondMemberValue)) { + if (!v8Object->Get(context, keys[34].Get(isolate)).ToLocal(&runtimeSecondMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -914,7 +998,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value if (OriginTrials::featureNameEnabled(executionContext)) { v8::Local originTrialMemberValue; - if (!v8Object->Get(context, keys[25].Get(isolate)).ToLocal(&originTrialMemberValue)) { + if (!v8Object->Get(context, keys[27].Get(isolate)).ToLocal(&originTrialMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -930,7 +1014,7 @@ void V8TestDictionary::ToImpl(v8::Isolate* isolate, v8::Local v8Value if (OriginTrials::featureName1Enabled(executionContext)) { v8::Local originTrialSecondMemberValue; - if (!v8Object->Get(context, keys[26].Get(isolate)).ToLocal(&originTrialSecondMemberValue)) { + if (!v8Object->Get(context, keys[28].Get(isolate)).ToLocal(&originTrialSecondMemberValue)) { exceptionState.RethrowV8Exception(block.Exception()); return; } @@ -1015,6 +1099,17 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio return false; } + v8::Local byteStringMemberValue; + bool byteStringMemberHasValueOrDefault = false; + if (impl.hasByteStringMember()) { + byteStringMemberValue = V8String(isolate, impl.byteStringMember()); + byteStringMemberHasValueOrDefault = true; + } + if (byteStringMemberHasValueOrDefault && + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[5].Get(isolate), byteStringMemberValue))) { + return false; + } + v8::Local createValue; bool createHasValueOrDefault = false; if (impl.hasCreateMember()) { @@ -1022,7 +1117,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio createHasValueOrDefault = true; } if (createHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[5].Get(isolate), createValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[6].Get(isolate), createValue))) { return false; } @@ -1033,7 +1128,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio deprecatedCreateMemberHasValueOrDefault = true; } if (deprecatedCreateMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[6].Get(isolate), deprecatedCreateMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[7].Get(isolate), deprecatedCreateMemberValue))) { return false; } @@ -1045,7 +1140,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio dictionaryMemberHasValueOrDefault = true; } if (dictionaryMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[7].Get(isolate), dictionaryMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[8].Get(isolate), dictionaryMemberValue))) { return false; } @@ -1059,7 +1154,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio doubleOrNullMemberHasValueOrDefault = true; } if (doubleOrNullMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[8].Get(isolate), doubleOrNullMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[9].Get(isolate), doubleOrNullMemberValue))) { return false; } @@ -1070,7 +1165,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio doubleOrNullOrDoubleOrNullSequenceMemberHasValueOrDefault = true; } if (doubleOrNullOrDoubleOrNullSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[9].Get(isolate), doubleOrNullOrDoubleOrNullSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[10].Get(isolate), doubleOrNullOrDoubleOrNullSequenceMemberValue))) { return false; } @@ -1081,7 +1176,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio doubleOrNullRecordMemberHasValueOrDefault = true; } if (doubleOrNullRecordMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[10].Get(isolate), doubleOrNullRecordMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[11].Get(isolate), doubleOrNullRecordMemberValue))) { return false; } @@ -1092,7 +1187,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio doubleOrNullSequenceMemberHasValueOrDefault = true; } if (doubleOrNullSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[11].Get(isolate), doubleOrNullSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[12].Get(isolate), doubleOrNullSequenceMemberValue))) { return false; } @@ -1106,7 +1201,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio doubleOrStringMemberHasValueOrDefault = true; } if (doubleOrStringMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[12].Get(isolate), doubleOrStringMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[13].Get(isolate), doubleOrStringMemberValue))) { return false; } @@ -1117,7 +1212,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio doubleOrStringSequenceMemberHasValueOrDefault = true; } if (doubleOrStringSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[13].Get(isolate), doubleOrStringSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[14].Get(isolate), doubleOrStringSequenceMemberValue))) { return false; } @@ -1131,7 +1226,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio elementOrNullMemberHasValueOrDefault = true; } if (elementOrNullMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[14].Get(isolate), elementOrNullMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[15].Get(isolate), elementOrNullMemberValue))) { return false; } @@ -1142,7 +1237,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio elementOrNullRecordMemberHasValueOrDefault = true; } if (elementOrNullRecordMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[15].Get(isolate), elementOrNullRecordMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[16].Get(isolate), elementOrNullRecordMemberValue))) { return false; } @@ -1153,7 +1248,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio elementOrNullSequenceMemberHasValueOrDefault = true; } if (elementOrNullSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[16].Get(isolate), elementOrNullSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[17].Get(isolate), elementOrNullSequenceMemberValue))) { return false; } @@ -1167,7 +1262,21 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio enumMemberHasValueOrDefault = true; } if (enumMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[17].Get(isolate), enumMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[18].Get(isolate), enumMemberValue))) { + return false; + } + + v8::Local enumOrNullMemberValue; + bool enumOrNullMemberHasValueOrDefault = false; + if (impl.hasEnumOrNullMember()) { + enumOrNullMemberValue = V8String(isolate, impl.enumOrNullMember()); + enumOrNullMemberHasValueOrDefault = true; + } else { + enumOrNullMemberValue = v8::Null(isolate); + enumOrNullMemberHasValueOrDefault = true; + } + if (enumOrNullMemberHasValueOrDefault && + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[19].Get(isolate), enumOrNullMemberValue))) { return false; } @@ -1178,7 +1287,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio enumSequenceMemberHasValueOrDefault = true; } if (enumSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[18].Get(isolate), enumSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[20].Get(isolate), enumSequenceMemberValue))) { return false; } @@ -1189,7 +1298,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio eventTargetMemberHasValueOrDefault = true; } if (eventTargetMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[19].Get(isolate), eventTargetMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[21].Get(isolate), eventTargetMemberValue))) { return false; } @@ -1200,7 +1309,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio garbageCollectedRecordMemberHasValueOrDefault = true; } if (garbageCollectedRecordMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[20].Get(isolate), garbageCollectedRecordMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[22].Get(isolate), garbageCollectedRecordMemberValue))) { return false; } @@ -1211,7 +1320,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio internalDictionarySequenceMemberHasValueOrDefault = true; } if (internalDictionarySequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[21].Get(isolate), internalDictionarySequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[23].Get(isolate), internalDictionarySequenceMemberValue))) { return false; } @@ -1225,7 +1334,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio longMemberHasValueOrDefault = true; } if (longMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[22].Get(isolate), longMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[24].Get(isolate), longMemberValue))) { return false; } @@ -1237,7 +1346,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio objectMemberHasValueOrDefault = true; } if (objectMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[23].Get(isolate), objectMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[25].Get(isolate), objectMemberValue))) { return false; } @@ -1252,7 +1361,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio objectOrNullMemberHasValueOrDefault = true; } if (objectOrNullMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[24].Get(isolate), objectOrNullMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[26].Get(isolate), objectOrNullMemberValue))) { return false; } @@ -1266,7 +1375,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio otherDoubleOrStringMemberHasValueOrDefault = true; } if (otherDoubleOrStringMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[27].Get(isolate), otherDoubleOrStringMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[29].Get(isolate), otherDoubleOrStringMemberValue))) { return false; } @@ -1277,7 +1386,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio publicHasValueOrDefault = true; } if (publicHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[28].Get(isolate), publicValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[30].Get(isolate), publicValue))) { return false; } @@ -1288,7 +1397,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio recordMemberHasValueOrDefault = true; } if (recordMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[29].Get(isolate), recordMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[31].Get(isolate), recordMemberValue))) { return false; } @@ -1302,7 +1411,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio restrictedDoubleMemberHasValueOrDefault = true; } if (restrictedDoubleMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[30].Get(isolate), restrictedDoubleMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[32].Get(isolate), restrictedDoubleMemberValue))) { return false; } @@ -1313,7 +1422,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio stringMemberHasValueOrDefault = true; } if (stringMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[33].Get(isolate), stringMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[35].Get(isolate), stringMemberValue))) { return false; } @@ -1327,7 +1436,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio stringOrNullMemberHasValueOrDefault = true; } if (stringOrNullMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[34].Get(isolate), stringOrNullMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[36].Get(isolate), stringOrNullMemberValue))) { return false; } @@ -1338,7 +1447,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio stringOrNullRecordMemberHasValueOrDefault = true; } if (stringOrNullRecordMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[35].Get(isolate), stringOrNullRecordMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[37].Get(isolate), stringOrNullRecordMemberValue))) { return false; } @@ -1349,7 +1458,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio stringOrNullSequenceMemberHasValueOrDefault = true; } if (stringOrNullSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[36].Get(isolate), stringOrNullSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[38].Get(isolate), stringOrNullSequenceMemberValue))) { return false; } @@ -1363,7 +1472,29 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio stringSequenceMemberHasValueOrDefault = true; } if (stringSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[37].Get(isolate), stringSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[39].Get(isolate), stringSequenceMemberValue))) { + return false; + } + + v8::Local testEnumOrNullOrTestEnumSequenceMemberValue; + bool testEnumOrNullOrTestEnumSequenceMemberHasValueOrDefault = false; + if (impl.hasTestEnumOrNullOrTestEnumSequenceMember()) { + testEnumOrNullOrTestEnumSequenceMemberValue = ToV8(impl.testEnumOrNullOrTestEnumSequenceMember(), creationContext, isolate); + testEnumOrNullOrTestEnumSequenceMemberHasValueOrDefault = true; + } + if (testEnumOrNullOrTestEnumSequenceMemberHasValueOrDefault && + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[40].Get(isolate), testEnumOrNullOrTestEnumSequenceMemberValue))) { + return false; + } + + v8::Local testEnumOrTestEnumOrNullSequenceMemberValue; + bool testEnumOrTestEnumOrNullSequenceMemberHasValueOrDefault = false; + if (impl.hasTestEnumOrTestEnumOrNullSequenceMember()) { + testEnumOrTestEnumOrNullSequenceMemberValue = ToV8(impl.testEnumOrTestEnumOrNullSequenceMember(), creationContext, isolate); + testEnumOrTestEnumOrNullSequenceMemberHasValueOrDefault = true; + } + if (testEnumOrTestEnumOrNullSequenceMemberHasValueOrDefault && + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[41].Get(isolate), testEnumOrTestEnumOrNullSequenceMemberValue))) { return false; } @@ -1374,7 +1505,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio testEnumOrTestEnumSequenceMemberHasValueOrDefault = true; } if (testEnumOrTestEnumSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[38].Get(isolate), testEnumOrTestEnumSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[42].Get(isolate), testEnumOrTestEnumSequenceMemberValue))) { return false; } @@ -1385,7 +1516,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio testInterface2OrUint8ArrayMemberHasValueOrDefault = true; } if (testInterface2OrUint8ArrayMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[39].Get(isolate), testInterface2OrUint8ArrayMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[43].Get(isolate), testInterface2OrUint8ArrayMemberValue))) { return false; } @@ -1396,7 +1527,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio testInterfaceGarbageCollectedMemberHasValueOrDefault = true; } if (testInterfaceGarbageCollectedMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[40].Get(isolate), testInterfaceGarbageCollectedMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[44].Get(isolate), testInterfaceGarbageCollectedMemberValue))) { return false; } @@ -1410,7 +1541,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio testInterfaceGarbageCollectedOrNullMemberHasValueOrDefault = true; } if (testInterfaceGarbageCollectedOrNullMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[41].Get(isolate), testInterfaceGarbageCollectedOrNullMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[45].Get(isolate), testInterfaceGarbageCollectedOrNullMemberValue))) { return false; } @@ -1424,7 +1555,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio testInterfaceGarbageCollectedSequenceMemberHasValueOrDefault = true; } if (testInterfaceGarbageCollectedSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[42].Get(isolate), testInterfaceGarbageCollectedSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[46].Get(isolate), testInterfaceGarbageCollectedSequenceMemberValue))) { return false; } @@ -1435,7 +1566,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio testInterfaceMemberHasValueOrDefault = true; } if (testInterfaceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[43].Get(isolate), testInterfaceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[47].Get(isolate), testInterfaceMemberValue))) { return false; } @@ -1449,7 +1580,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio testInterfaceOrNullMemberHasValueOrDefault = true; } if (testInterfaceOrNullMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[44].Get(isolate), testInterfaceOrNullMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[48].Get(isolate), testInterfaceOrNullMemberValue))) { return false; } @@ -1463,7 +1594,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio testInterfaceSequenceMemberHasValueOrDefault = true; } if (testInterfaceSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[45].Get(isolate), testInterfaceSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[49].Get(isolate), testInterfaceSequenceMemberValue))) { return false; } @@ -1474,7 +1605,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio testObjectSequenceMemberHasValueOrDefault = true; } if (testObjectSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[46].Get(isolate), testObjectSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[50].Get(isolate), testObjectSequenceMemberValue))) { return false; } @@ -1488,7 +1619,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio treatNullAsStringSequenceMemberHasValueOrDefault = true; } if (treatNullAsStringSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[47].Get(isolate), treatNullAsStringSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[51].Get(isolate), treatNullAsStringSequenceMemberValue))) { return false; } @@ -1499,7 +1630,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio uint8ArrayMemberHasValueOrDefault = true; } if (uint8ArrayMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[48].Get(isolate), uint8ArrayMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[52].Get(isolate), uint8ArrayMemberValue))) { return false; } @@ -1510,7 +1641,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio unionInRecordMemberHasValueOrDefault = true; } if (unionInRecordMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[49].Get(isolate), unionInRecordMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[53].Get(isolate), unionInRecordMemberValue))) { return false; } @@ -1524,7 +1655,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio unionMemberWithSequenceDefaultHasValueOrDefault = true; } if (unionMemberWithSequenceDefaultHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[50].Get(isolate), unionMemberWithSequenceDefaultValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[54].Get(isolate), unionMemberWithSequenceDefaultValue))) { return false; } @@ -1535,7 +1666,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio unionOrNullRecordMemberHasValueOrDefault = true; } if (unionOrNullRecordMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[51].Get(isolate), unionOrNullRecordMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[55].Get(isolate), unionOrNullRecordMemberValue))) { return false; } @@ -1546,7 +1677,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio unionOrNullSequenceMemberHasValueOrDefault = true; } if (unionOrNullSequenceMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[52].Get(isolate), unionOrNullSequenceMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[56].Get(isolate), unionOrNullSequenceMemberValue))) { return false; } @@ -1557,7 +1688,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio unionWithTypedefsHasValueOrDefault = true; } if (unionWithTypedefsHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[53].Get(isolate), unionWithTypedefsValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[57].Get(isolate), unionWithTypedefsValue))) { return false; } @@ -1571,7 +1702,21 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio unrestrictedDoubleMemberHasValueOrDefault = true; } if (unrestrictedDoubleMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[54].Get(isolate), unrestrictedDoubleMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[58].Get(isolate), unrestrictedDoubleMemberValue))) { + return false; + } + + v8::Local usvStringOrNullMemberValue; + bool usvStringOrNullMemberHasValueOrDefault = false; + if (impl.hasUsvStringOrNullMember()) { + usvStringOrNullMemberValue = V8String(isolate, impl.usvStringOrNullMember()); + usvStringOrNullMemberHasValueOrDefault = true; + } else { + usvStringOrNullMemberValue = v8::Null(isolate); + usvStringOrNullMemberHasValueOrDefault = true; + } + if (usvStringOrNullMemberHasValueOrDefault && + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[59].Get(isolate), usvStringOrNullMemberValue))) { return false; } @@ -1583,7 +1728,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio runtimeMemberHasValueOrDefault = true; } if (runtimeMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[31].Get(isolate), runtimeMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[33].Get(isolate), runtimeMemberValue))) { return false; } @@ -1594,7 +1739,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio runtimeSecondMemberHasValueOrDefault = true; } if (runtimeSecondMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[32].Get(isolate), runtimeSecondMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[34].Get(isolate), runtimeSecondMemberValue))) { return false; } } @@ -1607,7 +1752,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio originTrialMemberHasValueOrDefault = true; } if (originTrialMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[25].Get(isolate), originTrialMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[27].Get(isolate), originTrialMemberValue))) { return false; } } @@ -1620,7 +1765,7 @@ bool toV8TestDictionary(const TestDictionary& impl, v8::Local dictio originTrialSecondMemberHasValueOrDefault = true; } if (originTrialSecondMemberHasValueOrDefault && - !V8CallBoolean(dictionary->CreateDataProperty(context, keys[26].Get(isolate), originTrialSecondMemberValue))) { + !V8CallBoolean(dictionary->CreateDataProperty(context, keys[28].Get(isolate), originTrialSecondMemberValue))) { return false; } } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.cpp index e6359b99f6..c6a4d9f96a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.cpp @@ -36,8 +36,6 @@ namespace blink { const WrapperTypeInfo V8TestIntegerIndexed::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestIntegerIndexed::domTemplate, - V8TestIntegerIndexed::Trace, - V8TestIntegerIndexed::TraceWrappers, nullptr, "TestIntegerIndexed", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.h index 63ed663509..1a30c81dc7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexed.h @@ -35,12 +35,6 @@ class V8TestIntegerIndexed { } CORE_EXPORT static TestIntegerIndexed* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackInfo&); static void indexedPropertySetterCustom(uint32_t, v8::Local, const v8::PropertyCallbackInfo&); static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo&); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp index c1f41ed45f..ea0a1165ae 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.cpp @@ -33,8 +33,6 @@ namespace blink { const WrapperTypeInfo V8TestIntegerIndexedGlobal::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestIntegerIndexedGlobal::domTemplate, - V8TestIntegerIndexedGlobal::Trace, - V8TestIntegerIndexedGlobal::TraceWrappers, nullptr, "TestIntegerIndexedGlobal", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.h index a0a1a1013e..46526676df 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedGlobal.h @@ -36,12 +36,6 @@ class V8TestIntegerIndexedGlobal { } CORE_EXPORT static TestIntegerIndexedGlobal* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackInfo&); static void indexedPropertySetterCustom(uint32_t, v8::Local, const v8::PropertyCallbackInfo&); static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo&); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.cpp index 5984ea3235..2879ebaa04 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.cpp @@ -33,8 +33,6 @@ namespace blink { const WrapperTypeInfo V8TestIntegerIndexedPrimaryGlobal::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestIntegerIndexedPrimaryGlobal::domTemplate, - V8TestIntegerIndexedPrimaryGlobal::Trace, - V8TestIntegerIndexedPrimaryGlobal::TraceWrappers, nullptr, "TestIntegerIndexedPrimaryGlobal", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.h index 179ddcac8d..40e6f5c1b8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestIntegerIndexedPrimaryGlobal.h @@ -36,12 +36,6 @@ class V8TestIntegerIndexedPrimaryGlobal { } CORE_EXPORT static TestIntegerIndexedPrimaryGlobal* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackInfo&); static void indexedPropertySetterCustom(uint32_t, v8::Local, const v8::PropertyCallbackInfo&); static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo&); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp index 06126964a3..94784a16d7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.cpp @@ -51,8 +51,6 @@ namespace blink { WrapperTypeInfo V8TestInterface::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface::domTemplate, - V8TestInterface::Trace, - V8TestInterface::TraceWrappers, V8TestInterface::InstallConditionalFeatures, "TestInterface", &V8TestInterfaceEmpty::wrapperTypeInfo, @@ -272,6 +270,50 @@ static void testEnumAttributeAttributeSetter(v8::Local v8Value, const impl->setTestEnumAttribute(cppValue); } +static void testEnumOrNullAttributeAttributeGetter(const v8::FunctionCallbackInfo& info) { + v8::Local holder = info.Holder(); + + TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); + + V8SetReturnValueStringOrNull(info, impl->testEnumOrNullAttribute(), info.GetIsolate()); +} + +static void testEnumOrNullAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { + v8::Isolate* isolate = info.GetIsolate(); + ALLOW_UNUSED_LOCAL(isolate); + + v8::Local holder = info.Holder(); + ALLOW_UNUSED_LOCAL(holder); + + TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); + + ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "testEnumOrNullAttribute"); + + // Prepare the value to be set. + V8StringResource cppValue = v8Value; + if (!cppValue.Prepare()) + return; + + // Type check per: http://heycam.github.io/webidl/#dfn-attribute-setter + // Returns undefined without setting the value if the value is invalid. + DummyExceptionStateForTesting dummyExceptionState; + const char* validValues[] = { + nullptr, + "", + "EnumValue1", + "EnumValue2", + "EnumValue3", + }; + if (!IsValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "TestEnum", dummyExceptionState)) { + ExecutionContext::ForCurrentRealm(info)->AddConsoleMessage( + ConsoleMessage::Create(kJSMessageSource, kWarningMessageLevel, + dummyExceptionState.Message())); + return; + } + + impl->setTestEnumOrNullAttribute(cppValue); +} + static void stringOrDoubleAttributeAttributeGetter(const v8::FunctionCallbackInfo& info) { v8::Local holder = info.Holder(); @@ -475,6 +517,58 @@ static void legacyInterfaceTypeCheckingAttributeAttributeSetter(v8::LocalsetLegacyInterfaceTypeCheckingAttribute(cppValue); } +static void stringNullAsEmptyAttributeAttributeGetter(const v8::FunctionCallbackInfo& info) { + v8::Local holder = info.Holder(); + + TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); + + V8SetReturnValueString(info, impl->stringNullAsEmptyAttribute(), info.GetIsolate()); +} + +static void stringNullAsEmptyAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { + v8::Isolate* isolate = info.GetIsolate(); + ALLOW_UNUSED_LOCAL(isolate); + + v8::Local holder = info.Holder(); + ALLOW_UNUSED_LOCAL(holder); + + TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); + + // Prepare the value to be set. + V8StringResource cppValue = v8Value; + if (!cppValue.Prepare()) + return; + + impl->setStringNullAsEmptyAttribute(cppValue); +} + +static void usvStringOrNullAttributeAttributeGetter(const v8::FunctionCallbackInfo& info) { + v8::Local holder = info.Holder(); + + TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); + + V8SetReturnValueStringOrNull(info, impl->usvStringOrNullAttribute(), info.GetIsolate()); +} + +static void usvStringOrNullAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { + v8::Isolate* isolate = info.GetIsolate(); + ALLOW_UNUSED_LOCAL(isolate); + + v8::Local holder = info.Holder(); + ALLOW_UNUSED_LOCAL(holder); + + TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); + + ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "usvStringOrNullAttribute"); + + // Prepare the value to be set. + V8StringResource cppValue = NativeValueTraits>::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) + return; + + impl->setUsvStringOrNullAttribute(cppValue); +} + static void alwaysExposedAttributeAttributeGetter(const v8::FunctionCallbackInfo& info) { v8::Local holder = info.Holder(); @@ -594,7 +688,7 @@ static void secureContextAttributeAttributeGetter(const v8::FunctionCallbackInfo TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextAttribute()); } static void secureContextAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -609,13 +703,9 @@ static void secureContextAttributeAttributeSetter(v8::Local v8Value, ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "secureContextAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextAttribute(cppValue); } @@ -625,7 +715,7 @@ static void secureContextRuntimeEnabledAttributeAttributeGetter(const v8::Functi TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextRuntimeEnabledAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextRuntimeEnabledAttribute()); } static void secureContextRuntimeEnabledAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -640,13 +730,9 @@ static void secureContextRuntimeEnabledAttributeAttributeSetter(v8::Local::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextRuntimeEnabledAttribute(cppValue); } @@ -656,7 +742,7 @@ static void secureContextWindowExposedAttributeAttributeGetter(const v8::Functio TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextWindowExposedAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextWindowExposedAttribute()); } static void secureContextWindowExposedAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -671,13 +757,9 @@ static void secureContextWindowExposedAttributeAttributeSetter(v8::Local::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextWindowExposedAttribute(cppValue); } @@ -687,7 +769,7 @@ static void secureContextWorkerExposedAttributeAttributeGetter(const v8::Functio TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextWorkerExposedAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextWorkerExposedAttribute()); } static void secureContextWorkerExposedAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -702,13 +784,9 @@ static void secureContextWorkerExposedAttributeAttributeSetter(v8::Local::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextWorkerExposedAttribute(cppValue); } @@ -718,7 +796,7 @@ static void secureContextWindowExposedRuntimeEnabledAttributeAttributeGetter(con TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextWindowExposedRuntimeEnabledAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextWindowExposedRuntimeEnabledAttribute()); } static void secureContextWindowExposedRuntimeEnabledAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -733,13 +811,9 @@ static void secureContextWindowExposedRuntimeEnabledAttributeAttributeSetter(v8: ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "secureContextWindowExposedRuntimeEnabledAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextWindowExposedRuntimeEnabledAttribute(cppValue); } @@ -749,7 +823,7 @@ static void secureContextWorkerExposedRuntimeEnabledAttributeAttributeGetter(con TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextWorkerExposedRuntimeEnabledAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextWorkerExposedRuntimeEnabledAttribute()); } static void secureContextWorkerExposedRuntimeEnabledAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -764,13 +838,9 @@ static void secureContextWorkerExposedRuntimeEnabledAttributeAttributeSetter(v8: ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "secureContextWorkerExposedRuntimeEnabledAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextWorkerExposedRuntimeEnabledAttribute(cppValue); } @@ -1205,7 +1275,7 @@ static void partial2SecureContextAttributeAttributeGetter(const v8::FunctionCall TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, TestInterfacePartial2Implementation::partial2SecureContextAttribute(*impl), impl); + V8SetReturnValueBool(info, TestInterfacePartial2Implementation::partial2SecureContextAttribute(*impl)); } static void partial2SecureContextAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -1220,13 +1290,9 @@ static void partial2SecureContextAttributeAttributeSetter(v8::Local v ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "partial2SecureContextAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } TestInterfacePartial2Implementation::setPartial2SecureContextAttribute(*impl, cppValue); } @@ -1236,7 +1302,7 @@ static void partialSecureContextAttributeAttributeGetter(const v8::FunctionCallb TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, TestInterfacePartialSecureContext::partialSecureContextAttribute(*impl), impl); + V8SetReturnValueBool(info, TestInterfacePartialSecureContext::partialSecureContextAttribute(*impl)); } static void partialSecureContextAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -1251,13 +1317,9 @@ static void partialSecureContextAttributeAttributeSetter(v8::Local v8 ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "partialSecureContextAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } TestInterfacePartialSecureContext::setPartialSecureContextAttribute(*impl, cppValue); } @@ -1267,7 +1329,7 @@ static void partialSecureContextRuntimeEnabledAttributeAttributeGetter(const v8: TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, TestInterfacePartialSecureContext::partialSecureContextRuntimeEnabledAttribute(*impl), impl); + V8SetReturnValueBool(info, TestInterfacePartialSecureContext::partialSecureContextRuntimeEnabledAttribute(*impl)); } static void partialSecureContextRuntimeEnabledAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -1282,13 +1344,9 @@ static void partialSecureContextRuntimeEnabledAttributeAttributeSetter(v8::Local ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "partialSecureContextRuntimeEnabledAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } TestInterfacePartialSecureContext::setPartialSecureContextRuntimeEnabledAttribute(*impl, cppValue); } @@ -1298,7 +1356,7 @@ static void partialSecureContextWindowExposedAttributeAttributeGetter(const v8:: TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, TestInterfacePartialSecureContext::partialSecureContextWindowExposedAttribute(*impl), impl); + V8SetReturnValueBool(info, TestInterfacePartialSecureContext::partialSecureContextWindowExposedAttribute(*impl)); } static void partialSecureContextWindowExposedAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -1313,13 +1371,9 @@ static void partialSecureContextWindowExposedAttributeAttributeSetter(v8::Local< ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "partialSecureContextWindowExposedAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } TestInterfacePartialSecureContext::setPartialSecureContextWindowExposedAttribute(*impl, cppValue); } @@ -1329,7 +1383,7 @@ static void partialSecureContextWorkerExposedAttributeAttributeGetter(const v8:: TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, TestInterfacePartialSecureContext::partialSecureContextWorkerExposedAttribute(*impl), impl); + V8SetReturnValueBool(info, TestInterfacePartialSecureContext::partialSecureContextWorkerExposedAttribute(*impl)); } static void partialSecureContextWorkerExposedAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -1344,13 +1398,9 @@ static void partialSecureContextWorkerExposedAttributeAttributeSetter(v8::Local< ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "partialSecureContextWorkerExposedAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } TestInterfacePartialSecureContext::setPartialSecureContextWorkerExposedAttribute(*impl, cppValue); } @@ -1360,7 +1410,7 @@ static void partialSecureContextWindowExposedRuntimeEnabledAttributeAttributeGet TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, TestInterfacePartialSecureContext::partialSecureContextWindowExposedRuntimeEnabledAttribute(*impl), impl); + V8SetReturnValueBool(info, TestInterfacePartialSecureContext::partialSecureContextWindowExposedRuntimeEnabledAttribute(*impl)); } static void partialSecureContextWindowExposedRuntimeEnabledAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -1375,13 +1425,9 @@ static void partialSecureContextWindowExposedRuntimeEnabledAttributeAttributeSet ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "partialSecureContextWindowExposedRuntimeEnabledAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } TestInterfacePartialSecureContext::setPartialSecureContextWindowExposedRuntimeEnabledAttribute(*impl, cppValue); } @@ -1391,7 +1437,7 @@ static void partialSecureContextWorkerExposedRuntimeEnabledAttributeAttributeGet TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder); - V8SetReturnValueFast(info, TestInterfacePartialSecureContext::partialSecureContextWorkerExposedRuntimeEnabledAttribute(*impl), impl); + V8SetReturnValueBool(info, TestInterfacePartialSecureContext::partialSecureContextWorkerExposedRuntimeEnabledAttribute(*impl)); } static void partialSecureContextWorkerExposedRuntimeEnabledAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -1406,13 +1452,9 @@ static void partialSecureContextWorkerExposedRuntimeEnabledAttributeAttributeSet ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterface", "partialSecureContextWorkerExposedRuntimeEnabledAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } TestInterfacePartialSecureContext::setPartialSecureContextWorkerExposedRuntimeEnabledAttribute(*impl, cppValue); } @@ -1781,7 +1823,7 @@ static void methodWithNullableSequencesMethod(const v8::FunctionCallbackInfo>>::NativeValue(info.GetIsolate(), info[1], exceptionState); + strings = NativeValueTraits>>::NativeValue(info.GetIsolate(), info[1], exceptionState); if (exceptionState.HadException()) return; @@ -1814,7 +1856,7 @@ static void methodWithNullableRecordsMethod(const v8::FunctionCallbackInfo>>::NativeValue(info.GetIsolate(), info[1], exceptionState); + strings = NativeValueTraits>>::NativeValue(info.GetIsolate(), info[1], exceptionState); if (exceptionState.HadException()) return; @@ -2415,6 +2457,20 @@ void V8TestInterface::testEnumAttributeAttributeSetterCallback(const v8::Functio TestInterfaceImplementationV8Internal::testEnumAttributeAttributeSetter(v8Value, info); } +void V8TestInterface::testEnumOrNullAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo& info) { + RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_testEnumOrNullAttribute_Getter"); + + TestInterfaceImplementationV8Internal::testEnumOrNullAttributeAttributeGetter(info); +} + +void V8TestInterface::testEnumOrNullAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo& info) { + RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_testEnumOrNullAttribute_Setter"); + + v8::Local v8Value = info[0]; + + TestInterfaceImplementationV8Internal::testEnumOrNullAttributeAttributeSetter(v8Value, info); +} + void V8TestInterface::stringOrDoubleAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo& info) { RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_stringOrDoubleAttribute_Getter"); @@ -2537,6 +2593,34 @@ void V8TestInterface::legacyInterfaceTypeCheckingAttributeAttributeSetterCallbac TestInterfaceImplementationV8Internal::legacyInterfaceTypeCheckingAttributeAttributeSetter(v8Value, info); } +void V8TestInterface::stringNullAsEmptyAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo& info) { + RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_stringNullAsEmptyAttribute_Getter"); + + TestInterfaceImplementationV8Internal::stringNullAsEmptyAttributeAttributeGetter(info); +} + +void V8TestInterface::stringNullAsEmptyAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo& info) { + RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_stringNullAsEmptyAttribute_Setter"); + + v8::Local v8Value = info[0]; + + TestInterfaceImplementationV8Internal::stringNullAsEmptyAttributeAttributeSetter(v8Value, info); +} + +void V8TestInterface::usvStringOrNullAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo& info) { + RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_usvStringOrNullAttribute_Getter"); + + TestInterfaceImplementationV8Internal::usvStringOrNullAttributeAttributeGetter(info); +} + +void V8TestInterface::usvStringOrNullAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo& info) { + RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_usvStringOrNullAttribute_Setter"); + + v8::Local v8Value = info[0]; + + TestInterfaceImplementationV8Internal::usvStringOrNullAttributeAttributeSetter(v8Value, info); +} + void V8TestInterface::alwaysExposedAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo& info) { RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_alwaysExposedAttribute_Getter"); @@ -3465,6 +3549,8 @@ static const V8DOMConfiguration::AccessorConfiguration V8TestInterfaceAccessors[ { "testEnumAttribute", V8TestInterface::testEnumAttributeAttributeGetterCallback, V8TestInterface::testEnumAttributeAttributeSetterCallback, V8PrivateProperty::kNoCachedAccessor, static_cast(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kAllWorlds }, + { "testEnumOrNullAttribute", V8TestInterface::testEnumOrNullAttributeAttributeGetterCallback, V8TestInterface::testEnumOrNullAttributeAttributeSetterCallback, V8PrivateProperty::kNoCachedAccessor, static_cast(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kAllWorlds }, + { "stringOrDoubleAttribute", V8TestInterface::stringOrDoubleAttributeAttributeGetterCallback, V8TestInterface::stringOrDoubleAttributeAttributeSetterCallback, V8PrivateProperty::kNoCachedAccessor, static_cast(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kAllWorlds }, { "withExtendedAttributeStringAttribute", V8TestInterface::withExtendedAttributeStringAttributeAttributeGetterCallback, V8TestInterface::withExtendedAttributeStringAttributeAttributeSetterCallback, V8PrivateProperty::kNoCachedAccessor, static_cast(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kAllWorlds }, @@ -3481,6 +3567,10 @@ static const V8DOMConfiguration::AccessorConfiguration V8TestInterfaceAccessors[ { "legacyInterfaceTypeCheckingAttribute", V8TestInterface::legacyInterfaceTypeCheckingAttributeAttributeGetterCallback, V8TestInterface::legacyInterfaceTypeCheckingAttributeAttributeSetterCallback, V8PrivateProperty::kNoCachedAccessor, static_cast(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kAllWorlds }, + { "stringNullAsEmptyAttribute", V8TestInterface::stringNullAsEmptyAttributeAttributeGetterCallback, V8TestInterface::stringNullAsEmptyAttributeAttributeSetterCallback, V8PrivateProperty::kNoCachedAccessor, static_cast(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kAllWorlds }, + + { "usvStringOrNullAttribute", V8TestInterface::usvStringOrNullAttributeAttributeGetterCallback, V8TestInterface::usvStringOrNullAttributeAttributeSetterCallback, V8PrivateProperty::kNoCachedAccessor, static_cast(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kAllWorlds }, + { "alwaysExposedAttribute", V8TestInterface::alwaysExposedAttributeAttributeGetterCallback, V8TestInterface::alwaysExposedAttributeAttributeSetterCallback, V8PrivateProperty::kNoCachedAccessor, static_cast(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kAllWorlds }, { "lenientThisAttribute", V8TestInterface::lenientThisAttributeAttributeGetterCallback, V8TestInterface::lenientThisAttributeAttributeSetterCallback, V8PrivateProperty::kNoCachedAccessor, static_cast(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kDoNotCheckHolder, V8DOMConfiguration::kAllWorlds }, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.h index 3417d3f36d..1fa8cb0f2b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface.h @@ -38,12 +38,6 @@ class V8TestInterface { } CORE_EXPORT static TestInterfaceImplementation* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static void implementsCustomVoidMethodMethodCustom(const v8::FunctionCallbackInfo&); static void legacyCallCustom(const v8::FunctionCallbackInfo&); static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; @@ -86,6 +80,8 @@ class V8TestInterface { CORE_EXPORT static void unrestrictedFloatAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void testEnumAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void testEnumAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo&); + CORE_EXPORT static void testEnumOrNullAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo&); + CORE_EXPORT static void testEnumOrNullAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void stringOrDoubleAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void stringOrDoubleAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void withExtendedAttributeStringAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo&); @@ -104,6 +100,10 @@ class V8TestInterface { CORE_EXPORT static void staticConditionalReadOnlyLongAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void legacyInterfaceTypeCheckingAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void legacyInterfaceTypeCheckingAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo&); + CORE_EXPORT static void stringNullAsEmptyAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo&); + CORE_EXPORT static void stringNullAsEmptyAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo&); + CORE_EXPORT static void usvStringOrNullAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo&); + CORE_EXPORT static void usvStringOrNullAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void alwaysExposedAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void alwaysExposedAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void workerExposedAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo&); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp index a23d8cfb5e..f05483bf6d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.cpp @@ -37,8 +37,6 @@ namespace blink { WrapperTypeInfo V8TestInterface2::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface2::domTemplate, - V8TestInterface2::Trace, - V8TestInterface2::TraceWrappers, nullptr, "TestInterface2", nullptr, @@ -78,24 +76,6 @@ static void sizeAttributeGetter(const v8::FunctionCallbackInfo& info) V8SetReturnValueUnsigned(info, impl->size()); } -static void legacyCallerMethod(const v8::FunctionCallbackInfo& info) { - ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "legacyCaller"); - - TestInterface2* impl = V8TestInterface2::ToImpl(info.Holder()); - - if (UNLIKELY(info.Length() < 1)) { - exceptionState.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length())); - return; - } - - uint32_t index; - index = NativeValueTraits::NativeValue(info.GetIsolate(), info[0], exceptionState, kNormalConversion); - if (exceptionState.HadException()) - return; - - V8SetReturnValue(info, impl->legacyCaller(index)); -} - static void itemMethod(const v8::FunctionCallbackInfo& info) { ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface2", "item"); @@ -512,12 +492,6 @@ void V8TestInterface2::sizeAttributeGetterCallback(const v8::FunctionCallbackInf TestInterface2V8Internal::sizeAttributeGetter(info); } -void V8TestInterface2::legacyCallerMethodCallback(const v8::FunctionCallbackInfo& info) { - RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_legacyCaller"); - - TestInterface2V8Internal::legacyCallerMethod(info); -} - void V8TestInterface2::itemMethodCallback(const v8::FunctionCallbackInfo& info) { RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterface2_item"); @@ -683,7 +657,6 @@ static const V8DOMConfiguration::AccessorConfiguration V8TestInterface2Accessors }; static const V8DOMConfiguration::MethodConfiguration V8TestInterface2Methods[] = { - {"legacyCaller", V8TestInterface2::legacyCallerMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds}, {"item", V8TestInterface2::itemMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds}, {"setItem", V8TestInterface2::setItemMethodCallback, 2, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds}, {"deleteItem", V8TestInterface2::deleteItemMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds}, @@ -768,8 +741,6 @@ void V8TestInterface2::installV8TestInterface2Template( }; V8DOMConfiguration::InstallMethod(isolate, world, prototypeTemplate, signature, symbolKeyedIteratorConfiguration); - instanceTemplate->SetCallAsFunctionHandler(TestInterface2V8Internal::legacyCallerMethodCallback); - // Custom signature } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.h index ba7473b075..6a420832a9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface2.h @@ -35,12 +35,6 @@ class V8TestInterface2 { } CORE_EXPORT static TestInterface2* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; CORE_EXPORT static void InstallConditionalFeatures( @@ -63,7 +57,6 @@ class V8TestInterface2 { CORE_EXPORT static void sizeAttributeGetterCallback(const v8::FunctionCallbackInfo&); - CORE_EXPORT static void legacyCallerMethodCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void itemMethodCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void setItemMethodCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void deleteItemMethodCallback(const v8::FunctionCallbackInfo&); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp index aa170ba190..5c0d166fb4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.cpp @@ -33,8 +33,6 @@ namespace blink { const WrapperTypeInfo V8TestInterface3::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface3::domTemplate, - V8TestInterface3::Trace, - V8TestInterface3::TraceWrappers, nullptr, "TestInterface3", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.h index cd17b5a668..d514c99fc0 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterface3.h @@ -35,12 +35,6 @@ class V8TestInterface3 { } CORE_EXPORT static TestInterface3* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackInfo&); static void indexedPropertySetterCustom(uint32_t, v8::Local, const v8::PropertyCallbackInfo&); static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo&); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.cpp index dfc4e7213d..cd6780078b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.cpp @@ -34,8 +34,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceCheckSecurity::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceCheckSecurity::domTemplate, - V8TestInterfaceCheckSecurity::Trace, - V8TestInterfaceCheckSecurity::TraceWrappers, nullptr, "TestInterfaceCheckSecurity", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.h index 8ce505b1f2..87e2557fc3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCheckSecurity.h @@ -35,12 +35,6 @@ class V8TestInterfaceCheckSecurity { } CORE_EXPORT static TestInterfaceCheckSecurity* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.cpp index 39601b6741..362c185808 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.cpp @@ -37,8 +37,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceConstructor::domTemplate, - V8TestInterfaceConstructor::Trace, - V8TestInterfaceConstructor::TraceWrappers, nullptr, "TestInterfaceConstructor", nullptr, @@ -104,8 +102,15 @@ static void constructor2(const v8::FunctionCallbackInfo& info) { Vector sequenceStringArg; Vector sequenceDictionaryArg; HeapVector sequenceLongOrTestDictionaryArg; + V8StringResource optionalUSVStringArg; Dictionary optionalDictionaryArg; TestInterfaceEmpty* optionalTestInterfaceEmptyArg; + int numArgsPassed = info.Length(); + while (numArgsPassed > 0) { + if (!info[numArgsPassed - 1]->IsUndefined()) + break; + --numArgsPassed; + } doubleArg = NativeValueTraits::NativeValue(info.GetIsolate(), info[0], exceptionState); if (exceptionState.HadException()) return; @@ -140,17 +145,35 @@ static void constructor2(const v8::FunctionCallbackInfo& info) { if (exceptionState.HadException()) return; - if (!info[7]->IsNullOrUndefined() && !info[7]->IsObject()) { - exceptionState.ThrowTypeError("parameter 8 ('optionalDictionaryArg') is not an object."); + if (UNLIKELY(numArgsPassed <= 7)) { + ExecutionContext* executionContext = ToExecutionContext( + info.NewTarget().As()->CreationContext()); + Document& document = *ToDocument(ToExecutionContext( + info.NewTarget().As()->CreationContext())); + TestInterfaceConstructor* impl = TestInterfaceConstructor::Create(scriptState, executionContext, document, doubleArg, stringArg, testInterfaceEmptyArg, dictionaryArg, sequenceStringArg, sequenceDictionaryArg, sequenceLongOrTestDictionaryArg, exceptionState); + if (exceptionState.HadException()) { + return; + } + v8::Local wrapper = info.Holder(); + wrapper = impl->AssociateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper); + V8SetReturnValue(info, wrapper); + return; + } + optionalUSVStringArg = NativeValueTraits>::NativeValue(info.GetIsolate(), info[7], exceptionState); + if (exceptionState.HadException()) + return; + + if (!info[8]->IsNullOrUndefined() && !info[8]->IsObject()) { + exceptionState.ThrowTypeError("parameter 9 ('optionalDictionaryArg') is not an object."); return; } - optionalDictionaryArg = NativeValueTraits::NativeValue(info.GetIsolate(), info[7], exceptionState); + optionalDictionaryArg = NativeValueTraits::NativeValue(info.GetIsolate(), info[8], exceptionState); if (exceptionState.HadException()) return; - optionalTestInterfaceEmptyArg = V8TestInterfaceEmpty::ToImplWithTypeCheck(info.GetIsolate(), info[8]); + optionalTestInterfaceEmptyArg = V8TestInterfaceEmpty::ToImplWithTypeCheck(info.GetIsolate(), info[9]); if (!optionalTestInterfaceEmptyArg) { - exceptionState.ThrowTypeError("parameter 9 is not of type 'TestInterfaceEmpty'."); + exceptionState.ThrowTypeError("parameter 10 is not of type 'TestInterfaceEmpty'."); return; } @@ -158,7 +181,7 @@ static void constructor2(const v8::FunctionCallbackInfo& info) { info.NewTarget().As()->CreationContext()); Document& document = *ToDocument(ToExecutionContext( info.NewTarget().As()->CreationContext())); - TestInterfaceConstructor* impl = TestInterfaceConstructor::Create(scriptState, executionContext, document, doubleArg, stringArg, testInterfaceEmptyArg, dictionaryArg, sequenceStringArg, sequenceDictionaryArg, sequenceLongOrTestDictionaryArg, optionalDictionaryArg, optionalTestInterfaceEmptyArg, exceptionState); + TestInterfaceConstructor* impl = TestInterfaceConstructor::Create(scriptState, executionContext, document, doubleArg, stringArg, testInterfaceEmptyArg, dictionaryArg, sequenceStringArg, sequenceDictionaryArg, sequenceLongOrTestDictionaryArg, optionalUSVStringArg, optionalDictionaryArg, optionalTestInterfaceEmptyArg, exceptionState); if (exceptionState.HadException()) { return; } @@ -254,7 +277,7 @@ static void constructor4(const v8::FunctionCallbackInfo& info) { static void constructor(const v8::FunctionCallbackInfo& info) { ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kConstructionContext, "TestInterfaceConstructor"); - switch (std::min(9, info.Length())) { + switch (std::min(10, info.Length())) { case 0: if (true) { TestInterfaceConstructorV8Internal::constructor1(info); @@ -297,9 +320,15 @@ static void constructor(const v8::FunctionCallbackInfo& info) { return; } break; + case 10: + if (true) { + TestInterfaceConstructorV8Internal::constructor2(info); + return; + } + break; default: if (info.Length() >= 0) { - exceptionState.ThrowTypeError(ExceptionMessages::InvalidArity("[0, 1, 2, 3, 7, 8, 9]", info.Length())); + exceptionState.ThrowTypeError(ExceptionMessages::InvalidArity("[0, 1, 2, 3, 7, 8, 9, 10]", info.Length())); return; } exceptionState.ThrowTypeError(ExceptionMessages::NotEnoughArguments(0, info.Length())); @@ -319,8 +348,6 @@ static void constructor(const v8::FunctionCallbackInfo& info) { const WrapperTypeInfo V8TestInterfaceConstructorConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceConstructorConstructor::domTemplate, - V8TestInterfaceConstructor::Trace, - V8TestInterfaceConstructor::TraceWrappers, nullptr, "TestInterfaceConstructor", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.h index f9a35c0402..1572fe65b0 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.h @@ -44,12 +44,6 @@ class V8TestInterfaceConstructor { } CORE_EXPORT static TestInterfaceConstructor* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.cpp index 2ca0d7f191..f5d6f76c5d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.cpp @@ -33,8 +33,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceConstructor2::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceConstructor2::domTemplate, - V8TestInterfaceConstructor2::Trace, - V8TestInterfaceConstructor2::TraceWrappers, nullptr, "TestInterfaceConstructor2", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.h index 061363f0ab..b22011b084 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor2.h @@ -35,12 +35,6 @@ class V8TestInterfaceConstructor2 { } CORE_EXPORT static TestInterfaceConstructor2* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.cpp index af61fc84f9..1a8bc40ae1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.cpp @@ -31,8 +31,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceConstructor3::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceConstructor3::domTemplate, - V8TestInterfaceConstructor3::Trace, - V8TestInterfaceConstructor3::TraceWrappers, nullptr, "TestInterfaceConstructor3", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.h index 4b83941d72..c0e6f87e23 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor3.h @@ -35,12 +35,6 @@ class V8TestInterfaceConstructor3 { } CORE_EXPORT static TestInterfaceConstructor3* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.cpp index bf03c9321e..721172d099 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.cpp @@ -32,8 +32,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceConstructor4::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceConstructor4::domTemplate, - V8TestInterfaceConstructor4::Trace, - V8TestInterfaceConstructor4::TraceWrappers, nullptr, "TestInterfaceConstructor4", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.h index 1093026bae..e06aec88a5 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor4.h @@ -35,12 +35,6 @@ class V8TestInterfaceConstructor4 { } CORE_EXPORT static TestInterfaceConstructor4* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.cpp index defb69c6c2..57a75e809e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.cpp @@ -29,8 +29,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceCustomConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceCustomConstructor::domTemplate, - V8TestInterfaceCustomConstructor::Trace, - V8TestInterfaceCustomConstructor::TraceWrappers, nullptr, "TestInterfaceCustomConstructor", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.h index 773e5cda5f..58619a9d1d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceCustomConstructor.h @@ -35,12 +35,6 @@ class V8TestInterfaceCustomConstructor { } CORE_EXPORT static TestInterfaceCustomConstructor* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static void constructorCustom(const v8::FunctionCallbackInfo&); static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.cpp index fa9cfd9e1b..739a935569 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.cpp @@ -34,8 +34,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceDocument::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceDocument::domTemplate, - V8TestInterfaceDocument::Trace, - V8TestInterfaceDocument::TraceWrappers, nullptr, "TestInterfaceDocument", &V8Document::wrapperTypeInfo, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.h index cb46d94097..9c454ff1f3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceDocument.h @@ -37,12 +37,6 @@ class V8TestInterfaceDocument { } CORE_EXPORT static TestInterfaceDocument* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.cpp index 5097965128..0fed3a9bb3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.cpp @@ -28,8 +28,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceEmpty::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEmpty::domTemplate, - V8TestInterfaceEmpty::Trace, - V8TestInterfaceEmpty::TraceWrappers, nullptr, "TestInterfaceEmpty", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.h index d992f48fdc..37912e1501 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEmpty.h @@ -35,12 +35,6 @@ class V8TestInterfaceEmpty { } CORE_EXPORT static TestInterfaceEmpty* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.cpp index 0ea7d3af37..58a8dbde93 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.cpp @@ -33,8 +33,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceEventInitConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventInitConstructor::domTemplate, - V8TestInterfaceEventInitConstructor::Trace, - V8TestInterfaceEventInitConstructor::TraceWrappers, nullptr, "TestInterfaceEventInitConstructor", &V8Event::wrapperTypeInfo, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.h index 438893314b..a1a0eb6237 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventInitConstructor.h @@ -36,12 +36,6 @@ class V8TestInterfaceEventInitConstructor { } CORE_EXPORT static TestInterfaceEventInitConstructor* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.cpp index dbcd66b047..0735657f5b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.cpp @@ -31,8 +31,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceEventTarget::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventTarget::domTemplate, - V8TestInterfaceEventTarget::Trace, - V8TestInterfaceEventTarget::TraceWrappers, nullptr, "TestInterfaceEventTarget", &V8EventTarget::wrapperTypeInfo, @@ -75,8 +73,6 @@ namespace TestInterfaceEventTargetV8Internal { const WrapperTypeInfo V8TestInterfaceEventTargetConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventTargetConstructor::domTemplate, - V8TestInterfaceEventTarget::Trace, - V8TestInterfaceEventTarget::TraceWrappers, nullptr, "TestInterfaceEventTarget", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.h index 05a421ce2c..a3ab1d1802 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.h @@ -44,12 +44,6 @@ class V8TestInterfaceEventTarget { } CORE_EXPORT static TestInterfaceEventTarget* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.cpp index 0817948ccb..582baeaf12 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.cpp @@ -36,8 +36,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceGarbageCollected::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceGarbageCollected::domTemplate, - V8TestInterfaceGarbageCollected::Trace, - V8TestInterfaceGarbageCollected::TraceWrappers, nullptr, "TestInterfaceGarbageCollected", &V8EventTarget::wrapperTypeInfo, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.h index c9e72ebc94..06c44643ac 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceGarbageCollected.h @@ -36,12 +36,6 @@ class V8TestInterfaceGarbageCollected { } CORE_EXPORT static TestInterfaceGarbageCollected* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.cpp index 0f139c33df..aabd35a0d0 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.cpp @@ -34,8 +34,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceNamedConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructor::domTemplate, - V8TestInterfaceNamedConstructor::Trace, - V8TestInterfaceNamedConstructor::TraceWrappers, nullptr, "TestInterfaceNamedConstructor", nullptr, @@ -97,8 +95,6 @@ static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceNamedCons const WrapperTypeInfo V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructorConstructor::domTemplate, - V8TestInterfaceNamedConstructor::Trace, - V8TestInterfaceNamedConstructor::TraceWrappers, nullptr, "TestInterfaceNamedConstructor", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.h index c851f89697..90756e5a5d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.h @@ -43,12 +43,6 @@ class V8TestInterfaceNamedConstructor { } CORE_EXPORT static TestInterfaceNamedConstructor* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp index 23b71b5679..9796d98a18 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp @@ -32,8 +32,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceNamedConstructor2::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructor2::domTemplate, - V8TestInterfaceNamedConstructor2::Trace, - V8TestInterfaceNamedConstructor2::TraceWrappers, nullptr, "TestInterfaceNamedConstructor2", nullptr, @@ -76,8 +74,6 @@ namespace TestInterfaceNamedConstructor2V8Internal { const WrapperTypeInfo V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructor2Constructor::domTemplate, - V8TestInterfaceNamedConstructor2::Trace, - V8TestInterfaceNamedConstructor2::TraceWrappers, nullptr, "TestInterfaceNamedConstructor2", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.h index 42e9111d09..a53ae36f28 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.h @@ -43,12 +43,6 @@ class V8TestInterfaceNamedConstructor2 { } CORE_EXPORT static TestInterfaceNamedConstructor2* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.cpp index f7114d163b..1b92837173 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.cpp @@ -36,8 +36,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceNode::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNode::domTemplate, - V8TestInterfaceNode::Trace, - V8TestInterfaceNode::TraceWrappers, nullptr, "TestInterfaceNode", &V8Node::wrapperTypeInfo, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.h index 266b627bab..f2c98a707a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNode.h @@ -36,12 +36,6 @@ class V8TestInterfaceNode { } CORE_EXPORT static TestInterfaceNode* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.cpp index 10f133a772..6ee0983026 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.cpp @@ -32,8 +32,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceOriginTrialEnabled::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceOriginTrialEnabled::domTemplate, - V8TestInterfaceOriginTrialEnabled::Trace, - V8TestInterfaceOriginTrialEnabled::TraceWrappers, nullptr, "TestInterfaceOriginTrialEnabled", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.h index daf7f9665d..2c0007b4d7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceOriginTrialEnabled.h @@ -35,12 +35,6 @@ class V8TestInterfaceOriginTrialEnabled { } CORE_EXPORT static TestInterfaceOriginTrialEnabled* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.cpp index c22b506776..783b0b42eb 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.cpp @@ -32,8 +32,6 @@ namespace blink { const WrapperTypeInfo V8TestInterfaceSecureContext::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceSecureContext::domTemplate, - V8TestInterfaceSecureContext::Trace, - V8TestInterfaceSecureContext::TraceWrappers, V8TestInterfaceSecureContext::InstallConditionalFeatures, "TestInterfaceSecureContext", nullptr, @@ -70,7 +68,7 @@ static void secureContextAttributeAttributeGetter(const v8::FunctionCallbackInfo TestInterfaceSecureContext* impl = V8TestInterfaceSecureContext::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextAttribute()); } static void secureContextAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -85,13 +83,9 @@ static void secureContextAttributeAttributeSetter(v8::Local v8Value, ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterfaceSecureContext", "secureContextAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextAttribute(cppValue); } @@ -101,7 +95,7 @@ static void secureContextRuntimeEnabledAttributeAttributeGetter(const v8::Functi TestInterfaceSecureContext* impl = V8TestInterfaceSecureContext::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextRuntimeEnabledAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextRuntimeEnabledAttribute()); } static void secureContextRuntimeEnabledAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -116,13 +110,9 @@ static void secureContextRuntimeEnabledAttributeAttributeSetter(v8::Local::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextRuntimeEnabledAttribute(cppValue); } @@ -132,7 +122,7 @@ static void secureContextWindowExposedAttributeAttributeGetter(const v8::Functio TestInterfaceSecureContext* impl = V8TestInterfaceSecureContext::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextWindowExposedAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextWindowExposedAttribute()); } static void secureContextWindowExposedAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -147,13 +137,9 @@ static void secureContextWindowExposedAttributeAttributeSetter(v8::Local::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextWindowExposedAttribute(cppValue); } @@ -163,7 +149,7 @@ static void secureContextWorkerExposedAttributeAttributeGetter(const v8::Functio TestInterfaceSecureContext* impl = V8TestInterfaceSecureContext::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextWorkerExposedAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextWorkerExposedAttribute()); } static void secureContextWorkerExposedAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -178,13 +164,9 @@ static void secureContextWorkerExposedAttributeAttributeSetter(v8::Local::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextWorkerExposedAttribute(cppValue); } @@ -194,7 +176,7 @@ static void secureContextWindowExposedRuntimeEnabledAttributeAttributeGetter(con TestInterfaceSecureContext* impl = V8TestInterfaceSecureContext::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextWindowExposedRuntimeEnabledAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextWindowExposedRuntimeEnabledAttribute()); } static void secureContextWindowExposedRuntimeEnabledAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -209,13 +191,9 @@ static void secureContextWindowExposedRuntimeEnabledAttributeAttributeSetter(v8: ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterfaceSecureContext", "secureContextWindowExposedRuntimeEnabledAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextWindowExposedRuntimeEnabledAttribute(cppValue); } @@ -225,7 +203,7 @@ static void secureContextWorkerExposedRuntimeEnabledAttributeAttributeGetter(con TestInterfaceSecureContext* impl = V8TestInterfaceSecureContext::ToImpl(holder); - V8SetReturnValueFast(info, WTF::GetPtr(impl->secureContextWorkerExposedRuntimeEnabledAttribute()), impl); + V8SetReturnValueBool(info, impl->secureContextWorkerExposedRuntimeEnabledAttribute()); } static void secureContextWorkerExposedRuntimeEnabledAttributeAttributeSetter(v8::Local v8Value, const v8::FunctionCallbackInfo& info) { @@ -240,13 +218,9 @@ static void secureContextWorkerExposedRuntimeEnabledAttributeAttributeSetter(v8: ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestInterfaceSecureContext", "secureContextWorkerExposedRuntimeEnabledAttribute"); // Prepare the value to be set. - bool* cppValue = V8bool::ToImplWithTypeCheck(info.GetIsolate(), v8Value); - - // Type check per: http://heycam.github.io/webidl/#es-interface - if (!cppValue) { - exceptionState.ThrowTypeError("The provided value is not of type 'bool'."); + bool cppValue = NativeValueTraits::NativeValue(info.GetIsolate(), v8Value, exceptionState); + if (exceptionState.HadException()) return; - } impl->setSecureContextWorkerExposedRuntimeEnabledAttribute(cppValue); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.h index 4d294a6cc1..ebc4917627 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceSecureContext.h @@ -35,12 +35,6 @@ class V8TestInterfaceSecureContext { } CORE_EXPORT static TestInterfaceSecureContext* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; CORE_EXPORT static void InstallConditionalFeatures( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestLegacyCallbackInterface.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestLegacyCallbackInterface.cpp index 941269c1e9..aebc1d56c3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestLegacyCallbackInterface.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestLegacyCallbackInterface.cpp @@ -12,6 +12,7 @@ #include "bindings/core/v8/V8BindingForCore.h" #include "bindings/core/v8/V8DOMConfiguration.h" +#include "bindings/tests/idls/core/TestLegacyCallbackInterface.h" namespace blink { @@ -25,8 +26,6 @@ const WrapperTypeInfo V8TestLegacyCallbackInterface::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestLegacyCallbackInterface::DomTemplate, nullptr, - nullptr, - nullptr, "TestLegacyCallbackInterface", nullptr, WrapperTypeInfo::kWrapperTypeNoPrototype, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestLegacyCallbackInterface.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestLegacyCallbackInterface.h index 4bdc6f2df7..dd4573db27 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestLegacyCallbackInterface.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestLegacyCallbackInterface.h @@ -11,7 +11,6 @@ #ifndef V8TestLegacyCallbackInterface_h #define V8TestLegacyCallbackInterface_h -#include "bindings/tests/idls/core/TestLegacyCallbackInterface.h" #include "core/CoreExport.h" #include "platform/bindings/DOMWrapperWorld.h" diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.cpp index 1480f29638..4838698056 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.cpp @@ -32,8 +32,6 @@ namespace blink { const WrapperTypeInfo V8TestNode::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestNode::domTemplate, - V8TestNode::Trace, - V8TestNode::TraceWrappers, nullptr, "TestNode", &V8Node::wrapperTypeInfo, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.h index 6eea858754..afa0eabdfc 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestNode.h @@ -36,12 +36,6 @@ class V8TestNode { } CORE_EXPORT static TestNode* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp index 187ce31561..a5364d6ac6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp @@ -89,8 +89,6 @@ namespace blink { const WrapperTypeInfo V8TestObject::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestObject::domTemplate, - V8TestObject::Trace, - V8TestObject::TraceWrappers, V8TestObject::InstallConditionalFeatures, "TestObject", nullptr, @@ -1563,6 +1561,7 @@ static void testEnumOrNullAttributeAttributeSetter(v8::Local v8Value, // Returns undefined without setting the value if the value is invalid. DummyExceptionStateForTesting dummyExceptionState; const char* validValues[] = { + nullptr, "", "EnumValue1", "EnumValue2", @@ -5282,7 +5281,7 @@ static void voidMethodNullableSequenceLongArgMethod(const v8::FunctionCallbackIn return; } - Nullable> longSequenceArg; + Optional> longSequenceArg; if (!info[0]->IsNullOrUndefined()) { longSequenceArg = NativeValueTraits>::NativeValue(info.GetIsolate(), info[0], exceptionState); if (exceptionState.HadException()) @@ -5337,11 +5336,11 @@ static void voidMethodTestInterfaceEmptyFrozenArrayMethodMethod(const v8::Functi static void nullableLongMethodMethod(const v8::FunctionCallbackInfo& info) { TestObject* impl = V8TestObject::ToImpl(info.Holder()); - Nullable result = impl->nullableLongMethod(); - if (result.IsNull()) + Optional result = impl->nullableLongMethod(); + if (!result) V8SetReturnValueNull(info); else - V8SetReturnValueInt(info, result.Get()); + V8SetReturnValueInt(info, result.value()); } static void nullableStringMethodMethod(const v8::FunctionCallbackInfo& info) { @@ -5359,11 +5358,11 @@ static void nullableTestInterfaceMethodMethod(const v8::FunctionCallbackInfo& info) { TestObject* impl = V8TestObject::ToImpl(info.Holder()); - Nullable> result = impl->nullableLongSequenceMethod(); - if (result.IsNull()) + Optional> result = impl->nullableLongSequenceMethod(); + if (!result) V8SetReturnValueNull(info); else - V8SetReturnValue(info, ToV8(result.Get(), info.Holder(), info.GetIsolate())); + V8SetReturnValue(info, ToV8(result.value(), info.Holder(), info.GetIsolate())); } static void testInterfaceGarbageCollectedOrDOMStringMethodMethod(const v8::FunctionCallbackInfo& info) { @@ -5718,12 +5717,12 @@ static void testDictionaryMethodMethod(const v8::FunctionCallbackInfo static void nullableTestDictionaryMethodMethod(const v8::FunctionCallbackInfo& info) { TestObject* impl = V8TestObject::ToImpl(info.Holder()); - Nullable result; + Optional result; impl->nullableTestDictionaryMethod(result); - if (result.IsNull()) + if (!result) V8SetReturnValueNull(info); else - V8SetReturnValue(info, result.Get()); + V8SetReturnValue(info, result.value()); } static void staticTestDictionaryMethodMethod(const v8::FunctionCallbackInfo& info) { @@ -5733,12 +5732,12 @@ static void staticTestDictionaryMethodMethod(const v8::FunctionCallbackInfo& info) { - Nullable result; + Optional result; TestObject::staticNullableTestDictionaryMethod(result); - if (result.IsNull()) + if (!result) V8SetReturnValueNull(info); else - V8SetReturnValue(info, result.Get(), info.GetIsolate()->GetCurrentContext()->Global()); + V8SetReturnValue(info, result.value(), info.GetIsolate()->GetCurrentContext()->Global()); } static void passPermissiveDictionaryMethodMethod(const v8::FunctionCallbackInfo& info) { @@ -5976,6 +5975,39 @@ static void voidMethodStringArgLongArgMethod(const v8::FunctionCallbackInfovoidMethodStringArgLongArg(stringArg, longArg); } +static void voidMethodByteStringOrNullOptionalUSVStringArgMethod(const v8::FunctionCallbackInfo& info) { + ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionContext, "TestObject", "voidMethodByteStringOrNullOptionalUSVStringArg"); + + TestObject* impl = V8TestObject::ToImpl(info.Holder()); + + if (UNLIKELY(info.Length() < 1)) { + exceptionState.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length())); + return; + } + + V8StringResource byteStringArg; + V8StringResource<> usvStringArg; + int numArgsPassed = info.Length(); + while (numArgsPassed > 0) { + if (!info[numArgsPassed - 1]->IsUndefined()) + break; + --numArgsPassed; + } + byteStringArg = NativeValueTraits>::NativeValue(info.GetIsolate(), info[0], exceptionState); + if (exceptionState.HadException()) + return; + + if (UNLIKELY(numArgsPassed <= 1)) { + impl->voidMethodByteStringOrNullOptionalUSVStringArg(byteStringArg); + return; + } + usvStringArg = NativeValueTraits::NativeValue(info.GetIsolate(), info[1], exceptionState); + if (exceptionState.HadException()) + return; + + impl->voidMethodByteStringOrNullOptionalUSVStringArg(byteStringArg, usvStringArg); +} + static void voidMethodOptionalStringArgMethod(const v8::FunctionCallbackInfo& info) { TestObject* impl = V8TestObject::ToImpl(info.Holder()); @@ -6397,7 +6429,7 @@ static void voidMethodDefaultNullableByteStringArgMethod(const v8::FunctionCallb V8StringResource defaultStringArg; if (!info[0]->IsUndefined()) { - defaultStringArg = NativeValueTraits::NativeValue(info.GetIsolate(), info[0], exceptionState); + defaultStringArg = NativeValueTraits>::NativeValue(info.GetIsolate(), info[0], exceptionState); if (exceptionState.HadException()) return; } else { @@ -12257,6 +12289,12 @@ void V8TestObject::voidMethodStringArgLongArgMethodCallback(const v8::FunctionCa TestObjectV8Internal::voidMethodStringArgLongArgMethod(info); } +void V8TestObject::voidMethodByteStringOrNullOptionalUSVStringArgMethodCallback(const v8::FunctionCallbackInfo& info) { + RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_voidMethodByteStringOrNullOptionalUSVStringArg"); + + TestObjectV8Internal::voidMethodByteStringOrNullOptionalUSVStringArgMethod(info); +} + void V8TestObject::voidMethodOptionalStringArgMethodCallback(const v8::FunctionCallbackInfo& info) { RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_voidMethodOptionalStringArg"); @@ -13581,6 +13619,7 @@ static const V8DOMConfiguration::MethodConfiguration V8TestObjectMethods[] = { {"voidMethodXPathNSResolverArg", V8TestObject::voidMethodXPathNSResolverArgMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds}, {"voidMethodDictionarySequenceArg", V8TestObject::voidMethodDictionarySequenceArgMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds}, {"voidMethodStringArgLongArg", V8TestObject::voidMethodStringArgLongArgMethodCallback, 2, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds}, + {"voidMethodByteStringOrNullOptionalUSVStringArg", V8TestObject::voidMethodByteStringOrNullOptionalUSVStringArgMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds}, {"voidMethodOptionalStringArg", V8TestObject::voidMethodOptionalStringArgMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds}, {"voidMethodOptionalTestInterfaceEmptyArg", V8TestObject::voidMethodOptionalTestInterfaceEmptyArgMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds}, {"voidMethodOptionalLongArg", V8TestObject::voidMethodOptionalLongArgMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kAllWorlds}, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.h index a304f7fa19..8de8cc6f5a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.h @@ -50,12 +50,6 @@ class V8TestObject { } CORE_EXPORT static TestObject* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static void customVoidMethodMethodCustom(const v8::FunctionCallbackInfo&); static void customCallPrologueVoidMethodMethodPrologueCustom(const v8::FunctionCallbackInfo&, TestObject*); static void customCallEpilogueVoidMethodMethodEpilogueCustom(const v8::FunctionCallbackInfo&, TestObject*); @@ -498,6 +492,7 @@ class V8TestObject { CORE_EXPORT static void voidMethodXPathNSResolverArgMethodCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void voidMethodDictionarySequenceArgMethodCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void voidMethodStringArgLongArgMethodCallback(const v8::FunctionCallbackInfo&); + CORE_EXPORT static void voidMethodByteStringOrNullOptionalUSVStringArgMethodCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void voidMethodOptionalStringArgMethodCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void voidMethodOptionalTestInterfaceEmptyArgMethodCallback(const v8::FunctionCallbackInfo&); CORE_EXPORT static void voidMethodOptionalLongArgMethodCallback(const v8::FunctionCallbackInfo&); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.cpp index ed46c2f24f..06256415e7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.cpp @@ -37,8 +37,6 @@ namespace blink { const WrapperTypeInfo V8TestSpecialOperations::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSpecialOperations::domTemplate, - V8TestSpecialOperations::Trace, - V8TestSpecialOperations::TraceWrappers, nullptr, "TestSpecialOperations", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.h index 92ede5b6c4..b62f073183 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperations.h @@ -36,12 +36,6 @@ class V8TestSpecialOperations { } CORE_EXPORT static TestSpecialOperations* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.cpp index b05d5d586a..221f7e14e8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.cpp @@ -30,8 +30,6 @@ namespace blink { const WrapperTypeInfo V8TestSpecialOperationsNotEnumerable::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSpecialOperationsNotEnumerable::domTemplate, - V8TestSpecialOperationsNotEnumerable::Trace, - V8TestSpecialOperationsNotEnumerable::TraceWrappers, nullptr, "TestSpecialOperationsNotEnumerable", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.h index c14f348cdc..bd00b8abc6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestSpecialOperationsNotEnumerable.h @@ -35,12 +35,6 @@ class V8TestSpecialOperationsNotEnumerable { } CORE_EXPORT static TestSpecialOperationsNotEnumerable* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp index ab9fe2b3fc..efa2bc06db 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp @@ -44,8 +44,6 @@ namespace blink { const WrapperTypeInfo V8TestTypedefs::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestTypedefs::domTemplate, - V8TestTypedefs::Trace, - V8TestTypedefs::TraceWrappers, nullptr, "TestTypedefs", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.h index d2cb72e61e..7b07b848ad 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.h @@ -40,12 +40,6 @@ class V8TestTypedefs { } CORE_EXPORT static TestTypedefs* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestVariadicConstructorArguments.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestVariadicConstructorArguments.cpp index 589007040b..17d693ed8a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestVariadicConstructorArguments.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestVariadicConstructorArguments.cpp @@ -31,8 +31,6 @@ namespace blink { const WrapperTypeInfo V8TestVariadicConstructorArguments::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestVariadicConstructorArguments::domTemplate, - V8TestVariadicConstructorArguments::Trace, - V8TestVariadicConstructorArguments::TraceWrappers, nullptr, "TestVariadicConstructorArguments", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestVariadicConstructorArguments.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestVariadicConstructorArguments.h index feeb6acaee..93ba40d5b0 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestVariadicConstructorArguments.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8TestVariadicConstructorArguments.h @@ -35,12 +35,6 @@ class V8TestVariadicConstructorArguments { } CORE_EXPORT static TestVariadicConstructorArguments* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.cpp index 6edaeb06ec..c2502ccbd9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.cpp @@ -30,8 +30,6 @@ namespace blink { const WrapperTypeInfo V8Uint8ClampedArray::wrapperTypeInfo = { gin::kEmbedderBlink, nullptr, - V8Uint8ClampedArray::Trace, - V8Uint8ClampedArray::TraceWrappers, nullptr, "Uint8ClampedArray", &V8ArrayBufferView::wrapperTypeInfo, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.h index fe6c3edc36..8d5c6cf733 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/V8Uint8ClampedArray.h @@ -33,12 +33,6 @@ class V8Uint8ClampedArray { CORE_EXPORT static TestUint8ClampedArray* ToImpl(v8::Local object); CORE_EXPORT static TestUint8ClampedArray* ToImplWithTypeCheck(v8::Isolate*, v8::Local); CORE_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/array_buffer_or_array_buffer_view_or_dictionary.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/array_buffer_or_array_buffer_view_or_dictionary.h index a053c6020a..8e530b6e14 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/array_buffer_or_array_buffer_view_or_dictionary.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/array_buffer_or_array_buffer_view_or_dictionary.h @@ -14,13 +14,13 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8ArrayBufferView.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "core/typed_arrays/ArrayBufferViewHelpers.h" #include "core/typed_arrays/FlexibleArrayBufferView.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_element_sequence.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_element_sequence.h index 8f34bd1e70..f9b1f3d5a9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_element_sequence.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_element_sequence.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_string_or_unrestricted_double.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_string_or_unrestricted_double.h index 5ea7f89ba9..864a88ae63 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_string_or_unrestricted_double.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_string_or_unrestricted_double.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_test_callback_interface.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_test_callback_interface.h index 6cbc382d69..d6d2fac022 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_test_callback_interface.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/boolean_or_test_callback_interface.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/byte_string_or_node_list.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/byte_string_or_node_list.h index 9fb449aad1..c58209708f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/byte_string_or_node_list.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/byte_string_or_node_list.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/byte_string_sequence_sequence_or_byte_string_byte_string_record.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/byte_string_sequence_sequence_or_byte_string_byte_string_record.h index e0513dbce2..df7bb47616 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/byte_string_sequence_sequence_or_byte_string_byte_string_record.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/byte_string_sequence_sequence_or_byte_string_byte_string_record.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_double_or_null_sequence.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_double_or_null_sequence.h index bea3b997e9..7cd16aa5b2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_double_or_null_sequence.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_double_or_null_sequence.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_double_sequence.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_double_sequence.h index c2a5de2c06..4f89698886 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_double_sequence.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_double_sequence.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_long_or_boolean_sequence.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_long_or_boolean_sequence.h index 24c6e3e061..4738ac3877 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_long_or_boolean_sequence.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_long_or_boolean_sequence.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_string.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_string.h index 2b5712a93d..cd139cca2a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_string.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_string.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_string_or_double_or_string_sequence.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_string_or_double_or_string_sequence.h index e876461cc8..b09f534999 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_string_or_double_or_string_sequence.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/double_or_string_or_double_or_string_sequence.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/element_sequence_or_byte_string_double_or_string_record.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/element_sequence_or_byte_string_double_or_string_record.h index bf3388b87e..82967d3d4c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/element_sequence_or_byte_string_double_or_string_record.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/element_sequence_or_byte_string_double_or_string_record.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/float_or_boolean.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/float_or_boolean.h index 1e39eaf42a..a548f97293 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/float_or_boolean.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/float_or_boolean.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_or_boolean.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_or_boolean.h index 55862ea0c1..972586685f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_or_boolean.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_or_boolean.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_or_test_dictionary.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_or_test_dictionary.h index 13fd8713f5..1b5debb02b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_or_test_dictionary.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_or_test_dictionary.h @@ -14,11 +14,11 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "bindings/core/v8/V8TestDictionary.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_sequence_or_event.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_sequence_or_event.h index bb06a179a5..6253e333ba 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_sequence_or_event.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/long_sequence_or_event.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/nested_union_type.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/nested_union_type.h index 41351a3ef7..4b31182fa4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/nested_union_type.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/nested_union_type.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/node_or_node_list.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/node_or_node_list.h index 8c83695419..964149a0ea 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/node_or_node_list.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/node_or_node_list.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_array_buffer_or_array_buffer_view.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_array_buffer_or_array_buffer_view.h index 58e9d32a1b..6561ddb09e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_array_buffer_or_array_buffer_view.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_array_buffer_or_array_buffer_view.h @@ -14,13 +14,13 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8ArrayBufferView.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "core/typed_arrays/ArrayBufferViewHelpers.h" #include "core/typed_arrays/FlexibleArrayBufferView.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_double.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_double.h index e5dce270db..462190a19b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_double.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_double.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_string_sequence.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_string_sequence.h index 8981f25ad6..43dc73d731 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_string_sequence.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/string_or_string_sequence.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_double.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_double.h index 2605ff4d59..1832d1df09 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_double.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_double.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_test_enum_or_null_sequence.cc b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_test_enum_or_null_sequence.cc new file mode 100644 index 0000000000..14a56eefd8 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_test_enum_or_null_sequence.cc @@ -0,0 +1,146 @@ +// Copyright 2014 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. + +// This file has been auto-generated from the Jinja2 template +// third_party/WebKit/Source/bindings/templates/union_container.cpp.tmpl +// by the script code_generator_v8.py. +// DO NOT MODIFY! + +// clang-format off +#include "test_enum_or_test_enum_or_null_sequence.h" + +#include "bindings/core/v8/IDLTypes.h" +#include "bindings/core/v8/NativeValueTraitsImpl.h" +#include "bindings/core/v8/ToV8ForCore.h" + +namespace blink { + +TestEnumOrTestEnumOrNullSequence::TestEnumOrTestEnumOrNullSequence() : type_(SpecificType::kNone) {} + +const String& TestEnumOrTestEnumOrNullSequence::GetAsTestEnum() const { + DCHECK(IsTestEnum()); + return test_enum_; +} + +void TestEnumOrTestEnumOrNullSequence::SetTestEnum(const String& value) { + DCHECK(IsNull()); + NonThrowableExceptionState exceptionState; + const char* validValues[] = { + "", + "EnumValue1", + "EnumValue2", + "EnumValue3", + }; + if (!IsValidEnum(value, validValues, WTF_ARRAY_LENGTH(validValues), "TestEnum", exceptionState)) { + NOTREACHED(); + return; + } + test_enum_ = value; + type_ = SpecificType::kTestEnum; +} + +TestEnumOrTestEnumOrNullSequence TestEnumOrTestEnumOrNullSequence::FromTestEnum(const String& value) { + TestEnumOrTestEnumOrNullSequence container; + container.SetTestEnum(value); + return container; +} + +const Vector& TestEnumOrTestEnumOrNullSequence::GetAsTestEnumOrNullSequence() const { + DCHECK(IsTestEnumOrNullSequence()); + return test_enum_or_null_sequence_; +} + +void TestEnumOrTestEnumOrNullSequence::SetTestEnumOrNullSequence(const Vector& value) { + DCHECK(IsNull()); + NonThrowableExceptionState exceptionState; + const char* validValues[] = { + nullptr, + "", + "EnumValue1", + "EnumValue2", + "EnumValue3", + }; + if (!IsValidEnum(value, validValues, WTF_ARRAY_LENGTH(validValues), "TestEnum", exceptionState)) { + NOTREACHED(); + return; + } + test_enum_or_null_sequence_ = value; + type_ = SpecificType::kTestEnumOrNullSequence; +} + +TestEnumOrTestEnumOrNullSequence TestEnumOrTestEnumOrNullSequence::FromTestEnumOrNullSequence(const Vector& value) { + TestEnumOrTestEnumOrNullSequence container; + container.SetTestEnumOrNullSequence(value); + return container; +} + +TestEnumOrTestEnumOrNullSequence::TestEnumOrTestEnumOrNullSequence(const TestEnumOrTestEnumOrNullSequence&) = default; +TestEnumOrTestEnumOrNullSequence::~TestEnumOrTestEnumOrNullSequence() = default; +TestEnumOrTestEnumOrNullSequence& TestEnumOrTestEnumOrNullSequence::operator=(const TestEnumOrTestEnumOrNullSequence&) = default; + +void TestEnumOrTestEnumOrNullSequence::Trace(blink::Visitor* visitor) { +} + +void V8TestEnumOrTestEnumOrNullSequence::ToImpl(v8::Isolate* isolate, v8::Local v8Value, TestEnumOrTestEnumOrNullSequence& impl, UnionTypeConversionMode conversionMode, ExceptionState& exceptionState) { + if (v8Value.IsEmpty()) + return; + + if (conversionMode == UnionTypeConversionMode::kNullable && IsUndefinedOrNull(v8Value)) + return; + + if (HasCallableIteratorSymbol(isolate, v8Value, exceptionState)) { + Vector cppValue = NativeValueTraits>>::NativeValue(isolate, v8Value, exceptionState); + if (exceptionState.HadException()) + return; + const char* validValues[] = { + nullptr, + "", + "EnumValue1", + "EnumValue2", + "EnumValue3", + }; + if (!IsValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "TestEnum", exceptionState)) + return; + impl.SetTestEnumOrNullSequence(cppValue); + return; + } + + { + V8StringResource<> cppValue = v8Value; + if (!cppValue.Prepare(exceptionState)) + return; + const char* validValues[] = { + "", + "EnumValue1", + "EnumValue2", + "EnumValue3", + }; + if (!IsValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "TestEnum", exceptionState)) + return; + impl.SetTestEnum(cppValue); + return; + } +} + +v8::Local ToV8(const TestEnumOrTestEnumOrNullSequence& impl, v8::Local creationContext, v8::Isolate* isolate) { + switch (impl.type_) { + case TestEnumOrTestEnumOrNullSequence::SpecificType::kNone: + return v8::Null(isolate); + case TestEnumOrTestEnumOrNullSequence::SpecificType::kTestEnum: + return V8String(isolate, impl.GetAsTestEnum()); + case TestEnumOrTestEnumOrNullSequence::SpecificType::kTestEnumOrNullSequence: + return ToV8(impl.GetAsTestEnumOrNullSequence(), creationContext, isolate); + default: + NOTREACHED(); + } + return v8::Local(); +} + +TestEnumOrTestEnumOrNullSequence NativeValueTraits::NativeValue(v8::Isolate* isolate, v8::Local value, ExceptionState& exceptionState) { + TestEnumOrTestEnumOrNullSequence impl; + V8TestEnumOrTestEnumOrNullSequence::ToImpl(isolate, value, impl, UnionTypeConversionMode::kNotNullable, exceptionState); + return impl; +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_test_enum_or_null_sequence.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_test_enum_or_null_sequence.h new file mode 100644 index 0000000000..177d68f1fd --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_test_enum_or_null_sequence.h @@ -0,0 +1,95 @@ +// Copyright 2014 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. + +// This file has been auto-generated from the Jinja2 template +// third_party/WebKit/Source/bindings/templates/union_container.h.tmpl +// by the script code_generator_v8.py. +// DO NOT MODIFY! + +// clang-format off +#ifndef TestEnumOrTestEnumOrNullSequence_h +#define TestEnumOrTestEnumOrNullSequence_h + +#include "bindings/core/v8/Dictionary.h" +#include "bindings/core/v8/ExceptionState.h" +#include "bindings/core/v8/NativeValueTraits.h" +#include "bindings/core/v8/V8BindingForCore.h" +#include "core/CoreExport.h" +#include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" + +namespace blink { + +class CORE_EXPORT TestEnumOrTestEnumOrNullSequence final { + DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); + public: + TestEnumOrTestEnumOrNullSequence(); + bool IsNull() const { return type_ == SpecificType::kNone; } + + bool IsTestEnum() const { return type_ == SpecificType::kTestEnum; } + const String& GetAsTestEnum() const; + void SetTestEnum(const String&); + static TestEnumOrTestEnumOrNullSequence FromTestEnum(const String&); + + bool IsTestEnumOrNullSequence() const { return type_ == SpecificType::kTestEnumOrNullSequence; } + const Vector& GetAsTestEnumOrNullSequence() const; + void SetTestEnumOrNullSequence(const Vector&); + static TestEnumOrTestEnumOrNullSequence FromTestEnumOrNullSequence(const Vector&); + + TestEnumOrTestEnumOrNullSequence(const TestEnumOrTestEnumOrNullSequence&); + ~TestEnumOrTestEnumOrNullSequence(); + TestEnumOrTestEnumOrNullSequence& operator=(const TestEnumOrTestEnumOrNullSequence&); + void Trace(blink::Visitor*); + + private: + enum class SpecificType { + kNone, + kTestEnum, + kTestEnumOrNullSequence, + }; + SpecificType type_; + + String test_enum_; + Vector test_enum_or_null_sequence_; + + friend CORE_EXPORT v8::Local ToV8(const TestEnumOrTestEnumOrNullSequence&, v8::Local, v8::Isolate*); +}; + +class V8TestEnumOrTestEnumOrNullSequence final { + public: + CORE_EXPORT static void ToImpl(v8::Isolate*, v8::Local, TestEnumOrTestEnumOrNullSequence&, UnionTypeConversionMode, ExceptionState&); +}; + +CORE_EXPORT v8::Local ToV8(const TestEnumOrTestEnumOrNullSequence&, v8::Local, v8::Isolate*); + +template +inline void V8SetReturnValue(const CallbackInfo& callbackInfo, TestEnumOrTestEnumOrNullSequence& impl) { + V8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate())); +} + +template +inline void V8SetReturnValue(const CallbackInfo& callbackInfo, TestEnumOrTestEnumOrNullSequence& impl, v8::Local creationContext) { + V8SetReturnValue(callbackInfo, ToV8(impl, creationContext, callbackInfo.GetIsolate())); +} + +template <> +struct NativeValueTraits : public NativeValueTraitsBase { + CORE_EXPORT static TestEnumOrTestEnumOrNullSequence NativeValue(v8::Isolate*, v8::Local, ExceptionState&); + CORE_EXPORT static TestEnumOrTestEnumOrNullSequence NullValue() { return TestEnumOrTestEnumOrNullSequence(); } +}; + +template <> +struct V8TypeOf { + typedef V8TestEnumOrTestEnumOrNullSequence Type; +}; + +} // namespace blink + +// We need to set canInitializeWithMemset=true because HeapVector supports +// items that can initialize with memset or have a vtable. It is safe to +// set canInitializeWithMemset=true for a union type object in practice. +// See https://codereview.chromium.org/1118993002/#msg5 for more details. +WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::TestEnumOrTestEnumOrNullSequence); + +#endif // TestEnumOrTestEnumOrNullSequence_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_test_enum_sequence.cc b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_test_enum_sequence.cc index cdcc0ef63a..d1018afe54 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_test_enum_sequence.cc +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/test_enum_or_test_enum_sequence.cc @@ -60,7 +60,7 @@ void TestEnumOrTestEnumSequence::SetTestEnumSequence(const Vector& value "EnumValue2", "EnumValue3", }; - if (!IsValidEnum(value, validValues, WTF_ARRAY_LENGTH(validValues), "TestEnumSequence", exceptionState)) { + if (!IsValidEnum(value, validValues, WTF_ARRAY_LENGTH(validValues), "TestEnum", exceptionState)) { NOTREACHED(); return; } @@ -98,7 +98,7 @@ void V8TestEnumOrTestEnumSequence::ToImpl(v8::Isolate* isolate, v8::Local V8AnyCallbackFunctionOptionalAnyArg::Invoke(ScriptWrappab } } +CORE_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackFunction::Invoke(ScriptWrappable* callback_this_value, ScriptValue optionalAnyArg) { + return Proxy()->Invoke( + callback_this_value, optionalAnyArg); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_any_callback_function_optional_any_arg.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_any_callback_function_optional_any_arg.h index 98434e4d03..112c88c56e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_any_callback_function_optional_any_arg.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_any_callback_function_optional_any_arg.h @@ -36,6 +36,39 @@ class CORE_EXPORT V8AnyCallbackFunctionOptionalAnyArg final : public CallbackFun : CallbackFunctionBase(callback_function) {} }; +template <> +class CORE_TEMPLATE_CLASS_EXPORT V8PersistentCallbackFunction final : public V8PersistentCallbackFunctionBase { + using V8CallbackFunction = V8AnyCallbackFunctionOptionalAnyArg; + + public: + ~V8PersistentCallbackFunction() override = default; + + // Returns a wrapper-tracing version of this callback function. + V8CallbackFunction* ToNonV8Persistent() { return Proxy(); } + + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe Invoke(ScriptWrappable* callback_this_value, ScriptValue optionalAnyArg) WARN_UNUSED_RESULT; + + private: + explicit V8PersistentCallbackFunction(V8CallbackFunction* callback_function) + : V8PersistentCallbackFunctionBase(callback_function) {} + + V8CallbackFunction* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackFunction* + ToV8PersistentCallbackFunction(V8CallbackFunction*); +}; + +// V8AnyCallbackFunctionOptionalAnyArg is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback functions is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackFunction*). +Persistent WrapPersistent(V8AnyCallbackFunctionOptionalAnyArg*) = delete; + } // namespace blink #endif // V8AnyCallbackFunctionOptionalAnyArg_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_long_callback_function.cc b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_long_callback_function.cc index 881268a058..9df7a63525 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_long_callback_function.cc +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_long_callback_function.cc @@ -111,4 +111,10 @@ v8::Maybe V8LongCallbackFunction::Invoke(ScriptWrappable* callback_this } } +CORE_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackFunction::Invoke(ScriptWrappable* callback_this_value, int32_t num1, int32_t num2) { + return Proxy()->Invoke( + callback_this_value, num1, num2); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_long_callback_function.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_long_callback_function.h index eec69f3458..63372e6b0b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_long_callback_function.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_long_callback_function.h @@ -36,6 +36,39 @@ class CORE_EXPORT V8LongCallbackFunction final : public CallbackFunctionBase { : CallbackFunctionBase(callback_function) {} }; +template <> +class CORE_TEMPLATE_CLASS_EXPORT V8PersistentCallbackFunction final : public V8PersistentCallbackFunctionBase { + using V8CallbackFunction = V8LongCallbackFunction; + + public: + ~V8PersistentCallbackFunction() override = default; + + // Returns a wrapper-tracing version of this callback function. + V8CallbackFunction* ToNonV8Persistent() { return Proxy(); } + + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe Invoke(ScriptWrappable* callback_this_value, int32_t num1, int32_t num2) WARN_UNUSED_RESULT; + + private: + explicit V8PersistentCallbackFunction(V8CallbackFunction* callback_function) + : V8PersistentCallbackFunctionBase(callback_function) {} + + V8CallbackFunction* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackFunction* + ToV8PersistentCallbackFunction(V8CallbackFunction*); +}; + +// V8LongCallbackFunction is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback functions is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackFunction*). +Persistent WrapPersistent(V8LongCallbackFunction*) = delete; + } // namespace blink #endif // V8LongCallbackFunction_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_string_sequence_callback_function_long_sequence_arg.cc b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_string_sequence_callback_function_long_sequence_arg.cc index b52150f7d6..204cf43957 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_string_sequence_callback_function_long_sequence_arg.cc +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_string_sequence_callback_function_long_sequence_arg.cc @@ -110,4 +110,10 @@ v8::Maybe> V8StringSequenceCallbackFunctionLongSequenceArg::Invok } } +CORE_TEMPLATE_EXPORT +v8::Maybe> V8PersistentCallbackFunction::Invoke(ScriptWrappable* callback_this_value, const Vector& arg) { + return Proxy()->Invoke( + callback_this_value, arg); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_string_sequence_callback_function_long_sequence_arg.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_string_sequence_callback_function_long_sequence_arg.h index 34dc31d091..3ab5822036 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_string_sequence_callback_function_long_sequence_arg.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_string_sequence_callback_function_long_sequence_arg.h @@ -36,6 +36,39 @@ class CORE_EXPORT V8StringSequenceCallbackFunctionLongSequenceArg final : public : CallbackFunctionBase(callback_function) {} }; +template <> +class CORE_TEMPLATE_CLASS_EXPORT V8PersistentCallbackFunction final : public V8PersistentCallbackFunctionBase { + using V8CallbackFunction = V8StringSequenceCallbackFunctionLongSequenceArg; + + public: + ~V8PersistentCallbackFunction() override = default; + + // Returns a wrapper-tracing version of this callback function. + V8CallbackFunction* ToNonV8Persistent() { return Proxy(); } + + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe> Invoke(ScriptWrappable* callback_this_value, const Vector& arg) WARN_UNUSED_RESULT; + + private: + explicit V8PersistentCallbackFunction(V8CallbackFunction* callback_function) + : V8PersistentCallbackFunctionBase(callback_function) {} + + V8CallbackFunction* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackFunction* + ToV8PersistentCallbackFunction(V8CallbackFunction*); +}; + +// V8StringSequenceCallbackFunctionLongSequenceArg is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback functions is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackFunction*). +Persistent WrapPersistent(V8StringSequenceCallbackFunctionLongSequenceArg*) = delete; + } // namespace blink #endif // V8StringSequenceCallbackFunctionLongSequenceArg_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function.cc b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function.cc index 317cdba1bc..db5d52883e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function.cc +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function.cc @@ -109,4 +109,16 @@ void V8VoidCallbackFunction::InvokeAndReportException(ScriptWrappable* callback_ ALLOW_UNUSED_LOCAL(maybe_result); } +CORE_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackFunction::Invoke(ScriptWrappable* callback_this_value) { + return Proxy()->Invoke( + callback_this_value); +} + +CORE_TEMPLATE_EXPORT +void V8PersistentCallbackFunction::InvokeAndReportException(ScriptWrappable* callback_this_value) { + Proxy()->InvokeAndReportException( + callback_this_value); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function.h index 16ba113072..775076ee12 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function.h @@ -40,6 +40,41 @@ class CORE_EXPORT V8VoidCallbackFunction final : public CallbackFunctionBase { : CallbackFunctionBase(callback_function) {} }; +template <> +class CORE_TEMPLATE_CLASS_EXPORT V8PersistentCallbackFunction final : public V8PersistentCallbackFunctionBase { + using V8CallbackFunction = V8VoidCallbackFunction; + + public: + ~V8PersistentCallbackFunction() override = default; + + // Returns a wrapper-tracing version of this callback function. + V8CallbackFunction* ToNonV8Persistent() { return Proxy(); } + + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe Invoke(ScriptWrappable* callback_this_value) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + void InvokeAndReportException(ScriptWrappable* callback_this_value); + + private: + explicit V8PersistentCallbackFunction(V8CallbackFunction* callback_function) + : V8PersistentCallbackFunctionBase(callback_function) {} + + V8CallbackFunction* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackFunction* + ToV8PersistentCallbackFunction(V8CallbackFunction*); +}; + +// V8VoidCallbackFunction is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback functions is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackFunction*). +Persistent WrapPersistent(V8VoidCallbackFunction*) = delete; + } // namespace blink #endif // V8VoidCallbackFunction_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_dictionary_arg.cc b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_dictionary_arg.cc index 15b89e8d4f..eecca4a406 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_dictionary_arg.cc +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_dictionary_arg.cc @@ -111,4 +111,16 @@ void V8VoidCallbackFunctionDictionaryArg::InvokeAndReportException(ScriptWrappab ALLOW_UNUSED_LOCAL(maybe_result); } +CORE_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackFunction::Invoke(ScriptWrappable* callback_this_value, const TestDictionary& arg) { + return Proxy()->Invoke( + callback_this_value, arg); +} + +CORE_TEMPLATE_EXPORT +void V8PersistentCallbackFunction::InvokeAndReportException(ScriptWrappable* callback_this_value, const TestDictionary& arg) { + Proxy()->InvokeAndReportException( + callback_this_value, arg); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_dictionary_arg.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_dictionary_arg.h index c118902024..2623825e77 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_dictionary_arg.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_dictionary_arg.h @@ -41,6 +41,41 @@ class CORE_EXPORT V8VoidCallbackFunctionDictionaryArg final : public CallbackFun : CallbackFunctionBase(callback_function) {} }; +template <> +class CORE_TEMPLATE_CLASS_EXPORT V8PersistentCallbackFunction final : public V8PersistentCallbackFunctionBase { + using V8CallbackFunction = V8VoidCallbackFunctionDictionaryArg; + + public: + ~V8PersistentCallbackFunction() override = default; + + // Returns a wrapper-tracing version of this callback function. + V8CallbackFunction* ToNonV8Persistent() { return Proxy(); } + + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe Invoke(ScriptWrappable* callback_this_value, const TestDictionary& arg) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + void InvokeAndReportException(ScriptWrappable* callback_this_value, const TestDictionary& arg); + + private: + explicit V8PersistentCallbackFunction(V8CallbackFunction* callback_function) + : V8PersistentCallbackFunctionBase(callback_function) {} + + V8CallbackFunction* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackFunction* + ToV8PersistentCallbackFunction(V8CallbackFunction*); +}; + +// V8VoidCallbackFunctionDictionaryArg is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback functions is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackFunction*). +Persistent WrapPersistent(V8VoidCallbackFunctionDictionaryArg*) = delete; + } // namespace blink #endif // V8VoidCallbackFunctionDictionaryArg_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_enum_arg.cc b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_enum_arg.cc index 335c16674e..03de0d9b24 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_enum_arg.cc +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_enum_arg.cc @@ -131,4 +131,16 @@ void V8VoidCallbackFunctionEnumArg::InvokeAndReportException(ScriptWrappable* ca ALLOW_UNUSED_LOCAL(maybe_result); } +CORE_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackFunction::Invoke(ScriptWrappable* callback_this_value, const String& arg) { + return Proxy()->Invoke( + callback_this_value, arg); +} + +CORE_TEMPLATE_EXPORT +void V8PersistentCallbackFunction::InvokeAndReportException(ScriptWrappable* callback_this_value, const String& arg) { + Proxy()->InvokeAndReportException( + callback_this_value, arg); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_enum_arg.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_enum_arg.h index 41e4804eda..9867c9f726 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_enum_arg.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_enum_arg.h @@ -40,6 +40,41 @@ class CORE_EXPORT V8VoidCallbackFunctionEnumArg final : public CallbackFunctionB : CallbackFunctionBase(callback_function) {} }; +template <> +class CORE_TEMPLATE_CLASS_EXPORT V8PersistentCallbackFunction final : public V8PersistentCallbackFunctionBase { + using V8CallbackFunction = V8VoidCallbackFunctionEnumArg; + + public: + ~V8PersistentCallbackFunction() override = default; + + // Returns a wrapper-tracing version of this callback function. + V8CallbackFunction* ToNonV8Persistent() { return Proxy(); } + + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe Invoke(ScriptWrappable* callback_this_value, const String& arg) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + void InvokeAndReportException(ScriptWrappable* callback_this_value, const String& arg); + + private: + explicit V8PersistentCallbackFunction(V8CallbackFunction* callback_function) + : V8PersistentCallbackFunctionBase(callback_function) {} + + V8CallbackFunction* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackFunction* + ToV8PersistentCallbackFunction(V8CallbackFunction*); +}; + +// V8VoidCallbackFunctionEnumArg is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback functions is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackFunction*). +Persistent WrapPersistent(V8VoidCallbackFunctionEnumArg*) = delete; + } // namespace blink #endif // V8VoidCallbackFunctionEnumArg_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_interface_arg.cc b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_interface_arg.cc index 6b450cb962..70b9c5a86d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_interface_arg.cc +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_interface_arg.cc @@ -111,4 +111,16 @@ void V8VoidCallbackFunctionInterfaceArg::InvokeAndReportException(ScriptWrappabl ALLOW_UNUSED_LOCAL(maybe_result); } +CORE_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackFunction::Invoke(ScriptWrappable* callback_this_value, HTMLDivElement* divElement) { + return Proxy()->Invoke( + callback_this_value, divElement); +} + +CORE_TEMPLATE_EXPORT +void V8PersistentCallbackFunction::InvokeAndReportException(ScriptWrappable* callback_this_value, HTMLDivElement* divElement) { + Proxy()->InvokeAndReportException( + callback_this_value, divElement); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_interface_arg.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_interface_arg.h index 17431d4fe5..b54b4ed5ef 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_interface_arg.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_interface_arg.h @@ -41,6 +41,41 @@ class CORE_EXPORT V8VoidCallbackFunctionInterfaceArg final : public CallbackFunc : CallbackFunctionBase(callback_function) {} }; +template <> +class CORE_TEMPLATE_CLASS_EXPORT V8PersistentCallbackFunction final : public V8PersistentCallbackFunctionBase { + using V8CallbackFunction = V8VoidCallbackFunctionInterfaceArg; + + public: + ~V8PersistentCallbackFunction() override = default; + + // Returns a wrapper-tracing version of this callback function. + V8CallbackFunction* ToNonV8Persistent() { return Proxy(); } + + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe Invoke(ScriptWrappable* callback_this_value, HTMLDivElement* divElement) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + void InvokeAndReportException(ScriptWrappable* callback_this_value, HTMLDivElement* divElement); + + private: + explicit V8PersistentCallbackFunction(V8CallbackFunction* callback_function) + : V8PersistentCallbackFunctionBase(callback_function) {} + + V8CallbackFunction* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackFunction* + ToV8PersistentCallbackFunction(V8CallbackFunction*); +}; + +// V8VoidCallbackFunctionInterfaceArg is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback functions is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackFunction*). +Persistent WrapPersistent(V8VoidCallbackFunctionInterfaceArg*) = delete; + } // namespace blink #endif // V8VoidCallbackFunctionInterfaceArg_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_test_interface_sequence_arg.cc b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_test_interface_sequence_arg.cc index 80a9f5295a..b1c23a1234 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_test_interface_sequence_arg.cc +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_test_interface_sequence_arg.cc @@ -112,4 +112,16 @@ void V8VoidCallbackFunctionTestInterfaceSequenceArg::InvokeAndReportException(Sc ALLOW_UNUSED_LOCAL(maybe_result); } +CORE_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackFunction::Invoke(ScriptWrappable* callback_this_value, const HeapVector>& arg) { + return Proxy()->Invoke( + callback_this_value, arg); +} + +CORE_TEMPLATE_EXPORT +void V8PersistentCallbackFunction::InvokeAndReportException(ScriptWrappable* callback_this_value, const HeapVector>& arg) { + Proxy()->InvokeAndReportException( + callback_this_value, arg); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_test_interface_sequence_arg.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_test_interface_sequence_arg.h index 57572e277e..1a82a9f3d5 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_test_interface_sequence_arg.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_test_interface_sequence_arg.h @@ -41,6 +41,41 @@ class CORE_EXPORT V8VoidCallbackFunctionTestInterfaceSequenceArg final : public : CallbackFunctionBase(callback_function) {} }; +template <> +class CORE_TEMPLATE_CLASS_EXPORT V8PersistentCallbackFunction final : public V8PersistentCallbackFunctionBase { + using V8CallbackFunction = V8VoidCallbackFunctionTestInterfaceSequenceArg; + + public: + ~V8PersistentCallbackFunction() override = default; + + // Returns a wrapper-tracing version of this callback function. + V8CallbackFunction* ToNonV8Persistent() { return Proxy(); } + + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe Invoke(ScriptWrappable* callback_this_value, const HeapVector>& arg) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + void InvokeAndReportException(ScriptWrappable* callback_this_value, const HeapVector>& arg); + + private: + explicit V8PersistentCallbackFunction(V8CallbackFunction* callback_function) + : V8PersistentCallbackFunctionBase(callback_function) {} + + V8CallbackFunction* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackFunction* + ToV8PersistentCallbackFunction(V8CallbackFunction*); +}; + +// V8VoidCallbackFunctionTestInterfaceSequenceArg is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback functions is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackFunction*). +Persistent WrapPersistent(V8VoidCallbackFunctionTestInterfaceSequenceArg*) = delete; + } // namespace blink #endif // V8VoidCallbackFunctionTestInterfaceSequenceArg_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_typedef.cc b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_typedef.cc index 3235d68168..87bedc6a63 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_typedef.cc +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_typedef.cc @@ -111,4 +111,16 @@ void V8VoidCallbackFunctionTypedef::InvokeAndReportException(ScriptWrappable* ca ALLOW_UNUSED_LOCAL(maybe_result); } +CORE_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackFunction::Invoke(ScriptWrappable* callback_this_value, const String& arg) { + return Proxy()->Invoke( + callback_this_value, arg); +} + +CORE_TEMPLATE_EXPORT +void V8PersistentCallbackFunction::InvokeAndReportException(ScriptWrappable* callback_this_value, const String& arg) { + Proxy()->InvokeAndReportException( + callback_this_value, arg); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_typedef.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_typedef.h index e8dde927fc..6405e43330 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_typedef.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/v8_void_callback_function_typedef.h @@ -40,6 +40,41 @@ class CORE_EXPORT V8VoidCallbackFunctionTypedef final : public CallbackFunctionB : CallbackFunctionBase(callback_function) {} }; +template <> +class CORE_TEMPLATE_CLASS_EXPORT V8PersistentCallbackFunction final : public V8PersistentCallbackFunctionBase { + using V8CallbackFunction = V8VoidCallbackFunctionTypedef; + + public: + ~V8PersistentCallbackFunction() override = default; + + // Returns a wrapper-tracing version of this callback function. + V8CallbackFunction* ToNonV8Persistent() { return Proxy(); } + + CORE_EXTERN_TEMPLATE_EXPORT + v8::Maybe Invoke(ScriptWrappable* callback_this_value, const String& arg) WARN_UNUSED_RESULT; + CORE_EXTERN_TEMPLATE_EXPORT + void InvokeAndReportException(ScriptWrappable* callback_this_value, const String& arg); + + private: + explicit V8PersistentCallbackFunction(V8CallbackFunction* callback_function) + : V8PersistentCallbackFunctionBase(callback_function) {} + + V8CallbackFunction* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackFunction* + ToV8PersistentCallbackFunction(V8CallbackFunction*); +}; + +// V8VoidCallbackFunctionTypedef is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback functions is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackFunction*). +Persistent WrapPersistent(V8VoidCallbackFunctionTypedef*) = delete; + } // namespace blink #endif // V8VoidCallbackFunctionTypedef_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/xml_http_request_or_string.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/xml_http_request_or_string.h index bdeb53c65d..86306d3579 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/xml_http_request_or_string.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/core/xml_http_request_or_string.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInheritedLegacyUnenumerableNamedProperties.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInheritedLegacyUnenumerableNamedProperties.cpp index ca560dfc50..1243e3c222 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInheritedLegacyUnenumerableNamedProperties.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInheritedLegacyUnenumerableNamedProperties.cpp @@ -31,8 +31,6 @@ namespace blink { const WrapperTypeInfo V8TestInheritedLegacyUnenumerableNamedProperties::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInheritedLegacyUnenumerableNamedProperties::domTemplate, - V8TestInheritedLegacyUnenumerableNamedProperties::Trace, - V8TestInheritedLegacyUnenumerableNamedProperties::TraceWrappers, nullptr, "TestInheritedLegacyUnenumerableNamedProperties", &V8TestSpecialOperationsNotEnumerable::wrapperTypeInfo, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInheritedLegacyUnenumerableNamedProperties.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInheritedLegacyUnenumerableNamedProperties.h index 9c6c2aca67..909cb8f776 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInheritedLegacyUnenumerableNamedProperties.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInheritedLegacyUnenumerableNamedProperties.h @@ -36,12 +36,6 @@ class V8TestInheritedLegacyUnenumerableNamedProperties { } MODULES_EXPORT static TestInheritedLegacyUnenumerableNamedProperties* ToImplWithTypeCheck(v8::Isolate*, v8::Local); MODULES_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp index e820eeb3c5..8a98d19602 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.cpp @@ -35,8 +35,6 @@ namespace blink { const WrapperTypeInfo V8TestInterface5::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface5::domTemplate, - V8TestInterface5::Trace, - V8TestInterface5::TraceWrappers, V8TestInterface5::InstallConditionalFeatures, "TestInterface5", &V8TestInterfaceEmpty::wrapperTypeInfo, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.h index a068ce7b96..f084ce7a7b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestInterface5.h @@ -38,12 +38,6 @@ class V8TestInterface5 { } MODULES_EXPORT static TestInterface5Implementation* ToImplWithTypeCheck(v8::Isolate*, v8::Local); MODULES_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static void legacyCallCustom(const v8::FunctionCallbackInfo&); static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestNotEnumerableNamedGetter.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestNotEnumerableNamedGetter.cpp index f1d865bc2d..d1c639f939 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestNotEnumerableNamedGetter.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestNotEnumerableNamedGetter.cpp @@ -30,8 +30,6 @@ namespace blink { const WrapperTypeInfo V8TestNotEnumerableNamedGetter::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestNotEnumerableNamedGetter::domTemplate, - V8TestNotEnumerableNamedGetter::Trace, - V8TestNotEnumerableNamedGetter::TraceWrappers, nullptr, "TestNotEnumerableNamedGetter", nullptr, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestNotEnumerableNamedGetter.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestNotEnumerableNamedGetter.h index 18c2123ae8..781e304e2a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestNotEnumerableNamedGetter.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestNotEnumerableNamedGetter.h @@ -35,12 +35,6 @@ class V8TestNotEnumerableNamedGetter { } MODULES_EXPORT static TestNotEnumerableNamedGetter* ToImplWithTypeCheck(v8::Isolate*, v8::Local); MODULES_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.cpp index 0be722aff8..198d5d4f88 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.cpp @@ -31,8 +31,6 @@ namespace blink { const WrapperTypeInfo V8TestSubObject::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSubObject::domTemplate, - V8TestSubObject::Trace, - V8TestSubObject::TraceWrappers, nullptr, "TestSubObject", &V8TestObject::wrapperTypeInfo, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.h index 935233198c..921b954ccb 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/V8TestSubObject.h @@ -36,12 +36,6 @@ class V8TestSubObject { } MODULES_EXPORT static TestSubObject* ToImplWithTypeCheck(v8::Isolate*, v8::Local); MODULES_EXPORT static const WrapperTypeInfo wrapperTypeInfo; - static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceFromGeneratedCode(scriptWrappable->ToImpl()); - } - static void TraceWrappers(ScriptWrappableVisitor* visitor, ScriptWrappable* scriptWrappable) { - visitor->TraceWrappersFromGeneratedCode(scriptWrappable->ToImpl()); - } static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount; // Callback functions diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/boolean_or_string.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/boolean_or_string.h index c86f194d5b..a5ddd78b9d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/boolean_or_string.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/boolean_or_string.h @@ -14,10 +14,10 @@ #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" -#include "bindings/core/v8/Nullable.h" #include "bindings/core/v8/V8BindingForCore.h" #include "modules/ModulesExport.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/v8_void_callback_function_modules.cc b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/v8_void_callback_function_modules.cc index 0edd594455..5a2bb5247a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/v8_void_callback_function_modules.cc +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/v8_void_callback_function_modules.cc @@ -109,4 +109,16 @@ void V8VoidCallbackFunctionModules::InvokeAndReportException(ScriptWrappable* ca ALLOW_UNUSED_LOCAL(maybe_result); } +MODULES_TEMPLATE_EXPORT +v8::Maybe V8PersistentCallbackFunction::Invoke(ScriptWrappable* callback_this_value) { + return Proxy()->Invoke( + callback_this_value); +} + +MODULES_TEMPLATE_EXPORT +void V8PersistentCallbackFunction::InvokeAndReportException(ScriptWrappable* callback_this_value) { + Proxy()->InvokeAndReportException( + callback_this_value); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/v8_void_callback_function_modules.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/v8_void_callback_function_modules.h index 156abbfc13..84f9c982d6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/v8_void_callback_function_modules.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/bindings/tests/results/modules/v8_void_callback_function_modules.h @@ -40,6 +40,41 @@ class MODULES_EXPORT V8VoidCallbackFunctionModules final : public CallbackFuncti : CallbackFunctionBase(callback_function) {} }; +template <> +class MODULES_TEMPLATE_CLASS_EXPORT V8PersistentCallbackFunction final : public V8PersistentCallbackFunctionBase { + using V8CallbackFunction = V8VoidCallbackFunctionModules; + + public: + ~V8PersistentCallbackFunction() override = default; + + // Returns a wrapper-tracing version of this callback function. + V8CallbackFunction* ToNonV8Persistent() { return Proxy(); } + + MODULES_EXTERN_TEMPLATE_EXPORT + v8::Maybe Invoke(ScriptWrappable* callback_this_value) WARN_UNUSED_RESULT; + MODULES_EXTERN_TEMPLATE_EXPORT + void InvokeAndReportException(ScriptWrappable* callback_this_value); + + private: + explicit V8PersistentCallbackFunction(V8CallbackFunction* callback_function) + : V8PersistentCallbackFunctionBase(callback_function) {} + + V8CallbackFunction* Proxy() { + return As(); + } + + template + friend V8PersistentCallbackFunction* + ToV8PersistentCallbackFunction(V8CallbackFunction*); +}; + +// V8VoidCallbackFunctionModules is designed to be used with wrapper-tracing. +// As blink::Persistent does not perform wrapper-tracing, use of +// |WrapPersistent| for callback functions is likely (if not always) misuse. +// Thus, this code prohibits such a use case. The call sites should explicitly +// use WrapPersistent(V8PersistentCallbackFunction*). +Persistent WrapPersistent(V8VoidCallbackFunctionModules*) = delete; + } // namespace blink #endif // V8VoidCallbackFunctionModules_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/make_cssom_types.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/make_cssom_types.py index 3c465ca76e..ac818f9e18 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/make_cssom_types.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/make_cssom_types.py @@ -16,9 +16,8 @@ class CSSOMTypesWriter(json5_generator.Writer): """ Generates CSSOMTypes.cpp and CSSOMKeywords.cpp. These classes provide - utility methods for determining whether a given CSSStyleValue or - CSSKeywordValue is valid for a given CSS property. The header files live in - core/css/cssom. + utility methods for determining whether a given CSSStyleValue is valid + for a given CSS property. The header files live in core/css/cssom. """ def __init__(self, json5_file_paths): super(CSSOMTypesWriter, self).__init__([]) @@ -31,10 +30,7 @@ def __init__(self, json5_file_paths): types = [] # Expand types for single_type in property_['typedom_types']: - if single_type == 'Image': - types.append('URLImage') - else: - types.append(single_type) + types.append(single_type) property_['typedom_types'] = types # Generate Keyword ID values from keywords. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/make_atrule_names.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/make_atrule_names.py index b9204a3ae6..0a3401c588 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/make_atrule_names.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/make_atrule_names.py @@ -42,8 +42,7 @@ def __init__(self, json5_file_paths): descriptor['name']) descriptor['enum_value'] = first_descriptor_id + offset self._character_offsets.append(chars_used) - # Add 1 to account for null terminator. - chars_used = chars_used + len(descriptor['name']) + 1 + chars_used += len(descriptor['name']) self._longest_name_length = max( len(descriptor['name']), len(descriptor['alias']), diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/templates/AtRuleDescriptors.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/templates/AtRuleDescriptors.cpp.tmpl index 94a821b331..9713b22d8e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/templates/AtRuleDescriptors.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/templates/AtRuleDescriptors.cpp.tmpl @@ -14,29 +14,10 @@ #pragma warning(disable : 4302 4311) #endif -#if defined(__clang__) -#pragma clang diagnostic push -// TODO(thakis): Remove once we use a gperf that no longer produces "register". -#pragma clang diagnostic ignored "-Wdeprecated-register" -#endif - namespace blink { namespace { -static const char descriptorNamesStringPool[] = { -{% for descriptor in descriptors %} - "{{descriptor.name}}\0" -{% endfor %} -}; - -static const unsigned short descriptorStringOffsets[] = { - 0, // Invalid. Should not be reached. -{% for offset in descriptor_offsets %} - {{offset}}, -{% endfor %} -}; - %} %struct-type @@ -61,10 +42,6 @@ struct Property; {% endfor %} %% -#if defined(__clang__) -#pragma clang diagnostic pop -#endif - const Property* FindDescriptor(const char* str, unsigned int len) { return AtRuleDescriptorHash::findDescriptorImpl(str, len); } @@ -97,15 +74,6 @@ static AtRuleDescriptorID AsAtRuleDescriptorID( } // namespace -const char* GetDescriptorName(AtRuleDescriptorID descriptor_id) { - DCHECK_NE(AtRuleDescriptorID::Invalid, descriptor_id); - DCHECK_LT(static_cast(descriptor_id), numAtRuleDescriptors); - unsigned short id = static_cast(descriptor_id); - unsigned short offset = descriptorStringOffsets[id]; - return &descriptorNamesStringPool[offset]; -} - - AtRuleDescriptorID AsAtRuleDescriptorID(StringView string) { unsigned length = string.length(); return string.Is8Bit() @@ -132,6 +100,7 @@ AtRuleDescriptorID CSSPropertyIDAsAtRuleDescriptor(CSSPropertyID id) { return AtRuleDescriptorID::{{descriptor.upper_camel_name}}; {% endfor %} default: + NOTREACHED(); return AtRuleDescriptorID::Invalid; } } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/templates/AtRuleDescriptors.h.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/templates/AtRuleDescriptors.h.tmpl index 3c540058d0..7b149a0cc9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/templates/AtRuleDescriptors.h.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/parser/templates/AtRuleDescriptors.h.tmpl @@ -18,20 +18,9 @@ enum class AtRuleDescriptorID { {% endfor %} }; -struct AtRuleDescriptorIDHash { - STATIC_ONLY(AtRuleDescriptorIDHash); - static unsigned GetHash(AtRuleDescriptorID id) { - return WTF::HashInt(static_cast(id)); - } - static bool Equal(AtRuleDescriptorID a, AtRuleDescriptorID b) { - return a == b; - } - static const bool safe_to_compare_to_empty_or_deleted = true; -}; - const int numAtRuleDescriptors = {{descriptors_count}}; -const char* GetDescriptorName(AtRuleDescriptorID); +const char* getValueName(AtRuleDescriptorID); AtRuleDescriptorID AsAtRuleDescriptorID(StringView string); @@ -40,11 +29,4 @@ AtRuleDescriptorID CSSPropertyIDAsAtRuleDescriptor(CSSPropertyID id); } // namespace blink -namespace WTF { -template <> -struct DefaultHash { - using Hash = blink::AtRuleDescriptorIDHash; -}; -} // namespace WTF - #endif // AtRuleDescriptors_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/properties/make_css_property_subclasses.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/properties/make_css_property_subclasses.py index 90a28c2bfa..0d816f7cdb 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/properties/make_css_property_subclasses.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/properties/make_css_property_subclasses.py @@ -25,6 +25,8 @@ def __init__(self, json5_file_paths): ('CSSPropertiesWriter requires 3 input json5 files, ' + 'got {}.'.format(len(json5_file_paths))) + self.template_cache = {} + # Map of property method name -> (return_type, parameters) self._property_methods = {} property_methods = json5_generator.Json5File.load_from_files( @@ -69,7 +71,8 @@ def __init__(self, json5_file_paths): def generate_property_h_builder(self, property_classname, property_): @template_expander.use_jinja( - 'core/css/properties/templates/CSSPropertySubclass.h.tmpl') + 'core/css/properties/templates/CSSPropertySubclass.h.tmpl', + template_cache=self.template_cache) def generate_property_h(): return { 'input_files': self._input_files, @@ -81,7 +84,8 @@ def generate_property_h(): def generate_property_cpp_builder(self, property_classname, property_): @template_expander.use_jinja( - 'core/css/properties/templates/CSSPropertySubclass.cpp.tmpl') + 'core/css/properties/templates/CSSPropertySubclass.cpp.tmpl', + template_cache=self.template_cache) def generate_property_cpp(): return { 'input_files': self._input_files, @@ -97,12 +101,6 @@ def calculate_apply_functions_to_declare(self, property_): if (property_name in ['Clip', 'ColumnCount', 'ColumnWidth', 'ZIndex']): property_['custom_apply'] = "auto" property_['custom_apply_args'] = {'auto_identity': 'CSSValueAuto'} - elif property_name == 'ColumnGap': - property_['custom_apply'] = "auto" - property_['custom_apply_args'] = { - 'auto_getter': 'HasNormalColumnGap', - 'auto_setter': 'SetHasNormalColumnGap', - 'auto_identity': 'CSSValueNormal'} elif (property_name in [ 'BorderImageOutset', 'BorderImageRepeat', 'BorderImageSlice', 'BorderImageWidth', 'WebkitMaskBoxImageOutset', 'WebkitMaskBoxImageRepeat', 'WebkitMaskBoxImageSlice', 'WebkitMaskBoxImageWidth']): diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/properties/templates/CSSProperty.h.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/properties/templates/CSSProperty.h.tmpl index 699a7b3f24..6165b10d7b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/properties/templates/CSSProperty.h.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/properties/templates/CSSProperty.h.tmpl @@ -95,10 +95,10 @@ class CSSProperty : public CSSUnresolvedProperty { bool allow_visited_style) const { return nullptr; } // FIXME: Resolve computed auto alignment in applyProperty/ComputedStyle and // remove this non-const Node parameter. - const CSSValue* CSSValueFromComputedStyle(const ComputedStyle&, - const LayoutObject*, - Node*, - bool allow_visited_style) const; + CORE_EXPORT const CSSValue* CSSValueFromComputedStyle(const ComputedStyle&, + const LayoutObject*, + Node*, + bool allow_visited_style) const; virtual const CSSProperty& ResolveDirectionAwareProperty( TextDirection, WritingMode) const { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/templates/CSSOMTypes.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/templates/CSSOMTypes.cpp.tmpl index a8b17a7e23..c524c372e8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/templates/CSSOMTypes.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/templates/CSSOMTypes.cpp.tmpl @@ -9,39 +9,78 @@ #include "core/css/cssom/CSSOMKeywords.h" #include "core/css/cssom/CSSKeywordValue.h" +#include "core/css/cssom/CSSNumericValue.h" #include "core/css/cssom/CSSStyleValue.h" #include "core/css/cssom/CSSUnsupportedStyleValue.h" #include "core/css/properties/CSSProperty.h" namespace blink { +namespace { + +bool IsCSSStyleValueLength(const CSSStyleValue& value) { + if (!value.IsNumericValue()) + return false; + return static_cast(value).Type(). + MatchesBaseType(CSSNumericValueType::BaseType::kLength); +} + +bool IsCSSStyleValueNumber(const CSSStyleValue& value) { + if (!value.IsNumericValue()) + return false; + return static_cast(value).Type(). + MatchesNumber(); +} + +bool IsCSSStyleValueTime(const CSSStyleValue& value) { + if (!value.IsNumericValue()) + return false; + return static_cast(value).Type(). + MatchesBaseType(CSSNumericValueType::BaseType::kTime); +} + +bool IsCSSStyleValuePercentage(const CSSStyleValue& value) { + if (!value.IsNumericValue()) + return false; + return static_cast(value).Type(). + MatchesPercentage(); +} + +bool IsCSSStyleValueImage(const CSSStyleValue& value) { + return value.GetType() == CSSStyleValue::kURLImageType; +} + +bool IsCSSStyleValueTransform(const CSSStyleValue& value) { + return value.GetType() == CSSStyleValue::kTransformType; +} + +bool IsCSSStyleValuePosition(const CSSStyleValue& value) { + return value.GetType() == CSSStyleValue::kPositionType; +} + +} + bool CSSOMTypes::PropertyCanTake(CSSPropertyID id, - const CSSStyleValue& styleValue) { - if (styleValue.GetType() == CSSStyleValue::kKeywordType) { + const CSSStyleValue& value) { + if (value.GetType() == CSSStyleValue::kKeywordType) { return CSSOMKeywords::ValidKeywordForProperty( - id, ToCSSKeywordValue(styleValue)); + id, ToCSSKeywordValue(value)); } - if (styleValue.ContainsPercent() && - !CSSProperty::Get(id).SupportsPercentage()) { - return false; + if (value.GetType() == CSSStyleValue::kUnknownType) { + return ToCSSUnsupportedStyleValue(value).GetProperty() == id; } - if (styleValue.GetType() == CSSStyleValue::kUnknownType) { - return ToCSSUnsupportedStyleValue(styleValue).GetProperty() == id; + if (value.GetType() == CSSStyleValue::kUnparsedType) { + return true; } - return CSSOMTypes::PropertyCanTakeType(id, styleValue.GetType()); -} - -bool CSSOMTypes::PropertyCanTakeType(CSSPropertyID id, - CSSStyleValue::StyleValueType type) { switch (id) { case CSSPropertyVariable: - return type == CSSStyleValue::kUnparsedType; + return value.GetType() == CSSStyleValue::kUnparsedType; {% for property in properties if property.typedom_types %} case {{property.property_id}}: return ( {% for type in property.typedom_types %} - {{ "|| " if not loop.first }}type == CSSStyleValue::k{{type}}Type + {{ "|| " if not loop.first }}IsCSSStyleValue{{type}}(value) {% endfor %} ); {% endfor %} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/templates/CSSValueKeywords.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/templates/CSSValueKeywords.cpp.tmpl index 3431dd3f24..6a27969d89 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/templates/CSSValueKeywords.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/core/css/templates/CSSValueKeywords.cpp.tmpl @@ -14,12 +14,6 @@ #pragma warning(disable : 4302 4311) #endif -#if defined(__clang__) -#pragma clang diagnostic push -// TODO(thakis): Remove once we use a gperf that no longer produces "register". -#pragma clang diagnostic ignored "-Wdeprecated-register" -#endif - namespace blink { static const char valueListStringPool[] = { {% for keyword in value_keywords %} @@ -53,10 +47,6 @@ struct Value; {% endfor %} %% -#if defined(__clang__) -#pragma clang diagnostic pop -#endif - const Value* FindValue(const char* str, unsigned int len) { return CSSValueKeywordsHash::findValueImpl(str, len); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/gperf.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/gperf.py index 1fd3ce2c89..770f867daf 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/gperf.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/gperf.py @@ -4,24 +4,18 @@ # Invokes gperf for the GN build. # Usage: gperf.py [--developer_dir PATH_TO_XCODE] gperf ... -# TODO(brettw) this can be removed once the run_executable rules have been -# checked in for the GN build. import argparse import os +import re import subprocess import sys import template_expander -def generate_gperf(gperf_path, gperf_input, extra_args=None): - # FIXME: If we could depend on Python 2.7, we would use +def generate_gperf(gperf_path, gperf_input, gperf_args): + # FIXME: If we could depend on Python 3.4, we would use # subprocess.check_output - gperf_args = [gperf_path, '--key-positions=*', '-P', '-n'] - gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. - gperf_args.append('-D') # Allow duplicate hashes -> More compact code. - if extra_args: - gperf_args.extend(extra_args) # If gperf isn't in the path we get an OSError. We don't want to use # the normal solution of shell=True (as this has to run on many @@ -29,11 +23,23 @@ def generate_gperf(gperf_path, gperf_input, extra_args=None): # CalledProcessError like subprocess would do when shell=True is set. try: gperf = subprocess.Popen( - gperf_args, + [gperf_path] + gperf_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) - return gperf.communicate(gperf_input)[0] + gperf_output = gperf.communicate(gperf_input)[0] + # Massage gperf output to be more palatable for modern compilers. + # TODO(thakis): Upstream these to gperf so we don't need massaging. + # `register` is deprecated in C++11 and removed in C++17, so remove + # it from gperf's output. + # https://savannah.gnu.org/bugs/index.php?53029 + gperf_output = re.sub(r'\bregister ', '', gperf_output) + # -Wimplicit-fallthrough needs an explicit fallthrough statement, + # so replace gperf's /*FALLTHROUGH*/ comment with the statement. + # https://savannah.gnu.org/bugs/index.php?53028 + gperf_output = gperf_output.replace('/*FALLTHROUGH*/', ' FALLTHROUGH;') + script = 'third_party/WebKit/Source/build/scripts/gperf.py' + return '// Generated by %s\n' % script + gperf_output except OSError: raise subprocess.CalledProcessError( 127, gperf_args, output='Command not found.') @@ -48,7 +54,12 @@ def generator_internal(*args, **kwargs): gperf_path = parameters['gperf_path'] gperf_input = template_expander.apply_template(template_path, parameters) - return generate_gperf(gperf_path, gperf_input, gperf_extra_args) + gperf_args = ['--key-positions=*', '-P', '-n'] + gperf_args.extend(['-m', '50']) # Pick best of 50 attempts. + gperf_args.append('-D') # Allow duplicate hashes -> More compact code. + if gperf_extra_args: + gperf_args.extend(gperf_extra_args) + return generate_gperf(gperf_path, gperf_input, gperf_args) generator_internal.func_name = generator.func_name return generator_internal return wrapper @@ -57,11 +68,24 @@ def generator_internal(*args, **kwargs): def main(): parser = argparse.ArgumentParser() parser.add_argument("--developer_dir", required=False) + parser.add_argument("--output-file") args, unknownargs = parser.parse_known_args() if args.developer_dir: os.environ['DEVELOPER_DIR'] = args.developer_dir - subprocess.check_call(unknownargs) + gperf_path, gperf_args = unknownargs[0], unknownargs[1:] + infile = None + for arg in gperf_args: + if os.path.isfile(arg): + assert infile is None, 'duplicate inputs? %s, %s' % (infile, arg) + infile = arg + assert infile is not None, 'no input found' + + # Since we're passing the input file on stdin, remove it from the args. + gperf_args.remove(infile) + + open(args.output_file, 'wb').write( + generate_gperf(gperf_path, open(infile).read(), gperf_args)) if __name__ == '__main__': main() diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_computed_style_base.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_computed_style_base.py index 65f6ea8192..0e0101941d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_computed_style_base.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_computed_style_base.py @@ -42,6 +42,7 @@ 'Vector', 'Vector', 'GridPosition', + 'GapLength', 'AtomicString', 'scoped_refptr', 'Persistent', diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_factory.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_factory.py index d7b1cd4c30..09256525ea 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_factory.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_factory.py @@ -41,7 +41,7 @@ class MakeElementFactoryWriter(MakeQualifiedNamesWriter): default_parameters = { 'JSInterfaceName': {}, 'Conditional': {}, - 'constructorNeedsCreatedByParser': {}, + 'constructorNeedsCreateElementFlags': {}, 'interfaceHeaderDir': {}, 'interfaceName': {}, 'noConstructor': {}, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_lookup_trie.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_lookup_trie.py index 965019118b..c391a5e774 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_lookup_trie.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_lookup_trie.py @@ -38,7 +38,7 @@ class ElementLookupTrieWriter(json5_generator.Writer): # FIXME: Inherit all these from somewhere. default_parameters = { 'JSInterfaceName': {}, - 'constructorNeedsCreatedByParser': {}, + 'constructorNeedsCreateElementFlags': {}, 'interfaceHeaderDir': {}, 'interfaceName': {}, 'noConstructor': {}, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_type_helpers.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_type_helpers.py index 591aae6296..9250605b1f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_type_helpers.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_element_type_helpers.py @@ -21,7 +21,7 @@ class MakeElementTypeHelpersWriter(json5_generator.Writer): 'Conditional': {}, 'ImplementedAs': {}, 'JSInterfaceName': {}, - 'constructorNeedsCreatedByParser': {}, + 'constructorNeedsCreateElementFlags': {}, 'interfaceHeaderDir': {}, 'interfaceName': {}, 'noConstructor': {}, @@ -73,7 +73,10 @@ def __init__(self, json5_file_path): for tag in tags: tag['interface'] = self._interface(tag) interface_counts[tag['interface']] += 1 - elements.add(tag['interface']) + tag['js_interface'] = tag['interface'] + if tag['JSInterfaceName']: + tag['js_interface'] = tag['JSInterfaceName'] + elements.add(tag['js_interface']) for tag in tags: tag['multipleTagNames'] = (interface_counts[tag['interface']] > 1 or tag['interface'] == self.fallback_interface) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_style_builder.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_style_builder.py index fe45731bbf..8ab966ffb7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_style_builder.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/make_style_builder.py @@ -54,7 +54,7 @@ def calculate_apply_functions_to_declare(property_): 'BackgroundAttachment', 'BackgroundBlendMode', 'BackgroundClip', 'BackgroundImage', 'BackgroundOrigin', 'BackgroundPositionX', 'BackgroundPositionY', 'BackgroundRepeatX', 'BackgroundRepeatY', 'BackgroundSize', 'BorderImageOutset', 'BorderImageRepeat', 'BorderImageSlice', 'BorderImageWidth', 'Clip', 'ColumnCount', - 'ColumnGap', 'ColumnWidth', 'MaskSourceType', 'WebkitMaskBoxImageOutset', 'WebkitMaskBoxImageRepeat', + 'ColumnWidth', 'MaskSourceType', 'WebkitMaskBoxImageOutset', 'WebkitMaskBoxImageRepeat', 'WebkitMaskBoxImageSlice', 'WebkitMaskBoxImageWidth', 'WebkitMaskClip', 'WebkitMaskComposite', 'WebkitMaskImage', 'WebkitMaskOrigin', 'WebkitMaskPositionX', 'WebkitMaskPositionY', 'WebkitMaskRepeatX', 'WebkitMaskRepeatY', 'WebkitMaskSize', 'ZIndex']): diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/template_expander.py b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/template_expander.py index e28eef6308..339e2ab37c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/template_expander.py +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/template_expander.py @@ -36,26 +36,37 @@ import jinja2 -def apply_template(template_path, params, filters=None, tests=None): - jinja_env = jinja2.Environment( - loader=jinja2.FileSystemLoader(_current_dir), - keep_trailing_newline=True, # newline-terminate generated files - lstrip_blocks=True, # so can indent control flow tags - trim_blocks=True) # so don't need {%- -%} everywhere - if filters: - jinja_env.filters.update(filters) - if tests: - jinja_env.tests.update(tests) - template = jinja_env.get_template(template_path) +def apply_template(template_path, params, filters=None, tests=None, template_cache=None): + template = None + + if filters is None and tests is None and template_cache is not None: + template = template_cache.get(template_path, None) + + if template is None: + jinja_env = jinja2.Environment( + loader=jinja2.FileSystemLoader(_current_dir), + keep_trailing_newline=True, # newline-terminate generated files + lstrip_blocks=True, # so can indent control flow tags + trim_blocks=True) # so don't need {%- -%} everywhere + if filters: + jinja_env.filters.update(filters) + if tests: + jinja_env.tests.update(tests) + + template = jinja_env.get_template(template_path) + if filters is None and tests is None and template_cache is not None: + template_cache[template_path] = template + params['template_file'] = template_path return template.render(params) -def use_jinja(template_path, filters=None, tests=None): +def use_jinja(template_path, filters=None, tests=None, template_cache=None): def real_decorator(generator): def generator_internal(*args, **kwargs): parameters = generator(*args, **kwargs) - return apply_template(template_path, parameters, filters=filters, tests=tests) + return apply_template(template_path, parameters, filters=filters, + tests=tests, template_cache=template_cache) generator_internal.func_name = generator.func_name return generator_internal return real_decorator diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/CSSPropertyNames.cpp.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/CSSPropertyNames.cpp.tmpl index c7f1c50e90..ea54cc73db 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/CSSPropertyNames.cpp.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/CSSPropertyNames.cpp.tmpl @@ -18,12 +18,6 @@ #pragma warning(disable : 4302 4311) #endif -#if defined(__clang__) -#pragma clang diagnostic push -// TODO(thakis): Remove once we use a gperf that no longer produces "register". -#pragma clang diagnostic ignored "-Wdeprecated-register" -#endif - namespace blink { %} %struct-type @@ -43,10 +37,6 @@ struct Property; {{property_to_enum_map}} %% -#if defined(__clang__) -#pragma clang diagnostic pop -#endif - const Property* FindProperty(const char* str, unsigned int len) { return {{class_name}}Hash::findPropertyImpl(str, len); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/InternalRuntimeFlags.h.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/InternalRuntimeFlags.h.tmpl index a441e5a330..199a6c7695 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/InternalRuntimeFlags.h.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/InternalRuntimeFlags.h.tmpl @@ -31,7 +31,11 @@ class InternalRuntimeFlags : public ScriptWrappable { {% for feature in standard_features %} bool {{feature.first_lowered_name}}Enabled() { + {% if feature.origin_trial_feature_name %} + return RuntimeEnabledFeatures::{{feature.name}}EnabledByRuntimeFlag(); + {% else %} return RuntimeEnabledFeatures::{{feature.name}}Enabled(); + {% endif %} } {% endfor %} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/RuntimeEnabledFeaturesTestHelpers.h.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/RuntimeEnabledFeaturesTestHelpers.h.tmpl index d66b642f64..3b56466179 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/RuntimeEnabledFeaturesTestHelpers.h.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/RuntimeEnabledFeaturesTestHelpers.h.tmpl @@ -31,7 +31,11 @@ class ScopedRuntimeEnabledFeatureForTest { {% for feature in features %} typedef ScopedRuntimeEnabledFeatureForTest< +{% if feature.origin_trial_feature_name %} + RuntimeEnabledFeatures::{{feature.name}}EnabledByRuntimeFlag, +{% else %} RuntimeEnabledFeatures::{{feature.name}}Enabled, +{% endif %} RuntimeEnabledFeatures::Set{{feature.name}}Enabled> Scoped{{feature.name}}ForTest; {% endfor %} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_factory.cc.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_factory.cc.tmpl index ebeac55723..1830cfd425 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_factory.cc.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_factory.cc.tmpl @@ -12,13 +12,6 @@ {% if fallback_interface %} #include "core/{{namespace|lower}}/{{fallback_interface_header}}" {% endif %} -{% if namespace == 'HTML' %} -#include "core/html/custom/CustomElement.h" -{% endif %} -#include "core/html/custom/V0CustomElement.h" -#include "core/html/custom/V0CustomElementRegistrationContext.h" -#include "core/dom/Document.h" -#include "core/frame/Settings.h" #include "platform/runtime_enabled_features.h" #include "platform/wtf/HashMap.h" @@ -26,7 +19,7 @@ namespace blink { typedef {{namespace}}Element* (*{{namespace}}ConstructorFunction)( Document&, - CreateElementFlags); + const CreateElementFlags); typedef HashMap {{namespace}}FunctionMap; @@ -35,7 +28,7 @@ static {{namespace}}FunctionMap* g_{{namespace}}_constructors = 0; {% for tag in tags|sort if not tag.noConstructor %} static {{namespace}}Element* {{namespace}}{{tag|symbol}}Constructor( Document& document, - CreateElementFlags flags) { + const CreateElementFlags flags) { {% if tag.runtimeEnabled %} if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) return {{fallback_interface}}::Create({{namespace}}Names::{{tag|symbol}}Tag, document); @@ -43,7 +36,7 @@ static {{namespace}}Element* {{namespace}}{{tag|symbol}}Constructor( return {{tag.interface}}::Create( {%- if tag.multipleTagNames %}{{namespace}}Names::{{tag|symbol}}Tag, {% endif -%} document - {%- if tag.constructorNeedsCreatedByParser %}, flags & kCreatedByParser{% endif -%} + {%- if tag.constructorNeedsCreateElementFlags %}, flags{% endif -%} ); } {% endfor %} @@ -67,38 +60,15 @@ static void create{{namespace}}FunctionMap() { g_{{namespace}}_constructors->Set(data[i].tag.LocalName(), data[i].func); } -{{namespace}}Element* {{namespace}}ElementFactory::create{{namespace}}Element( +{{namespace}}Element* {{namespace}}ElementFactory::Create( const AtomicString& localName, Document& document, - CreateElementFlags flags) { + const CreateElementFlags flags) { if (!g_{{namespace}}_constructors) create{{namespace}}FunctionMap(); if ({{namespace}}ConstructorFunction function = g_{{namespace}}_constructors->at(localName)) return function(document, flags); - - {% if namespace == 'HTML' %} - // createElement handles custom element creation itself in order to - // transmit exceptions. - // TODO(dominicc): When the HTML parser can pass an error - // reporting ExceptionState, and "v0" custom elements have been - // removed, consolidate custom element creation into one place. - if (flags != kCreatedByCreateElement && CustomElement::ShouldCreateCustomElement(localName)) { - QualifiedName tagName(g_null_atom, localName, HTMLNames::xhtmlNamespaceURI); - if (flags & kAsynchronousCustomElements) - return CustomElement::CreateCustomElementAsync(document, tagName); - return CustomElement::CreateCustomElementSync(document, tagName); - } - {% endif %} - - if (document.RegistrationContext() && - V0CustomElement::IsValidName(localName)) { - Element* element = document.RegistrationContext()->CreateCustomTagElement( - document, QualifiedName(g_null_atom, localName, {{namespace}}Names::{{namespace_prefix}}NamespaceURI)); - SECURITY_DCHECK(element->Is{{namespace}}Element()); - return To{{namespace}}Element(element); - } - - return {{fallback_interface}}::Create(QualifiedName(g_null_atom, localName, {{namespace}}Names::{{namespace_prefix}}NamespaceURI), document); + return nullptr; } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_factory.h.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_factory.h.tmpl index eceae0e60d..83e5859a5d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_factory.h.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_factory.h.tmpl @@ -6,22 +6,21 @@ #ifndef BLINK_CORE_{{namespace|upper}}_ELEMENT_FACTORY_H_ #define BLINK_CORE_{{namespace|upper}}_ELEMENT_FACTORY_H_ -#include "core/dom/Document.h" +#include "core/dom/CreateElementFlags.h" #include "platform/wtf/Forward.h" namespace blink { +class Document; class {{namespace}}Element; -{% if namespace == 'HTML' %} -class HTMLFormElement; -{% endif %} class {{namespace}}ElementFactory { public: - static {{namespace}}Element* create{{namespace}}Element( + // If |localName| is unknown, nullptr is returned. + static {{namespace}}Element* Create( const AtomicString& localName, Document&, - CreateElementFlags flags = kCreatedByParser); + const CreateElementFlags flags); }; } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_type_helpers.cc.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_type_helpers.cc.tmpl index da4b1ca9a3..ea3a34463f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_type_helpers.cc.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/element_type_helpers.cc.tmpl @@ -22,7 +22,7 @@ HTMLTypeMap CreateHTMLTypeMap() { HTMLElementType type; } kTags[] = { {% for tag in tags|sort %} - { "{{tag.name}}", HTMLElementType::k{{tag.interface}} }, + { "{{tag.name}}", HTMLElementType::k{{tag.js_interface}} }, {% endfor %} }; for (const auto& tag : kTags) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/origin_trials.cc.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/origin_trials.cc.tmpl index da09b455c9..e0b3c18557 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/origin_trials.cc.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/origin_trials.cc.tmpl @@ -20,7 +20,7 @@ const char OriginTrials::k{{feature.name}}TrialName[] = "{{feature.origin_trial_ {% if feature.origin_trial_feature_name %} bool OriginTrials::{{feature.first_lowered_name}}Enabled(const ExecutionContext* executionContext) { - if (RuntimeEnabledFeatures::{{feature.name}}Enabled()) + if (RuntimeEnabledFeatures::{{feature.name}}EnabledByRuntimeFlag()) return true; {% if feature.origin_trial_os %} #if diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/runtime_enabled_features.cc.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/runtime_enabled_features.cc.tmpl index e2dfc7e0b7..98a6209c89 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/runtime_enabled_features.cc.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/runtime_enabled_features.cc.tmpl @@ -12,7 +12,11 @@ namespace blink { RuntimeEnabledFeatures::Backup::Backup() : {% for feature in standard_features -%} +{% if feature.origin_trial_feature_name %} + {{feature.class_member_name}}(RuntimeEnabledFeatures::{{feature.name}}EnabledByRuntimeFlag()) +{% else %} {{feature.class_member_name}}(RuntimeEnabledFeatures::{{feature.name}}Enabled()) +{% endif %} {%- if not loop.last %}, {%+ endif -%} {% endfor %} {} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/runtime_enabled_features.h.tmpl b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/runtime_enabled_features.h.tmpl index 9e095daa4a..412a225f83 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/runtime_enabled_features.h.tmpl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/build/scripts/templates/runtime_enabled_features.h.tmpl @@ -38,11 +38,35 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures { static void SetFeatureEnabledFromString(const std::string& name, bool enabled); {% for feature in features %} + {% if not feature.origin_trial_feature_name %} {% if feature.custom %} static bool {{feature.name}}Enabled(); {% else %} static void Set{{feature.name}}Enabled(bool enabled) { is_{{feature.class_member_name}}enabled_ = enabled; } static bool {{feature.name}}Enabled() { return {{feature.enabled_condition}}; } + {% endif %} + + {% endif %} + {% endfor %} + + // Origin-trial-enabled features: + // + // These features are currently part of an origin trial (see + // https://www.chromium.org/blink/origin-trials). These methods can be used + // to test whether the feature is unconditionally enabled (for example, by + // starting the browser with the appropriate command-line flag). However, + // that is almost always the incorrect check. Most renderer code should + // be calling OriginTrials::Enabled() instead, to test if the + // feature is enabled in a given context. + + {% for feature in features %} + {% if feature.origin_trial_feature_name %} + {% if feature.custom %} + static bool {{feature.name}}EnabledByRuntimeFlag(); + {% else %} + static void Set{{feature.name}}Enabled(bool enabled) { is_{{feature.class_member_name}}enabled_ = enabled; } + static bool {{feature.name}}EnabledByRuntimeFlag() { return {{feature.enabled_condition}}; } + {% endif %} {% endif %} {% endfor %} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/config.gni b/lgpl/sources/chromium/src/third_party/WebKit/Source/config.gni index 73f25a10b7..c92adafad9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/config.gni +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/config.gni @@ -14,10 +14,23 @@ if (current_cpu == "arm") { } declare_args() { + # TODO: send a PSA out to tell people to switch to blink_symbol_level + # and remove this. # If true, doesn't compile debug symbols into webcore reducing the # size of the binary and increasing the speed of gdb. remove_webcore_debug_symbols = false + # How many symbols to include in the build of blink. This affects + # the performance of the build since the symbols are large and dealing with + # them is slow. + # 2 means regular build with symbols. + # 1 means minimal symbols, usually enough for backtraces only. Symbols with + # internal linkage (static functions or those in anonymous namespaces) may not + # appear when using this level. + # 0 means no symbols. + # -1 means auto-set according to debug/release and platform. + blink_symbol_level = -1 + # If true, defaults image interpolation to low quality. use_low_quality_image_interpolation = is_android @@ -63,6 +76,10 @@ if (use_default_render_theme) { feature_defines_list += [ "WTF_USE_DEFAULT_RENDER_THEME=1" ] } +assert( + blink_symbol_level == -1 || !remove_webcore_debug_symbols, + "blink_symbol_level and remove_webcore_debug_symbols cannot both be set.") + if (remove_webcore_debug_symbols) { if (is_win && symbol_level != 0) { # If we use no_symbols on Windows when symbol_level is not zero then no @@ -71,9 +88,18 @@ if (remove_webcore_debug_symbols) { # situation keeps the build times fast (roughly identical to no_symbols) # while still generating a PDB to keep ninja happy (and it gives us proper # call stacks). - remove_webcore_symbols_config = - [ "//build/config/compiler:minimal_symbols" ] + blink_symbol_level = 1 } else { - remove_webcore_symbols_config = [ "//build/config/compiler:no_symbols" ] + blink_symbol_level = 0 } } + +if (blink_symbol_level == 2) { + blink_symbols_config = [ "//build/config/compiler:symbols" ] +} else if (blink_symbol_level == 1) { + blink_symbols_config = [ "//build/config/compiler:minimal_symbols" ] +} else if (blink_symbol_level == 0) { + blink_symbols_config = [ "//build/config/compiler:no_symbols" ] +} else { + blink_symbols_config = [ "//build/config/compiler:default_symbols" ] +} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/BUILD.gn b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/BUILD.gn index d10cff4a0f..67afa8b0bc 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/BUILD.gn +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/BUILD.gn @@ -50,10 +50,8 @@ component("controller") { ] } - if (remove_webcore_debug_symbols) { - configs -= [ "//build/config/compiler:default_symbols" ] - configs += remove_webcore_symbols_config - } + configs -= [ "//build/config/compiler:default_symbols" ] + configs += blink_symbols_config } group("webkit_unit_tests_data") { @@ -75,6 +73,7 @@ test("webkit_unit_tests") { ] if (is_android) { + enable_multidex = true deps += [ "//base:base_java", "//content/public/android:content_java", diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/BlinkInitializer.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/BlinkInitializer.cpp index 914358d102..bcb85bad66 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/BlinkInitializer.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/BlinkInitializer.cpp @@ -121,14 +121,14 @@ void BlinkInitializer::RegisterInterfaces( service_manager::BinderRegistry& registry) { ModulesInitializer::RegisterInterfaces(registry); WebThread* main_thread = Platform::Current()->MainThread(); - // GetSingleThreadTaskRunner() uses GetWebTaskRunner() internally. + // GetSingleThreadTaskRunner() uses GetTaskRunner() internally. // crbug.com/781664 - if (!main_thread || !main_thread->GetWebTaskRunner()) + if (!main_thread || !main_thread->GetTaskRunner()) return; registry.AddInterface( ConvertToBaseCallback(CrossThreadBind(&OomInterventionImpl::Create)), - main_thread->GetSingleThreadTaskRunner()); + main_thread->GetTaskRunner()); } void BlinkInitializer::InitLocalFrame(LocalFrame& frame) const { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/DevToolsFrontendImpl.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/DevToolsFrontendImpl.cpp index edf31bd299..9aa2c5d446 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/DevToolsFrontendImpl.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/DevToolsFrontendImpl.cpp @@ -48,7 +48,6 @@ void DevToolsFrontendImpl::BindMojoRequest( if (!local_frame) return; local_frame->ProvideSupplement( - SupplementName(), new DevToolsFrontendImpl(*local_frame, std::move(request))); } @@ -56,14 +55,11 @@ void DevToolsFrontendImpl::BindMojoRequest( DevToolsFrontendImpl* DevToolsFrontendImpl::From(LocalFrame* local_frame) { if (!local_frame) return nullptr; - return static_cast( - local_frame->RequireSupplement(SupplementName())); + return local_frame->RequireSupplement(); } // static -const char* DevToolsFrontendImpl::SupplementName() { - return "DevToolsFrontendImpl"; -} +const char DevToolsFrontendImpl::kSupplementName[] = "DevToolsFrontendImpl"; DevToolsFrontendImpl::DevToolsFrontendImpl( LocalFrame& frame, @@ -131,7 +127,7 @@ void DevToolsFrontendImpl::ShowContextMenu(LocalFrame* target_frame, void DevToolsFrontendImpl::DestroyOnHostGone() { if (devtools_host_) devtools_host_->DisconnectClient(); - GetSupplementable()->RemoveSupplement(SupplementName()); + GetSupplementable()->RemoveSupplement(); } void DevToolsFrontendImpl::Trace(blink::Visitor* visitor) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/DevToolsFrontendImpl.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/DevToolsFrontendImpl.h index c14dcbbd8b..fe851eeb52 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/DevToolsFrontendImpl.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/DevToolsFrontendImpl.h @@ -55,6 +55,8 @@ class DevToolsFrontendImpl final USING_GARBAGE_COLLECTED_MIXIN(DevToolsFrontendImpl); public: + static const char kSupplementName[]; + static void BindMojoRequest(LocalFrame*, mojom::blink::DevToolsFrontendAssociatedRequest); static DevToolsFrontendImpl* From(LocalFrame*); @@ -66,7 +68,6 @@ class DevToolsFrontendImpl final private: DevToolsFrontendImpl(LocalFrame&, mojom::blink::DevToolsFrontendAssociatedRequest); - static const char* SupplementName(); void DestroyOnHostGone(); // mojom::blink::DevToolsFrontend implementation. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/OomInterventionImpl.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/OomInterventionImpl.cpp index 2e15341362..7df866d41e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/OomInterventionImpl.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/OomInterventionImpl.cpp @@ -47,7 +47,9 @@ void OomInterventionImpl::Create(mojom::blink::OomInterventionRequest request) { OomInterventionImpl::OomInterventionImpl( MemoryWorkloadCaculator workload_calculator) : workload_calculator_(std::move(workload_calculator)), - timer_(this, &OomInterventionImpl::Check) { + timer_(Platform::Current()->MainThread()->GetTaskRunner(), + this, + &OomInterventionImpl::Check) { DCHECK(workload_calculator_); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/OomInterventionImpl.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/OomInterventionImpl.h index a05bccfc71..8fd85d054c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/OomInterventionImpl.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/OomInterventionImpl.h @@ -41,7 +41,7 @@ class CONTROLLER_EXPORT OomInterventionImpl MemoryWorkloadCaculator workload_calculator_; mojom::blink::OomInterventionHostPtr host_; bool trigger_intervention_ = false; - Timer timer_; + TaskRunnerTimer timer_; std::unique_ptr pauser_; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/tests/RunAllTests.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/tests/RunAllTests.cpp index 5f65ec20f8..b634385cce 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/tests/RunAllTests.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/controller/tests/RunAllTests.cpp @@ -49,8 +49,7 @@ int runHelper(base::TestSuite* testSuite) { // Tickle EndOfTaskRunner which among other things will flush the queue // of error messages via V8Initializer::reportRejectedPromisesOnMainThread. - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - base::Bind(&base::DoNothing)); + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::DoNothing()); base::RunLoop().RunUntilIdle(); // Collect garbage (including threadspecific persistent handles) in order diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/BUILD.gn b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/BUILD.gn index 9281c8608c..837586fd89 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/BUILD.gn +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/BUILD.gn @@ -94,7 +94,6 @@ source_set("generated") { "//third_party/libwebp", "//third_party/libxml", "//third_party/libxslt", - "//third_party/sqlite", # FIXME: don't depend on bindings/modules http://crbug.com/358074 "//third_party/WebKit/Source/bindings/modules:bindings_modules_generated", @@ -108,7 +107,6 @@ source_set("generated") { source_set("prerequisites") { public_deps = [ - "//gpu/command_buffer/client:gles2_c_lib", "//services/network/public/cpp:cpp", "//services/service_manager/public/cpp", "//skia", @@ -125,7 +123,6 @@ source_set("prerequisites") { "//third_party/libxslt", "//third_party/ots", "//third_party/snappy", - "//third_party/sqlite", "//third_party/zlib", "//ui/gfx/geometry", "//url", @@ -222,7 +219,7 @@ component("core") { "//third_party/WebKit/Source/core/workers", "//third_party/WebKit/Source/core/xml", "//third_party/WebKit/Source/core/xmlhttprequest", - "//third_party/WebKit/common:blink_common", + "//third_party/WebKit/public/common", ] if (is_win && is_debug && is_component_build && current_cpu == "x64") { @@ -297,6 +294,8 @@ jumbo_source_set("testing") { "testing/RecordTest.h", "testing/SequenceTest.cpp", "testing/SequenceTest.h", + "testing/StaticSelection.cpp", + "testing/StaticSelection.h", "testing/TypeConversions.h", "testing/UnionTypesTest.cpp", "testing/UnionTypesTest.h", @@ -689,10 +688,8 @@ css_properties("make_core_generated_css_longhand_property_classes") { "$blink_core_output_dir/css/properties/longhands/GridAutoFlow.h", "$blink_core_output_dir/css/properties/longhands/GridAutoRows.h", "$blink_core_output_dir/css/properties/longhands/GridColumnEnd.h", - "$blink_core_output_dir/css/properties/longhands/GridColumnGap.h", "$blink_core_output_dir/css/properties/longhands/GridColumnStart.h", "$blink_core_output_dir/css/properties/longhands/GridRowEnd.h", - "$blink_core_output_dir/css/properties/longhands/GridRowGap.h", "$blink_core_output_dir/css/properties/longhands/GridRowStart.h", "$blink_core_output_dir/css/properties/longhands/GridTemplateAreas.h", "$blink_core_output_dir/css/properties/longhands/GridTemplateColumns.h", @@ -773,10 +770,12 @@ css_properties("make_core_generated_css_longhand_property_classes") { "$blink_core_output_dir/css/properties/longhands/Resize.h", "$blink_core_output_dir/css/properties/longhands/Right.h", "$blink_core_output_dir/css/properties/longhands/Rotate.h", + "$blink_core_output_dir/css/properties/longhands/RowGap.h", "$blink_core_output_dir/css/properties/longhands/Rx.h", "$blink_core_output_dir/css/properties/longhands/Ry.h", "$blink_core_output_dir/css/properties/longhands/Scale.h", "$blink_core_output_dir/css/properties/longhands/ScrollBehavior.h", + "$blink_core_output_dir/css/properties/longhands/ScrollCustomization.h", "$blink_core_output_dir/css/properties/longhands/ScrollMarginBlockEnd.h", "$blink_core_output_dir/css/properties/longhands/ScrollMarginBlockStart.h", "$blink_core_output_dir/css/properties/longhands/ScrollMarginBottom.h", @@ -1045,9 +1044,12 @@ css_properties("make_core_generated_css_shorthand_property_classes") { "$blink_core_output_dir/css/properties/shorthands/FlexFlow.h", "$blink_core_output_dir/css/properties/shorthands/Font.h", "$blink_core_output_dir/css/properties/shorthands/FontVariant.h", + "$blink_core_output_dir/css/properties/shorthands/Gap.h", "$blink_core_output_dir/css/properties/shorthands/Grid.h", "$blink_core_output_dir/css/properties/shorthands/GridArea.h", "$blink_core_output_dir/css/properties/shorthands/GridColumn.h", + "$blink_core_output_dir/css/properties/shorthands/GridColumnGap.h", + "$blink_core_output_dir/css/properties/shorthands/GridRowGap.h", "$blink_core_output_dir/css/properties/shorthands/GridGap.h", "$blink_core_output_dir/css/properties/shorthands/GridRow.h", "$blink_core_output_dir/css/properties/shorthands/GridTemplate.h", @@ -1100,6 +1102,7 @@ css_properties("make_core_generated_css_shorthand_property_classes") { css_properties("make_core_generated_css_property_names") { script = "../build/scripts/make_css_property_names.py" other_inputs = [ + "../build/scripts/gperf.py", "../build/scripts/templates/CSSPropertyNames.cpp.tmpl", "../build/scripts/templates/CSSPropertyNames.h.tmpl", ] @@ -1112,6 +1115,7 @@ css_properties("make_core_generated_css_property_names") { code_generator("make_core_generated_atrule_names") { script = "../build/scripts/core/css/parser/make_atrule_names.py" json_inputs = [ "css/parser/AtRuleNames.json5" ] + other_inputs = [ "../build/scripts/gperf.py" ] templates = [ "../build/scripts/core/css/parser/templates/AtRuleDescriptors.cpp.tmpl", "../build/scripts/core/css/parser/templates/AtRuleDescriptors.h.tmpl", @@ -1179,6 +1183,7 @@ code_generator("make_core_generated_css_value_keywords") { "css/CSSValueKeywords.json5", "css/SVGCSSValueKeywords.json5", ] + other_inputs = [ "../build/scripts/gperf.py" ] templates = [ "../build/scripts/core/css/templates/CSSValueKeywords.cpp.tmpl", "../build/scripts/core/css/templates/CSSValueKeywords.h.tmpl", @@ -1596,7 +1601,6 @@ target("jumbo_" + core_link_small_target_type, "core_generated") { "//third_party/libwebp", "//third_party/libxml", "//third_party/libxslt", - "//third_party/sqlite", # FIXME: don't depend on bindings/modules http://crbug.com/358074 "//third_party/WebKit/Source/bindings/modules:bindings_modules_generated", @@ -1677,6 +1681,7 @@ jumbo_source_set("unit_tests") { "css/CSSSelectorTest.cpp", "css/CSSSelectorWatchTest.cpp", "css/CSSStyleDeclarationTest.cpp", + "css/CSSStyleSheetTest.cpp", "css/CSSTestHelper.cpp", "css/CSSTestHelper.h", "css/CSSValueTestHelper.h", @@ -1694,14 +1699,14 @@ jumbo_source_set("unit_tests") { "css/StyleElementTest.cpp", "css/StyleEngineTest.cpp", "css/StyleSheetContentsTest.cpp", + "css/StyleSheetListTest.cpp", "css/cssom/CSSMathInvertTest.cpp", "css/cssom/CSSMathNegateTest.cpp", "css/cssom/CSSNumericValueTypeTest.cpp", "css/cssom/CSSResourceValueTest.cpp", "css/cssom/CSSStyleImageValueTest.cpp", "css/cssom/CSSUnitValueTest.cpp", - "css/cssom/CSSVariableReferenceValueTest.cpp", - "css/cssom/FilteredComputedStylePropertyMapTest.cpp", + "css/cssom/PrepopulatedComputedStylePropertyMapTest.cpp", "css/invalidation/InvalidationSetTest.cpp", "css/invalidation/StyleInvalidatorTest.cpp", "css/parser/CSSLazyParsingTest.cpp", @@ -1714,6 +1719,7 @@ jumbo_source_set("unit_tests") { "css/parser/MediaConditionTest.cpp", "css/parser/SizesAttributeParserTest.cpp", "css/parser/SizesCalcParserTest.cpp", + "css/properties/CSSParsingUtilsTest.cpp", "css/resolver/FontBuilderTest.cpp", "css/resolver/FontStyleResolverTest.cpp", "css/resolver/MatchResultTest.cpp", @@ -1801,8 +1807,6 @@ jumbo_source_set("unit_tests") { "fetch/ReadableStreamBytesConsumerTest.cpp", "fetch/RequestTest.cpp", "fetch/ResponseTest.cpp", - "fileapi/FileListTest.cpp", - "fileapi/FileTest.cpp", "frame/BrowserControlsTest.cpp", "frame/DOMTimerTest.cpp", "frame/DeferredLoadingTest.cpp", @@ -1814,10 +1818,12 @@ jumbo_source_set("unit_tests") { "frame/HistoryTest.cpp", "frame/LocalFrameTest.cpp", "frame/LocalFrameViewTest.cpp", - "frame/MHTMLTest.cpp", + "frame/MHTMLArchiveTest.cpp", + "frame/MHTMLLoadingTest.cpp", "frame/OriginsUsingFeaturesTest.cpp", "frame/PerformanceMonitorTest.cpp", "frame/RootFrameViewportTest.cpp", + "frame/RotationViewportAnchorTest.cpp", "frame/UseCounterTest.cpp", "frame/VisualViewportTest.cpp", "frame/csp/CSPDirectiveListTest.cpp", @@ -1897,6 +1903,7 @@ jumbo_source_set("unit_tests") { "input/ScrollSnapTest.cpp", "input/TouchActionTest.cpp", "input/TouchEventManagerTest.cpp", + "inspector/MainThreadDebuggerTest.cpp", "inspector/ProtocolParserTest.cpp", "intersection_observer/IntersectionObserverTest.cpp", "layout/CollapsedBorderValueTest.cpp", @@ -1911,6 +1918,7 @@ jumbo_source_set("unit_tests") { "layout/LayoutMultiColumnFlowThreadTest.cpp", "layout/LayoutObjectTest.cpp", "layout/LayoutProgressTest.cpp", + "layout/LayoutReplacedTest.cpp", "layout/LayoutTableCellTest.cpp", "layout/LayoutTableColTest.cpp", "layout/LayoutTableRowTest.cpp", @@ -1918,6 +1926,7 @@ jumbo_source_set("unit_tests") { "layout/LayoutTableTest.cpp", "layout/LayoutTestHelper.cpp", "layout/LayoutTestHelper.h", + "layout/LayoutTextControlTest.cpp", "layout/LayoutTextFragmentTest.cpp", "layout/LayoutTextTest.cpp", "layout/LayoutThemeTest.cpp", @@ -1933,6 +1942,7 @@ jumbo_source_set("unit_tests") { "layout/TextAutosizerTest.cpp", "layout/VisualRectMappingTest.cpp", "layout/api/SelectionStateTest.cpp", + "layout/custom/LayoutWorkletTest.cpp", "layout/line/InlineTextBoxTest.cpp", "layout/ng/NGInlineLayoutTest.cpp", "layout/ng/exclusions/ng_exclusion_space_test.cc", @@ -1942,12 +1952,14 @@ jumbo_source_set("unit_tests") { "layout/ng/geometry/ng_physical_offset_rect_test.cc", "layout/ng/geometry/ng_physical_offset_test.cc", "layout/ng/geometry/ng_physical_rect_test.cc", + "layout/ng/inline/ng_caret_rect_test.cc", "layout/ng/inline/ng_inline_fragment_traversal_test.cc", "layout/ng/inline/ng_inline_items_builder_test.cc", "layout/ng/inline/ng_inline_layout_algorithm_test.cc", "layout/ng/inline/ng_inline_node_test.cc", "layout/ng/inline/ng_line_breaker_test.cc", "layout/ng/inline/ng_offset_mapping_test.cc", + "layout/ng/inline/ng_physical_line_box_fragment_test.cc", "layout/ng/inline/ng_physical_text_fragment_test.cc", "layout/ng/ng_absolute_utils_test.cc", "layout/ng/ng_base_layout_algorithm_test.cc", @@ -1969,6 +1981,7 @@ jumbo_source_set("unit_tests") { "loader/BaseFetchContextTest.cpp", "loader/DocumentLoadTimingTest.cpp", "loader/DocumentLoaderTest.cpp", + "loader/DocumentThreadableLoaderTest.cpp", "loader/FrameFetchContextTest.cpp", "loader/IdlenessDetectorTest.cpp", "loader/InteractiveDetectorTest.cpp", @@ -1989,6 +2002,7 @@ jumbo_source_set("unit_tests") { "loader/resource/MockImageResourceObserver.cpp", "loader/resource/MockImageResourceObserver.h", "loader/resource/MultipartImageResourceParserTest.cpp", + "messaging/BlinkTransferableMessageStructTraitsTest.cpp", "origin_trials/OriginTrialContextTest.cpp", "page/AutoscrollControllerTest.cpp", "page/ChromeClientImplTest.cpp", @@ -2005,13 +2019,14 @@ jumbo_source_set("unit_tests") { "page/ViewportTest.cpp", "page/WindowFeaturesTest.cpp", "page/scrolling/RootScrollerTest.cpp", + "page/scrolling/ScrollIntoViewTest.cpp", "page/scrolling/ScrollMetricsTest.cpp", "page/scrolling/ScrollStateTest.cpp", "page/scrolling/ScrollingCoordinatorTest.cpp", - "page/scrolling/SmoothScrollTest.cpp", "page/scrolling/SnapCoordinatorTest.cpp", "paint/BlockPainterTest.cpp", "paint/BoxPaintInvalidatorTest.cpp", + "paint/CSSMaskPainterTest.cpp", "paint/FirstMeaningfulPaintDetectorTest.cpp", "paint/FragmentDataTest.cpp", "paint/HTMLCanvasPainterTest.cpp", @@ -2039,8 +2054,10 @@ jumbo_source_set("unit_tests") { "paint/ViewPainterTest.cpp", "paint/compositing/CompositedLayerMappingTest.cpp", "paint/compositing/CompositingInputsUpdaterTest.cpp", + "paint/compositing/CompositingLayerAssignerTest.cpp", "paint/compositing/CompositingReasonFinderTest.cpp", "paint/compositing/PaintLayerCompositorTest.cpp", + "paint/ng/ng_paint_fragment_test.cc", "paint/ng/ng_text_fragment_painter_test.cc", "policy/PolicyTest.cpp", "resize_observer/ResizeObserverTest.cpp", @@ -2071,8 +2088,6 @@ jumbo_source_set("unit_tests") { "testing/sim/SimCanvas.h", "testing/sim/SimCompositor.cpp", "testing/sim/SimCompositor.h", - "testing/sim/SimDisplayItemList.cpp", - "testing/sim/SimDisplayItemList.h", "testing/sim/SimNetwork.cpp", "testing/sim/SimNetwork.h", "testing/sim/SimPage.cpp", @@ -2086,11 +2101,11 @@ jumbo_source_set("unit_tests") { "testing/sim/SimWebViewClient.cpp", "testing/sim/SimWebViewClient.h", "timing/MemoryInfoTest.cpp", - "timing/PerformanceBaseTest.cpp", "timing/PerformanceNavigationTimingTest.cpp", "timing/PerformanceObserverTest.cpp", "timing/PerformanceResourceTimingTest.cpp", "timing/PerformanceTest.cpp", + "timing/WindowPerformanceTest.cpp", "url/URLSearchParamsTest.cpp", "workers/DedicatedWorkerTest.cpp", "workers/MainThreadWorkletTest.cpp", @@ -2114,6 +2129,7 @@ jumbo_source_set("unit_tests") { "//testing/gmock", "//testing/gtest", "//third_party/WebKit/Source/core/editing:unit_tests", + "//third_party/WebKit/Source/core/fileapi:unit_tests", ] # FIXME: Enable mojo unittests on Android after fixing data dependency. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/CoreExport.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/CoreExport.h index 0659a1fa06..8541dbe1ab 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/CoreExport.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/CoreExport.h @@ -2,48 +2,71 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// This header defines macros to export component's symbols. +// See "platform/PlatformExport.h" for details. + #ifndef CoreExport_h #define CoreExport_h #include "build/build_config.h" -#if defined(COMPONENT_BUILD) -#if defined(WIN32) +// +// BLINK_CORE_IMPLEMENTATION +// +#if !defined(BLINK_CORE_IMPLEMENTATION) +#define BLINK_CORE_IMPLEMENTATION 0 +#endif -#if defined(BLINK_CORE_IMPLEMENTATION) && BLINK_CORE_IMPLEMENTATION +// +// CORE_EXPORT +// +#if !defined(COMPONENT_BUILD) +#define CORE_EXPORT // No need of export +#else + +#if defined(COMPILER_MSVC) +#if BLINK_CORE_IMPLEMENTATION #define CORE_EXPORT __declspec(dllexport) #else #define CORE_EXPORT __declspec(dllimport) -#endif // defined(BLINK_CORE_IMPLEMENTATION) && BLINK_CORE_IMPLEMENTATION +#endif +#endif // defined(COMPILER_MSVC) -#else // defined(WIN32) -#if defined(BLINK_CORE_IMPLEMENTATION) && BLINK_CORE_IMPLEMENTATION +#if defined(COMPILER_GCC) +#if BLINK_CORE_IMPLEMENTATION #define CORE_EXPORT __attribute__((visibility("default"))) #else #define CORE_EXPORT #endif -#endif +#endif // defined(COMPILER_GCC) -#else // defined(COMPONENT_BUILD) -#define CORE_EXPORT -#endif +#endif // !defined(COMPONENT_BUILD) + +// +// CORE_TEMPLATE_CLASS_EXPORT +// CORE_EXTERN_TEMPLATE_EXPORT +// CORE_TEMPLATE_EXPORT +// +#if BLINK_CORE_IMPLEMENTATION -#if defined(BLINK_CORE_IMPLEMENTATION) && BLINK_CORE_IMPLEMENTATION #if defined(COMPILER_MSVC) #define CORE_TEMPLATE_CLASS_EXPORT #define CORE_EXTERN_TEMPLATE_EXPORT CORE_EXPORT #define CORE_TEMPLATE_EXPORT CORE_EXPORT -#elif defined(COMPILER_GCC) +#endif + +#if defined(COMPILER_GCC) #define CORE_TEMPLATE_CLASS_EXPORT CORE_EXPORT #define CORE_EXTERN_TEMPLATE_EXPORT CORE_EXPORT #define CORE_TEMPLATE_EXPORT -#else -#error Unknown compiler #endif -#else // !BLINK_CORE_IMPLEMENTATION + +#else // BLINK_CORE_IMPLEMENTATION + #define CORE_TEMPLATE_CLASS_EXPORT #define CORE_EXTERN_TEMPLATE_EXPORT CORE_EXPORT #define CORE_TEMPLATE_EXPORT -#endif + +#endif // BLINK_CORE_IMPLEMENTATION #endif // CoreExport_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/DEPS b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/DEPS index 0c72d14a51..44bc57844d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/DEPS +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/DEPS @@ -3,11 +3,10 @@ include_rules = [ "+base/memory/scoped_refptr.h", "+base/unguessable_token.h", "+bindings/core", - "-bindings/modules", "+build/mac", "+build/win", - "+common", "+core", + "-bindings/modules", "+gpu/config/gpu_feature_info.h", "-inspector/v8", "+inspector/v8/public", @@ -15,12 +14,16 @@ include_rules = [ "+mojo/public/cpp/bindings", "+mojo/public/cpp/system", "+platform", + "+public/common", + "+public/mojom", "+public/platform", "+public/web", "+services/metrics/public", - "+services/network/public/interfaces", + "+services/network/public/cpp/features.h", + "+services/network/public/mojom", "+services/resource_coordinator/public/cpp/resource_coordinator_features.h", "+services/service_manager/public", + "+skia/public/interfaces/bitmap_skbitmap_struct_traits.h", "+third_party/skia/include", "+ui/gfx/geometry", "-web", @@ -41,5 +44,10 @@ specific_include_rules = { ".*Test\.cpp" : [ "+core/frame/WebLocalFrameImpl.h", "+core/frame/WebRemoteFrameImpl.h", + "+gin" + ], + # Allow LocalFrame.cpp to use WebLocalFrameImpl.h + "LocalFrame.cpp" : [ + "+core/frame/WebLocalFrameImpl.h", ] } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/OWNERS b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/OWNERS index c890acc497..36889359bb 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/OWNERS +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/OWNERS @@ -28,6 +28,7 @@ fs@opera.com futhark@chromium.org haraken@chromium.org hayato@chromium.org +ikilpatrick@chromium.org inferno@chromium.org japhet@chromium.org jbroman@chromium.org @@ -41,9 +42,10 @@ kenneth.r.christiansen@intel.com kinuko@chromium.org kojii@chromium.org kouhei@chromium.org -meade@chromium.org mkwst@chromium.org mstensho@chromium.org +# nainar reviews changes in core/css,core/style +# and related code in core/dom and core/layout. nainar@chromium.org ojan@chromium.org # pdr reviews many svg and text autosizing patches. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Animation.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Animation.cpp index 3c5a2a93e8..10ab095837 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Animation.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Animation.cpp @@ -45,8 +45,7 @@ #include "core/inspector/InspectorTraceEvents.h" #include "core/paint/PaintLayer.h" #include "core/probe/CoreProbes.h" -#include "platform/WebTaskRunner.h" -#include "platform/animation/CompositorAnimationPlayer.h" +#include "platform/animation/CompositorAnimation.h" #include "platform/bindings/ScriptForbiddenScope.h" #include "platform/heap/Persistent.h" #include "platform/instrumentation/tracing/TraceEvent.h" @@ -144,16 +143,16 @@ Animation::Animation(ExecutionContext* execution_context, } Animation::~Animation() { - // Verify that m_compositorPlayer has been disposed of. - DCHECK(!compositor_player_); + // Verify that compositor_animation_ has been disposed of. + DCHECK(!compositor_animation_); } void Animation::Dispose() { - DestroyCompositorPlayer(); + DestroyCompositorAnimation(); // If the DocumentTimeline and its Animation objects are // finalized by the same GC, we have to eagerly clear out - // this Animation object's compositor player registration. - DCHECK(!compositor_player_); + // this Animation object's compositor animation registration. + DCHECK(!compositor_animation_); } double Animation::EffectEnd() const { @@ -327,7 +326,7 @@ bool Animation::PreCommit( CompositorAnimations::FailureCode failure_code = CheckCanStartAnimationOnCompositor(composited_element_ids); if (failure_code.Ok()) { - CreateCompositorPlayer(); + CreateCompositorAnimation(); StartAnimationOnCompositor(composited_element_ids); compositor_state_ = WTF::WrapUnique(new CompositorState(*this)); } else { @@ -447,7 +446,7 @@ bool Animation::Affects(const Element& element, const KeyframeEffectReadOnly* effect = ToKeyframeEffectReadOnly(content_.Get()); - return (effect->Target() == &element) && + return (effect->target() == &element) && effect->Affects(PropertyHandle(property)); } @@ -699,7 +698,7 @@ ScriptPromise Animation::ready(ScriptState* script_state) { } const AtomicString& Animation::InterfaceName() const { - return EventTargetNames::AnimationPlayer; + return EventTargetNames::Animation; } ExecutionContext* Animation::GetExecutionContext() const { @@ -846,7 +845,7 @@ Animation::CheckCanStartAnimationOnCompositorInternal( if (composited_element_ids.has_value()) { DCHECK(RuntimeEnabledFeatures::SlimmingPaintV2Enabled()); Element* target_element = - ToKeyframeEffectReadOnly(content_.Get())->Target(); + ToKeyframeEffectReadOnly(content_.Get())->target(); if (!target_element) { return CompositorAnimations::FailureCode::Actionable( "Animation is not attached to an element"); @@ -904,7 +903,7 @@ void Animation::StartAnimationOnCompositor( void Animation::SetCompositorPending(bool effect_changed) { // FIXME: KeyframeEffect could notify this directly? if (!HasActiveAnimationsOnCompositor()) { - DestroyCompositorPlayer(); + DestroyCompositorAnimation(); compositor_state_.reset(); } if (effect_changed && compositor_state_) { @@ -925,12 +924,15 @@ void Animation::CancelAnimationOnCompositor() { if (HasActiveAnimationsOnCompositor()) ToKeyframeEffectReadOnly(content_.Get())->CancelAnimationOnCompositor(); - DestroyCompositorPlayer(); + DestroyCompositorAnimation(); } void Animation::RestartAnimationOnCompositor() { - if (HasActiveAnimationsOnCompositor()) - ToKeyframeEffectReadOnly(content_.Get())->RestartAnimationOnCompositor(); + if (!HasActiveAnimationsOnCompositor()) + return; + + if (ToKeyframeEffectReadOnly(content_.Get())->CancelAnimationOnCompositor()) + SetCompositorPending(true); } void Animation::CancelIncompatibleAnimationsOnCompositor() { @@ -1001,6 +1003,22 @@ bool Animation::Update(TimingUpdateReason reason) { return !finished_ || std::isfinite(TimeToEffectChange()); } +void Animation::UpdateIfNecessary() { + if (Outdated()) + Update(kTimingUpdateOnDemand); + DCHECK(!Outdated()); +} + +void Animation::SpecifiedTimingChanged() { + SetOutdated(); + // FIXME: Needs to consider groups when added. + SetCompositorPending(true); +} + +bool Animation::IsEventDispatchAllowed() const { + return Paused() || HasStartTime(); +} + double Animation::TimeToEffectChange() { DCHECK(!outdated_); if (!HasStartTime() || held_) @@ -1043,48 +1061,48 @@ void Animation::EndUpdatingState() { state_is_being_updated_ = false; } -void Animation::CreateCompositorPlayer() { +void Animation::CreateCompositorAnimation() { if (Platform::Current()->IsThreadedAnimationEnabled() && - !compositor_player_) { + !compositor_animation_) { DCHECK(Platform::Current()->CompositorSupport()); - compositor_player_ = CompositorAnimationPlayerHolder::Create(this); - DCHECK(compositor_player_); + compositor_animation_ = CompositorAnimationHolder::Create(this); + DCHECK(compositor_animation_); AttachCompositorTimeline(); } AttachCompositedLayers(); } -void Animation::DestroyCompositorPlayer() { +void Animation::DestroyCompositorAnimation() { DetachCompositedLayers(); - if (compositor_player_) { + if (compositor_animation_) { DetachCompositorTimeline(); - compositor_player_->Detach(); - compositor_player_ = nullptr; + compositor_animation_->Detach(); + compositor_animation_ = nullptr; } } void Animation::AttachCompositorTimeline() { - if (compositor_player_) { + if (compositor_animation_) { CompositorAnimationTimeline* timeline = timeline_ ? timeline_->CompositorTimeline() : nullptr; if (timeline) - timeline->PlayerAttached(*this); + timeline->AnimationAttached(*this); } } void Animation::DetachCompositorTimeline() { - if (compositor_player_) { + if (compositor_animation_) { CompositorAnimationTimeline* timeline = timeline_ ? timeline_->CompositorTimeline() : nullptr; if (timeline) - timeline->PlayerDestroyed(*this); + timeline->AnimationDestroyed(*this); } } void Animation::AttachCompositedLayers() { - if (!compositor_player_) + if (!compositor_animation_) return; DCHECK(content_); @@ -1094,8 +1112,9 @@ void Animation::AttachCompositedLayers() { } void Animation::DetachCompositedLayers() { - if (compositor_player_ && compositor_player_->Player()->IsElementAttached()) - compositor_player_->Player()->DetachElement(); + if (compositor_animation_ && + compositor_animation_->GetAnimation()->IsElementAttached()) + compositor_animation_->GetAnimation()->DetachElement(); } void Animation::NotifyAnimationStarted(double monotonic_time, int group) { @@ -1242,7 +1261,7 @@ void Animation::InvalidateKeyframeEffect(const TreeScope& tree_scope) { if (!content_ || !content_->IsKeyframeEffectReadOnly()) return; - Element* target = ToKeyframeEffectReadOnly(content_.Get())->Target(); + Element* target = ToKeyframeEffectReadOnly(content_.Get())->target(); // TODO(alancutter): Remove dependency of this function on CSSAnimations. // This function makes the incorrect assumption that the animation uses @@ -1292,35 +1311,35 @@ void Animation::Trace(blink::Visitor* visitor) { visitor->Trace(pending_cancelled_event_); visitor->Trace(finished_promise_); visitor->Trace(ready_promise_); - visitor->Trace(compositor_player_); + visitor->Trace(compositor_animation_); EventTargetWithInlineData::Trace(visitor); ContextLifecycleObserver::Trace(visitor); } -Animation::CompositorAnimationPlayerHolder* -Animation::CompositorAnimationPlayerHolder::Create(Animation* animation) { - return new CompositorAnimationPlayerHolder(animation); +Animation::CompositorAnimationHolder* +Animation::CompositorAnimationHolder::Create(Animation* animation) { + return new CompositorAnimationHolder(animation); } -Animation::CompositorAnimationPlayerHolder::CompositorAnimationPlayerHolder( +Animation::CompositorAnimationHolder::CompositorAnimationHolder( Animation* animation) : animation_(animation) { - compositor_player_ = CompositorAnimationPlayer::Create(); - compositor_player_->SetAnimationDelegate(animation_); + compositor_animation_ = CompositorAnimation::Create(); + compositor_animation_->SetAnimationDelegate(animation_); } -void Animation::CompositorAnimationPlayerHolder::Dispose() { +void Animation::CompositorAnimationHolder::Dispose() { if (!animation_) return; animation_->Dispose(); DCHECK(!animation_); - DCHECK(!compositor_player_); + DCHECK(!compositor_animation_); } -void Animation::CompositorAnimationPlayerHolder::Detach() { - DCHECK(compositor_player_); - compositor_player_->SetAnimationDelegate(nullptr); +void Animation::CompositorAnimationHolder::Detach() { + DCHECK(compositor_animation_); + compositor_animation_->SetAnimationDelegate(nullptr); animation_ = nullptr; - compositor_player_.reset(); + compositor_animation_.reset(); } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Animation.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Animation.h index 99bdea9721..02a8091975 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Animation.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Animation.h @@ -41,20 +41,21 @@ #include "bindings/core/v8/ScriptPromiseProperty.h" #include "core/CSSPropertyNames.h" #include "core/CoreExport.h" +#include "core/animation/AnimationEffectOwner.h" #include "core/animation/AnimationEffectReadOnly.h" #include "core/animation/CompositorAnimations.h" #include "core/animation/DocumentTimeline.h" #include "core/dom/ContextLifecycleObserver.h" #include "core/dom/DOMException.h" #include "core/dom/events/EventTarget.h" +#include "platform/animation/CompositorAnimationClient.h" #include "platform/animation/CompositorAnimationDelegate.h" -#include "platform/animation/CompositorAnimationPlayerClient.h" #include "platform/graphics/CompositorElementId.h" #include "platform/heap/Handle.h" namespace blink { -class CompositorAnimationPlayer; +class CompositorAnimation; class Element; class ExceptionState; class TreeScope; @@ -63,7 +64,8 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData, public ActiveScriptWrappable, public ContextLifecycleObserver, public CompositorAnimationDelegate, - public CompositorAnimationPlayerClient { + public CompositorAnimationClient, + public AnimationEffectOwner { DEFINE_WRAPPERTYPEINFO(); USING_GARBAGE_COLLECTED_MIXIN(Animation); @@ -94,6 +96,12 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData, // Returns whether the animation is finished. bool Update(TimingUpdateReason); + // AnimationEffectOwner: + void UpdateIfNecessary() override; + void SpecifiedTimingChanged() override; + bool IsEventDispatchAllowed() const override; + Animation* GetAnimation() override { return this; } + // timeToEffectChange returns: // infinity - if this animation is no longer in effect // 0 - if this animation requires an update on the next frame @@ -184,9 +192,10 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData, void SetCompositorPending(bool effect_changed = false); void NotifyCompositorStartTime(double timeline_time); void NotifyStartTime(double timeline_time); - // CompositorAnimationPlayerClient implementation. - CompositorAnimationPlayer* CompositorPlayer() const override { - return compositor_player_ ? compositor_player_->Player() : nullptr; + // CompositorAnimationClient implementation. + CompositorAnimation* GetCompositorAnimation() const override { + return compositor_animation_ ? compositor_animation_->GetAnimation() + : nullptr; } bool Affects(const Element&, const CSSProperty&) const; @@ -206,7 +215,7 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData, return animation1->SequenceNumber() < animation2->SequenceNumber(); } - bool EffectSuppressed() const { return effect_suppressed_; } + bool EffectSuppressed() const override { return effect_suppressed_; } void SetEffectSuppressed(bool); void InvalidateKeyframeEffect(const TreeScope&); @@ -243,8 +252,8 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData, CompositorAnimations::FailureCode CheckCanStartAnimationOnCompositorInternal( const Optional&) const; - void CreateCompositorPlayer(); - void DestroyCompositorPlayer(); + void CreateCompositorAnimation(); + void DestroyCompositorAnimation(); void AttachCompositorTimeline(); void DetachCompositorTimeline(); void AttachCompositedLayers(); @@ -335,30 +344,30 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData, CompositorPendingChange compositor_pending_change_; }; - // CompositorAnimationPlayer objects need to eagerly sever - // their connection to their Animation delegate; use a separate - // 'holder' on-heap object to accomplish that. - class CompositorAnimationPlayerHolder - : public GarbageCollectedFinalized { - USING_PRE_FINALIZER(CompositorAnimationPlayerHolder, Dispose); + // CompositorAnimation objects need to eagerly sever their connection to their + // Animation delegate; use a separate 'holder' on-heap object to accomplish + // that. + class CompositorAnimationHolder + : public GarbageCollectedFinalized { + USING_PRE_FINALIZER(CompositorAnimationHolder, Dispose); public: - static CompositorAnimationPlayerHolder* Create(Animation*); + static CompositorAnimationHolder* Create(Animation*); void Detach(); void Trace(blink::Visitor* visitor) { visitor->Trace(animation_); } - CompositorAnimationPlayer* Player() const { - return compositor_player_.get(); + CompositorAnimation* GetAnimation() const { + return compositor_animation_.get(); } private: - explicit CompositorAnimationPlayerHolder(Animation*); + explicit CompositorAnimationHolder(Animation*); void Dispose(); - std::unique_ptr compositor_player_; + std::unique_ptr compositor_animation_; Member animation_; }; @@ -369,7 +378,7 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData, bool compositor_pending_; int compositor_group_; - Member compositor_player_; + Member compositor_animation_; bool current_time_pending_; bool state_is_being_updated_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectOwner.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectOwner.h new file mode 100644 index 0000000000..d62b83d83c --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectOwner.h @@ -0,0 +1,58 @@ +// Copyright 2018 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 AnimationEffectOwner_h +#define AnimationEffectOwner_h + +#include "platform/heap/GarbageCollected.h" + +namespace blink { + +class Animation; + +// This interface is used by AnimationEffect to interact with its owning +// animation. +class AnimationEffectOwner : public GarbageCollectedMixin { + public: + AnimationEffectOwner() = default; + + // Returns the owning animation's sequence number. It is used by the effect to + // determine its ordering compared to other effects. + virtual unsigned SequenceNumber() const = 0; + + // Returns true if the owning animation is playing. It is eventually used by + // EffectStack to determine if a property is actively being animated. + virtual bool Playing() const = 0; + + // Returns true if the owning animation allows events to be dispatched. This + // is used by the effect to determine if should dispatch animation events + // (e.g. start, end, iteration) when its phase and timing changes. + virtual bool IsEventDispatchAllowed() const = 0; + + // Returns true if the effect is supressed. Used to determine if effect needs + // to be updated or not. + virtual bool EffectSuppressed() const = 0; + + // Notifies the owning animation that the effect's specified timing has + // changed. This means that the owning animation may need to update its play + // state and current time. + // For more info on specified timing see: core/animation/Timing.h + virtual void SpecifiedTimingChanged() = 0; + + virtual void UpdateIfNecessary() = 0; + + // TODO(majidvp): Remove this. Exposing the animation instance here is not + // ideal as it punches a hole in our abstraction. This is currently necessary + // as CompositorAnimations and EffectStack need to access the animation + // instance but we should try to replace these usage with more appropriate + // patterns and remove this. http://crbug.com/812410 + virtual Animation* GetAnimation() = 0; + + protected: + virtual ~AnimationEffectOwner() = default; +}; + +} // namespace blink + +#endif // AnimationEffectOwner_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnly.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnly.cpp index b96d85c0ad..14bfa0e0a0 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnly.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnly.cpp @@ -52,7 +52,7 @@ Timing::FillMode ResolvedFillMode(Timing::FillMode fill_mode, AnimationEffectReadOnly::AnimationEffectReadOnly(const Timing& timing, EventDelegate* event_delegate) - : animation_(nullptr), + : owner_(nullptr), timing_(timing), event_delegate_(event_delegate), calculated_(), @@ -89,9 +89,8 @@ void AnimationEffectReadOnly::UpdateSpecifiedTiming(const Timing& timing) { // FIXME: Test whether the timing is actually different? timing_ = timing; Invalidate(); - if (animation_) - animation_->SetOutdated(); - SpecifiedTimingChanged(); + if (owner_) + owner_->SpecifiedTimingChanged(); } void AnimationEffectReadOnly::getComputedTiming( @@ -102,7 +101,7 @@ void AnimationEffectReadOnly::getComputedTiming( if (EnsureCalculated().is_in_effect) { computed_timing.setLocalTime(EnsureCalculated().local_time * 1000); - computed_timing.setProgress(EnsureCalculated().progress); + computed_timing.setProgress(EnsureCalculated().progress.value()); computed_timing.setCurrentIteration(EnsureCalculated().current_iteration); } else { computed_timing.setLocalTimeToNull(); @@ -140,7 +139,7 @@ void AnimationEffectReadOnly::UpdateInheritedTime( needs_update_ || (last_update_time_ != inherited_time && !(IsNull(last_update_time_) && IsNull(inherited_time))) || - (GetAnimation() && GetAnimation()->EffectSuppressed()); + (owner_ && owner_->EffectSuppressed()); needs_update_ = false; last_update_time_ = inherited_time; @@ -160,7 +159,7 @@ void AnimationEffectReadOnly::UpdateInheritedTime( local_time, kParentPhase, current_phase, timing_); double current_iteration; - double progress; + WTF::Optional progress; if (const double iteration_duration = this->IterationDuration()) { const double start_offset = MultiplyZeroAlwaysGivesZero( timing_.iteration_start, iteration_duration); @@ -173,7 +172,7 @@ void AnimationEffectReadOnly::UpdateInheritedTime( current_iteration = CalculateCurrentIteration( iteration_duration, iteration_time, scaled_active_time, timing_); - const double transformed_time = CalculateTransformedTime( + const WTF::Optional transformed_time = CalculateTransformedTime( current_iteration, iteration_duration, iteration_time, timing_); // The infinite iterationDuration case here is a workaround because @@ -182,8 +181,8 @@ void AnimationEffectReadOnly::UpdateInheritedTime( // https://github.com/w3c/web-animations/issues/142 if (!std::isfinite(iteration_duration)) progress = fmod(timing_.iteration_start, 1.0); - else - progress = transformed_time / iteration_duration; + else if (transformed_time) + progress = transformed_time.value() / iteration_duration; if (!IsNull(iteration_time)) { time_to_next_iteration = (iteration_duration - iteration_time) / @@ -238,10 +237,10 @@ void AnimationEffectReadOnly::UpdateInheritedTime( // Test for events even if timing didn't need an update as the animation may // have gained a start time. - // FIXME: Refactor so that we can DCHECK(m_animation) here, this is currently + // FIXME: Refactor so that we can DCHECK(owner_) here, this is currently // required to be nullable for testing. if (reason == kTimingUpdateForAnimationFrame && - (!animation_ || animation_->HasStartTime() || animation_->Paused())) { + (!owner_ || owner_->IsEventDispatchAllowed())) { if (event_delegate_) event_delegate_->OnEventCondition(*this); } @@ -258,11 +257,10 @@ void AnimationEffectReadOnly::UpdateInheritedTime( const AnimationEffectReadOnly::CalculatedTiming& AnimationEffectReadOnly::EnsureCalculated() const { - if (!animation_) + if (!owner_) return calculated_; - if (animation_->Outdated()) - animation_->Update(kTimingUpdateOnDemand); - DCHECK(!animation_->Outdated()); + + owner_->UpdateIfNecessary(); return calculated_; } @@ -270,8 +268,15 @@ AnimationEffectTimingReadOnly* AnimationEffectReadOnly::timing() { return AnimationEffectTimingReadOnly::Create(this); } +Animation* AnimationEffectReadOnly::GetAnimation() { + return owner_ ? owner_->GetAnimation() : nullptr; +} +const Animation* AnimationEffectReadOnly::GetAnimation() const { + return owner_ ? owner_->GetAnimation() : nullptr; +} + void AnimationEffectReadOnly::Trace(blink::Visitor* visitor) { - visitor->Trace(animation_); + visitor->Trace(owner_); visitor->Trace(event_delegate_); ScriptWrappable::Trace(visitor); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnly.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnly.h index 8f6066f31e..8690e3c33e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnly.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnly.h @@ -35,10 +35,12 @@ #include "core/animation/Timing.h" #include "platform/bindings/ScriptWrappable.h" #include "platform/heap/Handle.h" +#include "platform/wtf/Optional.h" namespace blink { class Animation; +class AnimationEffectOwner; class AnimationEffectReadOnly; class AnimationEffectTimingReadOnly; class ComputedTimingProperties; @@ -60,7 +62,14 @@ static inline double NullValue() { // http://w3c.github.io/web-animations/#animation-effect class CORE_EXPORT AnimationEffectReadOnly : public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); - friend class Animation; // Calls attach/detach, updateInheritedTime. + // Calls Attach/Detach, GetAnimation, UpdateInheritedTime. + friend class Animation; + + // Calls GetAnimation(). + // TODO(majidvp): Remove this. EffectStack should not need to access animation + // directly. + friend class EffectStack; + public: // Note that logic in CSSAnimations depends on the order of these values. enum Phase { @@ -91,7 +100,7 @@ class CORE_EXPORT AnimationEffectReadOnly : public ScriptWrappable { double CurrentIteration() const { return EnsureCalculated().current_iteration; } - double Progress() const { return EnsureCalculated().progress; } + WTF::Optional Progress() const { return EnsureCalculated().progress; } double TimeToForwardsEffectChange() const { return EnsureCalculated().time_to_forwards_effect_change; } @@ -106,8 +115,6 @@ class CORE_EXPORT AnimationEffectReadOnly : public ScriptWrappable { SpecifiedTiming().end_delay; } - const Animation* GetAnimation() const { return animation_; } - Animation* GetAnimation() { return animation_; } const Timing& SpecifiedTiming() const { return timing_; } virtual AnimationEffectTimingReadOnly* timing(); void UpdateSpecifiedTiming(const Timing&); @@ -116,6 +123,8 @@ class CORE_EXPORT AnimationEffectReadOnly : public ScriptWrappable { void getComputedTiming(ComputedTimingProperties&); ComputedTimingProperties getComputedTiming(); + const Animation* GetAnimationForTesting() const { return GetAnimation(); } + virtual void Trace(blink::Visitor*); protected: @@ -131,11 +140,11 @@ class CORE_EXPORT AnimationEffectReadOnly : public ScriptWrappable { } void ClearEventDelegate() { event_delegate_ = nullptr; } - virtual void Attach(Animation* animation) { animation_ = animation; } + virtual void Attach(AnimationEffectOwner* owner) { owner_ = owner; } virtual void Detach() { - DCHECK(animation_); - animation_ = nullptr; + DCHECK(owner_); + owner_ = nullptr; } double RepeatedDuration() const; @@ -146,9 +155,11 @@ class CORE_EXPORT AnimationEffectReadOnly : public ScriptWrappable { bool forwards, double local_time, double time_to_next_iteration) const = 0; - virtual void SpecifiedTimingChanged() {} - Member animation_; + const Animation* GetAnimation() const; + Animation* GetAnimation(); + + Member owner_; Timing timing_; Member event_delegate_; @@ -156,7 +167,7 @@ class CORE_EXPORT AnimationEffectReadOnly : public ScriptWrappable { DISALLOW_NEW(); Phase phase; double current_iteration; - double progress; + WTF::Optional progress; bool is_current; bool is_in_effect; bool is_in_play; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnlyTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnlyTest.cpp index 0d037a6ecb..fb7c60cae4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnlyTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationEffectReadOnlyTest.cpp @@ -178,7 +178,7 @@ TEST(AnimationAnimationEffectReadOnlyTest, FillForwards) { TestAnimationEffectReadOnly::Create(timing); animation_node->UpdateInheritedTime(-1); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); animation_node->UpdateInheritedTime(2); EXPECT_EQ(1, animation_node->Progress()); @@ -195,7 +195,7 @@ TEST(AnimationAnimationEffectReadOnlyTest, FillBackwards) { EXPECT_EQ(0, animation_node->Progress()); animation_node->UpdateInheritedTime(2); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); } TEST(AnimationAnimationEffectReadOnlyTest, FillBoth) { @@ -221,7 +221,7 @@ TEST(AnimationAnimationEffectReadOnlyTest, StartDelay) { TestAnimationEffectReadOnly::Create(timing); animation_node->UpdateInheritedTime(0); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); animation_node->UpdateInheritedTime(0.5); EXPECT_EQ(0, animation_node->Progress()); @@ -241,7 +241,7 @@ TEST(AnimationAnimationEffectReadOnlyTest, ZeroIteration) { animation_node->UpdateInheritedTime(-1); EXPECT_EQ(0, animation_node->ActiveDurationInternal()); EXPECT_TRUE(IsNull(animation_node->CurrentIteration())); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); animation_node->UpdateInheritedTime(0); EXPECT_EQ(0, animation_node->ActiveDurationInternal()); @@ -259,7 +259,7 @@ TEST(AnimationAnimationEffectReadOnlyTest, InfiniteIteration) { animation_node->UpdateInheritedTime(-1); EXPECT_TRUE(IsNull(animation_node->CurrentIteration())); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); EXPECT_EQ(std::numeric_limits::infinity(), animation_node->ActiveDurationInternal()); @@ -308,15 +308,15 @@ TEST(AnimationAnimationEffectReadOnlyTest, IterationStart) { animation_node->UpdateInheritedTime(-1); EXPECT_EQ(1, animation_node->CurrentIteration()); - EXPECT_NEAR(0.2, animation_node->Progress(), 0.000000000000001); + EXPECT_NEAR(0.2, animation_node->Progress().value(), 0.000000000000001); animation_node->UpdateInheritedTime(0); EXPECT_EQ(1, animation_node->CurrentIteration()); - EXPECT_NEAR(0.2, animation_node->Progress(), 0.000000000000001); + EXPECT_NEAR(0.2, animation_node->Progress().value(), 0.000000000000001); animation_node->UpdateInheritedTime(10); EXPECT_EQ(3, animation_node->CurrentIteration()); - EXPECT_NEAR(0.4, animation_node->Progress(), 0.000000000000001); + EXPECT_NEAR(0.4, animation_node->Progress().value(), 0.000000000000001); } TEST(AnimationAnimationEffectReadOnlyTest, IterationAlternate) { @@ -394,7 +394,7 @@ TEST(AnimationAnimationEffectReadOnlyTest, ZeroDurationFillForwards) { TestAnimationEffectReadOnly::Create(timing); animation_node->UpdateInheritedTime(-1); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); animation_node->UpdateInheritedTime(0); EXPECT_EQ(1, animation_node->Progress()); @@ -413,10 +413,10 @@ TEST(AnimationAnimationEffectReadOnlyTest, ZeroDurationFillBackwards) { EXPECT_EQ(0, animation_node->Progress()); animation_node->UpdateInheritedTime(0); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); animation_node->UpdateInheritedTime(1); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); } TEST(AnimationAnimationEffectReadOnlyTest, ZeroDurationFillBoth) { @@ -443,7 +443,7 @@ TEST(AnimationAnimationEffectReadOnlyTest, ZeroDurationStartDelay) { TestAnimationEffectReadOnly::Create(timing); animation_node->UpdateInheritedTime(0); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); animation_node->UpdateInheritedTime(0.5); EXPECT_EQ(1, animation_node->Progress()); @@ -465,10 +465,10 @@ TEST(AnimationAnimationEffectReadOnlyTest, ZeroDurationIterationStartAndCount) { EXPECT_EQ(0.1, animation_node->Progress()); animation_node->UpdateInheritedTime(0.3); - EXPECT_DOUBLE_EQ(0.3, animation_node->Progress()); + EXPECT_DOUBLE_EQ(0.3, animation_node->Progress().value()); animation_node->UpdateInheritedTime(1); - EXPECT_DOUBLE_EQ(0.3, animation_node->Progress()); + EXPECT_DOUBLE_EQ(0.3, animation_node->Progress().value()); } // FIXME: Needs specification work. @@ -482,7 +482,7 @@ TEST(AnimationAnimationEffectReadOnlyTest, ZeroDurationInfiniteIteration) { animation_node->UpdateInheritedTime(-1); EXPECT_EQ(0, animation_node->ActiveDurationInternal()); EXPECT_TRUE(IsNull(animation_node->CurrentIteration())); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); animation_node->UpdateInheritedTime(0); EXPECT_EQ(0, animation_node->ActiveDurationInternal()); @@ -500,7 +500,7 @@ TEST(AnimationAnimationEffectReadOnlyTest, ZeroDurationIteration) { animation_node->UpdateInheritedTime(-1); EXPECT_TRUE(IsNull(animation_node->CurrentIteration())); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); animation_node->UpdateInheritedTime(0); EXPECT_EQ(1, animation_node->CurrentIteration()); @@ -521,15 +521,15 @@ TEST(AnimationAnimationEffectReadOnlyTest, ZeroDurationIterationStart) { animation_node->UpdateInheritedTime(-1); EXPECT_EQ(1, animation_node->CurrentIteration()); - EXPECT_NEAR(0.2, animation_node->Progress(), 0.000000000000001); + EXPECT_NEAR(0.2, animation_node->Progress().value(), 0.000000000000001); animation_node->UpdateInheritedTime(0); EXPECT_EQ(3, animation_node->CurrentIteration()); - EXPECT_NEAR(0.4, animation_node->Progress(), 0.000000000000001); + EXPECT_NEAR(0.4, animation_node->Progress().value(), 0.000000000000001); animation_node->UpdateInheritedTime(10); EXPECT_EQ(3, animation_node->CurrentIteration()); - EXPECT_NEAR(0.4, animation_node->Progress(), 0.000000000000001); + EXPECT_NEAR(0.4, animation_node->Progress().value(), 0.000000000000001); } TEST(AnimationAnimationEffectReadOnlyTest, ZeroDurationIterationAlternate) { @@ -542,7 +542,7 @@ TEST(AnimationAnimationEffectReadOnlyTest, ZeroDurationIterationAlternate) { animation_node->UpdateInheritedTime(-1); EXPECT_TRUE(IsNull(animation_node->CurrentIteration())); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); animation_node->UpdateInheritedTime(0); EXPECT_EQ(1, animation_node->CurrentIteration()); @@ -564,7 +564,7 @@ TEST(AnimationAnimationEffectReadOnlyTest, animation_node->UpdateInheritedTime(-1); EXPECT_TRUE(IsNull(animation_node->CurrentIteration())); - EXPECT_TRUE(IsNull(animation_node->Progress())); + EXPECT_FALSE(animation_node->Progress()); animation_node->UpdateInheritedTime(0); EXPECT_EQ(1, animation_node->CurrentIteration()); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp index 7774e5cfb5..b99cfed8f1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationInputHelpers.cpp @@ -83,9 +83,9 @@ CSSPropertyID AnimationInputHelpers::KeyframeAttributeToCSSProperty( CSSPropertyID AnimationInputHelpers::KeyframeAttributeToPresentationAttribute( const String& property, - const Element& element) { - if (!RuntimeEnabledFeatures::WebAnimationsSVGEnabled() || - !element.IsSVGElement() || !IsSVGPrefixed(property)) + const Element* element) { + if (!RuntimeEnabledFeatures::WebAnimationsSVGEnabled() || !element || + !element->IsSVGElement() || !IsSVGPrefixed(property)) return CSSPropertyInvalid; String unprefixed_property = RemoveSVGPrefix(property); @@ -215,12 +215,12 @@ QualifiedName SvgAttributeName(const String& property) { const QualifiedName* AnimationInputHelpers::KeyframeAttributeToSVGAttribute( const String& property, - Element& element) { - if (!RuntimeEnabledFeatures::WebAnimationsSVGEnabled() || - !element.IsSVGElement() || !IsSVGPrefixed(property)) + Element* element) { + if (!RuntimeEnabledFeatures::WebAnimationsSVGEnabled() || !element || + !element->IsSVGElement() || !IsSVGPrefixed(property)) return nullptr; - SVGElement& svg_element = ToSVGElement(element); + SVGElement* svg_element = ToSVGElement(element); if (IsSVGSMILElement(svg_element)) return nullptr; @@ -229,7 +229,7 @@ const QualifiedName* AnimationInputHelpers::KeyframeAttributeToSVGAttribute( const AttributeNameMap& supported_attributes = GetSupportedAttributes(); auto iter = supported_attributes.find(attribute_name); if (iter == supported_attributes.end() || - !svg_element.PropertyFromAttribute(*iter->value)) + !svg_element->PropertyFromAttribute(*iter->value)) return nullptr; return iter->value; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationInputHelpers.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationInputHelpers.h index 7ef40cacad..c131539e86 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationInputHelpers.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationInputHelpers.h @@ -26,9 +26,9 @@ class CORE_EXPORT AnimationInputHelpers { static CSSPropertyID KeyframeAttributeToCSSProperty(const String&, const Document&); static CSSPropertyID KeyframeAttributeToPresentationAttribute(const String&, - const Element&); + const Element*); static const QualifiedName* KeyframeAttributeToSVGAttribute(const String&, - Element&); + Element*); static scoped_refptr ParseTimingFunction(const String&, Document*, ExceptionState&); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationSimTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationSimTest.cpp index ddb9df18a9..68555fee75 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationSimTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationSimTest.cpp @@ -9,7 +9,6 @@ #include "core/frame/WebLocalFrameImpl.h" #include "core/page/Page.h" #include "core/testing/sim/SimCompositor.h" -#include "core/testing/sim/SimDisplayItemList.h" #include "core/testing/sim/SimRequest.h" #include "core/testing/sim/SimTest.h" #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationTest.cpp index 62307c776d..d2182ac3ac 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/AnimationTest.cpp @@ -559,8 +559,8 @@ TEST_F(AnimationAnimationTest, SetEffect) { animation->SetCurrentTimeInternal(15); animation->setEffect(effect2); EXPECT_EQ(15, animation->CurrentTimeInternal()); - EXPECT_EQ(nullptr, effect1->GetAnimation()); - EXPECT_EQ(animation, effect2->GetAnimation()); + EXPECT_EQ(nullptr, effect1->GetAnimationForTesting()); + EXPECT_EQ(animation, effect2->GetAnimationForTesting()); EXPECT_EQ(effect2, animation->effect()); } @@ -708,7 +708,7 @@ TEST_F(AnimationAnimationTest, TimeToNextEffectSimpleCancelledBeforeStart) { } TEST_F(AnimationAnimationTest, AttachedAnimations) { - Persistent element = document->createElement("foo"); + Persistent element = document->CreateElementForBinding("foo"); Timing timing; KeyframeEffect* keyframe_effect = diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BUILD.gn b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BUILD.gn index 55b7f50870..46012d1d5b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BUILD.gn +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BUILD.gn @@ -12,6 +12,7 @@ blink_core_sources("animation") { "Animation.h", "AnimationClock.cpp", "AnimationClock.h", + "AnimationEffectOwner.h", "AnimationEffectReadOnly.cpp", "AnimationEffectReadOnly.h", "AnimationEffectTiming.cpp", @@ -226,7 +227,6 @@ blink_core_sources("animation") { "animatable/AnimatableFilterOperations.h", "animatable/AnimatableTransform.cpp", "animatable/AnimatableTransform.h", - "animatable/AnimatableUnknown.h", "animatable/AnimatableValue.cpp", "animatable/AnimatableValue.h", "css/CSSAnimatableValueFactory.cpp", diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BaseKeyframe.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BaseKeyframe.idl index fef225f4a6..ffe157e36d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BaseKeyframe.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BaseKeyframe.idl @@ -7,5 +7,5 @@ dictionary BaseKeyframe { double? offset = null; DOMString easing = "linear"; - CompositeOperation composite; + CompositeOperation? composite = null; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BasePropertyIndexedKeyframe.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BasePropertyIndexedKeyframe.idl index 2a04a0478c..8f7646d2b2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BasePropertyIndexedKeyframe.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BasePropertyIndexedKeyframe.idl @@ -7,5 +7,5 @@ dictionary BasePropertyIndexedKeyframe { (double? or sequence) offset = []; (DOMString or sequence) easing = []; - (CompositeOperation or sequence) composite = []; + (CompositeOperation? or sequence) composite = []; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BasicShapeInterpolationFunctions.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BasicShapeInterpolationFunctions.cpp index faa1a14e7c..56b507461c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BasicShapeInterpolationFunctions.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/BasicShapeInterpolationFunctions.cpp @@ -173,7 +173,8 @@ enum CircleComponentIndex : unsigned { kCircleComponentIndexCount, }; -InterpolationValue ConvertCSSValue(const CSSBasicShapeCircleValue& circle) { +InterpolationValue ConvertCSSValue( + const cssvalue::CSSBasicShapeCircleValue& circle) { std::unique_ptr list = InterpolableList::Create(kCircleComponentIndexCount); list->Set(kCircleCenterXIndex, ConvertCSSCoordinate(circle.CenterX())); @@ -241,7 +242,8 @@ enum EllipseComponentIndex : unsigned { kEllipseComponentIndexCount, }; -InterpolationValue ConvertCSSValue(const CSSBasicShapeEllipseValue& ellipse) { +InterpolationValue ConvertCSSValue( + const cssvalue::CSSBasicShapeEllipseValue& ellipse) { std::unique_ptr list = InterpolableList::Create(kEllipseComponentIndexCount); list->Set(kEllipseCenterXIndex, ConvertCSSCoordinate(ellipse.CenterX())); @@ -326,7 +328,8 @@ enum InsetComponentIndex : unsigned { kInsetComponentIndexCount, }; -InterpolationValue ConvertCSSValue(const CSSBasicShapeInsetValue& inset) { +InterpolationValue ConvertCSSValue( + const cssvalue::CSSBasicShapeInsetValue& inset) { std::unique_ptr list = InterpolableList::Create(kInsetComponentIndexCount); list->Set(kInsetTopIndex, ConvertCSSLength(inset.Top())); @@ -449,7 +452,8 @@ scoped_refptr CreateBasicShape( namespace PolygonFunctions { -InterpolationValue ConvertCSSValue(const CSSBasicShapePolygonValue& polygon) { +InterpolationValue ConvertCSSValue( + const cssvalue::CSSBasicShapePolygonValue& polygon) { size_t size = polygon.Values().size(); std::unique_ptr list = InterpolableList::Create(size); for (size_t i = 0; i < size; i++) @@ -506,16 +510,22 @@ scoped_refptr CreateBasicShape( InterpolationValue BasicShapeInterpolationFunctions::MaybeConvertCSSValue( const CSSValue& value) { - if (value.IsBasicShapeCircleValue()) - return CircleFunctions::ConvertCSSValue(ToCSSBasicShapeCircleValue(value)); - if (value.IsBasicShapeEllipseValue()) + if (value.IsBasicShapeCircleValue()) { + return CircleFunctions::ConvertCSSValue( + cssvalue::ToCSSBasicShapeCircleValue(value)); + } + if (value.IsBasicShapeEllipseValue()) { return EllipseFunctions::ConvertCSSValue( - ToCSSBasicShapeEllipseValue(value)); - if (value.IsBasicShapeInsetValue()) - return InsetFunctions::ConvertCSSValue(ToCSSBasicShapeInsetValue(value)); - if (value.IsBasicShapePolygonValue()) + cssvalue::ToCSSBasicShapeEllipseValue(value)); + } + if (value.IsBasicShapeInsetValue()) { + return InsetFunctions::ConvertCSSValue( + cssvalue::ToCSSBasicShapeInsetValue(value)); + } + if (value.IsBasicShapePolygonValue()) { return PolygonFunctions::ConvertCSSValue( - ToCSSBasicShapePolygonValue(value)); + cssvalue::ToCSSBasicShapePolygonValue(value)); + } return nullptr; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp index 59e6774b4f..2fc47bf262 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp @@ -23,7 +23,7 @@ const FilterOperations& GetFilterList(const CSSProperty& property, switch (property.PropertyID()) { default: NOTREACHED(); - // Fall through. + FALLTHROUGH; case CSSPropertyBackdropFilter: return style.BackdropFilter(); case CSSPropertyFilter: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSFontVariationSettingsInterpolationType.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSFontVariationSettingsInterpolationType.cpp index 4f0d15cbf5..6aa72e2964 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSFontVariationSettingsInterpolationType.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSFontVariationSettingsInterpolationType.cpp @@ -151,7 +151,8 @@ InterpolationValue CSSFontVariationSettingsInterpolationType::MaybeConvertValue( std::unique_ptr numbers = InterpolableList::Create(length); Vector tags; for (size_t i = 0; i < length; ++i) { - const CSSFontVariationValue& item = ToCSSFontVariationValue(list.Item(i)); + const cssvalue::CSSFontVariationValue& item = + cssvalue::ToCSSFontVariationValue(list.Item(i)); numbers->Set(i, InterpolableNumber::Create(item.Value())); tags.push_back(item.Tag()); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSInterpolationTypesMap.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSInterpolationTypesMap.cpp index 7450253252..ba12557bdc 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSInterpolationTypesMap.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSInterpolationTypesMap.cpp @@ -134,6 +134,7 @@ const InterpolationTypes& CSSInterpolationTypesMap::Get( case CSSPropertyWebkitBorderHorizontalSpacing: case CSSPropertyWebkitBorderVerticalSpacing: case CSSPropertyColumnGap: + case CSSPropertyRowGap: case CSSPropertyColumnRuleWidth: case CSSPropertyColumnWidth: case CSSPropertyWebkitPerspectiveOriginX: @@ -197,7 +198,7 @@ const InterpolationTypes& CSSInterpolationTypesMap::Get( case CSSPropertyOffsetPath: applicable_types->push_back( std::make_unique(used_property)); - // Fall through. + FALLTHROUGH; case CSSPropertyD: applicable_types->push_back( std::make_unique(used_property)); @@ -396,6 +397,7 @@ CSSInterpolationTypesMap::CreateInterpolationTypesForCSSSyntax( case CSSSyntaxType::kInteger: result.push_back(std::make_unique( property, ®istration, true)); + break; case CSSSyntaxType::kTransformList: // TODO(alancutter): Support smooth interpolation of these types. break; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSRayInterpolationType.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSRayInterpolationType.cpp index ef45b494f0..b1bde5a3db 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSRayInterpolationType.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSRayInterpolationType.cpp @@ -5,7 +5,6 @@ #include "core/animation/CSSRayInterpolationType.h" #include "core/css/BasicShapeFunctions.h" -#include "core/css/CSSRayValue.h" #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" #include "core/style/StyleRay.h" diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSRotateInterpolationType.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSRotateInterpolationType.cpp index 034097be80..bfd7c51a3e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSRotateInterpolationType.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CSSRotateInterpolationType.cpp @@ -163,7 +163,7 @@ class InheritedRotationChecker const InterpolationValue& underlying) const final { OptionalRotation inherited_rotation = GetRotation(*state.ParentStyle()); if (inherited_rotation_.IsNone() || inherited_rotation.IsNone()) - return inherited_rotation.IsNone() == inherited_rotation.IsNone(); + return inherited_rotation_.IsNone() == inherited_rotation.IsNone(); return inherited_rotation_.GetRotation().axis == inherited_rotation.GetRotation().axis && inherited_rotation_.GetRotation().angle == diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp index 66542d846b..e2407f8344 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp @@ -49,11 +49,11 @@ #include "core/paint/compositing/CompositedLayerMapping.h" #include "platform/animation/AnimationTranslationUtil.h" #include "platform/animation/CompositorAnimation.h" -#include "platform/animation/CompositorAnimationPlayer.h" #include "platform/animation/CompositorFilterAnimationCurve.h" #include "platform/animation/CompositorFilterKeyframe.h" #include "platform/animation/CompositorFloatAnimationCurve.h" #include "platform/animation/CompositorFloatKeyframe.h" +#include "platform/animation/CompositorKeyframeModel.h" #include "platform/animation/CompositorTransformAnimationCurve.h" #include "platform/animation/CompositorTransformKeyframe.h" #include "platform/geometry/FloatBox.h" @@ -65,7 +65,8 @@ namespace blink { namespace { bool ConsiderAnimationAsIncompatible(const Animation& animation, - const Animation& animation_to_add) { + const Animation& animation_to_add, + const EffectModel& effect_to_add) { if (&animation == &animation_to_add) return false; @@ -77,7 +78,10 @@ bool ConsiderAnimationAsIncompatible(const Animation& animation, return true; case Animation::kPaused: case Animation::kFinished: - return Animation::HasLowerPriority(&animation_to_add, &animation); + if (Animation::HasLowerPriority(&animation, &animation_to_add)) { + return effect_to_add.AffectedByUnderlyingAnimations(); + } + return true; default: NOTREACHED(); return true; @@ -103,6 +107,12 @@ bool IsTransformRelatedAnimation(const Element& target_element, bool HasIncompatibleAnimations(const Element& target_element, const Animation& animation_to_add, const EffectModel& effect_to_add) { + if (!target_element.HasAnimations()) + return false; + + ElementAnimations* element_animations = target_element.GetElementAnimations(); + DCHECK(element_animations); + const bool affects_opacity = effect_to_add.Affects(PropertyHandle(GetCSSPropertyOpacity())); const bool affects_transform = effect_to_add.IsTransformRelatedEffect(); @@ -111,16 +121,12 @@ bool HasIncompatibleAnimations(const Element& target_element, const bool affects_backdrop_filter = effect_to_add.Affects(PropertyHandle(GetCSSPropertyBackdropFilter())); - if (!target_element.HasAnimations()) - return false; - - ElementAnimations* element_animations = target_element.GetElementAnimations(); - DCHECK(element_animations); - for (const auto& entry : element_animations->Animations()) { const Animation* attached_animation = entry.key; - if (!ConsiderAnimationAsIncompatible(*attached_animation, animation_to_add)) + if (!ConsiderAnimationAsIncompatible(*attached_animation, animation_to_add, + effect_to_add)) { continue; + } if ((affects_opacity && attached_animation->Affects( target_element, GetCSSPropertyOpacity())) || @@ -130,8 +136,9 @@ bool HasIncompatibleAnimations(const Element& target_element, attached_animation->Affects(target_element, GetCSSPropertyFilter())) || (affects_backdrop_filter && attached_animation->Affects(target_element, - GetCSSPropertyBackdropFilter()))) + GetCSSPropertyBackdropFilter()))) { return true; + } } return false; @@ -146,6 +153,23 @@ CompositorAnimations::CheckCanStartEffectOnCompositor( const Animation* animation_to_add, const EffectModel& effect, double animation_playback_rate) { + // Check whether this animation is main thread compositable or not. + // If this runtime feature is on + we have either opacity or 2d transform + // animation, then this animation is main thread compositable. + if (RuntimeEnabledFeatures:: + TurnOff2DAndOpacityCompositorAnimationsEnabled()) { + LayoutObject* layout_object = target_element.GetLayoutObject(); + if (layout_object) { + const ComputedStyle* style = layout_object->Style(); + if (style && (style->HasCurrentOpacityAnimation() || + (style->HasCurrentTransformAnimation() && + !style->Has3DTransform()))) { + return FailureCode::AcceleratableAnimNotAccelerated( + "Acceleratable animation not accelerated due to an experiment"); + } + } + } + const KeyframeEffectModelBase& keyframe_effect = ToKeyframeEffectModelBase(effect); @@ -283,25 +307,20 @@ CompositorAnimations::CheckCanStartElementOnCompositor( } } } else { + LayoutObject* layout_object = target_element.GetLayoutObject(); bool paints_into_own_backing = - target_element.GetLayoutObject() && - target_element.GetLayoutObject()->GetCompositingState() == - kPaintsIntoOwnBacking; - // This function is called in CheckCanStartAnimationOnCompositor(), after - // CheckCanStartEffectOnCompositor returns code.Ok(), which means that we - // know this animation could be accelerated. If |!paints_into_own_backing|, - // then we know that the animation is not composited due to certain check, - // such as the ComputedStyle::ShouldCompositeForCurrentAnimations(), for - // a running experiment. + layout_object && + layout_object->GetCompositingState() == kPaintsIntoOwnBacking; if (!paints_into_own_backing) { - return FailureCode::NotPaintIntoOwnBacking( - "Acceleratable animation not accelerated due to an experiment"); + return FailureCode::NonActionable( + "Element does not paint into own backing"); } } return FailureCode::None(); } +// TODO(crbug.com/809685): consider refactor this function. CompositorAnimations::FailureCode CompositorAnimations::CheckCanStartAnimationOnCompositor( const Timing& timing, @@ -338,8 +357,10 @@ void CompositorAnimations::CancelIncompatibleAnimationsOnCompositor( for (const auto& entry : element_animations->Animations()) { Animation* attached_animation = entry.key; - if (!ConsiderAnimationAsIncompatible(*attached_animation, animation_to_add)) + if (!ConsiderAnimationAsIncompatible(*attached_animation, animation_to_add, + effect_to_add)) { continue; + } if ((affects_opacity && attached_animation->Affects( target_element, GetCSSPropertyOpacity())) || @@ -349,8 +370,9 @@ void CompositorAnimations::CancelIncompatibleAnimationsOnCompositor( attached_animation->Affects(target_element, GetCSSPropertyFilter())) || (affects_backdrop_filter && attached_animation->Affects(target_element, - GetCSSPropertyBackdropFilter()))) + GetCSSPropertyBackdropFilter()))) { attached_animation->CancelAnimationOnCompositor(); + } } } @@ -361,7 +383,7 @@ void CompositorAnimations::StartAnimationOnCompositor( double time_offset, const Timing& timing, const Animation* animation, - CompositorAnimationPlayer& compositor_player, + CompositorAnimation& compositor_animation, const EffectModel& effect, Vector& started_animation_ids, double animation_playback_rate) { @@ -373,14 +395,14 @@ void CompositorAnimations::StartAnimationOnCompositor( const KeyframeEffectModelBase& keyframe_effect = ToKeyframeEffectModelBase(effect); - Vector> animations; + Vector> keyframe_models; GetAnimationOnCompositor(timing, group, start_time, time_offset, - keyframe_effect, animations, + keyframe_effect, keyframe_models, animation_playback_rate); - DCHECK(!animations.IsEmpty()); - for (auto& compositor_animation : animations) { - int id = compositor_animation->Id(); - compositor_player.AddAnimation(std::move(compositor_animation)); + DCHECK(!keyframe_models.IsEmpty()); + for (auto& compositor_keyframe_model : keyframe_models) { + int id = compositor_keyframe_model->Id(); + compositor_animation.AddKeyframeModel(std::move(compositor_keyframe_model)); started_animation_ids.push_back(id); } DCHECK(!started_animation_ids.IsEmpty()); @@ -398,9 +420,10 @@ void CompositorAnimations::CancelAnimationOnCompositor( // compositing update. return; } - CompositorAnimationPlayer* compositor_player = animation.CompositorPlayer(); - if (compositor_player) - compositor_player->RemoveAnimation(id); + CompositorAnimation* compositor_animation = + animation.GetCompositorAnimation(); + if (compositor_animation) + compositor_animation->RemoveKeyframeModel(id); } void CompositorAnimations::PauseAnimationForTestingOnCompositor( @@ -414,15 +437,16 @@ void CompositorAnimations::PauseAnimationForTestingOnCompositor( DisableCompositingQueryAsserts disabler; DCHECK(CheckCanStartElementOnCompositor(element).Ok()); - CompositorAnimationPlayer* compositor_player = animation.CompositorPlayer(); - DCHECK(compositor_player); - compositor_player->PauseAnimation(id, pause_time); + CompositorAnimation* compositor_animation = + animation.GetCompositorAnimation(); + DCHECK(compositor_animation); + compositor_animation->PauseKeyframeModel(id, pause_time); } void CompositorAnimations::AttachCompositedLayers( Element& element, - CompositorAnimationPlayer* compositor_player) { - if (!compositor_player) + CompositorAnimation* compositor_animation) { + if (!compositor_animation) return; if (!element.GetLayoutObject() || @@ -446,7 +470,7 @@ void CompositorAnimations::AttachCompositedLayers( return; } - compositor_player->AttachElement(CompositorElementIdFromUniqueObjectId( + compositor_animation->AttachElement(CompositorElementIdFromUniqueObjectId( element.GetLayoutObject()->UniqueId(), CompositorElementIdNamespace::kPrimary)); } @@ -552,9 +576,9 @@ void CompositorAnimations::GetAnimationOnCompositor( double start_time, double time_offset, const KeyframeEffectModelBase& effect, - Vector>& animations, + Vector>& keyframe_models, double animation_playback_rate) { - DCHECK(animations.IsEmpty()); + DCHECK(keyframe_models.IsEmpty()); CompositorTiming compositor_timing; bool timing_valid = ConvertTimingForCompositor( timing, time_offset, compositor_timing, animation_playback_rate); @@ -617,21 +641,21 @@ void CompositorAnimations::GetAnimationOnCompositor( } DCHECK(curve.get()); - std::unique_ptr animation = - CompositorAnimation::Create(*curve, target_property, group, 0); + std::unique_ptr keyframe_model = + CompositorKeyframeModel::Create(*curve, target_property, group, 0); if (!std::isnan(start_time)) - animation->SetStartTime(start_time); - - animation->SetIterations(compositor_timing.adjusted_iteration_count); - animation->SetIterationStart(compositor_timing.iteration_start); - animation->SetTimeOffset(compositor_timing.scaled_time_offset); - animation->SetDirection(compositor_timing.direction); - animation->SetPlaybackRate(compositor_timing.playback_rate); - animation->SetFillMode(compositor_timing.fill_mode); - animations.push_back(std::move(animation)); + keyframe_model->SetStartTime(start_time); + + keyframe_model->SetIterations(compositor_timing.adjusted_iteration_count); + keyframe_model->SetIterationStart(compositor_timing.iteration_start); + keyframe_model->SetTimeOffset(compositor_timing.scaled_time_offset); + keyframe_model->SetDirection(compositor_timing.direction); + keyframe_model->SetPlaybackRate(compositor_timing.playback_rate); + keyframe_model->SetFillMode(compositor_timing.fill_mode); + keyframe_models.push_back(std::move(keyframe_model)); } - DCHECK(!animations.IsEmpty()); + DCHECK(!keyframe_models.IsEmpty()); } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimations.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimations.h index e27a65533c..2b7a61c1e6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimations.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimations.h @@ -43,7 +43,6 @@ namespace blink { class Animation; class CompositorAnimation; -class CompositorAnimationPlayer; class Element; class KeyframeEffectModelBase; @@ -68,7 +67,7 @@ class CORE_EXPORT CompositorAnimations { static FailureCode NonActionable(const String& reason) { return FailureCode(false, false, false, reason); } - static FailureCode NotPaintIntoOwnBacking(const String& reason) { + static FailureCode AcceleratableAnimNotAccelerated(const String& reason) { return FailureCode(true, false, false, reason); } @@ -106,7 +105,7 @@ class CORE_EXPORT CompositorAnimations { double time_offset, const Timing&, const Animation*, - CompositorAnimationPlayer&, + CompositorAnimation&, const EffectModel&, Vector& started_animation_ids, double animation_playback_rate); @@ -118,7 +117,7 @@ class CORE_EXPORT CompositorAnimations { int id, double pause_time); - static void AttachCompositedLayers(Element&, CompositorAnimationPlayer*); + static void AttachCompositedLayers(Element&, CompositorAnimation*); struct CompositorTiming { Timing::PlaybackDirection direction; @@ -141,7 +140,7 @@ class CORE_EXPORT CompositorAnimations { double start_time, double time_offset, const KeyframeEffectModelBase&, - Vector>& animations, + Vector>& animations, double animation_playback_rate); private: @@ -160,6 +159,8 @@ class CORE_EXPORT CompositorAnimations { canStartElementOnCompositorEffectSPv2); FRIEND_TEST_ALL_PREFIXES(AnimationCompositorAnimationsTest, canStartElementOnCompositorEffect); + FRIEND_TEST_ALL_PREFIXES(AnimationCompositorAnimationsTest, + cannotStartElementOnCompositorEffectSVG); FRIEND_TEST_ALL_PREFIXES( AnimationCompositorAnimationsTest, cannotStartElementOnCompositorEffectWithRuntimeFeature); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp index bd33ab543a..067982a2ed 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp @@ -49,9 +49,10 @@ #include "core/style/ComputedStyle.h" #include "core/style/FilterOperations.h" #include "core/testing/DummyPageHolder.h" -#include "platform/animation/CompositorAnimation.h" +#include "platform/animation/CompositorAnimationHost.h" #include "platform/animation/CompositorFloatAnimationCurve.h" #include "platform/animation/CompositorFloatKeyframe.h" +#include "platform/animation/CompositorKeyframeModel.h" #include "platform/geometry/FloatBox.h" #include "platform/geometry/IntSize.h" #include "platform/testing/HistogramTester.h" @@ -115,7 +116,7 @@ class AnimationCompositorAnimationsTest : public RenderingTest { timeline_ = DocumentTimeline::Create(&GetDocument()); timeline_->ResetForTesting(); - element_ = GetDocument().createElement("test"); + element_ = GetDocument().CreateElementForBinding("test"); helper_.Initialize(nullptr, nullptr, nullptr, &ConfigureSettings); base_url_ = "http://www.test.com/"; @@ -140,17 +141,17 @@ class AnimationCompositorAnimationsTest : public RenderingTest { void GetAnimationOnCompositor( Timing& timing, StringKeyframeEffectModel& effect, - Vector>& animations) { - GetAnimationOnCompositor(timing, effect, animations, 1); + Vector>& keyframe_models) { + GetAnimationOnCompositor(timing, effect, keyframe_models, 1); } void GetAnimationOnCompositor( Timing& timing, StringKeyframeEffectModel& effect, - Vector>& animations, - double player_playback_rate) { + Vector>& keyframe_models, + double animation_playback_rate) { CompositorAnimations::GetAnimationOnCompositor( timing, 0, std::numeric_limits::quiet_NaN(), 0, effect, - animations, player_playback_rate); + keyframe_models, animation_playback_rate); } bool DuplicateSingleKeyframeAndTestIsCandidateOnResult( @@ -276,22 +277,22 @@ class AnimationCompositorAnimationsTest : public RenderingTest { timeline_->ServiceAnimations(kTimingUpdateForAnimationFrame); } - std::unique_ptr ConvertToCompositorAnimation( + std::unique_ptr ConvertToCompositorAnimation( StringKeyframeEffectModel& effect, - double player_playback_rate) { + double animation_playback_rate) { // As the compositor code only understands AnimatableValues, we must // snapshot the effect to make those available. // TODO(crbug.com/725385): Remove once compositor uses InterpolationTypes. auto style = ComputedStyle::Create(); effect.SnapshotAllCompositorKeyframes(*element_.Get(), *style, nullptr); - Vector> result; - GetAnimationOnCompositor(timing_, effect, result, player_playback_rate); + Vector> result; + GetAnimationOnCompositor(timing_, effect, result, animation_playback_rate); DCHECK_EQ(1U, result.size()); return std::move(result[0]); } - std::unique_ptr ConvertToCompositorAnimation( + std::unique_ptr ConvertToCompositorAnimation( StringKeyframeEffectModel& effect) { return ConvertToCompositorAnimation(effect, 1.0); } @@ -321,6 +322,8 @@ class AnimationCompositorAnimationsTest : public RenderingTest { LocalFrame* GetFrame() const { return helper_.LocalMainFrame()->GetFrame(); } + void BeginFrame() { helper_.GetWebView()->BeginFrame(WTF::CurrentTime()); } + void ForceFullCompositingUpdate() { helper_.GetWebView()->UpdateAllLifecyclePhases(); } @@ -769,16 +772,18 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation) { CreateReplaceOpKeyframe(CSSPropertyOpacity, "0.2", 0), CreateReplaceOpKeyframe(CSSPropertyOpacity, "0.5", 1.0)); - std::unique_ptr animation = + std::unique_ptr keyframe_model = ConvertToCompositorAnimation(*effect); - EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->TargetProperty()); - EXPECT_EQ(1.0, animation->Iterations()); - EXPECT_EQ(0, animation->TimeOffset()); - EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->GetDirection()); - EXPECT_EQ(1.0, animation->PlaybackRate()); + EXPECT_EQ(CompositorTargetProperty::OPACITY, + keyframe_model->TargetProperty()); + EXPECT_EQ(1.0, keyframe_model->Iterations()); + EXPECT_EQ(0, keyframe_model->TimeOffset()); + EXPECT_EQ(CompositorKeyframeModel::Direction::NORMAL, + keyframe_model->GetDirection()); + EXPECT_EQ(1.0, keyframe_model->PlaybackRate()); std::unique_ptr keyframed_float_curve = - animation->FloatCurveForTesting(); + keyframe_model->FloatCurveForTesting(); CompositorFloatAnimationCurve::Keyframes keyframes = keyframed_float_curve->KeyframesForTesting(); @@ -805,10 +810,10 @@ TEST_F(AnimationCompositorAnimationsTest, const double kDuration = 10.0; timing_.iteration_duration = kDuration; - std::unique_ptr animation = + std::unique_ptr keyframe_model = ConvertToCompositorAnimation(*effect); std::unique_ptr keyframed_float_curve = - animation->FloatCurveForTesting(); + keyframe_model->FloatCurveForTesting(); CompositorFloatAnimationCurve::Keyframes keyframes = keyframed_float_curve->KeyframesForTesting(); @@ -830,17 +835,18 @@ TEST_F(AnimationCompositorAnimationsTest, timing_.direction = Timing::PlaybackDirection::ALTERNATE_NORMAL; timing_.playback_rate = 2.0; - std::unique_ptr animation = + std::unique_ptr keyframe_model = ConvertToCompositorAnimation(*effect); - EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->TargetProperty()); - EXPECT_EQ(5.0, animation->Iterations()); - EXPECT_EQ(0, animation->TimeOffset()); - EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_NORMAL, - animation->GetDirection()); - EXPECT_EQ(2.0, animation->PlaybackRate()); + EXPECT_EQ(CompositorTargetProperty::OPACITY, + keyframe_model->TargetProperty()); + EXPECT_EQ(5.0, keyframe_model->Iterations()); + EXPECT_EQ(0, keyframe_model->TimeOffset()); + EXPECT_EQ(CompositorKeyframeModel::Direction::ALTERNATE_NORMAL, + keyframe_model->GetDirection()); + EXPECT_EQ(2.0, keyframe_model->PlaybackRate()); std::unique_ptr keyframed_float_curve = - animation->FloatCurveForTesting(); + keyframe_model->FloatCurveForTesting(); CompositorFloatAnimationCurve::Keyframes keyframes = keyframed_float_curve->KeyframesForTesting(); @@ -880,15 +886,16 @@ TEST_F(AnimationCompositorAnimationsTest, timing_.iteration_duration = 1.75; timing_.start_delay = kStartDelay; - std::unique_ptr animation = + std::unique_ptr keyframe_model = ConvertToCompositorAnimation(*effect); - EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->TargetProperty()); - EXPECT_EQ(5.0, animation->Iterations()); - EXPECT_EQ(-kStartDelay, animation->TimeOffset()); + EXPECT_EQ(CompositorTargetProperty::OPACITY, + keyframe_model->TargetProperty()); + EXPECT_EQ(5.0, keyframe_model->Iterations()); + EXPECT_EQ(-kStartDelay, keyframe_model->TimeOffset()); std::unique_ptr keyframed_float_curve = - animation->FloatCurveForTesting(); + keyframe_model->FloatCurveForTesting(); CompositorFloatAnimationCurve::Keyframes keyframes = keyframed_float_curve->KeyframesForTesting(); @@ -916,17 +923,18 @@ TEST_F(AnimationCompositorAnimationsTest, timing_.iteration_count = 10; timing_.direction = Timing::PlaybackDirection::ALTERNATE_NORMAL; - std::unique_ptr animation = + std::unique_ptr keyframe_model = ConvertToCompositorAnimation(*effect); - EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->TargetProperty()); - EXPECT_EQ(10.0, animation->Iterations()); - EXPECT_EQ(0, animation->TimeOffset()); - EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_NORMAL, - animation->GetDirection()); - EXPECT_EQ(1.0, animation->PlaybackRate()); + EXPECT_EQ(CompositorTargetProperty::OPACITY, + keyframe_model->TargetProperty()); + EXPECT_EQ(10.0, keyframe_model->Iterations()); + EXPECT_EQ(0, keyframe_model->TimeOffset()); + EXPECT_EQ(CompositorKeyframeModel::Direction::ALTERNATE_NORMAL, + keyframe_model->GetDirection()); + EXPECT_EQ(1.0, keyframe_model->PlaybackRate()); std::unique_ptr keyframed_float_curve = - animation->FloatCurveForTesting(); + keyframe_model->FloatCurveForTesting(); CompositorFloatAnimationCurve::Keyframes keyframes = keyframed_float_curve->KeyframesForTesting(); @@ -973,17 +981,18 @@ TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) { timing_.iteration_count = 10; timing_.direction = Timing::PlaybackDirection::ALTERNATE_REVERSE; - std::unique_ptr animation = + std::unique_ptr keyframe_model = ConvertToCompositorAnimation(*effect); - EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->TargetProperty()); - EXPECT_EQ(10.0, animation->Iterations()); - EXPECT_EQ(0, animation->TimeOffset()); - EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_REVERSE, - animation->GetDirection()); - EXPECT_EQ(1.0, animation->PlaybackRate()); + EXPECT_EQ(CompositorTargetProperty::OPACITY, + keyframe_model->TargetProperty()); + EXPECT_EQ(10.0, keyframe_model->Iterations()); + EXPECT_EQ(0, keyframe_model->TimeOffset()); + EXPECT_EQ(CompositorKeyframeModel::Direction::ALTERNATE_REVERSE, + keyframe_model->GetDirection()); + EXPECT_EQ(1.0, keyframe_model->PlaybackRate()); std::unique_ptr keyframed_float_curve = - animation->FloatCurveForTesting(); + keyframe_model->FloatCurveForTesting(); CompositorFloatAnimationCurve::Keyframes keyframes = keyframed_float_curve->KeyframesForTesting(); @@ -1027,17 +1036,18 @@ TEST_F(AnimationCompositorAnimationsTest, timing_.start_delay = kNegativeStartDelay; timing_.direction = Timing::PlaybackDirection::ALTERNATE_REVERSE; - std::unique_ptr animation = + std::unique_ptr keyframe_model = ConvertToCompositorAnimation(*effect); - EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->TargetProperty()); - EXPECT_EQ(5.0, animation->Iterations()); - EXPECT_EQ(-kNegativeStartDelay, animation->TimeOffset()); - EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_REVERSE, - animation->GetDirection()); - EXPECT_EQ(1.0, animation->PlaybackRate()); + EXPECT_EQ(CompositorTargetProperty::OPACITY, + keyframe_model->TargetProperty()); + EXPECT_EQ(5.0, keyframe_model->Iterations()); + EXPECT_EQ(-kNegativeStartDelay, keyframe_model->TimeOffset()); + EXPECT_EQ(CompositorKeyframeModel::Direction::ALTERNATE_REVERSE, + keyframe_model->GetDirection()); + EXPECT_EQ(1.0, keyframe_model->PlaybackRate()); std::unique_ptr keyframed_float_curve = - animation->FloatCurveForTesting(); + keyframe_model->FloatCurveForTesting(); CompositorFloatAnimationCurve::Keyframes keyframes = keyframed_float_curve->KeyframesForTesting(); @@ -1052,20 +1062,23 @@ TEST_F(AnimationCompositorAnimationsTest, CreateReplaceOpKeyframe(CSSPropertyOpacity, "0.5", 1.0)); const double kPlaybackRate = 2; - const double kPlayerPlaybackRate = -1.5; + const double kAnimationPlaybackRate = -1.5; timing_.playback_rate = kPlaybackRate; - std::unique_ptr animation = - ConvertToCompositorAnimation(*effect, kPlayerPlaybackRate); - EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->TargetProperty()); - EXPECT_EQ(1.0, animation->Iterations()); - EXPECT_EQ(0, animation->TimeOffset()); - EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->GetDirection()); - EXPECT_EQ(kPlaybackRate * kPlayerPlaybackRate, animation->PlaybackRate()); + std::unique_ptr keyframe_model = + ConvertToCompositorAnimation(*effect, kAnimationPlaybackRate); + EXPECT_EQ(CompositorTargetProperty::OPACITY, + keyframe_model->TargetProperty()); + EXPECT_EQ(1.0, keyframe_model->Iterations()); + EXPECT_EQ(0, keyframe_model->TimeOffset()); + EXPECT_EQ(CompositorKeyframeModel::Direction::NORMAL, + keyframe_model->GetDirection()); + EXPECT_EQ(kPlaybackRate * kAnimationPlaybackRate, + keyframe_model->PlaybackRate()); std::unique_ptr keyframed_float_curve = - animation->FloatCurveForTesting(); + keyframe_model->FloatCurveForTesting(); CompositorFloatAnimationCurve::Keyframes keyframes = keyframed_float_curve->KeyframesForTesting(); @@ -1081,9 +1094,10 @@ TEST_F(AnimationCompositorAnimationsTest, timing_.fill_mode = Timing::FillMode::NONE; - std::unique_ptr animation = + std::unique_ptr keyframe_model = ConvertToCompositorAnimation(*effect); - EXPECT_EQ(CompositorAnimation::FillMode::NONE, animation->GetFillMode()); + EXPECT_EQ(CompositorKeyframeModel::FillMode::NONE, + keyframe_model->GetFillMode()); } TEST_F(AnimationCompositorAnimationsTest, @@ -1095,14 +1109,17 @@ TEST_F(AnimationCompositorAnimationsTest, timing_.fill_mode = Timing::FillMode::AUTO; - std::unique_ptr animation = + std::unique_ptr keyframe_model = ConvertToCompositorAnimation(*effect); - EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->TargetProperty()); - EXPECT_EQ(1.0, animation->Iterations()); - EXPECT_EQ(0, animation->TimeOffset()); - EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->GetDirection()); - EXPECT_EQ(1.0, animation->PlaybackRate()); - EXPECT_EQ(CompositorAnimation::FillMode::NONE, animation->GetFillMode()); + EXPECT_EQ(CompositorTargetProperty::OPACITY, + keyframe_model->TargetProperty()); + EXPECT_EQ(1.0, keyframe_model->Iterations()); + EXPECT_EQ(0, keyframe_model->TimeOffset()); + EXPECT_EQ(CompositorKeyframeModel::Direction::NORMAL, + keyframe_model->GetDirection()); + EXPECT_EQ(1.0, keyframe_model->PlaybackRate()); + EXPECT_EQ(CompositorKeyframeModel::FillMode::NONE, + keyframe_model->GetFillMode()); } TEST_F(AnimationCompositorAnimationsTest, @@ -1114,11 +1131,11 @@ TEST_F(AnimationCompositorAnimationsTest, timing_.timing_function = cubic_custom_timing_function_; - std::unique_ptr animation = + std::unique_ptr keyframe_model = ConvertToCompositorAnimation(*effect); std::unique_ptr keyframed_float_curve = - animation->FloatCurveForTesting(); + keyframe_model->FloatCurveForTesting(); auto curve_timing_function = keyframed_float_curve->GetTimingFunctionForTesting(); @@ -1150,7 +1167,7 @@ TEST_F(AnimationCompositorAnimationsTest, TEST_F(AnimationCompositorAnimationsTest, cancelIncompatibleCompositorAnimations) { - Persistent element = GetDocument().createElement("shared"); + Persistent element = GetDocument().CreateElementForBinding("shared"); LayoutObjectProxy* layout_object = LayoutObjectProxy::Create(element.Get()); element->SetLayoutObject(layout_object); @@ -1240,7 +1257,7 @@ void UpdateDummyEffectNode(ObjectPaintProperties& properties, TEST_F(AnimationCompositorAnimationsTest, canStartElementOnCompositorTransformSPv2) { - Persistent element = GetDocument().createElement("shared"); + Persistent element = GetDocument().CreateElementForBinding("shared"); LayoutObjectProxy* layout_object = LayoutObjectProxy::Create(element.Get()); element->SetLayoutObject(layout_object); @@ -1272,7 +1289,7 @@ TEST_F(AnimationCompositorAnimationsTest, TEST_F(AnimationCompositorAnimationsTest, canStartElementOnCompositorEffectSPv2) { - Persistent element = GetDocument().createElement("shared"); + Persistent element = GetDocument().CreateElementForBinding("shared"); LayoutObjectProxy* layout_object = LayoutObjectProxy::Create(element.Get()); element->SetLayoutObject(layout_object); @@ -1302,6 +1319,70 @@ TEST_F(AnimationCompositorAnimationsTest, LayoutObjectProxy::Dispose(layout_object); } +TEST_F(AnimationCompositorAnimationsTest, trackRafAnimation) { + LoadTestData("raf-countdown.html"); + + CompositorAnimationHost* host = + GetFrame()->GetDocument()->View()->GetCompositorAnimationHost(); + + // The test file registers two rAF 'animations'; one which ends after 5 + // iterations and the other that ends after 10. + for (int i = 0; i < 9; i++) { + BeginFrame(); + ForceFullCompositingUpdate(); + EXPECT_TRUE(host->CurrentFrameHadRAFForTesting()); + EXPECT_TRUE(host->NextFrameHasPendingRAFForTesting()); + } + + // On the 10th iteration, there should be a current rAF, but no more pending + // rAFs. + BeginFrame(); + ForceFullCompositingUpdate(); + EXPECT_TRUE(host->CurrentFrameHadRAFForTesting()); + EXPECT_FALSE(host->NextFrameHasPendingRAFForTesting()); + + // On the 11th iteration, there should be no more rAFs firing. + BeginFrame(); + ForceFullCompositingUpdate(); + EXPECT_FALSE(host->CurrentFrameHadRAFForTesting()); + EXPECT_FALSE(host->NextFrameHasPendingRAFForTesting()); +} + +TEST_F(AnimationCompositorAnimationsTest, trackRafAnimationTimeout) { + LoadTestData("raf-timeout.html"); + + CompositorAnimationHost* host = + GetFrame()->GetDocument()->View()->GetCompositorAnimationHost(); + + // The test file executes a rAF, which fires a setTimeout for the next rAF. + // Even with setTimeout(func, 0), the next rAF is not considered pending. + BeginFrame(); + ForceFullCompositingUpdate(); + EXPECT_TRUE(host->CurrentFrameHadRAFForTesting()); + EXPECT_FALSE(host->NextFrameHasPendingRAFForTesting()); +} + +TEST_F(AnimationCompositorAnimationsTest, trackRafAnimationNoneRegistered) { + SetBodyInnerHTML("
"); + + // Run a full frame after loading the test data so that scripted animations + // are serviced and data propagated. + BeginFrame(); + ForceFullCompositingUpdate(); + + // The HTML does not have any rAFs. + CompositorAnimationHost* host = + GetFrame()->GetDocument()->View()->GetCompositorAnimationHost(); + EXPECT_FALSE(host->CurrentFrameHadRAFForTesting()); + EXPECT_FALSE(host->NextFrameHasPendingRAFForTesting()); + + // And still shouldn't after another frame. + BeginFrame(); + ForceFullCompositingUpdate(); + EXPECT_FALSE(host->CurrentFrameHadRAFForTesting()); + EXPECT_FALSE(host->NextFrameHasPendingRAFForTesting()); +} + TEST_F(AnimationCompositorAnimationsTest, canStartElementOnCompositorEffect) { LoadTestData("transform-animation.html"); Document* document = GetFrame()->GetDocument(); @@ -1320,9 +1401,31 @@ TEST_F(AnimationCompositorAnimationsTest, canStartElementOnCompositorEffect) { EXPECT_EQ(host->GetMainThreadCompositableAnimationsCountForTesting(), 0u); EXPECT_EQ(host->GetCompositedAnimationsCountForTesting(), 1u); } -// TODO(xidachen): test temporary disabled due to crbug.com/781305. + +// Regression test for crbug.com/781305. When we have a transform animation +// on a SVG element, the effect can be started on compositor but the element +// itself cannot. The animation should not be a main thread compositable +// animation. +TEST_F(AnimationCompositorAnimationsTest, + cannotStartElementOnCompositorEffectSVG) { + LoadTestData("transform-animation-on-svg.html"); + Document* document = GetFrame()->GetDocument(); + Element* target = document->getElementById("dots"); + CompositorAnimations::FailureCode code = + CompositorAnimations::CheckCanStartElementOnCompositor(*target); + EXPECT_EQ(code, CompositorAnimations::FailureCode::NonActionable( + "Element does not paint into own backing")); + EXPECT_EQ(document->Timeline().PendingAnimationsCount(), 4u); + EXPECT_EQ(document->Timeline().MainThreadCompositableAnimationsCount(), 0u); + CompositorAnimationHost* host = + document->View()->GetCompositorAnimationHost(); + EXPECT_EQ(host->GetMainThreadAnimationsCountForTesting(), 4u); + EXPECT_EQ(host->GetMainThreadCompositableAnimationsCountForTesting(), 0u); + EXPECT_EQ(host->GetCompositedAnimationsCountForTesting(), 0u); +} + TEST_F(AnimationCompositorAnimationsTest, - DISABLED_cannotStartElementOnCompositorEffectWithRuntimeFeature) { + cannotStartAnimationOnCompositorWithRuntimeFeature) { ScopedTurnOff2DAndOpacityCompositorAnimationsForTest turn_off_2d_and_opacity_compositors_animation(true); LoadTestData("transform-animation.html"); @@ -1331,11 +1434,15 @@ TEST_F(AnimationCompositorAnimationsTest, const ObjectPaintProperties* properties = target->GetLayoutObject()->FirstFragment().PaintProperties(); EXPECT_TRUE(properties->Transform()->HasDirectCompositingReasons()); + Timing timing; + KeyframeEffectModelBase* effect = + StringKeyframeEffectModel::Create(StringKeyframeVector()); CompositorAnimations::FailureCode code = - CompositorAnimations::CheckCanStartElementOnCompositor(*target); + CompositorAnimations::CheckCanStartAnimationOnCompositor( + timing, *target, nullptr, *effect, 1.0); EXPECT_EQ( code, - CompositorAnimations::FailureCode::NotPaintIntoOwnBacking( + CompositorAnimations::FailureCode::AcceleratableAnimNotAccelerated( "Acceleratable animation not accelerated due to an experiment")); EXPECT_EQ(document->Timeline().PendingAnimationsCount(), 1u); EXPECT_EQ(document->Timeline().MainThreadCompositableAnimationsCount(), 1u); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/DocumentAnimations.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/DocumentAnimations.cpp index bc30d70017..61bc2de3e8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/DocumentAnimations.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/DocumentAnimations.cpp @@ -39,6 +39,7 @@ #include "core/dom/Node.h" #include "core/frame/LocalFrame.h" #include "core/frame/LocalFrameView.h" +#include "platform/animation/CompositorAnimationHost.h" namespace blink { @@ -85,8 +86,12 @@ void DocumentAnimations::UpdateAnimations( main_thread_compositable_animations_count = document.Timeline().MainThreadCompositableAnimationsCount(); } - host->SetAnimationCounts(total_animations_count, - main_thread_compositable_animations_count); + // In the CompositorTimingHistory::DidDraw where we know that there is + // visual update, we will use document.CurrentFrameHadRAF as a signal to + // record UMA or not. + host->SetAnimationCounts( + total_animations_count, main_thread_compositable_animations_count, + document.CurrentFrameHadRAF(), document.NextFrameHasPendingRAF()); } } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/DocumentTimeline.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/DocumentTimeline.cpp index 91d642fb68..252a1da90c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/DocumentTimeline.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/DocumentTimeline.cpp @@ -117,6 +117,7 @@ Animation* DocumentTimeline::Play(AnimationEffectReadOnly* child) { } HeapVector> DocumentTimeline::getAnimations() { + document_->UpdateStyleAndLayoutTree(); HeapVector> animations; for (const auto& animation : animations_) { if (animation->effect() && @@ -193,14 +194,20 @@ void DocumentTimeline::DocumentTimelineTiming::Trace(blink::Visitor* visitor) { size_t DocumentTimeline::MainThreadCompositableAnimationsCount() const { size_t main_thread_compositable_animations_count = 0; - // TODO(crbug.com/781305): Restore the calculation here. + for (Animation* animation : animations_needing_update_) { + if (animation->IsNonCompositedCompositable() && + animation->PlayStateInternal() != Animation::kFinished) + main_thread_compositable_animations_count++; + } return main_thread_compositable_animations_count; } double DocumentTimeline::ZeroTime() { if (!zero_time_initialized_ && document_ && document_->Loader()) { - zero_time_ = document_->Loader()->GetTiming().ReferenceMonotonicTime() + - origin_time_; + zero_time_ = + TimeTicksInSeconds( + document_->Loader()->GetTiming().ReferenceMonotonicTime()) + + origin_time_; zero_time_initialized_ = true; } return zero_time_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInput.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInput.cpp index 651cd1da54..1d14dc26e4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInput.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInput.cpp @@ -60,64 +60,53 @@ namespace { // Converts the composite property of a BasePropertyIndexedKeyframe into a // vector of EffectModel::CompositeOperation enums. -// -// If the composite property cannot be extracted or parsed for some reason, an -// exception will be thrown in |exception_state|. -Vector ParseCompositeProperty( - const BasePropertyIndexedKeyframe& keyframe, - ExceptionState& exception_state) { - const CompositeOperationOrCompositeOperationSequence& composite = +Vector> ParseCompositeProperty( + const BasePropertyIndexedKeyframe& keyframe) { + const CompositeOperationOrCompositeOperationOrNullSequence& composite = keyframe.composite(); + + // This handles the case where we have 'composite: null'. The null value is + // lifted to the union level in the bindings code. + if (composite.IsNull()) + return {WTF::nullopt}; + if (composite.IsCompositeOperation()) { - EffectModel::CompositeOperation composite_operation; - if (!EffectModel::StringToCompositeOperation( - composite.GetAsCompositeOperation(), composite_operation, - &exception_state)) { - DCHECK(exception_state.HadException()); - return {}; - } - return {composite_operation}; + return {EffectModel::StringToCompositeOperation( + composite.GetAsCompositeOperation())}; } - Vector result; + Vector> result; for (const String& composite_operation_string : - composite.GetAsCompositeOperationSequence()) { - EffectModel::CompositeOperation composite_operation; - if (!EffectModel::StringToCompositeOperation(composite_operation_string, - composite_operation, - &exception_state)) { - DCHECK(exception_state.HadException()); - return {}; + composite.GetAsCompositeOperationOrNullSequence()) { + if (composite_operation_string.IsNull()) { + result.push_back(WTF::nullopt); + } else { + result.push_back( + EffectModel::StringToCompositeOperation(composite_operation_string)); } - result.push_back(composite_operation); } return result; } -void SetKeyframeValue(Element& element, +void SetKeyframeValue(Element* element, + Document& document, StringKeyframe& keyframe, const String& property, const String& value, ExecutionContext* execution_context) { - StyleSheetContents* style_sheet_contents = - element.GetDocument().ElementSheet().Contents(); + StyleSheetContents* style_sheet_contents = document.ElementSheet().Contents(); CSSPropertyID css_property = - AnimationInputHelpers::KeyframeAttributeToCSSProperty( - property, element.GetDocument()); + AnimationInputHelpers::KeyframeAttributeToCSSProperty(property, document); if (css_property != CSSPropertyInvalid) { MutableCSSPropertyValueSet::SetResult set_result = css_property == CSSPropertyVariable ? keyframe.SetCSSPropertyValue( - AtomicString(property), - element.GetDocument().GetPropertyRegistry(), value, - element.GetDocument().GetSecureContextMode(), - style_sheet_contents) - : keyframe.SetCSSPropertyValue( - css_property, value, - element.GetDocument().GetSecureContextMode(), - style_sheet_contents); + AtomicString(property), document.GetPropertyRegistry(), value, + document.GetSecureContextMode(), style_sheet_contents) + : keyframe.SetCSSPropertyValue(css_property, value, + document.GetSecureContextMode(), + style_sheet_contents); if (!set_result.did_parse && execution_context) { - Document& document = ToDocument(*execution_context); if (document.GetFrame()) { document.GetFrame()->Console().AddMessage(ConsoleMessage::Create( kJSMessageSource, kWarningMessageLevel, @@ -131,8 +120,8 @@ void SetKeyframeValue(Element& element, element); if (css_property != CSSPropertyInvalid) { keyframe.SetPresentationAttributeValue( - CSSProperty::Get(css_property), value, - element.GetDocument().GetSecureContextMode(), style_sheet_contents); + CSSProperty::Get(css_property), value, document.GetSecureContextMode(), + style_sheet_contents); return; } const QualifiedName* svg_attribute = @@ -141,93 +130,79 @@ void SetKeyframeValue(Element& element, keyframe.SetSVGAttributeValue(*svg_attribute, value); } -KeyframeEffectModelBase* CreateEmptyEffectModel( - EffectModel::CompositeOperation composite) { - return StringKeyframeEffectModel::Create(StringKeyframeVector(), composite); -} +bool ValidatePartialKeyframes(const StringKeyframeVector& keyframes) { + // CSSAdditiveAnimationsEnabled guards both additive animations and allowing + // partial (implicit) keyframes. + if (RuntimeEnabledFeatures::CSSAdditiveAnimationsEnabled()) + return true; -KeyframeEffectModelBase* CreateEffectModel( - Element& element, - const StringKeyframeVector& keyframes, - EffectModel::CompositeOperation composite, - ExceptionState& exception_state) { - StringKeyframeEffectModel* keyframe_effect_model = - StringKeyframeEffectModel::Create(keyframes, composite, - LinearTimingFunction::Shared()); - if (!RuntimeEnabledFeatures::CSSAdditiveAnimationsEnabled()) { - for (const auto& keyframe_group : - keyframe_effect_model->GetPropertySpecificKeyframeGroups()) { - PropertyHandle property = keyframe_group.key; + // An implicit keyframe is inserted in the below cases. Note that the 'first' + // keyframe is actually all keyframes with offset 0.0, and the 'last' keyframe + // is actually all keyframes with offset 1.0. + // + // 1. A given property is present somewhere in the full set of keyframes, + // but is either not present in the first keyframe (requiring an implicit + // start value for that property) or last keyframe (requiring an implicit + // end value for that property). + // + // 2. There is no first keyframe (requiring an implicit start keyframe), or + // no last keyframe (requiring an implicit end keyframe). + // + // We only care about CSS properties here; animating SVG elements is protected + // by a different runtime flag. + + Vector computed_offsets = + KeyframeEffectModelBase::GetComputedOffsets(keyframes); + + PropertyHandleSet properties_with_offset_0; + PropertyHandleSet properties_with_offset_1; + for (size_t i = 0; i < keyframes.size(); i++) { + for (const PropertyHandle& property : keyframes[i]->Properties()) { if (!property.IsCSSProperty()) continue; - for (const auto& keyframe : keyframe_group.value->Keyframes()) { - if (keyframe->IsNeutral()) { - exception_state.ThrowDOMException( - kNotSupportedError, "Partial keyframes are not supported."); - return nullptr; - } - if (keyframe->Composite() != EffectModel::kCompositeReplace) { - exception_state.ThrowDOMException( - kNotSupportedError, "Additive animations are not supported."); - return nullptr; + if (computed_offsets[i] == 0.0) { + properties_with_offset_0.insert(property); + } else { + if (!properties_with_offset_0.Contains(property)) + return false; + if (computed_offsets[i] == 1.0) { + properties_with_offset_1.insert(property); } } } } - DCHECK(!exception_state.HadException()); - return keyframe_effect_model; + // At this point we have compared all keyframes with offset > 0 against the + // properties contained in the first keyframe, and found that they match. Now + // we just need to make sure that there aren't any properties in the first + // keyframe that aren't in the last keyframe. + return properties_with_offset_0.size() == properties_with_offset_1.size(); } -} // namespace - -// Implements "Processing a keyframes argument" from the web-animations spec. -// https://drafts.csswg.org/web-animations/#processing-a-keyframes-argument -KeyframeEffectModelBase* EffectInput::Convert( - Element* element, - const ScriptValue& keyframes, - EffectModel::CompositeOperation effect_composite, - ScriptState* script_state, - ExceptionState& exception_state) { - // Per the spec, a null keyframes object maps to a valid but empty sequence. - // TODO(crbug.com/772014): The element is allowed to be null; remove check. - if (keyframes.IsNull() || !element) - return CreateEmptyEffectModel(effect_composite); - - v8::Isolate* isolate = script_state->GetIsolate(); - Dictionary dictionary(isolate, keyframes.V8Value(), exception_state); - if (exception_state.HadException()) - return nullptr; - - KeyframeEffectModelBase* model; - DictionaryIterator iterator = - dictionary.GetIterator(ExecutionContext::From(script_state)); - if (iterator.IsNull()) { - model = ConvertObjectForm(*element, dictionary, effect_composite, - script_state, exception_state); - } else { - model = ConvertArrayForm(*element, iterator, effect_composite, script_state, - exception_state); +// Ensures that a CompositeOperation is of an allowed value for a given +// StringKeyframe and the current runtime flags. +EffectModel::CompositeOperation ResolveCompositeOperationForKeyframe( + EffectModel::CompositeOperation composite, + const scoped_refptr& keyframe) { + if (!RuntimeEnabledFeatures::CSSAdditiveAnimationsEnabled() && + keyframe->HasCssProperty() && composite == EffectModel::kCompositeAdd) { + return EffectModel::kCompositeReplace; } - - DCHECK(model || exception_state.HadException()); - return model; + return composite; } -namespace { +// Temporary storage struct used when converting array-form keyframes. struct KeyframeOutput { BaseKeyframe base_keyframe; Vector> property_value_pairs; }; -} // namespace -KeyframeEffectModelBase* EffectInput::ConvertArrayForm( - Element& element, - DictionaryIterator iterator, - EffectModel::CompositeOperation effect_composite, - ScriptState* script_state, - ExceptionState& exception_state) { +StringKeyframeVector ConvertArrayForm(Element* element, + Document& document, + DictionaryIterator iterator, + ScriptState* script_state, + ExceptionState& exception_state) { // This loop captures step 5 of the procedure to process a keyframes argument, // in the case where the argument is iterable. Vector processed_keyframes; @@ -239,7 +214,7 @@ KeyframeEffectModelBase* EffectInput::ConvertArrayForm( Dictionary keyframe_dictionary; if (!iterator.ValueAsDictionary(keyframe_dictionary, exception_state)) { exception_state.ThrowTypeError("Keyframes must be objects."); - return nullptr; + return {}; } // Extract the offset, easing, and composite as per step 1 of the 'procedure @@ -248,12 +223,12 @@ KeyframeEffectModelBase* EffectInput::ConvertArrayForm( keyframe_dictionary.V8Value(), keyframe_output.base_keyframe, exception_state); if (exception_state.HadException()) - return nullptr; + return {}; const Vector& keyframe_properties = keyframe_dictionary.GetPropertyNames(exception_state); if (exception_state.HadException()) - return nullptr; + return {}; for (const auto& property : keyframe_properties) { if (property == "offset" || property == "composite" || @@ -267,26 +242,26 @@ KeyframeEffectModelBase* EffectInput::ConvertArrayForm( v8::Local v8_value; if (!keyframe_dictionary.Get(property, v8_value)) { // TODO(crbug.com/666661): Propagate exceptions from Dictionary::Get. - return CreateEmptyEffectModel(effect_composite); + return {}; } if (v8_value->IsArray()) { exception_state.ThrowTypeError( "Lists of values not permitted in array-form list of keyframes"); - return nullptr; + return {}; } String string_value = NativeValueTraits::NativeValue( isolate, v8_value, exception_state); if (exception_state.HadException()) - return nullptr; + return {}; keyframe_output.property_value_pairs.push_back( std::make_pair(property, string_value)); } processed_keyframes.push_back(keyframe_output); } if (exception_state.HadException()) - return nullptr; + return {}; // 6. If processed keyframes is not loosely sorted by offset, throw a // TypeError and abort these steps. @@ -297,7 +272,7 @@ KeyframeEffectModelBase* EffectInput::ConvertArrayForm( if (offset < previous_offset) { exception_state.ThrowTypeError( "Offsets must be montonically non-decreasing."); - return nullptr; + return {}; } previous_offset = offset; } @@ -312,7 +287,7 @@ KeyframeEffectModelBase* EffectInput::ConvertArrayForm( if (offset < 0 || offset > 1) { exception_state.ThrowTypeError( "Offsets must be null or in the range [0,1]."); - return nullptr; + return {}; } } } @@ -327,22 +302,19 @@ KeyframeEffectModelBase* EffectInput::ConvertArrayForm( keyframe->SetOffset(processed_keyframe.base_keyframe.offset()); } - if (processed_keyframe.base_keyframe.hasComposite()) { - EffectModel::CompositeOperation composite_operation; - if (!EffectModel::StringToCompositeOperation( - processed_keyframe.base_keyframe.composite(), composite_operation, - &exception_state)) { - return nullptr; - } - keyframe->SetComposite(composite_operation); - } - // 8.1. For each property-value pair in frame, parse the property value // using the syntax specified for that property. for (const auto& pair : processed_keyframe.property_value_pairs) { // TODO(crbug.com/777971): Make parsing of property values spec-compliant. - SetKeyframeValue(element, *keyframe.get(), pair.first, pair.second, - execution_context); + SetKeyframeValue(element, document, *keyframe.get(), pair.first, + pair.second, execution_context); + } + + if (processed_keyframe.base_keyframe.hasComposite()) { + keyframe->SetComposite(ResolveCompositeOperationForKeyframe( + EffectModel::StringToCompositeOperation( + processed_keyframe.base_keyframe.composite()), + keyframe)); } // 8.2. Let the timing function of frame be the result of parsing the @@ -353,19 +325,17 @@ KeyframeEffectModelBase* EffectInput::ConvertArrayForm( // procedure. scoped_refptr timing_function = AnimationInputHelpers::ParseTimingFunction( - processed_keyframe.base_keyframe.easing(), &element.GetDocument(), + processed_keyframe.base_keyframe.easing(), &document, exception_state); if (!timing_function) - return nullptr; + return {}; keyframe->SetEasing(timing_function); keyframes.push_back(keyframe); } DCHECK(!exception_state.HadException()); - - return CreateEffectModel(element, keyframes, effect_composite, - exception_state); + return keyframes; } // Extracts the values for a given property in the input keyframes. As per the @@ -382,8 +352,10 @@ static bool GetPropertyIndexedKeyframeValues( // By spec, we are only allowed to access a given (property, value) pair once. // This is observable by the web client, so we take care to adhere to that. v8::Local v8_value; - if (!keyframe_dictionary.Get(property, v8_value)) + if (!keyframe_dictionary.Get(property, v8_value)) { + // TODO(crbug.com/666661): Get() should rethrow internal exceptions. return false; + } StringOrStringSequence string_or_string_sequence; V8StringOrStringSequence::ToImpl( @@ -404,12 +376,11 @@ static bool GetPropertyIndexedKeyframeValues( // web-animations spec for an object form keyframes argument. // // See https://drafts.csswg.org/web-animations/#processing-a-keyframes-argument -KeyframeEffectModelBase* EffectInput::ConvertObjectForm( - Element& element, - const Dictionary& dictionary, - EffectModel::CompositeOperation effect_composite, - ScriptState* script_state, - ExceptionState& exception_state) { +StringKeyframeVector ConvertObjectForm(Element* element, + Document& document, + const Dictionary& dictionary, + ScriptState* script_state, + ExceptionState& exception_state) { // We implement much of this procedure out of order from the way the spec is // written, to avoid repeatedly going over the list of keyframes. // The web-observable behavior should be the same as the spec. @@ -421,7 +392,7 @@ KeyframeEffectModelBase* EffectInput::ConvertObjectForm( dictionary.GetIsolate(), dictionary.V8Value(), property_indexed_keyframe, exception_state); if (exception_state.HadException()) - return nullptr; + return {}; Vector> offsets; if (property_indexed_keyframe.offset().IsNull()) @@ -439,10 +410,8 @@ KeyframeEffectModelBase* EffectInput::ConvertObjectForm( else easings = property_indexed_keyframe.easing().GetAsStringSequence(); - Vector composite_operations = - ParseCompositeProperty(property_indexed_keyframe, exception_state); - if (exception_state.HadException()) - return nullptr; + Vector> composite_operations = + ParseCompositeProperty(property_indexed_keyframe); // Next extract all animatable properties from the input argument and iterate // through them, processing each as a list of values for that property. This @@ -452,7 +421,7 @@ KeyframeEffectModelBase* EffectInput::ConvertObjectForm( const Vector& keyframe_properties = dictionary.GetPropertyNames(exception_state); if (exception_state.HadException()) - return nullptr; + return {}; // Steps 5.2 - 5.4 state that the user agent is to: // @@ -473,10 +442,7 @@ KeyframeEffectModelBase* EffectInput::ConvertObjectForm( Vector values; if (!GetPropertyIndexedKeyframeValues(dictionary, property, script_state, exception_state, values)) { - // TODO(crbug.com/666661): Propagate exceptions from Dictionary::Get. - if (exception_state.HadException()) - return nullptr; - return CreateEmptyEffectModel(effect_composite); + return {}; } // Now create a keyframe (or retrieve and augment an existing one) for each @@ -497,8 +463,8 @@ KeyframeEffectModelBase* EffectInput::ConvertObjectForm( if (result.is_new_entry) result.stored_value->value = StringKeyframe::Create(); - SetKeyframeValue(element, *result.stored_value->value.get(), property, - values[i], execution_context); + SetKeyframeValue(element, document, *result.stored_value->value.get(), + property, values[i], execution_context); } } @@ -533,7 +499,7 @@ KeyframeEffectModelBase* EffectInput::ConvertObjectForm( if (offset.value() < previous_offset) { exception_state.ThrowTypeError( "Offsets must be montonically non-decreasing."); - return nullptr; + return {}; } previous_offset = offset.value(); } @@ -544,7 +510,7 @@ KeyframeEffectModelBase* EffectInput::ConvertObjectForm( if (offset.has_value() && (offset.value() < 0 || offset.value() > 1)) { exception_state.ThrowTypeError( "Offsets must be null or in the range [0,1]."); - return nullptr; + return {}; } keyframe->SetOffset(offset); @@ -566,10 +532,10 @@ KeyframeEffectModelBase* EffectInput::ConvertObjectForm( // If parsing the “easing” property fails, throw a TypeError and abort // this procedure. scoped_refptr timing_function = - AnimationInputHelpers::ParseTimingFunction( - easing, &element.GetDocument(), exception_state); + AnimationInputHelpers::ParseTimingFunction(easing, &document, + exception_state); if (!timing_function) - return nullptr; + return {}; keyframe->SetEasing(timing_function); } @@ -579,8 +545,12 @@ KeyframeEffectModelBase* EffectInput::ConvertObjectForm( // property keyframes, repeat the elements in composite modes successively // starting from the beginning of the list until composite modes has as // many items as property keyframes. - keyframe->SetComposite( - composite_operations[i % composite_operations.size()]); + WTF::Optional composite = + composite_operations[i % composite_operations.size()]; + if (composite) { + keyframe->SetComposite( + ResolveCompositeOperationForKeyframe(composite.value(), keyframe)); + } } results.push_back(keyframe); @@ -597,15 +567,107 @@ KeyframeEffectModelBase* EffectInput::ConvertObjectForm( // procedure. for (size_t i = results.size(); i < easings.size(); i++) { scoped_refptr timing_function = - AnimationInputHelpers::ParseTimingFunction( - easings[i], &element.GetDocument(), exception_state); + AnimationInputHelpers::ParseTimingFunction(easings[i], &document, + exception_state); if (!timing_function) - return nullptr; + return {}; } DCHECK(!exception_state.HadException()); + return results; +} - return CreateEffectModel(element, results, effect_composite, exception_state); +bool HasAdditiveCompositeCSSKeyframe( + const KeyframeEffectModelBase::KeyframeGroupMap& keyframe_groups) { + for (const auto& keyframe_group : keyframe_groups) { + PropertyHandle property = keyframe_group.key; + if (!property.IsCSSProperty()) + continue; + for (const auto& keyframe : keyframe_group.value->Keyframes()) { + if (keyframe->Composite() == EffectModel::kCompositeAdd) + return true; + } + } + return false; } +} // namespace +KeyframeEffectModelBase* EffectInput::Convert( + Element* element, + const ScriptValue& keyframes, + EffectModel::CompositeOperation composite, + ScriptState* script_state, + ExceptionState& exception_state) { + StringKeyframeVector parsed_keyframes = + ParseKeyframesArgument(element, keyframes, script_state, exception_state); + if (exception_state.HadException()) + return nullptr; + + composite = ResolveCompositeOperation(composite, parsed_keyframes); + + StringKeyframeEffectModel* keyframe_effect_model = + StringKeyframeEffectModel::Create(parsed_keyframes, composite, + LinearTimingFunction::Shared()); + + if (!RuntimeEnabledFeatures::CSSAdditiveAnimationsEnabled()) { + // This should be enforced by the parsing code. + DCHECK(!HasAdditiveCompositeCSSKeyframe( + keyframe_effect_model->GetPropertySpecificKeyframeGroups())); + } + + DCHECK(!exception_state.HadException()); + return keyframe_effect_model; +} + +StringKeyframeVector EffectInput::ParseKeyframesArgument( + Element* element, + const ScriptValue& keyframes, + ScriptState* script_state, + ExceptionState& exception_state) { + // Per the spec, a null keyframes object maps to a valid but empty sequence. + if (keyframes.IsNull()) + return {}; + + v8::Isolate* isolate = script_state->GetIsolate(); + Dictionary dictionary(isolate, keyframes.V8Value(), exception_state); + if (exception_state.HadException()) + return {}; + + // TODO(crbug.com/816934): Get spec to specify what parsing context to use. + Document& document = element + ? element->GetDocument() + : *ToDocument(ExecutionContext::From(script_state)); + + StringKeyframeVector parsed_keyframes; + DictionaryIterator iterator = + dictionary.GetIterator(ExecutionContext::From(script_state)); + if (iterator.IsNull()) { + parsed_keyframes = ConvertObjectForm(element, document, dictionary, + script_state, exception_state); + } else { + parsed_keyframes = ConvertArrayForm(element, document, iterator, + script_state, exception_state); + } + + if (!ValidatePartialKeyframes(parsed_keyframes)) { + exception_state.ThrowDOMException(kNotSupportedError, + "Partial keyframes are not supported."); + return {}; + } + return parsed_keyframes; +} + +EffectModel::CompositeOperation EffectInput::ResolveCompositeOperation( + EffectModel::CompositeOperation composite, + const StringKeyframeVector& keyframes) { + EffectModel::CompositeOperation result = composite; + for (const scoped_refptr& keyframe : keyframes) { + // Replace is always supported, so we can early-exit if and when we have + // that as our composite value. + if (result == EffectModel::kCompositeReplace) + break; + result = ResolveCompositeOperationForKeyframe(result, keyframe); + } + return result; +} } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInput.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInput.h index a083b5aced..149fc37de7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInput.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInput.h @@ -7,14 +7,12 @@ #include "core/CoreExport.h" #include "core/animation/EffectModel.h" +#include "core/animation/KeyframeEffectModel.h" #include "platform/wtf/Allocator.h" #include "platform/wtf/Vector.h" namespace blink { -class KeyframeEffectModelBase; -class Dictionary; -class DictionaryIterator; class Element; class ExceptionState; class ScriptState; @@ -24,27 +22,28 @@ class CORE_EXPORT EffectInput { STATIC_ONLY(EffectInput); public: - // TODO(alancutter): Replace Element* parameter with Document&. - static KeyframeEffectModelBase* Convert( + static KeyframeEffectModelBase* Convert(Element*, + const ScriptValue& keyframes, + EffectModel::CompositeOperation, + ScriptState*, + ExceptionState&); + + // Implements "Processing a keyframes argument" from the web-animations spec. + // https://drafts.csswg.org/web-animations/#processing-a-keyframes-argument + static StringKeyframeVector ParseKeyframesArgument( Element*, const ScriptValue& keyframes, - EffectModel::CompositeOperation effect_composite, ScriptState*, ExceptionState&); - private: - static KeyframeEffectModelBase* ConvertArrayForm( - Element&, - DictionaryIterator keyframes, - EffectModel::CompositeOperation effect_composite, - ScriptState*, - ExceptionState&); - static KeyframeEffectModelBase* ConvertObjectForm( - Element&, - const Dictionary& keyframe, - EffectModel::CompositeOperation effect_composite, - ScriptState*, - ExceptionState&); + // Ensures that a CompositeOperation is of an allowed value for a set of + // StringKeyframes and the current runtime flags. + // + // Under certain runtime flags, additive composite operations are not allowed + // for CSS properties. + static EffectModel::CompositeOperation ResolveCompositeOperation( + EffectModel::CompositeOperation, + const StringKeyframeVector&); }; } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInputTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInputTest.cpp index c69b8f25dc..de1e7d83c5 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInputTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectInputTest.cpp @@ -20,7 +20,7 @@ namespace blink { Element* AppendElement(Document& document) { - Element* element = document.createElement("foo"); + Element* element = document.CreateElementForBinding("foo"); document.documentElement()->AppendChild(element); return element; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectModel.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectModel.cpp index cfbd18c645..c6825038c4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectModel.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectModel.cpp @@ -9,41 +9,17 @@ #include "platform/runtime_enabled_features.h" namespace blink { -EffectModel::CompositeOperation EffectModel::ExtractCompositeOperation( - const KeyframeEffectOptions& options) { - // We have to be careful to keep backwards compatible behavior here; no valid - // value of KeyframeEffectOptions should throw, even if it is unsupported in - // Chrome currently. Values we do not support should just be turned into - // kCompositeReplace. - // - // See http://crbug.com/806139. - if (RuntimeEnabledFeatures::CSSAdditiveAnimationsEnabled() && - options.composite() == "add") { +EffectModel::CompositeOperation EffectModel::StringToCompositeOperation( + const String& composite_string) { + DCHECK(composite_string == "replace" || composite_string == "add" || + composite_string == "accumulate"); + if (composite_string == "add") { return kCompositeAdd; } + // TODO(crbug.com/788440): Support accumulate. return kCompositeReplace; } -bool EffectModel::StringToCompositeOperation(String composite_string, - CompositeOperation& result, - ExceptionState* exception_state) { - // TODO(crbug.com/788440): Once all CompositeOperations are supported we can - // just DCHECK the input and directly convert it instead of handling failure. - if (composite_string == "add") { - result = kCompositeAdd; - return true; - } - if (composite_string == "replace") { - result = kCompositeReplace; - return true; - } - if (exception_state) { - exception_state->ThrowTypeError("Invalid composite value: '" + - composite_string + "'"); - } - return false; -} - String EffectModel::CompositeOperationToString(CompositeOperation composite) { switch (composite) { case EffectModel::kCompositeAdd: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectModel.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectModel.h index e86b3de96f..e808be9958 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectModel.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectModel.h @@ -39,9 +39,7 @@ namespace blink { -class ExceptionState; class Interpolation; -class KeyframeEffectOptions; // Time independent representation of an Animation's content. // Can be sampled for the active pairs of Keyframes (represented by @@ -52,13 +50,7 @@ class CORE_EXPORT EffectModel : public GarbageCollectedFinalized { kCompositeReplace, kCompositeAdd, }; - // Returns the correct CompositeOperation for a KeyframeEffectOptions, - // respecting any relevant RuntimeFeatures that are enabled or disabled. - static CompositeOperation ExtractCompositeOperation( - const KeyframeEffectOptions&); - static bool StringToCompositeOperation(String, - CompositeOperation&, - ExceptionState* = nullptr); + static CompositeOperation StringToCompositeOperation(const String&); static String CompositeOperationToString(CompositeOperation); EffectModel() = default; @@ -69,6 +61,7 @@ class CORE_EXPORT EffectModel : public GarbageCollectedFinalized { Vector>&) const = 0; virtual bool Affects(const PropertyHandle&) const { return false; } + virtual bool AffectedByUnderlyingAnimations() const = 0; virtual bool IsTransformRelatedEffect() const { return false; } virtual bool IsKeyframeEffectModel() const { return false; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectStack.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectStack.cpp index 9d35658bbb..ce1a1c659f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectStack.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectStack.cpp @@ -90,10 +90,8 @@ EffectStack::EffectStack() = default; bool EffectStack::HasActiveAnimationsOnCompositor( const PropertyHandle& property) const { for (const auto& sampled_effect : sampled_effects_) { - // TODO(dstockwell): move the playing check into AnimationEffectReadOnly and - // expose both hasAnimations and hasActiveAnimations if (sampled_effect->Effect() && - sampled_effect->Effect()->GetAnimation()->Playing() && + sampled_effect->Effect()->HasPlayingAnimation() && sampled_effect->Effect()->HasActiveAnimationsOnCompositor(property)) return true; } @@ -127,6 +125,8 @@ ActiveInterpolationsMap EffectStack::ActiveInterpolations( effect_stack->RemoveRedundantSampledEffects(); for (const auto& sampled_effect : sampled_effects) { if (sampled_effect->GetPriority() != priority || + // TODO(majidvp): Instead of accessing the effect's animation move the + // check inside KeyframeEffectReadOnly. http://crbug.com/812410 (suppressed_animations && sampled_effect->Effect() && suppressed_animations->Contains( sampled_effect->Effect()->GetAnimation()))) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectStackTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectStackTest.cpp index 1e02d2459e..81cecf9027 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectStackTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/EffectStackTest.cpp @@ -25,7 +25,7 @@ class AnimationEffectStackTest : public PageTestBase { PageTestBase::SetUp(IntSize()); GetDocument().GetAnimationClock().ResetTimeForTesting(); timeline = DocumentTimeline::Create(&GetDocument()); - element = GetDocument().createElement("foo"); + element = GetDocument().CreateElementForBinding("foo"); } Animation* Play(KeyframeEffect* effect, double start_time) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimation.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimation.cpp index 5dd8f80193..037b9777c8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimation.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimation.cpp @@ -28,8 +28,8 @@ Animation* ElementAnimation::animate( ExceptionState& exception_state) { EffectModel::CompositeOperation composite = EffectModel::kCompositeReplace; if (options.IsKeyframeAnimationOptions()) { - composite = EffectModel::ExtractCompositeOperation( - options.GetAsKeyframeAnimationOptions()); + composite = EffectModel::StringToCompositeOperation( + options.GetAsKeyframeAnimationOptions().composite()); } KeyframeEffectModelBase* effect = EffectInput::Convert( @@ -62,15 +62,16 @@ Animation* ElementAnimation::animate(ScriptState* script_state, HeapVector> ElementAnimation::getAnimations( Element& element) { - HeapVector> animations; + element.GetDocument().UpdateStyleAndLayoutTreeForNode(&element); + HeapVector> animations; if (!element.HasAnimations()) return animations; for (const auto& animation : element.GetDocument().Timeline().getAnimations()) { DCHECK(animation->effect()); - if (ToKeyframeEffectReadOnly(animation->effect())->Target() == element && + if (ToKeyframeEffectReadOnly(animation->effect())->target() == element && (animation->effect()->IsCurrent() || animation->effect()->IsInEffect())) animations.push_back(animation); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimations.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimations.cpp index b933aab293..e2c2c94ffd 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimations.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimations.cpp @@ -34,6 +34,25 @@ namespace blink { +namespace { + +void UpdateAnimationFlagsForEffect(const KeyframeEffectReadOnly& effect, + ComputedStyle& style) { + if (effect.Affects(PropertyHandle(GetCSSPropertyOpacity()))) + style.SetHasCurrentOpacityAnimation(true); + if (effect.Affects(PropertyHandle(GetCSSPropertyTransform())) || + effect.Affects(PropertyHandle(GetCSSPropertyRotate())) || + effect.Affects(PropertyHandle(GetCSSPropertyScale())) || + effect.Affects(PropertyHandle(GetCSSPropertyTranslate()))) + style.SetHasCurrentTransformAnimation(true); + if (effect.Affects(PropertyHandle(GetCSSPropertyFilter()))) + style.SetHasCurrentFilterAnimation(true); + if (effect.Affects(PropertyHandle(GetCSSPropertyBackdropFilter()))) + style.SetHasCurrentBackdropFilterAnimation(true); +} + +} // namespace + ElementAnimations::ElementAnimations() : animation_style_change_(false) {} ElementAnimations::~ElementAnimations() = default; @@ -46,19 +65,17 @@ void ElementAnimations::UpdateAnimationFlags(ComputedStyle& style) { DCHECK(animation.effect()->IsKeyframeEffectReadOnly()); const KeyframeEffectReadOnly& effect = *ToKeyframeEffectReadOnly(animation.effect()); - if (effect.IsCurrent()) { - if (effect.Affects(PropertyHandle(GetCSSPropertyOpacity()))) - style.SetHasCurrentOpacityAnimation(true); - if (effect.Affects(PropertyHandle(GetCSSPropertyTransform())) || - effect.Affects(PropertyHandle(GetCSSPropertyRotate())) || - effect.Affects(PropertyHandle(GetCSSPropertyScale())) || - effect.Affects(PropertyHandle(GetCSSPropertyTranslate()))) - style.SetHasCurrentTransformAnimation(true); - if (effect.Affects(PropertyHandle(GetCSSPropertyFilter()))) - style.SetHasCurrentFilterAnimation(true); - if (effect.Affects(PropertyHandle(GetCSSPropertyBackdropFilter()))) - style.SetHasCurrentBackdropFilterAnimation(true); - } + if (!effect.IsCurrent()) + continue; + UpdateAnimationFlagsForEffect(effect, style); + } + + for (const auto& entry : worklet_animations_) { + const KeyframeEffectReadOnly& effect = *entry->GetEffect(); + // TODO(majidvp): we should check the effect's phase before updating the + // style once the timing of effect is ready to use. + // https://crbug.com/814851. + UpdateAnimationFlagsForEffect(effect, style); } if (style.HasCurrentOpacityAnimation()) { @@ -92,6 +109,7 @@ void ElementAnimations::Trace(blink::Visitor* visitor) { visitor->Trace(css_animations_); visitor->Trace(effect_stack_); visitor->Trace(animations_); + visitor->Trace(worklet_animations_); } const ComputedStyle* ElementAnimations::BaseComputedStyle() const { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimations.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimations.h index 65f709b11a..ce575eaefb 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimations.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ElementAnimations.h @@ -34,6 +34,7 @@ #include "base/macros.h" #include "base/memory/scoped_refptr.h" #include "core/animation/EffectStack.h" +#include "core/animation/WorkletAnimationBase.h" #include "core/animation/css/CSSAnimations.h" #include "platform/wtf/HashCountedSet.h" #include "platform/wtf/HashMap.h" @@ -43,8 +44,10 @@ namespace blink { class CSSAnimations; using AnimationCountedSet = HeapHashCountedSet>; +using WorkletAnimationSet = HeapHashSet>; -class ElementAnimations : public GarbageCollectedFinalized { +class CORE_EXPORT ElementAnimations + : public GarbageCollectedFinalized { public: ElementAnimations(); ~ElementAnimations(); @@ -62,6 +65,8 @@ class ElementAnimations : public GarbageCollectedFinalized { // Animations which have effects targeting this element. AnimationCountedSet& Animations() { return animations_; } + // Worklet Animations which have effects targeting this element. + WorkletAnimationSet& GetWorkletAnimations() { return worklet_animations_; } bool IsEmpty() const { return effect_stack_.IsEmpty() && css_animations_.IsEmpty() && @@ -87,6 +92,7 @@ class ElementAnimations : public GarbageCollectedFinalized { EffectStack effect_stack_; CSSAnimations css_animations_; AnimationCountedSet animations_; + WorkletAnimationSet worklet_animations_; bool animation_style_change_; scoped_refptr base_computed_style_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ImageSlicePropertyFunctions.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ImageSlicePropertyFunctions.h index ec40271628..f3f273e74a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ImageSlicePropertyFunctions.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ImageSlicePropertyFunctions.h @@ -30,7 +30,7 @@ class ImageSlicePropertyFunctions { switch (property.PropertyID()) { default: NOTREACHED(); - // Fall through. + FALLTHROUGH; case CSSPropertyBorderImageSlice: return ImageSlice(style.BorderImageSlices(), style.BorderImageSlicesFill()); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/InertEffect.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/InertEffect.cpp index daf30704ca..efeb7c56b3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/InertEffect.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/InertEffect.cpp @@ -59,8 +59,8 @@ void InertEffect::Sample(Vector>& result) const { double iteration = CurrentIteration(); DCHECK_GE(iteration, 0); - model_->Sample(clampTo(iteration, 0), Progress(), IterationDuration(), - result); + model_->Sample(clampTo(iteration, 0), Progress().value(), + IterationDuration(), result); } double InertEffect::CalculateTimeToEffectChange(bool, double, double) const { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Keyframe.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Keyframe.cpp index 92d1397bff..55991dbbfa 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Keyframe.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Keyframe.cpp @@ -28,18 +28,13 @@ void Keyframe::AddKeyframePropertiesToV8Object( object_builder.AddNull("offset"); } object_builder.Add("easing", easing_->ToString()); - if (composite_.has_value()) { + if (composite_) { object_builder.AddString( "composite", EffectModel::CompositeOperationToString(composite_.value())); + } else { + object_builder.AddNull("composite"); } } -bool Keyframe::CompareOffsets(const scoped_refptr& a, - const scoped_refptr& b) { - if (!a->Offset() || !b->Offset()) - return false; - return a->CheckedOffset() < b->CheckedOffset(); -} - } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Keyframe.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Keyframe.h index 8e2c516087..0d0211f20c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Keyframe.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Keyframe.h @@ -35,10 +35,10 @@ class V8ObjectBuilder; // * A non-null timing function, which applies to the period of time between // this keyframe and the next keyframe in the same effect and influences // the interpolation between them. -// * An optional keyframe-specific composite operation, which specifies a -// specific composite operation used to combine values in this keyframe -// with an underlying value. If this is missing, the keyframe effect -// composite operation is used instead. +// * An possibly-null keyframe-specific composite operation, which specifies a +// specific composite operation used to combine values in this keyframe with +// an underlying value. If this is null, the keyframe effect composite +// operation is used instead. // // For spec details, refer to: http://w3c.github.io/web-animations/#keyframe // @@ -186,10 +186,6 @@ class CORE_EXPORT Keyframe : public RefCounted { EffectModel::CompositeOperation effect_composite, double offset) const = 0; - // Comparator function for sorting Keyframes based on their offsets. - static bool CompareOffsets(const scoped_refptr&, - const scoped_refptr&); - protected: Keyframe() : offset_(), composite_(), easing_(LinearTimingFunction::Shared()) {} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.cpp index 51746ceb95..900c1fc3f5 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.cpp @@ -71,15 +71,14 @@ KeyframeEffect* KeyframeEffect::Create( EffectModel::CompositeOperation composite = EffectModel::kCompositeReplace; if (options.IsKeyframeEffectOptions()) { - composite = EffectModel::ExtractCompositeOperation( - options.GetAsKeyframeEffectOptions()); + composite = EffectModel::StringToCompositeOperation( + options.GetAsKeyframeEffectOptions().composite()); } KeyframeEffectModelBase* model = EffectInput::Convert( element, keyframes, composite, script_state, exception_state); if (exception_state.HadException()) return nullptr; - return Create(element, model, timing); } @@ -106,7 +105,7 @@ KeyframeEffect* KeyframeEffect::Create(ScriptState* script_state, ExceptionState& exception_state) { Timing new_timing = source->SpecifiedTiming(); KeyframeEffectModelBase* model = source->Model()->Clone(); - return new KeyframeEffect(source->Target(), model, new_timing, + return new KeyframeEffect(source->target(), model, new_timing, source->GetPriority(), source->GetEventDelegate()); } @@ -120,9 +119,32 @@ KeyframeEffect::KeyframeEffect(Element* target, KeyframeEffect::~KeyframeEffect() = default; void KeyframeEffect::setComposite(String composite_string) { - EffectModel::CompositeOperation composite; - if (EffectModel::StringToCompositeOperation(composite_string, composite)) - Model()->SetComposite(composite); + Model()->SetComposite( + EffectModel::StringToCompositeOperation(composite_string)); +} + +void KeyframeEffect::setKeyframes(ScriptState* script_state, + const ScriptValue& keyframes, + ExceptionState& exception_state) { + // TODO(crbug.com/799061): Support TransitionKeyframeEffectModel. This will + // require a lot of work as the setKeyframes API can mutate a transition + // Animation into a 'normal' one with multiple properties. + if (!Model()->IsStringKeyframeEffectModel()) { + exception_state.ThrowDOMException( + kNotSupportedError, + "Calling setKeyframes on CSS Transitions is not yet supported"); + return; + } + + StringKeyframeVector new_keyframes = EffectInput::ParseKeyframesArgument( + target(), keyframes, script_state, exception_state); + if (exception_state.HadException()) + return; + + Model()->SetComposite(EffectInput::ResolveCompositeOperation( + Model()->Composite(), new_keyframes)); + + ToStringKeyframeEffectModel(Model())->SetFrames(new_keyframes); } AnimationEffectTiming* KeyframeEffect::timing() { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.h index 7e1db593a0..cf9966f78f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.h @@ -73,6 +73,9 @@ class CORE_EXPORT KeyframeEffect final : public KeyframeEffectReadOnly { // IDL implementation. void setComposite(String); + void setKeyframes(ScriptState*, + const ScriptValue& keyframes, + ExceptionState&); bool IsKeyframeEffect() const override { return true; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.idl index 53c9df7fde..ee6b903513 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffect.idl @@ -38,4 +38,5 @@ RuntimeEnabled=WebAnimationsAPI ] interface KeyframeEffect : KeyframeEffectReadOnly { inherit attribute CompositeOperation composite; + [CallWith=ScriptState, RaisesException] void setKeyframes(object? keyframes); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp index 9453df5bbf..3d435fb60c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp @@ -54,21 +54,27 @@ PropertyHandleSet KeyframeEffectModelBase::Properties() const { return result; } -void KeyframeEffectModelBase::SetFrames(KeyframeVector& keyframes) { +template +void KeyframeEffectModelBase::SetFrames(Vector& keyframes) { // TODO(samli): Should also notify/invalidate the animation - keyframes_ = keyframes; + keyframes_.clear(); keyframe_groups_ = nullptr; interpolation_effect_.Clear(); last_fraction_ = std::numeric_limits::quiet_NaN(); + keyframes_.AppendVector(keyframes); } +template CORE_EXPORT void KeyframeEffectModelBase::SetFrames( + Vector>& keyframes); +template CORE_EXPORT void KeyframeEffectModelBase::SetFrames( + Vector>& keyframes); + bool KeyframeEffectModelBase::Sample( int iteration, double fraction, double iteration_duration, Vector>& result) const { DCHECK_GE(iteration, 0); - DCHECK(!IsNull(fraction)); EnsureKeyframeGroups(); EnsureInterpolationEffectPopulated(); @@ -152,8 +158,9 @@ bool KeyframeEffectModelBase::SnapshotAllCompositorKeyframes( return updated; } +template Vector KeyframeEffectModelBase::GetComputedOffsets( - const KeyframeVector& keyframes) { + const Vector& keyframes) { // To avoid having to create two vectors when converting from the nullable // offsets to the non-nullable computed offsets, we keep the convention in // this function that std::numeric_limits::quiet_NaN() represents null. @@ -199,6 +206,11 @@ Vector KeyframeEffectModelBase::GetComputedOffsets( return result; } +template CORE_EXPORT Vector KeyframeEffectModelBase::GetComputedOffsets( + const Vector>& keyframes); +template CORE_EXPORT Vector KeyframeEffectModelBase::GetComputedOffsets( + const Vector>& keyframes); + bool KeyframeEffectModelBase::IsTransformRelatedEffect() const { return Affects(PropertyHandle(GetCSSPropertyTransform())) || Affects(PropertyHandle(GetCSSPropertyRotate())) || @@ -291,7 +303,7 @@ void KeyframeEffectModelBase::EnsureInterpolationEffectPopulated() const { interpolation_effect_.SetPopulated(); } -bool KeyframeEffectModelBase::IsReplaceOnly() { +bool KeyframeEffectModelBase::IsReplaceOnly() const { EnsureKeyframeGroups(); for (const auto& entry : *keyframe_groups_) { for (const auto& keyframe : entry.value->Keyframes()) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModel.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModel.h index 6c4dc9bec8..c18fa95afe 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModel.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModel.h @@ -74,14 +74,16 @@ class CORE_EXPORT KeyframeEffectModelBase : public EffectModel { friend class KeyframeEffectModelBase; }; - bool IsReplaceOnly(); + bool AffectedByUnderlyingAnimations() const final { return !IsReplaceOnly(); } + bool IsReplaceOnly() const; PropertyHandleSet Properties() const; using KeyframeVector = Vector>; const KeyframeVector& GetFrames() const { return keyframes_; } bool HasFrames() const { return !keyframes_.IsEmpty(); } - void SetFrames(KeyframeVector& keyframes); + template + void SetFrames(Vector& keyframes); CompositeOperation Composite() const { return composite_; } void SetComposite(CompositeOperation composite) { composite_ = composite; } @@ -127,7 +129,8 @@ class CORE_EXPORT KeyframeEffectModelBase : public EffectModel { const ComputedStyle& base_style, const ComputedStyle* parent_style) const; - static Vector GetComputedOffsets(const KeyframeVector& keyframes); + template + static Vector GetComputedOffsets(const Vector& keyframes); bool Affects(const PropertyHandle& property) const override { EnsureKeyframeGroups(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModelTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModelTest.cpp index 1ec83c8da5..3bfc60a0f0 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModelTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectModelTest.cpp @@ -35,7 +35,6 @@ #include "core/animation/InvalidatableInterpolation.h" #include "core/animation/StringKeyframe.h" #include "core/animation/animatable/AnimatableDouble.h" -#include "core/animation/animatable/AnimatableUnknown.h" #include "core/css/CSSPrimitiveValue.h" #include "core/dom/Element.h" #include "core/testing/PageTestBase.h" @@ -47,7 +46,7 @@ class AnimationKeyframeEffectModel : public PageTestBase { protected: void SetUp() override { PageTestBase::SetUp(IntSize()); - element = GetDocument().createElement("foo"); + element = GetDocument().CreateElementForBinding("foo"); } void ExpectLengthValue(double expected_value, @@ -91,11 +90,6 @@ class AnimationKeyframeEffectModel : public PageTestBase { const double kDuration = 1.0; -scoped_refptr UnknownAnimatableValue(double n) { - return AnimatableUnknown::Create( - CSSPrimitiveValue::Create(n, CSSPrimitiveValue::UnitType::kUnknown)); -} - StringKeyframeVector KeyframesAtZeroAndOne(CSSPropertyID property, const String& zero_value, const String& one_value) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.cpp index 64be8c6c0d..190a1f8331 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.cpp @@ -56,8 +56,8 @@ KeyframeEffectReadOnly* KeyframeEffectReadOnly::Create( EffectModel::CompositeOperation composite = EffectModel::kCompositeReplace; if (options.IsKeyframeEffectOptions()) { - composite = EffectModel::ExtractCompositeOperation( - options.GetAsKeyframeEffectOptions()); + composite = EffectModel::StringToCompositeOperation( + options.GetAsKeyframeEffectOptions().composite()); } KeyframeEffectModelBase* model = EffectInput::Convert( @@ -93,7 +93,7 @@ KeyframeEffectReadOnly* KeyframeEffectReadOnly::Create( ExceptionState& exception_state) { Timing new_timing = source->SpecifiedTiming(); KeyframeEffectModelBase* model = source->Model()->Clone(); - return new KeyframeEffectReadOnly(source->Target(), model, new_timing, + return new KeyframeEffectReadOnly(source->target(), model, new_timing, source->GetPriority(), source->GetEventDelegate()); } @@ -111,33 +111,26 @@ KeyframeEffectReadOnly::KeyframeEffectReadOnly(Element* target, DCHECK(model_); } -void KeyframeEffectReadOnly::Attach(Animation* animation) { - if (target_) { - target_->EnsureElementAnimations().Animations().insert(animation); +void KeyframeEffectReadOnly::Attach(AnimationEffectOwner* owner) { + if (target_ && owner->GetAnimation()) { + target_->EnsureElementAnimations().Animations().insert( + owner->GetAnimation()); target_->SetNeedsAnimationStyleRecalc(); if (RuntimeEnabledFeatures::WebAnimationsSVGEnabled() && target_->IsSVGElement()) ToSVGElement(target_)->SetWebAnimationsPending(); } - AnimationEffectReadOnly::Attach(animation); + AnimationEffectReadOnly::Attach(owner); } void KeyframeEffectReadOnly::Detach() { - if (target_) + if (target_ && GetAnimation()) target_->GetElementAnimations()->Animations().erase(GetAnimation()); if (sampled_effect_) ClearEffects(); AnimationEffectReadOnly::Detach(); } -void KeyframeEffectReadOnly::SpecifiedTimingChanged() { - if (GetAnimation()) { - // FIXME: Needs to consider groups when added. - DCHECK_EQ(GetAnimation()->effect(), this); - GetAnimation()->SetCompositorPending(true); - } -} - static EffectStack& EnsureEffectStack(Element* element) { return element->EnsureElementAnimations().GetEffectStack(); } @@ -192,15 +185,16 @@ void KeyframeEffectReadOnly::ApplyEffects() { DCHECK_GE(iteration, 0); bool changed = false; if (sampled_effect_) { - changed = model_->Sample(clampTo(iteration, 0), Progress(), + changed = model_->Sample(clampTo(iteration, 0), Progress().value(), IterationDuration(), sampled_effect_->MutableInterpolations()); } else { Vector> interpolations; - model_->Sample(clampTo(iteration, 0), Progress(), IterationDuration(), - interpolations); + model_->Sample(clampTo(iteration, 0), Progress().value(), + IterationDuration(), interpolations); if (!interpolations.IsEmpty()) { - SampledEffect* sampled_effect = SampledEffect::Create(this); + SampledEffect* sampled_effect = + SampledEffect::Create(this, owner_->SequenceNumber()); sampled_effect->MutableInterpolations().swap(interpolations); sampled_effect_ = sampled_effect; EnsureEffectStack(target_).Add(sampled_effect); @@ -224,7 +218,7 @@ void KeyframeEffectReadOnly::ClearEffects() { sampled_effect_->Clear(); sampled_effect_ = nullptr; - RestartAnimationOnCompositor(); + GetAnimation()->RestartAnimationOnCompositor(); target_->SetNeedsAnimationStyleRecalc(); if (RuntimeEnabledFeatures::WebAnimationsSVGEnabled() && target_->IsSVGElement()) @@ -236,7 +230,7 @@ void KeyframeEffectReadOnly::UpdateChildrenAndEffects() const { if (!model_->HasFrames()) return; DCHECK(GetAnimation()); - if (IsInEffect() && !GetAnimation()->EffectSuppressed()) + if (IsInEffect() && !owner_->EffectSuppressed()) const_cast(this)->ApplyEffects(); else if (sampled_effect_) const_cast(this)->ClearEffects(); @@ -322,18 +316,18 @@ void KeyframeEffectReadOnly::StartAnimationOnCompositor( double start_time, double current_time, double animation_playback_rate, - CompositorAnimationPlayer* compositor_player) { + CompositorAnimation* compositor_animation) { DCHECK(!HasActiveAnimationsOnCompositor()); DCHECK(CheckCanStartAnimationOnCompositor(animation_playback_rate).Ok()); - if (!compositor_player) - compositor_player = GetAnimation()->CompositorPlayer(); - DCHECK(compositor_player); + if (!compositor_animation) + compositor_animation = GetAnimation()->GetCompositorAnimation(); + DCHECK(compositor_animation); CompositorAnimations::StartAnimationOnCompositor( *target_, group, start_time, current_time, SpecifiedTiming(), - GetAnimation(), *compositor_player, *Model(), compositor_animation_ids_, - animation_playback_rate); + GetAnimation(), *compositor_animation, *Model(), + compositor_animation_ids_, animation_playback_rate); DCHECK(!compositor_animation_ids_.IsEmpty()); } @@ -398,11 +392,6 @@ bool KeyframeEffectReadOnly::CancelAnimationOnCompositor() { return true; } -void KeyframeEffectReadOnly::RestartAnimationOnCompositor() { - if (CancelAnimationOnCompositor()) - GetAnimation()->SetCompositorPending(true); -} - void KeyframeEffectReadOnly::CancelIncompatibleAnimationsOnCompositor() { if (target_ && GetAnimation() && model_->HasFrames()) { CompositorAnimations::CancelIncompatibleAnimationsOnCompositor( @@ -426,7 +415,15 @@ void KeyframeEffectReadOnly::AttachCompositedLayers() { DCHECK(target_); DCHECK(GetAnimation()); CompositorAnimations::AttachCompositedLayers( - *target_, GetAnimation()->CompositorPlayer()); + *target_, GetAnimation()->GetCompositorAnimation()); +} + +bool KeyframeEffectReadOnly::HasAnimation() const { + return !!owner_; +} + +bool KeyframeEffectReadOnly::HasPlayingAnimation() const { + return owner_ && owner_->Playing(); } void KeyframeEffectReadOnly::Trace(blink::Visitor* visitor) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.h index 957cd87506..9c1dfd37d4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.h @@ -55,6 +55,7 @@ class CORE_EXPORT KeyframeEffectReadOnly : public AnimationEffectReadOnly { // IDL implementation. String composite() const; Vector getKeyframes(ScriptState*); + Element* target() const { return target_; } EffectModel::CompositeOperation compositeInternal() const { return model_->Composite(); @@ -68,23 +69,20 @@ class CORE_EXPORT KeyframeEffectReadOnly : public AnimationEffectReadOnly { model_ = model; } Priority GetPriority() const { return priority_; } - Element* Target() const { return target_; } void NotifySampledEffectRemovedFromEffectStack(); CompositorAnimations::FailureCode CheckCanStartAnimationOnCompositor( double animation_playback_rate) const; // Must only be called once. - void StartAnimationOnCompositor( - int group, - double start_time, - double time_offset, - double animation_playback_rate, - CompositorAnimationPlayer* compositor_player = nullptr); + void StartAnimationOnCompositor(int group, + double start_time, + double time_offset, + double animation_playback_rate, + CompositorAnimation* = nullptr); bool HasActiveAnimationsOnCompositor() const; bool HasActiveAnimationsOnCompositor(const PropertyHandle&) const; bool CancelAnimationOnCompositor(); - void RestartAnimationOnCompositor(); void CancelIncompatibleAnimationsOnCompositor(); void PauseAnimationForTestingOnCompositor(double pause_time); @@ -99,6 +97,9 @@ class CORE_EXPORT KeyframeEffectReadOnly : public AnimationEffectReadOnly { void DowngradeToNormal() { priority_ = kDefaultPriority; } + bool HasAnimation() const; + bool HasPlayingAnimation() const; + protected: KeyframeEffectReadOnly(Element*, KeyframeEffectModelBase*, @@ -109,9 +110,8 @@ class CORE_EXPORT KeyframeEffectReadOnly : public AnimationEffectReadOnly { void ApplyEffects(); void ClearEffects(); void UpdateChildrenAndEffects() const override; - void Attach(Animation*) override; + void Attach(AnimationEffectOwner*) override; void Detach() override; - void SpecifiedTimingChanged() override; double CalculateTimeToEffectChange( bool forwards, double inherited_time, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.idl index 4a0c0aa4b5..72fc2edc0c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectReadOnly.idl @@ -15,4 +15,5 @@ enum CompositeOperation { "replace", "add", "accumulate" }; ] interface KeyframeEffectReadOnly : AnimationEffectReadOnly { readonly attribute CompositeOperation composite; [CallWith=ScriptState] sequence getKeyframes(); + readonly attribute Element? target; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp index e8af75a74c..83c36f35c0 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp @@ -18,16 +18,18 @@ #include "core/animation/KeyframeEffectModel.h" #include "core/animation/Timing.h" #include "core/dom/Document.h" -#include "core/testing/DummyPageHolder.h" +#include "core/testing/PageTestBase.h" +#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" #include "testing/gtest/include/gtest/gtest.h" #include "v8/include/v8.h" namespace blink { -class KeyframeEffectTest : public ::testing::Test { +class KeyframeEffectTest : public PageTestBase { protected: - KeyframeEffectTest() : page_holder(DummyPageHolder::Create()) { - element = GetDocument().createElement("foo"); + virtual void SetUp() { + PageTestBase::SetUp(IntSize()); + element = GetDocument().CreateElementForBinding("foo"); GetDocument().GetAnimationClock().ResetTimeForTesting( GetDocument().Timeline().ZeroTime()); @@ -35,13 +37,10 @@ class KeyframeEffectTest : public ::testing::Test { EXPECT_EQ(0, GetDocument().Timeline().currentTime()); } - Document& GetDocument() const { return page_holder->GetDocument(); } - KeyframeEffectModelBase* CreateEmptyEffectModel() { return StringKeyframeEffectModel::Create(StringKeyframeVector()); } - std::unique_ptr page_holder; Persistent element; }; @@ -103,7 +102,7 @@ TEST_F(AnimationKeyframeEffectV8Test, CanCreateAnAnimation) { KeyframeEffect* animation = CreateAnimation(script_state, element.Get(), js_keyframes, 0); - Element* target = animation->Target(); + Element* target = animation->target(); EXPECT_EQ(*element.Get(), *target); const KeyframeVector keyframes = animation->Model()->GetFrames(); @@ -382,36 +381,68 @@ TEST_F(AnimationKeyframeEffectV8Test, SetSpecifiedDuration) { EXPECT_FALSE(duration2.IsString()); } +TEST_F(AnimationKeyframeEffectV8Test, SetKeyframesAdditiveCompositeOperation) { + ScopedCSSAdditiveAnimationsForTest css_additive_animation(false); + V8TestingScope scope; + ScriptState* script_state = scope.GetScriptState(); + ScriptValue js_keyframes = ScriptValue::CreateNull(script_state); + v8::Local timing_input = v8::Object::New(scope.GetIsolate()); + KeyframeEffectOptions timing_input_dictionary; + DummyExceptionStateForTesting exception_state; + V8KeyframeEffectOptions::ToImpl(scope.GetIsolate(), timing_input, + timing_input_dictionary, exception_state); + ASSERT_FALSE(exception_state.HadException()); + + // Since there are no CSS-targeting keyframes, we can create a KeyframeEffect + // with composite = 'add'. + timing_input_dictionary.setComposite("add"); + KeyframeEffect* effect = CreateAnimation( + script_state, element.Get(), js_keyframes, timing_input_dictionary); + EXPECT_EQ(effect->Model()->Composite(), EffectModel::kCompositeAdd); + + // But if we then setKeyframes with CSS-targeting keyframes, the composite + // should fallback to 'replace'. + Vector blink_keyframes = { + V8ObjectBuilder(script_state).AddString("width", "10px").GetScriptValue(), + V8ObjectBuilder(script_state).AddString("width", "0px").GetScriptValue()}; + ScriptValue new_js_keyframes( + script_state, + ToV8(blink_keyframes, scope.GetContext()->Global(), scope.GetIsolate())); + effect->setKeyframes(script_state, new_js_keyframes, exception_state); + ASSERT_FALSE(exception_state.HadException()); + EXPECT_EQ(effect->Model()->Composite(), EffectModel::kCompositeReplace); +} + TEST_F(KeyframeEffectTest, TimeToEffectChange) { Timing timing; timing.iteration_duration = 100; timing.start_delay = 100; timing.end_delay = 100; timing.fill_mode = Timing::FillMode::NONE; - KeyframeEffect* animation = + KeyframeEffect* keyframe_effect = KeyframeEffect::Create(nullptr, CreateEmptyEffectModel(), timing); - Animation* player = GetDocument().Timeline().Play(animation); + Animation* animation = GetDocument().Timeline().Play(keyframe_effect); double inf = std::numeric_limits::infinity(); - EXPECT_EQ(100, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(inf, animation->TimeToReverseEffectChange()); + EXPECT_EQ(100, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(inf, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(100); - EXPECT_EQ(100, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(0, animation->TimeToReverseEffectChange()); + animation->SetCurrentTimeInternal(100); + EXPECT_EQ(100, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(199); - EXPECT_EQ(1, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(0, animation->TimeToReverseEffectChange()); + animation->SetCurrentTimeInternal(199); + EXPECT_EQ(1, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(200); + animation->SetCurrentTimeInternal(200); // End-exclusive. - EXPECT_EQ(inf, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(0, animation->TimeToReverseEffectChange()); + EXPECT_EQ(inf, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(300); - EXPECT_EQ(inf, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(100, animation->TimeToReverseEffectChange()); + animation->SetCurrentTimeInternal(300); + EXPECT_EQ(inf, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(100, keyframe_effect->TimeToReverseEffectChange()); } TEST_F(KeyframeEffectTest, TimeToEffectChangeWithPlaybackRate) { @@ -421,30 +452,30 @@ TEST_F(KeyframeEffectTest, TimeToEffectChangeWithPlaybackRate) { timing.end_delay = 100; timing.playback_rate = 2; timing.fill_mode = Timing::FillMode::NONE; - KeyframeEffect* animation = + KeyframeEffect* keyframe_effect = KeyframeEffect::Create(nullptr, CreateEmptyEffectModel(), timing); - Animation* player = GetDocument().Timeline().Play(animation); + Animation* animation = GetDocument().Timeline().Play(keyframe_effect); double inf = std::numeric_limits::infinity(); - EXPECT_EQ(100, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(inf, animation->TimeToReverseEffectChange()); + EXPECT_EQ(100, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(inf, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(100); - EXPECT_EQ(50, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(0, animation->TimeToReverseEffectChange()); + animation->SetCurrentTimeInternal(100); + EXPECT_EQ(50, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(149); - EXPECT_EQ(1, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(0, animation->TimeToReverseEffectChange()); + animation->SetCurrentTimeInternal(149); + EXPECT_EQ(1, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(150); + animation->SetCurrentTimeInternal(150); // End-exclusive. - EXPECT_EQ(inf, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(0, animation->TimeToReverseEffectChange()); + EXPECT_EQ(inf, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(200); - EXPECT_EQ(inf, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(50, animation->TimeToReverseEffectChange()); + animation->SetCurrentTimeInternal(200); + EXPECT_EQ(inf, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(50, keyframe_effect->TimeToReverseEffectChange()); } TEST_F(KeyframeEffectTest, TimeToEffectChangeWithNegativePlaybackRate) { @@ -454,42 +485,29 @@ TEST_F(KeyframeEffectTest, TimeToEffectChangeWithNegativePlaybackRate) { timing.end_delay = 100; timing.playback_rate = -2; timing.fill_mode = Timing::FillMode::NONE; - KeyframeEffect* animation = + KeyframeEffect* keyframe_effect = KeyframeEffect::Create(nullptr, CreateEmptyEffectModel(), timing); - Animation* player = GetDocument().Timeline().Play(animation); + Animation* animation = GetDocument().Timeline().Play(keyframe_effect); double inf = std::numeric_limits::infinity(); - EXPECT_EQ(100, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(inf, animation->TimeToReverseEffectChange()); + EXPECT_EQ(100, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(inf, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(100); - EXPECT_EQ(50, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(0, animation->TimeToReverseEffectChange()); + animation->SetCurrentTimeInternal(100); + EXPECT_EQ(50, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(149); - EXPECT_EQ(1, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(0, animation->TimeToReverseEffectChange()); + animation->SetCurrentTimeInternal(149); + EXPECT_EQ(1, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(150); - EXPECT_EQ(inf, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(0, animation->TimeToReverseEffectChange()); + animation->SetCurrentTimeInternal(150); + EXPECT_EQ(inf, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange()); - player->SetCurrentTimeInternal(200); - EXPECT_EQ(inf, animation->TimeToForwardsEffectChange()); - EXPECT_EQ(50, animation->TimeToReverseEffectChange()); -} - -TEST_F(KeyframeEffectTest, ElementDestructorClearsAnimationTarget) { - // This test expects incorrect behaviour should be removed once Element - // and KeyframeEffect are moved to Oilpan. See crbug.com/362404 for context. - Timing timing; - timing.iteration_duration = 5; - KeyframeEffect* animation = - KeyframeEffect::Create(element.Get(), CreateEmptyEffectModel(), timing); - EXPECT_EQ(element.Get(), animation->Target()); - GetDocument().Timeline().Play(animation); - page_holder.reset(); - element.Clear(); + animation->SetCurrentTimeInternal(200); + EXPECT_EQ(inf, keyframe_effect->TimeToForwardsEffectChange()); + EXPECT_EQ(50, keyframe_effect->TimeToReverseEffectChange()); } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/LengthPropertyFunctions.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/LengthPropertyFunctions.cpp index 98ff0d02af..17dfa9aa6b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/LengthPropertyFunctions.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/LengthPropertyFunctions.cpp @@ -35,6 +35,7 @@ ValueRange LengthPropertyFunctions::GetValueRange(const CSSProperty& property) { case CSSPropertyWebkitBorderHorizontalSpacing: case CSSPropertyWebkitBorderVerticalSpacing: case CSSPropertyColumnGap: + case CSSPropertyRowGap: case CSSPropertyColumnWidth: case CSSPropertyWidth: return kValueRangeNonNegative; @@ -255,10 +256,15 @@ bool LengthPropertyFunctions::GetLength(const CSSProperty& property, case CSSPropertyWebkitBorderVerticalSpacing: result = Length(style.VerticalBorderSpacing(), kFixed); return true; + case CSSPropertyRowGap: + if (style.RowGap().IsNormal()) + return false; + result = style.RowGap().GetLength(); + return true; case CSSPropertyColumnGap: - if (style.HasNormalColumnGap()) + if (style.ColumnGap().IsNormal()) return false; - result = Length(style.ColumnGap(), kFixed); + result = style.ColumnGap().GetLength(); return true; case CSSPropertyColumnRuleWidth: result = Length(style.ColumnRuleWidth(), kFixed); @@ -435,6 +441,7 @@ bool LengthPropertyFunctions::SetLength(const CSSProperty& property, case CSSPropertyWebkitBorderHorizontalSpacing: case CSSPropertyWebkitBorderVerticalSpacing: case CSSPropertyColumnGap: + case CSSPropertyRowGap: case CSSPropertyColumnRuleWidth: case CSSPropertyColumnWidth: case CSSPropertyWebkitTransformOriginZ: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/OWNERS b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/OWNERS index 9c5abe2197..5e43ed4ece 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/OWNERS +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/OWNERS @@ -1,11 +1,11 @@ +flackr@chromium.org +smcgruer@chromium.org + +# Legacy owners: alancutter@chromium.org -dstockwell@chromium.org ericwilligers@chromium.org -flackr@chromium.org -shans@chromium.org -timloh@chromium.org per-file Compositor*=loyso@chromium.org -# TEAM: style-dev@chromium.org +# TEAM: animations-dev@chromium.org # COMPONENT: Blink>Animation diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/README.md b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/README.md new file mode 100644 index 0000000000..51b36cde62 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/README.md @@ -0,0 +1,387 @@ +# `Source/core/animation` + +This directory contains the main thread animation engine. This implements the +Web Animations timing model that drives CSS Animations, Transitions and exposes +the Web Animations API (`element.animate()`) to Javascript. + +## Contacts + +As of 2018 Blink animations is maintained by the +[cc/ team](https://cs.chromium.org/chromium/src/cc/OWNERS). + +## Specifications Implemented + +* [CSS Animations Level 1](https://www.w3.org/TR/css-animations-1/) +* [CSS Transitions](https://www.w3.org/TR/css-transitions-1/) +* [Web Animations](https://www.w3.org/TR/web-animations-1/) +* [CSS Properties and Values API Level 1 - Animation Behavior of Custom Properties](https://www.w3.org/TR/css-properties-values-api-1/#animation-behavior-of-custom-properties) +* Individual CSS property animation behaviour [e.g. transform interolation](https://www.w3.org/TR/css-transforms-1/#interpolation-of-transforms). + +## Integration with Chromium + +The Blink animation engine interacts with Blink/Chrome in the following ways: + +* ### [Blink's Style engine](../css) + + The most user visible functionality of the animation engine is animating + CSS values. This means animations have a place in the [CSS cascade][] and + influence the [ComputedStyle][]s returned by [styleForElement()][]. + + The implementation for this lives under [ApplyAnimatedStandardProperties()][] + for standard properties and [ApplyAnimatedCustomProperties()][] for custom + properties. Custom properties have more complex application logic due to + dynamic dependencies introduced by [variable references]. + + Animations can be controlled by CSS via the [`animation`](https://www.w3.org/TR/css-animations-1/#animation) + and [`transition`](https://www.w3.org/TR/css-transitions-1/#transition-shorthand-property) properties. + In code this happens when [styleForElement()][] uses [CalculateAnimationUpdate()][] + and [CalculateTransitionUpdate()][] to build a [set of mutations][] to make + to the animation engine which gets [applied later][]. + +[CSS cascade]: https://www.w3.org/TR/css-cascade-3/#cascade-origin +[ComputedStyle]: https://cs.chromium.org/search/?q=class:blink::ComputedStyle$ +[styleForElement()]: https://cs.chromium.org/search/?q=function:StyleResolver::styleForElement +[ApplyAnimatedStandardProperties()]: https://cs.chromium.org/?type=cs&q=function:StyleResolver::ApplyAnimatedStandardProperties +[ApplyAnimatedCustomProperties()]: https://cs.chromium.org/?type=cs&q=function:ApplyAnimatedCustomProperties +[variable references]: https://www.w3.org/TR/css-variables-1/#using-variables +[CalculateAnimationUpdate()]: https://cs.chromium.org/search/?q=function:CSSAnimations::CalculateAnimationUpdate +[CalculateTransitionUpdate()]: https://cs.chromium.org/search/?q=function:CSSAnimations::CalculateTransitionUpdate +[MaybeApplyPendingUpdate()]: https://cs.chromium.org/search/?q=function:CSSAnimations::MaybeApplyPendingUpdate +[set of mutations]: https://cs.chromium.org/search/?q=class:CSSAnimationUpdate +[applied later]: https://cs.chromium.org/search/?q=function:Element::StyleForLayoutObject+MaybeApplyPendingUpdate + +* ### [Chromium's Compositor](../../../../../cc/README.md) + + Chromium's compositor has a separate, more lightweight [animation + engine](../../../../../cc/animation/README.md) that runs separate to the + main thread. Blink's animation engine delegates animations to the compositor + where possible for better performance and power utilisation. + + #### Compositable animations + + A subset of style properties (currently transform, opacity, filter, and + backdrop-filter) can be mutated on the compositor thread. Animations that + mutates only these properties are a candidate for being accelerated and run + on compositor thread which ensures they are isolated from Blink's main + thread work. + + Whether or not an animation can be accelerated is determined by + [CheckCanStartAnimationOnCompositor()][] which looks at several aspects + such as the composite mode, other animations affecting same property, and + whether the target element can be promoted and mutated in compositor. + Reasons for not compositing animations are captured in [FailureCodes][]. + + #### Lifetime of a compositor animation + + Animations that can be accelerated get added to the [PendingAnimations][] + list. The pending list is updates as part of document lifecycle and ensures + each pending animation gets a corresponding [cc::AnimationPlayer][] + representing the animation on the compositor. The player is initialized with + appropriate timing values and corresponding effects. + + Note that changing that animation playback rate, start time, or effect, + simply adds the animation back on to the pending list and causes the + compositor animation to be cancelled and a new one to be started. See + [Animation::PreCommit()][] for more details. + + An accelerated animation is still running on main thread ensuring that its + effective output is reflected in the Element style. So while the compositor + animation updates the visuals the main thread animation updates the computed + style. There is a special case logic to ensure updates from such accelerated + animations do not cause spurious commits from main to compositor (See + [CompositedLayerMapping::UpdateGraphicsLayerGeometry()][]) + + A compositor animation provide updates on its playback state changes (e.g., + on start, finish, abort) to its blink counterpart via + [CompositorAnimationDelegate][] interface. Blink animation uses the start + event callback to obtain an accurate start time for the animation which is + important to ensure its output accurately reflects the compositor animation + output. + +[CheckCanStartAnimationOnCompositor()]: https://cs.chromium.org/search/?q=file:Animation.h+function:CheckCanStartAnimationOnCompositor +[FailureCodes]: https://cs.chromium.org/search/?q=return%5Cs%2B(CompositorAnimations::)?FailureCode +[cc::AnimationPlayer]: https://cs.chromium.org/search/?q=file:src/cc/animation/animation_player.h+class:AnimationPlayer +[PendingAnimations]: https://cs.chromium.org/search/?q=file:PendingAnimations.h+class:PendingAnimations +[Animation::PreCommit()]: https://cs.chromium.org/search/?q=file:Animation.h+function:PreCommit +[CompositorAnimationDelegate]: https://cs.chromium.org/search/?q=file:CompositorAnimationDelegate.h +[CompositedLayerMapping::UpdateGraphicsLayerGeometry()]: https://cs.chromium.org/search/?q=file:CompositedLayerMapping.h+function:UpdateGraphicsLayerGeometry + +* ### Javascript + + [EffectInput](https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/animation/EffectInput.cpp) + contains the helper functions that are used to + [process a keyframe argument](https://drafts.csswg.org/web-animations/#processing-a-keyframes-argument) + which can take an argument of either object or array form. + + [PlayStateUpdateScope](https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/animation/Animation.h?l=323): + whenever there is a mutation to the animation engine from JS level, this + gets created and the destructor has the logic that handles everything. It + keeps the old and new state of the animation, checks the difference and + mutate the properties of the animation, at the end it calls + SetOutdatedAnimation() to inform the animation timeline that the time state + of this animation is dirtied. + + There are a couple of other integration points that are less critical to everyday browsing: + +* ### DevTools + + The animations timeline uses [InspectorAnimationAgent][] to track all active + animations. This class has interfaces for pausing, adjusting + DocumentTimeline playback rate, and seeking animations. + + InspectorAnimationAgent clones the inspected animation in order to avoid + firing animation events, and suppresses the effects of the original + animation. From this point on, modifications can be made to the cloned + animation without having any effect on the underlying animation or its + listeners. + +[InspectorAnimationAgent]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.h + +* ### SVG + + The `element.animate()` API supports targeting SVG attributes in its + keyframes. This is an experimental implementation guarded by the + WebAnimationsSVG flag and not exposed on the web. + + This feature should provide a high fidelity alternative to our SMIL + implementation. + +## Architecture + +### Animation Timing Model + +The animation engine is built around the +[timing model](https://www.w3.org/TR/web-animations-1/#timing-model) described +in the Web Animations spec. + +This describes a hierarchy of entities: + +* __[DocumentTimeline][]__: Represents the wall clock time. + * __[Animation][]__: Represents an individual animation and when it + started playing. + * __[AnimationEffect][]__: Represents the effect an animation has + during the animation (e.g. updating an element's color property). + +Time trickles down from the [DocumentTimeline][] and is transformed at each +stage to produce some progress fraction that can be used to apply the effects of +the animations. + +For example: + +```javascript +// Page was loaded at 2:00:00PM, the time is currently 2:00:10PM. +// document.timeline.currentTime is currently 10000 (10 seconds). + +let animation = element.animate([ + {transform: 'none'}, + {transform: 'rotate(200deg)'}, + ], { + duration: 20000, // 20 seconds + }); + +animation.startTime = 6000; // 6 seconds +``` + +* __[DocumentTimeline][]__ notifies that the time is 10 seconds. + * __[Animation][]__ computes that its currentTime is 4 seconds due to its + startTime being at 6 seconds. + * __[AnimationEffect][]__ has a duration of 20 seconds and computes + that it has a progress of 20% from the parent animation being 4 + seconds into the animation. + + The effect is animating an element from `transform: none` to + `transform: rotate(200deg)` so it computes the current effect to be + `transfrom: rotate(40deg)`. + +[Animation]: https://cs.chromium.org/search/?q=class:blink::Animation$ +[AnimationEffect]: https://cs.chromium.org/search/?q=class:blink::AnimationEffectReadOnly$ +[DocumentTimeline]: https://cs.chromium.org/search/?q=class:blink::DocumentTimeline$ +[EffectStack]: https://cs.chromium.org/search/?q=class:blink::EffectStack + +### Lifecycle of an Animation + +1. An [Animation][] is created via CSS1 or `element.animate()`. +2. At the start of the next frame the [Animation][] and its [AnimationEffect][] + are updated with the currentTime of the [DocumentTimeline][]. +3. The [AnimationEffect][] gets sampled with its computed localTime, pushes a + [SampledEffect][] into its target element's [EffectStack][] and marks the + elements style as dirty to ensure it gets updated later in the document + lifecycle. +4. During the next [style resolve][styleForElement()] on the target element all + the [SampledEffect][]s in its [EffectStack][] are incorporated into building + the element's [ComputedStyle][]. + +One key takeaway here is to note that timing updates are done in a separate +phase to effect application. Effect application must occur during style +resolution which is a highly complex process with a well defined place in the +document lifecycle. Updates to animation timing will request style updates +rather than invoke them directly. + +1 CSS animations and transitions are actually created/destroyed +during style resolve (step 4). There is special logic for forcing these +animations to have their timing updated and their effects included in +the same style resolve. An unfortunate side effect of this is that style +resolution can cause style to get dirtied, this is currently a +[code health bug](http://crbug.com/492887). + +[SampledEffect]: https://cs.chromium.org/search/?q=class:blink::SampledEffect + +### [KeyframeEffect][] + +Currently all animations use [KeyframeEffect][] for their [AnimationEffect][]. +The generic [AnimationEffect][] from which it inherits is an extention point in +Web Animations where other kinds of animation effects can be defined later by +other specs (for example Javascript callback based effects). + +#### Structure of a [KeyframeEffect][] + +* __[KeyframeEffect][]__ represents the effect an animation has (without any + details of when it started or whether it's playing) and is comprised of + three things: + * Some __[Timing][]__ information (inherited from [AnimationEffect][]). + [Example](http://jsbin.com/nuyohulojo/edit?js,output): + ```javascript + { + duration: 4000, + easing: 'ease-in-out', + iterations: 8, + direction: 'alternate', + } + ``` + This is used to [compute][UpdateInheritedTime()] the percentage progress + of the effect given the duration of time that the animation has been + playing for. + + * The DOM __[Element][]__ that is being animated. + + * A __[KeyframeEffectModel][]__ that holds a sequence of keyframes to + specify the properties being animated and what values they pass + through. + [Example](http://jsbin.com/wiyefaxiru/1/edit?js,output): + ```javascript + [ + {backgroundColor: 'red', transform: 'rotate(0deg)'}, + {backgroundColor: 'yellow'}, + {backgroundColor: 'lime'}, + {backgroundColor: 'blue'}, + {backgroundColor: 'red', transform: 'rotate(360deg)'}, + ] + ``` + + These keyframes are used to compute: + * A __[PropertySpecificKeyframe map][KeyframeGroupMap]__ that simply + breaks up the input multi-property keyframes into per-property + keyframe lists. + * An __[InterpolationEffect][]__ which holds a set of + [Interpolation][]s, each one representing the animated values + between adjacent pairs of [PropertySpecificKeyframe][]s, and where + in the percentage progress they are active. + In the example keyframes above the [Interpolations][] generated + would include, among the 5 different property specific keyframe + pairs, one for `backgroundColor: 'red'` to + `backgroundColor: 'yellow'` that applied from 0% to 25% and one for + `transform: 'rotate(0deg)'` to `transform: 'rotate(360deg)'` that + applied from 0% to 100%. + +[Element]: https://cs.chromium.org/search/?q=class:blink::Element$ +[KeyframeGroupMap]: https://cs.chromium.org/search/?q=class:blink::KeyframeEffectModelBase+KeyframeGroupMap +[PropertySpecificKeyframe]: https://cs.chromium.org/search/?q=class:blink::Keyframe::PropertySpecificKeyframe +[KeyframeEffect]: https://cs.chromium.org/search/?q=class:blink::KeyframeEffectReadOnly$ +[KeyframeEffectModel]: https://cs.chromium.org/search/?q=class:blink::KeyframeEffectModelBase$ +[Timing]: https://cs.chromium.org/search/?q=class:blink::Timing$ +[UpdateInheritedTime()]: https://cs.chromium.org/search/?q=function:%5CbAnimationEffectReadOnly::UpdateInheritedTime + +#### Lifecycle of an [Interpolation][] + +[Interpolation][] is the data structure that [style +resolution][styleForElement()] uses to resolve what animated value to apply +to an animated element's [ComputedStyle][]. + +1. [Interpolation][]s are lazily + [instantiated][EnsureInterpolationEffectPopulated()] prior to sampling. +2. [KeyframeEffectModel][]s are [sampled][Sample()] every frame (or as + necessary) for a stack of [Interpolation][]s to + [apply][ApplyAnimatedStandardProperties()] to the associated [Element][] + and stashed away in the [Element][]'s [ElementAnimations][]' + [EffectStack][]'s [SampledEffect][]s. +3. During [style resolution][styleForElement()] on the target [Element][] all + the [Interpolation][]s are [collected and organised by + category][AdoptActiveInterpolations] according to whether it's a transition + or not (transitions in Blink are + [suppressed][CalculateTransitionUpdateForProperty()] in the presence of + non-transition animations on the same property) and whether it affects + custom properties or not (animated custom properties are + [animation-tainted](https://www.w3.org/TR/css-variables-1/#animation-tainted) + and affect the [processing of animation + properties][animation-tainted-processing]. +4. TODO(alancutter): Describe what happens in processing a stack of + interpolations. + +[AdoptActiveInterpolations]: https://cs.chromium.org/search/?q=AdoptActiveInterpolations%5Cw%2B +[animation-tainted-processing]: https://cs.chromium.org/search/?q=function:blink::StyleBuilder::ApplyProperty+animation_tainted +[CalculateTransitionUpdateForProperty()]: https://cs.chromium.org/search/?q=function:blink::CSSAnimations::CalculateTransitionUpdateForProperty +[ElementAnimations]: https://cs.chromium.org/search/?q=class:blink::ElementAnimations +[EnsureInterpolationEffectPopulated()]: https://cs.chromium.org/search/?q=function:KeyframeEffectModelBase::EnsureInterpolationEffectPopulated +[Interpolation]: https://cs.chromium.org/search/?q=class:blink::Interpolation$ +[InterpolationEffect]: https://cs.chromium.org/search/?q=class:blink::InterpolationEffect +[Sample()]: https://cs.chromium.org/search/?q=function:KeyframeEffectModelBase::Sample + +## Testing pointers + +Test new animation features using end to end web-platform-tests to ensure +cross-browser interoperability. Use unit testing when access to chrome internals +is required. Test chrome specific features such as compositing of animation +using LayoutTests or unit tests. + +### End to end testing + +Features in the Web Animations spec are tested in +[web-animations][web-animations-tests]. [Writing web platform tests][] has +pointers for how to get started. If Chrome does not correctly implement the +spec, add a corresponding -expected.txt file with your test listing the expected +failure in Chrome. + +[Layout tests](../../../../../docs/testing/writing_layout_tests.md) are located +in [third_party/WebKit/LayoutTests][]. These should be written when needing end +to end testing but either when testing chrome specific features (i.e. +non-standardized) such as compositing or when the test requires access to chrome +internal features not easily tested by web-platform-tests. + +[web-animations-tests]: https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/external/wpt/web-animations/ +[Writing web platform tests]: ../../../../../docs/testing/web_platform_tests.md#Writing-tests +[third_party/WebKit/LayoutTests]: https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/animations/ + +### Unit testing + +Unit testing of animations can range from [extending Test][] when you will +manually construct an instance of your object to [extending RenderingTest][] +where you can load HTML, [enable compositing][] if necessary, and run assertions +about the state. + +[extending Test]: https://cs.chromium.org/search/?q=public%5C+::testing::Test+file:core%5C/Animation&sq=package:chromium&type=cs +[extending RenderingTest]: https://cs.chromium.org/search/?q=public%5C+RenderingTest+file:core%5C/animation&type=cs +[enable compositing]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp?type=cs&sq=package:chromium&q=file:core%5C/animation%5C/.*Test%5C.cpp+EnableCompositing + +## Ongoing work + +### Properties And Values API + +TODO: Summarize properties and values API. + +### Web Animations API + +TODO: Summarize Web Animations API. + +### [Animation Worklet](../../modules/animationworklet/README.md) + +AnimationWorklet is a new primitive for creating high performance procedural +animations on the web. It is being incubated as part of the +[CSS Houdini task force](https://github.com/w3c/css-houdini-drafts/wiki), and if +successful will be transferred to that task force for full standardization. + +A [WorkletAnimation][] behaves and exposes the same animation interface as other +web animation but it allows the animation itself to be highly customized in +Javascript by providing an `animate` callback. These animations run inside an +isolated worklet global scope. + +[WorkletAnimation]: https://cs.chromium.org/search/?q=file:animationworklet/WorkletAnimation.h+class:WorkletAnimation diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/SampledEffect.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/SampledEffect.cpp index 0b0d3b253c..4073093926 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/SampledEffect.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/SampledEffect.cpp @@ -6,9 +6,10 @@ namespace blink { -SampledEffect::SampledEffect(KeyframeEffectReadOnly* effect) +SampledEffect::SampledEffect(KeyframeEffectReadOnly* effect, + unsigned sequence_number) : effect_(effect), - sequence_number_(effect->GetAnimation()->SequenceNumber()), + sequence_number_(sequence_number), priority_(effect->GetPriority()) {} void SampledEffect::Clear() { @@ -16,8 +17,10 @@ void SampledEffect::Clear() { interpolations_.clear(); } +// Design doc: +// https://docs.google.com/document/d/1NomOWRrGQHlynQGO64CgdqRPAAEHhi3fSa8sf0Ip6xE bool SampledEffect::WillNeverChange() const { - return !effect_ || !effect_->GetAnimation(); + return !effect_ || !effect_->HasAnimation(); } void SampledEffect::RemoveReplacedInterpolations( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/SampledEffect.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/SampledEffect.h index 0d5b2425d4..34855e0d47 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/SampledEffect.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/SampledEffect.h @@ -18,8 +18,9 @@ namespace blink { // effect ordering and managing composited animations. class SampledEffect : public GarbageCollectedFinalized { public: - static SampledEffect* Create(KeyframeEffectReadOnly* animation) { - return new SampledEffect(animation); + static SampledEffect* Create(KeyframeEffectReadOnly* effect, + unsigned sequence_number) { + return new SampledEffect(effect, sequence_number); } void Clear(); @@ -41,7 +42,7 @@ class SampledEffect : public GarbageCollectedFinalized { void Trace(blink::Visitor*); private: - SampledEffect(KeyframeEffectReadOnly*); + SampledEffect(KeyframeEffectReadOnly*, unsigned sequence_number); WeakMember effect_; Vector> interpolations_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ScrollTimeline.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ScrollTimeline.cpp index 222bd4df66..ee0439a24b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ScrollTimeline.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ScrollTimeline.cpp @@ -57,7 +57,6 @@ ScrollTimeline::ScrollTimeline(const Document& document, : scroll_source_(scroll_source), orientation_(orientation), time_range_(time_range) { - DCHECK(RuntimeEnabledFeatures::AnimationWorkletEnabled()); } double ScrollTimeline::currentTime(bool& is_null) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ScrollTimeline.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ScrollTimeline.idl index f0c240bf7b..06e991a6d9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ScrollTimeline.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/ScrollTimeline.idl @@ -7,8 +7,9 @@ [ Constructor(optional ScrollTimelineOptions options), ConstructorCallWith=Document, + MeasureAs=ScrollTimelineConstructor, RaisesException=Constructor, - RuntimeEnabled=AnimationWorklet + OriginTrialEnabled=AnimationWorklet ] interface ScrollTimeline : AnimationTimeline { readonly attribute Element? scrollSource; readonly attribute ScrollDirection orientation; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/StringKeyframe.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/StringKeyframe.cpp index c141260bc9..9399a67e40 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/StringKeyframe.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/StringKeyframe.cpp @@ -104,6 +104,15 @@ PropertyHandleSet StringKeyframe::Properties() const { return properties; } +bool StringKeyframe::HasCssProperty() const { + PropertyHandleSet properties = Properties(); + for (const PropertyHandle& property : properties) { + if (property.IsCSSProperty()) + return true; + } + return false; +} + void StringKeyframe::AddKeyframePropertiesToV8Object( V8ObjectBuilder& object_builder) const { Keyframe::AddKeyframePropertiesToV8Object(object_builder); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/StringKeyframe.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/StringKeyframe.h index 2b19589ff7..3462568646 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/StringKeyframe.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/StringKeyframe.h @@ -76,6 +76,8 @@ class CORE_EXPORT StringKeyframe : public Keyframe { PropertyHandleSet Properties() const override; + bool HasCssProperty() const; + void AddKeyframePropertiesToV8Object(V8ObjectBuilder&) const override; class CSSPropertySpecificKeyframe diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Timing.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Timing.h index 438c44dc7a..04ce533caa 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Timing.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/Timing.h @@ -33,7 +33,7 @@ #include "base/memory/scoped_refptr.h" #include "core/style/DataEquivalency.h" -#include "platform/animation/CompositorAnimation.h" +#include "platform/animation/CompositorKeyframeModel.h" #include "platform/animation/TimingFunction.h" #include "platform/wtf/Allocator.h" #include "platform/wtf/MathExtras.h" @@ -44,8 +44,8 @@ struct Timing { USING_FAST_MALLOC(Timing); public: - using FillMode = CompositorAnimation::FillMode; - using PlaybackDirection = CompositorAnimation::Direction; + using FillMode = CompositorKeyframeModel::FillMode; + using PlaybackDirection = CompositorKeyframeModel::Direction; static String FillModeString(FillMode); static String PlaybackDirectionString(PlaybackDirection); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/TimingCalculations.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/TimingCalculations.h index d697d009a1..874c2db27e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/TimingCalculations.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/TimingCalculations.h @@ -232,10 +232,11 @@ static inline double CalculateDirectedTime(double current_iteration, : iteration_duration - iteration_time; } -static inline double CalculateTransformedTime(double current_iteration, - double iteration_duration, - double iteration_time, - const Timing& specified) { +static inline WTF::Optional CalculateTransformedTime( + double current_iteration, + double iteration_duration, + double iteration_time, + const Timing& specified) { DCHECK(IsNull(current_iteration) || current_iteration >= 0); DCHECK_GT(iteration_duration, 0); DCHECK(IsNull(iteration_time) || @@ -244,7 +245,7 @@ static inline double CalculateTransformedTime(double current_iteration, double directed_time = CalculateDirectedTime( current_iteration, iteration_duration, iteration_time, specified); if (IsNull(directed_time)) - return NullValue(); + return WTF::nullopt; if (!std::isfinite(iteration_duration)) return directed_time; double time_fraction = directed_time / iteration_duration; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/TimingCalculationsTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/TimingCalculationsTest.cpp index 3258265bf6..1db47cfc8a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/TimingCalculationsTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/TimingCalculationsTest.cpp @@ -228,7 +228,7 @@ TEST(AnimationTimingCalculationsTest, TransformedTime) { // currentIteration, iterationDuration, iterationTime, timing) // Iteration time is null - EXPECT_TRUE(IsNull(CalculateTransformedTime(1, 2, NullValue(), timing))); + EXPECT_FALSE(CalculateTransformedTime(1, 2, NullValue(), timing).has_value()); // PlaybackDirectionForwards EXPECT_EQ(12, CalculateTransformedTime(0, 20, 12, timing)); @@ -253,7 +253,7 @@ TEST(AnimationTimingCalculationsTest, TransformedTime) { EXPECT_EQ(5, CalculateTransformedTime(1, 20, 12, timing)); // Timing function when directed time is null. - EXPECT_TRUE(IsNull(CalculateTransformedTime(1, 2, NullValue(), timing))); + EXPECT_FALSE(CalculateTransformedTime(1, 2, NullValue(), timing).has_value()); // Timing function when iterationDuration is infinity timing.direction = Timing::PlaybackDirection::NORMAL; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/WorkletAnimationBase.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/WorkletAnimationBase.h index 22750c0936..8a28f090ef 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/WorkletAnimationBase.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/WorkletAnimationBase.h @@ -12,6 +12,7 @@ namespace blink { class Document; +class KeyframeEffectReadOnly; class CORE_EXPORT WorkletAnimationBase : public ScriptWrappable { public: @@ -27,6 +28,7 @@ class CORE_EXPORT WorkletAnimationBase : public ScriptWrappable { virtual bool StartOnCompositor(String* failure_message) = 0; virtual Document* GetDocument() const = 0; + virtual KeyframeEffectReadOnly* GetEffect() const = 0; }; } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp index d882e84aed..5cf550161c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp @@ -148,8 +148,11 @@ StringKeyframeEffectModel* CreateKeyframeEffectModel( } // Merge duplicate keyframes. - std::stable_sort(keyframes.begin(), keyframes.end(), - Keyframe::CompareOffsets); + std::stable_sort( + keyframes.begin(), keyframes.end(), + [](const scoped_refptr& a, const scoped_refptr& b) { + return a->CheckedOffset() < b->CheckedOffset(); + }); size_t target_index = 0; for (size_t i = 1; i < keyframes.size(); i++) { if (keyframes[i]->CheckedOffset() == @@ -750,12 +753,12 @@ void CSSAnimations::CalculateTransitionUpdateForProperty( const ComputedStyle* reversing_adjusted_start_value = &state.old_style; double reversing_shortening_factor = 1; if (interrupted_transition) { - const double interrupted_progress = + const WTF::Optional interrupted_progress = interrupted_transition->animation->effect()->Progress(); - if (!std::isnan(interrupted_progress)) { + if (interrupted_progress) { reversing_adjusted_start_value = interrupted_transition->to.get(); reversing_shortening_factor = - clampTo((interrupted_progress * + clampTo((interrupted_progress.value() * interrupted_transition->reversing_shortening_factor) + (1 - interrupted_transition->reversing_shortening_factor), 0.0, 1.0); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/test_data/raf-countdown.html b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/test_data/raf-countdown.html new file mode 100644 index 0000000000..dfe149953a --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/test_data/raf-countdown.html @@ -0,0 +1,11 @@ + + diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/test_data/raf-timeout.html b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/test_data/raf-timeout.html new file mode 100644 index 0000000000..bc0c530bbf --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/test_data/raf-timeout.html @@ -0,0 +1,9 @@ + + diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/test_data/transform-animation-on-svg.html b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/test_data/transform-animation-on-svg.html new file mode 100644 index 0000000000..a56d082341 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/animation/test_data/transform-animation-on-svg.html @@ -0,0 +1,42 @@ + + + + + diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataObjectItem.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataObjectItem.cpp index 2c988d8dd6..261bfdb09a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataObjectItem.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataObjectItem.cpp @@ -131,10 +131,8 @@ File* DataObjectItem::GetAsFile() const { mojom::ClipboardBuffer::kStandard); if (blob_info.size() < 0) return nullptr; - return File::Create( - "image.png", CurrentTimeMS(), - BlobDataHandle::Create(blob_info.Uuid(), blob_info.GetType(), - blob_info.size())); + return File::Create("image.png", CurrentTimeMS(), + blob_info.GetBlobHandle()); } return nullptr; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransfer.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransfer.cpp index 625d8874a8..fcb74921b9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransfer.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransfer.cpp @@ -133,9 +133,9 @@ class DraggedNodeImageBuilder { DocumentLifecycle::kPaintClean); PropertyTreeState border_box_properties = PropertyTreeState::Root(); - if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) { + if (RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) { border_box_properties = - *layer->GetLayoutObject().FirstFragment().LocalBorderBoxProperties(); + layer->GetLayoutObject().FirstFragment().LocalBorderBoxProperties(); } FloatPoint paint_offset = dragged_layout_object->LocalToAncestorPoint( FloatPoint(), &layer->GetLayoutObject(), kUseTransforms); @@ -362,13 +362,13 @@ void DataTransfer::SetDragImageElement(Node* node, const IntPoint& loc) { setDragImage(nullptr, node, loc); } -FloatRect DataTransfer::ClipByVisualViewport(const FloatRect& rect_in_document, +FloatRect DataTransfer::ClipByVisualViewport(const FloatRect& absolute_rect, const LocalFrame& frame) { IntRect viewport_in_root_frame = IntRect(frame.GetPage()->GetVisualViewport().VisibleRect()); - FloatRect viewport_in_document = - frame.View()->RootFrameToDocument(viewport_in_root_frame); - return Intersection(viewport_in_document, rect_in_document); + FloatRect absolute_viewport = + frame.View()->RootFrameToAbsolute(viewport_in_root_frame); + return Intersection(absolute_viewport, absolute_rect); } // static diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransferItem.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransferItem.cpp index 4f09d6803b..6fa726bbba 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransferItem.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransferItem.cpp @@ -32,7 +32,6 @@ #include "base/location.h" #include "bindings/core/v8/V8BindingForCore.h" -#include "bindings/core/v8/v8_function_string_callback.h" #include "core/clipboard/DataObjectItem.h" #include "core/clipboard/DataTransfer.h" #include "core/dom/ExecutionContext.h" @@ -76,14 +75,16 @@ void DataTransferItem::getAsString(ScriptState* script_state, if (!callback || item_->Kind() != DataObjectItem::kStringKind) return; - callbacks_.emplace_back(callback); + auto* v8persistent_callback = ToV8PersistentCallbackFunction(callback); ExecutionContext* context = ExecutionContext::From(script_state); - probe::AsyncTaskScheduled(context, "DataTransferItem.getAsString", callback); + probe::AsyncTaskScheduled(context, "DataTransferItem.getAsString", + v8persistent_callback); context->GetTaskRunner(TaskType::kUserInteraction) ->PostTask(FROM_HERE, WTF::Bind(&DataTransferItem::RunGetAsStringTask, WrapPersistent(this), WrapPersistent(context), - WrapPersistent(callback), item_->GetAsString())); + WrapPersistent(v8persistent_callback), + item_->GetAsString())); } File* DataTransferItem::getAsFile() const { @@ -97,30 +98,20 @@ DataTransferItem::DataTransferItem(DataTransfer* data_transfer, DataObjectItem* item) : data_transfer_(data_transfer), item_(item) {} -void DataTransferItem::RunGetAsStringTask(ExecutionContext* context, - V8FunctionStringCallback* callback, - const String& data) { +void DataTransferItem::RunGetAsStringTask( + ExecutionContext* context, + V8PersistentCallbackFunction* callback, + const String& data) { DCHECK(callback); probe::AsyncTask async_task(context, callback); if (context) callback->InvokeAndReportException(nullptr, data); - size_t index = callbacks_.Find(callback); - DCHECK(index != kNotFound); - callbacks_.EraseAt(index); } void DataTransferItem::Trace(blink::Visitor* visitor) { visitor->Trace(data_transfer_); visitor->Trace(item_); - visitor->Trace(callbacks_); ScriptWrappable::Trace(visitor); } -void DataTransferItem::TraceWrappers( - const ScriptWrappableVisitor* visitor) const { - for (auto callback : callbacks_) - visitor->TraceWrappers(callback); - ScriptWrappable::TraceWrappers(visitor); -} - } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransferItem.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransferItem.h index c45673d890..7954e6660c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransferItem.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/clipboard/DataTransferItem.h @@ -32,9 +32,9 @@ #define DataTransferItem_h #include "base/macros.h" +#include "bindings/core/v8/v8_function_string_callback.h" #include "core/CoreExport.h" #include "platform/bindings/ScriptWrappable.h" -#include "platform/bindings/TraceWrapperMember.h" #include "platform/heap/Handle.h" #include "platform/wtf/Forward.h" @@ -45,7 +45,6 @@ class DataTransfer; class ExecutionContext; class File; class ScriptState; -class V8FunctionStringCallback; class CORE_EXPORT DataTransferItem final : public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); @@ -62,19 +61,18 @@ class CORE_EXPORT DataTransferItem final : public ScriptWrappable { DataTransfer* GetDataTransfer() { return data_transfer_.Get(); } DataObjectItem* GetDataObjectItem() { return item_.Get(); } - void Trace(blink::Visitor*); - virtual void TraceWrappers(const ScriptWrappableVisitor*) const; + void Trace(blink::Visitor*) override; private: DataTransferItem(DataTransfer*, DataObjectItem*); - void RunGetAsStringTask(ExecutionContext*, - V8FunctionStringCallback*, - const String& data); + void RunGetAsStringTask( + ExecutionContext*, + V8PersistentCallbackFunction*, + const String& data); Member data_transfer_; Member item_; - HeapVector> callbacks_; DISALLOW_COPY_AND_ASSIGN(DataTransferItem); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/context_features/ContextFeatureSettings.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/context_features/ContextFeatureSettings.cpp index a5045c8592..f70610cf8f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/context_features/ContextFeatureSettings.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/context_features/ContextFeatureSettings.cpp @@ -13,20 +13,17 @@ ContextFeatureSettings::ContextFeatureSettings(ExecutionContext& context) : Supplement(context) {} // static -const char* ContextFeatureSettings::SupplementName() { - return "ContextFeatureSettings"; -} +const char ContextFeatureSettings::kSupplementName[] = "ContextFeatureSettings"; // static ContextFeatureSettings* ContextFeatureSettings::From( ExecutionContext* context, CreationMode creation_mode) { - ContextFeatureSettings* settings = static_cast( - Supplement::From(context, SupplementName())); + ContextFeatureSettings* settings = + Supplement::From(context); if (!settings && creation_mode == CreationMode::kCreateIfNotExists) { settings = new ContextFeatureSettings(*context); - Supplement::ProvideTo(*context, SupplementName(), - settings); + Supplement::ProvideTo(*context, settings); } return settings; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/context_features/ContextFeatureSettings.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/context_features/ContextFeatureSettings.h index 48baaa8e17..6362f7cf27 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/context_features/ContextFeatureSettings.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/context_features/ContextFeatureSettings.h @@ -21,12 +21,12 @@ class CORE_EXPORT ContextFeatureSettings final public Supplement { USING_GARBAGE_COLLECTED_MIXIN(ContextFeatureSettings) public: + static const char kSupplementName[]; + enum class CreationMode { kCreateIfNotExists, kDontCreateIfNotExists }; explicit ContextFeatureSettings(ExecutionContext&); - static const char* SupplementName(); - // Returns the ContextFeatureSettings for an ExecutionContext. If one does not // already exist for the given context, one is created. static ContextFeatureSettings* From(ExecutionContext*, CreationMode); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/core.gni b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/core.gni index f1f7963faa..98d6a11ccb 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/core.gni +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/core.gni @@ -30,10 +30,8 @@ if (is_win && is_official_build) { core_config_add += [ "//build/config/compiler:optimize_max" ] } -if (remove_webcore_debug_symbols) { - core_config_remove += [ "//build/config/compiler:default_symbols" ] - core_config_add += remove_webcore_symbols_config -} +core_config_remove += [ "//build/config/compiler:default_symbols" ] +core_config_add += blink_symbols_config # Use this target type to link core targets. if (is_component_build) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/core_idl_files.gni b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/core_idl_files.gni index 697e5c8a59..0d283d4e01 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/core_idl_files.gni +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/core_idl_files.gni @@ -86,20 +86,22 @@ core_idl_files = "css/cssom/CSSNumericValue.idl", "css/cssom/CSSPerspective.idl", "css/cssom/CSSPositionValue.idl", - "css/cssom/CSSResourceValue.idl", - "css/cssom/CSSRotation.idl", + "css/cssom/CSSRotate.idl", "css/cssom/CSSScale.idl", "css/cssom/CSSSkew.idl", + "css/cssom/CSSSkewX.idl", + "css/cssom/CSSSkewY.idl", "css/cssom/CSSStyleValue.idl", "css/cssom/CSSTransformComponent.idl", "css/cssom/CSSTransformValue.idl", - "css/cssom/CSSTranslation.idl", - "css/cssom/CSSURLImageValue.idl", + "css/cssom/CSSTranslate.idl", "css/cssom/CSSUnitValue.idl", "css/cssom/CSSUnparsedValue.idl", "css/cssom/CSSVariableReferenceValue.idl", "css/cssom/StylePropertyMap.idl", "css/cssom/StylePropertyMapReadOnly.idl", + "dom/AbortController.idl", + "dom/AbortSignal.idl", "dom/AccessibleNode.idl", "dom/AccessibleNodeList.idl", "dom/Attr.idl", @@ -112,7 +114,6 @@ core_idl_files = "dom/DOMStringList.idl", "dom/DOMStringMap.idl", "dom/DOMTokenList.idl", - "dom/Document.idl", "dom/DocumentFragment.idl", "dom/DocumentType.idl", "dom/Element.idl", @@ -128,7 +129,6 @@ core_idl_files = "policy/Policy.idl", "dom/ProcessingInstruction.idl", "dom/Range.idl", - "dom/ShadowRoot.idl", "dom/StaticRange.idl", "dom/Text.idl", "dom/TreeWalker.idl", @@ -294,6 +294,7 @@ core_idl_files = "inspector/InspectorOverlayHost.idl", "intersection_observer/IntersectionObserver.idl", "intersection_observer/IntersectionObserverEntry.idl", + "layout/custom/LayoutChild.idl", "layout/custom/LayoutWorkletGlobalScope.idl", "loader/appcache/ApplicationCache.idl", "messaging/MessageChannel.idl", @@ -305,7 +306,6 @@ core_idl_files = "mojo/test/MojoInterfaceRequestEvent.idl", "page/PagePopupController.idl", "page/scrolling/ScrollState.idl", - "page/scrolling/ScrollStateCallback.idl", "resize_observer/ResizeObserver.idl", "resize_observer/ResizeObserverEntry.idl", "streams/UnderlyingSourceBase.idl", @@ -460,6 +460,8 @@ core_idl_with_modules_dependency_files = get_path_info([ "clipboard/DataTransferItem.idl", "css/CSS.idl", + "dom/Document.idl", + "dom/ShadowRoot.idl", "frame/Navigator.idl", "frame/Screen.idl", "frame/Window.idl", @@ -559,11 +561,13 @@ core_dictionary_idl_files = "animation/KeyframeAnimationOptions.idl", "animation/KeyframeEffectOptions.idl", "animation/ScrollTimelineOptions.idl", + "css/CSSStyleSheetInit.idl", "css/FontFaceDescriptors.idl", "css/FontFaceSetLoadEventInit.idl", "css/MediaQueryListEventInit.idl", "css/PropertyDescriptor.idl", "css/cssom/CSSMatrixComponentOptions.idl", + "css/cssom/CSSNumericType.idl", "dom/ElementCreationOptions.idl", "dom/ElementDefinitionOptions.idl", "dom/ElementRegistrationOptions.idl", @@ -612,13 +616,13 @@ core_dictionary_idl_files = "geometry/DOMRectInit.idl", "html/FocusOptions.idl", "html/AssignedNodesOptions.idl", - "html/canvas/CanvasContextCreationAttributes.idl", "html/canvas/ImageDataColorSettings.idl", "html/track/TrackEventInit.idl", "imagebitmap/ImageBitmapOptions.idl", "input/InputDeviceCapabilitiesInit.idl", "input/TouchInit.idl", "intersection_observer/IntersectionObserverInit.idl", + "layout/custom/FragmentResultOptions.idl", "mojo/MojoCreateDataPipeOptions.idl", "mojo/MojoCreateDataPipeResult.idl", "mojo/MojoCreateMessagePipeResult.idl", @@ -665,6 +669,7 @@ webcore_testing_idl_files = "testing/OriginTrialsTest.idl", "testing/RecordTest.idl", "testing/SequenceTest.idl", + "testing/StaticSelection.idl", "testing/TypeConversions.idl", "testing/UnionTypesTest.idl", "testing/WorkerInternals.idl", diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/AbstractPropertySetCSSStyleDeclaration.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/AbstractPropertySetCSSStyleDeclaration.cpp index 2d12bc0f8a..c54bac8870 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/AbstractPropertySetCSSStyleDeclaration.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/AbstractPropertySetCSSStyleDeclaration.cpp @@ -227,8 +227,8 @@ StyleSheetContents* AbstractPropertySetCSSStyleDeclaration::ContextStyleSheet() bool AbstractPropertySetCSSStyleDeclaration::CssPropertyMatches( CSSPropertyID property_id, - const CSSValue* property_value) const { - return PropertySet().PropertyMatches(property_id, *property_value); + const CSSValue& property_value) const { + return PropertySet().PropertyMatches(property_id, property_value); } void AbstractPropertySetCSSStyleDeclaration::Trace(blink::Visitor* visitor) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/AbstractPropertySetCSSStyleDeclaration.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/AbstractPropertySetCSSStyleDeclaration.h index 8f8e237626..6785d8bf76 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/AbstractPropertySetCSSStyleDeclaration.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/AbstractPropertySetCSSStyleDeclaration.h @@ -41,7 +41,7 @@ class StyleSheetContents; class AbstractPropertySetCSSStyleDeclaration : public CSSStyleDeclaration { public: - Element* ParentElement() const override { return nullptr; } + virtual Element* ParentElement() const { return nullptr; } StyleSheetContents* ContextStyleSheet() const; virtual void Trace(blink::Visitor*); @@ -77,7 +77,7 @@ class AbstractPropertySetCSSStyleDeclaration : public CSSStyleDeclaration { SecureContextMode, ExceptionState&) final; - bool CssPropertyMatches(CSSPropertyID, const CSSValue*) const final; + bool CssPropertyMatches(CSSPropertyID, const CSSValue&) const final; protected: enum MutationType { kNoChanges, kPropertyChanged }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/BUILD.gn b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/BUILD.gn index e88052757b..ff2fc6ca93 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/BUILD.gn +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/BUILD.gn @@ -11,10 +11,6 @@ blink_core_sources("css") { "AbstractPropertySetCSSStyleDeclaration.h", "ActiveStyleSheets.cpp", "ActiveStyleSheets.h", - "AtRuleCSSStyleDeclaration.cpp", - "AtRuleCSSStyleDeclaration.h", - "AtRuleDescriptorSerializer.cpp", - "AtRuleDescriptorSerializer.h", "BasicShapeFunctions.cpp", "BasicShapeFunctions.h", "BinaryDataFontFaceSource.cpp", @@ -98,6 +94,8 @@ blink_core_sources("css") { "CSSKeyframeRule.h", "CSSKeyframesRule.cpp", "CSSKeyframesRule.h", + "CSSLayoutFunctionValue.cpp", + "CSSLayoutFunctionValue.h", "CSSMarkup.cpp", "CSSMarkup.h", "CSSMediaRule.cpp", @@ -338,23 +336,29 @@ blink_core_sources("css") { "cssom/CSSPositionValue.cpp", "cssom/CSSPositionValue.h", "cssom/CSSResourceValue.h", - "cssom/CSSRotation.cpp", - "cssom/CSSRotation.h", + "cssom/CSSRotate.cpp", + "cssom/CSSRotate.h", "cssom/CSSScale.cpp", "cssom/CSSScale.h", "cssom/CSSSkew.cpp", "cssom/CSSSkew.h", + "cssom/CSSSkewX.cpp", + "cssom/CSSSkewX.h", + "cssom/CSSSkewY.cpp", + "cssom/CSSSkewY.h", "cssom/CSSStyleImageValue.cpp", "cssom/CSSStyleImageValue.h", "cssom/CSSStyleValue.cpp", "cssom/CSSStyleValue.h", + "cssom/CSSStyleVariableReferenceValue.cpp", "cssom/CSSStyleVariableReferenceValue.h", "cssom/CSSTransformComponent.cpp", "cssom/CSSTransformComponent.h", "cssom/CSSTransformValue.cpp", "cssom/CSSTransformValue.h", - "cssom/CSSTranslation.cpp", - "cssom/CSSTranslation.h", + "cssom/CSSTranslate.cpp", + "cssom/CSSTranslate.h", + "cssom/CSSURLImageValue.cpp", "cssom/CSSURLImageValue.h", "cssom/CSSUnitValue.cpp", "cssom/CSSUnitValue.h", @@ -368,10 +372,10 @@ blink_core_sources("css") { "cssom/DeclaredStylePropertyMap.cpp", "cssom/DeclaredStylePropertyMap.h", "cssom/ElementComputedStyleMap.h", - "cssom/FilteredComputedStylePropertyMap.cpp", - "cssom/FilteredComputedStylePropertyMap.h", "cssom/InlineStylePropertyMap.cpp", "cssom/InlineStylePropertyMap.h", + "cssom/PrepopulatedComputedStylePropertyMap.cpp", + "cssom/PrepopulatedComputedStylePropertyMap.h", "cssom/StylePropertyMap.cpp", "cssom/StylePropertyMap.h", "cssom/StylePropertyMapReadOnly.cpp", @@ -385,8 +389,6 @@ blink_core_sources("css") { "invalidation/StyleInvalidator.h", "parser/AtRuleDescriptorParser.cpp", "parser/AtRuleDescriptorParser.h", - "parser/AtRuleDescriptorValueSet.cpp", - "parser/AtRuleDescriptorValueSet.h", "parser/CSSAtRuleID.cpp", "parser/CSSAtRuleID.h", "parser/CSSLazyParsingState.cpp", @@ -560,10 +562,8 @@ blink_core_sources("css") { "properties/longhands/GridAutoFlowCustom.cpp", "properties/longhands/GridAutoRowsCustom.cpp", "properties/longhands/GridColumnEndCustom.cpp", - "properties/longhands/GridColumnGapCustom.cpp", "properties/longhands/GridColumnStartCustom.cpp", "properties/longhands/GridRowEndCustom.cpp", - "properties/longhands/GridRowGapCustom.cpp", "properties/longhands/GridRowStartCustom.cpp", "properties/longhands/GridTemplateAreasCustom.cpp", "properties/longhands/GridTemplateColumnsCustom.cpp", @@ -640,10 +640,12 @@ blink_core_sources("css") { "properties/longhands/ResizeCustom.cpp", "properties/longhands/RightCustom.cpp", "properties/longhands/RotateCustom.cpp", + "properties/longhands/RowGapCustom.cpp", "properties/longhands/RxCustom.cpp", "properties/longhands/RyCustom.cpp", "properties/longhands/ScaleCustom.cpp", "properties/longhands/ScrollBehaviorCustom.cpp", + "properties/longhands/ScrollCustomizationCustom.cpp", "properties/longhands/ScrollMarginBlockEndCustom.cpp", "properties/longhands/ScrollMarginBlockStartCustom.cpp", "properties/longhands/ScrollMarginBottomCustom.cpp", @@ -830,11 +832,14 @@ blink_core_sources("css") { "properties/shorthands/FlexFlowCustom.cpp", "properties/shorthands/FontCustom.cpp", "properties/shorthands/FontVariantCustom.cpp", + "properties/shorthands/GapCustom.cpp", "properties/shorthands/GridAreaCustom.cpp", "properties/shorthands/GridColumnCustom.cpp", + "properties/shorthands/GridColumnGapCustom.cpp", "properties/shorthands/GridCustom.cpp", "properties/shorthands/GridGapCustom.cpp", "properties/shorthands/GridRowCustom.cpp", + "properties/shorthands/GridRowGapCustom.cpp", "properties/shorthands/GridTemplateCustom.cpp", "properties/shorthands/ListStyleCustom.cpp", "properties/shorthands/MarginCustom.cpp", diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/BasicShapeFunctions.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/BasicShapeFunctions.cpp index 608f94fd31..7e29d32b3e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/BasicShapeFunctions.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/BasicShapeFunctions.cpp @@ -120,7 +120,7 @@ CSSValue* ValueForBasicShape(const ComputedStyle& style, switch (basic_shape->GetType()) { case BasicShape::kStyleRayType: { const StyleRay& ray = ToStyleRay(*basic_shape); - return CSSRayValue::Create( + return cssvalue::CSSRayValue::Create( *CSSPrimitiveValue::Create(ray.Angle(), CSSPrimitiveValue::UnitType::kDegrees), *CSSIdentifierValue::Create(RaySizeToKeyword(ray.Size())), @@ -133,8 +133,8 @@ CSSValue* ValueForBasicShape(const ComputedStyle& style, case BasicShape::kBasicShapeCircleType: { const BasicShapeCircle* circle = ToBasicShapeCircle(basic_shape); - CSSBasicShapeCircleValue* circle_value = - CSSBasicShapeCircleValue::Create(); + cssvalue::CSSBasicShapeCircleValue* circle_value = + cssvalue::CSSBasicShapeCircleValue::Create(); circle_value->SetCenterX(ValueForCenterCoordinate( style, circle->CenterX(), EBoxOrient::kHorizontal)); @@ -146,8 +146,8 @@ CSSValue* ValueForBasicShape(const ComputedStyle& style, } case BasicShape::kBasicShapeEllipseType: { const BasicShapeEllipse* ellipse = ToBasicShapeEllipse(basic_shape); - CSSBasicShapeEllipseValue* ellipse_value = - CSSBasicShapeEllipseValue::Create(); + cssvalue::CSSBasicShapeEllipseValue* ellipse_value = + cssvalue::CSSBasicShapeEllipseValue::Create(); ellipse_value->SetCenterX(ValueForCenterCoordinate( style, ellipse->CenterX(), EBoxOrient::kHorizontal)); @@ -161,8 +161,8 @@ CSSValue* ValueForBasicShape(const ComputedStyle& style, } case BasicShape::kBasicShapePolygonType: { const BasicShapePolygon* polygon = ToBasicShapePolygon(basic_shape); - CSSBasicShapePolygonValue* polygon_value = - CSSBasicShapePolygonValue::Create(); + cssvalue::CSSBasicShapePolygonValue* polygon_value = + cssvalue::CSSBasicShapePolygonValue::Create(); polygon_value->SetWindRule(polygon->GetWindRule()); const Vector& values = polygon->Values(); @@ -175,7 +175,8 @@ CSSValue* ValueForBasicShape(const ComputedStyle& style, } case BasicShape::kBasicShapeInsetType: { const BasicShapeInset* inset = ToBasicShapeInset(basic_shape); - CSSBasicShapeInsetValue* inset_value = CSSBasicShapeInsetValue::Create(); + cssvalue::CSSBasicShapeInsetValue* inset_value = + cssvalue::CSSBasicShapeInsetValue::Create(); inset_value->SetTop( CSSPrimitiveValue::Create(inset->Top(), style.EffectiveZoom())); @@ -287,8 +288,8 @@ scoped_refptr BasicShapeForValue( scoped_refptr basic_shape; if (basic_shape_value.IsBasicShapeCircleValue()) { - const CSSBasicShapeCircleValue& circle_value = - ToCSSBasicShapeCircleValue(basic_shape_value); + const cssvalue::CSSBasicShapeCircleValue& circle_value = + cssvalue::ToCSSBasicShapeCircleValue(basic_shape_value); scoped_refptr circle = BasicShapeCircle::Create(); circle->SetCenterX( @@ -299,8 +300,8 @@ scoped_refptr BasicShapeForValue( basic_shape = std::move(circle); } else if (basic_shape_value.IsBasicShapeEllipseValue()) { - const CSSBasicShapeEllipseValue& ellipse_value = - ToCSSBasicShapeEllipseValue(basic_shape_value); + const cssvalue::CSSBasicShapeEllipseValue& ellipse_value = + cssvalue::ToCSSBasicShapeEllipseValue(basic_shape_value); scoped_refptr ellipse = BasicShapeEllipse::Create(); ellipse->SetCenterX( @@ -314,8 +315,8 @@ scoped_refptr BasicShapeForValue( basic_shape = std::move(ellipse); } else if (basic_shape_value.IsBasicShapePolygonValue()) { - const CSSBasicShapePolygonValue& polygon_value = - ToCSSBasicShapePolygonValue(basic_shape_value); + const cssvalue::CSSBasicShapePolygonValue& polygon_value = + cssvalue::ToCSSBasicShapePolygonValue(basic_shape_value); scoped_refptr polygon = BasicShapePolygon::Create(); polygon->SetWindRule(polygon_value.GetWindRule()); @@ -327,8 +328,8 @@ scoped_refptr BasicShapeForValue( basic_shape = std::move(polygon); } else if (basic_shape_value.IsBasicShapeInsetValue()) { - const CSSBasicShapeInsetValue& rect_value = - ToCSSBasicShapeInsetValue(basic_shape_value); + const cssvalue::CSSBasicShapeInsetValue& rect_value = + cssvalue::ToCSSBasicShapeInsetValue(basic_shape_value); scoped_refptr rect = BasicShapeInset::Create(); rect->SetTop(ConvertToLength(state, rect_value.Top())); @@ -347,7 +348,8 @@ scoped_refptr BasicShapeForValue( basic_shape = std::move(rect); } else if (basic_shape_value.IsRayValue()) { - const CSSRayValue& ray_value = ToCSSRayValue(basic_shape_value); + const cssvalue::CSSRayValue& ray_value = + cssvalue::ToCSSRayValue(basic_shape_value); float angle = ray_value.Angle().ComputeDegrees(); StyleRay::RaySize size = KeywordToRaySize(ray_value.Size().GetValueID()); bool contain = !!ray_value.Contain(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSBasicShapeValues.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSBasicShapeValues.cpp index cf76485620..f7122a5c18 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSBasicShapeValues.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSBasicShapeValues.cpp @@ -36,6 +36,7 @@ #include "platform/wtf/text/StringBuilder.h" namespace blink { +namespace cssvalue { static String BuildCircleString(const String& radius, const String& center_x, @@ -436,4 +437,5 @@ void CSSBasicShapeInsetValue::TraceAfterDispatch(blink::Visitor* visitor) { CSSValue::TraceAfterDispatch(visitor); } +} // namespace cssvalue } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSBasicShapeValues.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSBasicShapeValues.h index 534e43c6f2..a508ec4482 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSBasicShapeValues.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSBasicShapeValues.h @@ -39,6 +39,7 @@ #include "platform/wtf/text/WTFString.h" namespace blink { +namespace cssvalue { class CSSBasicShapeCircleValue final : public CSSValue { public: @@ -216,6 +217,7 @@ DEFINE_CSS_VALUE_TYPE_CASTS(CSSBasicShapePolygonValue, IsBasicShapePolygonValue()); DEFINE_CSS_VALUE_TYPE_CASTS(CSSBasicShapeInsetValue, IsBasicShapeInsetValue()); +} // namespace cssvalue } // namespace blink #endif // CSSBasicShapeValues_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp index 54e48645f6..0f5c61e40b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.cpp @@ -39,6 +39,7 @@ #include "core/dom/Document.h" #include "core/dom/ExceptionCode.h" #include "core/dom/PseudoElement.h" +#include "core/frame/UseCounter.h" #include "core/layout/LayoutObject.h" #include "core/style/ComputedStyle.h" #include "platform/wtf/text/StringBuilder.h" @@ -97,9 +98,9 @@ const CSSPropertyID kComputedPropertyArray[] = { CSSPropertyOverflowX, CSSPropertyOverflowY, CSSPropertyPaddingBottom, CSSPropertyPaddingLeft, CSSPropertyPaddingRight, CSSPropertyPaddingTop, CSSPropertyPointerEvents, CSSPropertyPosition, CSSPropertyResize, - CSSPropertyRight, CSSPropertyScrollBehavior, CSSPropertySpeak, - CSSPropertyTableLayout, CSSPropertyTabSize, CSSPropertyTextAlign, - CSSPropertyTextAlignLast, CSSPropertyTextDecoration, + CSSPropertyRight, CSSPropertyScrollBehavior, CSSPropertyScrollCustomization, + CSSPropertySpeak, CSSPropertyTableLayout, CSSPropertyTabSize, + CSSPropertyTextAlign, CSSPropertyTextAlignLast, CSSPropertyTextDecoration, CSSPropertyTextDecorationLine, CSSPropertyTextDecorationStyle, CSSPropertyTextDecorationColor, CSSPropertyTextDecorationSkipInk, CSSPropertyTextJustify, CSSPropertyTextUnderlinePosition, @@ -131,8 +132,8 @@ const CSSPropertyID kComputedPropertyArray[] = { CSSPropertyGridAutoRows, CSSPropertyGridColumnEnd, CSSPropertyGridColumnStart, CSSPropertyGridTemplateAreas, CSSPropertyGridTemplateColumns, CSSPropertyGridTemplateRows, - CSSPropertyGridRowEnd, CSSPropertyGridRowStart, CSSPropertyGridColumnGap, - CSSPropertyGridRowGap, CSSPropertyWebkitHighlight, CSSPropertyHyphens, + CSSPropertyGridRowEnd, CSSPropertyGridRowStart, CSSPropertyRowGap, + CSSPropertyWebkitHighlight, CSSPropertyHyphens, CSSPropertyWebkitHyphenateCharacter, CSSPropertyWebkitLineBreak, CSSPropertyWebkitLineClamp, CSSPropertyWebkitLocale, CSSPropertyWebkitMarginBeforeCollapse, CSSPropertyWebkitMarginAfterCollapse, @@ -389,10 +390,10 @@ String CSSComputedStyleDeclaration::item(unsigned i) const { bool CSSComputedStyleDeclaration::CssPropertyMatches( CSSPropertyID property_id, - const CSSValue* property_value) const { + const CSSValue& property_value) const { if (property_id == CSSPropertyFontSize && - (property_value->IsPrimitiveValue() || - property_value->IsIdentifierValue()) && + (property_value.IsPrimitiveValue() || + property_value.IsIdentifierValue()) && node_) { node_->GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); const ComputedStyle* style = @@ -400,13 +401,13 @@ bool CSSComputedStyleDeclaration::CssPropertyMatches( if (style && style->GetFontDescription().KeywordSize()) { CSSValueID size_value = CssIdentifierForFontSizeKeyword( style->GetFontDescription().KeywordSize()); - if (property_value->IsIdentifierValue() && - ToCSSIdentifierValue(property_value)->GetValueID() == size_value) + if (property_value.IsIdentifierValue() && + ToCSSIdentifierValue(property_value).GetValueID() == size_value) return true; } } const CSSValue* value = GetPropertyCSSValue(CSSProperty::Get(property_id)); - return DataEquivalent(value, property_value); + return DataEquivalent(value, &property_value); } MutableCSSPropertyValueSet* CSSComputedStyleDeclaration::CopyProperties() @@ -484,6 +485,10 @@ String CSSComputedStyleDeclaration::removeProperty( const CSSValue* CSSComputedStyleDeclaration::GetPropertyCSSValueInternal( CSSPropertyID property_id) { + if (property_id == CSSPropertyWebkitAppearance && node_) { + UseCounter::Count(node_->GetDocument(), + WebFeature::kGetComputedStyleWebkitAppearance); + } return GetPropertyCSSValue(CSSProperty::Get(property_id)); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.h index 69a02f5af0..d5bb14f725 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSComputedStyleDeclaration.h @@ -120,7 +120,7 @@ class CORE_EXPORT CSSComputedStyleDeclaration final SecureContextMode, ExceptionState&) override; - bool CssPropertyMatches(CSSPropertyID, const CSSValue*) const override; + bool CssPropertyMatches(CSSPropertyID, const CSSValue&) const override; Member node_; PseudoId pseudo_element_specifier_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSContentDistributionValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSContentDistributionValue.cpp index bdb5e2a5d2..b03cef2ec1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSContentDistributionValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSContentDistributionValue.cpp @@ -8,6 +8,7 @@ #include "platform/wtf/text/StringBuilder.h" namespace blink { +namespace cssvalue { CSSContentDistributionValue::CSSContentDistributionValue( CSSValueID distribution, @@ -33,12 +34,11 @@ String CSSContentDistributionValue::CustomCSSText() const { list->Append(*CSSIdentifierValue::Create(preference)); list->Append(*CSSIdentifierValue::Create(CSSValueBaseline)); } else { + if (overflow_ != CSSValueInvalid) + list->Append(*CSSIdentifierValue::Create(overflow_)); list->Append(*CSSIdentifierValue::Create(position_)); } } - if (overflow_ != CSSValueInvalid) - list->Append(*CSSIdentifierValue::Create(overflow_)); - return list->CustomCSSText(); } @@ -48,4 +48,5 @@ bool CSSContentDistributionValue::Equals( overflow_ == other.overflow_; } +} // namespace cssvalue } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSContentDistributionValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSContentDistributionValue.h index e24fd2cc31..6f58bfad03 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSContentDistributionValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSContentDistributionValue.h @@ -11,6 +11,7 @@ #include "core/css/CSSValuePair.h" namespace blink { +namespace cssvalue { class CSSContentDistributionValue : public CSSValue { public: @@ -48,6 +49,7 @@ class CSSContentDistributionValue : public CSSValue { DEFINE_CSS_VALUE_TYPE_CASTS(CSSContentDistributionValue, IsContentDistributionValue()); +} // namespace cssvalue } // namespace blink #endif // CSSContentDistributionValue_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp index 9d3c77e89a..0d6a1d2bff 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp @@ -151,8 +151,9 @@ CSSCrossfadeValue* CSSCrossfadeValue::ValueWithURLsMadeAbsolute() { return CSSCrossfadeValue::Create(from_value, to_value, percentage_value_); } -FloatSize CSSCrossfadeValue::FixedSize(const Document& document, - const FloatSize& default_object_size) { +FloatSize CSSCrossfadeValue::FixedSize( + const Document& document, + const FloatSize& default_object_size) const { Image* from_image = RenderableImageForCSSValue(from_value_.Get(), document); Image* to_image = RenderableImageForCSSValue(to_value_.Get(), document); @@ -226,7 +227,7 @@ scoped_refptr CSSCrossfadeValue::GetImage( const ImageResourceObserver& client, const Document& document, const ComputedStyle&, - const LayoutSize& size) { + const FloatSize& size) const { if (size.IsEmpty()) return nullptr; @@ -247,9 +248,9 @@ scoped_refptr CSSCrossfadeValue::GetImage( to_image_ref = SVGImageForContainer::Create( ToSVGImage(to_image), size, 1, UrlForCSSValue(to_value_.Get())); - return CrossfadeGeneratedImage::Create( - from_image_ref, to_image_ref, percentage_value_->GetFloatValue(), - FixedSize(document, FloatSize(size)), FloatSize(size)); + return CrossfadeGeneratedImage::Create(from_image_ref, to_image_ref, + percentage_value_->GetFloatValue(), + FixedSize(document, size), size); } void CSSCrossfadeValue::CrossfadeChanged( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSCrossfadeValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSCrossfadeValue.h index 419296730d..c5d81f8033 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSCrossfadeValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSCrossfadeValue.h @@ -57,9 +57,9 @@ class CORE_EXPORT CSSCrossfadeValue final : public CSSImageGeneratorValue { scoped_refptr GetImage(const ImageResourceObserver&, const Document&, const ComputedStyle&, - const LayoutSize& container_size); + const FloatSize& target_size) const; bool IsFixedSize() const { return true; } - FloatSize FixedSize(const Document&, const FloatSize&); + FloatSize FixedSize(const Document&, const FloatSize&) const; bool IsPending() const; bool KnownToBeOpaque(const Document&, const ComputedStyle&) const; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceRule.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceRule.cpp index 61d19220c1..c284737049 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceRule.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceRule.cpp @@ -21,10 +21,9 @@ #include "core/css/CSSFontFaceRule.h" -#include "core/css/AtRuleCSSStyleDeclaration.h" #include "core/css/CSSPropertyValueSet.h" #include "core/css/StyleRule.h" -#include "core/css/parser/AtRuleDescriptorValueSet.h" +#include "core/css/StyleRuleCSSStyleDeclaration.h" #include "platform/wtf/text/StringBuilder.h" namespace blink { @@ -37,9 +36,9 @@ CSSFontFaceRule::~CSSFontFaceRule() = default; CSSStyleDeclaration* CSSFontFaceRule::style() const { if (!properties_cssom_wrapper_) { - properties_cssom_wrapper_ = - AtRuleCSSStyleDeclaration::Create(&font_face_rule_->MutableProperties(), - const_cast(this)); + properties_cssom_wrapper_ = StyleRuleCSSStyleDeclaration::Create( + font_face_rule_->MutableProperties(), + const_cast(this)); } return properties_cssom_wrapper_.Get(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceRule.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceRule.h index 4895a248a4..9abae288cf 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceRule.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceRule.h @@ -27,9 +27,9 @@ namespace blink { -class AtRuleCSSStyleDeclaration; class CSSStyleDeclaration; class StyleRuleFontFace; +class StyleRuleCSSStyleDeclaration; class CSSFontFaceRule final : public CSSRule { DEFINE_WRAPPERTYPEINFO(); @@ -57,7 +57,7 @@ class CSSFontFaceRule final : public CSSRule { CSSRule::Type type() const override { return kFontFaceRule; } Member font_face_rule_; - mutable Member properties_cssom_wrapper_; + mutable Member properties_cssom_wrapper_; }; DEFINE_CSS_RULE_TYPE_CASTS(CSSFontFaceRule, kFontFaceRule); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSource.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSource.cpp index 65d2656708..45f429f949 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSource.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSource.cpp @@ -60,10 +60,15 @@ scoped_refptr CSSFontFaceSource::GetFontData( FontCacheKey key = font_description.CacheKey(FontFaceCreationParams()); - scoped_refptr& font_data = - font_data_table_.insert(key, nullptr).stored_value->value; - if (!font_data) - font_data = CreateFontData(font_description, font_selection_capabilities); + // Get or create the font data. Take care to avoid dangling references into + // font_data_table_, because it is modified below during pruning. + scoped_refptr font_data; + { + auto* it = font_data_table_.insert(key, nullptr).stored_value; + if (!it->value) + it->value = CreateFontData(font_description, font_selection_capabilities); + font_data = it->value; + } font_cache_key_age.PrependOrMoveToFirst(key); PruneOldestIfNeeded(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSourceTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSourceTest.cpp index 64e1a3ceb8..c9a33746f4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSourceTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSourceTest.cpp @@ -19,8 +19,8 @@ class DummyFontFaceSource : public CSSFontFaceSource { const FontDescription&, const FontSelectionCapabilities&) override { return SimpleFontData::Create(FontPlatformData( - PaintTypeface::FromSkTypeface(SkTypeface::MakeDefault()), "", 0, false, - false)); + PaintTypeface::FromSkTypeface(SkTypeface::MakeDefault()), CString(), 0, + false, false)); } DummyFontFaceSource() = default; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSrcValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSrcValue.cpp index 68d7120199..050342d583 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSrcValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSrcValue.cpp @@ -79,7 +79,7 @@ bool CSSFontFaceSrcValue::HasFailedOrCanceledSubresources() const { return fetched_ && fetched_->GetResource()->LoadFailedOrCanceled(); } -FontResource* CSSFontFaceSrcValue::Fetch(ExecutionContext* context, +FontResource& CSSFontFaceSrcValue::Fetch(ExecutionContext* context, FontResourceClient* client) const { if (!fetched_) { ResourceRequest resource_request(absolute_resource_); @@ -104,12 +104,9 @@ FontResource* CSSFontFaceSrcValue::Fetch(ExecutionContext* context, if (context->IsWorkerGlobalScope()) { ToWorkerGlobalScope(context)->EnsureFetcher(); } - FontResource* resource = - FontResource::Fetch(params, context->Fetcher(), client); - if (!resource) - return nullptr; fetched_ = FontResourceHelper::Create( - resource, context->GetTaskRunner(TaskType::kUnspecedLoading).get()); + FontResource::Fetch(params, context->Fetcher(), client), + context->GetTaskRunner(TaskType::kUnspecedLoading).get()); } else { // FIXME: CSSFontFaceSrcValue::Fetch is invoked when @font-face rule // is processed by StyleResolver / StyleEngine. @@ -120,7 +117,7 @@ FontResource* CSSFontFaceSrcValue::Fetch(ExecutionContext* context, context->GetTaskRunner(TaskType::kUnspecedLoading).get()); } } - return ToFontResource(fetched_->GetResource()); + return *ToFontResource(fetched_->GetResource()); } void CSSFontFaceSrcValue::RestoreCachedResourceIfNeeded( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSrcValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSrcValue.h index a807cdc376..1fb96f1671 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSrcValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFaceSrcValue.h @@ -67,7 +67,7 @@ class CORE_EXPORT CSSFontFaceSrcValue : public CSSValue { bool HasFailedOrCanceledSubresources() const; - FontResource* Fetch(ExecutionContext*, FontResourceClient*) const; + FontResource& Fetch(ExecutionContext*, FontResourceClient*) const; bool Equals(const CSSFontFaceSrcValue&) const; @@ -106,8 +106,9 @@ class CORE_EXPORT CSSFontFaceSrcValue : public CSSValue { USING_GARBAGE_COLLECTED_MIXIN(FontResourceHelper); public: - static FontResourceHelper* Create(FontResource* resource, - WebTaskRunner* task_runner) { + static FontResourceHelper* Create( + FontResource* resource, + base::SingleThreadTaskRunner* task_runner) { return new FontResourceHelper(resource, task_runner); } @@ -116,7 +117,8 @@ class CORE_EXPORT CSSFontFaceSrcValue : public CSSValue { } private: - FontResourceHelper(FontResource* resource, WebTaskRunner* task_runner) { + FontResourceHelper(FontResource* resource, + base::SingleThreadTaskRunner* task_runner) { SetResource(resource, task_runner); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFeatureValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFeatureValue.cpp index 90d08b3fb6..61d2028ab0 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFeatureValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontFeatureValue.cpp @@ -35,10 +35,14 @@ CSSFontFeatureValue::CSSFontFeatureValue(const AtomicString& tag, int value) String CSSFontFeatureValue::CustomCSSText() const { StringBuilder builder; - builder.Append('\''); + builder.Append('"'); builder.Append(tag_); - builder.Append("' "); - builder.AppendNumber(value_); + builder.Append('"'); + // Omit the value if it's 1 as 1 is implied by default. + if (value_ != 1) { + builder.Append(' '); + builder.AppendNumber(value_); + } return builder.ToString(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontVariationValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontVariationValue.cpp index 18bde583f5..479477121c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontVariationValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontVariationValue.cpp @@ -4,9 +4,11 @@ #include "core/css/CSSFontVariationValue.h" +#include "core/css/CSSMarkup.h" #include "platform/wtf/text/StringBuilder.h" namespace blink { +namespace cssvalue { CSSFontVariationValue::CSSFontVariationValue(const AtomicString& tag, float value) @@ -14,9 +16,8 @@ CSSFontVariationValue::CSSFontVariationValue(const AtomicString& tag, String CSSFontVariationValue::CustomCSSText() const { StringBuilder builder; - builder.Append('\''); - builder.Append(tag_); - builder.Append("' "); + SerializeString(tag_, builder); + builder.Append(' '); builder.AppendNumber(value_); return builder.ToString(); } @@ -25,4 +26,5 @@ bool CSSFontVariationValue::Equals(const CSSFontVariationValue& other) const { return tag_ == other.tag_ && value_ == other.value_; } +} // namespace cssvalue } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontVariationValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontVariationValue.h index 627694de81..22f387a613 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontVariationValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSFontVariationValue.h @@ -9,6 +9,7 @@ #include "platform/wtf/text/WTFString.h" namespace blink { +namespace cssvalue { class CSSFontVariationValue : public CSSValue { public: @@ -35,6 +36,7 @@ class CSSFontVariationValue : public CSSValue { DEFINE_CSS_VALUE_TYPE_CASTS(CSSFontVariationValue, IsFontVariationValue()); +} // namespace cssvalue } // namespace blink #endif diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSGradientValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSGradientValue.cpp index 6a888d4e34..8d626c5270 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSGradientValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSGradientValue.cpp @@ -36,7 +36,6 @@ #include "core/css/CSSValuePair.h" #include "core/dom/NodeComputedStyle.h" #include "core/dom/TextLinkColors.h" -#include "core/layout/LayoutObject.h" #include "platform/geometry/IntSize.h" #include "platform/graphics/ColorBlend.h" #include "platform/graphics/Gradient.h" @@ -107,7 +106,7 @@ scoped_refptr CSSGradientValue::GetImage( const ImageResourceObserver& client, const Document& document, const ComputedStyle& style, - const LayoutSize& size) { + const FloatSize& size) const { if (size.IsEmpty()) return nullptr; @@ -120,34 +119,31 @@ scoped_refptr CSSGradientValue::GetImage( } // We need to create an image. - scoped_refptr gradient; - const ComputedStyle* root_style = document.documentElement()->GetComputedStyle(); - // TODO: Break dependency on LayoutObject. - const LayoutObject& layout_object = static_cast(client); CSSToLengthConversionData conversion_data( - &style, root_style, layout_object.View(), style.EffectiveZoom()); + &style, root_style, document.GetLayoutView(), style.EffectiveZoom()); + scoped_refptr gradient; switch (GetClassType()) { case kLinearGradientClass: gradient = ToCSSLinearGradientValue(this)->CreateGradient( - conversion_data, size, layout_object); + conversion_data, size, document, style); break; case kRadialGradientClass: gradient = ToCSSRadialGradientValue(this)->CreateGradient( - conversion_data, size, layout_object); + conversion_data, size, document, style); break; case kConicGradientClass: gradient = ToCSSConicGradientValue(this)->CreateGradient( - conversion_data, size, layout_object); + conversion_data, size, document, style); break; default: NOTREACHED(); } scoped_refptr new_image = - GradientGeneratedImage::Create(gradient, FloatSize(size)); + GradientGeneratedImage::Create(gradient, size); if (is_cacheable_) PutImage(size, new_image); @@ -294,30 +290,26 @@ static Color ResolveStopColor(const CSSValue& stop_color, stop_color, style.VisitedDependentColor(GetCSSPropertyColor())); } -static Color ResolveStopColor(const CSSValue& stop_color, - const LayoutObject& obj) { - return ResolveStopColor(stop_color, obj.GetDocument(), obj.StyleRef()); -} - void CSSGradientValue::AddDeprecatedStops(GradientDesc& desc, - const LayoutObject& object) { + const Document& document, + const ComputedStyle& style) const { DCHECK(gradient_type_ == kCSSDeprecatedLinearGradient || gradient_type_ == kCSSDeprecatedRadialGradient); - if (!stops_sorted_) { - if (stops_.size()) - std::stable_sort(stops_.begin(), stops_.end(), CompareStops); - stops_sorted_ = true; - } + // Performance here is probably not important because this is for deprecated + // gradients. + auto stops_sorted = stops_; + std::stable_sort(stops_sorted.begin(), stops_sorted.end(), CompareStops); - for (const auto& stop : stops_) { + for (const auto& stop : stops_sorted) { float offset; if (stop.offset_->IsPercentage()) offset = stop.offset_->GetFloatValue() / 100; else offset = stop.offset_->GetFloatValue(); - desc.stops.emplace_back(offset, ResolveStopColor(*stop.color_, object)); + const Color color = ResolveStopColor(*stop.color_, document, style); + desc.stops.emplace_back(offset, color); } } @@ -463,10 +455,11 @@ void AdjustGradientRadiiForOffsetRange(CSSGradientValue::GradientDesc& desc, void CSSGradientValue::AddStops( CSSGradientValue::GradientDesc& desc, const CSSToLengthConversionData& conversion_data, - const LayoutObject& object) { + const Document& document, + const ComputedStyle& style) const { if (gradient_type_ == kCSSDeprecatedLinearGradient || gradient_type_ == kCSSDeprecatedRadialGradient) { - AddDeprecatedStops(desc, object); + AddDeprecatedStops(desc, document, style); return; } @@ -497,7 +490,7 @@ void CSSGradientValue::AddStops( if (stop.IsHint()) has_hints = true; else - stops[i].color = ResolveStopColor(*stop.color_, object); + stops[i].color = ResolveStopColor(*stop.color_, document, style); if (stop.offset_) { if (stop.offset_->IsPercentage()) { @@ -631,12 +624,11 @@ void CSSGradientValue::AddStops( static float PositionFromValue(const CSSValue* value, const CSSToLengthConversionData& conversion_data, - const LayoutSize& size, + const FloatSize& size, bool is_horizontal) { float origin = 0; int sign = 1; - float edge_distance = - is_horizontal ? size.Width().ToFloat() : size.Height().ToFloat(); + float edge_distance = is_horizontal ? size.Width() : size.Height(); // In this case the center of the gradient is given relative to an edge in the // form of: [ top | bottom | right | left ] [ | ]. @@ -697,7 +689,7 @@ static FloatPoint ComputeEndPoint( const CSSValue* horizontal, const CSSValue* vertical, const CSSToLengthConversionData& conversion_data, - const LayoutSize& size) { + const FloatSize& size) { FloatPoint result; if (horizontal) @@ -719,12 +711,15 @@ bool CSSGradientValue::KnownToBeOpaque(const Document& document, return true; } -void CSSGradientValue::GetStopColors(Vector& stop_colors, - const LayoutObject& object) const { - for (auto& stop : stops_) { +Vector CSSGradientValue::GetStopColors( + const Document& document, + const ComputedStyle& style) const { + Vector stop_colors; + for (const auto& stop : stops_) { if (!stop.IsHint()) - stop_colors.push_back(ResolveStopColor(*stop.color_, object)); + stop_colors.push_back(ResolveStopColor(*stop.color_, document, style)); } + return stop_colors; } void CSSGradientValue::TraceAfterDispatch(blink::Visitor* visitor) { @@ -805,7 +800,7 @@ String CSSLinearGradientValue::CustomCSSText() const { // Compute the endpoints so that a gradient of the given angle covers a box of // the given size. static void EndPointsFromAngle(float angle_deg, - const LayoutSize& size, + const FloatSize& size, FloatPoint& first_point, FloatPoint& second_point, CSSGradientType type) { @@ -877,8 +872,9 @@ static void EndPointsFromAngle(float angle_deg, scoped_refptr CSSLinearGradientValue::CreateGradient( const CSSToLengthConversionData& conversion_data, - const LayoutSize& size, - const LayoutObject& object) { + const FloatSize& size, + const Document& document, + const ComputedStyle& style) const { DCHECK(!size.IsEmpty()); FloatPoint first_point; @@ -943,7 +939,7 @@ scoped_refptr CSSLinearGradientValue::CreateGradient( GradientDesc desc(first_point, second_point, repeating_ ? kSpreadMethodRepeat : kSpreadMethodPad); - AddStops(desc, conversion_data, object); + AddStops(desc, conversion_data, document, style); scoped_refptr gradient = Gradient::CreateLinear(desc.p0, desc.p1, desc.spread_method, @@ -1243,8 +1239,9 @@ FloatSize RadiusToCorner(const FloatPoint& point, scoped_refptr CSSRadialGradientValue::CreateGradient( const CSSToLengthConversionData& conversion_data, - const LayoutSize& size, - const LayoutObject& object) { + const FloatSize& size, + const Document& document, + const ComputedStyle& style) const { DCHECK(!size.IsEmpty()); FloatPoint first_point = @@ -1286,23 +1283,22 @@ scoped_refptr CSSRadialGradientValue::CreateGradient( ? kCircleEndShape : kEllipseEndShape; - FloatSize float_size(size); switch (sizing_behavior_ ? sizing_behavior_->GetValueID() : 0) { case CSSValueContain: case CSSValueClosestSide: - second_radius = RadiusToSide(second_point, float_size, shape, + second_radius = RadiusToSide(second_point, size, shape, [](float a, float b) { return a < b; }); break; case CSSValueFarthestSide: - second_radius = RadiusToSide(second_point, float_size, shape, + second_radius = RadiusToSide(second_point, size, shape, [](float a, float b) { return a > b; }); break; case CSSValueClosestCorner: - second_radius = RadiusToCorner(second_point, float_size, shape, + second_radius = RadiusToCorner(second_point, size, shape, [](float a, float b) { return a < b; }); break; default: - second_radius = RadiusToCorner(second_point, float_size, shape, + second_radius = RadiusToCorner(second_point, size, shape, [](float a, float b) { return a > b; }); break; } @@ -1316,7 +1312,7 @@ scoped_refptr CSSRadialGradientValue::CreateGradient( GradientDesc desc(first_point, second_point, first_radius, is_degenerate ? 0 : second_radius.Width(), repeating_ ? kSpreadMethodRepeat : kSpreadMethodPad); - AddStops(desc, conversion_data, object); + AddStops(desc, conversion_data, document, style); scoped_refptr gradient = Gradient::CreateRadial( desc.p0, desc.r0, desc.p1, desc.r1, @@ -1419,8 +1415,9 @@ String CSSConicGradientValue::CustomCSSText() const { scoped_refptr CSSConicGradientValue::CreateGradient( const CSSToLengthConversionData& conversion_data, - const LayoutSize& size, - const LayoutObject& object) { + const FloatSize& size, + const Document& document, + const ComputedStyle& style) const { DCHECK(!size.IsEmpty()); const float angle = from_angle_ ? from_angle_->ComputeDegrees() : 0; @@ -1433,7 +1430,7 @@ scoped_refptr CSSConicGradientValue::CreateGradient( GradientDesc desc(position, position, repeating_ ? kSpreadMethodRepeat : kSpreadMethodPad); - AddStops(desc, conversion_data, object); + AddStops(desc, conversion_data, document, style); scoped_refptr gradient = Gradient::CreateConic( position, angle, desc.start_angle, desc.end_angle, desc.spread_method, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSGradientValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSGradientValue.h index 47ee78002e..7186aa8faf 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSGradientValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSGradientValue.h @@ -37,7 +37,6 @@ namespace blink { class Color; class Gradient; class Document; -class LayoutObject; namespace cssvalue { @@ -96,7 +95,7 @@ class CSSGradientValue : public CSSImageGeneratorValue { scoped_refptr GetImage(const ImageResourceObserver&, const Document&, const ComputedStyle&, - const LayoutSize&); + const FloatSize&) const; void AddStop(const CSSGradientColorStop& stop) { stops_.push_back(stop); @@ -117,7 +116,7 @@ class CSSGradientValue : public CSSImageGeneratorValue { void LoadSubimages(const Document&) {} - void GetStopColors(Vector& stop_colors, const LayoutObject&) const; + Vector GetStopColors(const Document&, const ComputedStyle&) const; void TraceAfterDispatch(blink::Visitor*); @@ -130,13 +129,15 @@ class CSSGradientValue : public CSSImageGeneratorValue { : CSSImageGeneratorValue(class_type), gradient_type_(gradient_type), repeating_(repeat == kRepeating), - stops_sorted_(false), is_cacheable_(true) {} void AddStops(GradientDesc&, const CSSToLengthConversionData&, - const LayoutObject&); - void AddDeprecatedStops(GradientDesc&, const LayoutObject&); + const Document&, + const ComputedStyle&) const; + void AddDeprecatedStops(GradientDesc&, + const Document&, + const ComputedStyle&) const; void AppendCSSTextForColorStops(StringBuilder&, bool requires_separator) const; @@ -146,7 +147,6 @@ class CSSGradientValue : public CSSImageGeneratorValue { HeapVector stops_; CSSGradientType gradient_type_; bool repeating_ : 1; - bool stops_sorted_ : 1; bool is_cacheable_ : 1; }; @@ -170,8 +170,9 @@ class CSSLinearGradientValue final : public CSSGradientValue { // Create the gradient for a given size. scoped_refptr CreateGradient(const CSSToLengthConversionData&, - const LayoutSize&, - const LayoutObject&); + const FloatSize&, + const Document&, + const ComputedStyle&) const; bool Equals(const CSSLinearGradientValue&) const; @@ -243,8 +244,9 @@ class CSSRadialGradientValue final : public CSSGradientValue { // Create the gradient for a given size. scoped_refptr CreateGradient(const CSSToLengthConversionData&, - const LayoutSize&, - const LayoutObject&); + const FloatSize&, + const Document&, + const ComputedStyle&) const; bool Equals(const CSSRadialGradientValue&) const; @@ -309,8 +311,9 @@ class CSSConicGradientValue final : public CSSGradientValue { // Create the gradient for a given size. scoped_refptr CreateGradient(const CSSToLengthConversionData&, - const LayoutSize&, - const LayoutObject&); + const FloatSize&, + const Document&, + const ComputedStyle&) const; bool Equals(const CSSConicGradientValue&) const; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSIdentifierValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSIdentifierValue.cpp index 5e5126e7bc..147caea3b8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSIdentifierValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSIdentifierValue.cpp @@ -51,6 +51,7 @@ CSSIdentifierValue::CSSIdentifierValue(const Length& length) break; case kExtendToZoom: value_id_ = CSSValueInternalExtendToZoom; + break; case kPercent: case kFixed: case kCalculated: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageGeneratorValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageGeneratorValue.cpp index 7765fd61cf..b8986c0f85 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageGeneratorValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageGeneratorValue.cpp @@ -37,28 +37,43 @@ using cssvalue::ToCSSConicGradientValue; using cssvalue::ToCSSLinearGradientValue; using cssvalue::ToCSSRadialGradientValue; -Image* GeneratedImageCache::GetImage(const LayoutSize& size) const { +Image* GeneratedImageCache::GetImage(const FloatSize& size) const { if (size.IsEmpty()) return nullptr; - return images_.at(size); + + DCHECK(sizes_.find(size) != sizes_.end()); + GeneratedImageMap::const_iterator image_iter = images_.find(size); + if (image_iter == images_.end()) + return nullptr; + return image_iter->second.get(); } -void GeneratedImageCache::PutImage(const LayoutSize& size, +void GeneratedImageCache::PutImage(const FloatSize& size, scoped_refptr image) { - images_.insert(size, std::move(image)); + DCHECK(!size.IsEmpty()); + images_.insert( + std::pair>(size, std::move(image))); } -void GeneratedImageCache::AddSize(const LayoutSize& size) { - if (size.IsEmpty()) - return; - sizes_.insert(size); +void GeneratedImageCache::AddSize(const FloatSize& size) { + DCHECK(!size.IsEmpty()); + ImageSizeCountMap::iterator size_entry = sizes_.find(size); + if (size_entry == sizes_.end()) + sizes_.insert(std::pair(size, 1)); + else + size_entry->second++; } -void GeneratedImageCache::RemoveSize(const LayoutSize& size) { - if (size.IsEmpty()) - return; - if (sizes_.erase(size)) - images_.erase(size); +void GeneratedImageCache::RemoveSize(const FloatSize& size) { + DCHECK(!size.IsEmpty()); + SECURITY_DCHECK(sizes_.find(size) != sizes_.end()); + unsigned& count = sizes_[size]; + count--; + if (count == 0) { + DCHECK(images_.find(size) != images_.end()); + sizes_.erase(sizes_.find(size)); + images_.erase(images_.find(size)); + } } CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType class_type) @@ -66,23 +81,16 @@ CSSImageGeneratorValue::CSSImageGeneratorValue(ClassType class_type) CSSImageGeneratorValue::~CSSImageGeneratorValue() = default; -void CSSImageGeneratorValue::AddClient(const ImageResourceObserver* client, - const LayoutSize& size) { +void CSSImageGeneratorValue::AddClient(const ImageResourceObserver* client) { DCHECK(client); if (clients_.IsEmpty()) { DCHECK(!keep_alive_); keep_alive_ = this; } - cached_images_.AddSize(size); - - ClientSizeCountMap::iterator it = clients_.find(client); - if (it == clients_.end()) { - clients_.insert(client, SizeAndCount(size, 1)); - } else { - SizeAndCount& size_count = it->value; - ++size_count.count; - } + SizeAndCount& size_count = + clients_.insert(client, SizeAndCount()).stored_value->value; + size_count.count++; } CSSImageGeneratorValue* CSSImageGeneratorValue::ValueWithURLsMadeAbsolute() { @@ -97,7 +105,10 @@ void CSSImageGeneratorValue::RemoveClient(const ImageResourceObserver* client) { SECURITY_DCHECK(it != clients_.end()); SizeAndCount& size_count = it->value; - cached_images_.RemoveSize(size_count.size); + if (!size_count.size.IsEmpty()) { + cached_images_.RemoveSize(size_count.size); + size_count.size = FloatSize(); + } if (!--size_count.count) clients_.erase(client); @@ -109,25 +120,28 @@ void CSSImageGeneratorValue::RemoveClient(const ImageResourceObserver* client) { } Image* CSSImageGeneratorValue::GetImage(const ImageResourceObserver* client, - const LayoutSize& size) { + const FloatSize& size) const { ClientSizeCountMap::iterator it = clients_.find(client); if (it != clients_.end()) { DCHECK(keep_alive_); SizeAndCount& size_count = it->value; if (size_count.size != size) { - cached_images_.RemoveSize(size_count.size); - cached_images_.AddSize(size); + if (!size_count.size.IsEmpty()) { + cached_images_.RemoveSize(size_count.size); + size_count.size = FloatSize(); + } - // If there's only one use for this client, then update the size. - if (size_count.count == 1) + if (!size.IsEmpty()) { + cached_images_.AddSize(size); size_count.size = size; + } } } return cached_images_.GetImage(size); } -void CSSImageGeneratorValue::PutImage(const LayoutSize& size, - scoped_refptr image) { +void CSSImageGeneratorValue::PutImage(const FloatSize& size, + scoped_refptr image) const { cached_images_.PutImage(size, std::move(image)); } @@ -135,23 +149,23 @@ scoped_refptr CSSImageGeneratorValue::GetImage( const ImageResourceObserver& client, const Document& document, const ComputedStyle& style, - const LayoutSize& container_size) { + const FloatSize& target_size) { switch (GetClassType()) { case kCrossfadeClass: return ToCSSCrossfadeValue(this)->GetImage(client, document, style, - container_size); + target_size); case kLinearGradientClass: return ToCSSLinearGradientValue(this)->GetImage(client, document, style, - container_size); + target_size); case kPaintClass: return ToCSSPaintValue(this)->GetImage(client, document, style, - container_size); + target_size); case kRadialGradientClass: return ToCSSRadialGradientValue(this)->GetImage(client, document, style, - container_size); + target_size); case kConicGradientClass: return ToCSSConicGradientValue(this)->GetImage(client, document, style, - container_size); + target_size); default: NOTREACHED(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageGeneratorValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageGeneratorValue.h index d82da8441e..ee3fa54203 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageGeneratorValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageGeneratorValue.h @@ -26,43 +26,65 @@ #ifndef CSSImageGeneratorValue_h #define CSSImageGeneratorValue_h +#include #include "base/memory/scoped_refptr.h" #include "core/CoreExport.h" #include "core/css/CSSValue.h" -#include "platform/geometry/LayoutSizeHash.h" +#include "platform/geometry/FloatSize.h" #include "platform/heap/SelfKeepAlive.h" -#include "platform/wtf/HashCountedSet.h" +#include "platform/wtf/HashMap.h" namespace blink { class Document; class Image; -class FloatSize; class ComputedStyle; class ImageResourceObserver; +struct FloatSizeCompare { + bool operator()(const FloatSize& lhs, const FloatSize& rhs) const { + if (lhs.Width() < rhs.Width()) + return true; + if (lhs.Width() > rhs.Width()) + return false; + return lhs.Height() < rhs.Height(); + } +}; + +// Use std::map because the WTF versions require a hashing function, while +// the stl maps require a weak comparison operator that can be defined for +// FloatSize. These maps do not contain many objects because we do not expect +// any particular CSSGeneratedImageValue to have clients at many different +// sizes at any given time. +using ImageSizeCountMap = std::map; +using GeneratedImageMap = + std::map, FloatSizeCompare>; + class GeneratedImageCache { public: - void AddSize(const LayoutSize&); - void RemoveSize(const LayoutSize&); + void AddSize(const FloatSize&); + void RemoveSize(const FloatSize&); - Image* GetImage(const LayoutSize&) const; - void PutImage(const LayoutSize&, scoped_refptr); + Image* GetImage(const FloatSize&) const; + void PutImage(const FloatSize&, scoped_refptr); private: // A count of how many times a given image size is in use. - HashCountedSet sizes_; + ImageSizeCountMap sizes_; // A cache of Image objects by image size. - HashMap> images_; + GeneratedImageMap images_; }; struct SizeAndCount { DISALLOW_NEW(); - SizeAndCount(LayoutSize new_size = LayoutSize(), int new_count = 0) - : size(new_size), count(new_count) {} + SizeAndCount() : size(), count(0) {} + + // The non-zero size associated with this client. A client must only + // ever be present at one non-zero size, with as many zero sizes as it wants. + FloatSize size; - LayoutSize size; + // The net number of times this client has been added. int count; }; @@ -72,13 +94,15 @@ class CORE_EXPORT CSSImageGeneratorValue : public CSSValue { public: ~CSSImageGeneratorValue(); - void AddClient(const ImageResourceObserver*, const LayoutSize&); + void AddClient(const ImageResourceObserver*); + void RemoveClient(const ImageResourceObserver*); - // The |container_size| is the container size with subpixel snapping. + // The |target_size| is the desired image size. Background images should not + // be snapped. In other case the target size must be pixel snapped already. scoped_refptr GetImage(const ImageResourceObserver&, const Document&, const ComputedStyle&, - const LayoutSize& container_size); + const FloatSize& target_size); bool IsFixedSize() const; FloatSize FixedSize(const Document&, const FloatSize& default_object_size); @@ -97,15 +121,15 @@ class CORE_EXPORT CSSImageGeneratorValue : public CSSValue { protected: explicit CSSImageGeneratorValue(ClassType); - Image* GetImage(const ImageResourceObserver*, const LayoutSize&); - void PutImage(const LayoutSize&, scoped_refptr); + Image* GetImage(const ImageResourceObserver*, const FloatSize&) const; + void PutImage(const FloatSize&, scoped_refptr) const; const ClientSizeCountMap& Clients() const { return clients_; } // A map from LayoutObjects (with entry count) to image sizes. - ClientSizeCountMap clients_; + mutable ClientSizeCountMap clients_; // Cached image instances. - GeneratedImageCache cached_images_; + mutable GeneratedImageCache cached_images_; // TODO(Oilpan): when/if we can make the layoutObject point directly to the // CSSImageGenerator value using a member we don't need to have this hack diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageSetValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageSetValue.cpp index 02e7447ab5..dd828823c6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageSetValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageSetValue.cpp @@ -32,7 +32,6 @@ #include "core/frame/LocalFrame.h" #include "core/loader/resource/ImageResourceContent.h" #include "core/style/StyleFetchedImageSet.h" -#include "core/style/StyleInvalidImage.h" #include "platform/loader/fetch/FetchParameters.h" #include "platform/loader/fetch/ResourceFetcher.h" #include "platform/loader/fetch/ResourceLoaderOptions.h" @@ -131,13 +130,9 @@ StyleImage* CSSImageSetValue::CacheImage( placeholder_image_request_type == FetchParameters::kAllowPlaceholder) document.GetFrame()->MaybeAllowImagePlaceholder(params); - if (ImageResourceContent* cached_image = - ImageResourceContent::Fetch(params, document.Fetcher())) { - cached_image_ = StyleFetchedImageSet::Create( - cached_image, image.scale_factor, this, params.Url()); - } else { - cached_image_ = StyleInvalidImage::Create(image.image_url); - } + cached_image_ = StyleFetchedImageSet::Create( + ImageResourceContent::Fetch(params, document.Fetcher()), + image.scale_factor, this, params.Url()); cached_scale_factor_ = device_scale_factor; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageValue.cpp index f28d6d03ef..1826a5454e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImageValue.cpp @@ -25,7 +25,6 @@ #include "core/frame/LocalFrame.h" #include "core/loader/resource/ImageResourceContent.h" #include "core/style/StyleFetchedImage.h" -#include "core/style/StyleInvalidImage.h" #include "platform/CrossOriginAttributeValue.h" #include "platform/loader/fetch/FetchParameters.h" #include "platform/loader/fetch/ResourceFetcher.h" @@ -78,13 +77,7 @@ StyleImage* CSSImageValue::CacheImage( placeholder_image_request_type == FetchParameters::kAllowPlaceholder) document.GetFrame()->MaybeAllowImagePlaceholder(params); - if (ImageResourceContent* cached_image = - ImageResourceContent::Fetch(params, document.Fetcher())) { - cached_image_ = - StyleFetchedImage::Create(cached_image, document, params.Url()); - } else { - cached_image_ = StyleInvalidImage::Create(Url()); - } + cached_image_ = StyleFetchedImage::Create(document, params); } return cached_image_.Get(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImportRule.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImportRule.idl index 5d518220e7..df2783750f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImportRule.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSImportRule.idl @@ -23,8 +23,8 @@ [ Exposed=Window ] interface CSSImportRule : CSSRule { + // TODO(bhagirathi.s@samsung.com): href should be USVString. readonly attribute DOMString href; - // TODO(foolip): media should have [PutForwards=mediaText]. - [SameObject] readonly attribute MediaList media; + [SameObject, PutForwards=mediaText] readonly attribute MediaList media; [SameObject] readonly attribute CSSStyleSheet styleSheet; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSLayoutFunctionValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSLayoutFunctionValue.cpp new file mode 100644 index 0000000000..982b4ba777 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSLayoutFunctionValue.cpp @@ -0,0 +1,43 @@ +// Copyright 2018 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 "core/css/CSSLayoutFunctionValue.h" + +#include "core/css/CSSCustomIdentValue.h" +#include "platform/wtf/text/StringBuilder.h" + +namespace blink { +namespace cssvalue { + +CSSLayoutFunctionValue::CSSLayoutFunctionValue(CSSCustomIdentValue* name, + bool is_inline) + : CSSValue(kLayoutFunctionClass), name_(name), is_inline_(is_inline) {} + +CSSLayoutFunctionValue::~CSSLayoutFunctionValue() = default; + +String CSSLayoutFunctionValue::CustomCSSText() const { + StringBuilder result; + if (is_inline_) + result.Append("inline-"); + result.Append("layout("); + result.Append(name_->CustomCSSText()); + result.Append(')'); + return result.ToString(); +} + +AtomicString CSSLayoutFunctionValue::GetName() const { + return name_->Value(); +} + +bool CSSLayoutFunctionValue::Equals(const CSSLayoutFunctionValue& other) const { + return GetName() == other.GetName() && IsInline() == other.IsInline(); +} + +void CSSLayoutFunctionValue::TraceAfterDispatch(blink::Visitor* visitor) { + visitor->Trace(name_); + CSSValue::TraceAfterDispatch(visitor); +} + +} // namespace cssvalue +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSLayoutFunctionValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSLayoutFunctionValue.h new file mode 100644 index 0000000000..7bd0897358 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSLayoutFunctionValue.h @@ -0,0 +1,45 @@ +// Copyright 2018 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 CSSLayoutFunctionValue_h +#define CSSLayoutFunctionValue_h + +#include "base/macros.h" +#include "core/css/CSSValue.h" +#include "platform/heap/Handle.h" + +namespace blink { + +class CSSCustomIdentValue; + +namespace cssvalue { + +class CSSLayoutFunctionValue : public CSSValue { + public: + static CSSLayoutFunctionValue* Create(CSSCustomIdentValue* name, + bool is_inline) { + return new CSSLayoutFunctionValue(name, is_inline); + } + ~CSSLayoutFunctionValue(); + + String CustomCSSText() const; + AtomicString GetName() const; + bool IsInline() const { return is_inline_; } + + bool Equals(const CSSLayoutFunctionValue&) const; + void TraceAfterDispatch(blink::Visitor*); + + private: + CSSLayoutFunctionValue(CSSCustomIdentValue* name, bool is_inline); + + Member name_; + bool is_inline_; +}; + +DEFINE_CSS_VALUE_TYPE_CASTS(CSSLayoutFunctionValue, IsLayoutFunctionValue()); + +} // namespace cssvalue +} // namespace blink + +#endif // CSSLayoutFunctionValue_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSMediaRule.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSMediaRule.idl index b287b6d43c..d4e4809558 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSMediaRule.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSMediaRule.idl @@ -20,7 +20,8 @@ // https://drafts.csswg.org/cssom/#the-cssmediarule-interface -interface CSSMediaRule : CSSConditionRule { - // TODO(foolip): media should have [PutForwards=mediaText]. - [SameObject] readonly attribute MediaList media; +[ + Exposed=Window +] interface CSSMediaRule : CSSConditionRule { + [SameObject, PutForwards=mediaText] readonly attribute MediaList media; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPageRule.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPageRule.idl index 01ce1c73b0..ae8187394b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPageRule.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPageRule.idl @@ -29,6 +29,5 @@ Exposed=Window ] interface CSSPageRule : CSSRule { [SetterCallWith=ExecutionContext] attribute DOMString selectorText; - // TODO(foolip): style should have [PutForwards=cssText]. - [SameObject] readonly attribute CSSStyleDeclaration style; + [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPaintValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPaintValue.cpp index 85933ca567..8c3ea7c281 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPaintValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPaintValue.cpp @@ -47,7 +47,7 @@ scoped_refptr CSSPaintValue::GetImage( const ImageResourceObserver& client, const Document& document, const ComputedStyle&, - const LayoutSize& container_size) { + const FloatSize& target_size) { if (!generator_) { generator_ = CSSPaintImageGenerator::Create( GetName(), document, paint_image_generator_observer_); @@ -56,7 +56,7 @@ scoped_refptr CSSPaintValue::GetImage( if (!ParseInputArguments(document)) return nullptr; - return generator_->Paint(client, RoundedIntSize(container_size), + return generator_->Paint(client, RoundedIntSize(target_size), parsed_input_arguments_); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPaintValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPaintValue.h index f3b2820b74..9e8bff29a8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPaintValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPaintValue.h @@ -33,11 +33,12 @@ class CSSPaintValue : public CSSImageGeneratorValue { String GetName() const; - // The |container_size| is container size with subpixel snapping. + // The |target_size| is container size with subpixel snapping when used + // in the context of paint images. scoped_refptr GetImage(const ImageResourceObserver&, const Document&, const ComputedStyle&, - const LayoutSize& container_size); + const FloatSize& target_size); bool IsFixedSize() const { return false; } FloatSize FixedSize(const Document&) { return FloatSize(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPrimitiveValueMappings.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPrimitiveValueMappings.h index 0afcd5e6c2..325cb3a05d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPrimitiveValueMappings.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPrimitiveValueMappings.h @@ -47,6 +47,7 @@ #include "platform/fonts/TextRenderingMode.h" #include "platform/graphics/GraphicsTypes.h" #include "platform/graphics/TouchAction.h" +#include "platform/scroll/ScrollCustomization.h" #include "platform/scroll/ScrollableArea.h" #include "platform/text/TextRun.h" #include "platform/text/WritingMode.h" @@ -1510,6 +1511,34 @@ inline TouchAction CSSIdentifierValue::ConvertTo() const { return TouchAction::kTouchActionNone; } +template <> +inline ScrollCustomization::ScrollDirection CSSIdentifierValue::ConvertTo() + const { + switch (value_id_) { + case CSSValueNone: + return ScrollCustomization::kScrollDirectionNone; + case CSSValueAuto: + return ScrollCustomization::kScrollDirectionAuto; + case CSSValuePanLeft: + return ScrollCustomization::kScrollDirectionPanLeft; + case CSSValuePanRight: + return ScrollCustomization::kScrollDirectionPanRight; + case CSSValuePanX: + return ScrollCustomization::kScrollDirectionPanX; + case CSSValuePanUp: + return ScrollCustomization::kScrollDirectionPanUp; + case CSSValuePanDown: + return ScrollCustomization::kScrollDirectionPanDown; + case CSSValuePanY: + return ScrollCustomization::kScrollDirectionPanY; + default: + break; + } + + NOTREACHED(); + return ScrollCustomization::kScrollDirectionNone; +} + template <> inline CSSIdentifierValue::CSSIdentifierValue(CSSBoxType css_box) : CSSValue(kIdentifierClass) { @@ -1554,6 +1583,9 @@ template <> inline CSSIdentifierValue::CSSIdentifierValue(ItemPosition item_position) : CSSValue(kIdentifierClass) { switch (item_position) { + case ItemPosition::kLegacy: + value_id_ = CSSValueLegacy; + break; case ItemPosition::kAuto: value_id_ = CSSValueAuto; break; @@ -1602,6 +1634,8 @@ inline CSSIdentifierValue::CSSIdentifierValue(ItemPosition item_position) template <> inline ItemPosition CSSIdentifierValue::ConvertTo() const { switch (value_id_) { + case CSSValueLegacy: + return ItemPosition::kLegacy; case CSSValueAuto: return ItemPosition::kAuto; case CSSValueNormal: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSProperties.json5 b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSProperties.json5 index e1277c9d4e..8ff0e61048 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSProperties.json5 +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSProperties.json5 @@ -230,7 +230,7 @@ "Frequency", "Length", "Number", - "Percent", + "Percentage", "Position", "Resolution", "Time", @@ -438,6 +438,7 @@ computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, priority: "High", + keywords: ["currentcolor"] }, { name: "direction", @@ -513,6 +514,7 @@ name_for_methods: "Style", converter: "ConvertFontStyle", priority: "High", + keywords: ["normal", "italic", "oblique"] }, { name: "font-variant-ligatures", @@ -561,6 +563,8 @@ name_for_methods: "Weight", converter: "ConvertFontWeight", priority: "High", + keywords: ["normal", "bold", "bolder", "lighter"], + typedom_types: ["Number"] }, { name: "font-feature-settings", @@ -577,7 +581,6 @@ property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], interpolable: true, inherited: true, - runtime_flag: "CSSVariableFonts", font: true, name_for_methods: "VariationSettings", converter: "ConvertFontVariationSettings", @@ -743,6 +746,7 @@ type_name: "StyleColor", computed_style_custom_functions: ["getter"], custom_apply_functions_all: true, + keywords: ["currentcolor"] }, { name: "background-image", @@ -750,6 +754,7 @@ interpolable: true, keywords: ["auto", "none"], typedom_types: ["Image"], + separator: " ", custom_apply_functions_all: true, }, { @@ -802,6 +807,7 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, + keywords: ["currentcolor"] }, { name: "border-bottom-left-radius", @@ -835,7 +841,6 @@ "dashed", "solid", "double" ], default_value: "none", - typedom_types: ["Image"], type_name: "EBorderStyle", }, { @@ -903,6 +908,7 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, + keywords: ["currentcolor"] }, { name: "border-left-style", @@ -914,7 +920,6 @@ "dashed", "solid", "double" ], default_value: "none", - typedom_types: ["Image"], type_name: "EBorderStyle", }, { @@ -942,6 +947,7 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, + keywords: ["currentcolor"] }, { name: "border-right-style", @@ -953,7 +959,6 @@ "dashed", "solid", "double" ], default_value: "none", - typedom_types: ["Image"], type_name: "EBorderStyle", }, { @@ -981,6 +986,7 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, + keywords: ["currentcolor"] }, { name: "border-top-left-radius", @@ -1014,7 +1020,6 @@ "dashed", "solid", "double" ], default_value: "none", - typedom_types: ["Image"], type_name: "EBorderStyle", }, { @@ -1039,7 +1044,7 @@ field_template: "", keywords: ["auto"], default_value: "Length()", - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], converter: "ConvertLengthOrAuto", }, { @@ -1123,6 +1128,7 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, + keywords: ["auto", "currentcolor"] }, { name: "clear", @@ -1266,8 +1272,7 @@ }, { name: "display", - property_methods: ["CSSValueFromComputedStyleInternal"], - field_template: 'keyword', + property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], keywords: [ "inline", "block", "list-item", "inline-block", "table", "inline-table", "table-row-group", "table-header-group", "table-footer-group", @@ -1275,7 +1280,7 @@ "table-caption", "-webkit-box", "-webkit-inline-box", "flex", "inline-flex", "grid", "inline-grid", "contents", "flow-root", "none" ], - default_value: "inline", + custom_apply_functions_all: true, }, { name: "dominant-baseline", @@ -1437,14 +1442,6 @@ type_name: "GridPosition", converter: "ConvertGridPosition", }, - { - name: "grid-column-gap", - property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], - field_group: "*", - field_template: "", - default_value: "Length(kFixed)", - converter: "ConvertLength", - }, { name: "grid-column-start", property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], @@ -1465,14 +1462,6 @@ type_name: "GridPosition", converter: "ConvertGridPosition", }, - { - name: "grid-row-gap", - property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], - field_group: "*", - field_template: "", - default_value: "Length(kFixed)", - converter: "ConvertLength", - }, { name: "grid-row-start", property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], @@ -1517,7 +1506,7 @@ field_template: "", keywords: ["auto", "fit-content", "min-content", "max-content"], default_value: "Length()", - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], converter: "ConvertLengthSizing", }, { @@ -1578,7 +1567,7 @@ field_group: "*", field_template: "external", include_paths: ["core/style/StyleSelfAlignmentData.h"], - default_value: "StyleSelfAlignmentData(ItemPosition::kAuto, OverflowAlignment::kDefault)", + default_value: "StyleSelfAlignmentData(ItemPosition::kLegacy, OverflowAlignment::kDefault)", type_name: "StyleSelfAlignmentData", converter: "ConvertSelfOrDefaultAlignmentData", }, @@ -1600,7 +1589,7 @@ field_template: "", keywords: ["auto"], default_value: "Length()", - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], converter: "ConvertLengthOrAuto", }, { @@ -1628,6 +1617,8 @@ getter: "SpecifiedLineHeight", computed_style_custom_functions: ["getter"], converter: "ConvertLineHeight", + keywords: ["normal"], + typedom_types: ["Length", "Number", "Percentage"] }, { name: "line-height-step", @@ -1654,6 +1645,7 @@ type_name: "StyleImage", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_value: true, + keywords: ["none"] }, { name: "list-style-position", @@ -1694,6 +1686,8 @@ field_template: "", default_value: "Length(kFixed)", converter: "ConvertQuirkyLength", + keywords: ["auto"], + typedom_types: ["Length", "Percentage"] }, { name: "margin-left", @@ -1703,6 +1697,8 @@ field_template: "", default_value: "Length(kFixed)", converter: "ConvertQuirkyLength", + keywords: ["auto"], + typedom_types: ["Length", "Percentage"] }, { name: "margin-right", @@ -1712,6 +1708,8 @@ field_template: "", default_value: "Length(kFixed)", converter: "ConvertQuirkyLength", + keywords: ["auto"], + typedom_types: ["Length", "Percentage"] }, { name: "margin-top", @@ -1721,6 +1719,8 @@ field_template: "", default_value: "Length(kFixed)", converter: "ConvertQuirkyLength", + keywords: ["auto"], + typedom_types: ["Length", "Percentage"] }, { name: "marker-end", @@ -1838,6 +1838,7 @@ default_value: "LengthPoint(Length(50.0, kPercent), Length(50.0, kPercent))", type_name: "LengthPoint", converter: "ConvertPosition", + typedom_types: ["Position"], }, { name: "offset-anchor", @@ -1905,6 +1906,7 @@ default_value: "1.0", type_name: "float", computed_style_custom_functions: ["setter"], + typedom_types: ["Number"] }, { name: "order", @@ -1937,6 +1939,7 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, + keywords: ["currentcolor"] }, { name: "outline-offset", @@ -2042,6 +2045,7 @@ field_template: "", default_value: "Length(kFixed)", converter: "ConvertLength", + typedom_types: ["Length", "Percentage"] }, { name: "padding-left", @@ -2051,6 +2055,7 @@ field_template: "", default_value: "Length(kFixed)", converter: "ConvertLength", + typedom_types: ["Length", "Percentage"] }, { name: "padding-right", @@ -2060,6 +2065,7 @@ field_template: "", default_value: "Length(kFixed)", converter: "ConvertLength", + typedom_types: ["Length", "Percentage"] }, { name: "padding-top", @@ -2069,6 +2075,7 @@ field_template: "", default_value: "Length(kFixed)", converter: "ConvertLength", + typedom_types: ["Length", "Percentage"] }, { name: "paint-order", @@ -2150,7 +2157,7 @@ field_template: "", keywords: ["auto"], default_value: "Length()", - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], converter: "ConvertLengthOrAuto", }, { @@ -2193,6 +2200,18 @@ shorthand_for_physical_side: "scrollMarginShorthand", }, }, + { + name: "scroll-customization", + property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], + converter: "ConvertFlags", + type_name: "ScrollCustomization::ScrollDirection", + field_group: "*", + field_size: 4, + field_template: "primitive", + default_value: "ScrollCustomization::kScrollDirectionNone", + include_paths: ["platform/scroll/ScrollCustomization.h"], + runtime_flag: "ScrollCustomization", + }, { name: "scroll-margin-block-start", property_methods: ["ParseSingleValue"], @@ -2265,7 +2284,7 @@ property_methods: ["ParseSingleValue"], runtime_flag: "CSSScrollSnapPoints", include_paths: ["platform/Length.h"], - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], type_name: "Length", converter: "ConvertLength", direction_aware_options: { @@ -2278,7 +2297,7 @@ property_methods: ["ParseSingleValue"], runtime_flag: "CSSScrollSnapPoints", include_paths: ["platform/Length.h"], - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], type_name: "Length", converter: "ConvertLength", direction_aware_options: { @@ -2293,7 +2312,7 @@ field_group: "*", field_template: "", default_value: "Length()", - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], converter: "ConvertLength", }, { @@ -2301,7 +2320,7 @@ property_methods: ["ParseSingleValue"], runtime_flag: "CSSScrollSnapPoints", include_paths: ["platform/Length.h"], - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], type_name: "Length", converter: "ConvertLength", direction_aware_options: { @@ -2314,7 +2333,7 @@ property_methods: ["ParseSingleValue"], runtime_flag: "CSSScrollSnapPoints", include_paths: ["platform/Length.h"], - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], type_name: "Length", converter: "ConvertLength", direction_aware_options: { @@ -2329,7 +2348,7 @@ field_group: "*", field_template: "", default_value: "Length()", - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], converter: "ConvertLength", }, { @@ -2339,7 +2358,7 @@ field_group: "*", field_template: "", default_value: "Length()", - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], converter: "ConvertLength", }, { @@ -2349,7 +2368,7 @@ field_group: "*", field_template: "", default_value: "Length()", - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], converter: "ConvertLength", }, { @@ -2416,6 +2435,7 @@ type_name: "ShapeValue", computed_style_custom_functions: ["getter"], converter: "ConvertShapeValue", + keywords: ["none"] }, { name: "shape-rendering", @@ -2592,6 +2612,7 @@ default_value: "StyleColor::CurrentColor()", type_name: "StyleColor", custom_apply_functions_all: true, + keywords: ["currentcolor"] }, { name: "text-decoration-line", @@ -2705,7 +2726,7 @@ field_template: "", keywords: ["auto"], default_value: "Length()", - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], converter: "ConvertLengthOrAuto", }, { @@ -2828,6 +2849,8 @@ interpolable: true, custom_apply_functions_inherit: true, custom_apply_functions_value: true, + typedom_types: ["Length", "Percentage"], + keywords: ["baseline", "sub", "super", "text-top", "text-bottom", "middle"], }, { name: "visibility", @@ -3005,12 +3028,22 @@ property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], interpolable: true, field_group: "*", - field_template: "primitive", - default_value: "0.0f", - type_name: "float", - computed_style_custom_functions: ["setter"], - converter: "ConvertComputedLength", - custom_apply_functions_all: true, + field_template: "external", + include_paths: ["core/style/GapLength.h"], + default_value: "GapLength()", + type_name: "GapLength", + converter: "ConvertGapLength", + }, + { + name: "row-gap", + property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], + interpolable: true, + field_group: "*", + field_template: "external", + include_paths: ["core/style/GapLength.h"], + default_value: "GapLength()", + type_name: "GapLength", + converter: "ConvertGapLength", }, { name: "column-rule-color", @@ -3023,6 +3056,7 @@ type_name: "Color", computed_style_custom_functions: ["getter","setter"], custom_apply_functions_all: true, + keywords: ["currentcolor"] }, { name: "column-rule-style", @@ -3429,7 +3463,7 @@ field_template: "", keywords: ["auto", "fit-content", "min-content", "max-content"], default_value: "Length()", - typedom_types: ["Length", "Percent"], + typedom_types: ["Length", "Percentage"], converter: "ConvertLengthSizing", }, { @@ -3472,6 +3506,7 @@ type_name: "int", computed_style_custom_functions: ["setter"], custom_apply_functions_all: true, + keywords: ["auto"], }, // CSS logical props @@ -3895,7 +3930,6 @@ ], property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"], keywords: ["none"], - typedom_types: ["Image"], }, { name: "border-top", @@ -3974,9 +4008,24 @@ longhands: ["grid-column-start", "grid-column-end"], property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"], }, + { + name: "grid-column-gap", + longhands: ["column-gap"], + property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"], + }, + { + name: "grid-row-gap", + longhands: ["row-gap"], + property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"], + }, + { + name: "gap", + longhands: ["row-gap", "column-gap"], + property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"], + }, { name: "grid-gap", - longhands: ["grid-row-gap", "grid-column-gap"], + longhands: ["row-gap", "column-gap"], property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"], }, { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertiesRanking.json5 b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertiesRanking.json5 index f25406de6a..9388eb09a2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertiesRanking.json5 +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertiesRanking.json5 @@ -402,6 +402,7 @@ "grid-column-gap", "buffered-rendering", "webkit-text-emphasis-position", + "gap", "grid-gap", "grid-column-start", "grid-auto-columns", @@ -420,6 +421,7 @@ "webkit-border-start", "grid-row", "grid-row-gap", + "row-gap", "webkit-mask-origin", "grid-row-start", "grid-row-end", diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertyEquality.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertyEquality.cpp index 7ed30206ad..032ea313e7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertyEquality.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertyEquality.cpp @@ -295,6 +295,8 @@ bool CSSPropertyEquality::PropertiesEqual(const PropertyHandle& property, return a.ColumnCount() == b.ColumnCount(); case CSSPropertyColumnGap: return a.ColumnGap() == b.ColumnGap(); + case CSSPropertyRowGap: + return a.RowGap() == b.RowGap(); case CSSPropertyColumnRuleColor: return a.ColumnRuleColor() == b.ColumnRuleColor() && a.VisitedLinkColumnRuleColor() == b.VisitedLinkColumnRuleColor(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertyValueSet.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertyValueSet.cpp index b6657fafbb..3bc31fc5cd 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertyValueSet.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSPropertyValueSet.cpp @@ -577,7 +577,7 @@ void MutableCSSPropertyValueSet::RemoveEquivalentProperties( unsigned size = property_vector_.size(); for (unsigned i = 0; i < size; ++i) { PropertyReference property = PropertyAt(i); - if (style->CssPropertyMatches(property.Id(), &property.Value())) + if (style->CssPropertyMatches(property.Id(), property.Value())) properties_to_remove.push_back(property.Id()); } // FIXME: This should use mass removal. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRayValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRayValue.cpp index bc63551d7d..62fbbcbe39 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRayValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRayValue.cpp @@ -9,6 +9,7 @@ #include "platform/wtf/text/StringBuilder.h" namespace blink { +namespace cssvalue { CSSRayValue* CSSRayValue::Create(const CSSPrimitiveValue& angle, const CSSIdentifierValue& size, @@ -48,4 +49,5 @@ void CSSRayValue::TraceAfterDispatch(blink::Visitor* visitor) { CSSValue::TraceAfterDispatch(visitor); } +} // namespace cssvalue } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRayValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRayValue.h index 8771cceee2..d9ec06c8ba 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRayValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRayValue.h @@ -12,6 +12,8 @@ namespace blink { class CSSIdentifierValue; class CSSPrimitiveValue; +namespace cssvalue { + class CSSRayValue : public CSSValue { public: static CSSRayValue* Create(const CSSPrimitiveValue& angle, @@ -40,6 +42,7 @@ class CSSRayValue : public CSSValue { DEFINE_CSS_VALUE_TYPE_CASTS(CSSRayValue, IsRayValue()); +} // namespace cssvalue } // namespace blink #endif // CSSRayValue_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSReflectValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSReflectValue.cpp index b848e44be4..cac8b34999 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSReflectValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSReflectValue.cpp @@ -29,6 +29,7 @@ #include "core/css/CSSPrimitiveValue.h" namespace blink { +namespace cssvalue { String CSSReflectValue::CustomCSSText() const { if (mask_) @@ -50,4 +51,5 @@ void CSSReflectValue::TraceAfterDispatch(blink::Visitor* visitor) { CSSValue::TraceAfterDispatch(visitor); } +} // namespace cssvalue } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSReflectValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSReflectValue.h index 5fb2b0aea7..4214ee2178 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSReflectValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSReflectValue.h @@ -34,6 +34,8 @@ namespace blink { class CSSIdentifierValue; class CSSPrimitiveValue; +namespace cssvalue { + class CSSReflectValue : public CSSValue { public: static CSSReflectValue* Create(CSSIdentifierValue* direction, @@ -68,6 +70,7 @@ class CSSReflectValue : public CSSValue { DEFINE_CSS_VALUE_TYPE_CASTS(CSSReflectValue, IsReflectValue()); +} // namespace cssvalue } // namespace blink #endif // CSSReflectValue_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRule.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRule.cpp index fa928b5d90..2d75fe426b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRule.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSRule.cpp @@ -48,13 +48,13 @@ const CSSParserContext* CSSRule::ParserContext( void CSSRule::SetParentStyleSheet(CSSStyleSheet* style_sheet) { parent_is_rule_ = false; parent_style_sheet_ = style_sheet; - ScriptWrappableVisitor::WriteBarrier(parent_style_sheet_); + ScriptWrappableMarkingVisitor::WriteBarrier(parent_style_sheet_); } void CSSRule::SetParentRule(CSSRule* rule) { parent_is_rule_ = true; parent_rule_ = rule; - ScriptWrappableVisitor::WriteBarrier(parent_rule_); + ScriptWrappableMarkingVisitor::WriteBarrier(parent_rule_); } void CSSRule::Trace(blink::Visitor* visitor) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelector.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelector.cpp index 048a26c3fa..6aaaf83287 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelector.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelector.cpp @@ -527,7 +527,7 @@ void CSSSelector::UpdatePseudoType(const AtomicString& value, // but should be PseudoElement like double colon. if (match_ == kPseudoClass) match_ = kPseudoElement; - // fallthrough + FALLTHROUGH; case kPseudoBackdrop: case kPseudoCue: case kPseudoPlaceholder: @@ -562,7 +562,7 @@ void CSSSelector::UpdatePseudoType(const AtomicString& value, pseudo_type_ = kPseudoUnknown; break; } - // fallthrough + FALLTHROUGH; case kPseudoActive: case kPseudoAny: case kPseudoAnyLink: @@ -788,7 +788,7 @@ const CSSSelector* CSSSelector::SerializeCompound( if (simple_selector->SelectorList()) { builder.Append('('); const CSSSelector* first_sub_selector = - simple_selector->SelectorList()->First(); + simple_selector->SelectorList()->FirstForCSSOM(); for (const CSSSelector* sub_selector = first_sub_selector; sub_selector; sub_selector = CSSSelectorList::Next(*sub_selector)) { if (sub_selector != first_sub_selector) @@ -836,6 +836,7 @@ String CSSSelector::SelectorText() const { break; case kSubSelector: NOTREACHED(); + break; case kShadowPseudo: case kShadowSlot: result = builder.ToString() + result; @@ -935,9 +936,7 @@ bool CSSSelector::IsCompound() const { return true; } -unsigned CSSSelector::ComputeLinkMatchType() const { - unsigned link_match_type = kMatchAll; - +unsigned CSSSelector::ComputeLinkMatchType(unsigned link_match_type) const { // Determine if this selector will match a link in visited, unvisited or any // state, or never. // :visited never matches other elements than the innermost link element. @@ -963,6 +962,14 @@ unsigned CSSSelector::ComputeLinkMatchType() const { case kPseudoVisited: link_match_type &= ~kMatchLink; break; + case kPseudoSlotted: + DCHECK(current->SelectorList()); + DCHECK(current->SelectorList()->First()); + DCHECK(!CSSSelectorList::Next(*current->SelectorList()->First())); + link_match_type = + current->SelectorList()->First()->ComputeLinkMatchType( + link_match_type); + break; default: // We don't support :link and :visited inside :-webkit-any. break; @@ -1055,6 +1062,14 @@ bool CSSSelector::NeedsUpdatedDistribution() const { *this); } +bool CSSSelector::HasPseudoMatches() const { + for (const CSSSelector* s = this; s; s = s->TagHistory()) { + if (s->GetPseudoType() == CSSSelector::kPseudoMatches) + return true; + } + return false; +} + CSSSelector::RareData::RareData(const AtomicString& value) : matching_value_(value), serializing_value_(value), diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelector.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelector.h index 6ce3d75ee8..d97a7a6f70 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelector.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelector.h @@ -333,9 +333,17 @@ class CORE_EXPORT CSSSelector { } bool IsLastInSelectorList() const { return is_last_in_selector_list_; } - void SetLastInSelectorList() { is_last_in_selector_list_ = true; } + void SetLastInSelectorList(bool is_last) { + is_last_in_selector_list_ = is_last; + } + + bool IsLastInOriginalList() const { return is_last_in_original_list_; } + void SetLastInOriginalList(bool is_last) { + is_last_in_original_list_ = is_last; + } + bool IsLastInTagHistory() const { return is_last_in_tag_history_; } - void SetNotLastInTagHistory() { is_last_in_tag_history_ = false; } + void SetLastInTagHistory(bool is_last) { is_last_in_tag_history_ = is_last; } // http://dev.w3.org/csswg/selectors4/#compound bool IsCompound() const; @@ -345,7 +353,7 @@ class CORE_EXPORT CSSSelector { kMatchVisited = 2, kMatchAll = kMatchLink | kMatchVisited }; - unsigned ComputeLinkMatchType() const; + unsigned ComputeLinkMatchType(unsigned link_match_type) const; bool IsForPage() const { return is_for_page_; } void SetForPage() { is_for_page_ = true; } @@ -363,6 +371,7 @@ class CORE_EXPORT CSSSelector { bool HasSlottedPseudo() const; bool HasDeepCombinatorOrShadowPseudo() const; bool NeedsUpdatedDistribution() const; + bool HasPseudoMatches() const; private: unsigned relation_ : 4; // enum RelationType @@ -374,6 +383,7 @@ class CORE_EXPORT CSSSelector { unsigned is_for_page_ : 1; unsigned tag_is_implicit_ : 1; unsigned relation_is_affected_by_pseudo_content_ : 1; + unsigned is_last_in_original_list_ : 1; void SetPseudoType(PseudoType pseudo_type) { pseudo_type_ = pseudo_type; @@ -474,7 +484,8 @@ inline CSSSelector::CSSSelector() has_rare_data_(false), is_for_page_(false), tag_is_implicit_(false), - relation_is_affected_by_pseudo_content_(false) {} + relation_is_affected_by_pseudo_content_(false), + is_last_in_original_list_(false) {} inline CSSSelector::CSSSelector(const QualifiedName& tag_q_name, bool tag_is_implicit) @@ -486,7 +497,8 @@ inline CSSSelector::CSSSelector(const QualifiedName& tag_q_name, has_rare_data_(false), is_for_page_(false), tag_is_implicit_(tag_is_implicit), - relation_is_affected_by_pseudo_content_(false) { + relation_is_affected_by_pseudo_content_(false), + is_last_in_original_list_(false) { data_.tag_q_name_ = tag_q_name.Impl(); data_.tag_q_name_->AddRef(); } @@ -501,7 +513,8 @@ inline CSSSelector::CSSSelector(const CSSSelector& o) is_for_page_(o.is_for_page_), tag_is_implicit_(o.tag_is_implicit_), relation_is_affected_by_pseudo_content_( - o.relation_is_affected_by_pseudo_content_) { + o.relation_is_affected_by_pseudo_content_), + is_last_in_original_list_(o.is_last_in_original_list_) { if (o.match_ == kTag) { data_.tag_q_name_ = o.data_.tag_q_name_; data_.tag_q_name_->AddRef(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorList.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorList.cpp index 6be106a6dd..9573a28923 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorList.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorList.cpp @@ -27,6 +27,7 @@ #include "core/css/CSSSelectorList.h" #include +#include #include "core/css/parser/CSSParserSelector.h" #include "platform/wtf/allocator/Partitions.h" #include "platform/wtf/text/StringBuilder.h" @@ -55,6 +56,167 @@ CSSSelectorList CSSSelectorList::Copy() const { return list; } +CSSSelectorList CSSSelectorList::ConcatenatePseudoMatchesExpansion( + const CSSSelectorList& expanded, + const CSSSelectorList& original) { + unsigned expanded_length = expanded.ComputeLength(); + unsigned original_length = original.ComputeLength(); + unsigned total_length = expanded_length + original_length; + + CSSSelectorList list; + list.selector_array_ = reinterpret_cast( + WTF::Partitions::FastMalloc(WTF::Partitions::ComputeAllocationSize( + total_length, sizeof(CSSSelector)), + kCSSSelectorTypeName)); + + unsigned list_index = 0; + for (unsigned i = 0; i < expanded_length; ++i) { + new (&list.selector_array_[list_index]) + CSSSelector(expanded.selector_array_[i]); + ++list_index; + } + DCHECK(list.selector_array_[list_index - 1].IsLastInOriginalList()); + DCHECK(list.selector_array_[list_index - 1].IsLastInSelectorList()); + list.selector_array_[list_index - 1].SetLastInSelectorList(false); + for (unsigned i = 0; i < original_length; ++i) { + new (&list.selector_array_[list_index]) + CSSSelector(original.selector_array_[i]); + ++list_index; + } + DCHECK(list.selector_array_[list_index - 1].IsLastInOriginalList()); + DCHECK(list.selector_array_[list_index - 1].IsLastInSelectorList()); + return list; +} + +std::vector SelectorBoundaries( + const CSSSelectorList& list) { + std::vector result; + for (const CSSSelector* s = list.First(); s; s = list.Next(*s)) { + result.push_back(s); + } + result.push_back(list.First() + list.ComputeLength()); + return result; +} + +void AddToList(CSSSelector*& destination, + const CSSSelector* begin, + const CSSSelector* end) { + for (const CSSSelector* current = begin; current != end; ++current) { + new (destination) CSSSelector(*current); + destination->SetLastInSelectorList(false); + destination->SetLastInOriginalList(false); + destination++; + } +} + +void AddToList(CSSSelector*& destination, + const CSSSelector* begin, + const CSSSelector* end, + CSSSelector::RelationType relation, + bool IsLastInTagHistory) { + for (const CSSSelector* current = begin; current != end; ++current) { + new (destination) CSSSelector(*current); + DCHECK_EQ(current + 1 == end, current->IsLastInTagHistory()); + if (current->IsLastInTagHistory()) { + destination->SetRelation(relation); + if (!IsLastInTagHistory) + destination->SetLastInTagHistory(false); + } + destination->SetLastInSelectorList(false); + destination->SetLastInOriginalList(false); + destination++; + } +} + +CSSSelectorList CSSSelectorList::ExpandedFirstMatchesPseudo() const { + unsigned original_length = this->ComputeLength(); + std::vector matches_boundaries = + SelectorBoundaries(*this); + + size_t i = 0; + while (!matches_boundaries[i]->HasPseudoMatches()) { + ++i; + } + const CSSSelector* selector_with_matches_begin = matches_boundaries[i]; + const CSSSelector* selector_with_matches_end = matches_boundaries[i + 1]; + size_t selector_with_matches_length = + selector_with_matches_end - selector_with_matches_begin; + + const CSSSelector* simple_matches = selector_with_matches_begin; + while (simple_matches->GetPseudoType() != CSSSelector::kPseudoMatches) { + simple_matches = simple_matches->TagHistory(); + } + + unsigned inner_matches_length = + simple_matches->SelectorList()->ComputeLength(); + std::vector matches_arg_boundaries = + SelectorBoundaries(*simple_matches->SelectorList()); + + size_t num_matches_args = matches_arg_boundaries.size() - 1; + unsigned other_selectors_length = + original_length - selector_with_matches_length; + + unsigned expanded_matches_length = + (selector_with_matches_length - 1) * num_matches_args + + inner_matches_length + other_selectors_length; + + // Do not perform expansion if the selector list size is too large to create + // RuleData + if (expanded_matches_length > 8192) + return CSSSelectorList(); + + CSSSelectorList list; + list.selector_array_ = + reinterpret_cast(WTF::Partitions::FastMalloc( + WTF::Partitions::ComputeAllocationSize(expanded_matches_length, + sizeof(CSSSelector)), + kCSSSelectorTypeName)); + + CSSSelector* destination = list.selector_array_; + + AddToList(destination, matches_boundaries[0], selector_with_matches_begin); + for (size_t i = 0; i < num_matches_args; ++i) { + AddToList(destination, selector_with_matches_begin, simple_matches); + AddToList(destination, matches_arg_boundaries[i], + matches_arg_boundaries[i + 1], simple_matches->Relation(), + simple_matches->IsLastInTagHistory()); + AddToList(destination, simple_matches + 1, selector_with_matches_end); + } + AddToList(destination, selector_with_matches_end, matches_boundaries.back()); + + DCHECK(destination == list.selector_array_ + expanded_matches_length); + + list.selector_array_[expanded_matches_length - 1].SetLastInOriginalList(true); + list.selector_array_[expanded_matches_length - 1].SetLastInSelectorList(true); + + return list; +} + +CSSSelectorList CSSSelectorList::TransformForPseudoMatches() { + DCHECK_GT(this->ComputeLength(), 0u); + DCHECK( + this->selector_array_[this->ComputeLength() - 1].IsLastInOriginalList()); + DCHECK(this->HasPseudoMatches()); + + // Append the expanded form of matches to the original selector list + CSSSelectorList transformed = this->Copy(); + do { + transformed = transformed.ExpandedFirstMatchesPseudo(); + } while (transformed.HasPseudoMatches()); + + if (transformed.ComputeLength() == 0) + return CSSSelectorList(); + return CSSSelectorList::ConcatenatePseudoMatchesExpansion(transformed, *this); +} + +bool CSSSelectorList::HasPseudoMatches() const { + for (const CSSSelector* s = FirstForCSSOM(); s; s = Next(*s)) { + if (s->HasPseudoMatches()) + return true; + } + return false; +} + CSSSelectorList CSSSelectorList::AdoptSelectorVector( Vector>& selector_vector) { size_t flattened_size = 0; @@ -84,18 +246,30 @@ CSSSelectorList CSSSelectorList::AdoptSelectorVector( current = current->TagHistory(); DCHECK(!list.selector_array_[array_index].IsLastInSelectorList()); if (current) - list.selector_array_[array_index].SetNotLastInTagHistory(); + list.selector_array_[array_index].SetLastInTagHistory(false); ++array_index; } DCHECK(list.selector_array_[array_index - 1].IsLastInTagHistory()); } DCHECK_EQ(flattened_size, array_index); - list.selector_array_[array_index - 1].SetLastInSelectorList(); + list.selector_array_[array_index - 1].SetLastInSelectorList(true); + list.selector_array_[array_index - 1].SetLastInOriginalList(true); selector_vector.clear(); return list; } +const CSSSelector* CSSSelectorList::FirstForCSSOM() const { + const CSSSelector* s = this->First(); + if (!s) + return nullptr; + while (this->Next(*s)) + s = this->Next(*s); + if (this->NextInFullList(*s)) + return this->NextInFullList(*s); + return this->First(); +} + unsigned CSSSelectorList::ComputeLength() const { if (!selector_array_) return 0; @@ -120,8 +294,8 @@ void CSSSelectorList::DeleteSelectors() { String CSSSelectorList::SelectorsText() const { StringBuilder result; - for (const CSSSelector* s = First(); s; s = Next(*s)) { - if (s != First()) + for (const CSSSelector* s = FirstForCSSOM(); s; s = Next(*s)) { + if (s != FirstForCSSOM()) result.Append(", "); result.Append(s->SelectorText()); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorList.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorList.h index 3cfca189c7..350b279402 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorList.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorList.h @@ -26,9 +26,10 @@ #ifndef CSSSelectorList_h #define CSSSelectorList_h +#include +#include #include "core/CoreExport.h" #include "core/css/CSSSelector.h" -#include namespace blink { @@ -71,7 +72,16 @@ class CORE_EXPORT CSSSelectorList { o.selector_array_ = nullptr; } + static CSSSelectorList ConcatenatePseudoMatchesExpansion( + const CSSSelectorList& expanded, + const CSSSelectorList& original); + + CSSSelectorList ExpandedFirstMatchesPseudo() const; + CSSSelectorList TransformForPseudoMatches(); + bool HasPseudoMatches() const; + CSSSelectorList& operator=(CSSSelectorList&& o) { + DCHECK(this != &o); DeleteSelectorsIfNeeded(); selector_array_ = o.selector_array_; o.selector_array_ = nullptr; @@ -86,7 +96,9 @@ class CORE_EXPORT CSSSelectorList { bool IsValid() const { return !!selector_array_; } const CSSSelector* First() const { return selector_array_; } + const CSSSelector* FirstForCSSOM() const; static const CSSSelector* Next(const CSSSelector&); + static const CSSSelector* NextInFullList(const CSSSelector&); // The CSS selector represents a single sequence of simple selectors. bool HasOneSelector() const { @@ -133,6 +145,15 @@ class CORE_EXPORT CSSSelectorList { inline const CSSSelector* CSSSelectorList::Next(const CSSSelector& current) { // Skip subparts of compound selectors. const CSSSelector* last = ¤t; + while (!last->IsLastInTagHistory()) + last++; + return last->IsLastInOriginalList() ? nullptr : last + 1; +} + +inline const CSSSelector* CSSSelectorList::NextInFullList( + const CSSSelector& current) { + // Skip subparts of compound selectors. + const CSSSelector* last = ¤t; while (!last->IsLastInTagHistory()) last++; return last->IsLastInSelectorList() ? nullptr : last + 1; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorWatch.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorWatch.cpp index d8b4b35930..abf47293ca 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorWatch.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorWatch.cpp @@ -41,8 +41,8 @@ namespace blink { -// The address of this string is important; its value is just documentation. -static const char kSupplementNameWatch[] = "CSSSelectorWatch"; +// static +const char CSSSelectorWatch::kSupplementName[] = "CSSSelectorWatch"; CSSSelectorWatch::CSSSelectorWatch(Document& document) : Supplement(document), @@ -56,14 +56,13 @@ CSSSelectorWatch& CSSSelectorWatch::From(Document& document) { CSSSelectorWatch* watch = FromIfExists(document); if (!watch) { watch = new CSSSelectorWatch(document); - Supplement::ProvideTo(document, kSupplementNameWatch, watch); + ProvideTo(document, watch); } return *watch; } CSSSelectorWatch* CSSSelectorWatch::FromIfExists(Document& document) { - return static_cast( - Supplement::From(document, kSupplementNameWatch)); + return Supplement::From(document); } void CSSSelectorWatch::CallbackSelectorChangeTimerFired(TimerBase*) { @@ -137,7 +136,7 @@ void CSSSelectorWatch::UpdateSelectorMatches( } static bool AllCompound(const CSSSelectorList& selector_list) { - for (const CSSSelector* selector = selector_list.First(); selector; + for (const CSSSelector* selector = selector_list.FirstForCSSOM(); selector; selector = selector_list.Next(*selector)) { if (!selector->IsCompound()) return false; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorWatch.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorWatch.h index 2557e1056f..3e88731b2a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorWatch.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSSelectorWatch.h @@ -48,6 +48,8 @@ class CORE_EXPORT CSSSelectorWatch final USING_GARBAGE_COLLECTED_MIXIN(CSSSelectorWatch); public: + static const char kSupplementName[]; + virtual ~CSSSelectorWatch() = default; static CSSSelectorWatch& From(Document&); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSShadowValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSShadowValue.cpp index 8cce5b794e..bcacab1e4f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSShadowValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSShadowValue.cpp @@ -44,31 +44,26 @@ CSSShadowValue::CSSShadowValue(CSSPrimitiveValue* x, String CSSShadowValue::CustomCSSText() const { StringBuilder text; - if (color) + if (color) { text.Append(color->CssText()); - if (x) { - if (!text.IsEmpty()) - text.Append(' '); - text.Append(x->CssText()); - } - if (y) { - if (!text.IsEmpty()) - text.Append(' '); - text.Append(y->CssText()); + text.Append(' '); } + + text.Append(x->CssText()); + text.Append(' '); + + text.Append(y->CssText()); + if (blur) { - if (!text.IsEmpty()) - text.Append(' '); + text.Append(' '); text.Append(blur->CssText()); } if (spread) { - if (!text.IsEmpty()) - text.Append(' '); + text.Append(' '); text.Append(spread->CssText()); } if (style) { - if (!text.IsEmpty()) - text.Append(' '); + text.Append(' '); text.Append(style->CssText()); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleDeclaration.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleDeclaration.h index edc1661b7f..d0b61ccccc 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleDeclaration.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleDeclaration.h @@ -35,7 +35,6 @@ namespace blink { class CSSRule; class CSSStyleSheet; class CSSValue; -class Element; class ExceptionState; enum class SecureContextMode; @@ -45,7 +44,6 @@ class CORE_EXPORT CSSStyleDeclaration : public ScriptWrappable { public: virtual ~CSSStyleDeclaration() = default; - virtual Element* ParentElement() const { return nullptr; } virtual CSSRule* parentRule() const = 0; String cssFloat() { return GetPropertyValueInternal(CSSPropertyFloat); } void setCSSFloat(const ExecutionContext* execution_context, @@ -89,7 +87,7 @@ class CORE_EXPORT CSSStyleDeclaration : public ScriptWrappable { SecureContextMode, ExceptionState&) = 0; - virtual bool CssPropertyMatches(CSSPropertyID, const CSSValue*) const = 0; + virtual bool CssPropertyMatches(CSSPropertyID, const CSSValue&) const = 0; virtual CSSStyleSheet* ParentStyleSheet() const { return nullptr; } protected: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.cpp index beea08611f..1069a11820 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.cpp @@ -44,7 +44,7 @@ static SelectorTextCache& GetSelectorTextCache() { CSSStyleRule::CSSStyleRule(StyleRule* style_rule, CSSStyleSheet* parent) : CSSRule(parent), style_rule_(style_rule), - attribute_style_map_(new DeclaredStylePropertyMap(this)) {} + style_map_(new DeclaredStylePropertyMap(this)) {} CSSStyleRule::~CSSStyleRule() = default; @@ -111,7 +111,7 @@ void CSSStyleRule::Reattach(StyleRuleBase* rule) { void CSSStyleRule::Trace(blink::Visitor* visitor) { visitor->Trace(style_rule_); visitor->Trace(properties_cssom_wrapper_); - visitor->Trace(attribute_style_map_); + visitor->Trace(style_map_); CSSRule::Trace(visitor); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.h index 99cc937b50..87ab08d96a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.h @@ -51,9 +51,7 @@ class CORE_EXPORT CSSStyleRule final : public CSSRule { CSSStyleDeclaration* style() const; - StylePropertyMap* attributeStyleMap() const { - return attribute_style_map_.Get(); - } + StylePropertyMap* styleMap() const { return style_map_.Get(); } // FIXME: Not CSSOM. Remove. StyleRule* GetStyleRule() const { return style_rule_.Get(); } @@ -67,7 +65,7 @@ class CORE_EXPORT CSSStyleRule final : public CSSRule { Member style_rule_; mutable Member properties_cssom_wrapper_; - Member attribute_style_map_; + Member style_map_; }; DEFINE_CSS_RULE_TYPE_CASTS(CSSStyleRule, kStyleRule); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.idl index af119069c6..2bfabec821 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleRule.idl @@ -25,5 +25,5 @@ ] interface CSSStyleRule : CSSRule { [SetterCallWith=ExecutionContext] attribute DOMString selectorText; [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style; - [SameObject, RuntimeEnabled=CSSTypedOM, MeasureAs=CSSTypedOMStylePropertyMap] readonly attribute StylePropertyMap attributeStyleMap; + [SameObject, RuntimeEnabled=CSSTypedOM, MeasureAs=CSSTypedOMStylePropertyMap] readonly attribute StylePropertyMap styleMap; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp index 65a9b71a12..4275ab1bdd 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.cpp @@ -22,8 +22,10 @@ #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/V8BindingForCore.h" +#include "bindings/core/v8/media_list_or_string.h" #include "core/css/CSSImportRule.h" #include "core/css/CSSRuleList.h" +#include "core/css/CSSStyleSheetInit.h" #include "core/css/MediaList.h" #include "core/css/StyleEngine.h" #include "core/css/StyleRule.h" @@ -34,7 +36,9 @@ #include "core/dom/ExceptionCode.h" #include "core/dom/Node.h" #include "core/frame/Deprecation.h" +#include "core/html/HTMLLinkElement.h" #include "core/html/HTMLStyleElement.h" +#include "core/html_names.h" #include "core/probe/CoreProbes.h" #include "core/svg/SVGStyleElement.h" #include "platform/bindings/V8PerIsolateData.h" @@ -43,6 +47,8 @@ namespace blink { +using namespace HTMLNames; + class StyleSheetCSSRuleList final : public CSSRuleList { public: static StyleSheetCSSRuleList* Create(CSSStyleSheet* sheet) { @@ -86,6 +92,45 @@ const Document* CSSStyleSheet::SingleOwnerDocument( return nullptr; } +CSSStyleSheet* CSSStyleSheet::Create(Document& document, + const String& text, + ExceptionState& exception_state) { + return CSSStyleSheet::Create(document, text, CSSStyleSheetInit(), + exception_state); +} + +CSSStyleSheet* CSSStyleSheet::Create(Document& document, + const String& text, + const CSSStyleSheetInit& options, + ExceptionState& exception_state) { + if (!RuntimeEnabledFeatures::ConstructableStylesheetsEnabled()) { + exception_state.ThrowTypeError("Illegal constructor"); + return nullptr; + } + // Folowing steps at spec draft + // https://wicg.github.io/construct-stylesheets/#dom-cssstylesheet-cssstylesheet + CSSParserContext* parser_context = CSSParserContext::Create(document); + StyleSheetContents* contents = StyleSheetContents::Create(parser_context); + CSSStyleSheet* sheet = new CSSStyleSheet(contents, nullptr); + sheet->SetTitle(options.title()); + sheet->ClearOwnerNode(); + sheet->ClearOwnerRule(); + if (options.media().IsString()) { + MediaList* media_list = MediaList::Create( + MediaQuerySet::Create(), const_cast(sheet)); + media_list->setMediaText(options.media().GetAsString()); + sheet->SetMedia(media_list); + } else { + sheet->SetMedia(options.media().GetAsMediaList()); + } + if (options.alternate()) + sheet->SetAlternateFromConstructor(true); + if (options.disabled()) + sheet->setDisabled(true); + sheet->SetText(text); + return sheet; +} + CSSStyleSheet* CSSStyleSheet::Create(StyleSheetContents* sheet, CSSImportRule* owner_rule) { return new CSSStyleSheet(sheet, owner_rule); @@ -168,13 +213,19 @@ void CSSStyleSheet::DidMutateRules() { DCHECK_LE(contents_->ClientSize(), 1u); Document* owner = OwnerDocument(); - if (!owner) - return; - if (ownerNode() && ownerNode()->isConnected()) { + if (owner && ownerNode() && ownerNode()->isConnected()) { owner->GetStyleEngine().SetNeedsActiveStyleUpdate( ownerNode()->GetTreeScope()); if (StyleResolver* resolver = owner->GetStyleEngine().Resolver()) resolver->InvalidateMatchedPropertiesCache(); + } else if (!constructed_tree_scopes_.IsEmpty()) { + for (auto tree_scope : constructed_tree_scopes_) { + tree_scope->GetDocument().GetStyleEngine().SetNeedsActiveStyleUpdate( + *tree_scope); + if (StyleResolver* resolver = + tree_scope->GetDocument().GetStyleEngine().Resolver()) + resolver->InvalidateMatchedPropertiesCache(); + } } } @@ -258,7 +309,7 @@ bool CSSStyleSheet::CanAccessRules() const { return true; if (document->GetStyleEngine().InspectorStyleSheet() == this) return true; - if (document->GetSecurityOrigin()->CanRequestNoSuborigin(base_url)) + if (document->GetSecurityOrigin()->CanRequest(base_url)) return true; if (allow_rule_access_from_origin_ && document->GetSecurityOrigin()->CanAccess( @@ -302,7 +353,6 @@ unsigned CSSStyleSheet::insertRule(const String& rule_string, return 0; } RuleMutationScope mutation_scope(this); - bool success = contents_->WrapperInsertRule(rule, index); if (!success) { if (rule->IsNamespaceRule()) @@ -408,6 +458,10 @@ MediaList* CSSStyleSheet::media() { return media_cssom_wrapper_.Get(); } +void CSSStyleSheet::SetMedia(MediaList* media_list) { + media_cssom_wrapper_ = media_list; +} + CSSStyleSheet* CSSStyleSheet::parentStyleSheet() const { return owner_rule_ ? owner_rule_->parentStyleSheet() : nullptr; } @@ -455,10 +509,51 @@ void CSSStyleSheet::SetText(const String& text) { contents_->ParseString(text); } +void CSSStyleSheet::SetAlternateFromConstructor( + bool alternate_from_constructor) { + alternate_from_constructor_ = alternate_from_constructor; +} + +bool CSSStyleSheet::IsAlternate() const { + if (owner_node_) { + return owner_node_->IsElementNode() && + ToElement(owner_node_)->getAttribute(relAttr).Contains("alternate"); + } + return alternate_from_constructor_; +} + +bool CSSStyleSheet::CanBeActivated( + const String& current_preferrable_name) const { + if (disabled()) + return false; + + if (owner_node_ && owner_node_->IsInShadowTree()) { + if (IsHTMLStyleElement(owner_node_) || IsSVGStyleElement(owner_node_)) + return true; + if (IsHTMLLinkElement(owner_node_) && + ToHTMLLinkElement(owner_node_)->IsImport()) + return !IsAlternate(); + } + + if (!owner_node_ || + owner_node_->getNodeType() == Node::kProcessingInstructionNode || + !IsHTMLLinkElement(owner_node_) || + !ToHTMLLinkElement(owner_node_)->IsEnabledViaScript()) { + if (!title_.IsEmpty() && title_ != current_preferrable_name) + return false; + } + + if (IsAlternate() && title_.IsEmpty()) + return false; + + return true; +} + void CSSStyleSheet::Trace(blink::Visitor* visitor) { visitor->Trace(contents_); visitor->Trace(owner_node_); visitor->Trace(owner_rule_); + visitor->Trace(constructed_tree_scopes_); visitor->Trace(media_cssom_wrapper_); visitor->Trace(child_rule_cssom_wrappers_); visitor->Trace(rule_list_cssom_wrapper_); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.h index ce40a21b5f..093d14b68a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.h @@ -27,6 +27,7 @@ #include "core/css/CSSRule.h" #include "core/css/MediaQueryEvaluator.h" #include "core/css/StyleSheet.h" +#include "core/dom/TreeScope.h" #include "platform/heap/Handle.h" #include "platform/wtf/Noncopyable.h" #include "platform/wtf/text/TextEncoding.h" @@ -38,6 +39,7 @@ class CSSImportRule; class CSSRule; class CSSRuleList; class CSSStyleSheet; +class CSSStyleSheetInit; class Document; class ExceptionState; class MediaQuerySet; @@ -50,6 +52,12 @@ class CORE_EXPORT CSSStyleSheet final : public StyleSheet { public: static const Document* SingleOwnerDocument(const CSSStyleSheet*); + static CSSStyleSheet* Create(Document&, const String&, ExceptionState&); + static CSSStyleSheet* Create(Document&, + const String&, + const CSSStyleSheetInit&, + ExceptionState&); + static CSSStyleSheet* Create(StyleSheetContents*, CSSImportRule* owner_rule = nullptr); static CSSStyleSheet* Create(StyleSheetContents*, Node& owner_node); @@ -119,6 +127,14 @@ class CORE_EXPORT CSSStyleSheet final : public StyleSheet { void SetAllowRuleAccessFromOrigin( scoped_refptr allowed_origin); + void AddedConstructedToTreeScope(TreeScope* tree_scope) { + constructed_tree_scopes_.insert(tree_scope); + } + + void RemovedConstructedFromTreeScope(TreeScope* tree_scope) { + constructed_tree_scopes_.erase(tree_scope); + } + class RuleMutationScope { STACK_ALLOCATED(); @@ -145,6 +161,10 @@ class CORE_EXPORT CSSStyleSheet final : public StyleSheet { bool LoadCompleted() const { return load_completed_; } void StartLoadingDynamicSheet(); void SetText(const String&); + void SetMedia(MediaList*); + void SetAlternateFromConstructor(bool); + bool IsAlternate() const; + bool CanBeActivated(const String& current_preferrable_name) const; virtual void Trace(blink::Visitor*); @@ -164,10 +184,21 @@ class CORE_EXPORT CSSStyleSheet final : public StyleSheet { void SetLoadCompleted(bool); + FRIEND_TEST_ALL_PREFIXES( + CSSStyleSheetTest, + CSSStyleSheetConstructionWithEmptyCSSStyleSheetInitAndText); + FRIEND_TEST_ALL_PREFIXES( + CSSStyleSheetTest, + CSSStyleSheetConstructionWithoutEmptyCSSStyleSheetInitAndText); + bool AlternateFromConstructor() const { return alternate_from_constructor_; } + Member contents_; bool is_inline_stylesheet_ = false; bool is_disabled_ = false; bool load_completed_ = false; + // This alternate variable is only used for constructed CSSStyleSheet. + // For other CSSStyleSheet, consult the alternate attribute. + bool alternate_from_constructor_ = false; String title_; scoped_refptr media_queries_; MediaQueryResultList viewport_dependent_media_query_results_; @@ -177,6 +208,7 @@ class CORE_EXPORT CSSStyleSheet final : public StyleSheet { Member owner_node_; Member owner_rule_; + HeapHashSet> constructed_tree_scopes_; TextPosition start_position_; Member media_cssom_wrapper_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.idl index 1251d19c8c..b76761ac24 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheet.idl @@ -21,6 +21,9 @@ // https://drafts.csswg.org/cssom/#the-cssstylesheet-interface [ + ConstructorCallWith=Document, + RaisesException=Constructor, + Constructor(DOMString text, optional CSSStyleSheetInit options), Exposed=Window ] interface CSSStyleSheet : StyleSheet { readonly attribute CSSRule? ownerRule; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheetInit.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheetInit.idl new file mode 100644 index 0000000000..7ce5fb6fe7 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheetInit.idl @@ -0,0 +1,10 @@ +// Copyright 2018 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. + +dictionary CSSStyleSheetInit { + (MediaList or DOMString) media = ""; + DOMString title = ""; + boolean alternate = false; + boolean disabled = false; +}; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheetTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheetTest.cpp new file mode 100644 index 0000000000..a317b31cb0 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSStyleSheetTest.cpp @@ -0,0 +1,78 @@ +// Copyright 2018 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/media_list_or_string.h" +#include "core/css/CSSRuleList.h" +#include "core/css/CSSStyleSheet.h" +#include "core/css/CSSStyleSheetInit.h" +#include "core/css/MediaList.h" +#include "core/testing/PageTestBase.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace blink { + +class CSSStyleSheetTest : public PageTestBase { + protected: + virtual void SetUp() { + PageTestBase::SetUp(); + RuntimeEnabledFeatures::SetConstructableStylesheetsEnabled(true); + } +}; + +TEST_F(CSSStyleSheetTest, ConstructorWithoutRuntimeFlagThrowsException) { + DummyExceptionStateForTesting exception_state; + RuntimeEnabledFeatures::SetConstructableStylesheetsEnabled(false); + EXPECT_EQ(CSSStyleSheet::Create(GetDocument(), "", CSSStyleSheetInit(), + exception_state), + nullptr); + ASSERT_TRUE(exception_state.HadException()); +} + +TEST_F(CSSStyleSheetTest, + CSSStyleSheetConstructionWithEmptyCSSStyleSheetInitAndText) { + DummyExceptionStateForTesting exception_state; + CSSStyleSheet* sheet = CSSStyleSheet::Create( + GetDocument(), "", CSSStyleSheetInit(), exception_state); + ASSERT_FALSE(exception_state.HadException()); + EXPECT_TRUE(sheet->href().IsNull()); + EXPECT_EQ(sheet->parentStyleSheet(), nullptr); + EXPECT_EQ(sheet->ownerNode(), nullptr); + EXPECT_EQ(sheet->ownerRule(), nullptr); + EXPECT_EQ(sheet->media()->length(), 0U); + EXPECT_EQ(sheet->title(), StringImpl::empty_); + EXPECT_FALSE(sheet->AlternateFromConstructor()); + EXPECT_FALSE(sheet->disabled()); + EXPECT_EQ(sheet->cssRules(exception_state)->length(), 0U); + ASSERT_FALSE(exception_state.HadException()); +} + +TEST_F(CSSStyleSheetTest, + CSSStyleSheetConstructionWithoutEmptyCSSStyleSheetInitAndText) { + DummyExceptionStateForTesting exception_state; + String styleText[2] = {".red { color: red; }", + ".red + span + span { color: red; }"}; + CSSStyleSheetInit init; + init.setMedia(MediaListOrString::FromString("screen, print")); + init.setTitle("test"); + init.setAlternate(true); + init.setDisabled(true); + CSSStyleSheet* sheet = CSSStyleSheet::Create( + GetDocument(), styleText[0] + styleText[1], init, exception_state); + ASSERT_FALSE(exception_state.HadException()); + EXPECT_TRUE(sheet->href().IsNull()); + EXPECT_EQ(sheet->parentStyleSheet(), nullptr); + EXPECT_EQ(sheet->ownerNode(), nullptr); + EXPECT_EQ(sheet->ownerRule(), nullptr); + EXPECT_EQ(sheet->media()->length(), 2U); + EXPECT_EQ(sheet->media()->mediaText(), init.media().GetAsString()); + EXPECT_EQ(sheet->title(), init.title()); + EXPECT_TRUE(sheet->AlternateFromConstructor()); + EXPECT_TRUE(sheet->disabled()); + EXPECT_EQ(sheet->cssRules(exception_state)->length(), 2U); + EXPECT_EQ(sheet->cssRules(exception_state)->item(0)->cssText(), styleText[0]); + EXPECT_EQ(sheet->cssRules(exception_state)->item(1)->cssText(), styleText[1]); + ASSERT_FALSE(exception_state.HadException()); +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTestHelper.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTestHelper.cpp index 3766cfc56a..2e2a5b2c86 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTestHelper.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTestHelper.cpp @@ -63,11 +63,14 @@ RuleSet& CSSTestHelper::GetRuleSet() { return rule_set; } -void CSSTestHelper::AddCSSRules(const char* css_text) { +void CSSTestHelper::AddCSSRules(const char* css_text, bool is_empty_sheet) { TextPosition position; unsigned sheet_length = style_sheet_->length(); style_sheet_->Contents()->ParseStringAtPosition(css_text, position); - ASSERT_GT(style_sheet_->length(), sheet_length); + if (!is_empty_sheet) + ASSERT_GT(style_sheet_->length(), sheet_length); + else + ASSERT_EQ(style_sheet_->length(), sheet_length); } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTestHelper.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTestHelper.h index ca8c4e145b..ab0997d222 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTestHelper.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTestHelper.h @@ -55,7 +55,7 @@ class CSSTestHelper { const Document& GetDocument() { return *document_; }; - void AddCSSRules(const char* rule_text); + void AddCSSRules(const char* rule_text, bool is_empty_sheet = false); RuleSet& GetRuleSet(); CSSRuleList* CssRules(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTiming.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTiming.cpp index 160c465944..6227b735e2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTiming.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTiming.cpp @@ -8,25 +8,25 @@ namespace blink { -static const char kSupplementName[] = "CSSTiming"; +// static +const char CSSTiming::kSupplementName[] = "CSSTiming"; CSSTiming& CSSTiming::From(Document& document) { - CSSTiming* timing = static_cast( - Supplement::From(document, kSupplementName)); + CSSTiming* timing = Supplement::From(document); if (!timing) { timing = new CSSTiming(document); - Supplement::ProvideTo(document, kSupplementName, timing); + ProvideTo(document, timing); } return *timing; } void CSSTiming::RecordAuthorStyleSheetParseTime(double seconds) { - if (!paint_timing_->FirstContentfulPaint()) + if (paint_timing_->FirstContentfulPaint().is_null()) parse_time_before_fcp_ += seconds; } void CSSTiming::RecordUpdateDuration(double seconds) { - if (!paint_timing_->FirstContentfulPaint()) + if (paint_timing_->FirstContentfulPaint().is_null()) update_time_before_fcp_ += seconds; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTiming.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTiming.h index 4a300bb828..bb24b3a080 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTiming.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTiming.h @@ -20,6 +20,8 @@ class CSSTiming : public GarbageCollectedFinalized, USING_GARBAGE_COLLECTED_MIXIN(CSSTiming); public: + static const char kSupplementName[]; + virtual ~CSSTiming() = default; void RecordAuthorStyleSheetParseTime(double seconds); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.cpp index b1e3d6c04b..1150393e6b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.cpp @@ -28,6 +28,7 @@ #include "platform/wtf/text/WTFString.h" namespace blink { +namespace cssvalue { String CSSCubicBezierTimingFunctionValue::CustomCSSText() const { return "cubic-bezier(" + String::Number(x1_) + ", " + String::Number(y1_) + @@ -70,4 +71,5 @@ bool CSSFramesTimingFunctionValue::Equals( return frames_ == other.frames_; } +} // namespace cssvalue } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.h index e6ea3b98cf..d9d843faab 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSTimingFunctionValue.h @@ -32,6 +32,7 @@ #include "platform/runtime_enabled_features.h" namespace blink { +namespace cssvalue { class CSSCubicBezierTimingFunctionValue : public CSSValue { public: @@ -135,6 +136,7 @@ class CSSFramesTimingFunctionValue : public CSSValue { DEFINE_CSS_VALUE_TYPE_CASTS(CSSFramesTimingFunctionValue, IsFramesTimingFunctionValue()); +} // namespace cssvalue } // namespace blink #endif diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSUnsetValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSUnsetValue.cpp index 74c96f40a4..b5367f28d1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSUnsetValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSUnsetValue.cpp @@ -8,6 +8,7 @@ #include "platform/wtf/text/WTFString.h" namespace blink { +namespace cssvalue { CSSUnsetValue* CSSUnsetValue::Create() { return CssValuePool().UnsetValue(); @@ -17,4 +18,5 @@ String CSSUnsetValue::CustomCSSText() const { return "unset"; } +} // namespace cssvalue } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSUnsetValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSUnsetValue.h index 34b21397eb..bfe1597456 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSUnsetValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSUnsetValue.h @@ -10,6 +10,10 @@ namespace blink { +class CSSValuePool; + +namespace cssvalue { + class CSSUnsetValue : public CSSValue { public: static CSSUnsetValue* Create(); @@ -23,13 +27,14 @@ class CSSUnsetValue : public CSSValue { } private: - friend class CSSValuePool; + friend class ::blink::CSSValuePool; CSSUnsetValue() : CSSValue(kUnsetClass) {} }; DEFINE_CSS_VALUE_TYPE_CASTS(CSSUnsetValue, IsUnsetValue()); +} // namespace cssvalue } // namespace blink #endif // CSSUnsetValue_h diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValue.cpp index c3489194a1..4e16f78aed 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValue.cpp @@ -50,6 +50,7 @@ #include "core/css/CSSImageValue.h" #include "core/css/CSSInheritedValue.h" #include "core/css/CSSInitialValue.h" +#include "core/css/CSSLayoutFunctionValue.h" #include "core/css/CSSPaintValue.h" #include "core/css/CSSPathValue.h" #include "core/css/CSSPendingSubstitutionValue.h" @@ -176,6 +177,8 @@ bool CSSValue::operator==(const CSSValue& other) const { return CompareCSSValues(*this, other); case kFunctionClass: return CompareCSSValues(*this, other); + case kLayoutFunctionClass: + return CompareCSSValues(*this, other); case kLinearGradientClass: return CompareCSSValues(*this, other); case kRadialGradientClass: @@ -280,6 +283,8 @@ String CSSValue::CssText() const { return ToCSSFontVariationValue(this)->CustomCSSText(); case kFunctionClass: return ToCSSFunctionValue(this)->CustomCSSText(); + case kLayoutFunctionClass: + return ToCSSLayoutFunctionValue(this)->CustomCSSText(); case kLinearGradientClass: return ToCSSLinearGradientValue(this)->CustomCSSText(); case kRadialGradientClass: @@ -395,6 +400,9 @@ void CSSValue::FinalizeGarbageCollectedObject() { case kFunctionClass: ToCSSFunctionValue(this)->~CSSFunctionValue(); return; + case kLayoutFunctionClass: + ToCSSLayoutFunctionValue(this)->~CSSLayoutFunctionValue(); + return; case kLinearGradientClass: ToCSSLinearGradientValue(this)->~CSSLinearGradientValue(); return; @@ -543,6 +551,9 @@ void CSSValue::Trace(blink::Visitor* visitor) { case kFunctionClass: ToCSSFunctionValue(this)->TraceAfterDispatch(visitor); return; + case kLayoutFunctionClass: + ToCSSLayoutFunctionValue(this)->TraceAfterDispatch(visitor); + return; case kLinearGradientClass: ToCSSLinearGradientValue(this)->TraceAfterDispatch(visitor); return; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValue.h index a57f8ee508..9ae3d2a1cf 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValue.h @@ -111,6 +111,9 @@ class CORE_EXPORT CSSValue : public GarbageCollectedFinalized { bool IsCSSWideKeyword() const { return class_type_ >= kInheritedClass && class_type_ <= kUnsetClass; } + bool IsLayoutFunctionValue() const { + return class_type_ == kLayoutFunctionClass; + } bool IsLinearGradientValue() const { return class_type_ == kLinearGradientClass; } @@ -232,6 +235,7 @@ class CORE_EXPORT CSSValue : public GarbageCollectedFinalized { kVariableReferenceClass, kCustomPropertyDeclarationClass, kPendingSubstitutionValueClass, + kLayoutFunctionClass, kCSSContentDistributionClass, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValueIDMappings.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValueIDMappings.h index 99a7834607..95bee3e0a6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValueIDMappings.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValueIDMappings.h @@ -112,11 +112,59 @@ inline ECursor CssValueIDToPlatformEnum(CSSValueID v) { template <> inline EDisplay CssValueIDToPlatformEnum(CSSValueID v) { + if (v == CSSValueNone) + return EDisplay::kNone; + if (v == CSSValueInline) + return EDisplay::kInline; + if (v == CSSValueBlock) + return EDisplay::kBlock; + if (v == CSSValueFlowRoot) + return EDisplay::kFlowRoot; + if (v == CSSValueListItem) + return EDisplay::kListItem; + if (v == CSSValueInlineBlock) + return EDisplay::kInlineBlock; + if (v == CSSValueTable) + return EDisplay::kTable; + if (v == CSSValueInlineTable) + return EDisplay::kInlineTable; + if (v == CSSValueTableRowGroup) + return EDisplay::kTableRowGroup; + if (v == CSSValueTableHeaderGroup) + return EDisplay::kTableHeaderGroup; + if (v == CSSValueTableFooterGroup) + return EDisplay::kTableFooterGroup; + if (v == CSSValueTableRow) + return EDisplay::kTableRow; + if (v == CSSValueTableColumnGroup) + return EDisplay::kTableColumnGroup; + if (v == CSSValueTableColumn) + return EDisplay::kTableColumn; + if (v == CSSValueTableCell) + return EDisplay::kTableCell; + if (v == CSSValueTableCaption) + return EDisplay::kTableCaption; + if (v == CSSValueWebkitBox) + return EDisplay::kWebkitBox; + if (v == CSSValueWebkitInlineBox) + return EDisplay::kWebkitInlineBox; + if (v == CSSValueFlex) + return EDisplay::kFlex; + if (v == CSSValueInlineFlex) + return EDisplay::kInlineFlex; + if (v == CSSValueGrid) + return EDisplay::kGrid; + if (v == CSSValueInlineGrid) + return EDisplay::kInlineGrid; + if (v == CSSValueContents) + return EDisplay::kContents; if (v == CSSValueWebkitFlex) return EDisplay::kFlex; if (v == CSSValueWebkitInlineFlex) return EDisplay::kInlineFlex; - return detail::cssValueIDToPlatformEnumGenerated(v); + + NOTREACHED(); + return EDisplay::kInline; } template <> @@ -126,6 +174,59 @@ inline EUserSelect CssValueIDToPlatformEnum(CSSValueID v) { return detail::cssValueIDToPlatformEnumGenerated(v); } +template <> +inline CSSValueID PlatformEnumToCSSValueID(EDisplay v) { + if (v == EDisplay::kNone) + return CSSValueNone; + if (v == EDisplay::kInline) + return CSSValueInline; + if (v == EDisplay::kBlock) + return CSSValueBlock; + if (v == EDisplay::kFlowRoot) + return CSSValueFlowRoot; + if (v == EDisplay::kListItem) + return CSSValueListItem; + if (v == EDisplay::kInlineBlock) + return CSSValueInlineBlock; + if (v == EDisplay::kTable) + return CSSValueTable; + if (v == EDisplay::kInlineTable) + return CSSValueInlineTable; + if (v == EDisplay::kTableRowGroup) + return CSSValueTableRowGroup; + if (v == EDisplay::kTableHeaderGroup) + return CSSValueTableHeaderGroup; + if (v == EDisplay::kTableFooterGroup) + return CSSValueTableFooterGroup; + if (v == EDisplay::kTableRow) + return CSSValueTableRow; + if (v == EDisplay::kTableColumnGroup) + return CSSValueTableColumnGroup; + if (v == EDisplay::kTableColumn) + return CSSValueTableColumn; + if (v == EDisplay::kTableCell) + return CSSValueTableCell; + if (v == EDisplay::kTableCaption) + return CSSValueTableCaption; + if (v == EDisplay::kWebkitBox) + return CSSValueWebkitBox; + if (v == EDisplay::kWebkitInlineBox) + return CSSValueWebkitInlineBox; + if (v == EDisplay::kFlex) + return CSSValueFlex; + if (v == EDisplay::kInlineFlex) + return CSSValueInlineFlex; + if (v == EDisplay::kGrid) + return CSSValueGrid; + if (v == EDisplay::kInlineGrid) + return CSSValueInlineGrid; + if (v == EDisplay::kContents) + return CSSValueContents; + + NOTREACHED(); + return CSSValueInline; +} + } // namespace blink #endif diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValueKeywords.json5 b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValueKeywords.json5 index f7367931c8..ffed993298 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValueKeywords.json5 +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValueKeywords.json5 @@ -373,6 +373,8 @@ //none "-webkit-flex", "-webkit-inline-flex", + "layout", + "inline-layout", // // cursor // The order of this enum must match the order found in CSSPropertyParser::ConsumeCursor(). @@ -1110,6 +1112,11 @@ "translateZ", "translate3d", + // scale + "x", + "y", + "z", + // offset-path "path", "ray", @@ -1120,8 +1127,8 @@ // scroll-snap-type // none - "x", - "y", + // x + // y // block // inline // both @@ -1142,7 +1149,7 @@ // containment // paint "style", - "layout", + // layout "size", // grid auto-repeat @@ -1172,5 +1179,15 @@ // auto, // contain // none + + //scroll-customization + // auto + // pan-x, + // pan-left, + // pan-right, + // pan-y, + // pan-up, + // pan-down + // none ], } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValuePool.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValuePool.h index 07923cbe6f..bd4473eacd 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValuePool.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSValuePool.h @@ -52,6 +52,7 @@ class CORE_EXPORT CSSValuePool // TODO(sashab): Make all the value pools store const CSSValues. static const int kMaximumCacheableIntegerValue = 255; using CSSColorValue = cssvalue::CSSColorValue; + using CSSUnsetValue = cssvalue::CSSUnsetValue; using ColorValueCache = HeapHashMap>; static const unsigned kMaximumColorCacheSize = 512; using FontFaceValueCache = diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSVariableData.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSVariableData.h index 81de3b86e5..1c778a5ed8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSVariableData.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/CSSVariableData.h @@ -21,6 +21,9 @@ class CORE_EXPORT CSSVariableData : public RefCounted { USING_FAST_MALLOC(CSSVariableData); public: + static scoped_refptr Create() { + return base::AdoptRef(new CSSVariableData()); + } static scoped_refptr Create(const CSSParserTokenRange& range, bool is_animation_tainted, bool needs_variable_resolution) { @@ -51,6 +54,9 @@ class CORE_EXPORT CSSVariableData : public RefCounted { SecureContextMode) const; private: + CSSVariableData() + : is_animation_tainted_(false), needs_variable_resolution_(false){}; + CSSVariableData(const CSSParserTokenRange&, bool is_animation_tainted, bool needs_variable_resolution); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ComputedStyleDiffFunctions.json5 b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ComputedStyleDiffFunctions.json5 index 12248ef170..95dd004e34 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ComputedStyleDiffFunctions.json5 +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ComputedStyleDiffFunctions.json5 @@ -65,8 +65,8 @@ "OrderedNamedGridRowLines", "AutoRepeatNamedGridColumnLines", "AutoRepeatNamedGridRowLines", "AutoRepeatOrderedNamedGridColumnLines", "AutoRepeatOrderedNamedGridRowLines", "NamedGridArea", "grid-auto-rows", - "grid-template-rows", "grid-template-columns", "grid-auto-columns", "grid-row-gap", - "grid-column-gap", "NamedGridAreaRowCount", "NamedGridAreaColumnCount", + "grid-template-rows", "grid-template-columns", "grid-auto-columns", "row-gap", + "NamedGridAreaRowCount", "NamedGridAreaColumnCount", "GridAutoRepeatColumns", "GridAutoRepeatRows", "GridAutoRepeatColumnsInsertionPoint", "GridAutoRepeatRowsInsertionPoint", "grid-auto-flow", "GridAutoRepeatColumnsType", "GridAutoRepeatRowsType", "-webkit-box-flex", @@ -76,7 +76,7 @@ "grid-row-start", "grid-row-end", "grid-column-start", "grid-column-end", "column-gap", "column-width", "column-rule-style", "column-rule-width", "column-rule-color", "ColumnRuleColorIsCurrentColor", "VisitedLinkColumnRuleColor", - "column-count", "HasAutoColumnCount", "HasAutoColumnWidth", "column-fill", "HasNormalColumnGap", "column-span",], + "column-count", "HasAutoColumnCount", "HasAutoColumnWidth", "column-fill", "column-span",], methods_to_diff: [ { method: "BorderLeftWidth()", @@ -154,10 +154,14 @@ method: "Floating()", field_dependencies: ["float"] }, + { + method: "DisplayLayoutCustomName()", + field_dependencies: ["DisplayLayoutCustomName"] + }, { method: "OriginalDisplay()", field_dependencies: ["OriginalDisplay"] - } + }, ], predicates_to_test: [ { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ComputedStyleExtraFields.json5 b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ComputedStyleExtraFields.json5 index 78f6c4d72c..857cfb0c57 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ComputedStyleExtraFields.json5 +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ComputedStyleExtraFields.json5 @@ -34,6 +34,12 @@ custom_copy: true, custom_compare: true, }, + { + name: "AnimationPropertiesLocked", + field_template: "primitive", + default_value: "false", + type_name: "bool", + }, { name: "BorderLeftColorIsCurrentColor", field_template: "primitive", @@ -63,15 +69,48 @@ field_group: "surround", }, { - name: "OriginalDisplay", + name: "Display", field_template: "keyword", + type_name: "EDisplay", + keywords: [ + "inline", "block", "list-item", "inline-block", "table", "inline-table", + "table-row-group", "table-header-group", "table-footer-group", + "table-row", "table-column-group", "table-column", "table-cell", + "table-caption", "-webkit-box", "-webkit-inline-box", "flex", + "inline-flex", "grid", "inline-grid", "contents", "flow-root", "none", + "layout-custom", "inline-layout-custom", + ], default_value: "inline", + }, + { + name: "DisplayLayoutCustomName", + field_template: "external", + field_group: "*", + type_name: "AtomicString", + include_paths: ["platform/wtf/text/AtomicString.h"], + default_value: "g_null_atom", + }, + { + name: "DisplayLayoutCustomParentName", + field_template: "external", + field_group: "*", + type_name: "AtomicString", + include_paths: ["platform/wtf/text/AtomicString.h"], + default_value: "g_null_atom", + }, + { + name: "OriginalDisplay", + field_template: "keyword", type_name: "EDisplay", keywords: [ - "inline", "block", "list-item", "inline-block", "table", "inline-table", "table-row-group", "table-header-group", - "table-footer-group", "table-row", "table-column-group", "table-column", "table-cell", "table-caption", "-webkit-box", - "-webkit-inline-box", "flex", "inline-flex", "grid", "inline-grid", "contents", "flow-root", "none", + "inline", "block", "list-item", "inline-block", "table", "inline-table", + "table-row-group", "table-header-group", "table-footer-group", + "table-row", "table-column-group", "table-column", "table-cell", + "table-caption", "-webkit-box", "-webkit-inline-box", "flex", + "inline-flex", "grid", "inline-grid", "contents", "flow-root", "none", + "layout-custom", "inline-layout-custom", ], + default_value: "inline", }, { name: "InsideLink", @@ -874,14 +913,6 @@ default_value: "true", computed_style_custom_functions: ["setter"], }, - { - name: "HasNormalColumnGap", - field_template: "primitive", - type_name: "bool", - field_group: "*->multi-col", - default_value: "true", - computed_style_custom_functions: ["setter"], - }, { name: "NamedGridColumnLines", field_template: "external", @@ -1014,5 +1045,13 @@ keywords: ["no-auto-repeat", "auto-fill", "auto-fit"], default_value: "no-auto-repeat", }, + { + name: "ForceLegacyLayout", + inherited: true, + field_template: "primitive", + type_name: "bool", + default_value: "false", + field_group: "*", + }, ], } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/DocumentStyleSheetCollection.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/DocumentStyleSheetCollection.cpp index 39c1ba3ddd..a5f80eaff7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/DocumentStyleSheetCollection.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/DocumentStyleSheetCollection.cpp @@ -32,6 +32,7 @@ #include "core/css/StyleChangeReason.h" #include "core/css/StyleEngine.h" #include "core/css/StyleSheetCandidate.h" +#include "core/css/StyleSheetList.h" #include "core/css/resolver/StyleResolver.h" #include "core/css/resolver/ViewportStyleResolver.h" #include "core/dom/Document.h" @@ -86,6 +87,25 @@ void DocumentStyleSheetCollection::CollectStyleSheetsFromCandidates( collector.AppendActiveStyleSheet( std::make_pair(css_sheet, master_engine.RuleSetForSheet(*css_sheet))); } + + if (!GetTreeScope().HasMoreStyleSheets()) + return; + + StyleSheetList& more_style_sheets = GetTreeScope().MoreStyleSheets(); + unsigned length = more_style_sheets.length(); + for (unsigned index = 0; index < length; ++index) { + StyleSheet* sheet = more_style_sheets.item(index); + if (!sheet) + continue; + CSSStyleSheet* css_sheet = ToCSSStyleSheet(sheet); + if (!css_sheet || + !css_sheet->CanBeActivated( + GetDocument().GetStyleEngine().PreferredStylesheetSetName())) + continue; + collector.AppendSheetForList(sheet); + collector.AppendActiveStyleSheet( + std::make_pair(css_sheet, master_engine.RuleSetForSheet(*css_sheet))); + } } void DocumentStyleSheetCollection::CollectStyleSheets( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.cpp index 1a1e08eef4..917e8a12d6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.cpp @@ -40,6 +40,7 @@ #include "core/css/CSSFontSelector.h" #include "core/css/CSSFontStyleRangeValue.h" #include "core/css/CSSIdentifierValue.h" +#include "core/css/CSSPropertyValueSet.h" #include "core/css/CSSUnicodeRangeValue.h" #include "core/css/CSSValueList.h" #include "core/css/FontFaceDescriptors.h" @@ -49,7 +50,6 @@ #include "core/css/StyleEngine.h" #include "core/css/StyleRule.h" #include "core/css/parser/AtRuleDescriptorParser.h" -#include "core/css/parser/AtRuleDescriptorValueSet.h" #include "core/css/parser/CSSParser.h" #include "core/dom/DOMException.h" #include "core/dom/Document.h" @@ -63,7 +63,6 @@ #include "core/workers/WorkerGlobalScope.h" #include "platform/Histogram.h" #include "platform/SharedBuffer.h" -#include "platform/WebTaskRunner.h" #include "platform/bindings/ScriptState.h" #include "platform/font_family_names.h" #include "platform/runtime_enabled_features.h" @@ -148,7 +147,7 @@ FontFace* FontFace::Create(ExecutionContext* context, kSyntaxError, "The source provided ('" + source + "') could not be parsed as a value list.")); - font_face->InitCSSFontFace(context, src); + font_face->InitCSSFontFace(context, *src); return font_face; } @@ -175,7 +174,7 @@ FontFace* FontFace::Create(ExecutionContext* context, FontFace* FontFace::Create(Document* document, const StyleRuleFontFace* font_face_rule) { - const AtRuleDescriptorValueSet& properties = font_face_rule->Properties(); + const CSSPropertyValueSet& properties = font_face_rule->Properties(); // Obtain the font-family property and the src property. Both must be defined. const CSSValue* family = @@ -205,7 +204,7 @@ FontFace* FontFace::Create(Document* document, AtRuleDescriptorID::FontDisplay) && font_face->GetFontSelectionCapabilities().IsValid() && !font_face->family().IsEmpty()) { - font_face->InitCSSFontFace(document, src); + font_face->InitCSSFontFace(document, *src); return font_face; } return nullptr; @@ -328,10 +327,10 @@ void FontFace::SetPropertyFromString(const ExecutionContext* context, SetError(DOMException::Create(kSyntaxError, message)); } -bool FontFace::SetPropertyFromStyle(const AtRuleDescriptorValueSet& properties, - AtRuleDescriptorID descriptor_id) { - return SetPropertyValue(properties.GetPropertyCSSValue(descriptor_id), - descriptor_id); +bool FontFace::SetPropertyFromStyle(const CSSPropertyValueSet& properties, + AtRuleDescriptorID property_id) { + return SetPropertyValue(properties.GetPropertyCSSValue(property_id), + property_id); } bool FontFace::SetPropertyValue(const CSSValue* value, @@ -703,22 +702,21 @@ bool ContextAllowsDownload(ExecutionContext* context) { return true; } -void FontFace::InitCSSFontFace(ExecutionContext* context, const CSSValue* src) { +void FontFace::InitCSSFontFace(ExecutionContext* context, const CSSValue& src) { css_font_face_ = CreateCSSFontFace(this, unicode_range_.Get()); if (error_) return; // Each item in the src property's list is a single CSSFontFaceSource. Put // them all into a CSSFontFace. - DCHECK(src); - DCHECK(src->IsValueList()); - const CSSValueList* src_list = ToCSSValueList(src); - int src_length = src_list->length(); + DCHECK(src.IsValueList()); + const CSSValueList& src_list = ToCSSValueList(src); + int src_length = src_list.length(); for (int i = 0; i < src_length; i++) { // An item in the list either specifies a string (local font name) or a URL // (remote font to download). - const CSSFontFaceSrcValue& item = ToCSSFontFaceSrcValue(src_list->Item(i)); + const CSSFontFaceSrcValue& item = ToCSSFontFaceSrcValue(src_list.Item(i)); if (!item.IsLocal()) { if (ContextAllowsDownload(context) && item.IsSupportedFormat()) { @@ -734,8 +732,8 @@ void FontFace::InitCSSFontFace(ExecutionContext* context, const CSSValue* src) { RemoteFontFaceSource* source = new RemoteFontFaceSource(css_font_face_, font_selector, CSSValueToFontDisplay(display_.Get())); - if (item.Fetch(context, source)) - css_font_face_->AddSource(source); + item.Fetch(context, source); + css_font_face_->AddSource(source); } } else { css_font_face_->AddSource(new LocalFontFaceSource(item.GetResource())); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.h index ca94ee2490..db4e443ff3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.h @@ -45,7 +45,6 @@ namespace blink { -class AtRuleDescriptorValueSet; class CSSFontFace; class CSSValue; class DOMArrayBuffer; @@ -54,6 +53,7 @@ class Document; class ExceptionState; class FontFaceDescriptors; class StringOrArrayBufferOrArrayBufferView; +class CSSPropertyValueSet; class StyleRuleFontFace; class CORE_EXPORT FontFace : public ScriptWrappable, @@ -145,14 +145,13 @@ class CORE_EXPORT FontFace : public ScriptWrappable, const AtomicString& family, const FontFaceDescriptors&); - void InitCSSFontFace(ExecutionContext*, const CSSValue* src); + void InitCSSFontFace(ExecutionContext*, const CSSValue& src); void InitCSSFontFace(const unsigned char* data, size_t); void SetPropertyFromString(const ExecutionContext*, const String&, AtRuleDescriptorID, ExceptionState* = nullptr); - bool SetPropertyFromStyle(const AtRuleDescriptorValueSet&, - AtRuleDescriptorID); + bool SetPropertyFromStyle(const CSSPropertyValueSet&, AtRuleDescriptorID); bool SetPropertyValue(const CSSValue*, AtRuleDescriptorID); bool SetFamilyValue(const CSSValue&); ScriptPromise FontStatusPromise(ScriptState*); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.idl index da6191803e..0078fab953 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFace.idl @@ -39,7 +39,7 @@ enum FontFaceLoadStatus { [ ActiveScriptWrappable, - Exposed(Window StableBlinkFeatures, Worker ExperimentalCanvasFeatures), + Exposed(Window StableBlinkFeatures, Worker OffscreenCanvasText), // FIXME: This should be (DOMString or BinaryData), where BinaryData is typedef of (ArrayBuffer or ArrayBufferView) Constructor(DOMString family, (DOMString or ArrayBuffer or ArrayBufferView) source, optional FontFaceDescriptors descriptors), ConstructorCallWith=ExecutionContext, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceCacheTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceCacheTest.cpp index 8e2105e7e1..f73dd1bdca 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceCacheTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceCacheTest.cpp @@ -12,8 +12,6 @@ #include "core/css/FontFace.h" #include "core/css/FontFaceCache.h" #include "core/css/StyleRule.h" -#include "core/css/parser/AtRuleDescriptorValueSet.h" -#include "core/dom/ExecutionContext.h" #include "core/testing/PageTestBase.h" #include "testing/gtest/include/gtest/gtest.h" @@ -66,18 +64,15 @@ void FontFaceCacheTest::AppendTestFaceForCapabilities(const CSSValue& stretch, kFontNameForTesting, kDoNotCheckContentSecurityPolicy); CSSValueList* src_value_list = CSSValueList::CreateCommaSeparated(); src_value_list->Append(*src); - - HeapVector properties; - properties.push_back( - CSSPropertyValue(GetCSSPropertyFontFamily(), *family_name)); - properties.push_back(CSSPropertyValue(GetCSSPropertySrc(), *src_value_list)); - AtRuleDescriptorValueSet* font_face_descriptor = - AtRuleDescriptorValueSet::Create(properties, kCSSFontFaceRuleMode, - AtRuleDescriptorValueSet::kFontFaceType); - - font_face_descriptor->SetProperty(AtRuleDescriptorID::FontStretch, stretch); - font_face_descriptor->SetProperty(AtRuleDescriptorID::FontStyle, style); - font_face_descriptor->SetProperty(AtRuleDescriptorID::FontWeight, weight); + CSSPropertyValue properties[] = { + CSSPropertyValue(GetCSSPropertyFontFamily(), *family_name), + CSSPropertyValue(GetCSSPropertySrc(), *src_value_list)}; + MutableCSSPropertyValueSet* font_face_descriptor = + MutableCSSPropertyValueSet::Create(properties, arraysize(properties)); + + font_face_descriptor->SetProperty(CSSPropertyFontStretch, stretch); + font_face_descriptor->SetProperty(CSSPropertyFontStyle, style); + font_face_descriptor->SetProperty(CSSPropertyFontWeight, weight); StyleRuleFontFace* style_rule_font_face = StyleRuleFontFace::Create(font_face_descriptor); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSet.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSet.idl index 39c439944a..f1f94a15eb 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSet.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSet.idl @@ -36,7 +36,7 @@ enum FontFaceSetLoadStatus { "loading", "loaded" }; // [NoInterfaceObject] [ NoInterfaceObject, - Exposed(Window StableBlinkFeatures, Worker ExperimentalCanvasFeatures) + Exposed(Window StableBlinkFeatures, Worker OffscreenCanvasText) ] interface FontFaceSet : EventTarget { setlike; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetDocument.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetDocument.cpp index 1632dae126..e5066c4c41 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetDocument.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetDocument.cpp @@ -43,6 +43,9 @@ namespace blink { +// static +const char FontFaceSetDocument::kSupplementName[] = "FontFaceSetDocument"; + FontFaceSetDocument::FontFaceSetDocument(Document& document) : FontFaceSet(document), Supplement(document) { PauseIfNeeded(); @@ -176,25 +179,25 @@ bool FontFaceSetDocument::ResolveFontStyle(const String& font_string, } FontFaceSetDocument* FontFaceSetDocument::From(Document& document) { - FontFaceSetDocument* fonts = static_cast( - Supplement::From(document, SupplementName())); + FontFaceSetDocument* fonts = + Supplement::From(document); if (!fonts) { fonts = FontFaceSetDocument::Create(document); - Supplement::ProvideTo(document, SupplementName(), fonts); + Supplement::ProvideTo(document, fonts); } return fonts; } void FontFaceSetDocument::DidLayout(Document& document) { - if (FontFaceSetDocument* fonts = static_cast( - Supplement::From(document, SupplementName()))) + if (FontFaceSetDocument* fonts = + Supplement::From(document)) fonts->DidLayout(); } size_t FontFaceSetDocument::ApproximateBlankCharacterCount(Document& document) { - if (FontFaceSetDocument* fonts = static_cast( - Supplement::From(document, SupplementName()))) + if (FontFaceSetDocument* fonts = + Supplement::From(document)) return fonts->ApproximateBlankCharacterCount(); return 0; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetDocument.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetDocument.h index 308ac03f73..9767219ba7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetDocument.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetDocument.h @@ -50,6 +50,8 @@ class CORE_EXPORT FontFaceSetDocument final : public FontFaceSet, USING_GARBAGE_COLLECTED_MIXIN(FontFaceSetDocument); public: + static const char kSupplementName[]; + ~FontFaceSetDocument() override; ScriptPromise ready(ScriptState*) override; @@ -71,8 +73,6 @@ class CORE_EXPORT FontFaceSetDocument final : public FontFaceSet, static void DidLayout(Document&); static size_t ApproximateBlankCharacterCount(Document&); - static const char* SupplementName() { return "FontFaceSetDocument"; } - virtual void Trace(blink::Visitor*); virtual void TraceWrappers(const ScriptWrappableVisitor*) const; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetWorker.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetWorker.cpp index 287f0492e0..e543bf6ac4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetWorker.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetWorker.cpp @@ -21,6 +21,9 @@ namespace blink { +// static +const char FontFaceSetWorker::kSupplementName[] = "FontFaceSetWorker"; + FontFaceSetWorker::FontFaceSetWorker(WorkerGlobalScope& worker) : FontFaceSet(worker), Supplement(worker) { PauseIfNeeded(); @@ -101,11 +104,11 @@ bool FontFaceSetWorker::ResolveFontStyle(const String& font_string, } FontFaceSetWorker* FontFaceSetWorker::From(WorkerGlobalScope& worker) { - FontFaceSetWorker* fonts = static_cast( - Supplement::From(worker, SupplementName())); + FontFaceSetWorker* fonts = + Supplement::From(worker); if (!fonts) { fonts = FontFaceSetWorker::Create(worker); - Supplement::ProvideTo(worker, SupplementName(), fonts); + ProvideTo(worker, fonts); } return fonts; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetWorker.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetWorker.h index 522a36a201..7a64650c5b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetWorker.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/FontFaceSetWorker.h @@ -27,6 +27,8 @@ class CORE_EXPORT FontFaceSetWorker final USING_GARBAGE_COLLECTED_MIXIN(FontFaceSetWorker); public: + static const char kSupplementName[]; + ~FontFaceSetWorker() override; ScriptPromise ready(ScriptState*) override; @@ -43,8 +45,6 @@ class CORE_EXPORT FontFaceSetWorker final static FontFaceSetWorker* From(WorkerGlobalScope&); - static const char* SupplementName() { return "FontFaceSetWorker"; } - void Trace(Visitor*) override; protected: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaList.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaList.idl index fb08328c0d..1c20b6aa0f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaList.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaList.idl @@ -29,8 +29,7 @@ [ Exposed=Window ] interface MediaList { - // TODO(foolip): [TreatNullAs=EmptyString] stringifier attribute DOMString mediaText; - attribute DOMString? mediaText; + stringifier attribute [TreatNullAs=EmptyString] DOMString mediaText; readonly attribute unsigned long length; [Measure] getter DOMString? item(unsigned long index); // TODO(foolip): appendMedium() and deleteMedium() should never throw. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp index 129d514a66..72d7b7b4dc 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp @@ -170,7 +170,7 @@ bool CompareValue(T a, T b, MediaFeaturePrefix op) { } bool CompareDoubleValue(double a, double b, MediaFeaturePrefix op) { - const double precision = std::numeric_limits::epsilon(); + const double precision = LayoutUnit::Epsilon(); switch (op) { case kMinPrefix: return a >= (b - precision); @@ -628,6 +628,26 @@ static bool Transform3dMediaFeatureEval(const MediaQueryExpValue& value, return return_value_if_no_parameter; } +static bool ImmersiveMediaFeatureEval(const MediaQueryExpValue& value, + MediaFeaturePrefix op, + const MediaValues& media_values) { + bool return_value_if_no_parameter; + int is_immersive_numeric_value; + + bool immersive = media_values.InImmersiveMode(); + + return_value_if_no_parameter = immersive; + is_immersive_numeric_value = immersive ? 1 : 0; + + if (value.IsValid()) { + float number; + return NumberValue(value, number) && + CompareValue(is_immersive_numeric_value, static_cast(number), + op); + } + return return_value_if_no_parameter; +} + static bool HoverMediaFeatureEval(const MediaQueryExpValue& value, MediaFeaturePrefix, const MediaValues& media_values) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp index 2ce15e86b7..f6952a47dd 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryEvaluatorTest.cpp @@ -8,7 +8,10 @@ #include "core/css/MediaList.h" #include "core/css/MediaValuesCached.h" #include "core/css/MediaValuesInitialViewport.h" +#include "core/css/parser/CSSTokenizer.h" +#include "core/css/parser/MediaQueryParser.h" #include "core/frame/LocalFrameView.h" +#include "core/frame/Settings.h" #include "core/media_type_names.h" #include "core/testing/DummyPageHolder.h" #include "platform/wtf/text/StringBuilder.h" @@ -87,19 +90,24 @@ MediaQueryEvaluatorTestCase g_viewport_test_cases[] = { {"(width: 501px)", 0}, {"(min-height: 500px)", 1}, {"(min-height: 501px)", 0}, - {"(min-height: 500.001px)", 0}, + {"(min-height: 500.02px)", 0}, {"(max-height: 500px)", 1}, - {"(max-height: 499.999px)", 0}, + {"(max-height: calc(500px))", 1}, + {"(max-height: 499.98px)", 0}, {"(max-height: 499px)", 0}, {"(height: 500px)", 1}, - {"(height: 500.001px)", 0}, - {"(height: 499.999px)", 0}, + {"(height: calc(500px))", 1}, + {"(height: 500.001px)", 1}, + {"(height: 499.999px)", 1}, + {"(height: 500.02px)", 0}, + {"(height: 499.98px)", 0}, {"(height: 501px)", 0}, {"(height)", 1}, {"(width)", 1}, {"(width: whatisthis)", 0}, {"screen and (min-width: 400px) and (max-width: 700px)", 1}, {"(max-aspect-ratio: 4294967296/1)", 1}, + {"(max-aspect-ratio: calc(4294967296) / calc(1)", 1}, {"(min-aspect-ratio: 1/4294967295)", 1}, {nullptr, 0} // Do not remove the terminator line. }; @@ -117,13 +125,13 @@ MediaQueryEvaluatorTestCase g_float_viewport_test_cases[] = { {"(min-height: 700px)", 1}, {"(min-height: 700.125px)", 1}, {"(min-height: 701px)", 0}, - {"(min-height: 700.126px)", 0}, + {"(min-height: 700.141px)", 0}, {"(max-height: 701px)", 1}, {"(max-height: 700.125px)", 1}, {"(max-height: 700px)", 0}, {"(height: 700.125px)", 1}, - {"(height: 700.126px)", 0}, - {"(height: 700.124px)", 0}, + {"(height: 700.141px)", 0}, + {"(height: 700.109px)", 0}, {"(height: 701px)", 0}, {nullptr, 0} // Do not remove the terminator line. }; @@ -147,16 +155,47 @@ MediaQueryEvaluatorTestCase g_print_test_cases[] = { {nullptr, 0} // Do not remove the terminator line. }; +MediaQueryEvaluatorTestCase g_non_immersive_test_cases[] = { + {"(immersive: 1)", 0}, + {"(immersive: 0)", 1}, + {nullptr, 0} // Do not remove the terminator line. +}; + +MediaQueryEvaluatorTestCase g_immersive_test_cases[] = { + {"(immersive: 1)", 1}, + {"(immersive: 0)", 0}, + {nullptr, 0} // Do not remove the terminator line. +}; + +MediaQueryEvaluatorTestCase g_non_ua_sheet_immersive_test_cases[] = { + {"(immersive: 1)", 0}, + {"(immersive: 0)", 0}, + {nullptr, 0} // Do not remove the terminator line. +}; + void TestMQEvaluator(MediaQueryEvaluatorTestCase* test_cases, - const MediaQueryEvaluator& media_query_evaluator) { + const MediaQueryEvaluator& media_query_evaluator, + CSSParserMode mode) { scoped_refptr query_set = nullptr; for (unsigned i = 0; test_cases[i].input; ++i) { - query_set = MediaQuerySet::Create(test_cases[i].input); + if (String(test_cases[i].input).IsEmpty()) { + query_set = MediaQuerySet::Create(); + } else { + query_set = MediaQueryParser::ParseMediaQuerySetInMode( + CSSParserTokenRange( + CSSTokenizer(test_cases[i].input).TokenizeToEOF()), + mode); + } EXPECT_EQ(test_cases[i].output, media_query_evaluator.Eval(*query_set)) << "Query: " << test_cases[i].input; } } +void TestMQEvaluator(MediaQueryEvaluatorTestCase* test_cases, + const MediaQueryEvaluator& media_query_evaluator) { + TestMQEvaluator(test_cases, media_query_evaluator, kHTMLStandardMode); +} + TEST(MediaQueryEvaluatorTest, Cached) { MediaValuesCached::MediaValuesCachedData data; data.viewport_width = 500; @@ -174,6 +213,7 @@ TEST(MediaQueryEvaluatorTest, Cached) { data.strict_mode = true; data.display_mode = kWebDisplayModeBrowser; data.display_shape = kDisplayShapeRect; + data.immersive_mode = false; // Default values. { @@ -181,6 +221,9 @@ TEST(MediaQueryEvaluatorTest, Cached) { MediaQueryEvaluator media_query_evaluator(*media_values); TestMQEvaluator(g_screen_test_cases, media_query_evaluator); TestMQEvaluator(g_viewport_test_cases, media_query_evaluator); + TestMQEvaluator(g_non_immersive_test_cases, media_query_evaluator, + kUASheetMode); + TestMQEvaluator(g_non_ua_sheet_immersive_test_cases, media_query_evaluator); } // Print values. @@ -202,6 +245,17 @@ TEST(MediaQueryEvaluatorTest, Cached) { data.color_bits_per_component = 24; data.monochrome_bits_per_component = 0; } + + // Immersive values. + { + data.immersive_mode = true; + MediaValues* media_values = MediaValuesCached::Create(data); + MediaQueryEvaluator media_query_evaluator(*media_values); + TestMQEvaluator(g_immersive_test_cases, media_query_evaluator, + kUASheetMode); + TestMQEvaluator(g_non_ua_sheet_immersive_test_cases, media_query_evaluator); + data.immersive_mode = false; + } } TEST(MediaQueryEvaluatorTest, Dynamic) { @@ -261,4 +315,18 @@ TEST(MediaQueryEvaluatorTest, InitialViewport) { TestMQEvaluator(g_viewport_test_cases, media_query_evaluator); } +TEST(MediaQueryEvaluatorTest, DynamicImmersive) { + std::unique_ptr page_holder = + DummyPageHolder::Create(IntSize(500, 500)); + page_holder->GetFrameView().SetMediaType(MediaTypeNames::screen); + + MediaQueryEvaluator media_query_evaluator(&page_holder->GetFrame()); + page_holder->GetDocument().GetSettings()->SetImmersiveModeEnabled(false); + + TestMQEvaluator(g_non_immersive_test_cases, media_query_evaluator, + kUASheetMode); + page_holder->GetDocument().GetSettings()->SetImmersiveModeEnabled(true); + TestMQEvaluator(g_immersive_test_cases, media_query_evaluator, kUASheetMode); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryExp.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryExp.cpp index d899349033..ffb00dbc8e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryExp.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryExp.cpp @@ -29,7 +29,8 @@ #include "core/css/MediaQueryExp.h" -#include "core/css/parser/CSSParserToken.h" +#include "core/css/parser/CSSParserTokenRange.h" +#include "core/css/parser/CSSPropertyParserHelpers.h" #include "core/html/parser/HTMLParserIdioms.h" #include "platform/Decimal.h" #include "platform/runtime_enabled_features.h" @@ -74,11 +75,11 @@ static inline bool FeatureWithValidIdent(const String& media_feature, return false; } -static inline bool FeatureWithValidPositiveLength(const String& media_feature, - const CSSParserToken& token) { - if (!(CSSPrimitiveValue::IsLength(token.GetUnitType()) || - (token.GetType() == kNumberToken && token.NumericValue() == 0)) || - token.NumericValue() < 0) +static inline bool FeatureWithValidPositiveLength( + const String& media_feature, + const CSSPrimitiveValue* value) { + if (!(value->IsLength() || + (value->IsNumber() && value->GetDoubleValue() == 0))) return false; return media_feature == heightMediaFeature || @@ -96,12 +97,14 @@ static inline bool FeatureWithValidPositiveLength(const String& media_feature, } static inline bool FeatureWithValidDensity(const String& media_feature, - const CSSParserToken& token) { - if ((token.GetUnitType() != CSSPrimitiveValue::UnitType::kDotsPerPixel && - token.GetUnitType() != CSSPrimitiveValue::UnitType::kDotsPerInch && - token.GetUnitType() != + const CSSPrimitiveValue* value) { + if ((value->TypeWithCalcResolved() != + CSSPrimitiveValue::UnitType::kDotsPerPixel && + value->TypeWithCalcResolved() != + CSSPrimitiveValue::UnitType::kDotsPerInch && + value->TypeWithCalcResolved() != CSSPrimitiveValue::UnitType::kDotsPerCentimeter) || - token.NumericValue() <= 0) + value->GetDoubleValue() <= 0) return false; return media_feature == resolutionMediaFeature || @@ -109,12 +112,8 @@ static inline bool FeatureWithValidDensity(const String& media_feature, media_feature == maxResolutionMediaFeature; } -static inline bool FeatureWithPositiveInteger(const String& media_feature, - const CSSParserToken& token) { - if (token.GetNumericValueType() != kIntegerValueType || - token.NumericValue() < 0) - return false; - +static inline bool FeatureExpectingPositiveInteger( + const String& media_feature) { return media_feature == colorMediaFeature || media_feature == maxColorMediaFeature || media_feature == minColorMediaFeature || @@ -123,12 +122,20 @@ static inline bool FeatureWithPositiveInteger(const String& media_feature, media_feature == minColorIndexMediaFeature || media_feature == monochromeMediaFeature || media_feature == maxMonochromeMediaFeature || - media_feature == minMonochromeMediaFeature; + media_feature == minMonochromeMediaFeature || + media_feature == immersiveMediaFeature; +} + +static inline bool FeatureWithPositiveInteger(const String& media_feature, + const CSSPrimitiveValue* value) { + if (value->TypeWithCalcResolved() != CSSPrimitiveValue::UnitType::kInteger) + return false; + return FeatureExpectingPositiveInteger(media_feature); } static inline bool FeatureWithPositiveNumber(const String& media_feature, - const CSSParserToken& token) { - if (token.GetType() != kNumberToken || token.NumericValue() < 0) + const CSSPrimitiveValue* value) { + if (!value->IsNumber()) return false; return media_feature == transform3dMediaFeature || @@ -138,9 +145,9 @@ static inline bool FeatureWithPositiveNumber(const String& media_feature, } static inline bool FeatureWithZeroOrOne(const String& media_feature, - const CSSParserToken& token) { - if (token.GetNumericValueType() != kIntegerValueType || - !(token.NumericValue() == 1 || !token.NumericValue())) + const CSSPrimitiveValue* value) { + if (value->TypeWithCalcResolved() != CSSPrimitiveValue::UnitType::kInteger || + !(value->GetDoubleValue() == 1 || !value->GetDoubleValue())) return false; return media_feature == gridMediaFeature; @@ -178,7 +185,8 @@ static inline bool FeatureWithoutValue(const String& media_feature) { media_feature == displayModeMediaFeature || media_feature == scanMediaFeature || media_feature == shapeMediaFeature || - media_feature == colorGamutMediaFeature; + media_feature == colorGamutMediaFeature || + media_feature == immersiveMediaFeature; } bool MediaQueryExp::IsViewportDependent() const { @@ -218,75 +226,63 @@ MediaQueryExp::MediaQueryExp(const String& media_feature, const MediaQueryExpValue& exp_value) : media_feature_(media_feature), exp_value_(exp_value) {} -MediaQueryExp MediaQueryExp::Create( - const String& media_feature, - const Vector& token_list) { +MediaQueryExp MediaQueryExp::Create(const String& media_feature, + CSSParserTokenRange& range) { DCHECK(!media_feature.IsNull()); MediaQueryExpValue exp_value; String lower_media_feature = AttemptStaticStringCreation(media_feature.LowerASCII()); + CSSPrimitiveValue* value = CSSPropertyParserHelpers::ConsumeInteger(range, 0); + if (!value && !FeatureExpectingPositiveInteger(lower_media_feature) && + !FeatureWithAspectRatio(lower_media_feature)) + value = + CSSPropertyParserHelpers::ConsumeNumber(range, kValueRangeNonNegative); + if (!value) + value = CSSPropertyParserHelpers::ConsumeLength(range, kHTMLStandardMode, + kValueRangeNonNegative); + if (!value) + value = CSSPropertyParserHelpers::ConsumeResolution(range); // Create value for media query expression that must have 1 or more values. - if (token_list.size() == 0 && FeatureWithoutValue(lower_media_feature)) { - // Valid, creates a MediaQueryExp with an 'invalid' MediaQueryExpValue - } else if (token_list.size() == 1) { - CSSParserToken token = token_list.front(); - - if (token.GetType() == kIdentToken) { - CSSValueID ident = token.Id(); - if (!FeatureWithValidIdent(lower_media_feature, ident)) + if (value) { + if (FeatureWithAspectRatio(lower_media_feature)) { + if (value->TypeWithCalcResolved() != + CSSPrimitiveValue::UnitType::kInteger || + value->GetDoubleValue() == 0) return Invalid(); - exp_value.id = ident; - exp_value.is_id = true; - } else if (token.GetType() == kNumberToken || - token.GetType() == kPercentageToken || - token.GetType() == kDimensionToken) { - // Check for numeric token types since it is only safe for these types to - // call numericValue. - if (FeatureWithValidDensity(lower_media_feature, token) || - FeatureWithValidPositiveLength(lower_media_feature, token)) { - // Media features that must have non-negative , ie. dppx, dpi - // or dpcm, or Media features that must have non-negative or - // number value. - exp_value.value = token.NumericValue(); - exp_value.unit = token.GetUnitType(); - exp_value.is_value = true; - } else if (FeatureWithPositiveInteger(lower_media_feature, token) || - FeatureWithPositiveNumber(lower_media_feature, token) || - FeatureWithZeroOrOne(lower_media_feature, token)) { - // Media features that must have non-negative integer value, - // or media features that must have non-negative number value, - // or media features that must have (0|1) value. - exp_value.value = token.NumericValue(); - exp_value.unit = CSSPrimitiveValue::UnitType::kNumber; - exp_value.is_value = true; - } else { + if (!CSSPropertyParserHelpers::ConsumeSlashIncludingWhitespace(range)) + return Invalid(); + CSSPrimitiveValue* denominator = + CSSPropertyParserHelpers::ConsumePositiveInteger(range); + if (!denominator) return Invalid(); - } + + exp_value.numerator = clampTo(value->GetDoubleValue()); + exp_value.denominator = clampTo(denominator->GetDoubleValue()); + exp_value.is_ratio = true; + } else if (FeatureWithValidDensity(lower_media_feature, value) || + FeatureWithValidPositiveLength(lower_media_feature, value) || + FeatureWithPositiveInteger(lower_media_feature, value) || + FeatureWithPositiveNumber(lower_media_feature, value) || + FeatureWithZeroOrOne(lower_media_feature, value)) { + exp_value.value = value->GetDoubleValue(); + if (value->IsNumber()) + exp_value.unit = CSSPrimitiveValue::UnitType::kNumber; + else + exp_value.unit = value->TypeWithCalcResolved(); + exp_value.is_value = true; } else { return Invalid(); } - } else if (token_list.size() == 3 && - FeatureWithAspectRatio(lower_media_feature)) { - // TODO(timloh): is supposed to allow whitespace around the '/' - // Applicable to device-aspect-ratio and aspect-ratio. - const CSSParserToken& numerator = token_list[0]; - const CSSParserToken& delimiter = token_list[1]; - const CSSParserToken& denominator = token_list[2]; - if (delimiter.GetType() != kDelimiterToken || delimiter.Delimiter() != '/') + } else if (CSSIdentifierValue* ident = CSSPropertyParserHelpers::ConsumeIdent(range)) { + CSSValueID ident_id = ident->GetValueID(); + if (!FeatureWithValidIdent(lower_media_feature, ident_id)) return Invalid(); - if (numerator.GetType() != kNumberToken || numerator.NumericValue() <= 0 || - numerator.GetNumericValueType() != kIntegerValueType) - return Invalid(); - if (denominator.GetType() != kNumberToken || - denominator.NumericValue() <= 0 || - denominator.GetNumericValueType() != kIntegerValueType) - return Invalid(); - - exp_value.numerator = clampTo(numerator.NumericValue()); - exp_value.denominator = clampTo(denominator.NumericValue()); - exp_value.is_ratio = true; + exp_value.id = ident_id; + exp_value.is_id = true; + } else if (FeatureWithoutValue(lower_media_feature)) { + // Valid, creates a MediaQueryExp with an 'invalid' MediaQueryExpValue } else { return Invalid(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryExp.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryExp.h index 132fa327a5..4a8e54dae7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryExp.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaQueryExp.h @@ -38,7 +38,7 @@ namespace blink { -class CSSParserToken; +class CSSParserTokenRange; struct MediaQueryExpValue { DISALLOW_NEW(); @@ -82,7 +82,7 @@ class CORE_EXPORT MediaQueryExp { public: // Returns an invalid MediaQueryExp if the arguments are invalid. static MediaQueryExp Create(const String& media_feature, - const Vector&); + CSSParserTokenRange&); static MediaQueryExp Invalid() { return MediaQueryExp(String(), MediaQueryExpValue()); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValues.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValues.cpp index 884411433a..64c3b35dc4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValues.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValues.cpp @@ -133,6 +133,12 @@ bool MediaValues::CalculateThreeDEnabled(LocalFrame* frame) { return three_d_enabled; } +bool MediaValues::CalculateInImmersiveMode(LocalFrame* frame) { + DCHECK(frame); + DCHECK(frame->GetSettings()); + return frame->GetSettings()->GetImmersiveModeEnabled(); +} + PointerType MediaValues::CalculatePrimaryPointerType(LocalFrame* frame) { DCHECK(frame); DCHECK(frame->GetSettings()); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValues.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValues.h index 3ecdacec18..0e2ac9f805 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValues.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValues.h @@ -66,6 +66,7 @@ class CORE_EXPORT MediaValues : public GarbageCollectedFinalized { virtual HoverType PrimaryHoverType() const = 0; virtual int AvailableHoverTypes() const = 0; virtual bool ThreeDEnabled() const = 0; + virtual bool InImmersiveMode() const = 0; virtual const String MediaType() const = 0; virtual WebDisplayMode DisplayMode() const = 0; virtual bool StrictMode() const = 0; @@ -89,6 +90,7 @@ class CORE_EXPORT MediaValues : public GarbageCollectedFinalized { static const String CalculateMediaType(LocalFrame*); static WebDisplayMode CalculateDisplayMode(LocalFrame*); static bool CalculateThreeDEnabled(LocalFrame*); + static bool CalculateInImmersiveMode(LocalFrame*); static PointerType CalculatePrimaryPointerType(LocalFrame*); static int CalculateAvailablePointerTypes(LocalFrame*); static HoverType CalculatePrimaryHoverType(LocalFrame*); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesCached.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesCached.cpp index 2ffa7dad00..76d6807b6f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesCached.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesCached.cpp @@ -26,6 +26,7 @@ MediaValuesCached::MediaValuesCachedData::MediaValuesCachedData() available_hover_types(kHoverTypeNone), default_font_size(16), three_d_enabled(false), + immersive_mode(false), strict_mode(true), display_mode(kWebDisplayModeBrowser), display_shape(kDisplayShapeRect), @@ -62,6 +63,7 @@ MediaValuesCached::MediaValuesCachedData::MediaValuesCachedData( available_hover_types = MediaValues::CalculateAvailableHoverTypes(frame); default_font_size = MediaValues::CalculateDefaultFontSize(frame); three_d_enabled = MediaValues::CalculateThreeDEnabled(frame); + immersive_mode = MediaValues::CalculateInImmersiveMode(frame); strict_mode = MediaValues::CalculateStrictMode(frame); display_mode = MediaValues::CalculateDisplayMode(frame); media_type = MediaValues::CalculateMediaType(frame); @@ -152,6 +154,10 @@ bool MediaValuesCached::ThreeDEnabled() const { return data_.three_d_enabled; } +bool MediaValuesCached::InImmersiveMode() const { + return data_.immersive_mode; +} + bool MediaValuesCached::StrictMode() const { return data_.strict_mode; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesCached.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesCached.h index 7f6080a081..042443df2d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesCached.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesCached.h @@ -30,6 +30,7 @@ class CORE_EXPORT MediaValuesCached final : public MediaValues { int available_hover_types; int default_font_size; bool three_d_enabled; + bool immersive_mode; bool strict_mode; String media_type; WebDisplayMode display_mode; @@ -54,6 +55,7 @@ class CORE_EXPORT MediaValuesCached final : public MediaValues { data.available_hover_types = available_hover_types; data.default_font_size = default_font_size; data.three_d_enabled = three_d_enabled; + data.immersive_mode = immersive_mode; data.strict_mode = strict_mode; data.media_type = media_type.IsolatedCopy(); data.display_mode = display_mode; @@ -85,6 +87,7 @@ class CORE_EXPORT MediaValuesCached final : public MediaValues { HoverType PrimaryHoverType() const override; int AvailableHoverTypes() const override; bool ThreeDEnabled() const override; + bool InImmersiveMode() const override; bool StrictMode() const override; Document* GetDocument() const override; bool HasValues() const override; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesDynamic.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesDynamic.cpp index 0a5d1d09e0..5abcaa0e68 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesDynamic.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesDynamic.cpp @@ -117,6 +117,10 @@ bool MediaValuesDynamic::ThreeDEnabled() const { return CalculateThreeDEnabled(frame_); } +bool MediaValuesDynamic::InImmersiveMode() const { + return CalculateInImmersiveMode(frame_); +} + const String MediaValuesDynamic::MediaType() const { return CalculateMediaType(frame_); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesDynamic.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesDynamic.h index 7b62e5e7a8..0f1f825346 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesDynamic.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesDynamic.h @@ -35,6 +35,7 @@ class CORE_EXPORT MediaValuesDynamic : public MediaValues { HoverType PrimaryHoverType() const override; int AvailableHoverTypes() const override; bool ThreeDEnabled() const override; + bool InImmersiveMode() const override; bool StrictMode() const override; const String MediaType() const override; WebDisplayMode DisplayMode() const override; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesInitialViewportTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesInitialViewportTest.cpp index bfbd41a935..ddf40ac720 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesInitialViewportTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/MediaValuesInitialViewportTest.cpp @@ -5,22 +5,17 @@ #include "core/css/MediaValuesInitialViewport.h" #include "core/frame/LocalFrameView.h" -#include "core/testing/DummyPageHolder.h" +#include "core/testing/PageTestBase.h" #include "testing/gtest/include/gtest/gtest.h" namespace blink { -class MediaValuesInitialViewportTest : public ::testing::Test { - protected: - Document& GetDocument() const { return dummy_page_holder_->GetDocument(); } - +class MediaValuesInitialViewportTest : public PageTestBase { private: void SetUp() override { - dummy_page_holder_ = DummyPageHolder::Create(IntSize(320, 480)); + PageTestBase::SetUp(IntSize(320, 480)); GetDocument().View()->SetInitialViewportSize(IntSize(320, 480)); } - - std::unique_ptr dummy_page_holder_; }; TEST_F(MediaValuesInitialViewportTest, InitialViewportSize) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/OWNERS b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/OWNERS index 3a690462c0..ebb863967b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/OWNERS +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/OWNERS @@ -1,11 +1,8 @@ -bugsnash@chromium.org ericwilligers@chromium.org -nainar@chromium.org shend@chromium.org -rjwright@chromium.org # Also core owners alancutter@chromium.org -meade@chromium.org +nainar@chromium.org # COMPONENT: Blink>CSS diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp index 312b77134e..4141522b61 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RemoteFontFaceSource.cpp @@ -9,6 +9,7 @@ #include "core/dom/Document.h" #include "core/frame/LocalFrameClient.h" #include "core/inspector/ConsoleMessage.h" +#include "core/probe/CoreProbes.h" #include "core/workers/WorkerGlobalScope.h" #include "platform/Histogram.h" #include "platform/fonts/FontCache.h" @@ -35,7 +36,7 @@ RemoteFontFaceSource::DisplayPeriod ComputePeriod( case kFontDisplayAuto: if (is_intervention_triggered) return RemoteFontFaceSource::kSwapPeriod; - // Fall through. + FALLTHROUGH; case kFontDisplayBlock: switch (phase) { case RemoteFontFaceSource::kNoLimitExceeded: @@ -132,8 +133,17 @@ void RemoteFontFaceSource::NotifyFinished(Resource* resource) { ClearResource(); PruneTable(); - if (face_->FontLoaded(this)) + if (face_->FontLoaded(this)) { font_selector_->FontFaceInvalidated(); + + const scoped_refptr customFontData = + font->GetCustomFontData(); + if (customFontData) { + probe::fontsUpdated(font_selector_->GetExecutionContext(), + face_->GetFontFace(), resource->Url().GetString(), + customFontData.get()); + } + } } void RemoteFontFaceSource::FontLoadShortLimitExceeded(FontResource*) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleFeatureSet.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleFeatureSet.cpp index 162cbab66b..23877803da 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleFeatureSet.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleFeatureSet.cpp @@ -91,7 +91,6 @@ bool SupportsInvalidation(CSSSelector::PseudoType type) { case CSSSelector::kPseudoLink: case CSSSelector::kPseudoVisited: case CSSSelector::kPseudoAny: - case CSSSelector::kPseudoMatches: case CSSSelector::kPseudoWebkitAnyLink: case CSSSelector::kPseudoAnyLink: case CSSSelector::kPseudoAutofill: @@ -163,6 +162,7 @@ bool SupportsInvalidation(CSSSelector::PseudoType type) { case CSSSelector::kPseudoVideoPersistent: case CSSSelector::kPseudoVideoPersistentAncestor: return true; + case CSSSelector::kPseudoMatches: case CSSSelector::kPseudoUnknown: case CSSSelector::kPseudoLeftPage: case CSSSelector::kPseudoRightPage: @@ -183,8 +183,6 @@ bool SupportsInvalidationWithSelectorList(CSSSelector::PseudoType pseudo) { pseudo == CSSSelector::kPseudoCue || pseudo == CSSSelector::kPseudoHost || pseudo == CSSSelector::kPseudoHostContext || - ((pseudo == CSSSelector::kPseudoMatches) && - RuntimeEnabledFeatures::CSSMatchesEnabled()) || pseudo == CSSSelector::kPseudoNot || pseudo == CSSSelector::kPseudoSlotted; } @@ -881,7 +879,7 @@ RuleFeatureSet::SelectorPreMatch RuleFeatureSet::CollectFeaturesFromSelector( return kSelectorNeverMatches; } found_host_pseudo = true; - // fall through. + FALLTHROUGH; default: if (const CSSSelectorList* selector_list = current->SelectorList()) { for (const CSSSelector* sub_selector = selector_list->First(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp index 1c0511aef2..479f1452ca 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleFeatureSetTest.cpp @@ -38,11 +38,24 @@ class RuleFeatureSetTest : public ::testing::Test { StrictCSSParserContext(SecureContextMode::kInsecureContext), nullptr, selector_text); + std::vector indices; + for (const CSSSelector* s = selector_list.First(); s; + s = selector_list.Next(*s)) { + indices.push_back(selector_list.SelectorIndex(*s)); + } + StyleRule* style_rule = StyleRule::Create( std::move(selector_list), MutableCSSPropertyValueSet::Create(kHTMLStandardMode)); - RuleData rule_data(style_rule, 0, 0, kRuleHasNoSpecialState); - return rule_feature_set_.CollectFeaturesFromRuleData(rule_data); + + RuleFeatureSet::SelectorPreMatch result = + RuleFeatureSet::SelectorPreMatch::kSelectorNeverMatches; + for (unsigned i = 0; i < indices.size(); ++i) { + RuleData rule_data(style_rule, indices[i], 0, kRuleHasNoSpecialState); + if (rule_feature_set_.CollectFeaturesFromRuleData(rule_data)) + result = RuleFeatureSet::SelectorPreMatch::kSelectorMayMatch; + } + return result; } void ClearFeatures() { rule_feature_set_.Clear(); } @@ -148,6 +161,28 @@ class RuleFeatureSetTest : public ::testing::Test { EXPECT_TRUE(classes.Contains(class_name)); } + void ExpectClassInvalidation(const AtomicString& first_class_name, + const AtomicString& second_class_name, + InvalidationSetVector& invalidation_sets) { + EXPECT_EQ(1u, invalidation_sets.size()); + HashSet classes = ClassSet(*invalidation_sets[0]); + EXPECT_EQ(2u, classes.size()); + EXPECT_TRUE(classes.Contains(first_class_name)); + EXPECT_TRUE(classes.Contains(second_class_name)); + } + + void ExpectClassInvalidation(const AtomicString& first_class_name, + const AtomicString& second_class_name, + const AtomicString& third_class_name, + InvalidationSetVector& invalidation_sets) { + EXPECT_EQ(1u, invalidation_sets.size()); + HashSet classes = ClassSet(*invalidation_sets[0]); + EXPECT_EQ(3u, classes.size()); + EXPECT_TRUE(classes.Contains(first_class_name)); + EXPECT_TRUE(classes.Contains(second_class_name)); + EXPECT_TRUE(classes.Contains(third_class_name)); + } + void ExpectSiblingClassInvalidation( unsigned max_direct_adjacent_selectors, const AtomicString& sibling_name, @@ -195,16 +230,6 @@ class RuleFeatureSetTest : public ::testing::Test { EXPECT_TRUE(descendant_classes.Contains(descendant_name)); } - void ExpectClassesInvalidation(const AtomicString& first_class_name, - const AtomicString& second_class_name, - InvalidationSetVector& invalidation_sets) { - EXPECT_EQ(1u, invalidation_sets.size()); - HashSet classes = ClassSet(*invalidation_sets[0]); - EXPECT_EQ(2u, classes.size()); - EXPECT_TRUE(classes.Contains(first_class_name)); - EXPECT_TRUE(classes.Contains(second_class_name)); - } - void ExpectIdInvalidation(const AtomicString& id, InvalidationSetVector& invalidation_sets) { EXPECT_EQ(1u, invalidation_sets.size()); @@ -213,9 +238,9 @@ class RuleFeatureSetTest : public ::testing::Test { EXPECT_TRUE(ids.Contains(id)); } - void ExpectIdsInvalidation(const AtomicString& first_id, - const AtomicString& second_id, - InvalidationSetVector& invalidation_sets) { + void ExpectIdInvalidation(const AtomicString& first_id, + const AtomicString& second_id, + InvalidationSetVector& invalidation_sets) { EXPECT_EQ(1u, invalidation_sets.size()); HashSet ids = IdSet(*invalidation_sets[0]); EXPECT_EQ(2u, ids.size()); @@ -231,9 +256,9 @@ class RuleFeatureSetTest : public ::testing::Test { EXPECT_TRUE(tag_names.Contains(tag_name)); } - void ExpectTagNamesInvalidation(const AtomicString& first_tag_name, - const AtomicString& second_tag_name, - InvalidationSetVector& invalidation_sets) { + void ExpectTagNameInvalidation(const AtomicString& first_tag_name, + const AtomicString& second_tag_name, + InvalidationSetVector& invalidation_sets) { EXPECT_EQ(1u, invalidation_sets.size()); HashSet tag_names = TagNameSet(*invalidation_sets[0]); EXPECT_EQ(2u, tag_names.size()); @@ -346,7 +371,7 @@ TEST_F(RuleFeatureSetTest, anyIdDescendant) { InvalidationLists invalidation_lists; CollectInvalidationSetsForClass(invalidation_lists, "a"); - ExpectIdsInvalidation("b", "c", invalidation_lists.descendants); + ExpectIdInvalidation("b", "c", invalidation_lists.descendants); } TEST_F(RuleFeatureSetTest, anyTagDescendant) { @@ -355,7 +380,7 @@ TEST_F(RuleFeatureSetTest, anyTagDescendant) { InvalidationLists invalidation_lists; CollectInvalidationSetsForClass(invalidation_lists, "a"); - ExpectTagNamesInvalidation("span", "div", invalidation_lists.descendants); + ExpectTagNameInvalidation("span", "div", invalidation_lists.descendants); } TEST_F(RuleFeatureSetTest, siblingAny) { @@ -365,7 +390,7 @@ TEST_F(RuleFeatureSetTest, siblingAny) { InvalidationLists invalidation_lists; CollectInvalidationSetsForClass(invalidation_lists, "v"); ExpectNoInvalidation(invalidation_lists.descendants); - ExpectClassesInvalidation("w", "x", invalidation_lists.siblings); + ExpectClassInvalidation("w", "x", invalidation_lists.siblings); } TEST_F(RuleFeatureSetTest, descendantSiblingAny) { @@ -374,7 +399,7 @@ TEST_F(RuleFeatureSetTest, descendantSiblingAny) { InvalidationLists invalidation_lists; CollectInvalidationSetsForClass(invalidation_lists, "u"); - ExpectClassesInvalidation("w", "x", invalidation_lists.descendants); + ExpectClassInvalidation("w", "x", invalidation_lists.descendants); ExpectNoInvalidation(invalidation_lists.siblings); } @@ -426,7 +451,7 @@ TEST_F(RuleFeatureSetTest, contentPseudo) { invalidation_lists.descendants.clear(); CollectInvalidationSetsForClass(invalidation_lists, "a"); - ExpectClassesInvalidation("b", "c", invalidation_lists.descendants); + ExpectClassInvalidation("b", "c", invalidation_lists.descendants); } TEST_F(RuleFeatureSetTest, nonMatchingHost) { @@ -951,4 +976,118 @@ TEST_F(RuleFeatureSetTest, ReplaceSelfInvalidationSet) { ExpectNotSelfInvalidationSet(invalidation_lists.descendants); } +TEST_F(RuleFeatureSetTest, pseudoMatchesSibling) { + EXPECT_EQ(RuleFeatureSet::kSelectorMayMatch, + CollectFeatures(":matches(.q, .r) ~ .s .t")); + { + InvalidationLists invalidation_lists; + CollectInvalidationSetsForClass(invalidation_lists, "q"); + ExpectNoInvalidation(invalidation_lists.descendants); + ExpectSiblingDescendantInvalidation(UINT_MAX, "s", "t", + invalidation_lists.siblings); + } + { + InvalidationLists invalidation_lists; + CollectInvalidationSetsForClass(invalidation_lists, "r"); + ExpectNoInvalidation(invalidation_lists.descendants); + ExpectSiblingDescendantInvalidation(UINT_MAX, "s", "t", + invalidation_lists.siblings); + } +} + +TEST_F(RuleFeatureSetTest, pseudoMatches) { + EXPECT_EQ(RuleFeatureSet::kSelectorMayMatch, + CollectFeatures(":matches(.w, .x)")); + + { + InvalidationLists invalidation_lists; + CollectInvalidationSetsForClass(invalidation_lists, "w"); + ExpectSelfInvalidation(invalidation_lists.descendants); + ExpectNoInvalidation(invalidation_lists.siblings); + } + { + InvalidationLists invalidation_lists; + CollectInvalidationSetsForClass(invalidation_lists, "x"); + ExpectSelfInvalidation(invalidation_lists.descendants); + ExpectNoInvalidation(invalidation_lists.siblings); + } +} + +TEST_F(RuleFeatureSetTest, pseudoMatchesIdDescendant) { + EXPECT_EQ(RuleFeatureSet::kSelectorMayMatch, + CollectFeatures(".a :matches(#b, #c)")); + + InvalidationLists invalidation_lists; + CollectInvalidationSetsForClass(invalidation_lists, "a"); + ExpectIdInvalidation("b", "c", invalidation_lists.descendants); +} + +TEST_F(RuleFeatureSetTest, pseudoMatchesTagDescendant) { + EXPECT_EQ(RuleFeatureSet::kSelectorMayMatch, + CollectFeatures(".a :matches(span, div)")); + + InvalidationLists invalidation_lists; + CollectInvalidationSetsForClass(invalidation_lists, "a"); + ExpectTagNameInvalidation("span", "div", invalidation_lists.descendants); +} + +TEST_F(RuleFeatureSetTest, pseudoMatchesAnySibling) { + EXPECT_EQ(RuleFeatureSet::kSelectorMayMatch, + CollectFeatures(".v ~ :matches(.w, .x)")); + + InvalidationLists invalidation_lists; + CollectInvalidationSetsForClass(invalidation_lists, "v"); + ExpectNoInvalidation(invalidation_lists.descendants); + ExpectClassInvalidation("w", "x", invalidation_lists.siblings); +} + +TEST_F(RuleFeatureSetTest, pseudoMatchesDescendantSibling) { + EXPECT_EQ(RuleFeatureSet::kSelectorMayMatch, + CollectFeatures(".u .v ~ :matches(.w, .x)")); + + InvalidationLists invalidation_lists; + CollectInvalidationSetsForClass(invalidation_lists, "u"); + ExpectClassInvalidation("w", "x", invalidation_lists.descendants); + ExpectNoInvalidation(invalidation_lists.siblings); +} + +TEST_F(RuleFeatureSetTest, pseudoMatchesWithComplexSelectors) { + EXPECT_EQ(RuleFeatureSet::kSelectorMayMatch, + CollectFeatures(".a :matches(.w+.b, .x>#c)")); + + InvalidationLists invalidation_lists; + CollectInvalidationSetsForClass(invalidation_lists, "a"); + ExpectClassInvalidation("b", invalidation_lists.descendants); + ExpectIdInvalidation("c", invalidation_lists.descendants); + ExpectNoInvalidation(invalidation_lists.siblings); +} + +TEST_F(RuleFeatureSetTest, pseudoMatchesNested) { + EXPECT_EQ(RuleFeatureSet::kSelectorMayMatch, + CollectFeatures(".a :matches(.w+.b, .e+:matches(.c, #d))")); + + InvalidationLists invalidation_lists; + CollectInvalidationSetsForClass(invalidation_lists, "a"); + ExpectClassInvalidation("b", "c", invalidation_lists.descendants); + ExpectIdInvalidation("d", invalidation_lists.descendants); + ExpectNoInvalidation(invalidation_lists.siblings); +} + +TEST_F(RuleFeatureSetTest, pseudoMatchesTooLarge) { + // RuleData cannot support selectors at index 8192 or beyond so the expansion + // is limited to this size + EXPECT_EQ(RuleFeatureSet::kSelectorNeverMatches, + CollectFeatures(":matches(.a#a, .b#b, .c#c, .d#d) + " + ":matches(.e#e, .f#f, .g#g, .h#h) + " + ":matches(.i#i, .j#j, .k#k, .l#l) + " + ":matches(.m#m, .n#n, .o#o, .p#p) + " + ":matches(.q#q, .r#r, .s#s, .t#t) + " + ":matches(.u#u, .v#v, .w#w, .x#x)")); + + InvalidationLists invalidation_lists; + CollectInvalidationSetsForClass(invalidation_lists, "a"); + ExpectNoInvalidation(invalidation_lists.descendants); + ExpectNoInvalidation(invalidation_lists.siblings); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleSet.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleSet.cpp index 425e44e7c7..17f1d2f621 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleSet.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleSet.cpp @@ -72,7 +72,7 @@ RuleData::RuleData(StyleRule* rule, is_last_in_array_(false), position_(position), specificity_(Selector().Specificity()), - link_match_type_(Selector().ComputeLinkMatchType()), + link_match_type_(Selector().ComputeLinkMatchType(CSSSelector::kMatchAll)), has_document_security_origin_(add_rule_flags & kRuleHasDocumentSecurityOrigin), property_whitelist_( @@ -134,6 +134,7 @@ static void ExtractSelectorValues(const CSSSelector* selector, default: break; } + break; default: break; } @@ -222,6 +223,11 @@ bool RuleSet::FindBestRuleSetAndAdd(const CSSSelector& component, void RuleSet::AddRule(StyleRule* rule, unsigned selector_index, AddRuleFlags add_rule_flags) { + // The selector index field in RuleData is only 13 bits so we can't support + // selectors at index 8192 or beyond. + // See https://crbug.com/804179 + if (selector_index >= 8192) + return; RuleData rule_data(rule, selector_index, rule_count_++, add_rule_flags); if (features_.CollectFeaturesFromRuleData(rule_data) == RuleFeatureSet::kSelectorNeverMatches) @@ -319,7 +325,9 @@ void RuleSet::AddRulesFromSheet(StyleSheetContents* sheet, } void RuleSet::AddStyleRule(StyleRule* rule, AddRuleFlags add_rule_flags) { - for (size_t selector_index = 0; selector_index != kNotFound; + for (size_t selector_index = + rule->SelectorList().SelectorIndex(*rule->SelectorList().First()); + selector_index != kNotFound; selector_index = rule->SelectorList().IndexOfNextSelectorAfter(selector_index)) AddRule(rule, selector_index, add_rule_flags); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleSetTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleSetTest.cpp index d3060743f4..1b13f41931 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleSetTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/RuleSetTest.cpp @@ -240,6 +240,49 @@ TEST(RuleSetTest, findBestRuleSetAndAdd_PlaceholderPseudo) { ASSERT_EQ(2u, rules->size()); } +TEST(RuleSetTest, findBestRuleSetAndAdd_PseudoMatches) { + CSSTestHelper helper; + + helper.AddCSSRules(".a :matches(.b+.c, .d>:matches(.e, .f)) { }"); + RuleSet& rule_set = helper.GetRuleSet(); + { + AtomicString str("c"); + const TerminatedArray* rules = rule_set.ClassRules(str); + ASSERT_EQ(1u, rules->size()); + ASSERT_EQ(str, rules->at(0).Selector().Value()); + } + { + AtomicString str("e"); + const TerminatedArray* rules = rule_set.ClassRules(str); + ASSERT_EQ(1u, rules->size()); + ASSERT_EQ(str, rules->at(0).Selector().Value()); + } + { + AtomicString str("f"); + const TerminatedArray* rules = rule_set.ClassRules(str); + ASSERT_EQ(1u, rules->size()); + ASSERT_EQ(str, rules->at(0).Selector().Value()); + } +} + +TEST(RuleSetTest, findBestRuleSetAndAdd_PseudoMatchesTooLarge) { + // RuleData cannot support selectors at index 8192 or beyond so the expansion + // is limited to this size + CSSTestHelper helper; + + helper.AddCSSRules( + ":matches(.a#a, .b#b, .c#c, .d#d) + " + ":matches(.e#e, .f#f, .g#g, .h#h) + " + ":matches(.i#i, .j#j, .k#k, .l#l) + " + ":matches(.m#m, .n#n, .o#o, .p#p) + " + ":matches(.q#q, .r#r, .s#s, .t#t) + " + ":matches(.u#u, .v#v, .w#w, .x#x) { }", + true); + + RuleSet& rule_set = helper.GetRuleSet(); + ASSERT_EQ(0u, rule_set.RuleCount()); +} + TEST(RuleSetTest, SelectorIndexLimit) { StringBuilder builder; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorChecker.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorChecker.cpp index 08505de29a..7f2006f0db 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorChecker.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorChecker.cpp @@ -338,7 +338,7 @@ SelectorChecker::MatchStatus SelectorChecker::MatchForRelation( case CSSSelector::kShadowDeepAsDescendant: Deprecation::CountDeprecation(context.element->GetDocument(), WebFeature::kCSSDeepCombinator); - // fall through + FALLTHROUGH; case CSSSelector::kDescendant: if (context.selector->RelationIsAffectedByPseudoContent()) { for (Element* element = context.element; element; @@ -504,6 +504,8 @@ SelectorChecker::MatchStatus SelectorChecker::MatchForRelation( } case CSSSelector::kShadowSlot: { + if (ToHTMLSlotElementIfSupportsAssignmentOrNull(*context.element)) + return kSelectorFailsCompletely; const HTMLSlotElement* slot = FindSlotElementInScope(context); if (!slot) return kSelectorFailsCompletely; @@ -878,21 +880,6 @@ bool SelectorChecker::CheckPseudoClass(const SelectorCheckingContext& context, } case CSSSelector::kPseudoTarget: return element == element.GetDocument().CssTarget(); - case CSSSelector::kPseudoMatches: { - if (!RuntimeEnabledFeatures::CSSMatchesEnabled()) - return false; - UseCounter::Count(context.element->GetDocument(), - WebFeature::kCSSSelectorPseudoMatches); - SelectorCheckingContext sub_context(context); - sub_context.is_sub_selector = true; - DCHECK(selector.SelectorList()); - for (sub_context.selector = selector.SelectorList()->First(); - sub_context.selector; sub_context.selector = CSSSelectorList::Next( - *sub_context.selector)) { - if (Match(sub_context)) - return true; - } - } break; case CSSSelector::kPseudoAny: { SelectorCheckingContext sub_context(context); sub_context.is_sub_selector = true; @@ -908,13 +895,7 @@ bool SelectorChecker::CheckPseudoClass(const SelectorCheckingContext& context, return element.IsFormControlElement() && ToHTMLFormControlElement(element).IsAutofilled(); case CSSSelector::kPseudoAnyLink: - UseCounter::Count(context.element->GetDocument(), - WebFeature::kCSSSelectorPseudoAnyLink); - return element.IsLink(); case CSSSelector::kPseudoWebkitAnyLink: - UseCounter::Count(context.element->GetDocument(), - WebFeature::kCSSSelectorPseudoWebkitAnyLink); - // Fall through case CSSSelector::kPseudoLink: return element.IsLink(); case CSSSelector::kPseudoVisited: @@ -1117,6 +1098,7 @@ bool SelectorChecker::CheckPseudoClass(const SelectorCheckingContext& context, case CSSSelector::kPseudoCornerPresent: return false; case CSSSelector::kPseudoUnknown: + case CSSSelector::kPseudoMatches: default: NOTREACHED(); break; @@ -1199,7 +1181,7 @@ bool SelectorChecker::CheckPseudoHost(const SelectorCheckingContext& context, const ContainerNode* shadow_host = context.scope->OwnerShadowHost(); if (!shadow_host || shadow_host != element) return false; - DCHECK(element.Shadow()); + DCHECK(IsShadowHost(element)); // For the case with no parameters, i.e. just :host. if (!selector.SelectorList()) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorQuery.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorQuery.cpp index 62cee6eff3..52e0549121 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorQuery.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorQuery.cpp @@ -305,21 +305,14 @@ void SelectorQuery::ExecuteSlow( } } -// FIXME: Move the following helper functions, authorShadowRootOf, -// firstWithinTraversingShadowTree, nextTraversingShadowTree to the best place, -// e.g. NodeTraversal. +// FIXME: Move the following helper functions, AuthorShadowRootOf, +// NextTraversingShadowTree to the best place, e.g. NodeTraversal. static ShadowRoot* AuthorShadowRootOf(const ContainerNode& node) { if (!node.IsElementNode()) return nullptr; - ElementShadow* shadow = ToElement(node).Shadow(); - if (!shadow) - return nullptr; - - for (ShadowRoot* shadow_root = &shadow->OldestShadowRoot(); shadow_root; - shadow_root = shadow_root->YoungerShadowRoot()) { - if (shadow_root->IsOpenOrV0()) - return shadow_root; - } + ShadowRoot* root = node.GetShadowRoot(); + if (root && root->IsOpenOrV0()) + return root; return nullptr; } @@ -339,10 +332,6 @@ static ContainerNode* NextTraversingShadowTree(const ContainerNode& node, ShadowRoot* shadow_root = current->ContainingShadowRoot(); if (shadow_root == root_node) return nullptr; - if (ShadowRoot* younger_shadow_root = shadow_root->YoungerShadowRoot()) { - DCHECK(younger_shadow_root->IsOpenOrV0()); - return younger_shadow_root; - } current = &shadow_root->host(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorQueryTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorQueryTest.cpp index 287fbc5ea9..62b236cc8e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorQueryTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/SelectorQueryTest.cpp @@ -248,8 +248,7 @@ TEST(SelectorQueryTest, FastPathScoped) { ShadowRoot& shadowRoot = scope->EnsureShadow().AddShadowRoot(*scope, ShadowRootType::kOpen); // Make the inside the shadow root be identical to that of the outer document. - shadowRoot.appendChild( - document->documentElement()->CloneElementWithChildren()); + shadowRoot.appendChild(document->documentElement()->CloneWithChildren()); static const struct QueryTest kTestCases[] = { // Id in the right most selector. {"#first", false, 0, {0, 0, 0, 0, 0, 0, 0}}, @@ -328,7 +327,7 @@ TEST(SelectorQueryTest, QuirksModeSlowPath) { TEST(SelectorQueryTest, DisconnectedSubtree) { Document* document = HTMLDocument::CreateForTest(); - Element* scope = document->createElement("div"); + Element* scope = document->CreateRawElement(HTMLNames::divTag); scope->SetInnerHTMLFromString(R"HTML(
@@ -355,7 +354,7 @@ TEST(SelectorQueryTest, DisconnectedSubtree) { TEST(SelectorQueryTest, DisconnectedTreeScope) { Document* document = HTMLDocument::CreateForTest(); - Element* host = document->createElement("div"); + Element* host = document->CreateRawElement(HTMLNames::divTag); // TODO(esprehn): Element::attachShadow() should not require a ScriptState, // it should handle the use counting in the bindings layer instead of in the // C++. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ShadowTreeStyleSheetCollection.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ShadowTreeStyleSheetCollection.cpp index 5490fba7b9..ed6e5983fd 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ShadowTreeStyleSheetCollection.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/ShadowTreeStyleSheetCollection.cpp @@ -64,6 +64,22 @@ void ShadowTreeStyleSheetCollection::CollectStyleSheets( std::make_pair(css_sheet, master_engine.RuleSetForSheet(*css_sheet))); } } + + if (!GetTreeScope().HasMoreStyleSheets()) + return; + + StyleSheetList& more_style_sheets = GetTreeScope().MoreStyleSheets(); + unsigned length = more_style_sheets.length(); + for (unsigned index = 0; index < length; ++index) { + StyleSheet* sheet = more_style_sheets.item(index); + if (!sheet) + continue; + CSSStyleSheet* css_sheet = ToCSSStyleSheet(sheet); + if (!css_sheet || !css_sheet->CanBeActivated(g_null_atom)) + continue; + collection.AppendActiveStyleSheet( + std::make_pair(css_sheet, master_engine.RuleSetForSheet(*css_sheet))); + } } void ShadowTreeStyleSheetCollection::UpdateActiveStyleSheets( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleAttributeMutationScope.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleAttributeMutationScope.cpp index 15a10004d6..c111ba861c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleAttributeMutationScope.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleAttributeMutationScope.cpp @@ -22,7 +22,7 @@ #include "core/css/StyleAttributeMutationScope.h" -#include "core/css/CSSStyleDeclaration.h" +#include "core/css/AbstractPropertySetCSSStyleDeclaration.h" #include "core/dom/MutationObserverInterestGroup.h" #include "core/dom/MutationRecord.h" #include "core/html/custom/CustomElement.h" @@ -45,13 +45,14 @@ static CustomElementDefinition* DefinitionIfStyleChangedCallback( } // namespace unsigned StyleAttributeMutationScope::scope_count_ = 0; -CSSStyleDeclaration* StyleAttributeMutationScope::current_decl_ = nullptr; +AbstractPropertySetCSSStyleDeclaration* + StyleAttributeMutationScope::current_decl_ = nullptr; bool StyleAttributeMutationScope::should_notify_inspector_ = false; bool StyleAttributeMutationScope::should_deliver_ = false; DISABLE_CFI_PERF StyleAttributeMutationScope::StyleAttributeMutationScope( - CSSStyleDeclaration* decl) { + AbstractPropertySetCSSStyleDeclaration* decl) { ++scope_count_; if (scope_count_ != 1) { @@ -108,7 +109,7 @@ StyleAttributeMutationScope::~StyleAttributeMutationScope() { } // We have to clear internal state before calling Inspector's code. - CSSStyleDeclaration* local_copy_style_decl = current_decl_; + AbstractPropertySetCSSStyleDeclaration* local_copy_style_decl = current_decl_; current_decl_ = nullptr; if (!should_notify_inspector_) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleAttributeMutationScope.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleAttributeMutationScope.h index 112fbe121a..7e0a3d35bb 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleAttributeMutationScope.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleAttributeMutationScope.h @@ -29,7 +29,7 @@ namespace blink { -class CSSStyleDeclaration; +class AbstractPropertySetCSSStyleDeclaration; class MutationObserverInterestGroup; class MutationRecord; @@ -37,7 +37,7 @@ class StyleAttributeMutationScope { STACK_ALLOCATED(); public: - StyleAttributeMutationScope(CSSStyleDeclaration*); + StyleAttributeMutationScope(AbstractPropertySetCSSStyleDeclaration*); ~StyleAttributeMutationScope(); @@ -47,7 +47,7 @@ class StyleAttributeMutationScope { private: static unsigned scope_count_; - static CSSStyleDeclaration* current_decl_; + static AbstractPropertySetCSSStyleDeclaration* current_decl_; static bool should_notify_inspector_; static bool should_deliver_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngine.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngine.cpp index 67141f87e7..f4d90d24ec 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngine.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngine.cpp @@ -141,35 +141,39 @@ StyleEngine::StyleSheetsForStyleSheetList(TreeScope& tree_scope) { return collection.StyleSheetsForStyleSheetList(); } -WebStyleSheetId StyleEngine::InjectSheet(StyleSheetContents* sheet, - WebDocument::CSSOrigin origin) { - if (origin == WebDocument::kUserOrigin) { - injected_user_style_sheets_.push_back( - std::make_pair(++injected_sheets_id_count_, - CSSStyleSheet::Create(sheet, *document_))); +void StyleEngine::InjectSheet(const StyleSheetKey& key, + StyleSheetContents* sheet, + WebDocument::CSSOrigin origin) { + HeapVector>>& + injected_style_sheets = origin == WebDocument::kUserOrigin + ? injected_user_style_sheets_ + : injected_author_style_sheets_; + injected_style_sheets.push_back( + std::make_pair(key, CSSStyleSheet::Create(sheet, *document_))); + if (origin == WebDocument::kUserOrigin) MarkUserStyleDirty(); - } else { - injected_author_style_sheets_.push_back( - std::make_pair(++injected_sheets_id_count_, - CSSStyleSheet::Create(sheet, *document_))); + else MarkDocumentDirty(); - } - - return injected_sheets_id_count_; } -void StyleEngine::RemoveInjectedSheet(WebStyleSheetId sheet_id) { - for (size_t i = 0; i < injected_user_style_sheets_.size(); ++i) { - if (injected_user_style_sheets_[i].first == sheet_id) { - injected_user_style_sheets_.EraseAt(i); +void StyleEngine::RemoveInjectedSheet(const StyleSheetKey& key, + WebDocument::CSSOrigin origin) { + HeapVector>>& + injected_style_sheets = origin == WebDocument::kUserOrigin + ? injected_user_style_sheets_ + : injected_author_style_sheets_; + // Remove the last sheet that matches. + const auto& it = std::find_if(injected_style_sheets.rbegin(), + injected_style_sheets.rend(), + [&key](const auto& item) { + return item.first == key; + }); + if (it != injected_style_sheets.rend()) { + injected_style_sheets.erase(std::next(it).base()); + if (origin == WebDocument::kUserOrigin) MarkUserStyleDirty(); - } - } - for (size_t i = 0; i < injected_author_style_sheets_.size(); ++i) { - if (injected_author_style_sheets_[i].first == sheet_id) { - injected_author_style_sheets_.EraseAt(i); + else MarkDocumentDirty(); - } } } @@ -273,6 +277,42 @@ void StyleEngine::ModifiedStyleSheetCandidateNode(Node& node) { SetNeedsActiveStyleUpdate(node.GetTreeScope()); } +void StyleEngine::MoreStyleSheetsWillChange(TreeScope& tree_scope, + StyleSheetList* old_sheets, + StyleSheetList* new_sheets) { + if (GetDocument().IsDetached()) + return; + + unsigned old_sheets_count = old_sheets ? old_sheets->length() : 0; + unsigned new_sheets_count = new_sheets ? new_sheets->length() : 0; + + unsigned min_count = std::min(old_sheets_count, new_sheets_count); + unsigned index = 0; + while (index < min_count && + old_sheets->item(index) == new_sheets->item(index)) { + index++; + } + + if (old_sheets_count == new_sheets_count && index == old_sheets_count) + return; + + for (unsigned i = index; i < old_sheets_count; ++i) { + ToCSSStyleSheet(old_sheets->item(i)) + ->RemovedConstructedFromTreeScope(&tree_scope); + } + for (unsigned i = index; i < new_sheets_count; ++i) { + ToCSSStyleSheet(new_sheets->item(i)) + ->AddedConstructedToTreeScope(&tree_scope); + } + + if (new_sheets_count) { + EnsureStyleSheetCollectionFor(tree_scope); + if (tree_scope != document_) + active_tree_scopes_.insert(&tree_scope); + } + SetNeedsActiveStyleUpdate(tree_scope); +} + void StyleEngine::MediaQueriesChangedInScope(TreeScope& tree_scope) { if (ScopedStyleResolver* resolver = tree_scope.GetScopedStyleResolver()) resolver->SetNeedsAppendAllSheets(); @@ -348,7 +388,8 @@ void StyleEngine::UpdateActiveStyleSheetsInShadow( ToShadowTreeStyleSheetCollection(StyleSheetCollectionFor(*tree_scope)); DCHECK(collection); collection->UpdateActiveStyleSheets(*this); - if (!collection->HasStyleSheetCandidateNodes()) { + if (!collection->HasStyleSheetCandidateNodes() && + !tree_scope->HasMoreStyleSheets()) { tree_scopes_removed.insert(tree_scope); // When removing TreeScope from ActiveTreeScopes, // its resolver should be destroyed by invoking resetAuthorStyle. @@ -696,7 +737,7 @@ void StyleEngine::FontsNeedUpdate(FontSelector*) { GetDocument().SetNeedsStyleRecalc( kSubtreeStyleChange, StyleChangeReasonForTracing::Create(StyleChangeReason::kFonts)); - probe::fontsUpdated(document_); + probe::fontsUpdated(document_, nullptr, String(), nullptr); } void StyleEngine::SetFontSelector(CSSFontSelector* font_selector) { @@ -985,7 +1026,7 @@ void StyleEngine::ScheduleTypeRuleSetInvalidations( } void StyleEngine::InvalidateSlottedElements(HTMLSlotElement& slot) { - for (auto& node : slot.GetDistributedNodes()) { + for (auto& node : slot.FlattenedAssignedNodes()) { if (node->IsElementNode()) { node->SetNeedsStyleRecalc(kLocalStyleChange, StyleChangeReasonForTracing::Create( @@ -1032,12 +1073,9 @@ void StyleEngine::ScheduleInvalidationsForRuleSets( InvalidateSlottedElements(ToHTMLSlotElement(*element)); if (invalidation_scope == kInvalidateAllScopes) { - ElementShadow* shadow = element->Shadow(); - ShadowRoot* shadow_root = shadow ? &shadow->OldestShadowRoot() : nullptr; - while (shadow_root) { + if (ShadowRoot* shadow_root = element->GetShadowRoot()) { ScheduleInvalidationsForRuleSets(*shadow_root, rule_sets, kInvalidateAllScopes); - shadow_root = shadow_root->YoungerShadowRoot(); } } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngine.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngine.h index 19ed1879ec..559bfe6521 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngine.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngine.h @@ -68,6 +68,8 @@ class ViewportStyleResolver; enum InvalidationScope { kInvalidateCurrentScope, kInvalidateAllScopes }; +using StyleSheetKey = AtomicString; + class CORE_EXPORT StyleEngine final : public GarbageCollectedFinalized, public FontSelectorClient, @@ -98,7 +100,7 @@ class CORE_EXPORT StyleEngine final StyleSheetsForStyleSheetList(TreeScope&); const HeapVector< - std::pair>>& + std::pair>>& InjectedAuthorStyleSheets() const { return injected_author_style_sheets_; } @@ -112,6 +114,9 @@ class CORE_EXPORT StyleEngine final void AddStyleSheetCandidateNode(Node&); void RemoveStyleSheetCandidateNode(Node&, ContainerNode& insertion_point); void ModifiedStyleSheetCandidateNode(Node&); + void MoreStyleSheetsWillChange(TreeScope&, + StyleSheetList* old_sheets, + StyleSheetList* new_sheets); void MediaQueriesChangedInScope(TreeScope&); void WatchedSelectorsChanged(); void InitialViewportChanged(); @@ -119,10 +124,12 @@ class CORE_EXPORT StyleEngine final void HtmlImportAddedOrRemoved(); void V0ShadowAddedOnV1Document(); - WebStyleSheetId InjectSheet(StyleSheetContents*, - WebDocument::CSSOrigin = - WebDocument::kAuthorOrigin); - void RemoveInjectedSheet(WebStyleSheetId); + void InjectSheet(const StyleSheetKey&, StyleSheetContents*, + WebDocument::CSSOrigin = + WebDocument::kAuthorOrigin); + void RemoveInjectedSheet(const StyleSheetKey&, + WebDocument::CSSOrigin = + WebDocument::kAuthorOrigin); CSSStyleSheet& EnsureInspectorStyleSheet(); RuleSet* WatchedSelectorsRuleSet() { DCHECK(IsMaster()); @@ -449,15 +456,13 @@ class CORE_EXPORT StyleEngine final std::unique_ptr style_resolver_stats_; unsigned style_for_element_count_ = 0; - HeapVector>> + HeapVector>> injected_user_style_sheets_; - HeapVector>> + HeapVector>> injected_author_style_sheets_; ActiveStyleSheetVector active_user_style_sheets_; - WebStyleSheetId injected_sheets_id_count_ = 0; - using KeyframesRuleMap = HeapHashMap>; KeyframesRuleMap keyframes_rule_map_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngineTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngineTest.cpp index 2a8c1390eb..71e141a269 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngineTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleEngineTest.cpp @@ -76,9 +76,9 @@ TEST_F(StyleEngineTest, DocumentDirtyAfterInject) { StyleSheetContents* parsed_sheet = StyleSheetContents::Create(CSSParserContext::Create(GetDocument())); parsed_sheet->ParseString("div {}"); - GetStyleEngine().InjectSheet(parsed_sheet); + GetStyleEngine().InjectSheet("", parsed_sheet); + EXPECT_FALSE(IsDocumentStyleSheetCollectionClean()); GetDocument().View()->UpdateAllLifecyclePhases(); - EXPECT_TRUE(IsDocumentStyleSheetCollectionClean()); } @@ -101,6 +101,7 @@ TEST_F(StyleEngineTest, AnalyzedInject) { #t6 { color: var(--stop-color); } #t7 { color: var(--go-color); } .red { color: red; } + #t11 { color: white; }
Green
White
@@ -112,6 +113,7 @@ TEST_F(StyleEngineTest, AnalyzedInject) {
screen: Red; print: Black
Green
Black
+
White
)HTML"); GetDocument().View()->UpdateAllLifecyclePhases(); @@ -140,10 +142,9 @@ TEST_F(StyleEngineTest, AnalyzedInject) { "#t1 { color: green !important }" "#t2 { color: white !important }" "#t3 { color: white }"); - WebStyleSheetId green_id = - GetStyleEngine().InjectSheet(green_parsed_sheet, - WebDocument::kUserOrigin); - EXPECT_EQ(1u, green_id); + StyleSheetKey green_key("green"); + GetStyleEngine().InjectSheet(green_key, green_parsed_sheet, + WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); EXPECT_EQ(3u, GetStyleEngine().StyleForElementCount() - initial_count); @@ -167,9 +168,9 @@ TEST_F(StyleEngineTest, AnalyzedInject) { "#t1 { color: blue !important }" "#t2 { color: silver }" "#t3 { color: silver !important }"); - WebStyleSheetId blue_id = - GetStyleEngine().InjectSheet(blue_parsed_sheet, WebDocument::kUserOrigin); - EXPECT_EQ(2u, blue_id); + StyleSheetKey blue_key("blue"); + GetStyleEngine().InjectSheet(blue_key, blue_parsed_sheet, + WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); EXPECT_EQ(6u, GetStyleEngine().StyleForElementCount() - initial_count); @@ -189,7 +190,7 @@ TEST_F(StyleEngineTest, AnalyzedInject) { MakeRGB(192, 192, 192), t3->GetComputedStyle()->VisitedDependentColor(GetCSSPropertyColor())); - GetStyleEngine().RemoveInjectedSheet(green_id); + GetStyleEngine().RemoveInjectedSheet(green_key, WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); EXPECT_EQ(9u, GetStyleEngine().StyleForElementCount() - initial_count); ASSERT_TRUE(t1->GetComputedStyle()); @@ -205,7 +206,7 @@ TEST_F(StyleEngineTest, AnalyzedInject) { MakeRGB(192, 192, 192), t3->GetComputedStyle()->VisitedDependentColor(GetCSSPropertyColor())); - GetStyleEngine().RemoveInjectedSheet(blue_id); + GetStyleEngine().RemoveInjectedSheet(blue_key, WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); EXPECT_EQ(12u, GetStyleEngine().StyleForElementCount() - initial_count); ASSERT_TRUE(t1->GetComputedStyle()); @@ -249,9 +250,9 @@ TEST_F(StyleEngineTest, AnalyzedInject) { " font-style: italic;" "}" ); - WebStyleSheetId font_face_id = - GetStyleEngine().InjectSheet(font_face_parsed_sheet, - WebDocument::kUserOrigin); + StyleSheetKey font_face_key("font_face"); + GetStyleEngine().InjectSheet(font_face_key, font_face_parsed_sheet, + WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); // After injecting a more specific font, now there are two and the @@ -268,8 +269,8 @@ TEST_F(StyleEngineTest, AnalyzedInject) { ASSERT_EQ(capabilities.slope, FontSelectionRange({ItalicSlopeValue(), ItalicSlopeValue()})); - HTMLStyleElement* style_element = HTMLStyleElement::Create( - GetDocument(), false); + auto* style_element = + HTMLStyleElement::Create(GetDocument(), CreateElementFlags()); style_element->SetInnerHTMLFromString( "@font-face {" " font-family: 'Cool Font';" @@ -295,7 +296,7 @@ TEST_F(StyleEngineTest, AnalyzedInject) { ASSERT_EQ(capabilities.slope, FontSelectionRange({ItalicSlopeValue(), ItalicSlopeValue()})); - GetStyleEngine().RemoveInjectedSheet(font_face_id); + GetStyleEngine().RemoveInjectedSheet(font_face_key, WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); // After removing the injected style sheet we're left with a bold-normal and @@ -325,9 +326,9 @@ TEST_F(StyleEngineTest, AnalyzedInject) { StyleSheetContents* keyframes_parsed_sheet = StyleSheetContents::Create(CSSParserContext::Create(GetDocument())); keyframes_parsed_sheet->ParseString("@keyframes dummy-animation { from {} }"); - WebStyleSheetId keyframes_id = - GetStyleEngine().InjectSheet(keyframes_parsed_sheet, - WebDocument::kUserOrigin); + StyleSheetKey keyframes_key("keyframes"); + GetStyleEngine().InjectSheet(keyframes_key, keyframes_parsed_sheet, + WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); // After injecting the style sheet, a @keyframes rule named dummy-animation @@ -338,7 +339,7 @@ TEST_F(StyleEngineTest, AnalyzedInject) { ASSERT_TRUE(keyframes); EXPECT_EQ(1u, keyframes->Keyframes().size()); - style_element = HTMLStyleElement::Create(GetDocument(), false); + style_element = HTMLStyleElement::Create(GetDocument(), CreateElementFlags()); style_element->SetInnerHTMLFromString( "@keyframes dummy-animation { from {} to {} }"); GetDocument().body()->AppendChild(style_element); @@ -359,7 +360,7 @@ TEST_F(StyleEngineTest, AnalyzedInject) { ASSERT_TRUE(keyframes); EXPECT_EQ(1u, keyframes->Keyframes().size()); - GetStyleEngine().RemoveInjectedSheet(keyframes_id); + GetStyleEngine().RemoveInjectedSheet(keyframes_key, WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); // Injected @keyframes rules are no longer available once removed. @@ -387,9 +388,10 @@ TEST_F(StyleEngineTest, AnalyzedInject) { " --stop-color: red !important;" " --go-color: green;" "}"); - WebStyleSheetId custom_properties_id = - GetStyleEngine().InjectSheet(custom_properties_parsed_sheet, - WebDocument::kUserOrigin); + StyleSheetKey custom_properties_key("custom_properties"); + GetStyleEngine().InjectSheet(custom_properties_key, + custom_properties_parsed_sheet, + WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); ASSERT_TRUE(t6->GetComputedStyle()); ASSERT_TRUE(t7->GetComputedStyle()); @@ -399,7 +401,8 @@ TEST_F(StyleEngineTest, AnalyzedInject) { MakeRGB(255, 255, 255), t7->GetComputedStyle()->VisitedDependentColor(GetCSSPropertyColor())); - GetStyleEngine().RemoveInjectedSheet(custom_properties_id); + GetStyleEngine().RemoveInjectedSheet(custom_properties_key, + WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); ASSERT_TRUE(t6->GetComputedStyle()); ASSERT_TRUE(t7->GetComputedStyle()); @@ -431,26 +434,28 @@ TEST_F(StyleEngineTest, AnalyzedInject) { " color: black !important;" " }" "}"); - WebStyleSheetId media_queries_sheet_id = - GetStyleEngine().InjectSheet(media_queries_parsed_sheet, - WebDocument::kUserOrigin); + StyleSheetKey media_queries_sheet_key("media_queries_sheet"); + GetStyleEngine().InjectSheet(media_queries_sheet_key, + media_queries_parsed_sheet, + WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); ASSERT_TRUE(t8->GetComputedStyle()); EXPECT_EQ(MakeRGB(255, 0, 0), t8->GetComputedStyle()->VisitedDependentColor( GetCSSPropertyColor())); FloatSize page_size(400, 400); - GetDocument().GetFrame()->SetPrinting(true, page_size, page_size, 1); + GetDocument().GetFrame()->StartPrinting(page_size, page_size, 1); ASSERT_TRUE(t8->GetComputedStyle()); EXPECT_EQ(MakeRGB(0, 0, 0), t8->GetComputedStyle()->VisitedDependentColor( GetCSSPropertyColor())); - GetDocument().GetFrame()->SetPrinting(false, FloatSize(), FloatSize(), 0); + GetDocument().GetFrame()->EndPrinting(); ASSERT_TRUE(t8->GetComputedStyle()); EXPECT_EQ(MakeRGB(255, 0, 0), t8->GetComputedStyle()->VisitedDependentColor( GetCSSPropertyColor())); - GetStyleEngine().RemoveInjectedSheet(media_queries_sheet_id); + GetStyleEngine().RemoveInjectedSheet(media_queries_sheet_key, + WebDocument::kUserOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); ASSERT_TRUE(t8->GetComputedStyle()); EXPECT_EQ( @@ -479,9 +484,9 @@ TEST_F(StyleEngineTest, AnalyzedInject) { "#t10 {" " color: white !important;" "}"); - WebStyleSheetId author_sheet_id = - GetStyleEngine().InjectSheet(parsed_author_sheet, - WebDocument::kAuthorOrigin); + StyleSheetKey author_sheet_key("author_sheet"); + GetStyleEngine().InjectSheet(author_sheet_key, parsed_author_sheet, + WebDocument::kAuthorOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); ASSERT_TRUE(t9->GetComputedStyle()); ASSERT_TRUE(t10->GetComputedStyle()); @@ -493,7 +498,8 @@ TEST_F(StyleEngineTest, AnalyzedInject) { EXPECT_EQ(MakeRGB(0, 0, 0), t10->GetComputedStyle()->VisitedDependentColor( GetCSSPropertyColor())); - GetStyleEngine().RemoveInjectedSheet(author_sheet_id); + GetStyleEngine().RemoveInjectedSheet(author_sheet_key, + WebDocument::kAuthorOrigin); GetDocument().View()->UpdateAllLifecyclePhases(); ASSERT_TRUE(t9->GetComputedStyle()); ASSERT_TRUE(t10->GetComputedStyle()); @@ -501,6 +507,90 @@ TEST_F(StyleEngineTest, AnalyzedInject) { GetCSSPropertyColor())); EXPECT_EQ(MakeRGB(0, 0, 0), t10->GetComputedStyle()->VisitedDependentColor( GetCSSPropertyColor())); + + // Style sheet removal + + Element* t11 = GetDocument().getElementById("t11"); + ASSERT_TRUE(t11); + ASSERT_TRUE(t11->GetComputedStyle()); + EXPECT_EQ( + MakeRGB(255, 255, 255), + t11->GetComputedStyle()->VisitedDependentColor(GetCSSPropertyColor())); + + StyleSheetContents* parsed_removable_red_sheet = + StyleSheetContents::Create(CSSParserContext::Create(GetDocument())); + parsed_removable_red_sheet->ParseString("#t11 { color: red !important; }"); + StyleSheetKey removable_red_sheet_key("removable_red_sheet"); + GetStyleEngine().InjectSheet(removable_red_sheet_key, + parsed_removable_red_sheet, + WebDocument::kUserOrigin); + GetDocument().View()->UpdateAllLifecyclePhases(); + ASSERT_TRUE(t11->GetComputedStyle()); + + EXPECT_EQ(MakeRGB(255, 0, 0), t11->GetComputedStyle()->VisitedDependentColor( + GetCSSPropertyColor())); + + StyleSheetContents* parsed_removable_green_sheet = + StyleSheetContents::Create(CSSParserContext::Create(GetDocument())); + parsed_removable_green_sheet->ParseString( + "#t11 { color: green !important; }"); + StyleSheetKey removable_green_sheet_key("removable_green_sheet"); + GetStyleEngine().InjectSheet(removable_green_sheet_key, + parsed_removable_green_sheet, + WebDocument::kUserOrigin); + GetDocument().View()->UpdateAllLifecyclePhases(); + ASSERT_TRUE(t11->GetComputedStyle()); + + EXPECT_EQ(MakeRGB(0, 128, 0), t11->GetComputedStyle()->VisitedDependentColor( + GetCSSPropertyColor())); + + StyleSheetContents* parsed_removable_red_sheet2 = + StyleSheetContents::Create(CSSParserContext::Create(GetDocument())); + parsed_removable_red_sheet2->ParseString("#t11 { color: red !important; }"); + GetStyleEngine().InjectSheet(removable_red_sheet_key, + parsed_removable_red_sheet2, + WebDocument::kUserOrigin); + GetDocument().View()->UpdateAllLifecyclePhases(); + ASSERT_TRUE(t11->GetComputedStyle()); + + EXPECT_EQ(MakeRGB(255, 0, 0), t11->GetComputedStyle()->VisitedDependentColor( + GetCSSPropertyColor())); + + GetStyleEngine().RemoveInjectedSheet(removable_red_sheet_key, + WebDocument::kAuthorOrigin); + GetDocument().View()->UpdateAllLifecyclePhases(); + ASSERT_TRUE(t11->GetComputedStyle()); + + // Removal works only within the same origin. + EXPECT_EQ(MakeRGB(255, 0, 0), t11->GetComputedStyle()->VisitedDependentColor( + GetCSSPropertyColor())); + + GetStyleEngine().RemoveInjectedSheet(removable_red_sheet_key, + WebDocument::kUserOrigin); + GetDocument().View()->UpdateAllLifecyclePhases(); + ASSERT_TRUE(t11->GetComputedStyle()); + + // The last sheet with the given key is removed. + EXPECT_EQ(MakeRGB(0, 128, 0), t11->GetComputedStyle()->VisitedDependentColor( + GetCSSPropertyColor())); + + GetStyleEngine().RemoveInjectedSheet(removable_green_sheet_key, + WebDocument::kUserOrigin); + GetDocument().View()->UpdateAllLifecyclePhases(); + ASSERT_TRUE(t11->GetComputedStyle()); + + // Only the last sheet with the given key is removed. + EXPECT_EQ(MakeRGB(255, 0, 0), t11->GetComputedStyle()->VisitedDependentColor( + GetCSSPropertyColor())); + + GetStyleEngine().RemoveInjectedSheet(removable_red_sheet_key, + WebDocument::kUserOrigin); + GetDocument().View()->UpdateAllLifecyclePhases(); + ASSERT_TRUE(t11->GetComputedStyle()); + + EXPECT_EQ( + MakeRGB(255, 255, 255), + t11->GetComputedStyle()->VisitedDependentColor(GetCSSPropertyColor())); } TEST_F(StyleEngineTest, IgnoreInvalidPropertyValue) { @@ -517,7 +607,7 @@ TEST_F(StyleEngineTest, IgnoreInvalidPropertyValue) { } TEST_F(StyleEngineTest, TextToSheetCache) { - HTMLStyleElement* element = HTMLStyleElement::Create(GetDocument(), false); + auto* element = HTMLStyleElement::Create(GetDocument(), CreateElementFlags()); String sheet_text("div {}"); TextPosition min_pos = TextPosition::MinimumPosition(); @@ -545,7 +635,7 @@ TEST_F(StyleEngineTest, TextToSheetCache) { // StyleSheetContents cache. ThreadState::Current()->CollectAllGarbage(); - element = HTMLStyleElement::Create(GetDocument(), false); + element = HTMLStyleElement::Create(GetDocument(), CreateElementFlags()); sheet1 = GetStyleEngine().CreateSheet(*element, sheet_text, min_pos, context); // Check that we did not use a cached StyleSheetContents after the garbage diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp index 1d8426e86a..a74f595e0d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StylePropertySerializer.cpp @@ -331,7 +331,7 @@ static bool AllowInitialInShorthand(CSSPropertyID property_id) { case CSSPropertyGridColumn: case CSSPropertyGridRow: case CSSPropertyGridArea: - case CSSPropertyGridGap: + case CSSPropertyGap: case CSSPropertyListStyle: case CSSPropertyOffset: case CSSPropertyTextDecoration: @@ -458,8 +458,8 @@ String StylePropertySerializer::GetPropertyValue( return GetShorthandValue(gridRowShorthand(), " / "); case CSSPropertyGridArea: return GetShorthandValue(gridAreaShorthand(), " / "); - case CSSPropertyGridGap: - return GetShorthandValue(gridGapShorthand()); + case CSSPropertyGap: + return GetShorthandValue(gapShorthand()); case CSSPropertyPlaceContent: return GetAlignmentShorthandValue(placeContentShorthand()); case CSSPropertyPlaceItems: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRule.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRule.cpp index d4a9770f46..7feec2a14a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRule.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRule.cpp @@ -33,7 +33,6 @@ #include "core/css/StyleRuleImport.h" #include "core/css/StyleRuleKeyframe.h" #include "core/css/StyleRuleNamespace.h" -#include "core/css/parser/AtRuleDescriptorValueSet.h" namespace blink { @@ -294,7 +293,7 @@ void StyleRulePage::TraceAfterDispatch(blink::Visitor* visitor) { StyleRuleBase::TraceAfterDispatch(visitor); } -StyleRuleFontFace::StyleRuleFontFace(AtRuleDescriptorValueSet* properties) +StyleRuleFontFace::StyleRuleFontFace(CSSPropertyValueSet* properties) : StyleRuleBase(kFontFace), properties_(properties) {} StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& font_face_rule) @@ -303,10 +302,10 @@ StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& font_face_rule) StyleRuleFontFace::~StyleRuleFontFace() = default; -AtRuleDescriptorValueSet& StyleRuleFontFace::MutableProperties() { +MutableCSSPropertyValueSet& StyleRuleFontFace::MutableProperties() { if (!properties_->IsMutable()) properties_ = properties_->MutableCopy(); - return *properties_; + return *ToMutableCSSPropertyValueSet(properties_); } void StyleRuleFontFace::TraceAfterDispatch(blink::Visitor* visitor) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRule.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRule.h index 382e61c85f..2218bd9782 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRule.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRule.h @@ -31,8 +31,6 @@ namespace blink { -class AtRuleDescriptorValueSet; -class CSSLazyPropertyParser; class CSSRule; class CSSStyleSheet; @@ -152,24 +150,24 @@ class CORE_EXPORT StyleRule : public StyleRuleBase { class CORE_EXPORT StyleRuleFontFace : public StyleRuleBase { public: - static StyleRuleFontFace* Create(AtRuleDescriptorValueSet* properties) { + static StyleRuleFontFace* Create(CSSPropertyValueSet* properties) { return new StyleRuleFontFace(properties); } ~StyleRuleFontFace(); - const AtRuleDescriptorValueSet& Properties() const { return *properties_; } - AtRuleDescriptorValueSet& MutableProperties(); + const CSSPropertyValueSet& Properties() const { return *properties_; } + MutableCSSPropertyValueSet& MutableProperties(); StyleRuleFontFace* Copy() const { return new StyleRuleFontFace(*this); } void TraceAfterDispatch(blink::Visitor*); private: - StyleRuleFontFace(AtRuleDescriptorValueSet*); + StyleRuleFontFace(CSSPropertyValueSet*); StyleRuleFontFace(const StyleRuleFontFace&); - Member properties_; // Cannot be null. + Member properties_; // Cannot be null. }; class StyleRulePage : public StyleRuleBase { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRuleImport.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRuleImport.cpp index 40cf99a85b..f3b9eb934c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRuleImport.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleRuleImport.cpp @@ -138,9 +138,8 @@ void StyleRuleImport::RequestStyleSheet() { params.SetCharset(parent_style_sheet_->Charset()); loading_ = true; DCHECK(!style_sheet_client_->GetResource()); - if (!CSSStyleSheetResource::Fetch(params, fetcher, style_sheet_client_)) { - loading_ = false; - } else if (loading_) { + CSSStyleSheetResource::Fetch(params, fetcher, style_sheet_client_); + if (loading_) { // if the import rule is issued dynamically, the sheet may be // removed from the pending sheet count, so let the doc know // the sheet being imported is pending. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheet.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheet.idl index 3da7328dc3..e009743476 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheet.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheet.idl @@ -29,7 +29,6 @@ readonly attribute Node? ownerNode; readonly attribute StyleSheet? parentStyleSheet; readonly attribute DOMString? title; - // TODO(foolip): media should have [PutForwards=mediaText]. - [SameObject] readonly attribute MediaList media; + [SameObject, PutForwards=mediaText] readonly attribute MediaList media; attribute boolean disabled; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetCandidate.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetCandidate.cpp index 997c7b14c9..ced5d203f4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetCandidate.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetCandidate.cpp @@ -62,12 +62,6 @@ Document* StyleSheetCandidate::ImportedDocument() const { return ToHTMLLinkElement(GetNode()).import(); } -bool StyleSheetCandidate::IsAlternate() const { - if (!IsElement()) - return false; - return ToElement(GetNode()).getAttribute(relAttr).Contains("alternate"); -} - bool StyleSheetCandidate::IsEnabledViaScript() const { return IsHTMLLink() && ToHTMLLinkElement(GetNode()).IsEnabledViaScript(); } @@ -82,22 +76,7 @@ bool StyleSheetCandidate::CanBeActivated( StyleSheet* sheet = this->Sheet(); if (!sheet || sheet->disabled() || !sheet->IsCSSStyleSheet()) return false; - - if (sheet->ownerNode() && sheet->ownerNode()->IsInShadowTree()) { - if (IsCSSStyle()) - return true; - if (IsHTMLLink() && !IsImport()) - return !IsAlternate(); - } - - const AtomicString& title = this->Title(); - if (!IsEnabledViaScript() && !title.IsEmpty() && - title != current_preferrable_name) - return false; - if (IsAlternate() && title.IsEmpty()) - return false; - - return true; + return ToCSSStyleSheet(Sheet())->CanBeActivated(current_preferrable_name); } StyleSheetCandidate::Type StyleSheetCandidate::TypeOf(Node& node) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetContents.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetContents.cpp index 1c4e5a079f..c493fd0a7a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetContents.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetContents.cpp @@ -27,7 +27,6 @@ #include "core/css/StyleRule.h" #include "core/css/StyleRuleImport.h" #include "core/css/StyleRuleNamespace.h" -#include "core/css/parser/AtRuleDescriptorValueSet.h" #include "core/css/parser/CSSParser.h" #include "core/dom/Document.h" #include "core/dom/Node.h" @@ -530,6 +529,7 @@ static bool ChildRulesHaveFailedOrCanceledSubresources( case StyleRuleBase::kImport: case StyleRuleBase::kNamespace: NOTREACHED(); + break; case StyleRuleBase::kPage: case StyleRuleBase::kKeyframes: case StyleRuleBase::kKeyframe: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.cpp index 8a19919b00..92bff303d2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.cpp @@ -31,8 +31,25 @@ namespace blink { using namespace HTMLNames; +StyleSheetList* StyleSheetList::Create( + const HeapVector>& style_sheet_vector, + ExceptionState& exception_state) { + if (!RuntimeEnabledFeatures::ConstructableStylesheetsEnabled()) { + exception_state.ThrowTypeError("Illegal constructor"); + return nullptr; + } + + return new StyleSheetList(style_sheet_vector); +} + +StyleSheetList::StyleSheetList( + const HeapVector>& style_sheet_vector) + : style_sheet_vector_(style_sheet_vector) {} + StyleSheetList::StyleSheetList(TreeScope* tree_scope) - : tree_scope_(tree_scope) {} + : tree_scope_(tree_scope) { + CHECK(tree_scope); +} inline const HeapVector>& StyleSheetList::StyleSheets() const { @@ -41,10 +58,16 @@ StyleSheetList::StyleSheets() const { } unsigned StyleSheetList::length() { + if (!tree_scope_) + return style_sheet_vector_.size(); return StyleSheets().size(); } StyleSheet* StyleSheetList::item(unsigned index) { + if (!tree_scope_) { + return index < style_sheet_vector_.size() ? style_sheet_vector_[index].Get() + : nullptr; + } const HeapVector>& sheets = StyleSheets(); return index < sheets.size() ? sheets[index].Get() : nullptr; } @@ -78,6 +101,7 @@ CSSStyleSheet* StyleSheetList::AnonymousNamedGetter(const AtomicString& name) { void StyleSheetList::Trace(blink::Visitor* visitor) { visitor->Trace(tree_scope_); + visitor->Trace(style_sheet_vector_); ScriptWrappable::Trace(visitor); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.h index 27e6abed2c..3a70e15883 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.h @@ -37,6 +37,9 @@ class CORE_EXPORT StyleSheetList final : public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); public: + static StyleSheetList* Create(const HeapVector>&, + ExceptionState&); + static StyleSheetList* Create(TreeScope* tree_scope) { return new StyleSheetList(tree_scope); } @@ -55,10 +58,12 @@ class CORE_EXPORT StyleSheetList final : public ScriptWrappable { void Trace(blink::Visitor*); private: + explicit StyleSheetList(const HeapVector>&); explicit StyleSheetList(TreeScope*); const HeapVector>& StyleSheets() const; Member tree_scope_; + HeapVector> style_sheet_vector_; }; } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.idl index 79e97b97cf..a3572d3a87 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetList.idl @@ -22,6 +22,8 @@ // TODO(foolip): StyleSheetList should be an [ArrayClass]. [ + RaisesException=Constructor, + Constructor(sequence sheets), Exposed=Window ] interface StyleSheetList { [Measure] getter StyleSheet? item(unsigned long index); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetListTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetListTest.cpp new file mode 100644 index 0000000000..9ddfcc7057 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/StyleSheetListTest.cpp @@ -0,0 +1,61 @@ +// Copyright 2018 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 "core/css/CSSRuleList.h" +#include "core/css/CSSStyleSheet.h" +#include "core/css/CSSStyleSheetInit.h" +#include "core/css/StyleSheetList.h" +#include "core/testing/PageTestBase.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace blink { + +class StyleSheetListTest : public PageTestBase { + protected: + virtual void SetUp() { + PageTestBase::SetUp(); + RuntimeEnabledFeatures::SetConstructableStylesheetsEnabled(true); + } +}; + +TEST_F(StyleSheetListTest, ConstructorWithoutRuntimeFlagThrowsException) { + DummyExceptionStateForTesting exception_state; + RuntimeEnabledFeatures::SetConstructableStylesheetsEnabled(false); + HeapVector> style_sheet_vector; + EXPECT_EQ(StyleSheetList::Create(style_sheet_vector, exception_state), + nullptr); + ASSERT_TRUE(exception_state.HadException()); +} + +TEST_F(StyleSheetListTest, StyleSheetListConstructionWithEmptyList) { + DummyExceptionStateForTesting exception_state; + HeapVector> style_sheet_vector; + StyleSheetList* sheet_list = + StyleSheetList::Create(style_sheet_vector, exception_state); + ASSERT_FALSE(exception_state.HadException()); + EXPECT_EQ(sheet_list->length(), 0U); +} + +TEST_F(StyleSheetListTest, StyleSheetListConstructionWithNonEmptyList) { + DummyExceptionStateForTesting exception_state; + HeapVector> style_sheet_vector; + CSSStyleSheetInit init; + init.setTitle("Red Sheet"); + CSSStyleSheet* red_style_sheet = CSSStyleSheet::Create( + GetDocument(), ".red { color: red; }", init, exception_state); + init.setTitle("Blue Sheet"); + CSSStyleSheet* blue_style_sheet = CSSStyleSheet::Create( + GetDocument(), ".blue { color: blue; }", init, exception_state); + style_sheet_vector.push_back(red_style_sheet); + style_sheet_vector.push_back(blue_style_sheet); + + StyleSheetList* sheet_list = + StyleSheetList::Create(style_sheet_vector, exception_state); + ASSERT_FALSE(exception_state.HadException()); + EXPECT_EQ(sheet_list->length(), 2U); + EXPECT_EQ(sheet_list->item(0), red_style_sheet); + EXPECT_EQ(sheet_list->item(1), blue_style_sheet); +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSImageValue.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSImageValue.idl index cf3a8ca21a..683bc070e7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSImageValue.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSImageValue.idl @@ -6,11 +6,8 @@ // image types. // https://drafts.css-houdini.org/css-typed-om/#imagevalue-objects [ - Exposed=(Window,PaintWorklet), RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), ImplementedAs=CSSStyleImageValue -] interface CSSImageValue : CSSResourceValue { - readonly attribute double? intrinsicWidth; - readonly attribute double? intrinsicHeight; - readonly attribute double? intrinsicRatio; +] interface CSSImageValue : CSSStyleValue { }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSKeywordValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSKeywordValue.cpp index 23436b601a..e8b806d8e5 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSKeywordValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSKeywordValue.cpp @@ -80,7 +80,7 @@ const CSSValue* CSSKeywordValue::ToCSSValue() const { case (CSSValueInitial): return CSSInitialValue::Create(); case (CSSValueUnset): - return CSSUnsetValue::Create(); + return cssvalue::CSSUnsetValue::Create(); case (CSSValueInvalid): return CSSCustomIdentValue::Create(AtomicString(keyword_value_)); default: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSKeywordValue.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSKeywordValue.idl index 8572fd1776..ae311bfe1d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSKeywordValue.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSKeywordValue.idl @@ -7,7 +7,8 @@ // https://drafts.css-houdini.org/css-typed-om/#keywordvalue-objects [ Constructor(DOMString keyword), - Exposed(Window CSSTypedOM, PaintWorklet CSSTypedOM), + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), RaisesException=Constructor ] interface CSSKeywordValue : CSSStyleValue { [RaisesException=Setter] attribute DOMString value; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.cpp index 9dab9b2870..b1db225743 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.cpp @@ -20,4 +20,17 @@ WTF::Optional CSSMathInvert::SumValue() const { return sum; } +void CSSMathInvert::BuildCSSText(Nested nested, + ParenLess paren_less, + StringBuilder& result) const { + if (paren_less == ParenLess::kNo) + result.Append(nested == Nested::kYes ? "(" : "calc("); + + result.Append("1 / "); + value_->BuildCSSText(Nested::kYes, ParenLess::kNo, result); + + if (paren_less == ParenLess::kNo) + result.Append(")"); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.h index 1206ea570d..d8d7753cf0 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.h @@ -29,9 +29,9 @@ class CORE_EXPORT CSSMathInvert : public CSSMathValue { String getOperator() const final { return "invert"; } void value(CSSNumberish& value) { value.SetCSSNumericValue(value_); } - void setValue(const CSSNumberish& value) { - value_ = CSSNumericValue::FromNumberish(value); - } + + // Blink-internal methods + const CSSNumericValue& Value() const { return *value_; } // From CSSStyleValue. StyleValueType GetType() const final { return CSSStyleValue::kInvertType; } @@ -63,6 +63,8 @@ class CORE_EXPORT CSSMathInvert : public CSSMathValue { CSSNumericValue* Invert() final { return value_.Get(); } WTF::Optional SumValue() const final; + void BuildCSSText(Nested, ParenLess, StringBuilder&) const final; + Member value_; DISALLOW_COPY_AND_ASSIGN(CSSMathInvert); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.idl index 032e80a70e..8827862c6b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathInvert.idl @@ -6,8 +6,8 @@ // https://drafts.css-houdini.org/css-typed-om-1/#cssmathinvert [ Constructor(CSSNumberish arg), - Exposed=(Window,PaintWorklet), - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet) ] interface CSSMathInvert : CSSMathValue { - attribute CSSNumberish value; + readonly attribute CSSNumberish value; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.cpp index 74c24751ea..8fb43e6d32 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.cpp @@ -50,4 +50,20 @@ WTF::Optional CSSMathMax::SumValue() const { return cur_max; } +void CSSMathMax::BuildCSSText(Nested, ParenLess, StringBuilder& result) const { + result.Append("max("); + + bool first_iteration = true; + for (const auto& value : NumericValues()) { + if (!first_iteration) + result.Append(", "); + first_iteration = false; + + DCHECK(value); + value->BuildCSSText(Nested::kYes, ParenLess::kYes, result); + } + + result.Append(")"); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.h index 4436f3466d..d1513ce86e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.h @@ -36,6 +36,8 @@ class CORE_EXPORT CSSMathMax final : public CSSMathVariadic { CSSMathMax(CSSNumericArray* values, const CSSNumericValueType& type) : CSSMathVariadic(values, type) {} + void BuildCSSText(Nested, ParenLess, StringBuilder&) const final; + WTF::Optional SumValue() const final; DISALLOW_COPY_AND_ASSIGN(CSSMathMax); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.idl index 51815d3c2a..702528f30d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMax.idl @@ -6,9 +6,9 @@ // https://drafts.css-houdini.org/css-typed-om-1/#cssmathsum [ Constructor(CSSNumberish... args), - Exposed=(Window,PaintWorklet), - RaisesException=Constructor, - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), + RaisesException=Constructor ] interface CSSMathMax : CSSMathValue { - attribute CSSNumericArray values; + readonly attribute CSSNumericArray values; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.cpp index b16837000a..09c07d3b78 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.cpp @@ -50,4 +50,19 @@ WTF::Optional CSSMathMin::SumValue() const { return cur_min; } +void CSSMathMin::BuildCSSText(Nested, ParenLess, StringBuilder& result) const { + result.Append("min("); + + bool first_iteration = true; + for (const auto& value : NumericValues()) { + if (!first_iteration) + result.Append(", "); + first_iteration = false; + + value->BuildCSSText(Nested::kYes, ParenLess::kYes, result); + } + + result.Append(")"); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.h index b6f267524e..5f690f422a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.h @@ -38,6 +38,8 @@ class CORE_EXPORT CSSMathMin final : public CSSMathVariadic { CSSMathMin(CSSNumericArray* values, const CSSNumericValueType& type) : CSSMathVariadic(values, type) {} + void BuildCSSText(Nested, ParenLess, StringBuilder&) const final; + WTF::Optional SumValue() const final; DISALLOW_COPY_AND_ASSIGN(CSSMathMin); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.idl index a1598f9b8f..3a500ef2fd 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathMin.idl @@ -6,9 +6,9 @@ // https://drafts.css-houdini.org/css-typed-om-1/#cssmathsum [ Constructor(CSSNumberish... args), - Exposed=(Window,PaintWorklet), - RaisesException=Constructor, - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), + RaisesException=Constructor ] interface CSSMathMin : CSSMathValue { - attribute CSSNumericArray values; + readonly attribute CSSNumericArray values; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.cpp index 59dbfaddda..99ccf2a3b2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.cpp @@ -18,4 +18,17 @@ WTF::Optional CSSMathNegate::SumValue() const { return maybe_sum; } +void CSSMathNegate::BuildCSSText(Nested nested, + ParenLess paren_less, + StringBuilder& result) const { + if (paren_less == ParenLess::kNo) + result.Append(nested == Nested::kYes ? "(" : "calc("); + + result.Append("-"); + value_->BuildCSSText(Nested::kYes, ParenLess::kNo, result); + + if (paren_less == ParenLess::kNo) + result.Append(")"); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.h index d7ca783fd8..3552fc366b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.h @@ -28,9 +28,9 @@ class CORE_EXPORT CSSMathNegate : public CSSMathValue { String getOperator() const final { return "negate"; } void value(CSSNumberish& value) { value.SetCSSNumericValue(value_); } - void setValue(const CSSNumberish& value) { - value_ = CSSNumericValue::FromNumberish(value); - } + + // Blink-internal methods + const CSSNumericValue& Value() const { return *value_; } // From CSSStyleValue. StyleValueType GetType() const final { return CSSStyleValue::kNegateType; } @@ -62,6 +62,8 @@ class CORE_EXPORT CSSMathNegate : public CSSMathValue { CSSNumericValue* Negate() final { return value_.Get(); } WTF::Optional SumValue() const final; + void BuildCSSText(Nested, ParenLess, StringBuilder&) const final; + Member value_; DISALLOW_COPY_AND_ASSIGN(CSSMathNegate); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.idl index 148146283a..971cad73d9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathNegate.idl @@ -6,8 +6,8 @@ // https://drafts.css-houdini.org/css-typed-om-1/#cssmathnegate [ Constructor(CSSNumberish arg), - Exposed=(Window,PaintWorklet), - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet) ] interface CSSMathNegate : CSSMathValue { - attribute CSSNumberish value; + readonly attribute CSSNumberish value; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.cpp index 892b6e850f..5bfaaa6fe4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.cpp @@ -5,6 +5,7 @@ #include "core/css/cssom/CSSMathProduct.h" #include "core/css/CSSCalculationValue.h" +#include "core/css/cssom/CSSMathInvert.h" namespace blink { @@ -94,4 +95,30 @@ CSSCalcExpressionNode* CSSMathProduct::ToCalcExpressionNode() const { return node; } +void CSSMathProduct::BuildCSSText(Nested nested, + ParenLess paren_less, + StringBuilder& result) const { + if (paren_less == ParenLess::kNo) + result.Append(nested == Nested::kYes ? "(" : "calc("); + + const auto& values = NumericValues(); + DCHECK(!values.IsEmpty()); + values[0]->BuildCSSText(Nested::kYes, ParenLess::kNo, result); + + for (size_t i = 1; i < values.size(); i++) { + const auto& arg = *values[i]; + if (arg.GetType() == CSSStyleValue::kInvertType) { + result.Append(" / "); + static_cast(arg).Value().BuildCSSText( + Nested::kYes, ParenLess::kNo, result); + } else { + result.Append(" * "); + arg.BuildCSSText(Nested::kYes, ParenLess::kNo, result); + } + } + + if (paren_less == ParenLess::kNo) + result.Append(")"); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.h index c6498ca24b..ca98802903 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.h @@ -33,6 +33,8 @@ class CORE_EXPORT CSSMathProduct final : public CSSMathVariadic { CSSMathProduct(CSSNumericArray* values, const CSSNumericValueType& type) : CSSMathVariadic(values, type) {} + void BuildCSSText(Nested, ParenLess, StringBuilder&) const final; + WTF::Optional SumValue() const final; DISALLOW_COPY_AND_ASSIGN(CSSMathProduct); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.idl index 8b4e6a42f4..f5628311e2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathProduct.idl @@ -6,9 +6,9 @@ // https://drafts.css-houdini.org/css-typed-om-1/#cssmathsub [ Constructor(CSSNumberish... args), - Exposed=(Window,PaintWorklet), - RaisesException=Constructor, - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), + RaisesException=Constructor ] interface CSSMathProduct : CSSMathValue { - attribute CSSNumericArray values; + readonly attribute CSSNumericArray values; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.cpp index 497d86cb2e..f774fc793c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.cpp @@ -5,6 +5,7 @@ #include "core/css/cssom/CSSMathSum.h" #include "core/css/CSSCalculationValue.h" +#include "core/css/cssom/CSSMathNegate.h" namespace blink { @@ -112,4 +113,30 @@ CSSCalcExpressionNode* CSSMathSum::ToCalcExpressionNode() const { return node; } +void CSSMathSum::BuildCSSText(Nested nested, + ParenLess paren_less, + StringBuilder& result) const { + if (paren_less == ParenLess::kNo) + result.Append(nested == Nested::kYes ? "(" : "calc("); + + const auto& values = NumericValues(); + DCHECK(!values.IsEmpty()); + values[0]->BuildCSSText(Nested::kYes, ParenLess::kNo, result); + + for (size_t i = 1; i < values.size(); i++) { + const auto& arg = *values[i]; + if (arg.GetType() == CSSStyleValue::kNegateType) { + result.Append(" - "); + static_cast(arg).Value().BuildCSSText( + Nested::kYes, ParenLess::kNo, result); + } else { + result.Append(" + "); + arg.BuildCSSText(Nested::kYes, ParenLess::kNo, result); + } + } + + if (paren_less == ParenLess::kNo) + result.Append(")"); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.h index 83954213f5..b6898055db 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.h @@ -33,6 +33,8 @@ class CORE_EXPORT CSSMathSum final : public CSSMathVariadic { CSSMathSum(CSSNumericArray* values, const CSSNumericValueType& type) : CSSMathVariadic(values, type) {} + void BuildCSSText(Nested, ParenLess, StringBuilder&) const final; + WTF::Optional SumValue() const final; DISALLOW_COPY_AND_ASSIGN(CSSMathSum); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.idl index e49fc1513d..a6429ac4b7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathSum.idl @@ -6,9 +6,9 @@ // https://drafts.css-houdini.org/css-typed-om-1/#cssmathsum [ Constructor(CSSNumberish... args), - Exposed=(Window,PaintWorklet), - RaisesException=Constructor, - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), + RaisesException=Constructor ] interface CSSMathSum : CSSMathValue { - attribute CSSNumericArray values; + readonly attribute CSSNumericArray values; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathValue.h index c3924eddd7..176f1d91fa 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathValue.h @@ -22,11 +22,6 @@ class CORE_EXPORT CSSMathValue : public CSSNumericValue { bool IsUnitValue() const final { return false; } // From CSSStyleValue. - bool ContainsPercent() const final { - // TODO(776173): Implement - return false; - } - const CSSValue* ToCSSValue() const final; protected: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathValue.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathValue.idl index c6dc854647..c9d7bc5369 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathValue.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathValue.idl @@ -14,8 +14,8 @@ enum CSSMathOperator { }; [ - Exposed=(Window,PaintWorklet), - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet) ] interface CSSMathValue : CSSNumericValue { [ImplementedAs=getOperator] readonly attribute CSSMathOperator operator; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathVariadic.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathVariadic.h index 89e94a143c..e618eb4532 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathVariadic.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMathVariadic.h @@ -16,7 +16,6 @@ class CORE_EXPORT CSSMathVariadic : public CSSMathValue { public: CSSNumericArray* values() { return values_.Get(); } - void setValues(CSSNumericArray* values) { values_ = values; } const CSSNumericValueVector& NumericValues() const { return values_->Values(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.cpp index 14623bad86..071c738655 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.cpp @@ -33,11 +33,10 @@ CSSMatrixComponent* CSSMatrixComponent::Create( matrix, options.hasIs2D() ? options.is2D() : matrix->is2D()); } -const DOMMatrix* CSSMatrixComponent::AsMatrix(ExceptionState&) const { +DOMMatrix* CSSMatrixComponent::toMatrix(ExceptionState&) const { if (is2D() && !matrix_->is2D()) return To2DMatrix(matrix_); - - return matrix_.Get(); + return DOMMatrix::Create(matrix_.Get()); } CSSMatrixComponent* CSSMatrixComponent::FromCSSValue( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.h index 4b91e35200..82d9f42561 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.h @@ -32,9 +32,10 @@ class CORE_EXPORT CSSMatrixComponent final : public CSSTransformComponent { DOMMatrix* matrix() { return matrix_.Get(); } void setMatrix(DOMMatrix* matrix) { matrix_ = matrix; } + DOMMatrix* toMatrix(ExceptionState&) const final; + // Internal methods - from CSSTransformComponent. TransformComponentType GetType() const final { return kMatrixType; } - const DOMMatrix* AsMatrix(ExceptionState&) const final; const CSSFunctionValue* ToCSSValue() const final; virtual void Trace(blink::Visitor* visitor) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.idl index 4ffa517d59..5db9a74e3f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSMatrixComponent.idl @@ -8,8 +8,8 @@ [ Constructor(DOMMatrixReadOnly matrix, optional CSSMatrixComponentOptions options), - Exposed=(Window,PaintWorklet), - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet) ] interface CSSMatrixComponent : CSSTransformComponent { attribute DOMMatrix matrix; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericArray.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericArray.idl index 4c1d858c31..1789d9ba04 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericArray.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericArray.idl @@ -5,10 +5,11 @@ // Represents the sum of one or more CSSNumericValues. // https://drafts.css-houdini.org/css-typed-om-1/#cssmathsum [ - Exposed=(Window,PaintWorklet), - RaisesException=Constructor, - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), + RaisesException=Constructor ] interface CSSNumericArray { + iterable; readonly attribute unsigned long length; getter CSSNumericValue(unsigned long index); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericType.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericType.idl new file mode 100644 index 0000000000..725518bab0 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericType.idl @@ -0,0 +1,30 @@ +// Copyright 2018 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. + +[ + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet) +] enum CSSNumericBaseType { + "length", + "angle", + "time", + "frequency", + "resolution", + "flex", + "percent", +}; + +// https://drafts.css-houdini.org/css-typed-om-1/#cssnumerictype +[ + Exposed=(Window,LayoutWorklet,PaintWorklet) +] dictionary CSSNumericType { + long length; + long angle; + long time; + long frequency; + long resolution; + long flex; + long percent; + CSSNumericBaseType percentHint; +}; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.cpp index e548fc1e38..53dd807a79 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.cpp @@ -228,6 +228,7 @@ CSSNumericValue* CSSNumericValue::parse(const String& css_text, DCHECK(calc_value->ExpressionNode()); return CalcToNumericValue(*calc_value->ExpressionNode()); } + break; default: break; } @@ -357,6 +358,29 @@ CSSMathSum* CSSNumericValue::toSum(const Vector& unit_strings, return value; } +void CSSNumericValue::type(CSSNumericType& type) const { + using BaseType = CSSNumericValueType::BaseType; + + if (int exponent = type_.Exponent(BaseType::kLength)) + type.setLength(exponent); + if (int exponent = type_.Exponent(BaseType::kAngle)) + type.setAngle(exponent); + if (int exponent = type_.Exponent(BaseType::kTime)) + type.setTime(exponent); + if (int exponent = type_.Exponent(BaseType::kFrequency)) + type.setFrequency(exponent); + if (int exponent = type_.Exponent(BaseType::kResolution)) + type.setResolution(exponent); + if (int exponent = type_.Exponent(BaseType::kFlex)) + type.setFlex(exponent); + if (int exponent = type_.Exponent(BaseType::kPercent)) + type.setPercent(exponent); + if (type_.HasPercentHint()) { + type.setPercentHint( + CSSNumericValueType::BaseTypeToString(type_.PercentHint())); + } +} + CSSNumericValue* CSSNumericValue::add( const HeapVector& numberishes, ExceptionState& exception_state) { @@ -400,8 +424,15 @@ CSSNumericValue* CSSNumericValue::div( const HeapVector& numberishes, ExceptionState& exception_state) { auto values = CSSNumberishesToNumericValues(numberishes); - std::transform(values.begin(), values.end(), values.begin(), - [](CSSNumericValue* v) { return v->Invert(); }); + for (auto& v : values) { + auto invert_value = v->Invert(); + if (!invert_value) { + exception_state.ThrowRangeError("Can't divide-by-zero"); + return nullptr; + } + v = invert_value; + } + PrependValueForArithmetic(values, this); if (CSSUnitValue* unit_value = MaybeMultiplyAsUnitValue(values)) @@ -441,6 +472,12 @@ bool CSSNumericValue::equals(const HeapVector& args) { [this](const auto& v) { return this->Equals(*v); }); } +String CSSNumericValue::toString() const { + StringBuilder result; + BuildCSSText(Nested::kNo, ParenLess::kNo, result); + return result.ToString(); +} + CSSNumericValue* CSSNumericValue::Negate() { return CSSMathNegate::Create(this); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.h index b3d2d49156..76962e1976 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.h @@ -10,6 +10,7 @@ #include "core/CoreExport.h" #include "core/css/CSSPrimitiveValue.h" #include "core/css/cssom/CSSNumericSumValue.h" +#include "core/css/cssom/CSSNumericType.h" #include "core/css/cssom/CSSNumericValueType.h" #include "core/css/cssom/CSSStyleValue.h" #include "platform/bindings/ScriptWrappable.h" @@ -49,6 +50,10 @@ class CORE_EXPORT CSSNumericValue : public CSSStyleValue { CSSUnitValue* to(const String&, ExceptionState&); CSSMathSum* toSum(const Vector&, ExceptionState&); + void type(CSSNumericType&) const; + + String toString() const final; + // Internal methods. // Arithmetic virtual CSSNumericValue* Negate(); @@ -64,6 +69,10 @@ class CORE_EXPORT CSSNumericValue : public CSSStyleValue { virtual CSSCalcExpressionNode* ToCalcExpressionNode() const = 0; + enum class Nested : bool { kYes, kNo }; + enum class ParenLess : bool { kYes, kNo }; + virtual void BuildCSSText(Nested, ParenLess, StringBuilder&) const = 0; + protected: static bool IsValidUnit(CSSPrimitiveValue::UnitType); static CSSPrimitiveValue::UnitType UnitFromName(const String& name); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.idl index 10c1e136c6..41cc26cf96 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.idl @@ -7,7 +7,8 @@ typedef (double or CSSNumericValue) CSSNumberish; [ - Exposed(Window CSSTypedOM, PaintWorklet CSSTypedOM) + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet) ] interface CSSNumericValue : CSSStyleValue { [RaisesException, NewObject] CSSNumericValue add(CSSNumberish... values); [RaisesException, NewObject] CSSNumericValue sub(CSSNumberish... values); @@ -20,6 +21,7 @@ typedef (double or CSSNumericValue) CSSNumberish; [RaisesException, NewObject] CSSUnitValue to(DOMString unit); [RaisesException, NewObject] CSSMathSum toSum(DOMString... units); + CSSNumericType type(); // Putting Exposed=Window in the next line makes |parse| not exposed to PaintWorklet. [RaisesException, NewObject, Exposed=Window] static CSSNumericValue parse(DOMString cssText); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueType.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueType.cpp index eb8b20c366..2da9dc0717 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueType.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueType.cpp @@ -61,6 +61,30 @@ CSSNumericValueType::BaseType UnitTypeToBaseType( } // namespace +AtomicString CSSNumericValueType::BaseTypeToString(BaseType base_type) { + switch (base_type) { + case BaseType::kLength: + return "length"; + case BaseType::kAngle: + return "angle"; + case BaseType::kTime: + return "time"; + case BaseType::kFrequency: + return "frequency"; + case BaseType::kResolution: + return "resolution"; + case BaseType::kFlex: + return "flex"; + case BaseType::kPercent: + return "percent"; + default: + break; + } + + NOTREACHED(); + return ""; +} + CSSNumericValueType::CSSNumericValueType(CSSPrimitiveValue::UnitType unit) { if (unit != CSSPrimitiveValue::UnitType::kNumber) SetExponent(UnitTypeToBaseType(unit), 1); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueType.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueType.h index 971e8cc492..1a939c7dab 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueType.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueType.h @@ -30,6 +30,8 @@ class CORE_EXPORT CSSNumericValueType { static constexpr unsigned kNumBaseTypes = static_cast(BaseType::kNumBaseTypes); + static AtomicString BaseTypeToString(BaseType); + explicit CSSNumericValueType( CSSPrimitiveValue::UnitType = CSSPrimitiveValue::UnitType::kNumber); CSSNumericValueType(int exponent, CSSPrimitiveValue::UnitType); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueTypeTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueTypeTest.cpp index e1382a3ab8..4ea0f294c7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueTypeTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSNumericValueTypeTest.cpp @@ -25,183 +25,6 @@ TEST(CSSNumericValueType, ApplyingPercentHintMovesPowerAndSetsPercentHint) { EXPECT_EQ(BaseType::kLength, type.PercentHint()); } -TEST(CSSNumericValueType, AddingDifferentNonNullTypeHintsIsError) { - // { *length: 0 } + { *time: 0 } == failure - CSSNumericValueType type1; - type1.ApplyPercentHint(BaseType::kTime); - EXPECT_EQ(BaseType::kTime, type1.PercentHint()); - - CSSNumericValueType type2; - type2.ApplyPercentHint(BaseType::kLength); - EXPECT_EQ(BaseType::kLength, type2.PercentHint()); - - bool error = false; - CSSNumericValueType::Add(type1, type2, error); - EXPECT_TRUE(error); -} - -TEST(CSSNumericValueType, AddingSameTypeRetainsSamePower) { - // { length: 1 } + { length: 1 } == { length: 1 } - const CSSNumericValueType type1(UnitType::kPixels); - const CSSNumericValueType type2(UnitType::kCentimeters); - - bool error = true; - const auto result = CSSNumericValueType::Add(type1, type2, error); - EXPECT_FALSE(error); - - EXPECT_EQ(1, result.Exponent(BaseType::kLength)); - EXPECT_FALSE(result.HasPercentHint()); -} - -TEST(CSSNumericValueType, AddingPercentRetainsPowersAndSetsTypeHint) { - // { length: 1 } + { percent: 1 } == { *length: 1 } - const CSSNumericValueType type1(UnitType::kPixels); - EXPECT_FALSE(type1.HasPercentHint()); - - const CSSNumericValueType type2(UnitType::kPercentage); - EXPECT_FALSE(type2.HasPercentHint()); - - bool error = true; - const auto result = CSSNumericValueType::Add(type1, type2, error); - EXPECT_FALSE(error); - - EXPECT_EQ(1, result.Exponent(BaseType::kLength)); - ASSERT_TRUE(result.HasPercentHint()); - EXPECT_EQ(BaseType::kLength, result.PercentHint()); -} - -TEST(CSSNumericValueType, - AddingSameTypeWithTypeHintRetainsPowersAndSetsTypeHint) { - // { length: 1 } + { *length: 1 } == { *length: 1 } - const CSSNumericValueType type1(UnitType::kPixels); - EXPECT_FALSE(type1.HasPercentHint()); - - CSSNumericValueType type2; - type2.ApplyPercentHint(BaseType::kLength); - type2.SetExponent(BaseType::kLength, 1); - ASSERT_TRUE(type2.HasPercentHint()); - EXPECT_EQ(BaseType::kLength, type2.PercentHint()); - - bool error = true; - const auto result = CSSNumericValueType::Add(type1, type2, error); - EXPECT_FALSE(error); - - EXPECT_EQ(1, result.Exponent(BaseType::kLength)); - ASSERT_TRUE(result.HasPercentHint()); - EXPECT_EQ(BaseType::kLength, result.PercentHint()); -} - -TEST(CSSNumericValueType, - AddingSameTypeAndSameTypeHintRetainsPowersAndTypeHint) { - // { *length: 1 } + { *length: 1 } == { *length: 1 } - CSSNumericValueType type1; - type1.ApplyPercentHint(BaseType::kLength); - type1.SetExponent(BaseType::kLength, 1); - ASSERT_TRUE(type1.HasPercentHint()); - EXPECT_EQ(BaseType::kLength, type1.PercentHint()); - - CSSNumericValueType type2; - type2.ApplyPercentHint(BaseType::kLength); - type2.SetExponent(BaseType::kLength, 1); - ASSERT_TRUE(type2.HasPercentHint()); - EXPECT_EQ(BaseType::kLength, type2.PercentHint()); - - bool error = true; - const auto result = CSSNumericValueType::Add(type1, type2, error); - EXPECT_FALSE(error); - - EXPECT_EQ(1, result.Exponent(BaseType::kLength)); - ASSERT_TRUE(result.HasPercentHint()); - EXPECT_EQ(BaseType::kLength, result.PercentHint()); -} - -TEST(CSSNumericValueType, AdditionRequiringApplyingPercentHint) { - // { *length: 1, time: 2 } + { time: 2, percent: 1 } == { *length: 1, time: 2 - // } - CSSNumericValueType type1(UnitType::kPercentage); - type1.ApplyPercentHint(BaseType::kLength); - type1.SetExponent(BaseType::kTime, 2); - EXPECT_EQ(1, type1.Exponent(BaseType::kLength)); - EXPECT_EQ(2, type1.Exponent(BaseType::kTime)); - ASSERT_TRUE(type1.HasPercentHint()); - EXPECT_EQ(BaseType::kLength, type1.PercentHint()); - - CSSNumericValueType type2(UnitType::kPercentage); - type2.SetExponent(BaseType::kTime, 2); - EXPECT_EQ(2, type2.Exponent(BaseType::kTime)); - EXPECT_EQ(1, type2.Exponent(BaseType::kPercent)); - EXPECT_FALSE(type2.HasPercentHint()); - - bool error = true; - const auto result = CSSNumericValueType::Add(type1, type2, error); - EXPECT_FALSE(error); - - EXPECT_EQ(1, result.Exponent(BaseType::kLength)); - EXPECT_EQ(2, result.Exponent(BaseType::kTime)); - ASSERT_TRUE(result.HasPercentHint()); - EXPECT_EQ(BaseType::kLength, result.PercentHint()); -} - -TEST(CSSNumericValueType, ImpossibleAdditionWithPercentHints) { - // { *length: 1, time: 3 } + { time: 2, percent: 2 } == failure - CSSNumericValueType type1(UnitType::kPercentage); - type1.ApplyPercentHint(BaseType::kLength); - type1.SetExponent(BaseType::kTime, 3); - EXPECT_EQ(1, type1.Exponent(BaseType::kLength)); - EXPECT_EQ(3, type1.Exponent(BaseType::kTime)); - ASSERT_TRUE(type1.HasPercentHint()); - EXPECT_EQ(BaseType::kLength, type1.PercentHint()); - - CSSNumericValueType type2; - type2.SetExponent(BaseType::kPercent, 2); - type2.SetExponent(BaseType::kTime, 2); - EXPECT_EQ(2, type2.Exponent(BaseType::kTime)); - EXPECT_EQ(2, type2.Exponent(BaseType::kPercent)); - EXPECT_FALSE(type2.HasPercentHint()); - - bool error = false; - CSSNumericValueType::Add(type1, type2, error); - EXPECT_TRUE(error); -} - -TEST(CSSNumericValueType, MultiplyDifferentNonNullTypeHintsIsError) { - // { *length: 0 } * { *time: 0 } == failure - CSSNumericValueType type1; - type1.ApplyPercentHint(BaseType::kTime); - EXPECT_EQ(BaseType::kTime, type1.PercentHint()); - - CSSNumericValueType type2; - type2.ApplyPercentHint(BaseType::kLength); - EXPECT_EQ(BaseType::kLength, type2.PercentHint()); - - bool error = false; - CSSNumericValueType::Multiply(type1, type2, error); - EXPECT_TRUE(error); -} - -TEST(CSSNumericValueType, MultiplyAddsPowersAndSetsPercentHint) { - // { length: 2, time: 1 } * { length: 3, angle*: 2 } == { length: 5, time: 1, - // angle: 2 } - CSSNumericValueType type1; - type1.SetExponent(BaseType::kLength, 2); - type1.SetExponent(BaseType::kTime, 1); - - CSSNumericValueType type2; - type2.ApplyPercentHint(BaseType::kAngle); - type2.SetExponent(BaseType::kLength, 3); - type2.SetExponent(BaseType::kAngle, 2); - - bool error = true; - const auto result = CSSNumericValueType::Multiply(type1, type2, error); - ASSERT_FALSE(error); - - EXPECT_EQ(5, result.Exponent(BaseType::kLength)); - EXPECT_EQ(1, result.Exponent(BaseType::kTime)); - EXPECT_EQ(2, result.Exponent(BaseType::kAngle)); - ASSERT_TRUE(result.HasPercentHint()); - EXPECT_EQ(BaseType::kAngle, result.PercentHint()); -} - TEST(CSSNumericValueType, MatchesBaseTypePercentage) { CSSNumericValueType type; EXPECT_FALSE(type.MatchesBaseType(BaseType::kLength)); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.cpp index cf415d6d0b..7245d92f51 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.cpp @@ -5,6 +5,7 @@ #include "core/css/cssom/CSSPerspective.h" #include "bindings/core/v8/ExceptionState.h" +#include "core/css/CSSCalculationValue.h" #include "core/css/cssom/CSSUnitValue.h" #include "core/geometry/DOMMatrix.h" @@ -45,8 +46,7 @@ CSSPerspective* CSSPerspective::FromCSSValue(const CSSFunctionValue& value) { return new CSSPerspective(length); } -const DOMMatrix* CSSPerspective::AsMatrix( - ExceptionState& exception_state) const { +DOMMatrix* CSSPerspective::toMatrix(ExceptionState& exception_state) const { if (length_->IsUnitValue() && ToCSSUnitValue(length_)->value() < 0) { // Negative values are invalid. // https://github.com/w3c/css-houdini-drafts/issues/420 @@ -64,15 +64,17 @@ const DOMMatrix* CSSPerspective::AsMatrix( } const CSSFunctionValue* CSSPerspective::ToCSSValue() const { + const CSSValue* length = nullptr; if (length_->IsUnitValue() && ToCSSUnitValue(length_)->value() < 0) { - // Negative values are invalid. - // https://github.com/w3c/css-houdini-drafts/issues/420 - return nullptr; + // Wrap out of range length with a calc. + CSSCalcExpressionNode* node = length_->ToCalcExpressionNode(); + node->SetIsNestedCalc(); + length = CSSPrimitiveValue::Create(CSSCalcValue::Create(node)); + } else { + length = length_->ToCSSValue(); } - const CSSValue* length = length_->ToCSSValue(); - if (!length) - return nullptr; + DCHECK(length); CSSFunctionValue* result = CSSFunctionValue::Create(CSSValuePerspective); result->Append(*length); return result; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.h index 31479e4a1e..f2d0c4359d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.h @@ -37,9 +37,10 @@ class CORE_EXPORT CSSPerspective final : public CSSTransformComponent { // https://drafts.css-houdini.org/css-typed-om/#dom-cssskew-is2d void setIs2D(bool is2D) final {} + DOMMatrix* toMatrix(ExceptionState&) const final; + // Internal methods - from CSSTransformComponent. TransformComponentType GetType() const final { return kPerspectiveType; } - const DOMMatrix* AsMatrix(ExceptionState&) const final; const CSSFunctionValue* ToCSSValue() const final; virtual void Trace(blink::Visitor* visitor) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.idl index 87b7b7e6b8..2fbea49132 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPerspective.idl @@ -7,8 +7,8 @@ // Spec: https://drafts.css-houdini.org/css-typed-om/#cssperspective [ Constructor(CSSNumericValue length), - Exposed=(Window,PaintWorklet), RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), RaisesException=Constructor ] interface CSSPerspective : CSSTransformComponent { [RaisesException=Setter] attribute CSSNumericValue length; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPositionValue.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPositionValue.idl index 6efa07397e..0edf3262f8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPositionValue.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSPositionValue.idl @@ -7,7 +7,8 @@ // Spec: https://drafts.css-houdini.org/css-typed-om/#positionvalue-objects [ Constructor(CSSNumericValue x, CSSNumericValue y), - Exposed(Window CSSTypedOM, PaintWorklet CSSTypedOM), + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), RaisesException=Constructor ] interface CSSPositionValue : CSSStyleValue { [RaisesException=Setter] attribute CSSNumericValue x; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSResourceValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSResourceValue.h index 1447329cd8..39526f511f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSResourceValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSResourceValue.h @@ -12,8 +12,6 @@ namespace blink { class CORE_EXPORT CSSResourceValue : public CSSStyleValue { - DEFINE_WRAPPERTYPEINFO(); - public: virtual ~CSSResourceValue() = default; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSRotate.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSRotate.cpp new file mode 100644 index 0000000000..d6b8019aa3 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSRotate.cpp @@ -0,0 +1,228 @@ +// 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 "core/css/cssom/CSSRotate.h" + +#include "bindings/core/v8/ExceptionState.h" +#include "core/css/CSSFunctionValue.h" +#include "core/css/CSSPrimitiveValue.h" +#include "core/css/cssom/CSSUnitValue.h" +#include "core/geometry/DOMMatrix.h" + +namespace blink { + +namespace { + +bool IsValidRotateCoord(const CSSNumericValue* value) { + return value && value->Type().MatchesNumber(); +} + +bool IsValidRotateAngle(const CSSNumericValue* value) { + return value && + value->Type().MatchesBaseType(CSSNumericValueType::BaseType::kAngle); +} + +CSSRotate* FromCSSRotate(const CSSFunctionValue& value) { + DCHECK_EQ(value.length(), 1UL); + CSSNumericValue* angle = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(0))); + return CSSRotate::Create(angle); +} + +CSSRotate* FromCSSRotate3d(const CSSFunctionValue& value) { + DCHECK_EQ(value.length(), 4UL); + + CSSNumericValue* x = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(0))); + CSSNumericValue* y = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(1))); + CSSNumericValue* z = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(2))); + CSSNumericValue* angle = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(3))); + + return CSSRotate::Create(x, y, z, angle); +} + +CSSRotate* FromCSSRotateXYZ(const CSSFunctionValue& value) { + DCHECK_EQ(value.length(), 1UL); + + CSSNumericValue* angle = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(0))); + + switch (value.FunctionType()) { + case CSSValueRotateX: + return CSSRotate::Create(CSSUnitValue::Create(1), CSSUnitValue::Create(0), + CSSUnitValue::Create(0), angle); + case CSSValueRotateY: + return CSSRotate::Create(CSSUnitValue::Create(0), CSSUnitValue::Create(1), + CSSUnitValue::Create(0), angle); + case CSSValueRotateZ: + return CSSRotate::Create(CSSUnitValue::Create(0), CSSUnitValue::Create(0), + CSSUnitValue::Create(1), angle); + default: + NOTREACHED(); + return nullptr; + } +} + +} // namespace + +CSSRotate* CSSRotate::Create(CSSNumericValue* angle, + ExceptionState& exception_state) { + if (!IsValidRotateAngle(angle)) { + exception_state.ThrowTypeError("Must pass an angle to CSSRotate"); + return nullptr; + } + return new CSSRotate(CSSUnitValue::Create(0), CSSUnitValue::Create(0), + CSSUnitValue::Create(1), angle, true /* is2D */); +} + +CSSRotate* CSSRotate::Create(const CSSNumberish& x, + const CSSNumberish& y, + const CSSNumberish& z, + CSSNumericValue* angle, + ExceptionState& exception_state) { + CSSNumericValue* x_value = CSSNumericValue::FromNumberish(x); + CSSNumericValue* y_value = CSSNumericValue::FromNumberish(y); + CSSNumericValue* z_value = CSSNumericValue::FromNumberish(z); + + if (!IsValidRotateCoord(x_value) || !IsValidRotateCoord(y_value) || + !IsValidRotateCoord(z_value)) { + exception_state.ThrowTypeError("Must specify an number unit"); + return nullptr; + } + if (!IsValidRotateAngle(angle)) { + exception_state.ThrowTypeError("Must pass an angle to CSSRotate"); + return nullptr; + } + return new CSSRotate(x_value, y_value, z_value, angle, false /* is2D */); +} + +CSSRotate* CSSRotate::Create(CSSNumericValue* angle) { + return new CSSRotate(CSSUnitValue::Create(0), CSSUnitValue::Create(0), + CSSUnitValue::Create(1), angle, true /* is2D */); +} + +CSSRotate* CSSRotate::Create(CSSNumericValue* x, + CSSNumericValue* y, + CSSNumericValue* z, + CSSNumericValue* angle) { + return new CSSRotate(x, y, z, angle, false /* is2D */); +} + +CSSRotate* CSSRotate::FromCSSValue(const CSSFunctionValue& value) { + switch (value.FunctionType()) { + case CSSValueRotate: + return FromCSSRotate(value); + case CSSValueRotate3d: + return FromCSSRotate3d(value); + case CSSValueRotateX: + case CSSValueRotateY: + case CSSValueRotateZ: + return FromCSSRotateXYZ(value); + default: + NOTREACHED(); + return nullptr; + } +} + +void CSSRotate::setAngle(CSSNumericValue* angle, + ExceptionState& exception_state) { + if (!IsValidRotateAngle(angle)) { + exception_state.ThrowTypeError("Must pass an angle to CSSRotate"); + return; + } + angle_ = angle; +} + +DOMMatrix* CSSRotate::toMatrix(ExceptionState& exception_state) const { + CSSUnitValue* x = x_->to(CSSPrimitiveValue::UnitType::kNumber); + CSSUnitValue* y = y_->to(CSSPrimitiveValue::UnitType::kNumber); + CSSUnitValue* z = z_->to(CSSPrimitiveValue::UnitType::kNumber); + if (!x || !y || !z) { + exception_state.ThrowTypeError( + "Cannot create matrix if units cannot be converted to CSSUnitValue"); + return nullptr; + } + + DOMMatrix* matrix = DOMMatrix::Create(); + CSSUnitValue* angle = angle_->to(CSSPrimitiveValue::UnitType::kDegrees); + if (is2D()) { + matrix->rotateAxisAngleSelf(0, 0, 1, angle->value()); + } else { + matrix->rotateAxisAngleSelf(x->value(), y->value(), z->value(), + angle->value()); + } + return matrix; +} + +const CSSFunctionValue* CSSRotate::ToCSSValue() const { + DCHECK(x_->to(CSSPrimitiveValue::UnitType::kNumber)); + DCHECK(y_->to(CSSPrimitiveValue::UnitType::kNumber)); + DCHECK(z_->to(CSSPrimitiveValue::UnitType::kNumber)); + DCHECK(angle_->to(CSSPrimitiveValue::UnitType::kRadians)); + + CSSFunctionValue* result = + CSSFunctionValue::Create(is2D() ? CSSValueRotate : CSSValueRotate3d); + if (!is2D()) { + const CSSValue* x = x_->ToCSSValue(); + const CSSValue* y = y_->ToCSSValue(); + const CSSValue* z = z_->ToCSSValue(); + if (!x || !y || !z) + return nullptr; + + result->Append(*x); + result->Append(*y); + result->Append(*z); + } + + const CSSValue* angle = angle_->ToCSSValue(); + if (!angle) + return nullptr; + + result->Append(*angle); + return result; +} + +void CSSRotate::setX(const CSSNumberish& x, ExceptionState& exception_state) { + CSSNumericValue* value = CSSNumericValue::FromNumberish(x); + if (!IsValidRotateCoord(value)) { + exception_state.ThrowTypeError("Must specify a number unit"); + return; + } + x_ = value; +} + +void CSSRotate::setY(const CSSNumberish& y, ExceptionState& exception_state) { + CSSNumericValue* value = CSSNumericValue::FromNumberish(y); + if (!IsValidRotateCoord(value)) { + exception_state.ThrowTypeError("Must specify a number unit"); + return; + } + y_ = value; +} + +void CSSRotate::setZ(const CSSNumberish& z, ExceptionState& exception_state) { + CSSNumericValue* value = CSSNumericValue::FromNumberish(z); + if (!IsValidRotateCoord(value)) { + exception_state.ThrowTypeError("Must specify a number unit"); + return; + } + z_ = value; +} + +CSSRotate::CSSRotate(CSSNumericValue* x, + CSSNumericValue* y, + CSSNumericValue* z, + CSSNumericValue* angle, + bool is2D) + : CSSTransformComponent(is2D), angle_(angle), x_(x), y_(y), z_(z) { + DCHECK(IsValidRotateCoord(x)); + DCHECK(IsValidRotateCoord(y)); + DCHECK(IsValidRotateCoord(z)); + DCHECK(IsValidRotateAngle(angle)); +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSRotate.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSRotate.h new file mode 100644 index 0000000000..ed57b01830 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSRotate.h @@ -0,0 +1,81 @@ +// 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 CSSRotate_h +#define CSSRotate_h + +#include "base/macros.h" +#include "core/css/cssom/CSSNumericValue.h" +#include "core/css/cssom/CSSTransformComponent.h" + +namespace blink { + +class DOMMatrix; +class ExceptionState; +class CSSNumericValue; + +// Represents a rotation value in a CSSTransformValue used for properties like +// "transform". +// See CSSRotate.idl for more information about this class. +class CORE_EXPORT CSSRotate final : public CSSTransformComponent { + DEFINE_WRAPPERTYPEINFO(); + + public: + // Constructors defined in the IDL. + static CSSRotate* Create(CSSNumericValue* angle, ExceptionState&); + static CSSRotate* Create(const CSSNumberish& x, + const CSSNumberish& y, + const CSSNumberish& z, + CSSNumericValue* angle, + ExceptionState&); + + // Blink-internal ways of creating CSSRotates. + static CSSRotate* Create(CSSNumericValue* angle); + static CSSRotate* Create(CSSNumericValue* x, + CSSNumericValue* y, + CSSNumericValue* z, + CSSNumericValue* angle); + static CSSRotate* FromCSSValue(const CSSFunctionValue&); + + // Getters and setters for attributes defined in the IDL. + CSSNumericValue* angle() { return angle_.Get(); } + void setAngle(CSSNumericValue* angle, ExceptionState&); + void x(CSSNumberish& x) { x.SetCSSNumericValue(x_); } + void y(CSSNumberish& y) { y.SetCSSNumericValue(y_); } + void z(CSSNumberish& z) { z.SetCSSNumericValue(z_); } + void setX(const CSSNumberish&, ExceptionState&); + void setY(const CSSNumberish&, ExceptionState&); + void setZ(const CSSNumberish&, ExceptionState&); + + DOMMatrix* toMatrix(ExceptionState&) const final; + + // Internal methods - from CSSTransformComponent. + TransformComponentType GetType() const final { return kRotationType; } + const CSSFunctionValue* ToCSSValue() const final; + + virtual void Trace(blink::Visitor* visitor) { + visitor->Trace(angle_); + visitor->Trace(x_); + visitor->Trace(y_); + visitor->Trace(z_); + CSSTransformComponent::Trace(visitor); + } + + private: + CSSRotate(CSSNumericValue* x, + CSSNumericValue* y, + CSSNumericValue* z, + CSSNumericValue* angle, + bool is2D); + + Member angle_; + Member x_; + Member y_; + Member z_; + DISALLOW_COPY_AND_ASSIGN(CSSRotate); +}; + +} // namespace blink + +#endif diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSRotate.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSRotate.idl new file mode 100644 index 0000000000..f2fe3a950e --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSRotate.idl @@ -0,0 +1,19 @@ +// 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. + +// Represents a rotation value in a CSSTransformValue used for properties like +// "transform". +// Spec: https://drafts.css-houdini.org/css-typed-om/#cssrotate +[ + Constructor(CSSNumericValue angleValue), + Constructor(CSSNumberish x, CSSNumberish y, CSSNumberish z, CSSNumericValue angle), + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), + RaisesException=Constructor +] interface CSSRotate : CSSTransformComponent { + [RaisesException=Setter] attribute CSSNumericValue angle; + [RaisesException=Setter] attribute CSSNumberish x; + [RaisesException=Setter] attribute CSSNumberish y; + [RaisesException=Setter] attribute CSSNumberish z; +}; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.cpp index b9dccdf175..fb1d5d31d0 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.cpp @@ -142,7 +142,7 @@ void CSSScale::setZ(const CSSNumberish& z, ExceptionState& exception_state) { z_ = value; } -const DOMMatrix* CSSScale::AsMatrix(ExceptionState& exception_state) const { +DOMMatrix* CSSScale::toMatrix(ExceptionState& exception_state) const { CSSUnitValue* x = x_->to(CSSPrimitiveValue::UnitType::kNumber); CSSUnitValue* y = y_->to(CSSPrimitiveValue::UnitType::kNumber); CSSUnitValue* z = z_->to(CSSPrimitiveValue::UnitType::kNumber); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.h index 1acacfe1b0..729187e8d1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.h @@ -50,9 +50,10 @@ class CORE_EXPORT CSSScale final : public CSSTransformComponent { void setY(const CSSNumberish&, ExceptionState&); void setZ(const CSSNumberish&, ExceptionState&); + DOMMatrix* toMatrix(ExceptionState&) const final; + // Internal methods - from CSSTransformComponent. TransformComponentType GetType() const final { return kScaleType; } - const DOMMatrix* AsMatrix(ExceptionState&) const final; const CSSFunctionValue* ToCSSValue() const final; virtual void Trace(blink::Visitor* visitor) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.idl index b04c7a7dbd..cd5d3c2a3f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSScale.idl @@ -7,8 +7,8 @@ // Spec: https://drafts.css-houdini.org/css-typed-om/#cssscale [ Constructor(CSSNumberish x, CSSNumberish y, optional CSSNumberish z), - Exposed=(Window,PaintWorklet), RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), RaisesException=Constructor ] interface CSSScale : CSSTransformComponent { [RaisesException=Setter] attribute CSSNumberish x; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp index 52463f4459..55e10467f9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp @@ -52,31 +52,21 @@ void CSSSkew::setAy(CSSNumericValue* value, ExceptionState& exception_state) { CSSSkew* CSSSkew::FromCSSValue(const CSSFunctionValue& value) { DCHECK_GT(value.length(), 0U); const CSSPrimitiveValue& x_value = ToCSSPrimitiveValue(value.Item(0)); - switch (value.FunctionType()) { - case CSSValueSkew: - if (value.length() == 2U) { - const CSSPrimitiveValue& y_value = ToCSSPrimitiveValue(value.Item(1)); - return CSSSkew::Create(CSSNumericValue::FromCSSValue(x_value), - CSSNumericValue::FromCSSValue(y_value)); - } - // Else fall through; skew(ax) == skewX(ax). - case CSSValueSkewX: - DCHECK_EQ(value.length(), 1U); - return CSSSkew::Create( - CSSNumericValue::FromCSSValue(x_value), - CSSUnitValue::Create(0, CSSPrimitiveValue::UnitType::kDegrees)); - case CSSValueSkewY: - DCHECK_EQ(value.length(), 1U); - return CSSSkew::Create( - CSSUnitValue::Create(0, CSSPrimitiveValue::UnitType::kDegrees), - CSSNumericValue::FromCSSValue(x_value)); - default: - NOTREACHED(); - return nullptr; + DCHECK_EQ(value.FunctionType(), CSSValueSkew); + if (value.length() == 1U) { + return CSSSkew::Create( + CSSNumericValue::FromCSSValue(x_value), + CSSUnitValue::Create(0, CSSPrimitiveValue::UnitType::kDegrees)); + } else if (value.length() == 2U) { + const CSSPrimitiveValue& y_value = ToCSSPrimitiveValue(value.Item(1)); + return CSSSkew::Create(CSSNumericValue::FromCSSValue(x_value), + CSSNumericValue::FromCSSValue(y_value)); } + NOTREACHED(); + return nullptr; } -const DOMMatrix* CSSSkew::AsMatrix(ExceptionState&) const { +DOMMatrix* CSSSkew::toMatrix(ExceptionState&) const { CSSUnitValue* ax = ax_->to(CSSPrimitiveValue::UnitType::kRadians); CSSUnitValue* ay = ay_->to(CSSPrimitiveValue::UnitType::kRadians); DCHECK(ax); @@ -95,7 +85,8 @@ const CSSFunctionValue* CSSSkew::ToCSSValue() const { CSSFunctionValue* result = CSSFunctionValue::Create(CSSValueSkew); result->Append(*ax); - result->Append(*ay); + if (!ay_->IsUnitValue() || ToCSSUnitValue(ay_)->value() != 0) + result->Append(*ay); return result; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.h index dfc6c7d6a0..90251ce9fc 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.h @@ -27,7 +27,7 @@ class CORE_EXPORT CSSSkew final : public CSSTransformComponent { return new CSSSkew(ax, ay); } - // Internal ways of creating CSSSkews. + // Internal ways of creating CSSSkew. static CSSSkew* FromCSSValue(const CSSFunctionValue&); // Getters and setters for the ax and ay attributes defined in the IDL. @@ -41,8 +41,9 @@ class CORE_EXPORT CSSSkew final : public CSSTransformComponent { // https://drafts.css-houdini.org/css-typed-om/#dom-cssskew-is2d void setIs2D(bool is2D) final {} + DOMMatrix* toMatrix(ExceptionState&) const final; + // Internal methods - from CSSTransformComponent. - const DOMMatrix* AsMatrix(ExceptionState&) const override; TransformComponentType GetType() const override { return kSkewType; } const CSSFunctionValue* ToCSSValue() const override; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.idl index 761bef9fbc..d600a54872 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkew.idl @@ -7,8 +7,8 @@ // Spec: https://drafts.css-houdini.org/css-typed-om/#cssskew [ Constructor(CSSNumericValue ax, CSSNumericValue ay), - Exposed=(Window,PaintWorklet), RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), RaisesException=Constructor ] interface CSSSkew : CSSTransformComponent { [RaisesException=Setter] attribute CSSNumericValue ax; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewX.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewX.cpp new file mode 100644 index 0000000000..5ddbb0cef1 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewX.cpp @@ -0,0 +1,77 @@ +// Copyright 2018 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 "core/css/cssom/CSSSkewX.h" + +#include "bindings/core/v8/ExceptionState.h" +#include "core/css/CSSFunctionValue.h" +#include "core/css/CSSPrimitiveValue.h" +#include "core/css/cssom/CSSNumericValue.h" +#include "core/css/cssom/CSSStyleValue.h" +#include "core/css/cssom/CSSUnitValue.h" +#include "core/geometry/DOMMatrix.h" + +namespace blink { + +namespace { + +bool IsValidSkewXAngle(CSSNumericValue* value) { + return value && + value->Type().MatchesBaseType(CSSNumericValueType::BaseType::kAngle); +} + +} // namespace + +CSSSkewX* CSSSkewX::Create(CSSNumericValue* ax, + ExceptionState& exception_state) { + if (!IsValidSkewXAngle(ax)) { + exception_state.ThrowTypeError("CSSSkewX does not support non-angles"); + return nullptr; + } + return new CSSSkewX(ax); +} + +void CSSSkewX::setAx(CSSNumericValue* value, ExceptionState& exception_state) { + if (!IsValidSkewXAngle(value)) { + exception_state.ThrowTypeError("Must specify an angle unit"); + return; + } + ax_ = value; +} + +CSSSkewX* CSSSkewX::FromCSSValue(const CSSFunctionValue& value) { + DCHECK_GT(value.length(), 0U); + DCHECK_EQ(value.FunctionType(), CSSValueSkewX); + if (value.length() == 1U) { + return CSSSkewX::Create( + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(0)))); + } + NOTREACHED(); + return nullptr; +} + +DOMMatrix* CSSSkewX::toMatrix(ExceptionState&) const { + CSSUnitValue* ax = ax_->to(CSSPrimitiveValue::UnitType::kRadians); + DCHECK(ax); + DOMMatrix* result = DOMMatrix::Create(); + result->skewXSelf(ax->value()); + return result; +} + +const CSSFunctionValue* CSSSkewX::ToCSSValue() const { + const CSSValue* ax = ax_->ToCSSValue(); + if (!ax) + return nullptr; + + CSSFunctionValue* result = CSSFunctionValue::Create(CSSValueSkewX); + result->Append(*ax); + return result; +} + +CSSSkewX::CSSSkewX(CSSNumericValue* ax) + : CSSTransformComponent(true /* is2D */), ax_(ax) { + DCHECK(ax); +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewX.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewX.h new file mode 100644 index 0000000000..06fb3b90c4 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewX.h @@ -0,0 +1,60 @@ +// Copyright 2018 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 CSSSkewX_h +#define CSSSkewX_h + +#include "base/macros.h" +#include "core/css/cssom/CSSNumericValue.h" +#include "core/css/cssom/CSSTransformComponent.h" + +namespace blink { + +class DOMMatrix; +class ExceptionState; + +// Represents a skewX value in a CSSTransformValue used for properties like +// "transform". +// See CSSSkewX.idl for more information about this class. +class CORE_EXPORT CSSSkewX final : public CSSTransformComponent { + DEFINE_WRAPPERTYPEINFO(); + + public: + // Constructor defined in the IDL. + static CSSSkewX* Create(CSSNumericValue*, ExceptionState&); + static CSSSkewX* Create(CSSNumericValue* ax) { return new CSSSkewX(ax); } + + // Internal ways of creating CSSSkewX. + static CSSSkewX* FromCSSValue(const CSSFunctionValue&); + + // Getters and setters for the ax attributes defined in the IDL. + CSSNumericValue* ax() { return ax_.Get(); } + void setAx(CSSNumericValue*, ExceptionState&); + + DOMMatrix* toMatrix(ExceptionState&) const final; + + // From CSSTransformComponent + // Setting is2D for CSSSkewX does nothing. + // https://drafts.css-houdini.org/css-typed-om/#dom-cssskew-is2d + void setIs2D(bool is2D) final {} + + // Internal methods - from CSSTransformComponent. + TransformComponentType GetType() const override { return kSkewXType; } + const CSSFunctionValue* ToCSSValue() const override; + + virtual void Trace(blink::Visitor* visitor) { + visitor->Trace(ax_); + CSSTransformComponent::Trace(visitor); + } + + private: + CSSSkewX(CSSNumericValue* ax); + + Member ax_; + DISALLOW_COPY_AND_ASSIGN(CSSSkewX); +}; + +} // namespace blink + +#endif diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewX.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewX.idl new file mode 100644 index 0000000000..2c0a37da85 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewX.idl @@ -0,0 +1,15 @@ +// Copyright 2018 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. + +// Represents a skewX value in a CSSTransformValue used for properties like +// "transform". +// Spec: https://drafts.css-houdini.org/css-typed-om-1/#cssskewx +[ + Constructor(CSSNumericValue ax), + RuntimeEnabled=CSSTypedOM, + Exposed=(Window, Worker, PaintWorklet, LayoutWorklet), + RaisesException=Constructor] +interface CSSSkewX : CSSTransformComponent { + [RaisesException=Setter] attribute CSSNumericValue ax; +}; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewY.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewY.cpp new file mode 100644 index 0000000000..5e448e41fe --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewY.cpp @@ -0,0 +1,77 @@ +// Copyright 2018 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 "core/css/cssom/CSSSkewY.h" + +#include "bindings/core/v8/ExceptionState.h" +#include "core/css/CSSFunctionValue.h" +#include "core/css/CSSPrimitiveValue.h" +#include "core/css/cssom/CSSNumericValue.h" +#include "core/css/cssom/CSSStyleValue.h" +#include "core/css/cssom/CSSUnitValue.h" +#include "core/geometry/DOMMatrix.h" + +namespace blink { + +namespace { + +bool IsValidSkewYAngle(CSSNumericValue* value) { + return value && + value->Type().MatchesBaseType(CSSNumericValueType::BaseType::kAngle); +} + +} // namespace + +CSSSkewY* CSSSkewY::Create(CSSNumericValue* ay, + ExceptionState& exception_state) { + if (!IsValidSkewYAngle(ay)) { + exception_state.ThrowTypeError("CSSSkewY does not support non-angles"); + return nullptr; + } + return new CSSSkewY(ay); +} + +void CSSSkewY::setAy(CSSNumericValue* value, ExceptionState& exception_state) { + if (!IsValidSkewYAngle(value)) { + exception_state.ThrowTypeError("Must specify an angle unit"); + return; + } + ay_ = value; +} + +CSSSkewY* CSSSkewY::FromCSSValue(const CSSFunctionValue& value) { + DCHECK_GT(value.length(), 0U); + DCHECK_EQ(value.FunctionType(), CSSValueSkewY); + if (value.length(), 1U) { + return CSSSkewY::Create( + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(0)))); + } + NOTREACHED(); + return nullptr; +} + +DOMMatrix* CSSSkewY::toMatrix(ExceptionState&) const { + CSSUnitValue* ay = ay_->to(CSSPrimitiveValue::UnitType::kRadians); + DCHECK(ay); + DOMMatrix* result = DOMMatrix::Create(); + result->skewYSelf(ay->value()); + return result; +} + +const CSSFunctionValue* CSSSkewY::ToCSSValue() const { + const CSSValue* ay = ay_->ToCSSValue(); + if (!ay) + return nullptr; + + CSSFunctionValue* result = CSSFunctionValue::Create(CSSValueSkewY); + result->Append(*ay); + return result; +} + +CSSSkewY::CSSSkewY(CSSNumericValue* ay) + : CSSTransformComponent(true /* is2D */), ay_(ay) { + DCHECK(ay); +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewY.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewY.h new file mode 100644 index 0000000000..dc8ba8846a --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewY.h @@ -0,0 +1,60 @@ +// Copyright 2018 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 CSSSkewY_h +#define CSSSkewY_h + +#include "base/macros.h" +#include "core/css/cssom/CSSNumericValue.h" +#include "core/css/cssom/CSSTransformComponent.h" + +namespace blink { + +class DOMMatrix; +class ExceptionState; + +// Represents a skewY value in a CSSTransformValue used for properties like +// "transform". +// See CSSSkewY.idl for more information about this class. +class CORE_EXPORT CSSSkewY final : public CSSTransformComponent { + DEFINE_WRAPPERTYPEINFO(); + + public: + // Constructor defined in the IDL. + static CSSSkewY* Create(CSSNumericValue*, ExceptionState&); + static CSSSkewY* Create(CSSNumericValue* ay) { return new CSSSkewY(ay); } + + // Internal ways of creating CSSSkewY. + static CSSSkewY* FromCSSValue(const CSSFunctionValue&); + + // Getters and setters for the ay attributes defined in the IDL. + CSSNumericValue* ay() { return ay_.Get(); } + void setAy(CSSNumericValue*, ExceptionState&); + + DOMMatrix* toMatrix(ExceptionState&) const final; + + // From CSSTransformComponent + // Setting is2D for CSSSkewY does nothing. + // https://drafts.css-houdini.org/css-typed-om/#dom-cssskew-is2d + void setIs2D(bool is2D) final {} + + // Internal methods - from CSSTransformComponent. + TransformComponentType GetType() const override { return kSkewYType; } + const CSSFunctionValue* ToCSSValue() const override; + + virtual void Trace(blink::Visitor* visitor) { + visitor->Trace(ay_); + CSSTransformComponent::Trace(visitor); + } + + private: + CSSSkewY(CSSNumericValue* ay); + + Member ay_; + DISALLOW_COPY_AND_ASSIGN(CSSSkewY); +}; + +} // namespace blink + +#endif diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewY.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewY.idl new file mode 100644 index 0000000000..85c09b4bfe --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSSkewY.idl @@ -0,0 +1,15 @@ +// Copyright 2018 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. + +// Represents a skewX value in a CSSTransformValue used for properties like +// "transform". +// Spec: https://drafts.css-houdini.org/css-typed-om-1/#cssskewy +[ + Constructor(CSSNumericValue ay), + RuntimeEnabled=CSSTypedOM, + Exposed=(Window, Worker, PaintWorklet, LayoutWorklet), + RaisesException=Constructor] +interface CSSSkewY : CSSTransformComponent { + [RaisesException=Setter] attribute CSSNumericValue ay; +}; \ No newline at end of file diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.cpp index 08f7aa9771..6c1fb6bed6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.cpp @@ -7,26 +7,30 @@ namespace blink { double CSSStyleImageValue::intrinsicWidth(bool& is_null) const { - is_null = Status() != ResourceStatus::kCached; - if (is_null) + const WTF::Optional size = IntrinsicSize(); + if (!size) { + is_null = true; return 0; - return ImageSize().Width(); + } + return size.value().Width(); } double CSSStyleImageValue::intrinsicHeight(bool& is_null) const { - is_null = Status() != ResourceStatus::kCached; - if (is_null) + const WTF::Optional size = IntrinsicSize(); + if (!size) { + is_null = true; return 0; - return ImageSize().Height(); + } + return size.value().Height(); } -double CSSStyleImageValue::intrinsicRatio(bool& is_null) { - is_null = Status() != ResourceStatus::kCached; - if (is_null || intrinsicHeight(is_null) == 0) { +double CSSStyleImageValue::intrinsicRatio(bool& is_null) const { + const WTF::Optional size = IntrinsicSize(); + if (!size || size.value().Height() == 0) { is_null = true; return 0; } - return intrinsicWidth(is_null) / intrinsicHeight(is_null); + return static_cast(size.value().Width()) / size.value().Height(); } FloatSize CSSStyleImageValue::ElementSize( @@ -35,21 +39,4 @@ FloatSize CSSStyleImageValue::ElementSize( return FloatSize(intrinsicWidth(not_used), intrinsicHeight(not_used)); } -bool CSSStyleImageValue::IsAccelerated() const { - return GetImage() && GetImage()->IsTextureBacked(); -} - -scoped_refptr CSSStyleImageValue::GetImage() const { - if (IsCachePending()) - return nullptr; - // cachedImage can be null if image is StyleInvalidImage - ImageResourceContent* cached_image = - image_value_->CachedImage()->CachedImage(); - if (cached_image) { - // getImage() returns the nullImage() if the image is not available yet - return cached_image->GetImage()->ImageForDefaultFrame(); - } - return nullptr; -} - } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.h index fad04105f2..5cea77fe60 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValue.h @@ -7,13 +7,9 @@ #include "base/macros.h" #include "core/CoreExport.h" -#include "core/css/CSSImageValue.h" #include "core/css/cssom/CSSResourceValue.h" -#include "core/css/cssom/CSSStyleValue.h" #include "core/html/canvas/CanvasImageSource.h" -#include "core/imagebitmap/ImageBitmapSource.h" -#include "core/loader/resource/ImageResourceContent.h" -#include "core/style/StyleImage.h" +#include "platform/wtf/Optional.h" namespace blink { @@ -26,9 +22,10 @@ class CORE_EXPORT CSSStyleImageValue : public CSSResourceValue, public: virtual ~CSSStyleImageValue() = default; + // IDL double intrinsicWidth(bool& is_null) const; double intrinsicHeight(bool& is_null) const; - double intrinsicRatio(bool& is_null); + double intrinsicRatio(bool& is_null) const; // CanvasImageSource bool IsCSSImageValue() const final { return true; } @@ -37,45 +34,13 @@ class CORE_EXPORT CSSStyleImageValue : public CSSResourceValue, return true; } FloatSize ElementSize(const FloatSize& default_object_size) const final; - scoped_refptr GetSourceImageForCanvas(SourceImageStatus*, - AccelerationHint, - const FloatSize&) final { - return GetImage(); - } - bool IsAccelerated() const override; - - virtual void Trace(blink::Visitor* visitor) { - visitor->Trace(image_value_); - CSSResourceValue::Trace(visitor); - } protected: - CSSStyleImageValue(const CSSImageValue* image_value) - : image_value_(image_value) {} - - virtual IntSize ImageSize() const { - DCHECK(!IsCachePending()); - ImageResourceContent* resource_content = - image_value_->CachedImage()->CachedImage(); - return resource_content - ? resource_content->IntrinsicSize(kDoNotRespectImageOrientation) - : IntSize(0, 0); - } + CSSStyleImageValue() = default; - virtual bool IsCachePending() const { return image_value_->IsCachePending(); } - - ResourceStatus Status() const override { - if (IsCachePending()) - return ResourceStatus::kNotStarted; - return image_value_->CachedImage()->CachedImage()->GetContentStatus(); - } - - const CSSImageValue* CssImageValue() const { return image_value_.Get(); }; + virtual WTF::Optional IntrinsicSize() const = 0; private: - scoped_refptr GetImage() const; - - Member image_value_; DISALLOW_COPY_AND_ASSIGN(CSSStyleImageValue); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValueTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValueTest.cpp index 4613d19cc7..bf726cfbc9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValueTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleImageValueTest.cpp @@ -4,6 +4,7 @@ #include "core/css/cssom/CSSStyleImageValue.h" +#include "platform/graphics/Image.h" #include "testing/gtest/include/gtest/gtest.h" namespace blink { @@ -12,22 +13,30 @@ namespace { class FakeCSSStyleImageValue : public CSSStyleImageValue { public: - FakeCSSStyleImageValue(CSSImageValue* image_value, - bool cache_pending, - IntSize size) - : CSSStyleImageValue(image_value), - cache_pending_(cache_pending), - size_(size) {} + FakeCSSStyleImageValue(bool cache_pending, IntSize size) + : cache_pending_(cache_pending), size_(size) {} - bool IsCachePending() const final { return cache_pending_; } - IntSize ImageSize() const final { return size_; } + // CSSStyleImageValue + WTF::Optional IntrinsicSize() const final { + if (cache_pending_) + return WTF::nullopt; + return size_; + } + // CanvasImageSource + scoped_refptr GetSourceImageForCanvas(SourceImageStatus*, + AccelerationHint, + const FloatSize&) final { + return nullptr; + } ResourceStatus Status() const final { - if (IsCachePending()) + if (cache_pending_) return ResourceStatus::kNotStarted; return ResourceStatus::kCached; } + bool IsAccelerated() const final { return false; } + // CSSStyleValue const CSSValue* ToCSSValue() const final { return nullptr; } StyleValueType GetType() const final { return kUnknownType; } @@ -39,22 +48,20 @@ class FakeCSSStyleImageValue : public CSSStyleImageValue { } // namespace TEST(CSSStyleImageValueTest, PendingCache) { - FakeCSSStyleImageValue* style_image_value = new FakeCSSStyleImageValue( - CSSImageValue::Create(""), true, IntSize(100, 100)); - bool is_null; - EXPECT_EQ(style_image_value->intrinsicWidth(is_null), 0); - EXPECT_EQ(style_image_value->intrinsicHeight(is_null), 0); - EXPECT_EQ(style_image_value->intrinsicRatio(is_null), 0); + FakeCSSStyleImageValue style_image_value(true, IntSize(100, 100)); + bool is_null = false; + EXPECT_EQ(style_image_value.intrinsicWidth(is_null), 0); + EXPECT_EQ(style_image_value.intrinsicHeight(is_null), 0); + EXPECT_EQ(style_image_value.intrinsicRatio(is_null), 0); EXPECT_TRUE(is_null); } TEST(CSSStyleImageValueTest, ValidLoadedImage) { - FakeCSSStyleImageValue* style_image_value = new FakeCSSStyleImageValue( - CSSImageValue::Create(""), false, IntSize(480, 120)); - bool is_null; - EXPECT_EQ(style_image_value->intrinsicWidth(is_null), 480); - EXPECT_EQ(style_image_value->intrinsicHeight(is_null), 120); - EXPECT_EQ(style_image_value->intrinsicRatio(is_null), 4); + FakeCSSStyleImageValue style_image_value(false, IntSize(480, 120)); + bool is_null = false; + EXPECT_EQ(style_image_value.intrinsicWidth(is_null), 480); + EXPECT_EQ(style_image_value.intrinsicHeight(is_null), 120); + EXPECT_EQ(style_image_value.intrinsicRatio(is_null), 4); EXPECT_FALSE(is_null); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.cpp index 47599bbf6e..72480de3ed 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.cpp @@ -28,12 +28,6 @@ CSSStyleValueVector ParseCSSStyleValue( return CSSStyleValueVector(); } - if (CSSProperty::Get(property_id).IsShorthand()) { - exception_state.ThrowTypeError( - "Parsing shorthand properties is not supported"); - return CSSStyleValueVector(); - } - const auto style_values = StyleValueFactory::FromString( property_id, value, CSSParserContext::Create(*execution_context)); if (style_values.IsEmpty()) { @@ -54,54 +48,22 @@ CSSStyleValue* CSSStyleValue::parse(const ExecutionContext* execution_context, ExceptionState& exception_state) { CSSStyleValueVector style_value_vector = ParseCSSStyleValue( execution_context, property_name, value, exception_state); - if (style_value_vector.IsEmpty()) - return nullptr; - - return style_value_vector[0]; + return style_value_vector.IsEmpty() ? nullptr : style_value_vector[0]; } -Nullable CSSStyleValue::parseAll( +CSSStyleValueVector CSSStyleValue::parseAll( const ExecutionContext* execution_context, const String& property_name, const String& value, ExceptionState& exception_state) { - CSSStyleValueVector style_value_vector = ParseCSSStyleValue( - execution_context, property_name, value, exception_state); - if (style_value_vector.IsEmpty()) - return nullptr; - - return style_value_vector; + return ParseCSSStyleValue(execution_context, property_name, value, + exception_state); } String CSSStyleValue::toString() const { const CSSValue* result = ToCSSValue(); - // TODO(crbug.com/782103): Remove this once all CSSStyleValues - // support toCSSValue(). - return result ? result->CssText() : ""; -} - -String CSSStyleValue::StyleValueTypeToString(StyleValueType type) { - switch (type) { - case StyleValueType::kNumberType: - return "number"; - case StyleValueType::kPercentType: - return "percent"; - case StyleValueType::kLengthType: - return "length"; - case StyleValueType::kAngleType: - return "angle"; - case StyleValueType::kTimeType: - return "time"; - case StyleValueType::kFrequencyType: - return "frequency"; - case StyleValueType::kResolutionType: - return "resolution"; - case StyleValueType::kFlexType: - return "flex"; - default: - NOTREACHED(); - return ""; - } + DCHECK(result); + return result->CssText(); } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.h index 5e01552fb9..3e12178c8c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.h @@ -6,11 +6,11 @@ #define CSSStyleValue_h #include "base/macros.h" -#include "bindings/core/v8/Nullable.h" #include "core/CSSPropertyNames.h" #include "core/CoreExport.h" #include "core/css/CSSValue.h" #include "platform/bindings/ScriptWrappable.h" +#include "platform/wtf/Optional.h" #include "platform/wtf/text/WTFString.h" namespace blink { @@ -28,56 +28,60 @@ class CORE_EXPORT CSSStyleValue : public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); public: + // This enum ordering is significant for CSSStyleValue::IsNumericValue. enum StyleValueType { kUnknownType, - kAngleType, - kFlexType, - kFrequencyType, - kInvertType, + kShorthandType, + kUnparsedType, kKeywordType, - kLengthType, - kMaxType, - kMinType, - kNegateType, - kNumberType, - kPercentType, - kPositionType, - kProductType, - kResolutionType, + // Start of CSSNumericValue subclasses + kUnitType, kSumType, - kTimeType, + kProductType, + kNegateType, + kInvertType, + kMinType, + kMaxType, + // End of CSSNumericValue subclasses kTransformType, - kUnparsedType, + kPositionType, kURLImageType, - kInvalidType, }; static CSSStyleValue* parse(const ExecutionContext*, const String& property_name, const String& value, ExceptionState&); - static Nullable parseAll(const ExecutionContext*, - const String& property_name, - const String& value, - ExceptionState&); + static CSSStyleValueVector parseAll(const ExecutionContext*, + const String& property_name, + const String& value, + ExceptionState&); virtual ~CSSStyleValue() = default; virtual StyleValueType GetType() const = 0; - virtual bool ContainsPercent() const { return false; } + bool IsNumericValue() const { + return GetType() >= kUnitType && GetType() <= kMaxType; + } virtual const CSSValue* ToCSSValue() const = 0; + // FIXME: We should make this a method on CSSProperty instead. virtual const CSSValue* ToCSSValueWithProperty(CSSPropertyID) const { return ToCSSValue(); } virtual String toString() const; - protected: - static String StyleValueTypeToString(StyleValueType); + // TODO(801935): Actually use this for serialization in subclasses. + // Currently only used by CSSUnsupportedStyleValue because it's + // immutable, so we have to worry about the serialization changing. + const String& CSSText() const { return css_text_; } + void SetCSSText(const String& css_text) { css_text_ = css_text; } + protected: CSSStyleValue() = default; private: + String css_text_; DISALLOW_COPY_AND_ASSIGN(CSSStyleValue); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.idl index 8fe50596fc..d9a273a89c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleValue.idl @@ -7,10 +7,10 @@ // base CSSStyleValues. // Spec: https://drafts.css-houdini.org/css-typed-om/#stylevalue-objects [ - Exposed(Window CSSTypedOM, PaintWorklet CSSPaintAPI) + Exposed(Window CSSTypedOM,LayoutWorklet CSSTypedOM,PaintWorklet CSSPaintAPI) ] interface CSSStyleValue { stringifier; - // Putting Exposed=Window in the next line makes |parse| not exposed to PaintWorklet. - [RaisesException, Exposed=Window, CallWith=ExecutionContext] static CSSStyleValue? parse(DOMString property, DOMString cssText); - [RaisesException, Exposed=Window, CallWith=ExecutionContext] static sequence? parseAll(DOMString property, DOMString cssText); + // Putting Exposed=Window in the next line makes |parse| not exposed to Worklets. + [RaisesException, Exposed=Window, CallWith=ExecutionContext] static CSSStyleValue parse(DOMString property, DOMString cssText); + [RaisesException, Exposed=Window, CallWith=ExecutionContext] static sequence parseAll(DOMString property, DOMString cssText); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleVariableReferenceValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleVariableReferenceValue.cpp new file mode 100644 index 0000000000..aed830afaf --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleVariableReferenceValue.cpp @@ -0,0 +1,46 @@ +// Copyright 2018 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 "core/css/cssom/CSSStyleVariableReferenceValue.h" + +namespace blink { + +CSSStyleVariableReferenceValue* CSSStyleVariableReferenceValue::Create( + const String& variable, + ExceptionState& exception_state) { + return Create(variable, nullptr, exception_state); +} + +CSSStyleVariableReferenceValue* CSSStyleVariableReferenceValue::Create( + const String& variable, + CSSUnparsedValue* fallback, + ExceptionState& exception_state) { + CSSStyleVariableReferenceValue* result = Create(variable, fallback); + if (!result) { + exception_state.ThrowTypeError("Invalid custom property name"); + return nullptr; + } + + return result; +} + +CSSStyleVariableReferenceValue* CSSStyleVariableReferenceValue::Create( + const String& variable, + CSSUnparsedValue* fallback) { + if (!variable.StartsWith("--")) + return nullptr; + return new CSSStyleVariableReferenceValue(variable, fallback); +} + +void CSSStyleVariableReferenceValue::setVariable( + const String& value, + ExceptionState& exception_state) { + if (!value.StartsWith("--")) { + exception_state.ThrowTypeError("Invalid custom property name"); + return; + } + variable_ = value; +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleVariableReferenceValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleVariableReferenceValue.h index 17997ff763..82decfeb9f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleVariableReferenceValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSStyleVariableReferenceValue.h @@ -12,6 +12,8 @@ namespace blink { +class ExceptionState; + // CSSStyleVariableReferenceValue represents a CSS var() value for CSS Typed OM. // The corresponding idl file is CSSVariableReferenceValue.idl. class CORE_EXPORT CSSStyleVariableReferenceValue final @@ -19,20 +21,22 @@ class CORE_EXPORT CSSStyleVariableReferenceValue final DEFINE_WRAPPERTYPEINFO(); public: - virtual ~CSSStyleVariableReferenceValue() = default; + static CSSStyleVariableReferenceValue* Create(const String& variable, + ExceptionState&); + + static CSSStyleVariableReferenceValue* Create(const String& variable, + CSSUnparsedValue* fallback, + ExceptionState&); static CSSStyleVariableReferenceValue* Create( const String& variable, - CSSUnparsedValue* fallback = nullptr) { - return new CSSStyleVariableReferenceValue(variable, fallback); - } + CSSUnparsedValue* fallback = nullptr); const String& variable() const { return variable_; } - void setVariable(const String& value) { variable_ = value; } + void setVariable(const String&, ExceptionState&); CSSUnparsedValue* fallback() { return fallback_.Get(); } const CSSUnparsedValue* fallback() const { return fallback_.Get(); } - void setFallback(CSSUnparsedValue* value) { fallback_ = value; } void Trace(blink::Visitor* visitor) override { visitor->Trace(fallback_); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.cpp index 766d787e6e..915e8a3201 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.cpp @@ -6,10 +6,12 @@ #include "core/css/cssom/CSSMatrixComponent.h" #include "core/css/cssom/CSSPerspective.h" -#include "core/css/cssom/CSSRotation.h" +#include "core/css/cssom/CSSRotate.h" #include "core/css/cssom/CSSScale.h" #include "core/css/cssom/CSSSkew.h" -#include "core/css/cssom/CSSTranslation.h" +#include "core/css/cssom/CSSSkewX.h" +#include "core/css/cssom/CSSSkewY.h" +#include "core/css/cssom/CSSTranslate.h" namespace blink { @@ -30,7 +32,7 @@ CSSTransformComponent* CSSTransformComponent::FromCSSValue( case CSSValueRotateY: case CSSValueRotateZ: case CSSValueRotate3d: - return CSSRotation::FromCSSValue(function_value); + return CSSRotate::FromCSSValue(function_value); case CSSValueScale: case CSSValueScaleX: case CSSValueScaleY: @@ -38,15 +40,17 @@ CSSTransformComponent* CSSTransformComponent::FromCSSValue( case CSSValueScale3d: return CSSScale::FromCSSValue(function_value); case CSSValueSkew: + return CSSSkew::FromCSSValue(function_value); case CSSValueSkewX: + return CSSSkewX::FromCSSValue(function_value); case CSSValueSkewY: - return CSSSkew::FromCSSValue(function_value); + return CSSSkewY::FromCSSValue(function_value); case CSSValueTranslate: case CSSValueTranslateX: case CSSValueTranslateY: case CSSValueTranslateZ: case CSSValueTranslate3d: - return CSSTranslation::FromCSSValue(function_value); + return CSSTranslate::FromCSSValue(function_value); default: return nullptr; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.h index 0f4a590014..b2c9fc697b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.h @@ -30,6 +30,8 @@ class CORE_EXPORT CSSTransformComponent : public ScriptWrappable { kRotationType, kScaleType, kSkewType, + kSkewXType, + kSkewYType, kTranslationType, }; @@ -43,10 +45,11 @@ class CORE_EXPORT CSSTransformComponent : public ScriptWrappable { virtual void setIs2D(bool is2D) { is2D_ = is2D; } String toString() const; + virtual DOMMatrix* toMatrix(ExceptionState&) const = 0; + // Internal methods. virtual TransformComponentType GetType() const = 0; virtual const CSSFunctionValue* ToCSSValue() const = 0; - virtual const DOMMatrix* AsMatrix(ExceptionState&) const = 0; protected: CSSTransformComponent(bool is2D) : is2D_(is2D) {} diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.idl index ec592a2fe2..ab1d67b712 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformComponent.idl @@ -7,9 +7,10 @@ // before they can be used as a value for properties like "transform". // Spec: https://drafts.css-houdini.org/css-typed-om/#csstransformcomponent [ - Exposed=(Window,PaintWorklet), - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet) ] interface CSSTransformComponent { stringifier; attribute boolean is2D; + [RaisesException] DOMMatrix toMatrix(); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.cpp index 112f75c06a..b04d2928c4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.cpp @@ -54,7 +54,7 @@ DOMMatrix* CSSTransformValue::toMatrix(ExceptionState& exception_state) const { DOMMatrix* matrix = DOMMatrix::Create(); for (size_t i = 0; i < transform_components_.size(); i++) { const DOMMatrix* matrixComponent = - transform_components_[i]->AsMatrix(exception_state); + transform_components_[i]->toMatrix(exception_state); if (matrixComponent) { matrix->multiplySelf(*matrixComponent); } @@ -74,4 +74,25 @@ const CSSValue* CSSTransformValue::ToCSSValue() const { return transform_css_value; } +bool CSSTransformValue::AnonymousIndexedSetter( + unsigned index, + const Member component, + ExceptionState& exception_state) { + if (index < transform_components_.size()) { + transform_components_[index] = component; + return true; + } + + if (index == transform_components_.size()) { + transform_components_.push_back(component); + return true; + } + + exception_state.ThrowRangeError( + ExceptionMessages::IndexOutsideRange( + "index", index, 0, ExceptionMessages::kInclusiveBound, + transform_components_.size(), ExceptionMessages::kInclusiveBound)); + return false; +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.h index 55cd81c7aa..08b1af7386 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.h @@ -38,9 +38,12 @@ class CORE_EXPORT CSSTransformValue final : public CSSStyleValue { StyleValueType GetType() const override { return kTransformType; } - CSSTransformComponent* componentAtIndex(uint32_t index) { + CSSTransformComponent* AnonymousIndexedGetter(uint32_t index) { return transform_components_.at(index); } + bool AnonymousIndexedSetter(unsigned, + const Member, + ExceptionState&); size_t length() const { return transform_components_.size(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.idl index e39cfdaa5d..422db60a81 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTransformValue.idl @@ -5,12 +5,13 @@ [ Constructor(sequence transforms), RaisesException=Constructor, - Exposed(Window CSSTypedOM, PaintWorklet CSSTypedOM) + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet) ] interface CSSTransformValue : CSSStyleValue { - // https://github.com/w3c/css-houdini-drafts/issues/358 - readonly attribute unsigned long length; - [ImplementedAs=componentAtIndex] getter CSSTransformComponent (unsigned long index); iterable; + readonly attribute unsigned long length; + getter CSSTransformComponent (unsigned long index); + [RaisesException] setter CSSTransformComponent (unsigned long index, CSSTransformComponent val); readonly attribute boolean is2D; [RaisesException, RuntimeEnabled=GeometryInterfaces] DOMMatrix toMatrix(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTranslate.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTranslate.cpp new file mode 100644 index 0000000000..753ca98190 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTranslate.cpp @@ -0,0 +1,212 @@ +// 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 "core/css/cssom/CSSTranslate.h" + +#include "bindings/core/v8/ExceptionState.h" +#include "core/css/CSSPrimitiveValue.h" +#include "core/css/cssom/CSSNumericValue.h" +#include "core/css/cssom/CSSStyleValue.h" +#include "core/geometry/DOMMatrix.h" + +namespace blink { + +namespace { + +bool IsValidTranslateXY(const CSSNumericValue* value) { + return value && value->Type().MatchesBaseTypePercentage( + CSSNumericValueType::BaseType::kLength); +} + +bool IsValidTranslateZ(const CSSNumericValue* value) { + return value && + value->Type().MatchesBaseType(CSSNumericValueType::BaseType::kLength); +} + +CSSTranslate* FromCSSTranslate(const CSSFunctionValue& value) { + DCHECK_GT(value.length(), 0UL); + + CSSNumericValue* x = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(0))); + + if (value.length() == 1) { + return CSSTranslate::Create( + x, CSSUnitValue::Create(0, CSSPrimitiveValue::UnitType::kPixels)); + } + + DCHECK_EQ(value.length(), 2UL); + + CSSNumericValue* y = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(1))); + + return CSSTranslate::Create(x, y); +} + +CSSTranslate* FromCSSTranslateXYZ(const CSSFunctionValue& value) { + DCHECK_EQ(value.length(), 1UL); + + CSSNumericValue* length = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(0))); + + switch (value.FunctionType()) { + case CSSValueTranslateX: + return CSSTranslate::Create( + length, + CSSUnitValue::Create(0, CSSPrimitiveValue::UnitType::kPixels)); + case CSSValueTranslateY: + return CSSTranslate::Create( + CSSUnitValue::Create(0, CSSPrimitiveValue::UnitType::kPixels), + length); + case CSSValueTranslateZ: + return CSSTranslate::Create( + CSSUnitValue::Create(0, CSSPrimitiveValue::UnitType::kPixels), + CSSUnitValue::Create(0, CSSPrimitiveValue::UnitType::kPixels), + length); + default: + NOTREACHED(); + return nullptr; + } +} + +CSSTranslate* FromCSSTranslate3D(const CSSFunctionValue& value) { + DCHECK_EQ(value.length(), 3UL); + + CSSNumericValue* x = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(0))); + CSSNumericValue* y = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(1))); + CSSNumericValue* z = + CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value.Item(2))); + + return CSSTranslate::Create(x, y, z); +} + +} // namespace + +CSSTranslate* CSSTranslate::Create(CSSNumericValue* x, + CSSNumericValue* y, + ExceptionState& exception_state) { + if (!IsValidTranslateXY(x) || !IsValidTranslateXY(y)) { + exception_state.ThrowTypeError( + "Must pass length or percentage to X and Y of CSSTranslate"); + return nullptr; + } + return new CSSTranslate( + x, y, CSSUnitValue::Create(0, CSSPrimitiveValue::UnitType::kPixels), + true /* is2D */); +} + +CSSTranslate* CSSTranslate::Create(CSSNumericValue* x, + CSSNumericValue* y, + CSSNumericValue* z, + ExceptionState& exception_state) { + if (!IsValidTranslateXY(x) || !IsValidTranslateXY(y) || + !IsValidTranslateZ(z)) { + exception_state.ThrowTypeError( + "Must pass length or percentage to X, Y and Z of CSSTranslate"); + return nullptr; + } + return new CSSTranslate(x, y, z, false /* is2D */); +} + +CSSTranslate* CSSTranslate::Create(CSSNumericValue* x, CSSNumericValue* y) { + return new CSSTranslate( + x, y, CSSUnitValue::Create(0, CSSPrimitiveValue::UnitType::kPixels), + true /* is2D */); +} + +CSSTranslate* CSSTranslate::Create(CSSNumericValue* x, + CSSNumericValue* y, + CSSNumericValue* z) { + return new CSSTranslate(x, y, z, false /* is2D */); +} + +CSSTranslate* CSSTranslate::FromCSSValue(const CSSFunctionValue& value) { + switch (value.FunctionType()) { + case CSSValueTranslateX: + case CSSValueTranslateY: + case CSSValueTranslateZ: + return FromCSSTranslateXYZ(value); + case CSSValueTranslate: + return FromCSSTranslate(value); + case CSSValueTranslate3d: + return FromCSSTranslate3D(value); + default: + NOTREACHED(); + return nullptr; + } +} + +void CSSTranslate::setX(CSSNumericValue* x, ExceptionState& exception_state) { + if (!IsValidTranslateXY(x)) { + exception_state.ThrowTypeError( + "Must pass length or percentage to X of CSSTranslate"); + return; + } + x_ = x; +} + +void CSSTranslate::setY(CSSNumericValue* y, ExceptionState& exception_state) { + if (!IsValidTranslateXY(y)) { + exception_state.ThrowTypeError( + "Must pass length or percent to Y of CSSTranslate"); + return; + } + y_ = y; +} + +void CSSTranslate::setZ(CSSNumericValue* z, ExceptionState& exception_state) { + if (!IsValidTranslateZ(z)) { + exception_state.ThrowTypeError("Must pass length to Z of CSSTranslate"); + return; + } + z_ = z; +} + +DOMMatrix* CSSTranslate::toMatrix(ExceptionState& exception_state) const { + CSSUnitValue* x = x_->to(CSSPrimitiveValue::UnitType::kPixels); + CSSUnitValue* y = y_->to(CSSPrimitiveValue::UnitType::kPixels); + CSSUnitValue* z = z_->to(CSSPrimitiveValue::UnitType::kPixels); + + if (!x || !y || !z) { + exception_state.ThrowTypeError( + "Cannot create matrix if units are not compatible with px"); + return nullptr; + } + + DOMMatrix* matrix = DOMMatrix::Create(); + if (is2D()) + matrix->translateSelf(x->value(), y->value()); + else + matrix->translateSelf(x->value(), y->value(), z->value()); + + return matrix; +} + +const CSSFunctionValue* CSSTranslate::ToCSSValue() const { + const CSSValue* x = x_->ToCSSValue(); + const CSSValue* y = y_->ToCSSValue(); + + CSSFunctionValue* result = CSSFunctionValue::Create( + is2D() ? CSSValueTranslate : CSSValueTranslate3d); + result->Append(*x); + result->Append(*y); + if (!is2D()) { + const CSSValue* z = z_->ToCSSValue(); + result->Append(*z); + } + return result; +} + +CSSTranslate::CSSTranslate(CSSNumericValue* x, + CSSNumericValue* y, + CSSNumericValue* z, + bool is2D) + : CSSTransformComponent(is2D), x_(x), y_(y), z_(z) { + DCHECK(IsValidTranslateXY(x)); + DCHECK(IsValidTranslateXY(y)); + DCHECK(IsValidTranslateZ(z)); +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTranslate.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTranslate.h new file mode 100644 index 0000000000..3067c94dbc --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTranslate.h @@ -0,0 +1,78 @@ +// 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 CSSTranslate_h +#define CSSTranslate_h + +#include "base/macros.h" +#include "core/css/CSSPrimitiveValue.h" +#include "core/css/cssom/CSSStyleValue.h" +#include "core/css/cssom/CSSTransformComponent.h" +#include "core/css/cssom/CSSUnitValue.h" + +namespace blink { + +class CSSNumericValue; +class DOMMatrix; +class ExceptionState; + +// Represents a translation value in a CSSTransformValue used for properties +// like "transform". +// See CSSTranslate.idl for more information about this class. +class CORE_EXPORT CSSTranslate final : public CSSTransformComponent { + DEFINE_WRAPPERTYPEINFO(); + + public: + // Constructors defined in the IDL. + static CSSTranslate* Create(CSSNumericValue* x, + CSSNumericValue* y, + CSSNumericValue* z, + ExceptionState&); + static CSSTranslate* Create(CSSNumericValue* x, + CSSNumericValue* y, + ExceptionState&); + + // Blink-internal ways of creating CSSTranslates. + static CSSTranslate* Create(CSSNumericValue* x, CSSNumericValue* y); + static CSSTranslate* Create(CSSNumericValue* x, + CSSNumericValue* y, + CSSNumericValue* z); + static CSSTranslate* FromCSSValue(const CSSFunctionValue&); + + // Getters and setters for attributes defined in the IDL. + CSSNumericValue* x() { return x_; } + CSSNumericValue* y() { return y_; } + CSSNumericValue* z() { return z_; } + void setX(CSSNumericValue* x, ExceptionState&); + void setY(CSSNumericValue* y, ExceptionState&); + void setZ(CSSNumericValue* z, ExceptionState&); + + DOMMatrix* toMatrix(ExceptionState&) const final; + + // Internal methods - from CSSTransformComponent. + TransformComponentType GetType() const final { return kTranslationType; } + const CSSFunctionValue* ToCSSValue() const final; + + virtual void Trace(blink::Visitor* visitor) { + visitor->Trace(x_); + visitor->Trace(y_); + visitor->Trace(z_); + CSSTransformComponent::Trace(visitor); + } + + private: + CSSTranslate(CSSNumericValue* x, + CSSNumericValue* y, + CSSNumericValue* z, + bool is2D); + + Member x_; + Member y_; + Member z_; + DISALLOW_COPY_AND_ASSIGN(CSSTranslate); +}; + +} // namespace blink + +#endif diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTranslate.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTranslate.idl new file mode 100644 index 0000000000..ca272a6734 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSTranslate.idl @@ -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. + +// Represents a translation value in a CSSTransformValue used for properties +// like "transform". +// Spec: https://drafts.css-houdini.org/css-typed-om/#csstranslate +[ + Constructor(CSSNumericValue x, CSSNumericValue y, + optional CSSNumericValue z), + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), + RaisesException=Constructor +] interface CSSTranslate : CSSTransformComponent { + [RaisesException=Setter] attribute CSSNumericValue x; + [RaisesException=Setter] attribute CSSNumericValue y; + [RaisesException=Setter] attribute CSSNumericValue z; +}; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSURLImageValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSURLImageValue.cpp new file mode 100644 index 0000000000..93cc090308 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSURLImageValue.cpp @@ -0,0 +1,89 @@ +// 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 "core/css/cssom/CSSURLImageValue.h" + +#include "bindings/core/v8/ExceptionState.h" +#include "core/css/CSSImageValue.h" +#include "core/dom/ExecutionContext.h" +#include "core/loader/resource/ImageResourceContent.h" +#include "core/style/StyleImage.h" +#include "platform/bindings/ScriptState.h" + +namespace blink { + +CSSURLImageValue* CSSURLImageValue::Create(ScriptState* script_state, + const AtomicString& url, + ExceptionState& exception_state) { + const auto* execution_context = ExecutionContext::From(script_state); + DCHECK(execution_context); + KURL parsed_url = execution_context->CompleteURL(url); + if (!parsed_url.IsValid()) { + exception_state.ThrowTypeError("Failed to parse URL from " + url); + return nullptr; + } + // Use absolute URL for CSSImageValue but keep relative URL for + // getter and serialization. + return new CSSURLImageValue( + *CSSImageValue::Create(url, parsed_url, Referrer())); +} + +CSSURLImageValue* CSSURLImageValue::FromCSSValue(const CSSImageValue& value) { + return new CSSURLImageValue(value); +} + +const String& CSSURLImageValue::url() const { + return value_->RelativeUrl(); +} + +WTF::Optional CSSURLImageValue::IntrinsicSize() const { + if (Status() != ResourceStatus::kCached) + return WTF::nullopt; + + DCHECK(!value_->IsCachePending()); + ImageResourceContent* resource_content = value_->CachedImage()->CachedImage(); + return resource_content + ? resource_content->IntrinsicSize(kDoNotRespectImageOrientation) + : IntSize(0, 0); +} + +ResourceStatus CSSURLImageValue::Status() const { + if (value_->IsCachePending()) + return ResourceStatus::kNotStarted; + return value_->CachedImage()->CachedImage()->GetContentStatus(); +} + +scoped_refptr CSSURLImageValue::GetSourceImageForCanvas( + SourceImageStatus*, + AccelerationHint, + const FloatSize&) { + return GetImage(); +} + +scoped_refptr CSSURLImageValue::GetImage() const { + if (value_->IsCachePending()) + return nullptr; + // cachedImage can be null if image is StyleInvalidImage + ImageResourceContent* cached_image = value_->CachedImage()->CachedImage(); + if (cached_image) { + // getImage() returns the nullImage() if the image is not available yet + return cached_image->GetImage()->ImageForDefaultFrame(); + } + return nullptr; +} + +bool CSSURLImageValue::IsAccelerated() const { + return GetImage() && GetImage()->IsTextureBacked(); +} + +const CSSValue* CSSURLImageValue::ToCSSValue() const { + return value_; +} + +void CSSURLImageValue::Trace(blink::Visitor* visitor) { + visitor->Trace(value_); + CSSStyleImageValue::Trace(visitor); +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSURLImageValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSURLImageValue.h index 6cd216d8d9..a5e77b7229 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSURLImageValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSURLImageValue.h @@ -7,42 +7,44 @@ #include "base/macros.h" #include "core/css/cssom/CSSStyleImageValue.h" -#include "platform/bindings/ScriptState.h" namespace blink { -class CORE_EXPORT CSSURLImageValue final : public CSSStyleImageValue { - DEFINE_WRAPPERTYPEINFO(); +class ScriptState; +class CSSImageValue; +class CORE_EXPORT CSSURLImageValue final : public CSSStyleImageValue { public: - static CSSURLImageValue* Create(ScriptState* script_state, + static CSSURLImageValue* Create(ScriptState*, const AtomicString& url, - ExceptionState& exception_state) { - const auto* execution_context = ExecutionContext::From(script_state); - DCHECK(execution_context); - KURL parsed_url = execution_context->CompleteURL(url); - if (!parsed_url.IsValid()) { - exception_state.ThrowTypeError("Failed to parse URL from " + url); - return nullptr; - } - // Use absolute URL for CSSImageValue but keep relative URL for - // getter and serialization. - return new CSSURLImageValue( - CSSImageValue::Create(url, parsed_url, Referrer())); - } - static CSSURLImageValue* Create(const CSSImageValue* image_value) { - return new CSSURLImageValue(image_value); - } - - StyleValueType GetType() const override { return kURLImageType; } - - const CSSValue* ToCSSValue() const override { return CssImageValue(); } - - const String& url() const { return CssImageValue()->RelativeUrl(); } + ExceptionState&); + + static CSSURLImageValue* FromCSSValue(const CSSImageValue&); + + const String& url() const; + + // CSSStyleImageValue + WTF::Optional IntrinsicSize() const final; + + // CanvasImageSource + ResourceStatus Status() const final; + scoped_refptr GetSourceImageForCanvas(SourceImageStatus*, + AccelerationHint, + const FloatSize&) final; + bool IsAccelerated() const final; + + // CSSStyleValue + StyleValueType GetType() const final { return kURLImageType; } + const CSSValue* ToCSSValue() const final; + + virtual void Trace(blink::Visitor*); private: - explicit CSSURLImageValue(const CSSImageValue* image_value) - : CSSStyleImageValue(image_value) {} + explicit CSSURLImageValue(const CSSImageValue& value) : value_(value) {} + + scoped_refptr GetImage() const; + + Member value_; DISALLOW_COPY_AND_ASSIGN(CSSURLImageValue); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.cpp index 02bbd98040..e0e40aaa95 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.cpp @@ -5,6 +5,7 @@ #include "core/css/cssom/CSSUnitValue.h" #include "bindings/core/v8/ExceptionState.h" +#include "core/animation/LengthPropertyFunctions.h" #include "core/css/CSSCalculationValue.h" #include "core/css/CSSResolutionUnits.h" #include "core/css/cssom/CSSMathInvert.h" @@ -13,6 +14,7 @@ #include "core/css/cssom/CSSMathProduct.h" #include "core/css/cssom/CSSMathSum.h" #include "core/css/cssom/CSSNumericSumValue.h" +#include "core/css/properties/CSSProperty.h" #include "platform/wtf/MathExtras.h" namespace blink { @@ -32,6 +34,23 @@ CSSPrimitiveValue::UnitType ToCanonicalUnitIfPossible( return canonical_unit; } +bool IsValueOutOfRangeForProperty(CSSPropertyID property_id, double value) { + // FIXME: Avoid this CSSProperty::Get call as it can be costly. + // The caller often has a CSSProperty already, so we can just pass it here. + if (LengthPropertyFunctions::GetValueRange(CSSProperty::Get(property_id)) == + kValueRangeNonNegative && + value < 0) + return true; + + // For non-length properties and special cases. + switch (property_id) { + case CSSPropertyFontWeight: + return value < 0 || value > 1000; + default: + return false; + } +} + } // namespace CSSUnitValue* CSSUnitValue::Create(double value, @@ -61,17 +80,6 @@ CSSUnitValue* CSSUnitValue::FromCSSValue(const CSSPrimitiveValue& value) { return new CSSUnitValue(value.GetDoubleValue(), unit); } -void CSSUnitValue::setUnit(const String& unit_name, - ExceptionState& exception_state) { - CSSPrimitiveValue::UnitType unit = UnitFromName(unit_name); - if (!IsValidUnit(unit)) { - exception_state.ThrowTypeError("Invalid unit: " + unit_name); - return; - } - - unit_ = unit; -} - String CSSUnitValue::unit() const { if (unit_ == CSSPrimitiveValue::UnitType::kNumber) return "number"; @@ -81,24 +89,7 @@ String CSSUnitValue::unit() const { } CSSStyleValue::StyleValueType CSSUnitValue::GetType() const { - if (unit_ == CSSPrimitiveValue::UnitType::kNumber) - return StyleValueType::kNumberType; - if (unit_ == CSSPrimitiveValue::UnitType::kPercentage) - return StyleValueType::kPercentType; - if (CSSPrimitiveValue::IsLength(unit_)) - return StyleValueType::kLengthType; - if (CSSPrimitiveValue::IsAngle(unit_)) - return StyleValueType::kAngleType; - if (CSSPrimitiveValue::IsTime(unit_)) - return StyleValueType::kTimeType; - if (CSSPrimitiveValue::IsFrequency(unit_)) - return StyleValueType::kFrequencyType; - if (CSSPrimitiveValue::IsResolution(unit_)) - return StyleValueType::kResolutionType; - if (CSSPrimitiveValue::IsFlex(unit_)) - return StyleValueType::kFlexType; - NOTREACHED(); - return StyleValueType::kUnknownType; + return StyleValueType::kUnitType; } CSSUnitValue* CSSUnitValue::ConvertTo( @@ -145,6 +136,18 @@ const CSSPrimitiveValue* CSSUnitValue::ToCSSValue() const { return CSSPrimitiveValue::Create(value_, unit_); } +const CSSPrimitiveValue* CSSUnitValue::ToCSSValueWithProperty( + CSSPropertyID property_id) const { + if (IsValueOutOfRangeForProperty(property_id, value_)) { + // Wrap out of range values with a calc. + CSSCalcExpressionNode* node = ToCalcExpressionNode(); + node->SetIsNestedCalc(); + return CSSPrimitiveValue::Create(CSSCalcValue::Create(node)); + } + + return CSSPrimitiveValue::Create(value_, unit_); +} + CSSCalcExpressionNode* CSSUnitValue::ToCalcExpressionNode() const { return CSSCalcValue::CreateExpressionNode( CSSPrimitiveValue::Create(value_, unit_)); @@ -155,9 +158,18 @@ CSSNumericValue* CSSUnitValue::Negate() { } CSSNumericValue* CSSUnitValue::Invert() { - if (unit_ == CSSPrimitiveValue::UnitType::kNumber) + if (unit_ == CSSPrimitiveValue::UnitType::kNumber) { + if (value_ == 0) + return nullptr; return CSSUnitValue::Create(1.0 / value_, unit_); + } return CSSMathInvert::Create(this); } +void CSSUnitValue::BuildCSSText(Nested, + ParenLess, + StringBuilder& result) const { + result.Append(ToCSSValue()->CssText()); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.h index b57e248095..d9041e28c7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.h @@ -31,7 +31,6 @@ class CORE_EXPORT CSSUnitValue final : public CSSNumericValue { // Setters and getters for attributes defined in the IDL. void setValue(double new_value) { value_ = new_value; } double value() const { return value_; } - void setUnit(const String& new_unit, ExceptionState&); String unit() const; // Internal methods. @@ -46,11 +45,8 @@ class CORE_EXPORT CSSUnitValue final : public CSSNumericValue { // From CSSStyleValue. StyleValueType GetType() const final; - bool ContainsPercent() const final { - return unit_ == CSSPrimitiveValue::UnitType::kPercentage; - } - const CSSPrimitiveValue* ToCSSValue() const final; + const CSSPrimitiveValue* ToCSSValueWithProperty(CSSPropertyID) const final; CSSCalcExpressionNode* ToCalcExpressionNode() const final; private: @@ -62,6 +58,8 @@ class CORE_EXPORT CSSUnitValue final : public CSSNumericValue { double ConvertFixedLength(CSSPrimitiveValue::UnitType) const; double ConvertAngle(CSSPrimitiveValue::UnitType) const; + void BuildCSSText(Nested, ParenLess, StringBuilder&) const final; + // From CSSNumericValue CSSNumericValue* Negate() final; CSSNumericValue* Invert() final; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.idl index b8768136fa..3ab49ee0e2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.idl @@ -8,9 +8,9 @@ [ Constructor(double value, DOMString unit), RaisesException=Constructor, - Exposed=(Window,PaintWorklet), - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet) ] interface CSSUnitValue : CSSNumericValue { [EnforceRange] attribute double value; - [RaisesException=Setter] attribute DOMString unit; + readonly attribute DOMString unit; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValueTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValueTest.cpp index 8f59a348e2..cda443dffe 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValueTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValueTest.cpp @@ -180,34 +180,4 @@ TEST(CSSUnitValueTest, QuarterMillimeterToOtherUnit) { kEpsilon); } -using UnitType = CSSPrimitiveValue::UnitType; -using BaseType = CSSNumericValueType::BaseType; - -class CSSUnitValueTypeTest - : public ::testing::TestWithParam> {}; - -TEST_P(CSSUnitValueTypeTest, TypeInitializesCorrectly) { - const CSSUnitValue* value = CSSUnitValue::Create(0, GetParam().first); - const auto& type = value->Type(); - for (unsigned i = 0; i < CSSNumericValueType::kNumBaseTypes; i++) { - const auto base_type = static_cast(i); - EXPECT_FALSE(type.HasPercentHint()); - if (base_type == GetParam().second) - EXPECT_EQ(type.Exponent(base_type), 1); - else - EXPECT_EQ(type.Exponent(base_type), 0); - } -} - -INSTANTIATE_TEST_CASE_P( - CanonicalUnits, - CSSUnitValueTypeTest, - ::testing::Values( - std::make_pair(UnitType::kPixels, BaseType::kLength), - std::make_pair(UnitType::kSeconds, BaseType::kTime), - std::make_pair(UnitType::kDegrees, BaseType::kAngle), - std::make_pair(UnitType::kHertz, BaseType::kFrequency), - std::make_pair(UnitType::kDotsPerInch, BaseType::kResolution), - std::make_pair(UnitType::kPercentage, BaseType::kPercent))); - } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValues.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValues.idl index 54e661bc07..5f1eeb3a11 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValues.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnitValues.idl @@ -27,7 +27,7 @@ [NewObject] static CSSUnitValue pc(double value); [NewObject] static CSSUnitValue px(double value); [NewObject] static CSSUnitValue Q(double value); - // Currently unsupported length units that are specified + // TODO: Currently unsupported length units that are specified // [NewObject] static CSSUnitValue ic(double value); // [NewObject] static CSSUnitValue lh(double value); // [NewObject] static CSSUnitValue rlh(double value); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.cpp index 71a3f180af..a94b85b927 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.cpp @@ -19,9 +19,9 @@ StringView FindVariableName(CSSParserTokenRange& range) { return range.Consume().Value(); } -StringOrCSSVariableReferenceValue VariableReferenceValue( +CSSUnparsedSegment VariableReferenceValue( const StringView& variable_name, - const HeapVector& tokens) { + const HeapVector& tokens) { CSSUnparsedValue* unparsed_value; if (tokens.size() == 0) unparsed_value = nullptr; @@ -31,19 +31,17 @@ StringOrCSSVariableReferenceValue VariableReferenceValue( CSSStyleVariableReferenceValue* variable_reference = CSSStyleVariableReferenceValue::Create(variable_name.ToString(), unparsed_value); - return StringOrCSSVariableReferenceValue::FromCSSVariableReferenceValue( - variable_reference); + return CSSUnparsedSegment::FromCSSVariableReferenceValue(variable_reference); } -HeapVector ParserTokenRangeToTokens( +HeapVector ParserTokenRangeToTokens( CSSParserTokenRange range) { - HeapVector tokens; + HeapVector tokens; StringBuilder builder; while (!range.AtEnd()) { if (range.Peek().FunctionId() == CSSValueVar) { if (!builder.IsEmpty()) { - tokens.push_back( - StringOrCSSVariableReferenceValue::FromString(builder.ToString())); + tokens.push_back(CSSUnparsedSegment::FromString(builder.ToString())); builder.Clear(); } CSSParserTokenRange block = range.ConsumeBlock(); @@ -58,8 +56,7 @@ HeapVector ParserTokenRangeToTokens( } } if (!builder.IsEmpty()) { - tokens.push_back( - StringOrCSSVariableReferenceValue::FromString(builder.ToString())); + tokens.push_back(CSSUnparsedSegment::FromString(builder.ToString())); } return tokens; } @@ -76,7 +73,39 @@ CSSUnparsedValue* CSSUnparsedValue::FromCSSValue(const CSSVariableData& value) { return CSSUnparsedValue::Create(ParserTokenRangeToTokens(value.TokenRange())); } +CSSUnparsedSegment CSSUnparsedValue::AnonymousIndexedGetter( + unsigned index, + ExceptionState& exception_state) { + if (index < tokens_.size()) + return tokens_[index]; + return {}; +} + +bool CSSUnparsedValue::AnonymousIndexedSetter(unsigned index, + const CSSUnparsedSegment& segment, + ExceptionState& exception_state) { + if (index < tokens_.size()) { + tokens_[index] = segment; + return true; + } + + if (index == tokens_.size()) { + tokens_.push_back(segment); + return true; + } + + exception_state.ThrowRangeError( + ExceptionMessages::IndexOutsideRange( + "index", index, 0, ExceptionMessages::kInclusiveBound, tokens_.size(), + ExceptionMessages::kInclusiveBound)); + return false; +} + const CSSValue* CSSUnparsedValue::ToCSSValue() const { + if (tokens_.IsEmpty()) { + return CSSVariableReferenceValue::Create(CSSVariableData::Create()); + } + CSSTokenizer tokenizer(ToString()); const auto tokens = tokenizer.TokenizeToEOF(); return CSSVariableReferenceValue::Create(CSSVariableData::Create( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.h index 42cb87bae9..0f1d622c57 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.h @@ -14,16 +14,21 @@ namespace blink { class CSSVariableReferenceValue; class CSSVariableData; +using CSSUnparsedSegment = StringOrCSSVariableReferenceValue; class CORE_EXPORT CSSUnparsedValue final : public CSSStyleValue { DEFINE_WRAPPERTYPEINFO(); public: static CSSUnparsedValue* Create( - const HeapVector& tokens) { + const HeapVector& tokens) { return new CSSUnparsedValue(tokens); } + // Blink-internal constructor + static CSSUnparsedValue* Create() { + return Create(HeapVector()); + } static CSSUnparsedValue* FromCSSValue(const CSSVariableReferenceValue&); static CSSUnparsedValue* FromCSSValue(const CSSVariableData&); @@ -31,13 +36,10 @@ class CORE_EXPORT CSSUnparsedValue final : public CSSStyleValue { StyleValueType GetType() const override { return kUnparsedType; } - StringOrCSSVariableReferenceValue AnonymousIndexedGetter( - unsigned index, - ExceptionState& exception_state) const { - if (index < tokens_.size()) - return tokens_[index]; - return {}; - } + CSSUnparsedSegment AnonymousIndexedGetter(unsigned, ExceptionState&); + bool AnonymousIndexedSetter(unsigned, + const CSSUnparsedSegment&, + ExceptionState&); size_t length() const { return tokens_.size(); } @@ -47,13 +49,13 @@ class CORE_EXPORT CSSUnparsedValue final : public CSSStyleValue { } protected: - CSSUnparsedValue(const HeapVector& tokens) + CSSUnparsedValue(const HeapVector& tokens) : CSSStyleValue(), tokens_(tokens) {} private: static CSSUnparsedValue* FromString(const String& string) { - HeapVector tokens; - tokens.push_back(StringOrCSSVariableReferenceValue::FromString(string)); + HeapVector tokens; + tokens.push_back(CSSUnparsedSegment::FromString(string)); return Create(tokens); } @@ -61,7 +63,7 @@ class CORE_EXPORT CSSUnparsedValue final : public CSSStyleValue { FRIEND_TEST_ALL_PREFIXES(CSSVariableReferenceValueTest, MixedList); - HeapVector tokens_; + HeapVector tokens_; DISALLOW_COPY_AND_ASSIGN(CSSUnparsedValue); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.idl index 6218b41e09..8792a46d73 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnparsedValue.idl @@ -6,10 +6,14 @@ // They represent a list of string fragments and variable references. // Spec: https://drafts.css-houdini.org/css-typed-om/#unparsedvalue-objects [ - Constructor((DOMString or CSSVariableReferenceValue)... members), - Exposed(Window CSSTypedOM, PaintWorklet CSSTypedOM) + Constructor(sequence members), + RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet) ] interface CSSUnparsedValue : CSSStyleValue { - iterable<(DOMString or CSSVariableReferenceValue)>; + iterable; readonly attribute unsigned long length; - [RaisesException] getter (DOMString or CSSVariableReferenceValue) (unsigned long index); + [RaisesException] getter CSSUnparsedSegment (unsigned long index); + [RaisesException] setter CSSUnparsedSegment (unsigned long index, CSSUnparsedSegment val); }; + +typedef (DOMString or CSSVariableReferenceValue) CSSUnparsedSegment; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnsupportedStyleValue.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnsupportedStyleValue.cpp index cb4c7d53e4..606bb712b6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnsupportedStyleValue.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnsupportedStyleValue.cpp @@ -9,8 +9,4 @@ namespace blink { -const CSSValue* CSSUnsupportedStyleValue::ToCSSValue() const { - return css_value_.Get(); -} - } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnsupportedStyleValue.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnsupportedStyleValue.h index e4ce6f177e..ccb4ad3fd2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnsupportedStyleValue.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSUnsupportedStyleValue.h @@ -17,27 +17,32 @@ namespace blink { class CORE_EXPORT CSSUnsupportedStyleValue final : public CSSStyleValue { public: static CSSUnsupportedStyleValue* Create(CSSPropertyID property, - const CSSValue& css_value) { - return new CSSUnsupportedStyleValue(property, css_value); + const String& css_text) { + return new CSSUnsupportedStyleValue(property, css_text); + } + static CSSUnsupportedStyleValue* Create(CSSPropertyID property, + const CSSValue& value) { + return new CSSUnsupportedStyleValue(property, value.CssText()); } StyleValueType GetType() const override { return StyleValueType::kUnknownType; } CSSPropertyID GetProperty() const { return property_; } - const CSSValue* ToCSSValue() const override; - - virtual void Trace(blink::Visitor* visitor) { - visitor->Trace(css_value_); - CSSStyleValue::Trace(visitor); + const CSSValue* ToCSSValue() const { + NOTREACHED(); + return nullptr; } + String toString() const final { return CSSText(); } + private: - CSSUnsupportedStyleValue(CSSPropertyID property, const CSSValue& css_value) - : property_(property), css_value_(css_value) {} + CSSUnsupportedStyleValue(CSSPropertyID property, const String& css_text) + : property_(property) { + SetCSSText(css_text); + } const CSSPropertyID property_; - Member css_value_; DISALLOW_COPY_AND_ASSIGN(CSSUnsupportedStyleValue); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSVariableReferenceValue.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSVariableReferenceValue.idl index 4d17cecea2..bcb4b3cd0f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSVariableReferenceValue.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/CSSVariableReferenceValue.idl @@ -5,11 +5,12 @@ // Represents a CSS var() reference in a CSS value. // Spec: https://drafts.css-houdini.org/css-typed-om/#cssvariablereferencevalue [ - Constructor(DOMString variable, optional CSSUnparsedValue fallback), - Exposed=(Window,PaintWorklet), + Constructor(DOMString variable, optional CSSUnparsedValue? fallback = null), RuntimeEnabled=CSSTypedOM, + Exposed=(Window,LayoutWorklet,PaintWorklet), + RaisesException=Constructor, ImplementedAs=CSSStyleVariableReferenceValue ] interface CSSVariableReferenceValue { - attribute DOMString variable; - attribute CSSUnparsedValue? fallback; + [RaisesException=Setter] attribute DOMString variable; + readonly attribute CSSUnparsedValue? fallback; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp index 58c466301f..e58dcb4fbf 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.cpp @@ -5,14 +5,184 @@ #include "core/css/cssom/ComputedStylePropertyMap.h" #include "core/css/CSSCustomPropertyDeclaration.h" +#include "core/css/CSSFunctionValue.h" +#include "core/css/CSSIdentifierValue.h" #include "core/css/CSSVariableData.h" #include "core/css/ComputedStyleCSSValueMapping.h" #include "core/dom/Document.h" #include "core/dom/PseudoElement.h" #include "core/style/ComputedStyle.h" +#include "platform/transforms/Matrix3DTransformOperation.h" +#include "platform/transforms/MatrixTransformOperation.h" +#include "platform/transforms/PerspectiveTransformOperation.h" +#include "platform/transforms/SkewTransformOperation.h" namespace blink { +namespace { + +// We collapse functions like translateX into translate, since we will reify +// them as a translate anyway. +const CSSValue* ComputedTransformComponent(const TransformOperation& operation, + float zoom) { + switch (operation.GetType()) { + case TransformOperation::kScaleX: + case TransformOperation::kScaleY: + case TransformOperation::kScaleZ: + case TransformOperation::kScale: + case TransformOperation::kScale3D: { + const auto& scale = ToScaleTransformOperation(operation); + CSSFunctionValue* result = CSSFunctionValue::Create( + operation.Is3DOperation() ? CSSValueScale3d : CSSValueScale); + result->Append(*CSSPrimitiveValue::Create( + scale.X(), CSSPrimitiveValue::UnitType::kNumber)); + result->Append(*CSSPrimitiveValue::Create( + scale.Y(), CSSPrimitiveValue::UnitType::kNumber)); + if (operation.Is3DOperation()) { + result->Append(*CSSPrimitiveValue::Create( + scale.Z(), CSSPrimitiveValue::UnitType::kNumber)); + } + return result; + } + case TransformOperation::kTranslateX: + case TransformOperation::kTranslateY: + case TransformOperation::kTranslateZ: + case TransformOperation::kTranslate: + case TransformOperation::kTranslate3D: { + const auto& translate = ToTranslateTransformOperation(operation); + CSSFunctionValue* result = CSSFunctionValue::Create( + operation.Is3DOperation() ? CSSValueTranslate3d : CSSValueTranslate); + result->Append(*CSSPrimitiveValue::Create(translate.X(), zoom)); + result->Append(*CSSPrimitiveValue::Create(translate.Y(), zoom)); + if (operation.Is3DOperation()) { + result->Append(*CSSPrimitiveValue::Create( + translate.Z(), CSSPrimitiveValue::UnitType::kPixels)); + } + return result; + } + case TransformOperation::kRotateX: + case TransformOperation::kRotateY: + case TransformOperation::kRotate3D: { + const auto& rotate = ToRotateTransformOperation(operation); + CSSFunctionValue* result = CSSFunctionValue::Create(CSSValueRotate3d); + result->Append(*CSSPrimitiveValue::Create( + rotate.X(), CSSPrimitiveValue::UnitType::kNumber)); + result->Append(*CSSPrimitiveValue::Create( + rotate.Y(), CSSPrimitiveValue::UnitType::kNumber)); + result->Append(*CSSPrimitiveValue::Create( + rotate.Z(), CSSPrimitiveValue::UnitType::kNumber)); + result->Append(*CSSPrimitiveValue::Create( + rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees)); + return result; + } + case TransformOperation::kRotate: { + const auto& rotate = ToRotateTransformOperation(operation); + CSSFunctionValue* result = CSSFunctionValue::Create(CSSValueRotate); + result->Append(*CSSPrimitiveValue::Create( + rotate.Angle(), CSSPrimitiveValue::UnitType::kDegrees)); + return result; + } + case TransformOperation::kSkewX: { + const auto& skew = ToSkewTransformOperation(operation); + CSSFunctionValue* result = CSSFunctionValue::Create(CSSValueSkewX); + result->Append(*CSSPrimitiveValue::Create( + skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees)); + return result; + } + case TransformOperation::kSkewY: { + const auto& skew = ToSkewTransformOperation(operation); + CSSFunctionValue* result = CSSFunctionValue::Create(CSSValueSkewY); + result->Append(*CSSPrimitiveValue::Create( + skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees)); + return result; + } + case TransformOperation::kSkew: { + const auto& skew = ToSkewTransformOperation(operation); + CSSFunctionValue* result = CSSFunctionValue::Create(CSSValueSkew); + result->Append(*CSSPrimitiveValue::Create( + skew.AngleX(), CSSPrimitiveValue::UnitType::kDegrees)); + result->Append(*CSSPrimitiveValue::Create( + skew.AngleY(), CSSPrimitiveValue::UnitType::kDegrees)); + return result; + } + case TransformOperation::kPerspective: { + const auto& perspective = ToPerspectiveTransformOperation(operation); + CSSFunctionValue* result = CSSFunctionValue::Create(CSSValuePerspective); + result->Append(*CSSPrimitiveValue::Create( + perspective.Perspective(), CSSPrimitiveValue::UnitType::kPixels)); + return result; + } + case TransformOperation::kMatrix: { + const auto& matrix = ToMatrixTransformOperation(operation).Matrix(); + CSSFunctionValue* result = CSSFunctionValue::Create(CSSValueMatrix); + double values[6] = {matrix.A(), matrix.B(), matrix.C(), + matrix.D(), matrix.E(), matrix.F()}; + for (double value : values) { + result->Append(*CSSPrimitiveValue::Create( + value, CSSPrimitiveValue::UnitType::kNumber)); + } + return result; + } + case TransformOperation::kMatrix3D: { + const auto& matrix = ToMatrix3DTransformOperation(operation).Matrix(); + CSSFunctionValue* result = CSSFunctionValue::Create(CSSValueMatrix3d); + double values[16] = { + matrix.M11(), matrix.M12(), matrix.M13(), matrix.M14(), + matrix.M21(), matrix.M22(), matrix.M23(), matrix.M24(), + matrix.M31(), matrix.M32(), matrix.M33(), matrix.M34(), + matrix.M41(), matrix.M42(), matrix.M43(), matrix.M44()}; + for (double value : values) { + result->Append(*CSSPrimitiveValue::Create( + value, CSSPrimitiveValue::UnitType::kNumber)); + } + return result; + } + case TransformOperation::kInterpolated: + // TODO(816803): The computed value in this case is not fully spec'd + // See https://github.com/w3c/css-houdini-drafts/issues/425 + return CSSIdentifierValue::Create(CSSValueNone); + default: + // The remaining operations are unsupported. + NOTREACHED(); + return CSSIdentifierValue::Create(CSSValueNone); + } +} + +const CSSValue* ComputedTransform(const ComputedStyle& style) { + if (style.Transform().Operations().size() == 0) + return CSSIdentifierValue::Create(CSSValueNone); + + CSSValueList* components = CSSValueList::CreateSpaceSeparated(); + for (const auto& operation : style.Transform().Operations()) { + components->Append( + *ComputedTransformComponent(*operation, style.EffectiveZoom())); + } + return components; +} + +} // namespace + +unsigned int ComputedStylePropertyMap::size() { + const ComputedStyle* style = UpdateStyle(); + if (!style) + return 0; + + const auto& variables = ComputedStyleCSSValueMapping::GetVariables(*style); + return CSSComputedStyleDeclaration::ComputableProperties().size() + + (variables ? variables->size() : 0); +} + +bool ComputedStylePropertyMap::ComparePropertyNames(const String& a, + const String& b) { + if (a.StartsWith("--")) + return b.StartsWith("--") && WTF::CodePointCompareLessThan(a, b); + if (a.StartsWith("-")) { + return b.StartsWith("--") || + (b.StartsWith("-") && WTF::CodePointCompareLessThan(a, b)); + } + return b.StartsWith("-") || WTF::CodePointCompareLessThan(a, b); +} + Node* ComputedStylePropertyMap::StyledNode() const { DCHECK(node_); if (!pseudo_id_) @@ -53,9 +223,17 @@ const CSSValue* ComputedStylePropertyMap::GetProperty( const ComputedStyle* style = UpdateStyle(); if (!style) return nullptr; - return CSSProperty::Get(property_id) - .CSSValueFromComputedStyle(*style, nullptr /* layout_object */, - StyledNode(), false); + + // Special cases for properties where CSSProperty::CSSValueFromComputedStyle + // doesn't return the correct computed value + switch (property_id) { + case CSSPropertyTransform: + return ComputedTransform(*style); + default: + return CSSProperty::Get(property_id) + .CSSValueFromComputedStyle(*style, nullptr /* layout_object */, + StyledNode(), false); + } } const CSSValue* ComputedStylePropertyMap::GetCustomProperty( @@ -73,6 +251,9 @@ void ComputedStylePropertyMap::ForEachProperty( if (!style) return; + // Have to sort by all properties by code point, so we have to store + // them in a buffer first. + HeapVector>> values; for (const CSSProperty* property : CSSComputedStyleDeclaration::ComputableProperties()) { DCHECK(property); @@ -80,18 +261,44 @@ void ComputedStylePropertyMap::ForEachProperty( const CSSValue* value = property->CSSValueFromComputedStyle( *style, nullptr /* layout_object */, StyledNode(), false); if (value) - callback(property->GetPropertyName(), *value); + values.emplace_back(property->GetPropertyNameAtomicString(), value); } const auto& variables = ComputedStyleCSSValueMapping::GetVariables(*style); if (variables) { for (const auto& name_value : *variables) { if (name_value.value) { - callback(name_value.key, *CSSCustomPropertyDeclaration::Create( - name_value.key, name_value.value)); + values.emplace_back(name_value.key, + CSSCustomPropertyDeclaration::Create( + name_value.key, name_value.value)); } } } + + std::sort(values.begin(), values.end(), [](const auto& a, const auto& b) { + return ComparePropertyNames(a.first, b.first); + }); + + for (const auto& value : values) + callback(value.first, *value.second); +} + +String ComputedStylePropertyMap::SerializationForShorthand( + const CSSProperty& property) { + DCHECK(property.IsShorthand()); + const ComputedStyle* style = UpdateStyle(); + if (!style) { + NOTREACHED(); + return ""; + } + + if (const CSSValue* value = property.CSSValueFromComputedStyle( + *style, nullptr /* layout_object */, StyledNode(), false)) { + return value->CssText(); + } + + NOTREACHED(); + return ""; } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.h index 561043ac73..2c9c1041ea 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/ComputedStylePropertyMap.h @@ -32,6 +32,13 @@ class CORE_EXPORT ComputedStylePropertyMap : public StylePropertyMapReadOnly { StylePropertyMapReadOnly::Trace(visitor); } + unsigned int size() override; + + // ComputedStylePropertyMap needs to be sorted. This puts CSS properties + // first, then prefixed properties, then custom properties. Everything is + // sorted by code point within each category. + static bool ComparePropertyNames(const String&, const String&); + protected: ComputedStylePropertyMap(Node* node, const String& pseudo_element = String()) : StylePropertyMapReadOnly(), @@ -42,6 +49,8 @@ class CORE_EXPORT ComputedStylePropertyMap : public StylePropertyMapReadOnly { const CSSValue* GetCustomProperty(AtomicString) override; void ForEachProperty(const IterationCallback&) override; + String SerializationForShorthand(const CSSProperty&) final; + private: // TODO: Pseudo-element support requires reintroducing Element.pseudo(...). // See diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/DeclaredStylePropertyMap.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/DeclaredStylePropertyMap.cpp index c43adc3509..e1b086f440 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/DeclaredStylePropertyMap.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/DeclaredStylePropertyMap.cpp @@ -9,6 +9,7 @@ #include "core/css/CSSStyleRule.h" #include "core/css/CSSStyleSheet.h" #include "core/css/CSSVariableReferenceValue.h" +#include "core/css/StylePropertySerializer.h" #include "core/css/StyleRule.h" namespace blink { @@ -16,6 +17,12 @@ namespace blink { DeclaredStylePropertyMap::DeclaredStylePropertyMap(CSSStyleRule* owner_rule) : StylePropertyMap(), owner_rule_(owner_rule) {} +unsigned int DeclaredStylePropertyMap::size() { + if (!GetStyleRule()) + return 0; + return GetStyleRule()->Properties().PropertyCount(); +} + const CSSValue* DeclaredStylePropertyMap::GetProperty( CSSPropertyID property_id) { if (!GetStyleRule()) @@ -38,6 +45,17 @@ void DeclaredStylePropertyMap::SetProperty(CSSPropertyID property_id, GetStyleRule()->MutableProperties().SetProperty(property_id, value); } +bool DeclaredStylePropertyMap::SetShorthandProperty( + CSSPropertyID property_id, + const String& value, + SecureContextMode secure_context_mode) { + DCHECK(CSSProperty::Get(property_id).IsShorthand()); + CSSStyleSheet::RuleMutationScope mutation_scope(owner_rule_); + const auto result = GetStyleRule()->MutableProperties().SetProperty( + property_id, value, false /* important */, secure_context_mode); + return result.did_parse; +} + void DeclaredStylePropertyMap::SetCustomProperty( const AtomicString& property_name, const CSSValue& value) { @@ -68,6 +86,13 @@ void DeclaredStylePropertyMap::RemoveCustomProperty( GetStyleRule()->MutableProperties().RemoveProperty(property_name); } +void DeclaredStylePropertyMap::RemoveAllProperties() { + if (!GetStyleRule()) + return; + CSSStyleSheet::RuleMutationScope mutation_scope(owner_rule_); + GetStyleRule()->MutableProperties().Clear(); +} + void DeclaredStylePropertyMap::ForEachProperty( const IterationCallback& callback) { if (!GetStyleRule()) @@ -93,4 +118,15 @@ StyleRule* DeclaredStylePropertyMap::GetStyleRule() const { return owner_rule_->GetStyleRule(); } +String DeclaredStylePropertyMap::SerializationForShorthand( + const CSSProperty& property) { + DCHECK(property.IsShorthand()); + if (StyleRule* style_rule = GetStyleRule()) { + return StylePropertySerializer(style_rule->Properties()) + .GetPropertyValue(property.PropertyID()); + } + + return ""; +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/DeclaredStylePropertyMap.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/DeclaredStylePropertyMap.h index 4e3ddf99b4..c1747ad90b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/DeclaredStylePropertyMap.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/DeclaredStylePropertyMap.h @@ -19,7 +19,7 @@ class StyleRule; // The declared StylePropertyMap retrieves styles specified by a CSS style rule // and returns them as CSSStyleValues. The IDL for this class is in // StylePropertyMap.idl. The declared StylePropertyMap for an element is -// accessed via CSSStyleRule.attributeStyleMap (see CSSStyleRule.idl) +// accessed via CSSStyleRule.styleMap (see CSSStyleRule.idl) class CORE_EXPORT DeclaredStylePropertyMap final : public StylePropertyMap { WTF_MAKE_NONCOPYABLE(DeclaredStylePropertyMap); @@ -31,14 +31,22 @@ class CORE_EXPORT DeclaredStylePropertyMap final : public StylePropertyMap { StylePropertyMap::Trace(visitor); } + unsigned int size() final; + protected: const CSSValue* GetProperty(CSSPropertyID) override; const CSSValue* GetCustomProperty(AtomicString) override; void ForEachProperty(const IterationCallback&) override; void SetProperty(CSSPropertyID, const CSSValue&) override; + bool SetShorthandProperty(CSSPropertyID, + const String&, + SecureContextMode) override; void SetCustomProperty(const AtomicString&, const CSSValue&) override; void RemoveProperty(CSSPropertyID) override; void RemoveCustomProperty(const AtomicString&) override; + void RemoveAllProperties() final; + + String SerializationForShorthand(const CSSProperty&) final; private: StyleRule* GetStyleRule() const; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp index 75a4ef94aa..b3a9a321ac 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp @@ -7,18 +7,26 @@ #include "core/css/CSSCustomPropertyDeclaration.h" #include "core/css/CSSPropertyValueSet.h" #include "core/css/CSSVariableReferenceValue.h" +#include "core/css/StylePropertySerializer.h" namespace blink { +unsigned int InlineStylePropertyMap::size() { + const CSSPropertyValueSet* inline_style = owner_element_->InlineStyle(); + return inline_style ? inline_style->PropertyCount() : 0; +} + const CSSValue* InlineStylePropertyMap::GetProperty(CSSPropertyID property_id) { - return owner_element_->EnsureMutableInlineStyle().GetPropertyCSSValue( - property_id); + const CSSPropertyValueSet* inline_style = owner_element_->InlineStyle(); + return inline_style ? inline_style->GetPropertyCSSValue(property_id) + : nullptr; } const CSSValue* InlineStylePropertyMap::GetCustomProperty( AtomicString property_name) { - return owner_element_->EnsureMutableInlineStyle().GetPropertyCSSValue( - property_name); + const CSSPropertyValueSet* inline_style = owner_element_->InlineStyle(); + return inline_style ? inline_style->GetPropertyCSSValue(property_name) + : nullptr; } void InlineStylePropertyMap::SetProperty(CSSPropertyID property_id, @@ -26,6 +34,16 @@ void InlineStylePropertyMap::SetProperty(CSSPropertyID property_id, owner_element_->SetInlineStyleProperty(property_id, value); } +bool InlineStylePropertyMap::SetShorthandProperty( + CSSPropertyID property_id, + const String& value, + SecureContextMode secure_context_mode) { + DCHECK(CSSProperty::Get(property_id).IsShorthand()); + const auto result = owner_element_->EnsureMutableInlineStyle().SetProperty( + property_id, value, false /* important */, secure_context_mode); + return result.did_parse; +} + void InlineStylePropertyMap::SetCustomProperty( const AtomicString& property_name, const CSSValue& value) { @@ -46,6 +64,10 @@ void InlineStylePropertyMap::RemoveCustomProperty( owner_element_->RemoveInlineStyleProperty(property_name); } +void InlineStylePropertyMap::RemoveAllProperties() { + owner_element_->RemoveAllInlineStyleProperties(); +} + void InlineStylePropertyMap::ForEachProperty( const IterationCallback& callback) { CSSPropertyValueSet& inline_style_set = @@ -63,4 +85,16 @@ void InlineStylePropertyMap::ForEachProperty( } } +String InlineStylePropertyMap::SerializationForShorthand( + const CSSProperty& property) { + DCHECK(property.IsShorthand()); + if (const CSSPropertyValueSet* inline_style = owner_element_->InlineStyle()) { + return StylePropertySerializer(*inline_style) + .GetPropertyValue(property.PropertyID()); + } + + NOTREACHED(); + return ""; +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.h index 505750d3ff..357dcaf0a6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.h @@ -21,14 +21,22 @@ class CORE_EXPORT InlineStylePropertyMap final : public StylePropertyMap { StylePropertyMap::Trace(visitor); } + unsigned int size() final; + protected: const CSSValue* GetProperty(CSSPropertyID) override; const CSSValue* GetCustomProperty(AtomicString) override; void ForEachProperty(const IterationCallback&) override; void SetProperty(CSSPropertyID, const CSSValue&) override; + bool SetShorthandProperty(CSSPropertyID, + const String&, + SecureContextMode) override; void SetCustomProperty(const AtomicString&, const CSSValue&) override; void RemoveProperty(CSSPropertyID) override; void RemoveCustomProperty(const AtomicString&); + void RemoveAllProperties() final; + + String SerializationForShorthand(const CSSProperty&) final; private: Member owner_element_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/PrepopulatedComputedStylePropertyMap.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/PrepopulatedComputedStylePropertyMap.cpp new file mode 100644 index 0000000000..ff727f5163 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/PrepopulatedComputedStylePropertyMap.cpp @@ -0,0 +1,131 @@ +// Copyright 2018 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 "core/css/cssom/PrepopulatedComputedStylePropertyMap.h" + +#include "core/css/CSSCustomPropertyDeclaration.h" +#include "core/css/CSSVariableData.h" +#include "core/css/ComputedStyleCSSValueMapping.h" +#include "core/css/cssom/CSSUnparsedValue.h" +#include "core/css/cssom/ComputedStylePropertyMap.h" +#include "core/dom/Document.h" +#include "core/style/ComputedStyle.h" + +namespace blink { + +PrepopulatedComputedStylePropertyMap::PrepopulatedComputedStylePropertyMap( + const Document& document, + const ComputedStyle& style, + Node* styled_node, + const Vector& native_properties, + const Vector& custom_properties) + : StylePropertyMapReadOnly(), styled_node_(styled_node) { + // NOTE: This may over-reserve as shorthand properties will get dropped from + // being in the map. + native_values_.ReserveCapacityForSize(native_properties.size()); + custom_values_.ReserveCapacityForSize(custom_properties.size()); + + for (const auto& property_id : native_properties) { + // Silently drop shorthand properties. + DCHECK_NE(property_id, CSSPropertyInvalid); + if (CSSProperty::Get(property_id).IsShorthand()) + continue; + + UpdateNativeProperty(style, property_id); + } + + for (const auto& property_name : custom_properties) { + UpdateCustomProperty(document, style, property_name); + } +} + +unsigned PrepopulatedComputedStylePropertyMap::size() { + return native_values_.size() + custom_values_.size(); +} + +void PrepopulatedComputedStylePropertyMap::UpdateStyle( + const Document& document, + const ComputedStyle& style) { + for (const auto& property_id : native_values_.Keys()) { + DCHECK_NE(property_id, CSSPropertyInvalid); + UpdateNativeProperty(style, property_id); + } + + for (const auto& property_name : custom_values_.Keys()) { + UpdateCustomProperty(document, style, property_name); + } +} + +void PrepopulatedComputedStylePropertyMap::UpdateNativeProperty( + const ComputedStyle& style, + CSSPropertyID property_id) { + native_values_.Set(property_id, + CSSProperty::Get(property_id) + .CSSValueFromComputedStyle( + style, /* layout_object */ nullptr, styled_node_, + /* allow_visited_style */ false)); +} + +void PrepopulatedComputedStylePropertyMap::UpdateCustomProperty( + const Document& document, + const ComputedStyle& style, + const AtomicString& property_name) { + const CSSValue* value = ComputedStyleCSSValueMapping::Get( + property_name, style, document.GetPropertyRegistry()); + if (!value) + value = CSSUnparsedValue::Create()->ToCSSValue(); + + custom_values_.Set(property_name, value); +} + +const CSSValue* PrepopulatedComputedStylePropertyMap::GetProperty( + CSSPropertyID property_id) { + return native_values_.at(property_id); +} + +const CSSValue* PrepopulatedComputedStylePropertyMap::GetCustomProperty( + AtomicString property_name) { + return custom_values_.at(property_name); +} + +void PrepopulatedComputedStylePropertyMap::ForEachProperty( + const IterationCallback& callback) { + // Have to sort by all properties by code point, so we have to store + // them in a buffer first. + HeapVector>> values; + + for (const auto& entry : native_values_) { + DCHECK(entry.value); + values.emplace_back( + CSSProperty::Get(entry.key).GetPropertyNameAtomicString(), entry.value); + } + + for (const auto& entry : custom_values_) { + DCHECK(entry.value); + values.emplace_back(entry.key, entry.value); + } + + std::sort(values.begin(), values.end(), [](const auto& a, const auto& b) { + return ComputedStylePropertyMap::ComparePropertyNames(a.first, b.first); + }); + + for (const auto& value : values) + callback(value.first, *value.second); +} + +String PrepopulatedComputedStylePropertyMap::SerializationForShorthand( + const CSSProperty&) { + // TODO(816722): Shorthands not yet supported for this style map. + NOTREACHED(); + return ""; +} + +void PrepopulatedComputedStylePropertyMap::Trace(blink::Visitor* visitor) { + visitor->Trace(styled_node_); + visitor->Trace(native_values_); + visitor->Trace(custom_values_); + StylePropertyMapReadOnly::Trace(visitor); +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/PrepopulatedComputedStylePropertyMap.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/PrepopulatedComputedStylePropertyMap.h new file mode 100644 index 0000000000..c6d08ede4e --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/PrepopulatedComputedStylePropertyMap.h @@ -0,0 +1,64 @@ +// Copyright 2018 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 PrepopulatedComputedStylePropertyMap_h +#define PrepopulatedComputedStylePropertyMap_h + +#include "base/macros.h" +#include "core/css/CSSPropertyIDTemplates.h" +#include "core/css/cssom/StylePropertyMapReadOnly.h" + +namespace blink { + +// This class has the same behaviour as the ComputedStylePropertyMap, except it +// only contains the properties given to the constructor. +// +// It is to be used with the Houdini APIs (css-paint-api, css-layout-api) which +// require style maps with a subset of properties. +// +// It will pre-populate internal maps (property->CSSValue), as the above APIs +// have a high probability of querying the values inside the map, however as a +// result when the ComputedStyle changes UpdateStyle needs to be called to +// re-populate the internal maps. +class CORE_EXPORT PrepopulatedComputedStylePropertyMap + : public StylePropertyMapReadOnly { + public: + // NOTE: styled_node may be null, in the case where this map is for an + // anonymous box. + PrepopulatedComputedStylePropertyMap( + const Document&, + const ComputedStyle&, + Node* styled_node, + const Vector& native_properties, + const Vector& custom_properties); + + // Updates the values of the properties based on the new computed style. + void UpdateStyle(const Document&, const ComputedStyle&); + + unsigned size() override; + void Trace(blink::Visitor*) override; + + protected: + const CSSValue* GetProperty(CSSPropertyID) override; + const CSSValue* GetCustomProperty(AtomicString) override; + void ForEachProperty(const IterationCallback&) override; + + String SerializationForShorthand(const CSSProperty&) override; + + private: + void UpdateNativeProperty(const ComputedStyle&, CSSPropertyID); + void UpdateCustomProperty(const Document&, + const ComputedStyle&, + const AtomicString& property_name); + + Member styled_node_; + HeapHashMap> native_values_; + HeapHashMap> custom_values_; + + DISALLOW_COPY_AND_ASSIGN(PrepopulatedComputedStylePropertyMap); +}; + +} // namespace blink + +#endif diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/PrepopulatedComputedStylePropertyMapTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/PrepopulatedComputedStylePropertyMapTest.cpp new file mode 100644 index 0000000000..3e8975aad1 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/PrepopulatedComputedStylePropertyMapTest.cpp @@ -0,0 +1,111 @@ +// 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 "core/css/cssom/PrepopulatedComputedStylePropertyMap.h" + +#include +#include "core/css/CSSComputedStyleDeclaration.h" +#include "core/dom/Element.h" +#include "core/testing/PageTestBase.h" +#include "platform/heap/Handle.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace blink { + +class PrepopulatedComputedStylePropertyMapTest : public PageTestBase { + public: + PrepopulatedComputedStylePropertyMapTest() = default; + + CSSComputedStyleDeclaration* Declaration() const { + return declaration_.Get(); + } + + void SetUp() override { + PageTestBase::SetUp(IntSize()); + declaration_ = + CSSComputedStyleDeclaration::Create(GetDocument().documentElement()); + } + + Node* PageNode() { return GetDocument().documentElement(); } + + private: + Persistent declaration_; +}; + +TEST_F(PrepopulatedComputedStylePropertyMapTest, NativePropertyAccessors) { + Vector native_properties( + {CSSPropertyColor, CSSPropertyAlignItems}); + Vector empty_custom_properties; + + Node* node = PageNode(); + const ComputedStyle& style = *node->EnsureComputedStyle(); + + PrepopulatedComputedStylePropertyMap* map = + new PrepopulatedComputedStylePropertyMap(GetDocument(), style, node, + native_properties, + empty_custom_properties); + + DummyExceptionStateForTesting exception_state; + + map->get("color", exception_state); + EXPECT_FALSE(exception_state.HadException()); + + map->has("color", exception_state); + EXPECT_FALSE(exception_state.HadException()); + + map->getAll("color", exception_state); + EXPECT_FALSE(exception_state.HadException()); + + map->get("align-contents", exception_state); + EXPECT_TRUE(exception_state.HadException()); + exception_state.ClearException(); + + map->has("align-contents", exception_state); + EXPECT_TRUE(exception_state.HadException()); + exception_state.ClearException(); + + map->getAll("align-contents", exception_state); + EXPECT_TRUE(exception_state.HadException()); + exception_state.ClearException(); +} + +TEST_F(PrepopulatedComputedStylePropertyMapTest, CustomPropertyAccessors) { + Vector empty_native_properties; + Vector custom_properties({"--foo", "--bar"}); + + Node* node = PageNode(); + const ComputedStyle& style = *node->EnsureComputedStyle(); + + PrepopulatedComputedStylePropertyMap* map = + new PrepopulatedComputedStylePropertyMap(GetDocument(), style, node, + empty_native_properties, + custom_properties); + + DummyExceptionStateForTesting exception_state; + + const CSSStyleValue* foo = map->get("--foo", exception_state); + ASSERT_NE(nullptr, foo); + ASSERT_EQ(CSSStyleValue::kUnparsedType, foo->GetType()); + EXPECT_FALSE(exception_state.HadException()); + + EXPECT_EQ(true, map->has("--foo", exception_state)); + EXPECT_FALSE(exception_state.HadException()); + + CSSStyleValueVector fooAll = map->getAll("--foo", exception_state); + EXPECT_EQ(1U, fooAll.size()); + ASSERT_NE(nullptr, fooAll[0]); + ASSERT_EQ(CSSStyleValue::kUnparsedType, fooAll[0]->GetType()); + EXPECT_FALSE(exception_state.HadException()); + + EXPECT_EQ(nullptr, map->get("--quix", exception_state)); + EXPECT_FALSE(exception_state.HadException()); + + EXPECT_EQ(false, map->has("--quix", exception_state)); + EXPECT_FALSE(exception_state.HadException()); + + EXPECT_EQ(CSSStyleValueVector(), map->getAll("--quix", exception_state)); + EXPECT_FALSE(exception_state.HadException()); +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp index 362b6c6ff6..c9201c1d2f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp @@ -5,10 +5,12 @@ #include "core/css/cssom/StylePropertyMap.h" #include "bindings/core/v8/ExceptionState.h" +#include "core/StylePropertyShorthand.h" #include "core/css/CSSValueList.h" #include "core/css/cssom/CSSOMTypes.h" #include "core/css/cssom/CSSStyleValue.h" #include "core/css/cssom/StyleValueFactory.h" +#include "core/css/parser/CSSParser.h" #include "core/css/parser/CSSParserContext.h" #include "core/css/properties/CSSProperty.h" @@ -32,11 +34,19 @@ CSSValueList* CssValueListForPropertyID(CSSPropertyID property_id) { } } -const CSSValue* StyleValueToCSSValue(const CSSProperty& property, - const CSSStyleValue& style_value) { +const CSSValue* StyleValueToCSSValue( + const CSSProperty& property, + const CSSStyleValue& style_value, + const ExecutionContext& execution_context) { const CSSPropertyID property_id = property.PropertyID(); if (!CSSOMTypes::PropertyCanTake(property_id, style_value)) return nullptr; + + if (style_value.GetType() == CSSStyleValue::kUnknownType) { + return CSSParser::ParseSingleValue( + property.PropertyID(), style_value.toString(), + CSSParserContext::Create(execution_context)); + } return style_value.ToCSSValueWithProperty(property_id); } @@ -50,7 +60,8 @@ const CSSValue* CoerceStyleValueOrString( if (!value.GetAsCSSStyleValue()) return nullptr; - return StyleValueToCSSValue(property, *value.GetAsCSSStyleValue()); + return StyleValueToCSSValue(property, *value.GetAsCSSStyleValue(), + execution_context); } else { DCHECK(value.IsString()); const auto values = StyleValueFactory::FromString( @@ -59,7 +70,7 @@ const CSSValue* CoerceStyleValueOrString( if (values.size() != 1U) return nullptr; - return StyleValueToCSSValue(property, *values[0]); + return StyleValueToCSSValue(property, *values[0], execution_context); } } @@ -79,8 +90,8 @@ const CSSValue* CoerceStyleValuesOrStrings( if (!value.GetAsCSSStyleValue()) return nullptr; - css_values.push_back( - StyleValueToCSSValue(property, *value.GetAsCSSStyleValue())); + css_values.push_back(StyleValueToCSSValue( + property, *value.GetAsCSSStyleValue(), execution_context)); } else { DCHECK(value.IsString()); if (!parser_context) @@ -93,7 +104,8 @@ const CSSValue* CoerceStyleValuesOrStrings( for (const auto& subvalue : subvalues) { DCHECK(subvalue); - css_values.push_back(StyleValueToCSSValue(property, *subvalue)); + css_values.push_back( + StyleValueToCSSValue(property, *subvalue, execution_context)); } } } @@ -102,7 +114,7 @@ const CSSValue* CoerceStyleValuesOrStrings( for (const auto& css_value : css_values) { if (!css_value) return nullptr; - if (css_value->IsCSSWideKeyword()) + if (css_value->IsCSSWideKeyword() || css_value->IsVariableReferenceValue()) return css_values.size() == 1U ? css_value : nullptr; result->Append(*css_value); @@ -118,13 +130,35 @@ void StylePropertyMap::set(const ExecutionContext* execution_context, const HeapVector& values, ExceptionState& exception_state) { const CSSPropertyID property_id = cssPropertyID(property_name); - if (property_id == CSSPropertyInvalid) { exception_state.ThrowTypeError("Invalid propertyName: " + property_name); return; } + DCHECK(isValidCSSPropertyID(property_id)); const CSSProperty& property = CSSProperty::Get(property_id); + if (property.IsShorthand()) { + if (values.size() != 1) { + exception_state.ThrowTypeError("Invalid type for property"); + return; + } + + String css_text; + if (values[0].IsCSSStyleValue()) { + CSSStyleValue* style_value = values[0].GetAsCSSStyleValue(); + if (style_value && CSSOMTypes::PropertyCanTake(property_id, *style_value)) + css_text = style_value->toString(); + } else { + css_text = values[0].GetAsString(); + } + + if (css_text.IsEmpty() || + !SetShorthandProperty(property.PropertyID(), css_text, + execution_context->GetSecureContextMode())) + exception_state.ThrowTypeError("Invalid type for property"); + + return; + } const CSSValue* result = nullptr; if (property.IsRepeated()) @@ -179,12 +213,11 @@ void StylePropertyMap::append(const ExecutionContext* execution_context, const CSSValue* result = CoerceStyleValuesOrStrings(property, values, *execution_context); - if (!result) { + if (!result || !result->IsValueList()) { exception_state.ThrowTypeError("Invalid type for property"); return; } - DCHECK(result->IsValueList()); for (const auto& value : *ToCSSValueList(result)) { current_value->Append(*value); } @@ -207,34 +240,8 @@ void StylePropertyMap::remove(const String& property_name, } } -void StylePropertyMap::update(const String& property_name, - V8UpdateFunction* update_function, - ExceptionState& exception_state) { - CSSStyleValue* old_value = get(property_name, exception_state); - if (exception_state.HadException()) { - exception_state.ThrowTypeError("Invalid propertyName: " + property_name); - return; - } - - const CSSPropertyID property_id = cssPropertyID(property_name); - - const auto& new_value = update_function->Invoke(this, old_value); - if (new_value.IsNothing() || !new_value.ToChecked()) { - exception_state.ThrowTypeError("Invalid type for property"); - return; - } - - const CSSValue* result = StyleValueToCSSValue(CSSProperty::Get(property_id), - *new_value.ToChecked()); - if (!result) { - exception_state.ThrowTypeError("Invalid type for property"); - return; - } - - if (property_id == CSSPropertyVariable) - SetCustomProperty(AtomicString(property_name), *result); - else - SetProperty(property_id, *result); +void StylePropertyMap::clear() { + RemoveAllProperties(); } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.h index 770f7ae593..c056086c06 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.h @@ -7,8 +7,8 @@ #include "base/macros.h" #include "bindings/core/v8/css_style_value_or_string.h" -#include "bindings/core/v8/v8_update_function.h" #include "core/css/cssom/StylePropertyMapReadOnly.h" +#include "core/dom/ExecutionContext.h" namespace blink { @@ -28,13 +28,17 @@ class CORE_EXPORT StylePropertyMap : public StylePropertyMapReadOnly { const HeapVector& values, ExceptionState&); void remove(const String& property_name, ExceptionState&); - void update(const String&, V8UpdateFunction*, ExceptionState&); + void clear(); protected: virtual void SetProperty(CSSPropertyID, const CSSValue&) = 0; + virtual bool SetShorthandProperty(CSSPropertyID, + const String&, + SecureContextMode) = 0; virtual void SetCustomProperty(const AtomicString&, const CSSValue&) = 0; virtual void RemoveProperty(CSSPropertyID) = 0; virtual void RemoveCustomProperty(const AtomicString&) = 0; + virtual void RemoveAllProperties() = 0; StylePropertyMap() = default; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.idl index fcbbfad4a1..fdc799743d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.idl @@ -4,14 +4,12 @@ // https://drafts.css-houdini.org/css-typed-om/#the-stylepropertymap -callback UpdateFunction = CSSStyleValue (CSSStyleValue oldValue); - [ - Exposed=(Window,PaintWorklet), - RuntimeEnabled=CSSTypedOM + RuntimeEnabled=CSSTypedOM, + Exposed=(Window) ] interface StylePropertyMap : StylePropertyMapReadOnly { + [RaisesException, CallWith=ExecutionContext] void set(DOMString property, (CSSStyleValue or DOMString)... values); [RaisesException, CallWith=ExecutionContext] void append(DOMString property, (CSSStyleValue or DOMString)... values); [RaisesException, ImplementedAs=remove] void delete(DOMString property); - [RaisesException, CallWith=ExecutionContext] void set(DOMString property, (CSSStyleValue or DOMString)... values); - [RaisesException] void update(DOMString property, UpdateFunction updateFunction); + void clear(); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.cpp index e5ab35c9eb..4ffb121516 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.cpp @@ -6,10 +6,13 @@ #include "bindings/core/v8/ExceptionState.h" #include "core/CSSPropertyNames.h" +#include "core/StylePropertyShorthand.h" #include "core/css/CSSCustomPropertyDeclaration.h" #include "core/css/CSSValueList.h" +#include "core/css/CSSVariableReferenceValue.h" #include "core/css/cssom/CSSStyleValue.h" #include "core/css/cssom/CSSUnparsedValue.h" +#include "core/css/cssom/CSSUnsupportedStyleValue.h" #include "core/css/cssom/StyleValueFactory.h" #include "core/css/properties/CSSProperty.h" @@ -18,8 +21,7 @@ namespace blink { namespace { class StylePropertyMapIterationSource final - : public PairIterable:: - IterationSource { + : public PairIterable::IterationSource { public: explicit StylePropertyMapIterationSource( HeapVector values) @@ -27,7 +29,7 @@ class StylePropertyMapIterationSource final bool Next(ScriptState*, String& key, - CSSStyleValueOrCSSStyleValueSequence& value, + CSSStyleValueVector& value, ExceptionState&) override { if (index_ >= values_.size()) return false; @@ -41,8 +43,7 @@ class StylePropertyMapIterationSource final virtual void Trace(blink::Visitor* visitor) { visitor->Trace(values_); - PairIterable:: - IterationSource::Trace(visitor); + PairIterable::IterationSource::Trace(visitor); } private: @@ -50,18 +51,34 @@ class StylePropertyMapIterationSource final const HeapVector values_; }; -bool ComparePropertyNames(const String& a, const String& b) { - if (a.StartsWith("--") == b.StartsWith("--")) - return WTF::CodePointCompareLessThan(a, b); - return b.StartsWith("--"); -} - } // namespace CSSStyleValue* StylePropertyMapReadOnly::get(const String& property_name, ExceptionState& exception_state) { - CSSStyleValueVector style_vector = getAll(property_name, exception_state); - return style_vector.IsEmpty() ? nullptr : style_vector[0]; + const CSSPropertyID property_id = cssPropertyID(property_name); + if (property_id == CSSPropertyInvalid) { + exception_state.ThrowTypeError("Invalid propertyName: " + property_name); + return nullptr; + } + + DCHECK(isValidCSSPropertyID(property_id)); + const CSSProperty& property = CSSProperty::Get(property_id); + if (property.IsShorthand()) + return GetShorthandProperty(property); + + const CSSValue* value = (property_id == CSSPropertyVariable) + ? GetCustomProperty(AtomicString(property_name)) + : GetProperty(property_id); + if (!value) + return nullptr; + + if (property.IsRepeated()) { + CSSStyleValueVector values = + StyleValueFactory::CssValueToStyleValueVector(property_id, *value); + return values.IsEmpty() ? nullptr : values[0]; + } + + return StyleValueFactory::CssValueToStyleValue(property_id, *value); } CSSStyleValueVector StylePropertyMapReadOnly::getAll( @@ -74,6 +91,14 @@ CSSStyleValueVector StylePropertyMapReadOnly::getAll( } DCHECK(isValidCSSPropertyID(property_id)); + const CSSProperty& property = CSSProperty::Get(property_id); + if (property.IsShorthand()) { + CSSStyleValueVector values; + if (CSSStyleValue* value = GetShorthandProperty(property)) + values.push_back(value); + return values; + } + const CSSValue* value = (property_id == CSSPropertyVariable) ? GetCustomProperty(AtomicString(property_name)) : GetProperty(property_id); @@ -88,17 +113,6 @@ bool StylePropertyMapReadOnly::has(const String& property_name, return !getAll(property_name, exception_state).IsEmpty(); } -Vector StylePropertyMapReadOnly::getProperties() { - Vector result; - - ForEachProperty([&result](const String& name, const CSSValue&) { - result.push_back(name); - }); - - std::sort(result.begin(), result.end(), ComparePropertyNames); - return result; -} - StylePropertyMapReadOnly::IterationSource* StylePropertyMapReadOnly::StartIteration(ScriptState*, ExceptionState&) { HeapVector result; @@ -106,27 +120,22 @@ StylePropertyMapReadOnly::StartIteration(ScriptState*, ExceptionState&) { ForEachProperty([&result](const String& property_name, const CSSValue& css_value) { const auto property_id = cssPropertyID(property_name); - CSSStyleValueOrCSSStyleValueSequence value; - if (property_id == CSSPropertyVariable) { - const CSSCustomPropertyDeclaration& decl = - ToCSSCustomPropertyDeclaration(css_value); - DCHECK(decl.Value()); - value.SetCSSStyleValue(CSSUnparsedValue::FromCSSValue(*decl.Value())); - } else { - auto style_value_vector = - StyleValueFactory::CssValueToStyleValueVector(property_id, css_value); - if (style_value_vector.size() == 1) - value.SetCSSStyleValue(style_value_vector[0]); - else - value.SetCSSStyleValueSequence(style_value_vector); - } - result.emplace_back(property_name, value); - }); - std::sort(result.begin(), result.end(), [](const auto& a, const auto& b) { - return ComparePropertyNames(a.first, b.first); + auto values = + StyleValueFactory::CssValueToStyleValueVector(property_id, css_value); + result.emplace_back(property_name, std::move(values)); }); + return new StylePropertyMapIterationSource(result); } +CSSStyleValue* StylePropertyMapReadOnly::GetShorthandProperty( + const CSSProperty& property) { + DCHECK(property.IsShorthand()); + const auto serialization = SerializationForShorthand(property); + if (serialization.IsEmpty()) + return nullptr; + return CSSUnsupportedStyleValue::Create(property.PropertyID(), serialization); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.h index 906fc5669f..0d953c585f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.h @@ -7,7 +7,6 @@ #include "base/macros.h" #include "bindings/core/v8/Iterable.h" -#include "bindings/core/v8/css_style_value_or_css_style_value_sequence.h" #include "core/CSSPropertyNames.h" #include "core/CoreExport.h" #include "core/css/cssom/CSSStyleValue.h" @@ -15,14 +14,15 @@ namespace blink { +class CSSProperty; + class CORE_EXPORT StylePropertyMapReadOnly : public ScriptWrappable, - public PairIterable { + public PairIterable { DEFINE_WRAPPERTYPEINFO(); public: - using StylePropertyMapEntry = - std::pair; + using StylePropertyMapEntry = std::pair; virtual ~StylePropertyMapReadOnly() = default; @@ -30,7 +30,7 @@ class CORE_EXPORT StylePropertyMapReadOnly CSSStyleValueVector getAll(const String& property_name, ExceptionState&); bool has(const String& property_name, ExceptionState&); - Vector getProperties(); + virtual unsigned int size() = 0; protected: StylePropertyMapReadOnly() = default; @@ -42,9 +42,13 @@ class CORE_EXPORT StylePropertyMapReadOnly std::function; virtual void ForEachProperty(const IterationCallback&) = 0; + virtual String SerializationForShorthand(const CSSProperty&) = 0; + private: IterationSource* StartIteration(ScriptState*, ExceptionState&) override; + CSSStyleValue* GetShorthandProperty(const CSSProperty&); + private: DISALLOW_COPY_AND_ASSIGN(StylePropertyMapReadOnly); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.idl index d2452e4314..c97035fb7f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.idl @@ -2,12 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Spec: https://drafts.css-houdini.org/css-typed-om-1/#the-stylepropertymap [ - Exposed(Window CSSTypedOM, PaintWorklet CSSPaintAPI) + Exposed(Window CSSTypedOM,LayoutWorklet CSSTypedOM,PaintWorklet CSSPaintAPI) ] interface StylePropertyMapReadOnly { + iterable>; + /* TODO: This should return (undefined or CSSStyleValue), + but IDL doesn't have anything like that yet. See: + https://github.com/heycam/webidl/issues/60 */ [RaisesException] CSSStyleValue? get(DOMString property); [RaisesException] sequence getAll(DOMString property); [RaisesException] boolean has(DOMString property); - iterable)>; - sequence getProperties(); + readonly attribute unsigned long size; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp index b14d38ef55..8bf00b9371 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp @@ -4,7 +4,9 @@ #include "core/css/cssom/StyleValueFactory.h" +#include "core/StylePropertyShorthand.h" #include "core/css/CSSCustomPropertyDeclaration.h" +#include "core/css/CSSIdentifierValue.h" #include "core/css/CSSImageValue.h" #include "core/css/CSSValue.h" #include "core/css/CSSVariableReferenceValue.h" @@ -27,13 +29,61 @@ namespace blink { namespace { +CSSStyleValue* CreateStyleValue(const CSSValue& value) { + if (value.IsIdentifierValue() || value.IsCustomIdentValue()) + return CSSKeywordValue::FromCSSValue(value); + if (value.IsPrimitiveValue()) + return CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value)); + if (value.IsImageValue()) { + return CSSURLImageValue::FromCSSValue(*ToCSSImageValue(value).Clone()); + } + return nullptr; +} + CSSStyleValue* CreateStyleValueWithPropertyInternal(CSSPropertyID property_id, const CSSValue& value) { + // FIXME: We should enforce/document what the possible CSSValue structures + // are for each property. switch (property_id) { + case CSSPropertyCaretColor: + // caret-color also supports 'auto' + if (value.IsIdentifierValue() && + ToCSSIdentifierValue(value).GetValueID() == CSSValueAuto) { + return CSSKeywordValue::Create("auto"); + } + FALLTHROUGH; + case CSSPropertyBackgroundColor: + case CSSPropertyBorderBottomColor: + case CSSPropertyBorderLeftColor: + case CSSPropertyBorderRightColor: + case CSSPropertyBorderTopColor: + case CSSPropertyColor: + case CSSPropertyColumnRuleColor: + case CSSPropertyOutlineColor: + case CSSPropertyTextDecorationColor: + case CSSPropertyWebkitTextEmphasisColor: + // Only 'currentcolor' is supported. + if (value.IsIdentifierValue() && + ToCSSIdentifierValue(value).GetValueID() == CSSValueCurrentcolor) { + return CSSKeywordValue::Create("currentcolor"); + } + return CSSUnsupportedStyleValue::Create(property_id, value); case CSSPropertyTransform: return CSSTransformValue::FromCSSValue(value); case CSSPropertyObjectPosition: return CSSPositionValue::FromCSSValue(value); + case CSSPropertyAlignItems: { + // Computed align-items is a ValueList of either length 1 or 2. + // Typed OM level 1 can't support "pairs", so we only return + // a Typed OM object for length 1 lists. + if (value.IsValueList()) { + const auto& value_list = ToCSSValueList(value); + if (value_list.length() != 1U) + return nullptr; + return CreateStyleValue(value_list.Item(0)); + } + return CreateStyleValue(value); + } default: // TODO(meade): Implement other properties. break; @@ -41,11 +91,85 @@ CSSStyleValue* CreateStyleValueWithPropertyInternal(CSSPropertyID property_id, return nullptr; } -CSSStyleValue* CreateStyleValue(const CSSValue& value) { - if (value.IsIdentifierValue() || value.IsCustomIdentValue()) +bool IsPropertySupported(CSSPropertyID property_id) { + switch (property_id) { + case CSSPropertyVariable: + case CSSPropertyAnimationDirection: + case CSSPropertyTransitionDuration: + case CSSPropertyColor: + case CSSPropertyDirection: + case CSSPropertyFontStyle: + case CSSPropertyFontWeight: + case CSSPropertyBackfaceVisibility: + case CSSPropertyBackgroundColor: + case CSSPropertyBackgroundImage: + case CSSPropertyBorderBottomColor: + case CSSPropertyBorderBottomStyle: + case CSSPropertyBorderBottomWidth: + case CSSPropertyBorderCollapse: + case CSSPropertyBorderImageSource: + case CSSPropertyBorderLeftColor: + case CSSPropertyBorderLeftStyle: + case CSSPropertyBorderLeftWidth: + case CSSPropertyBorderRightColor: + case CSSPropertyBorderRightStyle: + case CSSPropertyBorderRightWidth: + case CSSPropertyBorderTopColor: + case CSSPropertyBorderTopStyle: + case CSSPropertyBorderTopWidth: + case CSSPropertyBottom: + case CSSPropertyBoxSizing: + case CSSPropertyCaretColor: + case CSSPropertyClear: + case CSSPropertyColumnRuleColor: + case CSSPropertyDisplay: + case CSSPropertyEmptyCells: + case CSSPropertyFloat: + case CSSPropertyHeight: + case CSSPropertyLeft: + case CSSPropertyLineHeight: + case CSSPropertyListStyleImage: + case CSSPropertyListStylePosition: + case CSSPropertyMarginBottom: + case CSSPropertyMarginLeft: + case CSSPropertyMarginRight: + case CSSPropertyMarginTop: + case CSSPropertyObjectPosition: + case CSSPropertyOpacity: + case CSSPropertyOutlineColor: + case CSSPropertyOutlineStyle: + case CSSPropertyOverflowAnchor: + case CSSPropertyOverflowX: + case CSSPropertyOverflowY: + case CSSPropertyPaddingBottom: + case CSSPropertyPaddingLeft: + case CSSPropertyPaddingRight: + case CSSPropertyPaddingTop: + case CSSPropertyPosition: + case CSSPropertyResize: + case CSSPropertyRight: + case CSSPropertyShapeOutside: + case CSSPropertyTextAlign: + case CSSPropertyTextDecorationColor: + case CSSPropertyTextDecorationStyle: + case CSSPropertyTextTransform: + case CSSPropertyTop: + case CSSPropertyTransform: + case CSSPropertyVerticalAlign: + case CSSPropertyVisibility: + case CSSPropertyWhiteSpace: + case CSSPropertyWidth: + return true; + default: + return false; + } +} + +CSSStyleValue* CreateStyleValueWithProperty(CSSPropertyID property_id, + const CSSValue& value) { + // These cannot be overridden by individual properties. + if (value.IsCSSWideKeyword()) return CSSKeywordValue::FromCSSValue(value); - if (value.IsPrimitiveValue()) - return CSSNumericValue::FromCSSValue(ToCSSPrimitiveValue(value)); if (value.IsVariableReferenceValue()) return CSSUnparsedValue::FromCSSValue(ToCSSVariableReferenceValue(value)); if (value.IsCustomPropertyDeclaration()) { @@ -54,16 +178,9 @@ CSSStyleValue* CreateStyleValue(const CSSValue& value) { DCHECK(variable_data); return CSSUnparsedValue::FromCSSValue(*variable_data); } - if (value.IsImageValue()) { - return CSSURLImageValue::Create(ToCSSImageValue(value).Clone()); - } - return nullptr; -} -CSSStyleValue* CreateStyleValueWithProperty(CSSPropertyID property_id, - const CSSValue& value) { - if (value.IsCSSWideKeyword()) - return CSSKeywordValue::FromCSSValue(value); + if (!IsPropertySupported(property_id)) + return CSSUnsupportedStyleValue::Create(property_id, value); CSSStyleValue* style_value = CreateStyleValueWithPropertyInternal(property_id, value); @@ -80,48 +197,59 @@ CSSStyleValueVector UnsupportedCSSValue(CSSPropertyID property_id, return style_value_vector; } -const CSSValue* ParseProperty(CSSPropertyID property_id, - const String& css_text, - const CSSParserContext* context) { +} // namespace + +CSSStyleValueVector StyleValueFactory::FromString( + CSSPropertyID property_id, + const String& css_text, + const CSSParserContext* parser_context) { + DCHECK_NE(property_id, CSSPropertyInvalid); CSSTokenizer tokenizer(css_text); const auto tokens = tokenizer.TokenizeToEOF(); const CSSParserTokenRange range(tokens); - if (property_id != CSSPropertyVariable) { - if (const CSSValue* value = - CSSPropertyParser::ParseSingleValue(property_id, range, context)) { - return value; + HeapVector parsed_properties; + if (property_id != CSSPropertyVariable && + CSSPropertyParser::ParseValue(property_id, false, range, parser_context, + parsed_properties, + StyleRule::RuleType::kStyle)) { + if (parsed_properties.size() == 1) { + const auto result = StyleValueFactory::CssValueToStyleValueVector( + parsed_properties[0].Id(), *parsed_properties[0].Value()); + // TODO(801935): Handle list-valued properties. + if (result.size() == 1U) + result[0]->SetCSSText(css_text); + return result; } + + // Shorthands are not yet supported. + CSSStyleValueVector result; + result.push_back(CSSUnsupportedStyleValue::Create(property_id, css_text)); + return result; } if (property_id == CSSPropertyVariable || CSSVariableParser::ContainsValidVariableReferences(range)) { - return CSSVariableReferenceValue::Create( + const auto variable_data = CSSVariableData::Create(range, false /* is_animation_tainted */, - false /* needs variable resolution */), - *context); + false /* needs variable resolution */); + CSSStyleValueVector values; + values.push_back(CSSUnparsedValue::FromCSSValue(*variable_data)); + return values; } - return nullptr; + return CSSStyleValueVector(); } -} // namespace - -CSSStyleValueVector StyleValueFactory::FromString( +CSSStyleValue* StyleValueFactory::CssValueToStyleValue( CSSPropertyID property_id, - const String& css_text, - const CSSParserContext* parser_context) { - DCHECK_NE(property_id, CSSPropertyInvalid); - DCHECK(!CSSProperty::Get(property_id).IsShorthand()); - - const CSSValue* value = ParseProperty(property_id, css_text, parser_context); - if (!value) - return CSSStyleValueVector(); - - CSSStyleValueVector style_value_vector = - StyleValueFactory::CssValueToStyleValueVector(property_id, *value); - DCHECK(!style_value_vector.IsEmpty()); - return style_value_vector; + const CSSValue& css_value) { + DCHECK(!CSSProperty::Get(property_id).IsRepeated()); + CSSStyleValue* style_value = + CreateStyleValueWithProperty(property_id, css_value); + if (!style_value) + return CSSUnsupportedStyleValue::Create(property_id, css_value); + return style_value; } CSSStyleValueVector StyleValueFactory::CssValueToStyleValueVector( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.h index c5bd98199e..9ec0395855 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.h @@ -21,6 +21,7 @@ class CORE_EXPORT StyleValueFactory { static CSSStyleValueVector FromString(CSSPropertyID, const String&, const CSSParserContext*); + static CSSStyleValue* CssValueToStyleValue(CSSPropertyID, const CSSValue&); static CSSStyleValueVector CssValueToStyleValueVector(CSSPropertyID, const CSSValue&); // If you don't have complex CSS properties, use this one. diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.cpp index 6165d79505..831db6d985 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/invalidation/StyleInvalidator.cpp @@ -342,15 +342,18 @@ bool StyleInvalidator::InvalidateShadowRootChildren( Element& element, RecursionData& recursion_data) { bool some_children_need_style_recalc = false; - for (ShadowRoot* root = element.YoungestShadowRoot(); root; - root = root->OlderShadowRoot()) { + if (ShadowRoot* root = element.GetShadowRoot()) { if (!recursion_data.TreeBoundaryCrossing() && !root->ChildNeedsStyleInvalidation() && !root->NeedsStyleInvalidation()) - continue; + return false; RecursionCheckpoint checkpoint(&recursion_data); SiblingData sibling_data; - if (UNLIKELY(root->NeedsStyleInvalidation())) - PushInvalidationSetsForContainerNode(*root, recursion_data, sibling_data); + if (!recursion_data.WholeSubtreeInvalid()) { + if (UNLIKELY(root->NeedsStyleInvalidation())) { + PushInvalidationSetsForContainerNode(*root, recursion_data, + sibling_data); + } + } for (Element* child = ElementTraversal::FirstChild(*root); child; child = ElementTraversal::NextSibling(*child)) { bool child_recalced = Invalidate(*child, recursion_data, sibling_data); @@ -367,7 +370,7 @@ bool StyleInvalidator::InvalidateChildren(Element& element, RecursionData& recursion_data) { SiblingData sibling_data; bool some_children_need_style_recalc = false; - if (UNLIKELY(!!element.YoungestShadowRoot())) { + if (UNLIKELY(!!element.GetShadowRoot())) { some_children_need_style_recalc = InvalidateShadowRootChildren(element, recursion_data); } @@ -419,7 +422,7 @@ bool StyleInvalidator::Invalidate(Element& element, void StyleInvalidator::InvalidateSlotDistributedElements( HTMLSlotElement& slot, const RecursionData& recursion_data) const { - for (auto& distributed_node : slot.GetDistributedNodes()) { + for (auto& distributed_node : slot.FlattenedAssignedNodes()) { if (distributed_node->NeedsStyleRecalc()) continue; if (!distributed_node->IsElementNode()) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/media_feature_names.json5 b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/media_feature_names.json5 index 5f06821c6e..c36a0f83f8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/media_feature_names.json5 +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/media_feature_names.json5 @@ -22,6 +22,9 @@ "device-height", "device-width", "display-mode", + // This has not been standardized and is only available to UA style sheets. + // See crbug.com/809165 + "immersive", "max-color", "max-color-index", "max-aspect-ratio", diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/AtRuleDescriptorParser.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/AtRuleDescriptorParser.cpp index 88a1487fec..f1c244c8e1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/AtRuleDescriptorParser.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/AtRuleDescriptorParser.cpp @@ -206,13 +206,6 @@ CSSValue* AtRuleDescriptorParser::ParseFontFaceDeclaration( return ParseFontFaceDescriptor(id, range, context); } -CSSValue* AtRuleDescriptorParser::ParseAtRule(AtRuleDescriptorID id, - const String& value, - const CSSParserContext& context) { - // TODO(meade): Handle other descriptor types here. - return ParseFontFaceDescriptor(id, value, context); -} - bool AtRuleDescriptorParser::ParseAtRule( AtRuleDescriptorID id, CSSParserTokenRange& range, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/AtRuleDescriptorParser.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/AtRuleDescriptorParser.h index a892199ccd..52ad8879db 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/AtRuleDescriptorParser.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/AtRuleDescriptorParser.h @@ -23,9 +23,6 @@ class AtRuleDescriptorParser { CSSParserTokenRange&, const CSSParserContext&, HeapVector&); - static CSSValue* ParseAtRule(AtRuleDescriptorID, - const String& value, - const CSSParserContext&); static CSSValue* ParseFontFaceDescriptor(AtRuleDescriptorID, CSSParserTokenRange&, const CSSParserContext&); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSS.proto b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSS.proto index 85b277291e..f876dc3e2d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSS.proto +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSS.proto @@ -810,7 +810,8 @@ message MfName { _WEBKIT_TRANSFORM_3D = 42; SCAN = 43; SHAPE = 44; - INVALID_NAME = 45; + IMMERSIVE = 45; + INVALID_NAME = 46; } required ValueId id = 1; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp index 58bb8b1274..23c4bc03af 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.cpp @@ -65,7 +65,8 @@ bool CSSLazyParsingState::ShouldLazilyParseProperties( // list. This ensures we don't cause a collectFeatures() when we trigger // parsing for attr() functions which would trigger expensive invalidation // propagation. - for (const auto* s = selectors.First(); s; s = CSSSelectorList::Next(*s)) { + for (const auto* s = selectors.FirstForCSSOM(); s; + s = CSSSelectorList::Next(*s)) { for (const CSSSelector* current = s; current; current = current->TagHistory()) { const CSSSelector::PseudoType type(current->GetPseudoType()); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.h index a1b520ffc6..3280e29945 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.h @@ -17,6 +17,12 @@ class CSSLazyPropertyParserImpl; // This class helps lazy parsing by retaining necessary state. It should not // outlive the StyleSheetContents that initiated the parse, as it retains a raw // reference to the UseCounter associated with the style sheet. +// +// Note: This class holds an extra reference to the underlying stylesheet +// text, and will extend its lifetime until this class is garbage collected. +// Currently, the only strong references to this class are from individual lazy +// properties, so after an entire lazy sheet is parsed, the extra memory should +// be released. class CSSLazyParsingState : public GarbageCollectedFinalized { public: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp index 3048c5adbb..2e4978b9f7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp @@ -33,8 +33,6 @@ static inline bool IsSimpleLengthPropertyID(CSSPropertyID property_id, case CSSPropertyMinBlockSize: case CSSPropertyMinInlineSize: case CSSPropertyFontSize: - case CSSPropertyGridColumnGap: - case CSSPropertyGridRowGap: case CSSPropertyHeight: case CSSPropertyWidth: case CSSPropertyMinHeight: @@ -196,6 +194,7 @@ static inline bool IsColorPropertyID(CSSPropertyID property_id) { template static int CheckForValidDouble(const CharacterType* string, const CharacterType* end, + const bool terminated_by_space, const char terminator) { int length = end - string; if (length < 1) @@ -205,7 +204,8 @@ static int CheckForValidDouble(const CharacterType* string, int processed_length = 0; for (int i = 0; i < length; ++i) { - if (string[i] == terminator) { + if (string[i] == terminator || + (terminated_by_space && IsHTMLSpace(string[i]))) { processed_length = i; break; } @@ -229,8 +229,10 @@ template static int ParseDouble(const CharacterType* string, const CharacterType* end, const char terminator, + const bool terminated_by_space, double& value) { - int length = CheckForValidDouble(string, end, terminator); + int length = + CheckForValidDouble(string, end, terminated_by_space, terminator); if (!length) return 0; @@ -264,13 +266,13 @@ static int ParseDouble(const CharacterType* string, } template -static bool ParseColorIntOrPercentage(const CharacterType*& string, - const CharacterType* end, - const char terminator, - bool& should_whitespace_terminate, - bool is_first_value, - CSSPrimitiveValue::UnitType& expect, - int& value) { +static bool ParseColorNumberOrPercentage(const CharacterType*& string, + const CharacterType* end, + const char terminator, + bool& should_whitespace_terminate, + bool is_first_value, + CSSPrimitiveValue::UnitType& expect, + int& value) { const CharacterType* current = string; double local_value = 0; bool negative = false; @@ -297,21 +299,29 @@ static bool ParseColorIntOrPercentage(const CharacterType*& string, if (current == end) return false; - if (expect == CSSPrimitiveValue::UnitType::kNumber && - (*current == '.' || *current == '%')) + if (expect == CSSPrimitiveValue::UnitType::kNumber && *current == '%') return false; if (*current == '.') { // We already parsed the integral part, try to parse - // the fraction part of the percentage value. - double percentage = 0; - int num_characters_parsed = ParseDouble(current, end, '%', percentage); - if (!num_characters_parsed) - return false; - current += num_characters_parsed; - if (*current != '%') - return false; - local_value += percentage; + // the fraction part. + double fractional = 0; + int num_characters_parsed = + ParseDouble(current, end, '%', false, fractional); + if (num_characters_parsed) { + // Number is a percent. + current += num_characters_parsed; + if (*current != '%') + return false; + } else { + // Number is a decimal. + num_characters_parsed = + ParseDouble(current, end, terminator, true, fractional); + if (!num_characters_parsed) + return false; + current += num_characters_parsed; + } + local_value += fractional; } if (expect == CSSPrimitiveValue::UnitType::kPercentage && *current != '%') @@ -319,7 +329,7 @@ static bool ParseColorIntOrPercentage(const CharacterType*& string, if (*current == '%') { expect = CSSPrimitiveValue::UnitType::kPercentage; - local_value = local_value / 100.0 * 256.0; + local_value = local_value / 100.0 * 255.0; // Clamp values at 255 for percentages over 100% if (local_value > 255) local_value = 255; @@ -346,7 +356,7 @@ static bool ParseColorIntOrPercentage(const CharacterType*& string, current++; // Clamp negative values at zero. - value = negative ? 0 : static_cast(local_value); + value = negative ? 0 : static_cast(roundf(local_value)); string = current; return true; } @@ -390,7 +400,7 @@ static inline bool ParseAlphaValue(const CharacterType*& string, return false; if (string[0] != '0' && string[0] != '1' && string[0] != '.') { - if (CheckForValidDouble(string, end, terminator)) { + if (CheckForValidDouble(string, end, false, terminator)) { value = negative ? 0 : 255; string = end; return true; @@ -415,7 +425,7 @@ static inline bool ParseAlphaValue(const CharacterType*& string, } double alpha = 0; - if (!ParseDouble(string, end, terminator, alpha)) + if (!ParseDouble(string, end, terminator, false, alpha)) return false; value = negative ? 0 : static_cast(roundf(std::min(alpha, 1.0) * 255.0f)); @@ -464,25 +474,27 @@ static bool FastParseColorInternal(RGBA32& rgb, bool should_whitespace_terminate = true; bool no_whitespace_check = false; - if (!ParseColorIntOrPercentage(current, end, ',', - should_whitespace_terminate, - true /* is_first_value */, expect, red)) + if (!ParseColorNumberOrPercentage(current, end, ',', + should_whitespace_terminate, + true /* is_first_value */, expect, red)) return false; - if (!ParseColorIntOrPercentage(current, end, ',', - should_whitespace_terminate, - false /* is_first_value */, expect, green)) + if (!ParseColorNumberOrPercentage( + current, end, ',', should_whitespace_terminate, + false /* is_first_value */, expect, green)) return false; - if (!ParseColorIntOrPercentage(current, end, ',', no_whitespace_check, - false /* is_first_value */, expect, blue)) { + if (!ParseColorNumberOrPercentage(current, end, ',', no_whitespace_check, + false /* is_first_value */, expect, + blue)) { // Might have slash as separator - if (ParseColorIntOrPercentage(current, end, '/', no_whitespace_check, - false /* is_first_value */, expect, blue)) { + if (ParseColorNumberOrPercentage(current, end, '/', no_whitespace_check, + false /* is_first_value */, expect, + blue)) { if (!should_whitespace_terminate) return false; should_have_alpha = true; } // Might not have alpha - else if (!ParseColorIntOrPercentage( + else if (!ParseColorNumberOrPercentage( current, end, ')', no_whitespace_check, false /* is_first_value */, expect, blue)) return false; @@ -1000,6 +1012,15 @@ bool CSSParserFastPaths::IsKeywordPropertyID(CSSPropertyID property_id) { } } +bool CSSParserFastPaths::IsPartialKeywordPropertyID(CSSPropertyID property_id) { + switch (property_id) { + case CSSPropertyDisplay: + return true; + default: + return false; + } +} + static CSSValue* ParseKeywordValue(CSSPropertyID property_id, const String& string, CSSParserMode parser_mode) { @@ -1031,7 +1052,7 @@ static CSSValue* ParseKeywordValue(CSSPropertyID property_id, if (value_id == CSSValueInitial) return CSSInitialValue::Create(); if (value_id == CSSValueUnset) - return CSSUnsetValue::Create(); + return cssvalue::CSSUnsetValue::Create(); if (CSSParserFastPaths::IsValidKeywordPropertyAndValue(property_id, value_id, parser_mode)) return CSSIdentifierValue::Create(value_id); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.h index d30a261b5e..0fee1dd446 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.h @@ -27,6 +27,11 @@ class CORE_EXPORT CSSParserFastPaths { // Properties handled here shouldn't be explicitly handled in // CSSPropertyParser static bool IsKeywordPropertyID(CSSPropertyID); + + // Returns if a property should be handled by the fast path, but have other + // non-keyword values which should be handled by the CSSPropertyParser. + static bool IsPartialKeywordPropertyID(CSSPropertyID); + static bool IsValidKeywordPropertyAndValue(CSSPropertyID, CSSValueID, CSSParserMode); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp index 89d418d0a1..3bb68115e8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp @@ -159,4 +159,30 @@ TEST(CSSParserFastPathsTest, ParseColorWithNewSyntax) { EXPECT_EQ(nullptr, value); } +TEST(CSSParserFastPathsTest, ParseColorWithDecimal) { + CSSValue* value = CSSParserFastPaths::ParseColor("rgba(0.0, 0.0, 0.0, 1.0)", + kHTMLStandardMode); + EXPECT_NE(nullptr, value); + EXPECT_TRUE(value->IsColorValue()); + EXPECT_EQ(Color::kBlack, ToCSSColorValue(*value).Value()); + + value = + CSSParserFastPaths::ParseColor("rgb(0.0, 0.0, 0.0)", kHTMLStandardMode); + EXPECT_NE(nullptr, value); + EXPECT_TRUE(value->IsColorValue()); + EXPECT_EQ(Color::kBlack, ToCSSColorValue(*value).Value()); + + value = + CSSParserFastPaths::ParseColor("rgb(0.0 , 0.0,0.0)", kHTMLStandardMode); + EXPECT_NE(nullptr, value); + EXPECT_TRUE(value->IsColorValue()); + EXPECT_EQ(Color::kBlack, ToCSSColorValue(*value).Value()); + + value = CSSParserFastPaths::ParseColor("rgb(254.5, 254.5, 254.5)", + kHTMLStandardMode); + EXPECT_NE(nullptr, value); + EXPECT_TRUE(value->IsColorValue()); + EXPECT_EQ(Color::kWhite, ToCSSColorValue(*value).Value()); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp index fd63902ec4..6246d92214 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp @@ -16,7 +16,6 @@ #include "core/css/StyleRuleNamespace.h" #include "core/css/StyleSheetContents.h" #include "core/css/parser/AtRuleDescriptorParser.h" -#include "core/css/parser/AtRuleDescriptorValueSet.h" #include "core/css/parser/CSSAtRuleID.h" #include "core/css/parser/CSSLazyParsingState.h" #include "core/css/parser/CSSLazyPropertyParserImpl.h" @@ -200,8 +199,6 @@ bool CSSParserImpl::ParseDeclarationList( StyleRule::RuleType rule_type = StyleRule::kStyle; if (declaration->CssParserMode() == kCSSViewportRuleMode) rule_type = StyleRule::kViewport; - if (declaration->CssParserMode() == kCSSFontFaceRuleMode) - rule_type = StyleRule::kFontFace; CSSTokenizer tokenizer(string); CSSParserTokenStream stream(tokenizer); parser.ConsumeDeclarationList(stream, rule_type); @@ -438,7 +435,7 @@ bool CSSParserImpl::ConsumeRuleList(CSSParserTokenStream& stream, stream.UncheckedConsume(); continue; } - // fallthrough + FALLTHROUGH; default: rule = ConsumeQualifiedRule(stream, allowed_rules); break; @@ -707,12 +704,8 @@ StyleRuleFontFace* CSSParserImpl::ConsumeFontFaceRule( style_sheet_->SetHasFontFaceRule(); ConsumeDeclarationList(stream, StyleRule::kFontFace); - StyleRuleFontFace* result = - StyleRuleFontFace::Create(AtRuleDescriptorValueSet::Create( - parsed_properties_, kCSSFontFaceRuleMode, - AtRuleDescriptorValueSet::kFontFaceType)); - parsed_properties_.clear(); - return result; + return StyleRuleFontFace::Create( + CreateCSSPropertyValueSet(parsed_properties_, kCSSFontFaceRuleMode)); } StyleRuleKeyframes* CSSParserImpl::ConsumeKeyframesRule( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserToken.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserToken.cpp index baeb2493d4..87cb1f0f72 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserToken.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserToken.cpp @@ -162,7 +162,7 @@ bool CSSParserToken::operator==(const CSSParserToken& other) const { case kHashToken: if (hash_token_type_ != other.hash_token_type_) return false; - // fallthrough + FALLTHROUGH; case kIdentToken: case kFunctionToken: case kStringToken: @@ -171,7 +171,7 @@ bool CSSParserToken::operator==(const CSSParserToken& other) const { case kDimensionToken: if (!ValueDataCharRawEqual(other)) return false; - // fallthrough + FALLTHROUGH; case kNumberToken: case kPercentageToken: return numeric_sign_ == other.numeric_sign_ && diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserTokenStream.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserTokenStream.h index da0fd24a4e..7e373d072b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserTokenStream.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSParserTokenStream.h @@ -65,7 +65,9 @@ class CORE_EXPORT CSSParserTokenStream { static constexpr size_t InitialBufferSize() { return 128; } explicit CSSParserTokenStream(CSSTokenizer& tokenizer) - : buffer_(InitialBufferSize()), tokenizer_(tokenizer), next_(kEOFToken) {} + : tokenizer_(tokenizer), next_(kEOFToken) { + buffer_.ReserveInitialCapacity(InitialBufferSize()); + } CSSParserTokenStream(CSSParserTokenStream&&) = default; @@ -141,7 +143,7 @@ class CORE_EXPORT CSSParserTokenStream { CSSParserTokenRange ConsumeUntilPeekedTypeIs() { EnsureLookAhead(); - buffer_.clear(); + buffer_.Shrink(0); while (!UncheckedAtEnd() && !detail::IsTokenTypeOneOf(UncheckedPeek().GetType())) { // Have to use internal consume/peek in here because they can read past @@ -158,35 +160,10 @@ class CORE_EXPORT CSSParserTokenStream { } while (!PeekInternal().IsEOF() && nesting_level); } - return buffer_.Range(); + return CSSParserTokenRange(buffer_); } private: - // Used to store tokens for CSSParserTokenRanges. - // FIXME: Determine if this improves speed at all compared to allocating a - // fresh vector each time. - class TokenBuffer { - public: - TokenBuffer(size_t capacity) { tokens_.ReserveInitialCapacity(capacity); } - - void clear() { size_ = 0; } - void push_back(const CSSParserToken& token) { - if (size_ < tokens_.size()) - tokens_[size_] = token; - else - tokens_.push_back(token); - ++size_; - } - CSSParserTokenRange Range() const { - return CSSParserTokenRange(tokens_).MakeSubRange(tokens_.begin(), - tokens_.begin() + size_); - } - - private: - Vector tokens_; - size_t size_ = 0; - }; - const CSSParserToken& PeekInternal() { EnsureLookAhead(); return UncheckedPeekInternal(); @@ -211,7 +188,7 @@ class CORE_EXPORT CSSParserTokenStream { void UncheckedSkipToEndOfBlock(); - TokenBuffer buffer_; + Vector buffer_; CSSTokenizer& tokenizer_; CSSParserToken next_; size_t offset_ = 0; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp index addf2077c0..d013b2717a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp @@ -218,7 +218,7 @@ bool CSSPropertyParser::ConsumeCSSWideKeyword(CSSPropertyID unresolved_property, else if (id == CSSValueInherit) value = CSSInheritedValue::Create(); else if (id == CSSValueUnset) - value = CSSUnsetValue::Create(); + value = cssvalue::CSSUnsetValue::Create(); else return false; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp index a4d3da17a7..f0c89ec567 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp @@ -301,7 +301,7 @@ CSSPrimitiveValue* ConsumeLength(CSSParserTokenRange& range, case CSSPrimitiveValue::UnitType::kQuirkyEms: if (css_parser_mode != kUASheetMode) return nullptr; - /* fallthrough intentional */ + FALLTHROUGH; case CSSPrimitiveValue::UnitType::kEms: case CSSPrimitiveValue::UnitType::kRems: case CSSPrimitiveValue::UnitType::kChs: @@ -543,17 +543,16 @@ CSSURIValue* ConsumeUrl(CSSParserTokenRange& range, static int ClampRGBComponent(const CSSPrimitiveValue& value) { double result = value.GetDoubleValue(); - // TODO(timloh): Multiply by 2.55 and round instead of floor. if (value.IsPercentage()) - result *= 2.56; - return clampTo(result, 0, 255); + result *= 2.55; + return clampTo(roundf(result), 0, 255); } static bool ParseRGBParameters(CSSParserTokenRange& range, RGBA32& result) { DCHECK(range.Peek().FunctionId() == CSSValueRgb || range.Peek().FunctionId() == CSSValueRgba); CSSParserTokenRange args = ConsumeFunction(range); - CSSPrimitiveValue* color_parameter = ConsumeInteger(args); + CSSPrimitiveValue* color_parameter = ConsumeNumber(args, kValueRangeAll); if (!color_parameter) color_parameter = ConsumePercent(args, kValueRangeAll); if (!color_parameter) @@ -572,7 +571,7 @@ static bool ParseRGBParameters(CSSParserTokenRange& range, RGBA32& result) { return false; } color_parameter = is_percent ? ConsumePercent(args, kValueRangeAll) - : ConsumeInteger(args); + : ConsumeNumber(args, kValueRangeAll); if (!color_parameter) return false; color_array[i] = ClampRGBComponent(*color_parameter); @@ -901,7 +900,10 @@ bool ConsumePosition(CSSParserTokenRange& range, PositionFromTwoValues(value1, value2, result_x, result_y); return true; } - context.Count(*threeValuePosition); + if (*threeValuePosition == WebFeature::kThreeValuedPositionBackground) + context.Count(*threeValuePosition); + else + context.CountDeprecation(*threeValuePosition); } CSSValue* values[5]; @@ -999,12 +1001,9 @@ static bool ConsumeDeprecatedGradientColorStop(CSSParserTokenRange& range, position = (id == CSSValueFrom) ? 0 : 1; } else { DCHECK(id == CSSValueColorStop); - const CSSParserToken& arg = args.ConsumeIncludingWhitespace(); - if (arg.GetType() == kPercentageToken) - position = arg.NumericValue() / 100.0; - else if (arg.GetType() == kNumberToken) - position = arg.NumericValue(); - else + if (CSSPrimitiveValue* percent_value = ConsumePercent(args, kValueRangeAll)) + position = percent_value->GetDoubleValue() / 100.0; + else if (!ConsumeNumberRaw(args, position)) return false; if (!ConsumeCommaIncludingWhitespace(args)) @@ -1377,14 +1376,14 @@ static CSSValue* ConsumeCrossFade(CSSParserTokenRange& args, return nullptr; CSSPrimitiveValue* percentage = nullptr; - const CSSParserToken& percentage_arg = args.ConsumeIncludingWhitespace(); - if (percentage_arg.GetType() == kPercentageToken) + if (CSSPrimitiveValue* percent_value = ConsumePercent(args, kValueRangeAll)) percentage = CSSPrimitiveValue::Create( - clampTo(percentage_arg.NumericValue() / 100, 0, 1), + clampTo(percent_value->GetDoubleValue() / 100.0, 0, 1), CSSPrimitiveValue::UnitType::kNumber); - else if (percentage_arg.GetType() == kNumberToken) + else if (CSSPrimitiveValue* number_value = + ConsumeNumber(args, kValueRangeAll)) percentage = CSSPrimitiveValue::Create( - clampTo(percentage_arg.NumericValue(), 0, 1), + clampTo(number_value->GetDoubleValue(), 0, 1), CSSPrimitiveValue::UnitType::kNumber); if (!percentage) @@ -1483,6 +1482,16 @@ static CSSValue* ConsumeGeneratedImage(CSSParserTokenRange& range, } if (!result || !args.AtEnd()) return nullptr; + + WebFeature feature; + if (id == CSSValueWebkitCrossFade) + feature = WebFeature::kWebkitCrossFade; + else if (id == CSSValuePaint) + feature = WebFeature::kCSSPaintFunction; + else + feature = WebFeature::kCSSGradient; + context->Count(feature); + range = range_copy; return result; } @@ -1691,11 +1700,15 @@ const CSSValue* ParseLonghand(CSSPropertyID unresolved_property, CSSPropertyID property_id = resolveCSSPropertyID(unresolved_property); DCHECK(!CSSProperty::Get(property_id).IsShorthand()); if (CSSParserFastPaths::IsKeywordPropertyID(property_id)) { - if (!CSSParserFastPaths::IsValidKeywordPropertyAndValue( - property_id, range.Peek().Id(), context.Mode())) + if (CSSParserFastPaths::IsValidKeywordPropertyAndValue( + property_id, range.Peek().Id(), context.Mode())) { + CountKeywordOnlyPropertyUsage(property_id, context, range.Peek().Id()); + return ConsumeIdent(range); + } + + // Some properties need to fallback onto the regular parser. + if (!CSSParserFastPaths::IsPartialKeywordPropertyID(property_id)) return nullptr; - CountKeywordOnlyPropertyUsage(property_id, context, range.Peek().Id()); - return ConsumeIdent(range); } const CSSValue* result = diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParserTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParserTest.cpp index 12bf5de908..bd2f28b662 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParserTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSPropertyParserTest.cpp @@ -5,9 +5,11 @@ #include "core/css/parser/CSSPropertyParser.h" #include "core/css/CSSColorValue.h" +#include "core/css/CSSIdentifierValue.h" #include "core/css/CSSValueList.h" #include "core/css/StyleSheetContents.h" #include "core/css/parser/CSSParser.h" +#include "core/html/HTMLHtmlElement.h" #include "core/testing/DummyPageHolder.h" #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" #include "testing/gtest/include/gtest/gtest.h" @@ -344,4 +346,82 @@ TEST(CSSPropertyParserTest, ClipPathEllipse) { UseCounter::IsCounted(*doc, WebFeature::kBasicShapeEllipseNoRadius)); } +TEST(CSSPropertyParserTest, ScrollCustomizationPropertySingleValue) { + RuntimeEnabledFeatures::SetScrollCustomizationEnabled(true); + const CSSValue* value = CSSParser::ParseSingleValue( + CSSPropertyScrollCustomization, "pan-down", + StrictCSSParserContext(SecureContextMode::kSecureContext)); + DCHECK(value); + const CSSValueList* list = ToCSSValueList(value); + EXPECT_EQ(1U, list->length()); + EXPECT_EQ(CSSValuePanDown, ToCSSIdentifierValue(list->Item(0U)).GetValueID()); +} + +TEST(CSSPropertyParserTest, ScrollCustomizationPropertyTwoValuesCombined) { + RuntimeEnabledFeatures::SetScrollCustomizationEnabled(true); + const CSSValue* value = CSSParser::ParseSingleValue( + CSSPropertyScrollCustomization, "pan-left pan-y", + StrictCSSParserContext(SecureContextMode::kSecureContext)); + const CSSValueList* list = ToCSSValueList(value); + EXPECT_EQ(2U, list->length()); + EXPECT_EQ(CSSValuePanLeft, ToCSSIdentifierValue(list->Item(0U)).GetValueID()); + EXPECT_EQ(CSSValuePanY, ToCSSIdentifierValue(list->Item(1U)).GetValueID()); +} + +TEST(CSSPropertyParserTest, ScrollCustomizationPropertyInvalidEntries) { + // We expect exactly one property value per coordinate. + RuntimeEnabledFeatures::SetScrollCustomizationEnabled(true); + const CSSValue* value = CSSParser::ParseSingleValue( + CSSPropertyScrollCustomization, "pan-left pan-right", + StrictCSSParserContext(SecureContextMode::kSecureContext)); + EXPECT_FALSE(value); + value = CSSParser::ParseSingleValue( + CSSPropertyScrollCustomization, "pan-up pan-down", + StrictCSSParserContext(SecureContextMode::kSecureContext)); + EXPECT_FALSE(value); + value = CSSParser::ParseSingleValue( + CSSPropertyScrollCustomization, "pan-x pan-left", + StrictCSSParserContext(SecureContextMode::kSecureContext)); + EXPECT_FALSE(value); + value = CSSParser::ParseSingleValue( + CSSPropertyScrollCustomization, "pan-x pan-x", + StrictCSSParserContext(SecureContextMode::kSecureContext)); + EXPECT_FALSE(value); +} + +TEST(CSSPropertyParserTest, GradientUseCount) { + std::unique_ptr dummy_page_holder = + DummyPageHolder::Create(IntSize(800, 600)); + Document& document = dummy_page_holder->GetDocument(); + WebFeature feature = WebFeature::kCSSGradient; + EXPECT_FALSE(UseCounter::IsCounted(document, feature)); + document.documentElement()->SetInnerHTMLFromString( + ""); + EXPECT_TRUE(UseCounter::IsCounted(document, feature)); +} + +TEST(CSSPropertyParserTest, PaintUseCount) { + std::unique_ptr dummy_page_holder = + DummyPageHolder::Create(IntSize(800, 600)); + Document& document = dummy_page_holder->GetDocument(); + document.SetSecureContextStateForTesting(SecureContextState::kSecure); + WebFeature feature = WebFeature::kCSSPaintFunction; + EXPECT_FALSE(UseCounter::IsCounted(document, feature)); + document.documentElement()->SetInnerHTMLFromString( + ""); + EXPECT_TRUE(UseCounter::IsCounted(document, feature)); +} + +TEST(CSSPropertyParserTest, CrossFadeUseCount) { + std::unique_ptr dummy_page_holder = + DummyPageHolder::Create(IntSize(800, 600)); + Document& document = dummy_page_holder->GetDocument(); + WebFeature feature = WebFeature::kWebkitCrossFade; + EXPECT_FALSE(UseCounter::IsCounted(document, feature)); + document.documentElement()->SetInnerHTMLFromString( + ""); + EXPECT_TRUE(UseCounter::IsCounted(document, feature)); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSProtoConverter.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSProtoConverter.cpp index d8cea1c423..5ac169791a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSProtoConverter.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSProtoConverter.cpp @@ -180,6 +180,7 @@ const std::string Converter::kMfNameLookupTable[] = { "-webkit-transform-3d", "scan", "shape", + "immersive", "INVALID_NAME"}; const std::string Converter::kImportLookupTable[] = { @@ -935,6 +936,7 @@ const std::string Converter::kPropertyLookupTable[] = { "-webkit-column-rule", "-webkit-order", "grid-row-gap", + "row-gap", "backdrop-filter", "font-variant-east-asian", "buffered-rendering", @@ -1368,6 +1370,7 @@ const std::string Converter::kPropertyLookupTable[] = { "-webkit-box-direction", "image-rendering", "src", + "gap", "grid-gap", "pointer-events", "border-image-width", diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp index fd29c00e88..f83a743b44 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSSelectorParser.cpp @@ -30,6 +30,9 @@ CSSSelectorList CSSSelectorParser::ParseSelector( return CSSSelectorList(); parser.RecordUsageAndDeprecations(result); + + if (result.HasPseudoMatches()) + return result.TransformForPseudoMatches(); return result; } @@ -43,6 +46,9 @@ CSSSelectorList CSSSelectorParser::ConsumeSelector( stream.ConsumeWhitespace(); CSSSelectorList result = parser.ConsumeComplexSelectorList(stream, observer); parser.RecordUsageAndDeprecations(result); + + if (result.HasPseudoMatches()) + return result.TransformForPseudoMatches(); return result; } @@ -528,9 +534,20 @@ std::unique_ptr CSSSelectorParser::ConsumePseudo( return nullptr; switch (selector->GetPseudoType()) { - case CSSSelector::kPseudoMatches: + case CSSSelector::kPseudoMatches: { if (!RuntimeEnabledFeatures::CSSMatchesEnabled()) break; + + DisallowPseudoElementsScope scope(this); + + std::unique_ptr selector_list = + std::make_unique(); + *selector_list = ConsumeComplexSelectorList(block); + if (!selector_list->IsValid() || !block.AtEnd()) + return nullptr; + selector->SetSelectorList(std::move(selector_list)); + return selector; + } case CSSSelector::kPseudoHost: case CSSSelector::kPseudoHostContext: case CSSSelector::kPseudoAny: @@ -540,7 +557,8 @@ std::unique_ptr CSSSelectorParser::ConsumePseudo( std::unique_ptr selector_list = std::make_unique(); *selector_list = ConsumeCompoundSelectorList(block); - if (!selector_list->IsValid() || !block.AtEnd()) + if (!selector_list->IsValid() || !block.AtEnd() || + selector_list->HasPseudoMatches()) return nullptr; selector->SetSelectorList(std::move(selector_list)); return selector; @@ -562,7 +580,8 @@ std::unique_ptr CSSSelectorParser::ConsumePseudo( std::unique_ptr inner_selector = ConsumeCompoundSelector(block); block.ConsumeWhitespace(); - if (!inner_selector || !block.AtEnd()) + if (!inner_selector || !block.AtEnd() || + inner_selector->GetPseudoType() == CSSSelector::kPseudoMatches) return nullptr; Vector> selector_vector; selector_vector.push_back(std::move(inner_selector)); @@ -675,6 +694,7 @@ CSSSelector::MatchType CSSSelectorParser::ConsumeAttributeMatch( case kDelimiterToken: if (token.Delimiter() == '=') return CSSSelector::kAttributeExact; + FALLTHROUGH; default: failed_parsing_ = true; return CSSSelector::kAttributeExact; @@ -901,7 +921,7 @@ void CSSSelectorParser::RecordUsageAndDeprecations( if (!context_->IsUseCounterRecordingEnabled()) return; - for (const CSSSelector* selector = selector_list.First(); selector; + for (const CSSSelector* selector = selector_list.FirstForCSSOM(); selector; selector = CSSSelectorList::Next(*selector)) { for (const CSSSelector* current = selector; current; current = current->TagHistory()) { @@ -911,8 +931,14 @@ void CSSSelectorParser::RecordUsageAndDeprecations( feature = WebFeature::kCSSSelectorPseudoAny; break; case CSSSelector::kPseudoMatches: - if (RuntimeEnabledFeatures::CSSMatchesEnabled()) - feature = WebFeature::kCSSSelectorPseudoMatches; + DCHECK(RuntimeEnabledFeatures::CSSMatchesEnabled()); + feature = WebFeature::kCSSSelectorPseudoMatches; + break; + case CSSSelector::kPseudoAnyLink: + feature = WebFeature::kCSSSelectorPseudoAnyLink; + break; + case CSSSelector::kPseudoWebkitAnyLink: + feature = WebFeature::kCSSSelectorPseudoWebkitAnyLink; break; case CSSSelector::kPseudoUnresolved: feature = WebFeature::kCSSSelectorPseudoUnresolved; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp index dd6f1050b9..3e36614c75 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSSelectorParserTest.cpp @@ -425,6 +425,80 @@ TEST(CSSSelectorParserTest, InternalPseudo) { } } +TEST(CSSSelectorParserTest, InvalidNestingPseudoMatches) { + // :matches() is currently not supported within these pseudo classes as they + // currently do not support complex selector arguments (:matches() does + // support this and the expansion of :matches() may provide complex selector + // arguments to these pseudo classes). Most of these test cases should + // eventually be removed once they support complex selector arguments. + const char* test_cases[] = {":-webkit-any(:matches(.a))", + "::cue(:matches(.a))", + ":cue(:matches(.a))", + ":host(:matches(.a))", + ":host-context(:matches(.a))", + ":lang(:matches(.a))", + ":not(:matches(.a))", + ":nth-child(:matches(.a))", + ":nth-last-child(:matches(.a))", + ":nth-last-of-type(:matches(.a))", + ":nth-of-type(:matches(.a))", + "::slotted(:matches(.a))"}; + + CSSParserContext* context = CSSParserContext::Create( + kHTMLStandardMode, SecureContextMode::kInsecureContext); + StyleSheetContents* sheet = StyleSheetContents::Create(context); + + for (auto test_case : test_cases) { + SCOPED_TRACE(test_case); + CSSTokenizer tokenizer(test_case); + const auto tokens = tokenizer.TokenizeToEOF(); + CSSParserTokenRange range(tokens); + CSSSelectorList list = + CSSSelectorParser::ParseSelector(range, context, sheet); + EXPECT_FALSE(list.IsValid()); + } +} + +TEST(CSSSelectorParserTest, InvalidPseudoMatchesArguments) { + // Pseudo-elements are not valid within :matches() as per the spec: + // https://drafts.csswg.org/selectors-4/#matches + const char* test_cases[] = {":matches(::-webkit-progress-bar)", + ":matches(::-webkit-progress-value)", + ":matches(::-webkit-slider-runnable-track)", + ":matches(::-webkit-slider-thumb)", + ":matches(::after)", + ":matches(::backdrop)", + ":matches(::before)", + ":matches(::cue)", + ":matches(::first-letter)", + ":matches(::first-line)", + ":matches(::grammar-error)", + ":matches(::marker)", + ":matches(::placeholder)", + ":matches(::selection)", + ":matches(::slotted)", + ":matches(::spelling-error)", + ":matches(:after)", + ":matches(:before)", + ":matches(:cue)", + ":matches(:first-letter)", + ":matches(:first-line)"}; + + CSSParserContext* context = CSSParserContext::Create( + kHTMLStandardMode, SecureContextMode::kInsecureContext); + StyleSheetContents* sheet = StyleSheetContents::Create(context); + + for (auto test_case : test_cases) { + SCOPED_TRACE(test_case); + CSSTokenizer tokenizer(test_case); + const auto tokens = tokenizer.TokenizeToEOF(); + CSSParserTokenRange range(tokens); + CSSSelectorList list = + CSSSelectorParser::ParseSelector(range, context, sheet); + EXPECT_FALSE(list.IsValid()); + } +} + namespace { const auto TagLocalName = [](const CSSSelector* selector) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSTokenizerTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSTokenizerTest.cpp index d0a2451c4e..17952a3f8c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSTokenizerTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/CSSTokenizerTest.cpp @@ -39,7 +39,7 @@ void CompareTokens(const CSSParserToken& expected, break; case kNumberToken: ASSERT_EQ(expected.GetNumericSign(), actual.GetNumericSign()); - // fallthrough + FALLTHROUGH; case kPercentageToken: ASSERT_EQ(expected.GetNumericValueType(), actual.GetNumericValueType()); ASSERT_DOUBLE_EQ(expected.NumericValue(), actual.NumericValue()); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/MediaQueryParser.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/MediaQueryParser.cpp index bf5e4d8b49..0eb43c2e43 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/MediaQueryParser.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/MediaQueryParser.cpp @@ -17,12 +17,20 @@ scoped_refptr MediaQueryParser::ParseMediaQuerySet( scoped_refptr MediaQueryParser::ParseMediaQuerySet( CSSParserTokenRange range) { - return MediaQueryParser(kMediaQuerySetParser).ParseImpl(range); + return MediaQueryParser(kMediaQuerySetParser, kHTMLStandardMode) + .ParseImpl(range); +} + +scoped_refptr MediaQueryParser::ParseMediaQuerySetInMode( + CSSParserTokenRange range, + CSSParserMode mode) { + return MediaQueryParser(kMediaQuerySetParser, mode).ParseImpl(range); } scoped_refptr MediaQueryParser::ParseMediaCondition( CSSParserTokenRange range) { - return MediaQueryParser(kMediaConditionParser).ParseImpl(range); + return MediaQueryParser(kMediaConditionParser, kHTMLStandardMode) + .ParseImpl(range); } const MediaQueryParser::State MediaQueryParser::kReadRestrictor = @@ -49,8 +57,10 @@ const MediaQueryParser::State MediaQueryParser::kSkipUntilBlockEnd = &MediaQueryParser::SkipUntilBlockEnd; const MediaQueryParser::State MediaQueryParser::kDone = &MediaQueryParser::Done; -MediaQueryParser::MediaQueryParser(ParserType parser_type) - : parser_type_(parser_type), query_set_(MediaQuerySet::Create()) { +MediaQueryParser::MediaQueryParser(ParserType parser_type, CSSParserMode mode) + : parser_type_(parser_type), + query_set_(MediaQuerySet::Create()), + mode_(mode) { if (parser_type == kMediaQuerySetParser) state_ = &MediaQueryParser::ReadRestrictor; else // MediaConditionParser @@ -68,16 +78,18 @@ void MediaQueryParser::SetStateAndRestrict( // State machine member functions start here void MediaQueryParser::ReadRestrictor(CSSParserTokenType type, - const CSSParserToken& token) { - ReadMediaType(type, token); + const CSSParserToken& token, + CSSParserTokenRange& range) { + ReadMediaType(type, token, range); } void MediaQueryParser::ReadMediaNot(CSSParserTokenType type, - const CSSParserToken& token) { + const CSSParserToken& token, + CSSParserTokenRange& range) { if (type == kIdentToken && EqualIgnoringASCIICase(token.Value(), "not")) SetStateAndRestrict(kReadFeatureStart, MediaQuery::kNot); else - ReadFeatureStart(type, token); + ReadFeatureStart(type, token, range); } static bool IsRestrictorOrLogicalOperator(const CSSParserToken& token) { @@ -89,7 +101,8 @@ static bool IsRestrictorOrLogicalOperator(const CSSParserToken& token) { } void MediaQueryParser::ReadMediaType(CSSParserTokenType type, - const CSSParserToken& token) { + const CSSParserToken& token, + CSSParserTokenRange& range) { if (type == kLeftParenthesisToken) { if (media_query_data_.Restrictor() != MediaQuery::kNone) state_ = kSkipUntilComma; @@ -115,12 +128,13 @@ void MediaQueryParser::ReadMediaType(CSSParserTokenType type, } else { state_ = kSkipUntilComma; if (type == kCommaToken) - SkipUntilComma(type, token); + SkipUntilComma(type, token, range); } } void MediaQueryParser::ReadAnd(CSSParserTokenType type, - const CSSParserToken& token) { + const CSSParserToken& token, + CSSParserTokenRange& range) { if (type == kIdentToken && EqualIgnoringASCIICase(token.Value(), "and")) { state_ = kReadFeatureStart; } else if (type == kCommaToken && parser_type_ != kMediaConditionParser) { @@ -134,7 +148,8 @@ void MediaQueryParser::ReadAnd(CSSParserTokenType type, } void MediaQueryParser::ReadFeatureStart(CSSParserTokenType type, - const CSSParserToken& token) { + const CSSParserToken& token, + CSSParserTokenRange& range) { if (type == kLeftParenthesisToken) state_ = kReadFeature; else @@ -142,55 +157,69 @@ void MediaQueryParser::ReadFeatureStart(CSSParserTokenType type, } void MediaQueryParser::ReadFeature(CSSParserTokenType type, - const CSSParserToken& token) { + const CSSParserToken& token, + CSSParserTokenRange& range) { if (type == kIdentToken) { - media_query_data_.SetMediaFeature(token.Value().ToString()); - state_ = kReadFeatureColon; + String media_feature = token.Value().ToString(); + if (IsMediaFeatureAllowedInMode(media_feature)) { + media_query_data_.SetMediaFeature(media_feature); + state_ = kReadFeatureColon; + } else { + state_ = kSkipUntilComma; + } } else { state_ = kSkipUntilComma; } } void MediaQueryParser::ReadFeatureColon(CSSParserTokenType type, - const CSSParserToken& token) { - if (type == kColonToken) - state_ = kReadFeatureValue; - else if (type == kRightParenthesisToken || type == kEOFToken) - ReadFeatureEnd(type, token); - else + const CSSParserToken& token, + CSSParserTokenRange& range) { + if (type == kColonToken) { + while (range.Peek().GetType() == kWhitespaceToken) + range.Consume(); + if (range.Peek().GetType() == kRightParenthesisToken || type == kEOFToken) + state_ = kSkipUntilBlockEnd; + else + state_ = kReadFeatureValue; + } else if (type == kRightParenthesisToken || type == kEOFToken) { + media_query_data_.AddExpression(range); + ReadFeatureEnd(type, token, range); + } else { state_ = kSkipUntilBlockEnd; + } } void MediaQueryParser::ReadFeatureValue(CSSParserTokenType type, - const CSSParserToken& token) { + const CSSParserToken& token, + CSSParserTokenRange& range) { if (type == kDimensionToken && token.GetUnitType() == CSSPrimitiveValue::UnitType::kUnknown) { + range.Consume(); state_ = kSkipUntilComma; } else { - if (media_query_data_.TryAddParserToken(type, token)) - state_ = kReadFeatureEnd; - else - state_ = kSkipUntilBlockEnd; + media_query_data_.AddExpression(range); + state_ = kReadFeatureEnd; } } void MediaQueryParser::ReadFeatureEnd(CSSParserTokenType type, - const CSSParserToken& token) { + const CSSParserToken& token, + CSSParserTokenRange& range) { if (type == kRightParenthesisToken || type == kEOFToken) { - if (media_query_data_.AddExpression()) + if (media_query_data_.LastExpressionValid()) state_ = kReadAnd; else state_ = kSkipUntilComma; - } else if (type == kDelimiterToken && token.Delimiter() == '/') { - media_query_data_.TryAddParserToken(type, token); - state_ = kReadFeatureValue; } else { + media_query_data_.RemoveLastExpression(); state_ = kSkipUntilBlockEnd; } } void MediaQueryParser::SkipUntilComma(CSSParserTokenType type, - const CSSParserToken& token) { + const CSSParserToken& token, + CSSParserTokenRange& range) { if ((type == kCommaToken && !block_watcher_.BlockLevel()) || type == kEOFToken) { state_ = kReadRestrictor; @@ -200,14 +229,16 @@ void MediaQueryParser::SkipUntilComma(CSSParserTokenType type, } void MediaQueryParser::SkipUntilBlockEnd(CSSParserTokenType type, - const CSSParserToken& token) { + const CSSParserToken& token, + CSSParserTokenRange& range) { if (token.GetBlockType() == CSSParserToken::kBlockEnd && !block_watcher_.BlockLevel()) state_ = kSkipUntilComma; } void MediaQueryParser::Done(CSSParserTokenType type, - const CSSParserToken& token) {} + const CSSParserToken& token, + CSSParserTokenRange& range) {} void MediaQueryParser::HandleBlocks(const CSSParserToken& token) { if (token.GetBlockType() == CSSParserToken::kBlockStart && @@ -215,26 +246,30 @@ void MediaQueryParser::HandleBlocks(const CSSParserToken& token) { state_ = kSkipUntilBlockEnd; } -void MediaQueryParser::ProcessToken(const CSSParserToken& token) { +void MediaQueryParser::ProcessToken(const CSSParserToken& token, + CSSParserTokenRange& range) { CSSParserTokenType type = token.GetType(); - HandleBlocks(token); - block_watcher_.HandleToken(token); + if (state_ != kReadFeatureValue || type == kWhitespaceToken) { + HandleBlocks(token); + block_watcher_.HandleToken(token); + range.Consume(); + } // Call the function that handles current state if (type != kWhitespaceToken) - ((this)->*(state_))(type, token); + ((this)->*(state_))(type, token, range); } // The state machine loop scoped_refptr MediaQueryParser::ParseImpl( CSSParserTokenRange range) { while (!range.AtEnd()) - ProcessToken(range.Consume()); + ProcessToken(range.Peek(), range); // FIXME: Can we get rid of this special case? if (parser_type_ == kMediaQuerySetParser) - ProcessToken(CSSParserToken(kEOFToken)); + ProcessToken(CSSParserToken(kEOFToken), range); if (state_ != kReadAnd && state_ != kReadRestrictor && state_ != kDone && state_ != kReadMediaNot) @@ -245,6 +280,12 @@ scoped_refptr MediaQueryParser::ParseImpl( return query_set_; } +bool MediaQueryParser::IsMediaFeatureAllowedInMode( + const String& media_feature) const { + return mode_ == kUASheetMode || + media_feature != MediaFeatureNames::immersiveMediaFeature; +} + MediaQueryData::MediaQueryData() : restrictor_(MediaQuery::kNone), media_type_(MediaTypeNames::all), @@ -255,7 +296,6 @@ void MediaQueryData::Clear() { media_type_ = MediaTypeNames::all; media_type_set_ = false; media_feature_ = String(); - value_list_.clear(); expressions_.clear(); } @@ -266,23 +306,16 @@ std::unique_ptr MediaQueryData::TakeMediaQuery() { return media_query; } -bool MediaQueryData::AddExpression() { - MediaQueryExp expression = MediaQueryExp::Create(media_feature_, value_list_); - expressions_.push_back(expression); - value_list_.clear(); - return expression.IsValid(); +void MediaQueryData::AddExpression(CSSParserTokenRange& range) { + expressions_.push_back(MediaQueryExp::Create(media_feature_, range)); } -bool MediaQueryData::TryAddParserToken(CSSParserTokenType type, - const CSSParserToken& token) { - if (type == kNumberToken || type == kPercentageToken || - type == kDimensionToken || type == kDelimiterToken || - type == kIdentToken) { - value_list_.push_back(token); - return true; - } +bool MediaQueryData::LastExpressionValid() { + return expressions_.back().IsValid(); +} - return false; +void MediaQueryData::RemoveLastExpression() { + expressions_.pop_back(); } void MediaQueryData::SetMediaType(const String& media_type) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/MediaQueryParser.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/MediaQueryParser.h index 97716a5081..1618275c46 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/MediaQueryParser.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/MediaQueryParser.h @@ -10,6 +10,7 @@ #include "core/css/MediaList.h" #include "core/css/MediaQuery.h" #include "core/css/MediaQueryExp.h" +#include "core/css/parser/CSSParserMode.h" #include "core/css/parser/CSSParserToken.h" #include "core/css/parser/CSSParserTokenRange.h" #include "core/css/parser/MediaQueryBlockWatcher.h" @@ -27,14 +28,14 @@ class MediaQueryData { String media_type_; ExpressionHeapVector expressions_; String media_feature_; - Vector value_list_; bool media_type_set_; public: MediaQueryData(); void Clear(); - bool AddExpression(); - bool TryAddParserToken(CSSParserTokenType, const CSSParserToken&); + void AddExpression(CSSParserTokenRange&); + bool LastExpressionValid(); + void RemoveLastExpression(); void SetMediaType(const String&); std::unique_ptr TakeMediaQuery(); @@ -59,6 +60,9 @@ class CORE_EXPORT MediaQueryParser { static scoped_refptr ParseMediaQuerySet(const String&); static scoped_refptr ParseMediaQuerySet(CSSParserTokenRange); static scoped_refptr ParseMediaCondition(CSSParserTokenRange); + static scoped_refptr ParseMediaQuerySetInMode( + CSSParserTokenRange, + CSSParserMode); private: enum ParserType { @@ -66,37 +70,61 @@ class CORE_EXPORT MediaQueryParser { kMediaConditionParser, }; - MediaQueryParser(ParserType); + MediaQueryParser(ParserType, CSSParserMode); virtual ~MediaQueryParser(); scoped_refptr ParseImpl(CSSParserTokenRange); - void ProcessToken(const CSSParserToken&); - - void ReadRestrictor(CSSParserTokenType, const CSSParserToken&); - void ReadMediaNot(CSSParserTokenType, const CSSParserToken&); - void ReadMediaType(CSSParserTokenType, const CSSParserToken&); - void ReadAnd(CSSParserTokenType, const CSSParserToken&); - void ReadFeatureStart(CSSParserTokenType, const CSSParserToken&); - void ReadFeature(CSSParserTokenType, const CSSParserToken&); - void ReadFeatureColon(CSSParserTokenType, const CSSParserToken&); - void ReadFeatureValue(CSSParserTokenType, const CSSParserToken&); - void ReadFeatureEnd(CSSParserTokenType, const CSSParserToken&); - void SkipUntilComma(CSSParserTokenType, const CSSParserToken&); - void SkipUntilBlockEnd(CSSParserTokenType, const CSSParserToken&); - void Done(CSSParserTokenType, const CSSParserToken&); + void ProcessToken(const CSSParserToken&, CSSParserTokenRange&); + + void ReadRestrictor(CSSParserTokenType, + const CSSParserToken&, + CSSParserTokenRange&); + void ReadMediaNot(CSSParserTokenType, + const CSSParserToken&, + CSSParserTokenRange&); + void ReadMediaType(CSSParserTokenType, + const CSSParserToken&, + CSSParserTokenRange&); + void ReadAnd(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); + void ReadFeatureStart(CSSParserTokenType, + const CSSParserToken&, + CSSParserTokenRange&); + void ReadFeature(CSSParserTokenType, + const CSSParserToken&, + CSSParserTokenRange&); + void ReadFeatureColon(CSSParserTokenType, + const CSSParserToken&, + CSSParserTokenRange&); + void ReadFeatureValue(CSSParserTokenType, + const CSSParserToken&, + CSSParserTokenRange&); + void ReadFeatureEnd(CSSParserTokenType, + const CSSParserToken&, + CSSParserTokenRange&); + void SkipUntilComma(CSSParserTokenType, + const CSSParserToken&, + CSSParserTokenRange&); + void SkipUntilBlockEnd(CSSParserTokenType, + const CSSParserToken&, + CSSParserTokenRange&); + void Done(CSSParserTokenType, const CSSParserToken&, CSSParserTokenRange&); using State = void (MediaQueryParser::*)(CSSParserTokenType, - const CSSParserToken&); + const CSSParserToken&, + CSSParserTokenRange&); void SetStateAndRestrict(State, MediaQuery::RestrictorType); void HandleBlocks(const CSSParserToken&); + bool IsMediaFeatureAllowedInMode(const String& media_feature) const; + State state_; ParserType parser_type_; MediaQueryData media_query_data_; scoped_refptr query_set_; MediaQueryBlockWatcher block_watcher_; + CSSParserMode mode_; const static State kReadRestrictor; const static State kReadMediaNot; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/SizesCalcParser.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/SizesCalcParser.cpp index 12a360f2e5..e02642e51c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/SizesCalcParser.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/SizesCalcParser.cpp @@ -32,25 +32,31 @@ static bool OperatorPriority(UChar cc, bool& high_priority) { bool SizesCalcParser::HandleOperator(Vector& stack, const CSSParserToken& token) { - // If the token is an operator, o1, then: - // while there is an operator token, o2, at the top of the stack, and - // either o1 is left-associative and its precedence is equal to that of o2, - // or o1 has precedence less than that of o2, - // pop o2 off the stack, onto the output queue; - // push o1 onto the stack. - bool stack_operator_priority; + // If the token is not an operator, then return. Else determine the + // precedence of the new operator (op1). bool incoming_operator_priority; - if (!OperatorPriority(token.Delimiter(), incoming_operator_priority)) return false; - if (!stack.IsEmpty() && stack.back().GetType() == kDelimiterToken) { - if (!OperatorPriority(stack.back().Delimiter(), stack_operator_priority)) + + while (!stack.IsEmpty()) { + // While there is an operator (op2) at the top of the stack, + // determine its precedence, and... + const CSSParserToken& top_of_stack = stack.back(); + if (top_of_stack.GetType() != kDelimiterToken) + break; + bool stack_operator_priority; + if (!OperatorPriority(top_of_stack.Delimiter(), stack_operator_priority)) return false; - if (!incoming_operator_priority || stack_operator_priority) { - AppendOperator(stack.back()); - stack.pop_back(); - } + // ...if op1 is left-associative (all currently supported + // operators are) and its precedence is equal to that of op2, or + // op1 has precedence less than that of op2, ... + if (incoming_operator_priority && !stack_operator_priority) + break; + // ...pop op2 off the stack and add it to the output queue. + AppendOperator(top_of_stack); + stack.pop_back(); } + // Push op1 onto the stack. stack.push_back(token); return true; } @@ -103,7 +109,8 @@ bool SizesCalcParser::CalcToReversePolishNotation(CSSParserTokenRange range) { case kFunctionToken: if (!EqualIgnoringASCIICase(token.Value(), "calc")) return false; - // "calc(" is the same as "(" + // "calc(" is the same as "(" + FALLTHROUGH; case kLeftParenthesisToken: // If the token is a left parenthesis, then push it onto the stack. stack.push_back(token); @@ -131,6 +138,7 @@ bool SizesCalcParser::CalcToReversePolishNotation(CSSParserTokenRange range) { break; case kCommentToken: NOTREACHED(); + FALLTHROUGH; case kCDOToken: case kCDCToken: case kAtKeywordToken: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/SizesCalcParserTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/SizesCalcParserTest.cpp index 830c5179b1..5ed0ffa12c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/SizesCalcParserTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/parser/SizesCalcParserTest.cpp @@ -97,6 +97,14 @@ TEST(SizesCalcParserTest, Basic) { {"calc(100px @ 2)", 0, false, false}, {"calc(1 flim 2)", 0, false, false}, {"calc(1 flim (2))", 0, false, false}, + {"calc((100vw - 2 * 40px - 2 * 30px) / 3)", 120, true, false}, + {"calc((100vw - 40px - 60px - 40px) / 3)", 120, true, false}, + {"calc((50vw + 40px + 30px + 40px) / 3)", 120, true, false}, + {"calc((100vw - 2 / 2 * 40px - 2 * 30px) / 4)", 100, true, false}, + {"calc((100vw - 2 * 2 / 2 * 40px - 2 * 30px) / 3)", 120, true, false}, + {"calc((100vw - 2 * 2 / 2 * 40px - 2 * 30px) / 3)", 120, true, false}, + {"calc((100vw - 2 * 2 * 20px - 2 * 30px) / 3)", 120, true, false}, + {"calc((100vw - 320px / 2 / 2 - 2 * 30px) / 3)", 120, true, false}, {nullptr, 0, true, false} // Do not remove the terminator line. }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/CSSParsingUtils.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/CSSParsingUtils.cpp index 67b7e5a4a5..4297374fa2 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/CSSParsingUtils.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/CSSParsingUtils.cpp @@ -46,24 +46,23 @@ #include "platform/wtf/text/StringBuilder.h" namespace blink { + +using namespace cssvalue; + namespace CSSParsingUtils { namespace { -bool IsSelfPositionKeyword(CSSValueID id) { - return CSSPropertyParserHelpers::IdentMatches< - CSSValueStart, CSSValueEnd, CSSValueCenter, CSSValueSelfStart, - CSSValueSelfEnd, CSSValueFlexStart, CSSValueFlexEnd, CSSValueLeft, - CSSValueRight>(id); +bool IsLeftOrRightKeyword(CSSValueID id) { + return CSSPropertyParserHelpers::IdentMatches( + id); } -CSSIdentifierValue* ConsumeSelfPositionKeyword(CSSParserTokenRange& range) { - return IsSelfPositionKeyword(range.Peek().Id()) - ? CSSPropertyParserHelpers::ConsumeIdent(range) - : nullptr; +bool IsAuto(CSSValueID id) { + return CSSPropertyParserHelpers::IdentMatches(id); } -bool IsAutoOrNormalOrStretch(CSSValueID id) { - return CSSPropertyParserHelpers::IdentMatches(id); } @@ -73,17 +72,17 @@ bool IsContentDistributionKeyword(CSSValueID id) { CSSValueStretch>(id); } -bool IsContentPositionKeyword(CSSValueID id) { - return CSSPropertyParserHelpers::IdentMatches< - CSSValueStart, CSSValueEnd, CSSValueCenter, CSSValueFlexStart, - CSSValueFlexEnd, CSSValueLeft, CSSValueRight>(id); -} - bool IsOverflowKeyword(CSSValueID id) { return CSSPropertyParserHelpers::IdentMatches( id); } +CSSIdentifierValue* ConsumeOverflowPositionKeyword(CSSParserTokenRange& range) { + return IsOverflowKeyword(range.Peek().Id()) + ? CSSPropertyParserHelpers::ConsumeIdent(range) + : nullptr; +} + bool IsBaselineKeyword(CSSValueID id) { return CSSPropertyParserHelpers::IdentMatches(id); @@ -95,32 +94,26 @@ CSSValueID GetBaselineKeyword(CSSValue& value) { return CSSValueBaseline; } + DCHECK(ToCSSIdentifierValue(ToCSSValuePair(value).First()).GetValueID() == + CSSValueLast); DCHECK(ToCSSIdentifierValue(ToCSSValuePair(value).Second()).GetValueID() == CSSValueBaseline); - if (ToCSSIdentifierValue(ToCSSValuePair(value).First()).GetValueID() == - CSSValueLast) { - return CSSValueLastBaseline; - } - DCHECK(ToCSSIdentifierValue(ToCSSValuePair(value).First()).GetValueID() == - CSSValueFirst); - return CSSValueFirstBaseline; + return CSSValueLastBaseline; } CSSValue* ConsumeBaselineKeyword(CSSParserTokenRange& range) { - CSSValueID id = range.Peek().Id(); - if (CSSPropertyParserHelpers::IdentMatches(id)) - return CSSPropertyParserHelpers::ConsumeIdent(range); - - if (CSSIdentifierValue* preference = - CSSPropertyParserHelpers::ConsumeIdent( - range)) { - if (range.Peek().Id() == CSSValueBaseline) { - return CSSValuePair::Create(preference, - CSSPropertyParserHelpers::ConsumeIdent(range), - CSSValuePair::kDropIdenticalValues); - } + CSSIdentifierValue* preference = + CSSPropertyParserHelpers::ConsumeIdent( + range); + CSSIdentifierValue* baseline = + CSSPropertyParserHelpers::ConsumeIdent(range); + if (!baseline) + return nullptr; + if (preference && preference->GetValueID() == CSSValueLast) { + return CSSValuePair::Create(preference, baseline, + CSSValuePair::kDropIdenticalValues); } - return nullptr; + return baseline; } CSSValue* ConsumeSteps(CSSParserTokenRange& range) { @@ -534,45 +527,75 @@ CSSValue* ConsumeTransformValue(CSSParserTokenRange& range, } // namespace -CSSValue* ConsumeSelfPositionOverflowPosition(CSSParserTokenRange& range) { +bool IsSelfPositionKeyword(CSSValueID id) { + return CSSPropertyParserHelpers::IdentMatches< + CSSValueStart, CSSValueEnd, CSSValueCenter, CSSValueSelfStart, + CSSValueSelfEnd, CSSValueFlexStart, CSSValueFlexEnd>(id); +} + +bool IsSelfPositionOrLeftOrRightKeyword(CSSValueID id) { + return IsSelfPositionKeyword(id) || IsLeftOrRightKeyword(id); +} + +bool IsContentPositionKeyword(CSSValueID id) { + return CSSPropertyParserHelpers::IdentMatches< + CSSValueStart, CSSValueEnd, CSSValueCenter, CSSValueFlexStart, + CSSValueFlexEnd>(id); +} + +bool IsContentPositionOrLeftOrRightKeyword(CSSValueID id) { + return IsContentPositionKeyword(id) || IsLeftOrRightKeyword(id); +} + +CSSValue* ConsumeSelfPositionOverflowPosition( + CSSParserTokenRange& range, + IsPositionKeyword is_position_keyword) { + DCHECK(is_position_keyword); CSSValueID id = range.Peek().Id(); - if (IsAutoOrNormalOrStretch(id)) + if (IsAuto(id) || IsNormalOrStretch(id)) return CSSPropertyParserHelpers::ConsumeIdent(range); if (IsBaselineKeyword(id)) return ConsumeBaselineKeyword(range); - CSSIdentifierValue* overflow_position = - CSSPropertyParserHelpers::ConsumeIdent( - range); - CSSIdentifierValue* self_position = ConsumeSelfPositionKeyword(range); - if (!self_position) + CSSIdentifierValue* overflow_position = ConsumeOverflowPositionKeyword(range); + if (!is_position_keyword(range.Peek().Id())) return nullptr; - if (!overflow_position) { - overflow_position = - CSSPropertyParserHelpers::ConsumeIdent( - range); - } + CSSIdentifierValue* self_position = + CSSPropertyParserHelpers::ConsumeIdent(range); if (overflow_position) { - return CSSValuePair::Create(self_position, overflow_position, + return CSSValuePair::Create(overflow_position, self_position, CSSValuePair::kDropIdenticalValues); } return self_position; } -CSSValue* ConsumeSimplifiedItemPosition(CSSParserTokenRange& range) { +CSSValue* ConsumeSimplifiedDefaultPosition( + CSSParserTokenRange& range, + IsPositionKeyword is_position_keyword) { + DCHECK(is_position_keyword); CSSValueID id = range.Peek().Id(); - if (IsAutoOrNormalOrStretch(id)) + if (IsNormalOrStretch(id) || is_position_keyword(id)) return CSSPropertyParserHelpers::ConsumeIdent(range); if (IsBaselineKeyword(id)) return ConsumeBaselineKeyword(range); - return ConsumeSelfPositionKeyword(range); + return nullptr; +} + +CSSValue* ConsumeSimplifiedSelfPosition(CSSParserTokenRange& range, + IsPositionKeyword is_position_keyword) { + DCHECK(is_position_keyword); + return IsAuto(range.Peek().Id()) + ? CSSPropertyParserHelpers::ConsumeIdent(range) + : ConsumeSimplifiedDefaultPosition(range, is_position_keyword); } CSSValue* ConsumeContentDistributionOverflowPosition( - CSSParserTokenRange& range) { + CSSParserTokenRange& range, + IsPositionKeyword is_position_keyword) { + DCHECK(is_position_keyword); CSSValueID id = range.Peek().Id(); if (CSSPropertyParserHelpers::IdentMatches(id)) { return CSSContentDistributionValue::Create( @@ -588,46 +611,30 @@ CSSValue* ConsumeContentDistributionOverflowPosition( CSSValueInvalid, GetBaselineKeyword(*baseline), CSSValueInvalid); } - CSSValueID distribution = CSSValueInvalid; - CSSValueID position = CSSValueInvalid; - CSSValueID overflow = CSSValueInvalid; - do { - if (IsContentDistributionKeyword(id)) { - if (distribution != CSSValueInvalid) - return nullptr; - distribution = id; - } else if (IsContentPositionKeyword(id)) { - if (position != CSSValueInvalid) - return nullptr; - position = id; - } else if (IsOverflowKeyword(id)) { - if (overflow != CSSValueInvalid) - return nullptr; - overflow = id; - } else { - return nullptr; - } - range.ConsumeIncludingWhitespace(); - id = range.Peek().Id(); - } while (!range.AtEnd()); - - // The grammar states that we should have at least or - // . - if (position == CSSValueInvalid && distribution == CSSValueInvalid) - return nullptr; + if (IsContentDistributionKeyword(id)) { + return CSSContentDistributionValue::Create( + range.ConsumeIncludingWhitespace().Id(), CSSValueInvalid, + CSSValueInvalid); + } - // The grammar states that must be associated to - // . - if (overflow != CSSValueInvalid && position == CSSValueInvalid) - return nullptr; + CSSValueID overflow = IsOverflowKeyword(id) + ? range.ConsumeIncludingWhitespace().Id() + : CSSValueInvalid; + if (is_position_keyword(range.Peek().Id())) { + return CSSContentDistributionValue::Create( + CSSValueInvalid, range.ConsumeIncludingWhitespace().Id(), overflow); + } - return CSSContentDistributionValue::Create(distribution, position, overflow); + return nullptr; } -CSSValue* ConsumeSimplifiedContentPosition(CSSParserTokenRange& range) { +CSSValue* ConsumeSimplifiedContentPosition( + CSSParserTokenRange& range, + IsPositionKeyword is_position_keyword) { + DCHECK(is_position_keyword); CSSValueID id = range.Peek().Id(); if (CSSPropertyParserHelpers::IdentMatches(id) || - IsContentPositionKeyword(id)) { + is_position_keyword(id)) { return CSSContentDistributionValue::Create( CSSValueInvalid, range.ConsumeIncludingWhitespace().Id(), CSSValueInvalid); @@ -646,6 +653,7 @@ CSSValue* ConsumeSimplifiedContentPosition(CSSParserTokenRange& range) { range.ConsumeIncludingWhitespace().Id(), CSSValueInvalid, CSSValueInvalid); } + return nullptr; } @@ -1175,7 +1183,7 @@ CSSValue* ConsumeBorderImageSlice(CSSParserTokenRange& range, CSSPropertyParserHelpers::Complete4Sides(slices); if (default_fill == DefaultFill::kFill) fill = true; - return cssvalue::CSSBorderImageSliceValue::Create( + return CSSBorderImageSliceValue::Create( CSSQuadValue::Create(slices[0], slices[1], slices[2], slices[3], CSSQuadValue::kSerializeAsQuad), fill); @@ -1272,12 +1280,15 @@ CSSShadowValue* ParseSingleShadow(CSSParserTokenRange& range, if (range.AtEnd()) return nullptr; + + color = CSSPropertyParserHelpers::ConsumeColor(range, css_parser_mode); if (range.Peek().Id() == CSSValueInset) { if (inset_and_spread != AllowInsetAndSpread::kAllow) return nullptr; style = CSSPropertyParserHelpers::ConsumeIdent(range); + if (!color) + color = CSSPropertyParserHelpers::ConsumeColor(range, css_parser_mode); } - color = CSSPropertyParserHelpers::ConsumeColor(range, css_parser_mode); CSSPrimitiveValue* horizontal_offset = CSSPropertyParserHelpers::ConsumeLength(range, css_parser_mode, @@ -1310,6 +1321,8 @@ CSSShadowValue* ParseSingleShadow(CSSParserTokenRange& range, if (inset_and_spread != AllowInsetAndSpread::kAllow || style) return nullptr; style = CSSPropertyParserHelpers::ConsumeIdent(range); + if (!color) + color = CSSPropertyParserHelpers::ConsumeColor(range, css_parser_mode); } } return CSSShadowValue::Create(horizontal_offset, vertical_offset, blur_radius, @@ -1352,6 +1365,14 @@ bool ConsumeColumnWidthOrCount(CSSParserTokenRange& range, return column_count; } +CSSValue* ConsumeGapLength(CSSParserTokenRange& range, + const CSSParserContext& context) { + if (range.Peek().Id() == CSSValueNormal) + return CSSPropertyParserHelpers::ConsumeIdent(range); + return CSSPropertyParserHelpers::ConsumeLengthOrPercent( + range, context.Mode(), kValueRangeNonNegative); +} + CSSValue* ConsumeCounter(CSSParserTokenRange& range, int default_value) { if (range.Peek().Id() == CSSValueNone) return CSSPropertyParserHelpers::ConsumeIdent(range); @@ -1580,8 +1601,7 @@ CSSValue* ConsumeFontFeatureSettings(CSSParserTokenRange& range) { return CSSPropertyParserHelpers::ConsumeIdent(range); CSSValueList* settings = CSSValueList::CreateCommaSeparated(); do { - cssvalue::CSSFontFeatureValue* font_feature_value = - ConsumeFontFeatureTag(range); + CSSFontFeatureValue* font_feature_value = ConsumeFontFeatureTag(range); if (!font_feature_value) return nullptr; settings->Append(*font_feature_value); @@ -1589,8 +1609,7 @@ CSSValue* ConsumeFontFeatureSettings(CSSParserTokenRange& range) { return settings; } -cssvalue::CSSFontFeatureValue* ConsumeFontFeatureTag( - CSSParserTokenRange& range) { +CSSFontFeatureValue* ConsumeFontFeatureTag(CSSParserTokenRange& range) { // Feature tag name consists of 4-letter characters. const unsigned kTagNameLength = 4; @@ -1611,17 +1630,14 @@ cssvalue::CSSFontFeatureValue* ConsumeFontFeatureTag( int tag_value = 1; // Feature tag values could follow: | on | off - if (range.Peek().GetType() == kNumberToken && - range.Peek().GetNumericValueType() == kIntegerValueType && - range.Peek().NumericValue() >= 0) { - tag_value = clampTo(range.ConsumeIncludingWhitespace().NumericValue()); - if (tag_value < 0) - return nullptr; + if (CSSPrimitiveValue* value = + CSSPropertyParserHelpers::ConsumeInteger(range, 0)) { + tag_value = clampTo(value->GetDoubleValue()); } else if (range.Peek().Id() == CSSValueOn || range.Peek().Id() == CSSValueOff) { tag_value = range.ConsumeIncludingWhitespace().Id() == CSSValueOn; } - return cssvalue::CSSFontFeatureValue::Create(tag, tag_value); + return CSSFontFeatureValue::Create(tag, tag_value); } CSSIdentifierValue* ConsumeFontVariantCSS21(CSSParserTokenRange& range) { @@ -2259,7 +2275,7 @@ CSSValue* ConsumePath(CSSParserTokenRange& range) { range = function_range; if (byte_stream->IsEmpty()) return CSSIdentifierValue::Create(CSSValueNone); - return cssvalue::CSSPathValue::Create(std::move(byte_stream)); + return CSSPathValue::Create(std::move(byte_stream)); } CSSValue* ConsumeRay(CSSParserTokenRange& range, @@ -2386,11 +2402,29 @@ bool ConsumePlaceAlignment(CSSParserTokenRange& range, DCHECK(!align_value); DCHECK(!justify_value); - align_value = consume_alignment_value(range); + bool is_baseline = IsBaselineKeyword(range.Peek().Id()); + bool is_content_alignment = + consume_alignment_value == ConsumeSimplifiedContentPosition; + align_value = consume_alignment_value(range, is_content_alignment + ? IsContentPositionKeyword + : IsSelfPositionKeyword); if (!align_value) return false; - justify_value = range.AtEnd() ? align_value : consume_alignment_value(range); + // justify-content property does not allow the values. + if (is_content_alignment) { + if (range.AtEnd() && is_baseline) + return false; + if (IsBaselineKeyword(range.Peek().Id())) + return false; + } + + justify_value = range.AtEnd() + ? align_value + : consume_alignment_value( + range, is_content_alignment + ? IsContentPositionOrLeftOrRightKeyword + : IsSelfPositionOrLeftOrRightKeyword); return justify_value && range.AtEnd(); } @@ -2458,6 +2492,8 @@ CSSValue* ConsumeBasicShape(CSSParserTokenRange& range, shape = ConsumeBasicShapeInset(args, context); if (!shape || !args.AtEnd()) return nullptr; + + context.Count(WebFeature::kCSSBasicShape); range = range_copy; return shape; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/CSSParsingUtils.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/CSSParsingUtils.h index 8af21eb471..9c4bd0fa27 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/CSSParsingUtils.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/CSSParsingUtils.h @@ -36,14 +36,27 @@ using ConsumeAnimationItemValue = CSSValue* (*)(CSSPropertyID, CSSParserTokenRange&, const CSSParserContext&, bool use_legacy_parsing); -using ConsumePlaceAlignmentValue = CSSValue* (*)(CSSParserTokenRange&); +using IsPositionKeyword = bool (*)(CSSValueID); +using ConsumePlaceAlignmentValue = CSSValue* (*)(CSSParserTokenRange&, + IsPositionKeyword); constexpr size_t kMaxNumAnimationLonghands = 8; -CSSValue* ConsumeSelfPositionOverflowPosition(CSSParserTokenRange&); -CSSValue* ConsumeSimplifiedItemPosition(CSSParserTokenRange&); -CSSValue* ConsumeContentDistributionOverflowPosition(CSSParserTokenRange&); -CSSValue* ConsumeSimplifiedContentPosition(CSSParserTokenRange&); +bool IsSelfPositionKeyword(CSSValueID); +bool IsSelfPositionOrLeftOrRightKeyword(CSSValueID); +bool IsContentPositionKeyword(CSSValueID); +bool IsContentPositionOrLeftOrRightKeyword(CSSValueID); + +CSSValue* ConsumeSelfPositionOverflowPosition(CSSParserTokenRange&, + IsPositionKeyword); +CSSValue* ConsumeSimplifiedDefaultPosition(CSSParserTokenRange&, + IsPositionKeyword); +CSSValue* ConsumeSimplifiedSelfPosition(CSSParserTokenRange&, + IsPositionKeyword); +CSSValue* ConsumeContentDistributionOverflowPosition(CSSParserTokenRange&, + IsPositionKeyword); +CSSValue* ConsumeSimplifiedContentPosition(CSSParserTokenRange&, + IsPositionKeyword); CSSValue* ConsumeAnimationIterationCount(CSSParserTokenRange&); CSSValue* ConsumeAnimationName(CSSParserTokenRange&, @@ -124,6 +137,7 @@ CSSShadowValue* ParseSingleShadow(CSSParserTokenRange&, CSSValue* ConsumeColumnCount(CSSParserTokenRange&); CSSValue* ConsumeColumnWidth(CSSParserTokenRange&); bool ConsumeColumnWidthOrCount(CSSParserTokenRange&, CSSValue*&, CSSValue*&); +CSSValue* ConsumeGapLength(CSSParserTokenRange&, const CSSParserContext&); CSSValue* ConsumeCounter(CSSParserTokenRange&, int); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/CSSParsingUtilsTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/CSSParsingUtilsTest.cpp new file mode 100644 index 0000000000..8f1d074b93 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/CSSParsingUtilsTest.cpp @@ -0,0 +1,24 @@ +// Copyright 2018 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 "core/css/properties/CSSParsingUtils.h" +#include "core/frame/UseCounter.h" +#include "core/html/HTMLHtmlElement.h" +#include "core/testing/DummyPageHolder.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace blink { + +TEST(CSSParsingUtilsTest, BasicShapeUseCount) { + std::unique_ptr dummy_page_holder = + DummyPageHolder::Create(IntSize(800, 600)); + Document& document = dummy_page_holder->GetDocument(); + WebFeature feature = WebFeature::kCSSBasicShape; + EXPECT_FALSE(UseCounter::IsCounted(document, feature)); + document.documentElement()->SetInnerHTMLFromString( + ""); + EXPECT_TRUE(UseCounter::IsCounted(document, feature)); +} + +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/ComputedStyleUtils.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/ComputedStyleUtils.cpp index bc85a76482..7b5b926d22 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/ComputedStyleUtils.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/ComputedStyleUtils.cpp @@ -33,6 +33,8 @@ namespace blink { +using namespace cssvalue; + // TODO(rjwright): make this const CSSValue* ComputedStyleUtils::ZoomAdjustedPixelValueForLength( const Length& length, @@ -96,7 +98,7 @@ CSSValue* ComputedStyleUtils::CurrentColorOrValidColor( const StyleColor& color) { // This function does NOT look at visited information, so that computed style // doesn't expose that. - return cssvalue::CSSColorValue::Create(color.Resolve(style.GetColor()).Rgb()); + return CSSColorValue::Create(color.Resolve(style.GetColor()).Rgb()); } const blink::Color ComputedStyleUtils::BorderSideColor( @@ -283,8 +285,8 @@ const CSSValue* ComputedStyleUtils::BackgroundPositionYOrWebkitMaskPositionY( return list; } -cssvalue::CSSBorderImageSliceValue* -ComputedStyleUtils::ValueForNinePieceImageSlice(const NinePieceImage& image) { +CSSBorderImageSliceValue* ComputedStyleUtils::ValueForNinePieceImageSlice( + const NinePieceImage& image) { // Create the slices. CSSPrimitiveValue* top = nullptr; CSSPrimitiveValue* right = nullptr; @@ -440,8 +442,7 @@ CSSValue* ComputedStyleUtils::ValueForNinePieceImage( image_value = image.GetImage()->ComputedCSSValue(); // Create the image slice. - cssvalue::CSSBorderImageSliceValue* image_slices = - ValueForNinePieceImageSlice(image); + CSSBorderImageSliceValue* image_slices = ValueForNinePieceImageSlice(image); // Create the border area slices. CSSValue* border_slices = @@ -496,11 +497,14 @@ CSSValue* ComputedStyleUtils::ValueForReflection( CSSValue* ComputedStyleUtils::MinWidthOrMinHeightAuto( Node* styled_node, const ComputedStyle& style) { - Node* parent = styled_node->parentNode(); - const ComputedStyle* ensured_style = - parent ? parent->EnsureComputedStyle() : nullptr; - if (ensured_style && ensured_style->IsDisplayFlexibleOrGridBox()) - return CSSIdentifierValue::Create(CSSValueAuto); + if (styled_node) { + Node* parent = styled_node->parentNode(); + const ComputedStyle* ensured_style = + parent ? parent->EnsureComputedStyle() : nullptr; + if (ensured_style && ensured_style->IsDisplayFlexibleOrGridBox()) + return CSSIdentifierValue::Create(CSSValueAuto); + } + return ZoomAdjustedPixelValue(0, style); } @@ -640,11 +644,14 @@ CSSValueList* ComputedStyleUtils::ValueForItemPositionWithOverflowAlignment( CSSIdentifierValue::Create(CSSValueBaseline), CSSValuePair::kDropIdenticalValues)); } else { - result->Append(*CSSIdentifierValue::Create(data.GetPosition())); + if (data.GetPosition() >= ItemPosition::kCenter && + data.Overflow() != OverflowAlignment::kDefault) + result->Append(*CSSIdentifierValue::Create(data.Overflow())); + if (data.GetPosition() == ItemPosition::kLegacy) + result->Append(*CSSIdentifierValue::Create(CSSValueNormal)); + else + result->Append(*CSSIdentifierValue::Create(data.GetPosition())); } - if (data.GetPosition() >= ItemPosition::kCenter && - data.Overflow() != OverflowAlignment::kDefault) - result->Append(*CSSIdentifierValue::Create(data.Overflow())); DCHECK_LE(result->length(), 2u); return result; } @@ -672,14 +679,14 @@ ComputedStyleUtils::ValueForContentPositionAndDistributionWithOverflowAlignment( CSSValuePair::kDropIdenticalValues)); break; default: + // Handle overflow-alignment (only allowed for content-position values) + if ((data.GetPosition() >= ContentPosition::kCenter || + data.Distribution() != ContentDistributionType::kDefault) && + data.Overflow() != OverflowAlignment::kDefault) + result->Append(*CSSIdentifierValue::Create(data.Overflow())); result->Append(*CSSIdentifierValue::Create(data.GetPosition())); } - // Handle overflow-alignment (only allowed for content-position values) - if ((data.GetPosition() >= ContentPosition::kCenter || - data.Distribution() != ContentDistributionType::kDefault) && - data.Overflow() != OverflowAlignment::kDefault) - result->Append(*CSSIdentifierValue::Create(data.Overflow())); DCHECK_GT(result->length(), 0u); DCHECK_LE(result->length(), 3u); return result; @@ -2276,4 +2283,45 @@ CSSValue* ComputedStyleUtils::ValuesForFontVariantProperty( } } +// Returns up to two values for 'scroll-customization' property. The values +// correspond to the customization values for 'x' and 'y' axes. +CSSValue* ComputedStyleUtils::ScrollCustomizationFlagsToCSSValue( + ScrollCustomization::ScrollDirection scroll_customization) { + CSSValueList* list = CSSValueList::CreateSpaceSeparated(); + if (scroll_customization == ScrollCustomization::kScrollDirectionAuto) { + list->Append(*CSSIdentifierValue::Create(CSSValueAuto)); + } else if (scroll_customization == + ScrollCustomization::kScrollDirectionNone) { + list->Append(*CSSIdentifierValue::Create(CSSValueNone)); + } else { + if ((scroll_customization & ScrollCustomization::kScrollDirectionPanX) == + ScrollCustomization::kScrollDirectionPanX) + list->Append(*CSSIdentifierValue::Create(CSSValuePanX)); + else if (scroll_customization & + ScrollCustomization::kScrollDirectionPanLeft) + list->Append(*CSSIdentifierValue::Create(CSSValuePanLeft)); + else if (scroll_customization & + ScrollCustomization::kScrollDirectionPanRight) + list->Append(*CSSIdentifierValue::Create(CSSValuePanRight)); + if ((scroll_customization & ScrollCustomization::kScrollDirectionPanY) == + ScrollCustomization::kScrollDirectionPanY) + list->Append(*CSSIdentifierValue::Create(CSSValuePanY)); + else if (scroll_customization & ScrollCustomization::kScrollDirectionPanUp) + list->Append(*CSSIdentifierValue::Create(CSSValuePanUp)); + else if (scroll_customization & + ScrollCustomization::kScrollDirectionPanDown) + list->Append(*CSSIdentifierValue::Create(CSSValuePanDown)); + } + + DCHECK(list->length()); + return list; +} + +CSSValue* ComputedStyleUtils::ValueForGapLength(const GapLength& gap_length, + const ComputedStyle& style) { + if (gap_length.IsNormal()) + return CSSIdentifierValue::Create(CSSValueNormal); + return ZoomAdjustedPixelValueForLength(gap_length.GetLength(), style); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/ComputedStyleUtils.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/ComputedStyleUtils.h index 4b9b7383a9..2ac5f1501e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/ComputedStyleUtils.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/ComputedStyleUtils.h @@ -195,6 +195,9 @@ class ComputedStyleUtils { const LayoutObject*, Node*, bool allow_visited_style); + static CSSValue* ScrollCustomizationFlagsToCSSValue( + ScrollCustomization::ScrollDirection); + static CSSValue* ValueForGapLength(const GapLength&, const ComputedStyle&); }; } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignContentCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignContentCustom.cpp index 692e272f83..6977ebe6a7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignContentCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignContentCustom.cpp @@ -15,7 +15,8 @@ const CSSValue* AlignContent::ParseSingleValue( CSSParserTokenRange& range, const CSSParserContext& context, const CSSParserLocalContext&) const { - return CSSParsingUtils::ConsumeContentDistributionOverflowPosition(range); + return CSSParsingUtils::ConsumeContentDistributionOverflowPosition( + range, CSSParsingUtils::IsContentPositionKeyword); } const CSSValue* AlignContent::CSSValueFromComputedStyleInternal( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignItemsCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignItemsCustom.cpp index 656c2ab274..6c8f03ba9d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignItemsCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignItemsCustom.cpp @@ -19,7 +19,8 @@ const CSSValue* AlignItems::ParseSingleValue( // align-items property does not allow the 'auto' value. if (CSSPropertyParserHelpers::IdentMatches(range.Peek().Id())) return nullptr; - return CSSParsingUtils::ConsumeSelfPositionOverflowPosition(range); + return CSSParsingUtils::ConsumeSelfPositionOverflowPosition( + range, CSSParsingUtils::IsSelfPositionKeyword); } const CSSValue* AlignItems::CSSValueFromComputedStyleInternal( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignSelfCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignSelfCustom.cpp index 0411fc325b..316924e1b8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignSelfCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/AlignSelfCustom.cpp @@ -15,7 +15,8 @@ const CSSValue* AlignSelf::ParseSingleValue( CSSParserTokenRange& range, const CSSParserContext& context, const CSSParserLocalContext&) const { - return CSSParsingUtils::ConsumeSelfPositionOverflowPosition(range); + return CSSParsingUtils::ConsumeSelfPositionOverflowPosition( + range, CSSParsingUtils::IsSelfPositionKeyword); } const CSSValue* AlignSelf::CSSValueFromComputedStyleInternal( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/ColumnGapCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/ColumnGapCustom.cpp index 6de54db5f4..f1fc181b59 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/ColumnGapCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/ColumnGapCustom.cpp @@ -4,9 +4,10 @@ #include "core/css/properties/longhands/ColumnGap.h" -#include "core/css/ZoomAdjustedPixelValue.h" #include "core/css/parser/CSSParserContext.h" #include "core/css/parser/CSSPropertyParserHelpers.h" +#include "core/css/properties/CSSParsingUtils.h" +#include "core/css/properties/ComputedStyleUtils.h" #include "core/style/ComputedStyle.h" namespace blink { @@ -16,21 +17,16 @@ const CSSValue* ColumnGap::ParseSingleValue( CSSParserTokenRange& range, const CSSParserContext& context, const CSSParserLocalContext&) const { - if (range.Peek().Id() == CSSValueNormal) - return CSSPropertyParserHelpers::ConsumeIdent(range); - return CSSPropertyParserHelpers::ConsumeLength(range, context.Mode(), - kValueRangeNonNegative); + return CSSParsingUtils::ConsumeGapLength(range, context); } const CSSValue* ColumnGap::CSSValueFromComputedStyleInternal( const ComputedStyle& style, const SVGComputedStyle&, const LayoutObject*, - Node* styled_node, - bool allow_visited_style) const { - if (style.HasNormalColumnGap()) - return CSSIdentifierValue::Create(CSSValueNormal); - return ZoomAdjustedPixelValue(style.ColumnGap(), style); + Node*, + bool) const { + return ComputedStyleUtils::ValueForGapLength(style.ColumnGap(), style); } } // namespace CSSLonghand diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/DisplayCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/DisplayCustom.cpp index c017b88b3b..97d29362d5 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/DisplayCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/DisplayCustom.cpp @@ -4,15 +4,58 @@ #include "core/css/properties/longhands/Display.h" +#include "core/css/CSSIdentifierValue.h" +#include "core/css/CSSLayoutFunctionValue.h" +#include "core/css/parser/CSSParserContext.h" +#include "core/css/parser/CSSPropertyParserHelpers.h" +#include "core/style/ComputedStyle.h" + namespace blink { namespace CSSLonghand { +const CSSValue* Display::ParseSingleValue(CSSParserTokenRange& range, + const CSSParserContext& context, + const CSSParserLocalContext&) const { + // NOTE: All the keyword values for the display property are handled by the + // CSSParserFastPaths. + if (!RuntimeEnabledFeatures::CSSLayoutAPIEnabled()) + return nullptr; + + if (!context.IsSecureContext()) + return nullptr; + + CSSValueID function = range.Peek().FunctionId(); + if (function != CSSValueLayout && function != CSSValueInlineLayout) + return nullptr; + + CSSParserTokenRange range_copy = range; + CSSParserTokenRange args = + CSSPropertyParserHelpers::ConsumeFunction(range_copy); + CSSCustomIdentValue* name = + CSSPropertyParserHelpers::ConsumeCustomIdent(args); + + // If we didn't get a custom-ident or didn't exhaust the function arguments + // return nothing. + if (!name || !args.AtEnd()) + return nullptr; + + range = range_copy; + return cssvalue::CSSLayoutFunctionValue::Create( + name, /* is_inline */ function == CSSValueInlineLayout); +} + const CSSValue* Display::CSSValueFromComputedStyleInternal( const ComputedStyle& style, const SVGComputedStyle&, const LayoutObject*, Node*, bool allow_visited_style) const { + if (style.IsDisplayLayoutCustomBox()) { + return cssvalue::CSSLayoutFunctionValue::Create( + CSSCustomIdentValue::Create(style.DisplayLayoutCustomName()), + style.IsDisplayInlineType()); + } + return CSSIdentifierValue::Create(style.Display()); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/FontVariationSettingsCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/FontVariationSettingsCustom.cpp index cb074de8d1..55fe366880 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/FontVariationSettingsCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/FontVariationSettingsCustom.cpp @@ -14,7 +14,8 @@ namespace blink { namespace { -CSSFontVariationValue* ConsumeFontVariationTag(CSSParserTokenRange& range) { +cssvalue::CSSFontVariationValue* ConsumeFontVariationTag( + CSSParserTokenRange& range) { // Feature tag name consists of 4-letter characters. static const unsigned kTagNameLength = 4; @@ -36,7 +37,8 @@ CSSFontVariationValue* ConsumeFontVariationTag(CSSParserTokenRange& range) { double tag_value = 0; if (!CSSPropertyParserHelpers::ConsumeNumberRaw(range, tag_value)) return nullptr; - return CSSFontVariationValue::Create(tag, clampTo(tag_value)); + return cssvalue::CSSFontVariationValue::Create(tag, + clampTo(tag_value)); } } // namespace @@ -46,12 +48,11 @@ const CSSValue* FontVariationSettings::ParseSingleValue( CSSParserTokenRange& range, const CSSParserContext& context, const CSSParserLocalContext&) const { - DCHECK(RuntimeEnabledFeatures::CSSVariableFontsEnabled()); if (range.Peek().Id() == CSSValueNormal) return CSSPropertyParserHelpers::ConsumeIdent(range); CSSValueList* variation_settings = CSSValueList::CreateCommaSeparated(); do { - CSSFontVariationValue* font_variation_value = + cssvalue::CSSFontVariationValue* font_variation_value = ConsumeFontVariationTag(range); if (!font_variation_value) return nullptr; @@ -66,7 +67,6 @@ const CSSValue* FontVariationSettings::CSSValueFromComputedStyleInternal( const LayoutObject*, Node* styled_node, bool allow_visited_style) const { - DCHECK(RuntimeEnabledFeatures::CSSVariableFontsEnabled()); const blink::FontVariationSettings* variation_settings = style.GetFontDescription().VariationSettings(); if (!variation_settings || !variation_settings->size()) @@ -74,8 +74,9 @@ const CSSValue* FontVariationSettings::CSSValueFromComputedStyleInternal( CSSValueList* list = CSSValueList::CreateCommaSeparated(); for (unsigned i = 0; i < variation_settings->size(); ++i) { const FontVariationAxis& variation_axis = variation_settings->at(i); - CSSFontVariationValue* variation_value = CSSFontVariationValue::Create( - variation_axis.Tag(), variation_axis.Value()); + cssvalue::CSSFontVariationValue* variation_value = + cssvalue::CSSFontVariationValue::Create(variation_axis.Tag(), + variation_axis.Value()); list->Append(*variation_value); } return list; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifyContentCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifyContentCustom.cpp index b7094fe5dc..5230491d76 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifyContentCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifyContentCustom.cpp @@ -15,7 +15,13 @@ const CSSValue* JustifyContent::ParseSingleValue( CSSParserTokenRange& range, const CSSParserContext& context, const CSSParserLocalContext&) const { - return CSSParsingUtils::ConsumeContentDistributionOverflowPosition(range); + // justify-content property does not allow the values. + if (CSSPropertyParserHelpers::IdentMatches( + range.Peek().Id())) + return nullptr; + return CSSParsingUtils::ConsumeContentDistributionOverflowPosition( + range, CSSParsingUtils::IsContentPositionOrLeftOrRightKeyword); } const CSSValue* JustifyContent::CSSValueFromComputedStyleInternal( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifyItemsCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifyItemsCustom.cpp index 8dad0bb0b9..375e822b79 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifyItemsCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifyItemsCustom.cpp @@ -8,6 +8,7 @@ #include "core/css/parser/CSSPropertyParserHelpers.h" #include "core/css/properties/CSSParsingUtils.h" #include "core/css/properties/ComputedStyleUtils.h" +#include "core/frame/WebFeature.h" #include "core/style/ComputedStyle.h" namespace blink { @@ -18,6 +19,9 @@ const CSSValue* JustifyItems::ParseSingleValue( const CSSParserContext& context, const CSSParserLocalContext&) const { CSSParserTokenRange range_copy = range; + // justify-items property does not allow the 'auto' value. + if (CSSPropertyParserHelpers::IdentMatches(range.Peek().Id())) + return nullptr; CSSIdentifierValue* legacy = CSSPropertyParserHelpers::ConsumeIdent(range_copy); CSSIdentifierValue* position_keyword = @@ -25,12 +29,18 @@ const CSSValue* JustifyItems::ParseSingleValue( CSSValueRight>(range_copy); if (!legacy) legacy = CSSPropertyParserHelpers::ConsumeIdent(range_copy); - if (legacy && position_keyword) { + if (legacy) { range = range_copy; - return CSSValuePair::Create(legacy, position_keyword, - CSSValuePair::kDropIdenticalValues); + if (position_keyword) { + context.Count(WebFeature::kCSSLegacyAlignment); + return CSSValuePair::Create(legacy, position_keyword, + CSSValuePair::kDropIdenticalValues); + } + return legacy; } - return CSSParsingUtils::ConsumeSelfPositionOverflowPosition(range); + + return CSSParsingUtils::ConsumeSelfPositionOverflowPosition( + range, CSSParsingUtils::IsSelfPositionOrLeftOrRightKeyword); } const CSSValue* JustifyItems::CSSValueFromComputedStyleInternal( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifySelfCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifySelfCustom.cpp index b3a1253acc..2b27cab54d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifySelfCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/JustifySelfCustom.cpp @@ -15,7 +15,8 @@ const CSSValue* JustifySelf::ParseSingleValue( CSSParserTokenRange& range, const CSSParserContext& context, const CSSParserLocalContext&) const { - return CSSParsingUtils::ConsumeSelfPositionOverflowPosition(range); + return CSSParsingUtils::ConsumeSelfPositionOverflowPosition( + range, CSSParsingUtils::IsSelfPositionOrLeftOrRightKeyword); } const CSSValue* JustifySelf::CSSValueFromComputedStyleInternal( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/RotateCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/RotateCustom.cpp index a481885ef5..8dec3ffca6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/RotateCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/RotateCustom.cpp @@ -24,21 +24,53 @@ const CSSValue* Rotate::ParseSingleValue(CSSParserTokenRange& range, CSSValueList* list = CSSValueList::CreateSpaceSeparated(); - for (unsigned i = 0; i < 3; i++) { // 3 dimensions of rotation - CSSValue* dimension = - CSSPropertyParserHelpers::ConsumeNumber(range, kValueRangeAll); - if (!dimension) { - if (i == 0) - break; - return nullptr; + CSSValue* rotation = CSSPropertyParserHelpers::ConsumeAngle( + range, &context, WTF::Optional()); + + CSSValueID axis_id = range.Peek().Id(); + if (axis_id == CSSValueX) { + CSSPropertyParserHelpers::ConsumeIdent(range); + list->Append( + *CSSPrimitiveValue::Create(1, CSSPrimitiveValue::UnitType::kNumber)); + list->Append( + *CSSPrimitiveValue::Create(0, CSSPrimitiveValue::UnitType::kNumber)); + list->Append( + *CSSPrimitiveValue::Create(0, CSSPrimitiveValue::UnitType::kNumber)); + } else if (axis_id == CSSValueY) { + CSSPropertyParserHelpers::ConsumeIdent(range); + list->Append( + *CSSPrimitiveValue::Create(0, CSSPrimitiveValue::UnitType::kNumber)); + list->Append( + *CSSPrimitiveValue::Create(1, CSSPrimitiveValue::UnitType::kNumber)); + list->Append( + *CSSPrimitiveValue::Create(0, CSSPrimitiveValue::UnitType::kNumber)); + } else if (axis_id == CSSValueZ) { + CSSPropertyParserHelpers::ConsumeIdent(range); + list->Append( + *CSSPrimitiveValue::Create(0, CSSPrimitiveValue::UnitType::kNumber)); + list->Append( + *CSSPrimitiveValue::Create(0, CSSPrimitiveValue::UnitType::kNumber)); + list->Append( + *CSSPrimitiveValue::Create(1, CSSPrimitiveValue::UnitType::kNumber)); + } else { + for (unsigned i = 0; i < 3; i++) { // 3 dimensions of rotation + CSSValue* dimension = + CSSPropertyParserHelpers::ConsumeNumber(range, kValueRangeAll); + if (!dimension) { + if (i == 0) + break; + return nullptr; + } + list->Append(*dimension); } - list->Append(*dimension); } - CSSValue* rotation = CSSPropertyParserHelpers::ConsumeAngle( - range, &context, WTF::Optional()); - if (!rotation) - return nullptr; + if (!rotation) { + rotation = CSSPropertyParserHelpers::ConsumeAngle( + range, &context, WTF::Optional()); + if (!rotation) + return nullptr; + } list->Append(*rotation); return list; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/RowGapCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/RowGapCustom.cpp new file mode 100644 index 0000000000..1054f83e70 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/RowGapCustom.cpp @@ -0,0 +1,32 @@ +// Copyright 2018 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 "core/css/properties/longhands/RowGap.h" + +#include "core/css/parser/CSSParserContext.h" +#include "core/css/parser/CSSPropertyParserHelpers.h" +#include "core/css/properties/CSSParsingUtils.h" +#include "core/css/properties/ComputedStyleUtils.h" +#include "core/style/ComputedStyle.h" + +namespace blink { +namespace CSSLonghand { + +const CSSValue* RowGap::ParseSingleValue(CSSParserTokenRange& range, + const CSSParserContext& context, + const CSSParserLocalContext&) const { + return CSSParsingUtils::ConsumeGapLength(range, context); +} + +const CSSValue* RowGap::CSSValueFromComputedStyleInternal( + const ComputedStyle& style, + const SVGComputedStyle&, + const LayoutObject*, + Node*, + bool) const { + return ComputedStyleUtils::ValueForGapLength(style.RowGap(), style); +} + +} // namespace CSSLonghand +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/ScaleCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/ScaleCustom.cpp index 0b39c90a2c..e13f03ec14 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/ScaleCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/ScaleCustom.cpp @@ -49,8 +49,6 @@ const CSSValue* Scale::CSSValueFromComputedStyleInternal( CSSValueList* list = CSSValueList::CreateSpaceSeparated(); list->Append(*CSSPrimitiveValue::Create( style.Scale()->X(), CSSPrimitiveValue::UnitType::kNumber)); - if (style.Scale()->Y() == 1 && style.Scale()->Z() == 1) - return list; list->Append(*CSSPrimitiveValue::Create( style.Scale()->Y(), CSSPrimitiveValue::UnitType::kNumber)); if (style.Scale()->Z() != 1) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/ScrollCustomizationCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/ScrollCustomizationCustom.cpp new file mode 100644 index 0000000000..ca81dd2f1c --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/ScrollCustomizationCustom.cpp @@ -0,0 +1,73 @@ +// Copyright 2018 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 "core/css/properties/longhands/ScrollCustomization.h" + +#include "core/css/CSSValueList.h" +#include "core/css/parser/CSSPropertyParserHelpers.h" +#include "core/css/properties/ComputedStyleUtils.h" +#include "core/style/ComputedStyle.h" + +class CSSParserLocalContext; +namespace blink { + +namespace { + +static bool ConsumePan(CSSParserTokenRange& range, + CSSValue** pan_x, + CSSValue** pan_y) { + CSSValueID id = range.Peek().Id(); + if ((id == CSSValuePanX || id == CSSValuePanRight || id == CSSValuePanLeft) && + !*pan_x) { + *pan_x = CSSPropertyParserHelpers::ConsumeIdent(range); + } else if ((id == CSSValuePanY || id == CSSValuePanDown || + id == CSSValuePanUp) && + !*pan_y) { + *pan_y = CSSPropertyParserHelpers::ConsumeIdent(range); + } else { + return false; + } + return true; +} + +} // namespace +namespace CSSLonghand { + +const CSSValue* ScrollCustomization::ParseSingleValue( + CSSParserTokenRange& range, + const CSSParserContext& context, + const CSSParserLocalContext&) const { + CSSValueList* list = CSSValueList::CreateSpaceSeparated(); + CSSValueID id = range.Peek().Id(); + if (id == CSSValueAuto || id == CSSValueNone) { + list->Append(*CSSPropertyParserHelpers::ConsumeIdent(range)); + return list; + } + + CSSValue* pan_x = nullptr; + CSSValue* pan_y = nullptr; + if (!ConsumePan(range, &pan_x, &pan_y)) + return nullptr; + if (!range.AtEnd() && !ConsumePan(range, &pan_x, &pan_y)) + return nullptr; + + if (pan_x) + list->Append(*pan_x); + if (pan_y) + list->Append(*pan_y); + return list; +} + +const CSSValue* ScrollCustomization::CSSValueFromComputedStyleInternal( + const ComputedStyle& style, + const SVGComputedStyle&, + const LayoutObject*, + Node*, + bool allow_visited_style) const { + return ComputedStyleUtils::ScrollCustomizationFlagsToCSSValue( + style.ScrollCustomization()); +} + +} // namespace CSSLonghand +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/TranslateCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/TranslateCustom.cpp index 52710945d7..4d5d54ac03 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/TranslateCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/TranslateCustom.cpp @@ -59,25 +59,12 @@ const CSSValue* Translate::CSSValueFromComputedStyleInternal( return CSSIdentifierValue::Create(CSSValueNone); CSSValueList* list = CSSValueList::CreateSpaceSeparated(); - if (layout_object && layout_object->IsBox()) { - LayoutRect box = ToLayoutBox(layout_object)->BorderBoxRect(); - list->Append(*ZoomAdjustedPixelValue( - FloatValueForLength(style.Translate()->X(), box.Width().ToFloat()), - style)); - if (!style.Translate()->Y().IsZero() || style.Translate()->Z() != 0) { - list->Append(*ZoomAdjustedPixelValue( - FloatValueForLength(style.Translate()->Y(), box.Height().ToFloat()), - style)); - } - } else { - // No box to resolve the percentage values - list->Append(*ComputedStyleUtils::ZoomAdjustedPixelValueForLength( - style.Translate()->X(), style)); + list->Append(*ComputedStyleUtils::ZoomAdjustedPixelValueForLength( + style.Translate()->X(), style)); - if (!style.Translate()->Y().IsZero() || style.Translate()->Z() != 0) { - list->Append(*ComputedStyleUtils::ZoomAdjustedPixelValueForLength( - style.Translate()->Y(), style)); - } + if (!style.Translate()->Y().IsZero() || style.Translate()->Z() != 0) { + list->Append(*ComputedStyleUtils::ZoomAdjustedPixelValueForLength( + style.Translate()->Y(), style)); } if (style.Translate()->Z() != 0) diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/WebkitBoxReflectCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/WebkitBoxReflectCustom.cpp index 52d349e832..d6259d27b6 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/WebkitBoxReflectCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/WebkitBoxReflectCustom.cpp @@ -39,7 +39,7 @@ CSSValue* ConsumeReflect(CSSParserTokenRange& range, if (!mask) return nullptr; } - return CSSReflectValue::Create(direction, offset, mask); + return cssvalue::CSSReflectValue::Create(direction, offset, mask); } } // namespace diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/WebkitTextEmphasisStyleCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/WebkitTextEmphasisStyleCustom.cpp index ef6ff4c881..d2c6fd5918 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/WebkitTextEmphasisStyleCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/longhands/WebkitTextEmphasisStyleCustom.cpp @@ -63,7 +63,7 @@ const CSSValue* WebkitTextEmphasisStyle::CSSValueFromComputedStyleInternal( return CSSStringValue::Create(style.TextEmphasisCustomMark()); case TextEmphasisMark::kAuto: NOTREACHED(); - // Fall through + FALLTHROUGH; case TextEmphasisMark::kDot: case TextEmphasisMark::kCircle: case TextEmphasisMark::kDoubleCircle: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GapCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GapCustom.cpp new file mode 100644 index 0000000000..f70ee5dbb0 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GapCustom.cpp @@ -0,0 +1,48 @@ +// Copyright 2018 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 "core/css/properties/shorthands/Gap.h" + +#include "core/StylePropertyShorthand.h" +#include "core/css/parser/CSSParserContext.h" +#include "core/css/parser/CSSPropertyParserHelpers.h" +#include "core/css/properties/CSSParsingUtils.h" +#include "core/css/properties/ComputedStyleUtils.h" + +namespace blink { +namespace CSSShorthand { + +bool Gap::ParseShorthand(bool important, + CSSParserTokenRange& range, + const CSSParserContext& context, + const CSSParserLocalContext&, + HeapVector& properties) const { + DCHECK_EQ(shorthandForProperty(CSSPropertyGap).length(), 2u); + CSSValue* row_gap = CSSParsingUtils::ConsumeGapLength(range, context); + CSSValue* column_gap = CSSParsingUtils::ConsumeGapLength(range, context); + if (!row_gap || !range.AtEnd()) + return false; + if (!column_gap) + column_gap = row_gap; + CSSPropertyParserHelpers::AddProperty( + CSSPropertyRowGap, CSSPropertyGap, *row_gap, important, + CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties); + CSSPropertyParserHelpers::AddProperty( + CSSPropertyColumnGap, CSSPropertyGap, *column_gap, important, + CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties); + return true; +} + +const CSSValue* Gap::CSSValueFromComputedStyleInternal( + const ComputedStyle& style, + const SVGComputedStyle&, + const LayoutObject* layout_object, + Node* styled_node, + bool allow_visited_style) const { + return ComputedStyleUtils::ValuesForShorthandProperty( + gapShorthand(), style, layout_object, styled_node, allow_visited_style); +} + +} // namespace CSSShorthand +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GridColumnGapCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GridColumnGapCustom.cpp new file mode 100644 index 0000000000..90a2454421 --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GridColumnGapCustom.cpp @@ -0,0 +1,43 @@ +// Copyright 2018 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 "core/css/properties/shorthands/GridColumnGap.h" + +#include "core/StylePropertyShorthand.h" +#include "core/css/parser/CSSPropertyParserHelpers.h" +#include "core/css/properties/CSSParsingUtils.h" +#include "core/css/properties/ComputedStyleUtils.h" + +namespace blink { +namespace CSSShorthand { + +bool GridColumnGap::ParseShorthand( + bool important, + CSSParserTokenRange& range, + const CSSParserContext& context, + const CSSParserLocalContext&, + HeapVector& properties) const { + CSSValue* gap_length = CSSParsingUtils::ConsumeGapLength(range, context); + if (!gap_length || !range.AtEnd()) + return false; + + CSSPropertyParserHelpers::AddProperty( + CSSPropertyColumnGap, CSSPropertyGridColumnGap, *gap_length, important, + CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties); + return true; +} + +const CSSValue* GridColumnGap::CSSValueFromComputedStyleInternal( + const ComputedStyle& style, + const SVGComputedStyle&, + const LayoutObject* layout_object, + Node* styled_node, + bool allow_visited_style) const { + return ComputedStyleUtils::ValuesForShorthandProperty( + gridColumnGapShorthand(), style, layout_object, styled_node, + allow_visited_style); +} + +} // namespace CSSShorthand +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GridGapCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GridGapCustom.cpp index 5ec1dfaab2..65f9af8d2c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GridGapCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GridGapCustom.cpp @@ -7,6 +7,7 @@ #include "core/StylePropertyShorthand.h" #include "core/css/parser/CSSParserContext.h" #include "core/css/parser/CSSPropertyParserHelpers.h" +#include "core/css/properties/CSSParsingUtils.h" #include "core/css/properties/ComputedStyleUtils.h" #include "core/style/ComputedStyle.h" @@ -20,19 +21,17 @@ bool GridGap::ParseShorthand( const CSSParserLocalContext&, HeapVector& properties) const { DCHECK_EQ(shorthandForProperty(CSSPropertyGridGap).length(), 2u); - CSSValue* row_gap = CSSPropertyParserHelpers::ConsumeLengthOrPercent( - range, context.Mode(), kValueRangeNonNegative); - CSSValue* column_gap = CSSPropertyParserHelpers::ConsumeLengthOrPercent( - range, context.Mode(), kValueRangeNonNegative); + CSSValue* row_gap = CSSParsingUtils::ConsumeGapLength(range, context); + CSSValue* column_gap = CSSParsingUtils::ConsumeGapLength(range, context); if (!row_gap || !range.AtEnd()) return false; if (!column_gap) column_gap = row_gap; CSSPropertyParserHelpers::AddProperty( - CSSPropertyGridRowGap, CSSPropertyGridGap, *row_gap, important, + CSSPropertyRowGap, CSSPropertyGap, *row_gap, important, CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties); CSSPropertyParserHelpers::AddProperty( - CSSPropertyGridColumnGap, CSSPropertyGridGap, *column_gap, important, + CSSPropertyColumnGap, CSSPropertyGap, *column_gap, important, CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties); return true; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GridRowGapCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GridRowGapCustom.cpp new file mode 100644 index 0000000000..9122c3283a --- /dev/null +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/GridRowGapCustom.cpp @@ -0,0 +1,43 @@ +// Copyright 2018 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 "core/css/properties/shorthands/GridRowGap.h" + +#include "core/StylePropertyShorthand.h" +#include "core/css/parser/CSSPropertyParserHelpers.h" +#include "core/css/properties/CSSParsingUtils.h" +#include "core/css/properties/ComputedStyleUtils.h" + +namespace blink { +namespace CSSShorthand { + +bool GridRowGap::ParseShorthand( + bool important, + CSSParserTokenRange& range, + const CSSParserContext& context, + const CSSParserLocalContext&, + HeapVector& properties) const { + CSSValue* gap_length = CSSParsingUtils::ConsumeGapLength(range, context); + if (!gap_length || !range.AtEnd()) + return false; + + CSSPropertyParserHelpers::AddProperty( + CSSPropertyRowGap, CSSPropertyGridRowGap, *gap_length, important, + CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties); + return true; +} + +const CSSValue* GridRowGap::CSSValueFromComputedStyleInternal( + const ComputedStyle& style, + const SVGComputedStyle&, + const LayoutObject* layout_object, + Node* styled_node, + bool allow_visited_style) const { + return ComputedStyleUtils::ValuesForShorthandProperty( + gridRowGapShorthand(), style, layout_object, styled_node, + allow_visited_style); +} + +} // namespace CSSShorthand +} // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/PlaceItemsCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/PlaceItemsCustom.cpp index d661c76c75..ac01502a5a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/PlaceItemsCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/PlaceItemsCustom.cpp @@ -21,14 +21,10 @@ bool PlaceItems::ParseShorthand( HeapVector& properties) const { DCHECK_EQ(shorthandForProperty(CSSPropertyPlaceItems).length(), 2u); - // align-items property does not allow the 'auto' value. - if (CSSPropertyParserHelpers::IdentMatches(range.Peek().Id())) - return false; - CSSValue* align_items_value = nullptr; CSSValue* justify_items_value = nullptr; if (!CSSParsingUtils::ConsumePlaceAlignment( - range, CSSParsingUtils::ConsumeSimplifiedItemPosition, + range, CSSParsingUtils::ConsumeSimplifiedDefaultPosition, align_items_value, justify_items_value)) return false; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/PlaceSelfCustom.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/PlaceSelfCustom.cpp index 534d75b4bb..8b7dc65c94 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/PlaceSelfCustom.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/properties/shorthands/PlaceSelfCustom.cpp @@ -23,11 +23,11 @@ bool PlaceSelf::ParseShorthand( CSSValue* align_self_value = nullptr; CSSValue* justify_self_value = nullptr; - if (!CSSParsingUtils::ConsumePlaceAlignment( - range, CSSParsingUtils::ConsumeSimplifiedItemPosition, - align_self_value, justify_self_value)) + range, CSSParsingUtils::ConsumeSimplifiedSelfPosition, + align_self_value, justify_self_value)) { return false; + } DCHECK(align_self_value); DCHECK(justify_self_value); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.cpp index 0b18cb75dd..b3ae0b7cf5 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/CSSToStyleMap.cpp @@ -458,8 +458,8 @@ scoped_refptr CSSToStyleMap::MapAnimationTimingFunction( } if (value.IsCubicBezierTimingFunctionValue()) { - const CSSCubicBezierTimingFunctionValue& cubic_timing_function = - ToCSSCubicBezierTimingFunctionValue(value); + const cssvalue::CSSCubicBezierTimingFunctionValue& cubic_timing_function = + cssvalue::ToCSSCubicBezierTimingFunctionValue(value); return CubicBezierTimingFunction::Create( cubic_timing_function.X1(), cubic_timing_function.Y1(), cubic_timing_function.X2(), cubic_timing_function.Y2()); @@ -469,14 +469,14 @@ scoped_refptr CSSToStyleMap::MapAnimationTimingFunction( return CSSTimingData::InitialTimingFunction(); if (value.IsFramesTimingFunctionValue()) { - const CSSFramesTimingFunctionValue& frames_timing_function = - ToCSSFramesTimingFunctionValue(value); + const cssvalue::CSSFramesTimingFunctionValue& frames_timing_function = + cssvalue::ToCSSFramesTimingFunctionValue(value); return FramesTimingFunction::Create( frames_timing_function.NumberOfFrames()); } - const CSSStepsTimingFunctionValue& steps_timing_function = - ToCSSStepsTimingFunctionValue(value); + const cssvalue::CSSStepsTimingFunctionValue& steps_timing_function = + cssvalue::ToCSSStepsTimingFunctionValue(value); if (steps_timing_function.GetStepPosition() == StepsTimingFunction::StepPosition::MIDDLE) { if (!allow_step_middle) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp index 468b0ce6e6..c22cfb5d3a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp @@ -219,12 +219,12 @@ const CSSValue* CSSVariableResolver::ResolveVariableReferences( if (!ResolveTokenRange(value.VariableDataValue()->Tokens(), disallow_animation_tainted, tokens, backing_strings, is_animation_tainted)) { - return CSSUnsetValue::Create(); + return cssvalue::CSSUnsetValue::Create(); } const CSSValue* result = CSSPropertyParser::ParseSingleValue(id, tokens, value.ParserContext()); if (!result) - return CSSUnsetValue::Create(); + return cssvalue::CSSUnsetValue::Create(); return result; } @@ -268,7 +268,7 @@ const CSSValue* CSSVariableResolver::ResolvePendingSubstitutions( if (value) return value; - return CSSUnsetValue::Create(); + return cssvalue::CSSUnsetValue::Create(); } scoped_refptr diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp index ddcac94047..48cad3f7dd 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/ElementStyleResources.cpp @@ -37,7 +37,6 @@ #include "core/style/StyleFetchedImageSet.h" #include "core/style/StyleGeneratedImage.h" #include "core/style/StyleImage.h" -#include "core/style/StyleInvalidImage.h" #include "core/style/StylePendingImage.h" #include "core/svg/SVGElementProxy.h" #include "platform/Length.h" @@ -116,15 +115,14 @@ void ElementStyleResources::LoadPendingSVGDocuments( } } -static bool ComputedStyleMayBeCSSSpriteBackgroundImage( - const ComputedStyle& style) { - // Simple heuristic to guess if CSS background image is used to create CSS - // sprites. For a legit background image it's very likely the X and the Y - // position will not be explicitly specifed. For CSS sprite image, +static bool BackgroundLayerMayBeSprite(const FillLayer& background_layer) { + // Simple heuristic to guess if a CSS background image layer is used to + // create CSS sprites. For a legit background image it's very likely the X + // and the Y position will not be explicitly specifed. For CSS sprite image, // background X or Y position will probably be specified. - const FillLayer& background = style.BackgroundLayers(); - return style.HasBackgroundImage() && - (background.PositionX().IsFixed() || background.PositionY().IsFixed()); + DCHECK(background_layer.GetImage()); + return background_layer.PositionX().IsFixed() || + background_layer.PositionY().IsFixed(); } StyleImage* ElementStyleResources::LoadPendingImage( @@ -187,7 +185,7 @@ void ElementStyleResources::LoadPendingImages(ComputedStyle* style) { background_layer->GetImage()->IsPendingImage()) { background_layer->SetImage(LoadPendingImage( style, ToStylePendingImage(background_layer->GetImage()), - ComputedStyleMayBeCSSSpriteBackgroundImage(*style) + BackgroundLayerMayBeSprite(*background_layer) ? FetchParameters::kDisallowPlaceholder : FetchParameters::kAllowPlaceholder)); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/FontBuilder.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/FontBuilder.cpp index d2f9a74634..1c15041448 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/FontBuilder.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/FontBuilder.cpp @@ -80,6 +80,7 @@ AtomicString FontBuilder::GenericFontFamilyName( switch (generic_family) { default: NOTREACHED(); + FALLTHROUGH; case FontDescription::kNoFamily: return AtomicString(); case FontDescription::kStandardFamily: diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.cpp index bf23296dfe..4f657cfd68 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.cpp @@ -66,7 +66,8 @@ const CachedMatchedProperties* MatchedPropertiesCache::Find( if (it == cache_.end()) return nullptr; CachedMatchedProperties* cache_item = it->value.Get(); - DCHECK(cache_item); + if (!cache_item) + return nullptr; size_t size = properties.size(); if (size != cache_item->matched_properties.size()) @@ -87,7 +88,7 @@ void MatchedPropertiesCache::Add(const ComputedStyle& style, const MatchedPropertiesVector& properties) { DCHECK(hash); Cache::AddResult add_result = cache_.insert(hash, nullptr); - if (add_result.is_new_entry) + if (add_result.is_new_entry || !add_result.stored_value->value) add_result.stored_value->value = new CachedMatchedProperties; CachedMatchedProperties* cache_item = add_result.stored_value->value.Get(); @@ -102,7 +103,8 @@ void MatchedPropertiesCache::Clear() { // destructors in the properties (e.g., ~FontFallbackList) expect that // the destructors are called promptly without relying on a GC timing. for (auto& cache_entry : cache_) { - cache_entry.value->Clear(); + if (cache_entry.value) + cache_entry.value->Clear(); } cache_.clear(); } @@ -111,7 +113,7 @@ void MatchedPropertiesCache::ClearViewportDependent() { Vector to_remove; for (const auto& cache_entry : cache_) { CachedMatchedProperties* cache_item = cache_entry.value.Get(); - if (cache_item->computed_style->HasViewportUnits()) + if (cache_item && cache_item->computed_style->HasViewportUnits()) to_remove.push_back(cache_entry.key); } cache_.RemoveAll(to_remove); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.h index abad69dd44..cd303d95de 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/MatchedPropertiesCache.h @@ -55,18 +55,30 @@ class CachedMatchedProperties final // entries in the MatchedPropertiesCache. struct CachedMatchedPropertiesHashTraits : HashTraits> { - static const WTF::WeakHandlingFlag kWeakHandlingFlag = - WTF::kWeakHandlingInCollections; + static const WTF::WeakHandlingFlag kWeakHandlingFlag = WTF::kWeakHandling; + + static bool IsAlive(Member& cached_properties) { + // Semantics see |CachedMatchedPropertiesHashTraits::TraceInCollection|. + if (cached_properties) { + for (const auto& matched_properties : + cached_properties->matched_properties) { + if (!ThreadHeap::IsHeapObjectAlive(matched_properties.properties)) { + return false; + } + } + } + return true; + } template static bool TraceInCollection( VisitorDispatcher visitor, Member& cached_properties, - WTF::ShouldWeakPointersBeMarkedStrongly strongify) { + WTF::WeakHandlingFlag weakness) { // Only honor the cache's weakness semantics if the collection is traced - // with WeakPointersActWeak. Otherwise just trace the cachedProperties - // strongly, ie. call trace on it. - if (cached_properties && strongify == WTF::kWeakPointersActWeak) { + // with |kWeakPointersActWeak|. Otherwise just trace the cachedProperties + // strongly, i.e., call trace on it. + if (cached_properties && weakness == WTF::kWeakHandling) { // A given cache entry is only kept alive if none of the MatchedProperties // in the CachedMatchedProperties value contain a dead "properties" field. // If there is a dead field the entire cache entry is removed. @@ -82,11 +94,7 @@ struct CachedMatchedPropertiesHashTraits } // At this point none of the entries in the matchedProperties vector // had a dead "properties" field so trace CachedMatchedProperties strongly. - // FIXME: traceInCollection is also called from WeakProcessing to check if - // the entry is dead. Avoid calling trace in that case by only calling - // trace when cachedProperties is not yet marked. - if (!ThreadHeap::IsHeapObjectAlive(cached_properties)) - visitor->Trace(cached_properties); + visitor->Trace(cached_properties); return false; } }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp index 8fa878d0b6..8df7231b0a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp @@ -114,7 +114,8 @@ void ScopedStyleResolver::CollectFeaturesTo( device_dependent_media_query_results_); for (auto sheet : author_style_sheets_) { - DCHECK(sheet->ownerNode()); + if (!RuntimeEnabledFeatures::ConstructableStylesheetsEnabled()) + DCHECK(sheet->ownerNode()); StyleSheetContents* contents = sheet->Contents(); if (contents->HasOneClient() || visited_shared_style_sheet_contents.insert(contents).is_new_entry) @@ -218,7 +219,8 @@ void ScopedStyleResolver::CollectMatchingAuthorRules( CascadeOrder cascade_order) { size_t sheet_index = 0; for (auto sheet : author_style_sheets_) { - DCHECK(sheet->ownerNode()); + if (!RuntimeEnabledFeatures::ConstructableStylesheetsEnabled()) + DCHECK(sheet->ownerNode()); MatchRequest match_request(&sheet->Contents()->GetRuleSet(), &scope_->RootNode(), sheet, sheet_index++); collector.CollectMatchingRules(match_request, cascade_order); @@ -230,7 +232,8 @@ void ScopedStyleResolver::CollectMatchingShadowHostRules( CascadeOrder cascade_order) { size_t sheet_index = 0; for (auto sheet : author_style_sheets_) { - DCHECK(sheet->ownerNode()); + if (!RuntimeEnabledFeatures::ConstructableStylesheetsEnabled()) + DCHECK(sheet->ownerNode()); MatchRequest match_request(&sheet->Contents()->GetRuleSet(), &scope_->RootNode(), sheet, sheet_index++); collector.CollectMatchingShadowHostRules(match_request, cascade_order); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp index ff449d33a9..f4e9898ed8 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp @@ -37,6 +37,7 @@ #include "core/dom/Document.h" #include "core/dom/Element.h" #include "core/dom/NodeComputedStyle.h" +#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrameView.h" #include "core/frame/Settings.h" #include "core/frame/UseCounter.h" @@ -49,12 +50,14 @@ #include "core/html/media/HTMLMediaElement.h" #include "core/html_names.h" #include "core/layout/LayoutObject.h" +#include "core/layout/LayoutReplaced.h" #include "core/layout/LayoutTheme.h" #include "core/style/ComputedStyle.h" #include "core/style/ComputedStyleConstants.h" #include "core/svg/SVGSVGElement.h" #include "core/svg_names.h" #include "platform/Length.h" +#include "platform/feature_policy/FeaturePolicy.h" #include "platform/runtime_enabled_features.h" #include "platform/transforms/TransformOperations.h" #include "platform/wtf/Assertions.h" @@ -76,6 +79,17 @@ TouchAction AdjustTouchActionForElement(TouchAction touch_action, return touch_action; } +// Returns true for elements that are either or image or "); - Element* script = GetDocument().createElement("script"); + Element* script = GetDocument().CreateRawElement(HTMLNames::scriptTag); script->setTextContent( "window.onunload = function() {" "document.querySelector('input').reportValidity(); };"); @@ -857,27 +857,6 @@ TEST_F(DocumentTest, SandboxDisablesAppCache) { EXPECT_TRUE(mock_web_host->without_manifest_was_called_); } -TEST_F(DocumentTest, SuboriginDisablesAppCache) { - ScopedSuboriginsForTest suborigins(true); - scoped_refptr origin = - SecurityOrigin::CreateFromString("https://test.com"); - Suborigin suborigin; - suborigin.SetName("foobar"); - origin->AddSuborigin(suborigin); - GetDocument().SetSecurityOrigin(origin); - GetDocument().SetURL(KURL("https://test.com/foobar/document")); - - ApplicationCacheHost* appcache_host = - GetDocument().Loader()->GetApplicationCacheHost(); - appcache_host->host_ = std::make_unique(); - appcache_host->SelectCacheWithManifest( - KURL("https://test.com/foobar/manifest")); - MockWebApplicationCacheHost* mock_web_host = - static_cast(appcache_host->host_.get()); - EXPECT_FALSE(mock_web_host->with_manifest_was_called_); - EXPECT_TRUE(mock_web_host->without_manifest_was_called_); -} - // Verifies that calling EnsurePaintLocationDataValidForNode cleans compositor // inputs only when necessary. We generally want to avoid cleaning the inputs, // as it is more expensive than just doing layout. @@ -945,6 +924,27 @@ TEST_F(DocumentTest, ViewportPropagationNoRecalc) { EXPECT_EQ(1, new_element_count - old_element_count); } +class InvalidatorObserver : public InterfaceInvalidator::Observer { + public: + void OnInvalidate() { ++invalidate_called_counter_; } + + int CountInvalidateCalled() const { return invalidate_called_counter_; } + + private: + int invalidate_called_counter_ = 0; +}; + +TEST_F(DocumentTest, InterfaceInvalidatorDestruction) { + InvalidatorObserver obs; + InterfaceInvalidator* invalidator = GetDocument().GetInterfaceInvalidator(); + invalidator->AddObserver(&obs); + EXPECT_EQ(obs.CountInvalidateCalled(), 0); + + GetDocument().Shutdown(); + EXPECT_FALSE(GetDocument().GetInterfaceInvalidator()); + EXPECT_EQ(1, obs.CountInvalidateCalled()); +} + typedef bool TestParamRootLayerScrolling; class ParameterizedDocumentTest : public ::testing::WithParamInterface, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentTiming.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentTiming.cpp index 5122accbde..c280301773 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentTiming.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentTiming.cpp @@ -27,36 +27,32 @@ void DocumentTiming::NotifyDocumentTimingChanged() { } void DocumentTiming::MarkDomLoading() { - dom_loading_ = CurrentTimeTicksInSeconds(); + dom_loading_ = CurrentTimeTicks(); TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing,rail", "domLoading", - TraceEvent::ToTraceTimestamp(dom_loading_), - "frame", GetFrame()); + dom_loading_, "frame", GetFrame()); NotifyDocumentTimingChanged(); } void DocumentTiming::MarkDomInteractive() { - dom_interactive_ = CurrentTimeTicksInSeconds(); - TRACE_EVENT_MARK_WITH_TIMESTAMP1( - "blink.user_timing,rail", "domInteractive", - TraceEvent::ToTraceTimestamp(dom_interactive_), "frame", GetFrame()); + dom_interactive_ = CurrentTimeTicks(); + TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing,rail", "domInteractive", + dom_interactive_, "frame", GetFrame()); NotifyDocumentTimingChanged(); } void DocumentTiming::MarkDomContentLoadedEventStart() { - dom_content_loaded_event_start_ = CurrentTimeTicksInSeconds(); + dom_content_loaded_event_start_ = CurrentTimeTicks(); TRACE_EVENT_MARK_WITH_TIMESTAMP1( "blink.user_timing,rail", "domContentLoadedEventStart", - TraceEvent::ToTraceTimestamp(dom_content_loaded_event_start_), "frame", - GetFrame()); + dom_content_loaded_event_start_, "frame", GetFrame()); NotifyDocumentTimingChanged(); } void DocumentTiming::MarkDomContentLoadedEventEnd() { - dom_content_loaded_event_end_ = CurrentTimeTicksInSeconds(); + dom_content_loaded_event_end_ = CurrentTimeTicks(); TRACE_EVENT_MARK_WITH_TIMESTAMP1( "blink.user_timing,rail", "domContentLoadedEventEnd", - TraceEvent::ToTraceTimestamp(dom_content_loaded_event_end_), "frame", - GetFrame()); + dom_content_loaded_event_end_, "frame", GetFrame()); InteractiveDetector* interactive_detector( InteractiveDetector::From(*document_)); if (interactive_detector) { @@ -66,18 +62,16 @@ void DocumentTiming::MarkDomContentLoadedEventEnd() { } void DocumentTiming::MarkDomComplete() { - dom_complete_ = CurrentTimeTicksInSeconds(); + dom_complete_ = CurrentTimeTicks(); TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing,rail", "domComplete", - TraceEvent::ToTraceTimestamp(dom_complete_), - "frame", GetFrame()); + dom_complete_, "frame", GetFrame()); NotifyDocumentTimingChanged(); } void DocumentTiming::MarkFirstLayout() { - first_layout_ = CurrentTimeTicksInSeconds(); + first_layout_ = CurrentTimeTicks(); TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing,rail", "firstLayout", - TraceEvent::ToTraceTimestamp(first_layout_), - "frame", GetFrame()); + first_layout_, "frame", GetFrame()); NotifyDocumentTimingChanged(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentTiming.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentTiming.h index c7236a74bf..0bbaa5e6f4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentTiming.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentTiming.h @@ -27,6 +27,7 @@ #define DocumentTiming_h #include "platform/heap/Handle.h" +#include "platform/wtf/Time.h" namespace blink { @@ -46,17 +47,17 @@ class DocumentTiming final { void MarkDomComplete(); void MarkFirstLayout(); - // These return monotonically-increasing seconds. - double DomLoading() const { return dom_loading_; } - double DomInteractive() const { return dom_interactive_; } - double DomContentLoadedEventStart() const { + // These return monotonically-increasing time. + TimeTicks DomLoading() const { return dom_loading_; } + TimeTicks DomInteractive() const { return dom_interactive_; } + TimeTicks DomContentLoadedEventStart() const { return dom_content_loaded_event_start_; } - double DomContentLoadedEventEnd() const { + TimeTicks DomContentLoadedEventEnd() const { return dom_content_loaded_event_end_; } - double DomComplete() const { return dom_complete_; } - double FirstLayout() const { return first_layout_; } + TimeTicks DomComplete() const { return dom_complete_; } + TimeTicks FirstLayout() const { return first_layout_; } void Trace(blink::Visitor*); @@ -64,12 +65,12 @@ class DocumentTiming final { LocalFrame* GetFrame() const; void NotifyDocumentTimingChanged(); - double dom_loading_ = 0.0; - double dom_interactive_ = 0.0; - double dom_content_loaded_event_start_ = 0.0; - double dom_content_loaded_event_end_ = 0.0; - double dom_complete_ = 0.0; - double first_layout_ = 0.0; + TimeTicks dom_loading_; + TimeTicks dom_interactive_; + TimeTicks dom_content_loaded_event_start_; + TimeTicks dom_content_loaded_event_end_; + TimeTicks dom_complete_; + TimeTicks first_layout_; Member document_; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentType.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentType.cpp index 986ef76141..45b37d8936 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentType.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentType.cpp @@ -44,8 +44,8 @@ Node::NodeType DocumentType::getNodeType() const { return kDocumentTypeNode; } -Node* DocumentType::cloneNode(bool /*deep*/, ExceptionState&) { - return Create(&GetDocument(), name_, public_id_, system_id_); +Node* DocumentType::Clone(Document& factory, CloneChildrenFlag) const { + return Create(&factory, name_, public_id_, system_id_); } Node::InsertionNotificationRequest DocumentType::InsertedInto( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentType.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentType.h index a2b76431e4..259f5102e3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentType.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/DocumentType.h @@ -51,7 +51,7 @@ class DocumentType final : public Node { String nodeName() const override; NodeType getNodeType() const override; - Node* cloneNode(bool deep, ExceptionState&) override; + Node* Clone(Document&, CloneChildrenFlag) const override; InsertionNotificationRequest InsertedInto(ContainerNode*) override; void RemovedFrom(ContainerNode*) override; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.cpp index daeae0792b..2fb906d8ae 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.cpp @@ -27,6 +27,7 @@ #include "core/dom/Element.h" #include + #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionMessages.h" #include "bindings/core/v8/ExceptionState.h" @@ -124,22 +125,25 @@ #include "core/layout/AdjustForAbsoluteZoom.h" #include "core/layout/LayoutTextFragment.h" #include "core/layout/LayoutView.h" +#include "core/layout/svg/SVGResources.h" +#include "core/loader/DocumentLoader.h" #include "core/page/ChromeClient.h" #include "core/page/FocusController.h" #include "core/page/Page.h" #include "core/page/PointerLockController.h" #include "core/page/SpatialNavigation.h" #include "core/page/scrolling/RootScrollerController.h" +#include "core/page/scrolling/RootScrollerUtil.h" #include "core/page/scrolling/ScrollCustomizationCallbacks.h" #include "core/page/scrolling/ScrollState.h" #include "core/page/scrolling/ScrollStateCallback.h" +#include "core/page/scrolling/SnapCoordinator.h" #include "core/page/scrolling/TopDocumentRootScrollerController.h" #include "core/paint/PaintLayer.h" #include "core/probe/CoreProbes.h" #include "core/resize_observer/ResizeObservation.h" #include "core/svg/SVGAElement.h" #include "core/svg/SVGElement.h" -#include "core/svg/SVGTreeScopeResources.h" #include "core/svg_names.h" #include "core/xml_names.h" #include "platform/EventDispatchForbiddenScope.h" @@ -239,7 +243,7 @@ int Element::tabIndex() const { : 0; } -bool Element::LayoutObjectIsFocusable() const { +bool Element::IsFocusableStyle() const { // Elements in canvas fallback content are not rendered, but they are allowed // to be focusable as long as their canvas is displayed and visible. if (IsInCanvasSubtree()) { @@ -258,28 +262,39 @@ bool Element::LayoutObjectIsFocusable() const { GetLayoutObject()->Style()->Visibility() == EVisibility::kVisible; } -Node* Element::cloneNode(bool deep, ExceptionState&) { - return deep ? CloneElementWithChildren() : CloneElementWithoutChildren(); +Node* Element::Clone(Document& factory, CloneChildrenFlag flag) const { + return flag == CloneChildrenFlag::kClone ? CloneWithChildren(&factory) + : CloneWithoutChildren(&factory); } -Element* Element::CloneElementWithChildren() { - Element* clone = CloneElementWithoutChildren(); - CloneChildNodes(clone); +Element* Element::CloneWithChildren(Document* nullable_factory) const { + Element* clone = CloneWithoutAttributesAndChildren( + nullable_factory ? *nullable_factory : GetDocument()); + // This will catch HTML elements in the wrong namespace that are not correctly + // copied. This is a sanity check as HTML overloads some of the DOM methods. + DCHECK_EQ(IsHTMLElement(), clone->IsHTMLElement()); + + clone->CloneAttributesFrom(*this); + clone->CloneNonAttributePropertiesFrom(*this, CloneChildrenFlag::kClone); + clone->CloneChildNodesFrom(*this); return clone; } -Element* Element::CloneElementWithoutChildren() { - Element* clone = CloneElementWithoutAttributesAndChildren(); +Element* Element::CloneWithoutChildren(Document* nullable_factory) const { + Element* clone = CloneWithoutAttributesAndChildren( + nullable_factory ? *nullable_factory : GetDocument()); // This will catch HTML elements in the wrong namespace that are not correctly // copied. This is a sanity check as HTML overloads some of the DOM methods. DCHECK_EQ(IsHTMLElement(), clone->IsHTMLElement()); - clone->CloneDataFromElement(*this); + clone->CloneAttributesFrom(*this); + clone->CloneNonAttributePropertiesFrom(*this, CloneChildrenFlag::kSkip); return clone; } -Element* Element::CloneElementWithoutAttributesAndChildren() { - return GetDocument().createElement(TagQName(), kCreatedByCloneNode); +Element* Element::CloneWithoutAttributesAndChildren(Document& factory) const { + return factory.CreateElement(TagQName(), CreateElementFlags::ByCloneNode(), + IsValue()); } Attr* Element::DetachAttribute(size_t index) { @@ -518,6 +533,12 @@ void Element::scrollIntoViewWithOptions(const ScrollIntoViewOptions& options) { if (!GetLayoutObject() || !GetDocument().GetPage()) return; + // TODO(810510): Move this logic inside "ScrollableArea::SetScrollOffset" and + // rely on ScrollType to detect js scrolls and set the flag. This requires + // adding new scroll type to enable this. + if (GetDocument().Loader()) + GetDocument().Loader()->GetInitialScrollState().was_scrolled_by_js = true; + ScrollBehavior behavior = (options.behavior() == "smooth") ? kScrollBehaviorSmooth : kScrollBehaviorAuto; @@ -529,7 +550,7 @@ void Element::scrollIntoViewWithOptions(const ScrollIntoViewOptions& options) { ScrollAlignment align_y = ToPhysicalAlignment(options, kVerticalScroll, is_horizontal_writing_mode); - LayoutRect bounds = BoundingBox(); + LayoutRect bounds = BoundingBoxForScrollIntoView(); GetLayoutObject()->ScrollRectToVisible( bounds, {align_x, align_y, kProgrammaticScroll, false, behavior}); @@ -542,7 +563,13 @@ void Element::scrollIntoViewIfNeeded(bool center_if_needed) { if (!GetLayoutObject()) return; - LayoutRect bounds = BoundingBox(); + // TODO(810510): Move this logic inside "ScrollableArea::SetScrollOffset" and + // rely on ScrollType to detect js scrolls and set the flag. This requires + // adding new scroll type to enable this. + if (GetDocument().Loader()) + GetDocument().Loader()->GetInitialScrollState().was_scrolled_by_js = true; + + LayoutRect bounds = BoundingBoxForScrollIntoView(); if (center_if_needed) { GetLayoutObject()->ScrollRectToVisible( bounds, @@ -556,18 +583,20 @@ void Element::scrollIntoViewIfNeeded(bool center_if_needed) { } } -void Element::setDistributeScroll(ScrollStateCallback* scroll_state_callback, - String native_scroll_behavior) { - scroll_state_callback->SetNativeScrollBehavior( - ScrollStateCallback::ToNativeScrollBehavior(native_scroll_behavior)); - GetScrollCustomizationCallbacks().SetDistributeScroll(this, - scroll_state_callback); +void Element::setDistributeScroll(V8ScrollStateCallback* scroll_state_callback, + const String& native_scroll_behavior) { + GetScrollCustomizationCallbacks().SetDistributeScroll( + this, ScrollStateCallbackV8Impl::Create(scroll_state_callback, + native_scroll_behavior)); +} + +void Element::setApplyScroll(V8ScrollStateCallback* scroll_state_callback, + const String& native_scroll_behavior) { + SetApplyScroll(ScrollStateCallbackV8Impl::Create(scroll_state_callback, + native_scroll_behavior)); } -void Element::setApplyScroll(ScrollStateCallback* scroll_state_callback, - String native_scroll_behavior) { - scroll_state_callback->SetNativeScrollBehavior( - ScrollStateCallback::ToNativeScrollBehavior(native_scroll_behavior)); +void Element::SetApplyScroll(ScrollStateCallback* scroll_state_callback) { GetScrollCustomizationCallbacks().SetApplyScroll(this, scroll_state_callback); } @@ -615,20 +644,25 @@ void Element::CallDistributeScroll(ScrollState& scroll_state) { ->GlobalRootScrollerController() .IsViewportScrollCallback(callback); + disable_custom_callbacks |= + !RootScrollerUtil::IsGlobal(this) && + RuntimeEnabledFeatures::ScrollCustomizationEnabled() && + !GetScrollCustomizationCallbacks().InScrollPhase(this); + if (!callback || disable_custom_callbacks) { NativeDistributeScroll(scroll_state); return; } if (callback->NativeScrollBehavior() != WebNativeScrollBehavior::kPerformAfterNativeScroll) - callback->handleEvent(&scroll_state); + callback->Invoke(&scroll_state); if (callback->NativeScrollBehavior() != WebNativeScrollBehavior::kDisableNativeScroll) NativeDistributeScroll(scroll_state); if (callback->NativeScrollBehavior() == WebNativeScrollBehavior::kPerformAfterNativeScroll) - callback->handleEvent(&scroll_state); -}; + callback->Invoke(&scroll_state); +} void Element::NativeApplyScroll(ScrollState& scroll_state) { // All elements in the scroll chain should be boxes. @@ -697,6 +731,10 @@ void Element::CallApplyScroll(ScrollState& scroll_state) { .GetPage() ->GlobalRootScrollerController() .IsViewportScrollCallback(callback); + disable_custom_callbacks |= + !RootScrollerUtil::IsGlobal(this) && + RuntimeEnabledFeatures::ScrollCustomizationEnabled() && + !GetScrollCustomizationCallbacks().InScrollPhase(this); if (!callback || disable_custom_callbacks) { NativeApplyScroll(scroll_state); @@ -704,13 +742,13 @@ void Element::CallApplyScroll(ScrollState& scroll_state) { } if (callback->NativeScrollBehavior() != WebNativeScrollBehavior::kPerformAfterNativeScroll) - callback->handleEvent(&scroll_state); + callback->Invoke(&scroll_state); if (callback->NativeScrollBehavior() != WebNativeScrollBehavior::kDisableNativeScroll) NativeApplyScroll(scroll_state); if (callback->NativeScrollBehavior() == WebNativeScrollBehavior::kPerformAfterNativeScroll) - callback->handleEvent(&scroll_state); + callback->Invoke(&scroll_state); } int Element::OffsetLeft() { @@ -901,13 +939,23 @@ void Element::setScrollLeft(double new_left) { new_left = ScrollableArea::NormalizeNonFiniteScroll(new_left); if (GetDocument().ScrollingElementNoLayout() == this) { - if (LocalDOMWindow* window = GetDocument().domWindow()) - window->scrollTo(new_left, window->scrollY()); + if (LocalDOMWindow* window = GetDocument().domWindow()) { + ScrollToOptions options; + options.setLeft(new_left); + window->scrollTo(options); + } } else { LayoutBox* box = GetLayoutBox(); - if (box) - box->SetScrollLeft( - LayoutUnit::FromFloatRound(new_left * box->Style()->EffectiveZoom())); + if (!box) + return; + + FloatPoint end_point(new_left * box->Style()->EffectiveZoom(), + box->ScrollTop().ToFloat()); + if (SnapCoordinator* coordinator = GetDocument().GetSnapCoordinator()) { + end_point = + coordinator->GetSnapPositionForPoint(*box, end_point, true, false); + } + box->SetScrollLeft(LayoutUnit::FromFloatRound(end_point.X())); } } @@ -920,13 +968,23 @@ void Element::setScrollTop(double new_top) { new_top = ScrollableArea::NormalizeNonFiniteScroll(new_top); if (GetDocument().ScrollingElementNoLayout() == this) { - if (LocalDOMWindow* window = GetDocument().domWindow()) - window->scrollTo(window->scrollX(), new_top); + if (LocalDOMWindow* window = GetDocument().domWindow()) { + ScrollToOptions options; + options.setTop(new_top); + window->scrollTo(options); + } } else { LayoutBox* box = GetLayoutBox(); - if (box) - box->SetScrollTop( - LayoutUnit::FromFloatRound(new_top * box->Style()->EffectiveZoom())); + if (!box) + return; + + FloatPoint end_point(box->ScrollLeft().ToFloat(), + new_top * box->Style()->EffectiveZoom()); + if (SnapCoordinator* coordinator = GetDocument().GetSnapCoordinator()) { + end_point = + coordinator->GetSnapPositionForPoint(*box, end_point, false, true); + } + box->SetScrollTop(LayoutUnit::FromFloatRound(end_point.Y())); } } @@ -1047,8 +1105,14 @@ void Element::ScrollLayoutBoxBy(const ScrollToOptions& scroll_to_options) { left * box->Style()->EffectiveZoom() + current_scaled_left; float new_scaled_top = top * box->Style()->EffectiveZoom() + current_scaled_top; - box->ScrollToPosition(FloatPoint(new_scaled_left, new_scaled_top), - scroll_behavior); + + FloatPoint new_scaled_position(new_scaled_left, new_scaled_top); + if (SnapCoordinator* coordinator = GetDocument().GetSnapCoordinator()) { + new_scaled_position = coordinator->GetSnapPositionForPoint( + *box, new_scaled_position, scroll_to_options.hasLeft(), + scroll_to_options.hasTop()); + } + box->ScrollToPosition(new_scaled_position, scroll_behavior); } } @@ -1069,7 +1133,14 @@ void Element::ScrollLayoutBoxTo(const ScrollToOptions& scroll_to_options) { scaled_top = ScrollableArea::NormalizeNonFiniteScroll(scroll_to_options.top()) * box->Style()->EffectiveZoom(); - box->ScrollToPosition(FloatPoint(scaled_left, scaled_top), scroll_behavior); + + FloatPoint new_scaled_position(scaled_left, scaled_top); + if (SnapCoordinator* coordinator = GetDocument().GetSnapCoordinator()) { + new_scaled_position = coordinator->GetSnapPositionForPoint( + *box, new_scaled_position, scroll_to_options.hasLeft(), + scroll_to_options.hasTop()); + } + box->ScrollToPosition(new_scaled_position, scroll_behavior); } } @@ -1094,12 +1165,26 @@ void Element::ScrollFrameBy(const ScrollToOptions& scroll_to_options) { if (!viewport) return; + // TODO(810510): Move this logic inside "ScrollableArea::SetScrollOffset" and + // rely on ScrollType to detect js scrolls and set the flag. This requires + // adding new scroll type to enable this. if (GetDocument().Loader()) + GetDocument().Loader()->GetInitialScrollState().was_scrolled_by_js = true; + float new_scaled_left = left * frame->PageZoomFactor() + viewport->GetScrollOffset().Width(); float new_scaled_top = top * frame->PageZoomFactor() + viewport->GetScrollOffset().Height(); - viewport->SetScrollOffset(ScrollOffset(new_scaled_left, new_scaled_top), - kProgrammaticScroll, scroll_behavior); + + FloatPoint new_scaled_position = ScrollOffsetToPosition( + ScrollOffset(new_scaled_left, new_scaled_top), viewport->ScrollOrigin()); + if (SnapCoordinator* coordinator = GetDocument().GetSnapCoordinator()) { + new_scaled_position = coordinator->GetSnapPositionForPoint( + *GetDocument().GetLayoutView(), new_scaled_position, + scroll_to_options.hasLeft(), scroll_to_options.hasTop()); + } + viewport->SetScrollOffset( + ScrollPositionToOffset(new_scaled_position, viewport->ScrollOrigin()), + kProgrammaticScroll, scroll_behavior); } void Element::ScrollFrameTo(const ScrollToOptions& scroll_to_options) { @@ -1114,6 +1199,12 @@ void Element::ScrollFrameTo(const ScrollToOptions& scroll_to_options) { if (!viewport) return; + // TODO(810510): Move this logic inside "ScrollableArea::SetScrollOffset" and + // rely on ScrollType to detect js scrolls and set the flag. This requires + // adding new scroll type to enable this. + if (GetDocument().Loader()) + GetDocument().Loader()->GetInitialScrollState().was_scrolled_by_js = true; + float scaled_left = viewport->GetScrollOffset().Width(); float scaled_top = viewport->GetScrollOffset().Height(); if (scroll_to_options.hasLeft()) @@ -1124,8 +1215,17 @@ void Element::ScrollFrameTo(const ScrollToOptions& scroll_to_options) { scaled_top = ScrollableArea::NormalizeNonFiniteScroll(scroll_to_options.top()) * frame->PageZoomFactor(); - viewport->SetScrollOffset(ScrollOffset(scaled_left, scaled_top), - kProgrammaticScroll, scroll_behavior); + + FloatPoint new_scaled_position = ScrollOffsetToPosition( + ScrollOffset(scaled_left, scaled_top), viewport->ScrollOrigin()); + if (SnapCoordinator* coordinator = GetDocument().GetSnapCoordinator()) { + new_scaled_position = coordinator->GetSnapPositionForPoint( + *GetDocument().GetLayoutView(), new_scaled_position, + scroll_to_options.hasLeft(), scroll_to_options.hasTop()); + } + viewport->SetScrollOffset( + ScrollPositionToOffset(new_scaled_position, viewport->ScrollOrigin()), + kProgrammaticScroll, scroll_behavior); } bool Element::HasNonEmptyLayoutSize() const { @@ -1279,14 +1379,6 @@ AccessibleNode* Element::accessibleNode() { return rare_data.EnsureAccessibleNode(this); } -ComputedAccessibleNode* Element::GetComputedAccessibleNode() { - if (!RuntimeEnabledFeatures::AccessibilityObjectModelEnabled()) - return nullptr; - - ElementRareData& rare_data = EnsureElementRareData(); - return rare_data.EnsureComputedAccessibleNode(this); -} - const AtomicString& Element::getAttribute( const AtomicString& local_name) const { if (!GetElementData()) @@ -1462,8 +1554,10 @@ void Element::AttributeChanged(const AttributeModificationParams& params) { InvalidateNodeListCachesInAncestors(&name, this, nullptr); if (isConnected()) { - if (AXObjectCache* cache = GetDocument().ExistingAXObjectCache()) - cache->HandleAttributeChanged(name, this); + if (AXObjectCache* cache = GetDocument().ExistingAXObjectCache()) { + if (params.old_value != params.new_value) + cache->HandleAttributeChanged(name, this); + } } if (params.reason == AttributeModificationReason::kDirectly && @@ -1487,16 +1581,6 @@ const QualifiedName& Element::SubResourceAttributeName() const { return QualifiedName::Null(); } -inline void Element::AttributeChangedFromParserOrByCloning( - const QualifiedName& name, - const AtomicString& new_value, - AttributeModificationReason reason) { - if (name == isAttr) - V0CustomElementRegistrationContext::SetTypeExtension(this, new_value); - AttributeChanged( - AttributeModificationParams(name, g_null_atom, new_value, reason)); -} - template static inline ClassStringContent ClassStringHasClassName( const CharacterType* characters, @@ -1653,9 +1737,9 @@ void Element::ParserSetAttributes(const Vector& attribute_vector) { // Use attributeVector instead of m_elementData because attributeChanged might // modify m_elementData. for (const auto& attribute : attribute_vector) { - AttributeChangedFromParserOrByCloning( - attribute.GetName(), attribute.Value(), - AttributeModificationReason::kByParser); + AttributeChanged(AttributeModificationParams( + attribute.GetName(), g_null_atom, attribute.Value(), + AttributeModificationReason::kByParser)); } } @@ -1794,11 +1878,8 @@ void Element::RemovedFrom(ContainerNode* insertion_point) { if (this == GetDocument().CssTarget()) GetDocument().SetCSSTarget(nullptr); - if (HasPendingResources()) { - GetTreeScope() - .EnsureSVGTreeScopedResources() - .RemoveElementFromPendingResources(*this); - } + if (HasPendingResources()) + SVGResources::RemoveWatchesForElement(*this); if (GetCustomElementState() == CustomElementState::kCustom) CustomElement::EnqueueDisconnectedCallback(this); @@ -1879,6 +1960,7 @@ void Element::AttachLayoutTree(AttachContext& context) { shadow->Attach(children_context); ContainerNode::AttachLayoutTree(children_context); + SetNonAttachedStyle(nullptr); AddCallbackSelectors(); CreateAndAttachPseudoElementIfNeeded(kPseudoIdAfter, children_context); @@ -2033,6 +2115,8 @@ void Element::RecalcStyle(StyleRecalcChange change) { if (ElementAnimations* element_animations = data->GetElementAnimations()) element_animations->SetAnimationStyleChange(false); + if (ComputedStyle* style = MutableComputedStyle()) + style->SetAnimationPropertiesLocked(false); } } if (ParentComputedStyle()) { @@ -2058,8 +2142,7 @@ void Element::RecalcStyle(StyleRecalcChange change) { UpdatePseudoElement(kPseudoIdBefore, change); if (change > kUpdatePseudoElements || ChildNeedsStyleRecalc()) { - for (ShadowRoot* root = YoungestShadowRoot(); root; - root = root->OlderShadowRoot()) { + if (ShadowRoot* root = GetShadowRoot()) { if (root->ShouldCallRecalcStyle(change)) root->RecalcStyle(change); } @@ -2158,24 +2241,21 @@ StyleRecalcChange Element::RecalcOwnStyle(StyleRecalcChange change) { if (local_change != kNoChange) UpdateCallbackSelectors(old_style.get(), new_style.get()); - if (LayoutObject* layout_object = this->GetLayoutObject()) { - if (local_change != kNoChange) { - layout_object->SetStyle(new_style.get()); - } else { - // Although no change occurred, we use the new style so that the cousin - // style sharing code won't get fooled into believing this style is the - // same. - // FIXME: We may be able to remove this hack, see discussion in - // https://codereview.chromium.org/30453002/ + if (LayoutObject* layout_object = GetLayoutObject()) { + // kNoChange may mean that the computed style didn't change, but there are + // additional flags in ComputedStyle which may have changed. For instance, + // the AffectedBy* flags. We don't need to go through the visual + // invalidation diffing in that case, but we replace the old ComputedStyle + // object with the new one to ensure the mentioned flags are up to date. + if (local_change == kNoChange) layout_object->SetStyleInternal(new_style.get()); - } + else + layout_object->SetStyle(new_style.get()); } else { - if (local_change != kNoChange) { - if (ShouldStoreNonLayoutObjectComputedStyle(*new_style)) - StoreNonLayoutObjectComputedStyle(new_style); - else if (HasRareData()) - GetElementRareData()->ClearComputedStyle(); - } + if (ShouldStoreNonLayoutObjectComputedStyle(*new_style)) + StoreNonLayoutObjectComputedStyle(new_style); + else if (HasRareData()) + GetElementRareData()->ClearComputedStyle(); } if (GetStyleChangeType() >= kSubtreeStyleChange) @@ -2199,13 +2279,23 @@ StyleRecalcChange Element::RecalcOwnStyle(StyleRecalcChange change) { } void Element::RecalcStyleForReattach() { - scoped_refptr non_attached_style = StyleForLayoutObject(); - SetNonAttachedStyle(non_attached_style); - SetNeedsReattachLayoutTree(); - if (LayoutObjectIsNeeded(*non_attached_style) || - ShouldStoreNonLayoutObjectComputedStyle(*non_attached_style)) { - RecalcShadowIncludingDescendantStylesForReattach(); + bool recalc_descendants = false; + if (ParentComputedStyle()) { + scoped_refptr non_attached_style = StyleForLayoutObject(); + SetNeedsReattachLayoutTree(); + SetNonAttachedStyle(non_attached_style); + recalc_descendants = + LayoutObjectIsNeeded(*non_attached_style) || + ShouldStoreNonLayoutObjectComputedStyle(*non_attached_style); + } else { + // Elements which cannot participate in the flat tree are and + // if SlotInFlatTree is not enabled. Even though we should not + // compute their styles for re-attachment, we may need to compute their + // children's style if fallback is rendered. + recalc_descendants = !CanParticipateInFlatTree(); } + if (recalc_descendants) + RecalcShadowIncludingDescendantStylesForReattach(); } void Element::RecalcShadowIncludingDescendantStylesForReattach() { @@ -2219,10 +2309,8 @@ void Element::RecalcShadowIncludingDescendantStylesForReattach() { } void Element::RecalcShadowRootStylesForReattach() { - for (ShadowRoot* root = YoungestShadowRoot(); root; - root = root->OlderShadowRoot()) { + if (ShadowRoot* root = GetShadowRoot()) root->RecalcStylesForReattach(); - } } void Element::RebuildLayoutTree(WhitespaceAttacher& whitespace_attacher) { @@ -2272,11 +2360,9 @@ void Element::RebuildLayoutTree(WhitespaceAttacher& whitespace_attacher) { void Element::RebuildShadowRootLayoutTree( WhitespaceAttacher& whitespace_attacher) { - DCHECK(Shadow()); - for (ShadowRoot* root = YoungestShadowRoot(); root; - root = root->OlderShadowRoot()) { - root->RebuildLayoutTree(whitespace_attacher); - } + DCHECK(IsShadowHost(this)); + ShadowRoot* root = GetShadowRoot(); + root->RebuildLayoutTree(whitespace_attacher); RebuildNonDistributedChildren(); } @@ -2345,6 +2431,8 @@ void Element::SetAnimationStyleChange(bool animation_style_change) { if (ElementAnimations* element_animations = GetElementRareData()->GetElementAnimations()) element_animations->SetAnimationStyleChange(animation_style_change); + if (ComputedStyle* style = MutableComputedStyle()) + style->SetAnimationPropertiesLocked(animation_style_change); } void Element::ClearAnimationStyleChange() { @@ -2353,6 +2441,8 @@ void Element::ClearAnimationStyleChange() { if (ElementAnimations* element_animations = GetElementRareData()->GetElementAnimations()) element_animations->SetAnimationStyleChange(false); + if (ComputedStyle* style = MutableComputedStyle()) + style->SetAnimationPropertiesLocked(false); } void Element::SetNeedsAnimationStyleRecalc() { @@ -2405,6 +2495,17 @@ CustomElementDefinition* Element::GetCustomElementDefinition() const { return nullptr; } +void Element::SetIsValue(const AtomicString& is_value) { + DCHECK(IsValue().IsNull()) << "SetIsValue() should be called at most once."; + EnsureElementRareData().SetIsValue(is_value); +} + +const AtomicString& Element::IsValue() const { + if (HasRareData()) + return GetElementRareData()->IsValue(); + return g_null_atom; +} + ShadowRoot* Element::createShadowRoot(const ScriptState* script_state, ExceptionState& exception_state) { HostsUsingFeatures::CountMainWorldOnly( @@ -2503,9 +2604,9 @@ ShadowRoot& Element::CreateShadowRootInternal() { return EnsureShadow().AddShadowRoot(*this, ShadowRootType::V0); } -ShadowRoot& Element::CreateUserAgentShadowRootV1() { +ShadowRoot& Element::CreateUserAgentShadowRoot() { DCHECK(!GetShadowRoot()); - return EnsureShadow().AddShadowRoot(*this, ShadowRootType::kUserAgentV1); + return EnsureShadow().AddShadowRoot(*this, ShadowRootType::kUserAgent); } ShadowRoot& Element::AttachShadowRootInternal(ShadowRootType type, @@ -2522,13 +2623,6 @@ ShadowRoot& Element::AttachShadowRootInternal(ShadowRootType type, return shadow_root; } -ShadowRoot* Element::GetShadowRoot() const { - ElementShadow* element_shadow = Shadow(); - if (!element_shadow) - return nullptr; - return &element_shadow->YoungestShadowRoot(); -} - ShadowRoot* Element::OpenShadowRoot() const { ShadowRoot* root = GetShadowRoot(); if (!root) @@ -2554,22 +2648,18 @@ ShadowRoot* Element::AuthorShadowRoot() const { } ShadowRoot* Element::UserAgentShadowRoot() const { - if (ElementShadow* element_shadow = Shadow()) { - ShadowRoot& root = element_shadow->OldestShadowRoot(); - DCHECK(root.IsUserAgent()); - return &root; - } - - return nullptr; + ShadowRoot* root = GetShadowRoot(); + DCHECK(!root || root->IsUserAgent()); + return root; } -ShadowRoot& Element::EnsureUserAgentShadowRootV1() { +ShadowRoot& Element::EnsureUserAgentShadowRoot() { if (ShadowRoot* shadow_root = UserAgentShadowRoot()) { - DCHECK(shadow_root->GetType() == ShadowRootType::kUserAgentV1); + DCHECK(shadow_root->GetType() == ShadowRootType::kUserAgent); return *shadow_root; } ShadowRoot& shadow_root = - EnsureShadow().AddShadowRoot(*this, ShadowRootType::kUserAgentV1); + EnsureShadow().AddShadowRoot(*this, ShadowRootType::kUserAgent); DidAddUserAgentShadowRoot(shadow_root); return shadow_root; } @@ -2970,7 +3060,7 @@ void Element::UpdateFocusAppearanceWithOptions( } else if (GetLayoutObject() && !GetLayoutObject()->IsLayoutEmbeddedContent()) { if (!options.preventScroll()) { - GetLayoutObject()->ScrollRectToVisible(BoundingBox(), + GetLayoutObject()->ScrollRectToVisible(BoundingBoxForScrollIntoView(), WebScrollIntoViewParams()); } } @@ -3031,8 +3121,7 @@ bool Element::IsFocusable() const { // needsLayoutTreeUpdateForNode check is invalid. DCHECK(!GetDocument().IsActive() || !GetDocument().NeedsLayoutTreeUpdateForNode(*this)); - return isConnected() && SupportsFocus() && !IsInert() && - LayoutObjectIsFocusable(); + return isConnected() && SupportsFocus() && !IsInert() && IsFocusableStyle(); } bool Element::IsKeyboardFocusable() const { @@ -3274,6 +3363,24 @@ void Element::SetNeedsResizeObserverUpdate() { } } +void Element::WillBeginCustomizedScrollPhase( + ScrollCustomization::ScrollDirection direction) { + DCHECK(!GetScrollCustomizationCallbacks().InScrollPhase(this)); + LayoutBox* box = GetLayoutBox(); + if (!box) + return; + + ScrollCustomization::ScrollDirection scroll_customization = + box->Style()->ScrollCustomization(); + + GetScrollCustomizationCallbacks().SetInScrollPhase( + this, direction & scroll_customization); +} + +void Element::DidEndCustomizedScrollPhase() { + GetScrollCustomizationCallbacks().SetInScrollPhase(this, false); +} + // Step 1 of http://domparsing.spec.whatwg.org/#insertadjacenthtml() static Element* ContextElementForInsertion(const String& where, Element* element, @@ -3552,7 +3659,11 @@ bool Element::ShouldStoreNonLayoutObjectComputedStyle( if (style.Display() == EDisplay::kContents && !NeedsReattachLayoutTree()) DCHECK(!GetLayoutObject() || IsPseudoElement()); #endif - + if (IsSVGElement()) { + Element* parent_element = LayoutTreeBuilderTraversal::ParentElement(*this); + if (parent_element && !parent_element->IsSVGElement()) + return false; + } return style.Display() == EDisplay::kContents || IsHTMLOptGroupElement(*this) || IsHTMLOptionElement(*this) || IsSVGStopElement(*this); @@ -4308,7 +4419,7 @@ scoped_refptr Element::CustomStyleForLayoutObject() { return OriginalStyleForLayoutObject(); } -void Element::CloneAttributesFromElement(const Element& other) { +void Element::CloneAttributesFrom(const Element& other) { if (HasRareData()) DetachAllAttrNodesFromElement(); @@ -4356,21 +4467,16 @@ void Element::CloneAttributesFromElement(const Element& other) { else element_data_ = other.element_data_->MakeUniqueCopy(); - AttributeCollection attributes = element_data_->Attributes(); - for (const Attribute& attr : attributes) { - AttributeChangedFromParserOrByCloning( - attr.GetName(), attr.Value(), AttributeModificationReason::kByCloning); + for (const Attribute& attr : element_data_->Attributes()) { + AttributeChanged( + AttributeModificationParams(attr.GetName(), g_null_atom, attr.Value(), + AttributeModificationReason::kByCloning)); } if (other.nonce() != g_null_atom) setNonce(other.nonce()); } -void Element::CloneDataFromElement(const Element& other) { - CloneAttributesFromElement(other); - CopyNonAttributePropertiesFromElement(other); -} - void Element::CreateUniqueElementData() { if (!element_data_) { element_data_ = UniqueElementData::Create(); @@ -4610,9 +4716,9 @@ void Element::AddPropertyToPresentationAttributeStyle( void Element::AddPropertyToPresentationAttributeStyle( MutableCSSPropertyValueSet* style, CSSPropertyID property_id, - const CSSValue* value) { + const CSSValue& value) { DCHECK(IsStyledElement()); - style->SetProperty(property_id, *value); + style->SetProperty(property_id, value); } void Element::LogAddElementIfIsolatedWorldAndInDocument( diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.h index c4060efd06..d8ffc47859 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.h @@ -36,6 +36,7 @@ #include "core/resize_observer/ResizeObserver.h" #include "platform/bindings/TraceWrapperMember.h" #include "platform/heap/Handle.h" +#include "platform/scroll/ScrollCustomization.h" #include "platform/scroll/ScrollTypes.h" #include "public/platform/WebFocusType.h" @@ -44,7 +45,7 @@ namespace blink { class AccessibleNode; class Attr; class Attribute; -class ComputedAccessibleNode; +class CSSPropertyValueSet; class CSSStyleDeclaration; class CustomElementDefinition; class DOMRect; @@ -53,6 +54,7 @@ class DOMStringMap; class DOMTokenList; class Document; class ElementAnimations; +class ElementIntersectionObserverData; class ElementRareData; class ElementShadow; class ExceptionState; @@ -63,7 +65,6 @@ class InputDeviceCapabilities; class Locale; class MutableCSSPropertyValueSet; class NamedNodeMap; -class ElementIntersectionObserverData; class PseudoElement; class PseudoStyleRequest; class ResizeObservation; @@ -77,9 +78,9 @@ class ShadowRootInit; class SpaceSplitString; class StringOrTrustedHTML; class StringOrTrustedScriptURL; -class CSSPropertyValueSet; class StylePropertyMap; class V0CustomElementDefinition; +class V8ScrollStateCallback; enum SpellcheckAttributeState { kSpellcheckAttributeTrue, @@ -295,8 +296,6 @@ class CORE_EXPORT Element : public ContainerNode { AccessibleNode* ExistingAccessibleNode() const; AccessibleNode* accessibleNode(); - ComputedAccessibleNode* GetComputedAccessibleNode(); - void DidMoveToNewDocument(Document&) override; void removeAttribute(const AtomicString& name); @@ -352,8 +351,8 @@ class CORE_EXPORT Element : public ContainerNode { String nodeName() const override; - Element* CloneElementWithChildren(); - Element* CloneElementWithoutChildren(); + Element* CloneWithChildren(Document* = nullptr) const; + Element* CloneWithoutChildren(Document* = nullptr) const; void SetBooleanAttribute(const QualifiedName&, bool); @@ -447,15 +446,13 @@ class CORE_EXPORT Element : public ContainerNode { } // Clones attributes only. - void CloneAttributesFromElement(const Element&); - - // Clones all attribute-derived data, including subclass specifics (through - // copyNonAttributeProperties.) - void CloneDataFromElement(const Element&); + void CloneAttributesFrom(const Element&); bool HasEquivalentAttributes(const Element* other) const; - virtual void CopyNonAttributePropertiesFromElement(const Element&) {} + // Step 5 of https://dom.spec.whatwg.org/#concept-node-clone + virtual void CloneNonAttributePropertiesFrom(const Element&, + CloneChildrenFlag) {} void AttachLayoutTree(AttachContext&) override; void DetachLayoutTree(const AttachContext& = AttachContext()) override; @@ -497,20 +494,19 @@ class CORE_EXPORT Element : public ContainerNode { const ShadowRootInit&, ExceptionState&); ShadowRoot& CreateShadowRootInternal(); - ShadowRoot& CreateUserAgentShadowRootV1(); + ShadowRoot& CreateUserAgentShadowRoot(); ShadowRoot& AttachShadowRootInternal(ShadowRootType, bool delegates_focus = false); + ShadowRoot* GetShadowRoot() const; ShadowRoot* OpenShadowRoot() const; ShadowRoot* ClosedShadowRoot() const; ShadowRoot* AuthorShadowRoot() const; ShadowRoot* UserAgentShadowRoot() const; - ShadowRoot* YoungestShadowRoot() const; - ShadowRoot* ShadowRootIfV1() const; - ShadowRoot& EnsureUserAgentShadowRootV1(); + ShadowRoot& EnsureUserAgentShadowRoot(); bool IsInDescendantTreeOf(const Element* shadow_host) const; @@ -587,9 +583,12 @@ class CORE_EXPORT Element : public ContainerNode { const FocusOptions&); virtual void blur(); - void setDistributeScroll(ScrollStateCallback*, String native_scroll_behavior); + void setDistributeScroll(V8ScrollStateCallback*, + const String& native_scroll_behavior); void NativeDistributeScroll(ScrollState&); - void setApplyScroll(ScrollStateCallback*, String native_scroll_behavior); + void setApplyScroll(V8ScrollStateCallback*, + const String& native_scroll_behavior); + void SetApplyScroll(ScrollStateCallback*); void RemoveApplyScroll(); void NativeApplyScroll(ScrollState&); @@ -755,6 +754,8 @@ class CORE_EXPORT Element : public ContainerNode { // sent at all. virtual bool IsDisabledFormControl() const { return false; } + virtual bool ShouldForceLegacyLayout() const { return false; } + bool HasPendingResources() const { return HasElementFlag(kHasPendingResources); } @@ -767,6 +768,9 @@ class CORE_EXPORT Element : public ContainerNode { void SetCustomElementDefinition(CustomElementDefinition*); CustomElementDefinition* GetCustomElementDefinition() const; + // https://dom.spec.whatwg.org/#concept-element-is-value + void SetIsValue(const AtomicString&); + const AtomicString& IsValue() const; bool ContainsFullScreenElement() const { return HasElementFlag(kContainsFullScreenElement); @@ -850,6 +854,9 @@ class CORE_EXPORT Element : public ContainerNode { EnsureResizeObserverData(); void SetNeedsResizeObserverUpdate(); + void WillBeginCustomizedScrollPhase(ScrollCustomization::ScrollDirection); + void DidEndCustomizedScrollPhase(); + protected: Element(const QualifiedName& tag_name, Document*, ConstructionType); @@ -866,10 +873,9 @@ class CORE_EXPORT Element : public ContainerNode { void AddPropertyToPresentationAttributeStyle(MutableCSSPropertyValueSet*, CSSPropertyID, const String& value); - // TODO(sashab): Make this take a const CSSValue&. void AddPropertyToPresentationAttributeStyle(MutableCSSPropertyValueSet*, CSSPropertyID, - const CSSValue*); + const CSSValue&); InsertionNotificationRequest InsertedInto(ContainerNode*) override; void RemovedFrom(ContainerNode*) override; @@ -893,8 +899,7 @@ class CORE_EXPORT Element : public ContainerNode { // However, it must not retrieve layout information like position and size. // This method cannot be moved to LayoutObject because some focusable nodes // don't have layoutObjects. e.g., HTMLOptionElement. - // TODO(tkent): Rename this to isFocusableStyle. - virtual bool LayoutObjectIsFocusable() const; + virtual bool IsFocusableStyle() const; virtual bool ChildrenCanHaveStyle() const { return true; } @@ -962,8 +967,6 @@ class CORE_EXPORT Element : public ContainerNode { inline PseudoElement* CreatePseudoElementIfNeeded(PseudoId); void CreateAndAttachPseudoElementIfNeeded(PseudoId, AttachContext&); - ShadowRoot* GetShadowRoot() const; - // FIXME: Everyone should allow author shadows. virtual bool AreAuthorShadowsAllowed() const { return true; } virtual void DidAddUserAgentShadowRoot(ShadowRoot&) {} @@ -1005,9 +1008,6 @@ class CORE_EXPORT Element : public ContainerNode { const AtomicString& value, SynchronizationOfLazyAttribute); void RemoveAttributeInternal(size_t index, SynchronizationOfLazyAttribute); - void AttributeChangedFromParserOrByCloning(const QualifiedName&, - const AtomicString&, - AttributeModificationReason); void CancelFocusAppearanceUpdate(); @@ -1021,10 +1021,10 @@ class CORE_EXPORT Element : public ContainerNode { inline void RemoveCallbackSelectors(); inline void AddCallbackSelectors(); - // cloneNode is private so that non-virtual cloneElementWithChildren and - // cloneElementWithoutChildren are used instead. - Node* cloneNode(bool deep, ExceptionState&) override; - virtual Element* CloneElementWithoutAttributesAndChildren(); + // Clone is private so that non-virtual CloneElementWithChildren and + // CloneElementWithoutChildren are used instead. + Node* Clone(Document&, CloneChildrenFlag) const override; + virtual Element* CloneWithoutAttributesAndChildren(Document& factory) const; QualifiedName tag_name_; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.idl b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.idl index 8cf0c74140..f02caeb17e 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.idl +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Element.idl @@ -22,6 +22,7 @@ // https://docs.google.com/document/d/1VnvAqeWFG9JFZfgG5evBqrLGDZYRE5w6G5jEDORekPY // for details. enum NativeScrollBehavior { "disable-native-scroll", "perform-before-native-scroll", "perform-after-native-scroll" }; +callback ScrollStateCallback = void (ScrollState scrollState); // https://dom.spec.whatwg.org/#interface-element diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementRareData.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementRareData.cpp index 7d0522d5bd..d64bbd3093 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementRareData.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementRareData.cpp @@ -34,14 +34,14 @@ #include "core/resize_observer/ResizeObservation.h" #include "core/resize_observer/ResizeObserver.h" #include "core/style/ComputedStyle.h" +#include "third_party/WebKit/Source/core/dom/AXObjectCache.h" namespace blink { struct SameSizeAsElementRareData : NodeRareData { IntSize scroll_offset; - AtomicString nonce; - void* pointers[1]; - Member members[15]; + void* pointers_or_strings[3]; + Member members[14]; }; ElementRareData::ElementRareData(NodeRenderingData* node_layout_data) @@ -120,7 +120,6 @@ void ElementRareData::TraceWrappersAfterDispatch( visitor->TraceWrappers(shadow_); visitor->TraceWrappers(class_list_); visitor->TraceWrappers(attribute_map_); - visitor->TraceWrappers(computed_accessible_node_); visitor->TraceWrappers(accessible_node_); visitor->TraceWrappers(intersection_observer_data_); if (resize_observer_data_) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementRareData.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementRareData.h index 59476a1ebd..8ebabc742c 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementRareData.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementRareData.h @@ -28,7 +28,6 @@ #include "core/css/cssom/InlineStylePropertyMap.h" #include "core/dom/AccessibleNode.h" #include "core/dom/Attr.h" -#include "core/dom/ComputedAccessibleNode.h" #include "core/dom/DOMTokenList.h" #include "core/dom/DatasetDOMStringMap.h" #include "core/dom/ElementShadow.h" @@ -133,6 +132,8 @@ class ElementRareData : public NodeRareData { CustomElementDefinition* GetCustomElementDefinition() const { return custom_element_definition_.Get(); } + void SetIsValue(const AtomicString& is_value) { is_value_ = is_value; } + const AtomicString& IsValue() const { return is_value_; } AccessibleNode* GetAccessibleNode() const { return accessible_node_.Get(); } AccessibleNode* EnsureAccessibleNode(Element* owner_element) { @@ -142,13 +143,6 @@ class ElementRareData : public NodeRareData { return accessible_node_; } - ComputedAccessibleNode* EnsureComputedAccessibleNode(Element* owner_element) { - if (!computed_accessible_node_) { - computed_accessible_node_ = ComputedAccessibleNode::Create(owner_element); - } - return computed_accessible_node_; - } - AttrNodeList& EnsureAttrNodeList(); AttrNodeList* GetAttrNodeList() { return attr_node_list_.Get(); } void RemoveAttrNodeList() { attr_node_list_.Clear(); } @@ -201,11 +195,11 @@ class ElementRareData : public NodeRareData { // TODO(davaajav):remove this field when v0 custom elements are deprecated Member v0_custom_element_definition_; Member custom_element_definition_; + AtomicString is_value_; Member pseudo_element_data_; TraceWrapperMember accessible_node_; - TraceWrapperMember computed_accessible_node_; explicit ElementRareData(NodeRenderingData*); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadow.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadow.cpp index b293c64f57..518ceb2ebf 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadow.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadow.cpp @@ -44,37 +44,20 @@ ElementShadow* ElementShadow::Create() { ElementShadow::ElementShadow() : needs_distribution_recalc_(false) {} -ShadowRoot& ElementShadow::YoungestShadowRoot() const { - ShadowRoot* current = shadow_root_; - DCHECK(current); - while (current->YoungerShadowRoot()) - current = current->YoungerShadowRoot(); - return *current; -} - ShadowRoot& ElementShadow::AddShadowRoot(Element& shadow_host, ShadowRootType type) { EventDispatchForbiddenScope assert_no_event_dispatch; ScriptForbiddenScope forbid_script; - // Multiple ShadowRoots are removed. - // TODO(kochi): Further cleanup of unnecessary code for multiple shadow. DCHECK(!shadow_root_); - - if (shadow_root_) { - // TODO(hayato): Is the order, from the youngest to the oldest, important? - for (ShadowRoot* root = &YoungestShadowRoot(); root; - root = root->OlderShadowRoot()) - root->LazyReattachIfAttached(); - } else if (type == ShadowRootType::V0) { + if (type == ShadowRootType::V0) { DCHECK(!element_shadow_v0_); element_shadow_v0_ = ElementShadowV0::Create(*this); } - ShadowRoot* shadow_root = ShadowRoot::Create(shadow_host.GetDocument(), type); - shadow_root->SetParentOrShadowHostNode(&shadow_host); - shadow_root->SetParentTreeScope(shadow_host.GetTreeScope()); - AppendShadowRoot(*shadow_root); + shadow_root_ = ShadowRoot::Create(shadow_host.GetDocument(), type); + shadow_root_->SetParentOrShadowHostNode(&shadow_host); + shadow_root_->SetParentTreeScope(shadow_host.GetTreeScope()); if (type == ShadowRootType::V0) { SetNeedsDistributionRecalc(); } else { @@ -82,51 +65,33 @@ ShadowRoot& ElementShadow::AddShadowRoot(Element& shadow_host, child.LazyReattachIfAttached(); } - shadow_root->InsertedInto(&shadow_host); + shadow_root_->InsertedInto(&shadow_host); shadow_host.SetChildNeedsStyleRecalc(); shadow_host.SetNeedsStyleRecalc( kSubtreeStyleChange, StyleChangeReasonForTracing::Create(StyleChangeReason::kShadow)); - probe::didPushShadowRoot(&shadow_host, shadow_root); + probe::didPushShadowRoot(&shadow_host, shadow_root_); - return *shadow_root; -} - -void ElementShadow::AppendShadowRoot(ShadowRoot& shadow_root) { - if (!shadow_root_) { - shadow_root_ = &shadow_root; - return; - } - ShadowRoot& youngest = YoungestShadowRoot(); - DCHECK(shadow_root.GetType() == ShadowRootType::V0); - DCHECK(youngest.GetType() == ShadowRootType::V0); - youngest.SetYoungerShadowRoot(shadow_root); - shadow_root.SetOlderShadowRoot(youngest); + return *shadow_root_; } void ElementShadow::Attach(const Node::AttachContext& context) { Node::AttachContext children_context(context); - - for (ShadowRoot* root = &YoungestShadowRoot(); root; - root = root->OlderShadowRoot()) { - if (root->NeedsAttach()) - root->AttachLayoutTree(children_context); - } + ShadowRoot& root = GetShadowRoot(); + if (root.NeedsAttach()) + root.AttachLayoutTree(children_context); } void ElementShadow::Detach(const Node::AttachContext& context) { Node::AttachContext children_context(context); children_context.clear_invalidation = true; - - for (ShadowRoot* root = &YoungestShadowRoot(); root; - root = root->OlderShadowRoot()) - root->DetachLayoutTree(children_context); + GetShadowRoot().DetachLayoutTree(children_context); } void ElementShadow::SetNeedsDistributionRecalcWillBeSetNeedsAssignmentRecalc() { if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled() && IsV1()) - YoungestShadowRoot().SetNeedsAssignmentRecalc(); + GetShadowRoot().SetNeedsAssignmentRecalc(); else SetNeedsDistributionRecalc(); } @@ -141,29 +106,9 @@ void ElementShadow::SetNeedsDistributionRecalc() { V0().ClearDistribution(); } -bool ElementShadow::HasSameStyles(const ElementShadow& other) const { - ShadowRoot* root = &YoungestShadowRoot(); - ShadowRoot* other_root = &other.YoungestShadowRoot(); - while (root || other_root) { - if (!root || !other_root) - return false; - - if (!ScopedStyleResolver::HaveSameStyles( - root->GetScopedStyleResolver(), - other_root->GetScopedStyleResolver())) { - return false; - } - - root = root->OlderShadowRoot(); - other_root = other_root->OlderShadowRoot(); - } - - return true; -} - void ElementShadow::Distribute() { if (IsV1()) - YoungestShadowRoot().DistributeV1(); + GetShadowRoot().DistributeV1(); else V0().Distribute(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadow.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadow.h index fee3237f50..c13a5b0e5b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadow.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadow.h @@ -48,20 +48,14 @@ class CORE_EXPORT ElementShadow final : public GarbageCollected, return shadow_root_->host(); } - // TODO(hayato): Remove youngestShadowRoot() and oldestShadowRoot() from - // ElementShadow - ShadowRoot& YoungestShadowRoot() const; - ShadowRoot& OldestShadowRoot() const { + ShadowRoot& GetShadowRoot() const { DCHECK(shadow_root_); return *shadow_root_; } - ElementShadow* ContainingShadow() const; ShadowRoot& AddShadowRoot(Element& shadow_host, ShadowRootType); - bool HasSameStyles(const ElementShadow&) const; - void Attach(const Node::AttachContext&); void Detach(const Node::AttachContext&); @@ -71,8 +65,8 @@ class CORE_EXPORT ElementShadow final : public GarbageCollected, void SetNeedsDistributionRecalc(); bool NeedsDistributionRecalc() const { return needs_distribution_recalc_; } - bool IsV1() const { return YoungestShadowRoot().IsV1(); } - bool IsOpenOrV0() const { return YoungestShadowRoot().IsOpenOrV0(); } + bool IsV1() const { return GetShadowRoot().IsV1(); } + bool IsOpenOrV0() const { return GetShadowRoot().IsOpenOrV0(); } ElementShadowV0& V0() const { DCHECK(element_shadow_v0_); @@ -85,7 +79,6 @@ class CORE_EXPORT ElementShadow final : public GarbageCollected, private: ElementShadow(); - void AppendShadowRoot(ShadowRoot&); void Distribute(); TraceWrapperMember element_shadow_v0_; @@ -94,15 +87,22 @@ class CORE_EXPORT ElementShadow final : public GarbageCollected, DISALLOW_COPY_AND_ASSIGN(ElementShadow); }; -inline ShadowRoot* Node::YoungestShadowRoot() const { +inline ShadowRoot* Node::GetShadowRoot() const { if (!IsElementNode()) return nullptr; - return ToElement(this)->YoungestShadowRoot(); + return ToElement(this)->GetShadowRoot(); } -inline ShadowRoot* Element::YoungestShadowRoot() const { +inline ShadowRoot* Element::GetShadowRoot() const { if (ElementShadow* shadow = Shadow()) - return &shadow->YoungestShadowRoot(); + return &shadow->GetShadowRoot(); + return nullptr; +} + +inline ShadowRoot* Element::ShadowRootIfV1() const { + ShadowRoot* root = GetShadowRoot(); + if (root && root->IsV1()) + return root; return nullptr; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadowV0.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadowV0.cpp index 256c3f81f1..8c9efd2ed7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadowV0.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadowV0.cpp @@ -132,12 +132,8 @@ ElementShadowV0::ElementShadowV0(ElementShadow& element_shadow) ElementShadowV0::~ElementShadowV0() = default; -ShadowRoot& ElementShadowV0::YoungestShadowRoot() const { - return element_shadow_->YoungestShadowRoot(); -} - -ShadowRoot& ElementShadowV0::OldestShadowRoot() const { - return element_shadow_->OldestShadowRoot(); +inline ShadowRoot& ElementShadowV0::GetShadowRoot() const { + return element_shadow_->GetShadowRoot(); } const V0InsertionPoint* ElementShadowV0::FinalDestinationInsertionPointFor( @@ -159,45 +155,28 @@ ElementShadowV0::DestinationInsertionPointsFor(const Node* key) const { } void ElementShadowV0::Distribute() { - HeapVector, 32> shadow_insertion_points; DistributionPool pool(element_shadow_->Host()); + HTMLShadowElement* shadow_insertion_point = nullptr; - for (ShadowRoot* root = &YoungestShadowRoot(); root; - root = root->OlderShadowRoot()) { - HTMLShadowElement* shadow_insertion_point = nullptr; - for (const auto& point : root->DescendantInsertionPoints()) { - if (!point->IsActive()) - continue; - if (auto* shadow = ToHTMLShadowElementOrNull(*point)) { - DCHECK(!shadow_insertion_point); - shadow_insertion_point = shadow; - shadow_insertion_points.push_back(shadow_insertion_point); - } else { - pool.DistributeTo(point, this); - if (ElementShadow* shadow = - ShadowWhereNodeCanBeDistributedForV0(*point)) { - if (!(RuntimeEnabledFeatures::IncrementalShadowDOMEnabled() && - shadow->IsV1())) - shadow->SetNeedsDistributionRecalc(); - } + for (const auto& point : GetShadowRoot().DescendantInsertionPoints()) { + if (!point->IsActive()) + continue; + if (auto* shadow = ToHTMLShadowElementOrNull(*point)) { + DCHECK(!shadow_insertion_point); + shadow_insertion_point = shadow; + } else { + pool.DistributeTo(point, this); + if (ElementShadow* shadow = + ShadowWhereNodeCanBeDistributedForV0(*point)) { + if (!(RuntimeEnabledFeatures::IncrementalShadowDOMEnabled() && + shadow->IsV1())) + shadow->SetNeedsDistributionRecalc(); } } } - for (size_t i = shadow_insertion_points.size(); i > 0; --i) { - HTMLShadowElement* shadow_insertion_point = shadow_insertion_points[i - 1]; - ShadowRoot* root = shadow_insertion_point->ContainingShadowRoot(); - DCHECK(root); - if (root->IsOldest()) { - pool.DistributeTo(shadow_insertion_point, this); - } else if (root->OlderShadowRoot()->GetType() == root->GetType()) { - // Only allow reprojecting older shadow roots between the same type to - // disallow reprojecting UA elements into author shadows. - DistributionPool older_shadow_root_pool(*root->OlderShadowRoot()); - older_shadow_root_pool.DistributeTo(shadow_insertion_point, this); - root->OlderShadowRoot()->SetShadowInsertionPointOfYoungerShadowRoot( - shadow_insertion_point); - } + if (shadow_insertion_point) { + pool.DistributeTo(shadow_insertion_point, this); if (ElementShadow* shadow = ShadowWhereNodeCanBeDistributedForV0(*shadow_insertion_point)) shadow->SetNeedsDistributionRecalc(); @@ -219,9 +198,7 @@ const SelectRuleFeatureSet& ElementShadowV0::EnsureSelectFeatureSet() { return select_features_; select_features_.Clear(); - for (const ShadowRoot* root = &OldestShadowRoot(); root; - root = root->YoungerShadowRoot()) - CollectSelectFeatureSetFrom(*root); + CollectSelectFeatureSetFrom(GetShadowRoot()); needs_select_feature_set_ = false; return select_features_; } @@ -252,10 +229,6 @@ void ElementShadowV0::WillAffectSelector() { void ElementShadowV0::ClearDistribution() { node_to_insertion_points_.clear(); - - for (ShadowRoot* root = &element_shadow_->YoungestShadowRoot(); root; - root = root->OlderShadowRoot()) - root->SetShadowInsertionPointOfYoungerShadowRoot(nullptr); } void ElementShadowV0::Trace(blink::Visitor* visitor) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadowV0.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadowV0.h index 886c93b162..daf1db5190 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadowV0.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ElementShadowV0.h @@ -60,8 +60,7 @@ class CORE_EXPORT ElementShadowV0 final private: explicit ElementShadowV0(ElementShadow&); - ShadowRoot& YoungestShadowRoot() const; - ShadowRoot& OldestShadowRoot() const; + ShadowRoot& GetShadowRoot() const; void DistributeNodeChildrenTo(V0InsertionPoint*, ContainerNode*); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ExecutionContext.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ExecutionContext.cpp index 7a35e2b015..bbcf9cc9aa 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ExecutionContext.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ExecutionContext.cpp @@ -32,8 +32,8 @@ #include "core/dom/PausableObject.h" #include "core/dom/events/EventTarget.h" #include "core/events/ErrorEvent.h" +#include "core/fileapi/PublicURLManager.h" #include "core/frame/UseCounter.h" -#include "core/html/PublicURLManager.h" #include "core/inspector/ConsoleMessage.h" #include "core/probe/CoreProbes.h" #include "core/workers/WorkerGlobalScope.h" @@ -51,7 +51,8 @@ ExecutionContext::ExecutionContext() is_context_paused_(false), is_context_destroyed_(false), window_interaction_tokens_(0), - referrer_policy_(kReferrerPolicyDefault) {} + referrer_policy_(kReferrerPolicyDefault), + invalidator_(std::make_unique()) {} ExecutionContext::~ExecutionContext() = default; @@ -87,6 +88,7 @@ void ExecutionContext::UnpausePausableObjects() { void ExecutionContext::NotifyContextDestroyed() { is_context_destroyed_ = true; + invalidator_.reset(); ContextLifecycleNotifier::NotifyContextDestroyed(); } @@ -117,7 +119,7 @@ bool ExecutionContext::ShouldSanitizeScriptError( const KURL& url = CompleteURL(source_url); if (url.ProtocolIsData()) return false; - return !(GetSecurityOrigin()->CanRequestNoSuborigin(url) || + return !(GetSecurityOrigin()->CanRequest(url) || cors_status == kSharableCrossOrigin); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ExecutionContext.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ExecutionContext.h index 532c05b2b9..6a70964b7a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ExecutionContext.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ExecutionContext.h @@ -32,6 +32,7 @@ #include "base/location.h" #include "base/macros.h" +#include "base/single_thread_task_runner.h" #include "core/CoreExport.h" #include "core/dom/ContextLifecycleNotifier.h" #include "core/dom/ContextLifecycleObserver.h" @@ -55,6 +56,7 @@ class DOMTimerCoordinator; class ErrorEvent; class EventQueue; class EventTarget; +class InterfaceInvalidator; class LocalDOMWindow; class PausableObject; class PublicURLManager; @@ -203,7 +205,10 @@ class CORE_EXPORT ExecutionContext : public ContextLifecycleNotifier, return nullptr; } - virtual scoped_refptr GetTaskRunner(TaskType) = 0; + virtual scoped_refptr GetTaskRunner( + TaskType) = 0; + + InterfaceInvalidator* GetInterfaceInvalidator() { return invalidator_.get(); } protected: ExecutionContext(); @@ -229,6 +234,9 @@ class CORE_EXPORT ExecutionContext : public ContextLifecycleNotifier, int window_interaction_tokens_; ReferrerPolicy referrer_policy_; + + std::unique_ptr invalidator_; + DISALLOW_COPY_AND_ASSIGN(ExecutionContext); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversal.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversal.cpp index 48810bf289..4e45ee482b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversal.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversal.cpp @@ -28,7 +28,6 @@ #include "core/dom/Element.h" #include "core/dom/ElementShadow.h" -#include "core/dom/ng/flat_tree_traversal_ng.h" #include "core/html/HTMLShadowElement.h" #include "core/html/HTMLSlotElement.h" @@ -36,12 +35,10 @@ namespace blink { Node* FlatTreeTraversal::TraverseChild(const Node& node, TraversalDirection direction) { - ElementShadow* shadow = ShadowFor(node); - if (shadow) { - ShadowRoot& shadow_root = shadow->YoungestShadowRoot(); + if (ShadowRoot* shadow_root = node.GetShadowRoot()) { return ResolveDistributionStartingAt(direction == kTraversalDirectionForward - ? shadow_root.firstChild() - : shadow_root.lastChild(), + ? shadow_root->firstChild() + : shadow_root->lastChild(), direction); } return ResolveDistributionStartingAt(direction == kTraversalDirectionForward @@ -59,14 +56,13 @@ Node* FlatTreeTraversal::ResolveDistributionStartingAt( sibling = (direction == kTraversalDirectionForward ? sibling->nextSibling() : sibling->previousSibling())) { - if (auto* slot = ToHTMLSlotElementOrNull(*sibling)) { - if (slot->SupportsAssignment()) { - if (Node* found = (direction == kTraversalDirectionForward - ? slot->FirstDistributedNode() - : slot->LastDistributedNode())) - return found; - continue; - } + if (const HTMLSlotElement* slot = + ToHTMLSlotElementIfSupportsAssignmentOrNull(*sibling)) { + if (Node* found = (direction == kTraversalDirectionForward + ? slot->FirstDistributedNode() + : slot->LastDistributedNode())) + return found; + continue; } if (node->IsInV0ShadowTree()) return V0ResolveDistributionStartingAt(*sibling, direction); @@ -78,8 +74,7 @@ Node* FlatTreeTraversal::ResolveDistributionStartingAt( Node* FlatTreeTraversal::V0ResolveDistributionStartingAt( const Node& node, TraversalDirection direction) { - DCHECK(!IsHTMLSlotElement(node) || - !ToHTMLSlotElement(node).SupportsAssignment()); + DCHECK(!ToHTMLSlotElementIfSupportsAssignmentOrNull(node)); for (const Node* sibling = &node; sibling; sibling = (direction == kTraversalDirectionForward ? sibling->nextSibling() @@ -117,24 +112,12 @@ Node* FlatTreeTraversal::TraverseSiblings(const Node& node, // Slotted nodes are already handled in traverseSiblingsForV1HostChild() // above, here is for fallback contents. - if (auto* slot = ToHTMLSlotElementOrNull(node.parentElement())) { - if (slot->SupportsAssignment() && slot->AssignedNodes().IsEmpty()) + if (auto* slot = + ToHTMLSlotElementIfSupportsAssignmentOrNull(node.parentElement())) { + if (slot->AssignedNodes().IsEmpty()) return TraverseSiblings(*slot, direction); } - if (!node.IsInV0ShadowTree()) - return nullptr; - - // For v0 older shadow tree - if (node.parentNode() && node.parentNode()->IsShadowRoot()) { - ShadowRoot* parent_shadow_root = ToShadowRoot(node.parentNode()); - if (!parent_shadow_root->IsYoungest()) { - HTMLShadowElement* assigned_insertion_point = - parent_shadow_root->ShadowInsertionPointOfYoungerShadowRoot(); - DCHECK(assigned_insertion_point); - return TraverseSiblings(*assigned_insertion_point, direction); - } - } return nullptr; } @@ -180,12 +163,11 @@ ContainerNode* FlatTreeTraversal::TraverseParent( return TraverseParent(*slot); } - if (auto* slot = ToHTMLSlotElementOrNull(node.parentElement())) { - if (slot->SupportsAssignment()) { - if (!slot->AssignedNodes().IsEmpty()) - return nullptr; - return TraverseParent(*slot, details); - } + if (auto* slot = + ToHTMLSlotElementIfSupportsAssignmentOrNull(node.parentElement())) { + if (!slot->AssignedNodes().IsEmpty()) + return nullptr; + return TraverseParent(*slot, details); } if (CanBeDistributedToV0InsertionPoint(node)) @@ -223,14 +205,11 @@ ContainerNode* FlatTreeTraversal::TraverseParentOrHost(const Node& node) { if (!parent->IsShadowRoot()) return parent; ShadowRoot* shadow_root = ToShadowRoot(parent); - DCHECK(!shadow_root->ShadowInsertionPointOfYoungerShadowRoot()); - if (!shadow_root->IsYoungest()) - return nullptr; return &shadow_root->host(); } Node* FlatTreeTraversal::ChildAt(const Node& node, unsigned index) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::ChildAt(node, index); AssertPrecondition(node); Node* child = TraverseFirstChild(node); @@ -241,7 +220,7 @@ Node* FlatTreeTraversal::ChildAt(const Node& node, unsigned index) { } Node* FlatTreeTraversal::NextSkippingChildren(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::NextSkippingChildren(node); if (Node* next_sibling = TraverseNextSibling(node)) return next_sibling; @@ -251,7 +230,7 @@ Node* FlatTreeTraversal::NextSkippingChildren(const Node& node) { bool FlatTreeTraversal::ContainsIncludingPseudoElement( const ContainerNode& container, const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::ContainsIncludingPseudoElement(container, node); AssertPrecondition(container); AssertPrecondition(node); @@ -266,7 +245,7 @@ bool FlatTreeTraversal::ContainsIncludingPseudoElement( } Node* FlatTreeTraversal::PreviousSkippingChildren(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::PreviousSkippingChildren(node); if (Node* previous_sibling = TraversePreviousSibling(node)) return previous_sibling; @@ -291,7 +270,7 @@ Node* FlatTreeTraversal::PreviousAncestorSiblingPostOrder( // between DOM tree traversal and flat tree tarversal. Node* FlatTreeTraversal::PreviousPostOrder(const Node& current, const Node* stay_within) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::PreviousPostOrder(current, stay_within); AssertPrecondition(current); if (stay_within) @@ -310,7 +289,7 @@ Node* FlatTreeTraversal::PreviousPostOrder(const Node& current, } bool FlatTreeTraversal::IsDescendantOf(const Node& node, const Node& other) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::IsDescendantOf(node, other); AssertPrecondition(node); AssertPrecondition(other); @@ -326,7 +305,7 @@ bool FlatTreeTraversal::IsDescendantOf(const Node& node, const Node& other) { Node* FlatTreeTraversal::CommonAncestor(const Node& node_a, const Node& node_b) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::CommonAncestor(node_a, node_b); AssertPrecondition(node_a); AssertPrecondition(node_b); @@ -357,7 +336,7 @@ Node* FlatTreeTraversal::TraversePreviousAncestorSibling(const Node& node) { } unsigned FlatTreeTraversal::Index(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::Index(node); AssertPrecondition(node); unsigned count = 0; @@ -368,7 +347,7 @@ unsigned FlatTreeTraversal::Index(const Node& node) { } unsigned FlatTreeTraversal::CountChildren(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::CountChildren(node); AssertPrecondition(node); unsigned count = 0; @@ -379,7 +358,7 @@ unsigned FlatTreeTraversal::CountChildren(const Node& node) { } Node* FlatTreeTraversal::LastWithin(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::LastWithin(node); AssertPrecondition(node); Node* descendant = TraverseLastChild(node); @@ -390,7 +369,7 @@ Node* FlatTreeTraversal::LastWithin(const Node& node) { } Node& FlatTreeTraversal::LastWithinOrSelf(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::LastWithinOrSelf(node); AssertPrecondition(node); Node* last_descendant = LastWithin(node); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversal.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversal.h index ca7f4d75c3..7273db4244 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversal.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversal.h @@ -98,7 +98,7 @@ class CORE_EXPORT FlatTreeTraversal { static bool IsDescendantOf(const Node& /*node*/, const Node& other); static bool Contains(const ContainerNode& container, const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::Contains(container, node); AssertPrecondition(container); AssertPrecondition(node); @@ -127,11 +127,12 @@ class CORE_EXPORT FlatTreeTraversal { // Flat tree range helper functions for range based for statement. // TODO(dom-team): We should have following functions to match with // |NodeTraversal|: - // - AncestorsOf() // - DescendantsOf() // - InclusiveDescendantsOf() // - StartsAt() // - StartsAfter() + static TraversalRange> + AncestorsOf(const Node&); static TraversalRange> ChildrenOf(const Node&); @@ -193,8 +194,8 @@ class CORE_EXPORT FlatTreeTraversal { inline ContainerNode* FlatTreeTraversal::Parent( const Node& node, ParentTraversalDetails* details) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) - return FlatTreeTraversalNg::Parent(node); + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) + return FlatTreeTraversalNg::Parent(node, details); AssertPrecondition(node); ContainerNode* result = TraverseParent(node, details); AssertPostcondition(result); @@ -202,14 +203,14 @@ inline ContainerNode* FlatTreeTraversal::Parent( } inline Element* FlatTreeTraversal::ParentElement(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::ParentElement(node); ContainerNode* parent = FlatTreeTraversal::Parent(node); return parent && parent->IsElementNode() ? ToElement(parent) : nullptr; } inline Node* FlatTreeTraversal::NextSibling(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::NextSibling(node); AssertPrecondition(node); Node* result = TraverseSiblings(node, kTraversalDirectionForward); @@ -218,7 +219,7 @@ inline Node* FlatTreeTraversal::NextSibling(const Node& node) { } inline Node* FlatTreeTraversal::PreviousSibling(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::PreviousSibling(node); AssertPrecondition(node); Node* result = TraverseSiblings(node, kTraversalDirectionBackward); @@ -227,7 +228,7 @@ inline Node* FlatTreeTraversal::PreviousSibling(const Node& node) { } inline Node* FlatTreeTraversal::Next(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::Next(node); AssertPrecondition(node); Node* result = TraverseNext(node); @@ -237,7 +238,7 @@ inline Node* FlatTreeTraversal::Next(const Node& node) { inline Node* FlatTreeTraversal::Next(const Node& node, const Node* stay_within) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::Next(node, stay_within); AssertPrecondition(node); Node* result = TraverseNext(node, stay_within); @@ -247,7 +248,7 @@ inline Node* FlatTreeTraversal::Next(const Node& node, inline Node* FlatTreeTraversal::NextSkippingChildren(const Node& node, const Node* stay_within) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::NextSkippingChildren(node, stay_within); AssertPrecondition(node); Node* result = TraverseNextSkippingChildren(node, stay_within); @@ -285,7 +286,7 @@ inline Node* FlatTreeTraversal::TraverseNextSkippingChildren( } inline Node* FlatTreeTraversal::Previous(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::Previous(node); AssertPrecondition(node); Node* result = TraversePrevious(node); @@ -303,7 +304,7 @@ inline Node* FlatTreeTraversal::TraversePrevious(const Node& node) { } inline Node* FlatTreeTraversal::FirstChild(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::FirstChild(node); AssertPrecondition(node); Node* result = TraverseChild(node, kTraversalDirectionForward); @@ -312,7 +313,7 @@ inline Node* FlatTreeTraversal::FirstChild(const Node& node) { } inline Node* FlatTreeTraversal::LastChild(const Node& node) { - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) return FlatTreeTraversalNg::LastChild(node); AssertPrecondition(node); Node* result = TraverseLastChild(node); @@ -341,6 +342,11 @@ inline Node* FlatTreeTraversal::TraverseLastChild(const Node& node) { } // TraverseRange implementations +inline TraversalRange> +FlatTreeTraversal::AncestorsOf(const Node& node) { + return TraversalRange>(&node); +} + inline TraversalRange> FlatTreeTraversal::ChildrenOf(const Node& parent) { return TraversalRange>(&parent); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversalTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversalTest.cpp index 77d928b77d..1ea98a6fc1 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversalTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/FlatTreeTraversalTest.cpp @@ -15,6 +15,7 @@ #include "core/html/HTMLElement.h" #include "core/testing/PageTestBase.h" #include "platform/geometry/IntSize.h" +#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" #include "platform/wtf/Compiler.h" #include "platform/wtf/StdLibExtras.h" #include "platform/wtf/Vector.h" @@ -22,7 +23,14 @@ namespace blink { -class FlatTreeTraversalTest : public PageTestBase { +class FlatTreeTraversalTest : public PageTestBase, + private ScopedSlotInFlatTreeForTest, + ScopedIncrementalShadowDOMForTest { + public: + FlatTreeTraversalTest() + : ScopedSlotInFlatTreeForTest(false), + ScopedIncrementalShadowDOMForTest(false) {} + protected: // Sets |mainHTML| to BODY element with |innerHTML| property and attaches // shadow root to child with |shadowHTML|, then update distribution for @@ -312,6 +320,23 @@ TEST_F(FlatTreeTraversalTest, nextSkippingChildren) { EXPECT_EQ(*m1, FlatTreeTraversal::PreviousSkippingChildren(*m2)); } +TEST_F(FlatTreeTraversalTest, AncestorsOf) { + SetupDocumentTree("
"); + Element* const sample = GetDocument().getElementById("sample"); + + HeapVector> expected_nodes; + for (Node* parent = FlatTreeTraversal::Parent(*sample); parent; + parent = FlatTreeTraversal::Parent(*parent)) { + expected_nodes.push_back(parent); + } + + HeapVector> actual_nodes; + for (Node& ancestor : FlatTreeTraversal::AncestorsOf(*sample)) + actual_nodes.push_back(&ancestor); + + EXPECT_EQ(expected_nodes, actual_nodes); +} + TEST_F(FlatTreeTraversalTest, InclusiveAncestorsOf) { SetupDocumentTree("
"); Element* const sample = GetDocument().getElementById("sample"); @@ -722,4 +747,21 @@ TEST_F(FlatTreeTraversalTest, v1AllFallbackContent) { EXPECT_EQ(nullptr, FlatTreeTraversal::PreviousSibling(*fallback_x)); } +TEST_F(FlatTreeTraversalTest, v0ParentDetailsInsertionPoint) { + const char* main_html = "
"; + const char* shadow_html = ""; + + SetupSampleHTML(main_html, shadow_html, 0); + + Element* span = GetDocument().body()->QuerySelector("span"); + ASSERT_TRUE(span); + + FlatTreeTraversal::ParentTraversalDetails details; + EXPECT_FALSE(details.GetInsertionPoint()); + + ContainerNode* parent = FlatTreeTraversal::Parent(*span, &details); + ASSERT_TRUE(parent); + EXPECT_TRUE(details.GetInsertionPoint()); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdTargetObserver.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdTargetObserver.h index 8952e72e93..5b74de2c4d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdTargetObserver.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdTargetObserver.h @@ -43,6 +43,8 @@ class IdTargetObserver : public GarbageCollectedFinalized { protected: IdTargetObserver(IdTargetObserverRegistry&, const AtomicString& id); + const AtomicString& Id() const { return id_; } + private: IdTargetObserverRegistry& Registry() { return *registry_; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdleDeadline.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdleDeadline.cpp index 411d0a8edf..5dbeb2b504 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdleDeadline.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdleDeadline.cpp @@ -4,7 +4,7 @@ #include "core/dom/IdleDeadline.h" -#include "core/timing/PerformanceBase.h" +#include "core/timing/Performance.h" #include "platform/scheduler/child/web_scheduler.h" #include "platform/wtf/Time.h" #include "public/platform/Platform.h" @@ -25,7 +25,7 @@ double IdleDeadline::timeRemaining() const { return 0; } - return 1000.0 * PerformanceBase::ClampTimeResolution(time_remaining); + return 1000.0 * Performance::ClampTimeResolution(time_remaining); } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdleDeadlineTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdleDeadlineTest.cpp index 0a2c39114b..fc788ddf4a 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdleDeadlineTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/IdleDeadlineTest.cpp @@ -4,6 +4,7 @@ #include "core/dom/IdleDeadline.h" +#include "base/single_thread_task_runner.h" #include "platform/scheduler/child/web_scheduler.h" #include "platform/testing/TestingPlatformSupportWithMockScheduler.h" #include "platform/wtf/Time.h" @@ -19,8 +20,7 @@ class MockIdleDeadlineScheduler final : public WebScheduler { ~MockIdleDeadlineScheduler() override = default; // WebScheduler implementation: - WebTaskRunner* TimerTaskRunner() override { return nullptr; } - WebTaskRunner* V8TaskRunner() override { return nullptr; } + base::SingleThreadTaskRunner* V8TaskRunner() override { return nullptr; } void Shutdown() override {} bool ShouldYieldForHighPriorityWork() override { return true; } bool CanExceedIdleDeadlineIfRequired() override { return false; } @@ -32,7 +32,9 @@ class MockIdleDeadlineScheduler final : public WebScheduler { WebViewScheduler::WebViewSchedulerDelegate*) override { return nullptr; } - WebTaskRunner* CompositorTaskRunner() override { return nullptr; } + base::SingleThreadTaskRunner* CompositorTaskRunner() override { + return nullptr; + } std::unique_ptr PauseScheduler() override { return nullptr; } @@ -41,6 +43,10 @@ class MockIdleDeadlineScheduler final : public WebScheduler { void RemovePendingNavigation( scheduler::RendererScheduler::NavigatingFrameType) override {} + base::TimeTicks MonotonicallyIncreasingVirtualTime() const override { + return base::TimeTicks(); + } + private: DISALLOW_COPY_AND_ASSIGN(MockIdleDeadlineScheduler); }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeList.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeList.h index 407c6940e9..6223a0aed9 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeList.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeList.h @@ -42,9 +42,9 @@ class CORE_EXPORT LiveNodeList : public NodeList, public LiveNodeListBase { LiveNodeList(ContainerNode& owner_node, CollectionType collection_type, NodeListInvalidationType invalidation_type, - NodeListRootType root_type = NodeListRootType::kNode) + NodeListSearchRoot search_root = NodeListSearchRoot::kOwnerNode) : LiveNodeListBase(owner_node, - root_type, + search_root, invalidation_type, collection_type) { // Keep this in the child class because |registerNodeList| requires wrapper diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeListBase.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeListBase.h index ffcd40083f..2078aa2943 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeListBase.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeListBase.h @@ -34,22 +34,22 @@ namespace blink { -enum class NodeListRootType { - kNode, +enum class NodeListSearchRoot { + kOwnerNode, kTreeScope, }; class CORE_EXPORT LiveNodeListBase : public GarbageCollectedMixin { public: LiveNodeListBase(ContainerNode& owner_node, - NodeListRootType root_type, + NodeListSearchRoot search_root, NodeListInvalidationType invalidation_type, CollectionType collection_type) : owner_node_(owner_node), - root_type_(static_cast(root_type)), + search_root_(static_cast(search_root)), invalidation_type_(invalidation_type), collection_type_(collection_type) { - DCHECK_EQ(root_type_, static_cast(root_type)); + DCHECK_EQ(search_root_, static_cast(search_root)); DCHECK_EQ(invalidation_type_, static_cast(invalidation_type)); DCHECK_EQ(collection_type_, static_cast(collection_type)); } @@ -60,7 +60,8 @@ class CORE_EXPORT LiveNodeListBase : public GarbageCollectedMixin { void DidMoveToDocument(Document& old_document, Document& new_document); ALWAYS_INLINE bool IsRootedAtTreeScope() const { - return root_type_ == static_cast(NodeListRootType::kTreeScope); + return search_root_ == + static_cast(NodeListSearchRoot::kTreeScope); } ALWAYS_INLINE NodeListInvalidationType InvalidationType() const { return static_cast(invalidation_type_); @@ -76,11 +77,13 @@ class CORE_EXPORT LiveNodeListBase : public GarbageCollectedMixin { static bool ShouldInvalidateTypeOnAttributeChange(NodeListInvalidationType, const QualifiedName&); + virtual void Trace(blink::Visitor* visitor) { visitor->Trace(owner_node_); } + protected: Document& GetDocument() const { return owner_node_->GetDocument(); } - ALWAYS_INLINE NodeListRootType RootType() const { - return static_cast(root_type_); + ALWAYS_INLINE NodeListSearchRoot SearchRoot() const { + return static_cast(search_root_); } template @@ -98,11 +101,9 @@ class CORE_EXPORT LiveNodeListBase : public GarbageCollectedMixin { unsigned& current_offset, MatchFunc); - virtual void Trace(blink::Visitor* visitor) { visitor->Trace(owner_node_); } - private: Member owner_node_; // Cannot be null. - const unsigned root_type_ : 1; + const unsigned search_root_ : 1; const unsigned invalidation_type_ : 4; const unsigned collection_type_ : 5; }; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeListRegistryTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeListRegistryTest.cpp index 0c9ebfa99c..6e9ff1de6b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeListRegistryTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/LiveNodeListRegistryTest.cpp @@ -6,7 +6,7 @@ #include "core/dom/Document.h" #include "core/dom/NameNodeList.h" -#include "core/testing/DummyPageHolder.h" +#include "core/testing/PageTestBase.h" #include "platform/heap/Persistent.h" #include "platform/heap/ThreadState.h" #include "testing/gtest/include/gtest/gtest.h" @@ -14,18 +14,14 @@ namespace blink { namespace { -class LiveNodeListRegistryTest : public ::testing::Test { +class LiveNodeListRegistryTest : public PageTestBase { public: - void SetUp() override { page_holder_ = DummyPageHolder::Create(); } + void SetUp() override { PageTestBase::SetUp(IntSize()); } protected: const LiveNodeListBase* CreateNodeList() { - return NameNodeList::Create(page_holder_->GetDocument(), kNameNodeListType, - g_empty_atom); + return NameNodeList::Create(GetDocument(), kNameNodeListType, g_empty_atom); } - - private: - std::unique_ptr page_holder_; }; TEST_F(LiveNodeListRegistryTest, InitialState) { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/MutationObserverTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/MutationObserverTest.cpp index 6f386de8fb..419de5e8d7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/MutationObserverTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/MutationObserverTest.cpp @@ -35,7 +35,7 @@ class EmptyMutationCallback : public MutationObserver::Delegate { TEST(MutationObserverTest, DisconnectCrash) { Persistent document = HTMLDocument::CreateForTest(); - HTMLElement* root = ToHTMLElement(document->createElement("html")); + auto* root = ToHTMLElement(document->CreateRawElement(HTMLNames::htmlTag)); document->AppendChild(root); root->SetInnerHTMLFromString("\n"); Node* head = root->firstChild()->firstChild(); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Node.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Node.cpp index 78f8a60a5a..a9c99727a7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Node.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Node.cpp @@ -340,7 +340,8 @@ NodeRareData& Node::EnsureRareData() { DCHECK(data_.rare_data_); SetFlag(kHasRareDataFlag); - ScriptWrappableVisitor::WriteBarrier(RareData()); + ScriptWrappableMarkingVisitor::WriteBarrier(RareData()); + ThreadState::Current()->Heap().WriteBarrier(RareData()); return *RareData(); } @@ -605,7 +606,24 @@ void Node::remove() { remove(ASSERT_NO_EXCEPTION); } -Node* Node::cloneNode(bool deep) { +Node* Node::cloneNode(bool deep, ExceptionState& exception_state) const { + // https://dom.spec.whatwg.org/#dom-node-clonenode + + // 1. If context object is a shadow root, then throw a + // "NotSupportedError" DOMException. + if (IsShadowRoot()) { + exception_state.ThrowDOMException(kNotSupportedError, + "ShadowRoot nodes are not clonable."); + return nullptr; + } + + // 2. Return a clone of the context object, with the clone children + // flag set if deep is true. + return Clone(GetDocument(), + deep ? CloneChildrenFlag::kClone : CloneChildrenFlag::kSkip); +} + +Node* Node::cloneNode(bool deep) const { return cloneNode(deep, ASSERT_NO_EXCEPTION); } @@ -663,6 +681,9 @@ void Node::SetLayoutObject(LayoutObject* layout_object) { void Node::SetNonAttachedStyle( scoped_refptr non_attached_style) { + // We don't set non-attached style for text nodes. + DCHECK(IsElementNode()); + NodeRenderingData* node_layout_data = HasRareData() ? data_.rare_data_->GetNodeRenderingData() : data_.node_layout_data_; @@ -677,6 +698,10 @@ void Node::SetNonAttachedStyle( if (!non_attached_style) return; + // Ensure we don't unnecessarily set non-attached style for elements which are + // not part of the flat tree and consequently won't be attached. + DCHECK(LayoutTreeBuilderTraversal::Parent(*this)); + // Swap the NodeRenderingData to point to a new NodeRenderingData instead of // the static SharedEmptyData instance. DCHECK(!node_layout_data->GetLayoutObject()); @@ -700,15 +725,14 @@ LayoutRect Node::BoundingBox() const { return LayoutRect(); } -#ifndef NDEBUG -inline static ShadowRoot* OldestShadowRootFor(const Node* node) { - if (!node->IsElementNode()) - return nullptr; - if (ElementShadow* shadow = ToElement(node)->Shadow()) - return &shadow->OldestShadowRoot(); - return nullptr; +LayoutRect Node::BoundingBoxForScrollIntoView() const { + if (GetLayoutObject()) { + return LayoutRect( + GetLayoutObject()->AbsoluteBoundingBoxRectForScrollIntoView()); + } + + return LayoutRect(); } -#endif Node& Node::ShadowIncludingRoot() const { if (isConnected()) @@ -785,8 +809,7 @@ void Node::RecalcDistribution() { child->RecalcDistribution(); } - for (ShadowRoot* root = YoungestShadowRoot(); root; - root = root->OlderShadowRoot()) { + if (ShadowRoot* root = GetShadowRoot()) { if (root->ChildNeedsDistributionRecalc()) root->RecalcDistribution(); } @@ -837,10 +860,9 @@ static ContainerNode* GetReattachParent(Node& node) { if (node.IsPseudoElement()) return node.ParentOrShadowHostNode(); if (node.IsChildOfV1ShadowHost()) { - HTMLSlotElement* slot = - RuntimeEnabledFeatures::IncrementalShadowDOMEnabled() - ? node.AssignedSlot() - : node.FinalDestinationSlot(); + HTMLSlotElement* slot = RuntimeEnabledFeatures::SlotInFlatTreeEnabled() + ? node.AssignedSlot() + : node.FinalDestinationSlot(); if (slot) return slot; } @@ -998,7 +1020,7 @@ bool Node::IsShadowIncludingInclusiveAncestorOf(const Node* node) const { return false; bool has_children = IsContainerNode() && ToContainerNode(this)->HasChildren(); - bool has_shadow = IsElementNode() && ToElement(this)->Shadow(); + bool has_shadow = IsShadowHost(this); if (!has_children && !has_shadow) return false; @@ -1086,7 +1108,6 @@ void Node::AttachLayoutTree(AttachContext& context) { ClearNeedsStyleRecalc(); ClearNeedsReattachLayoutTree(); - SetNonAttachedStyle(nullptr); if (AXObjectCache* cache = GetDocument().GetOrCreateAXObjectCache()) cache->UpdateCacheAfterNodeIsAttached(this); @@ -1126,10 +1147,11 @@ bool Node::CanStartSelection(SelectionStartPolicy selection_start_policy) const const ComputedStyle& style = GetLayoutObject()->StyleRef(); if (style.UserSelect() == EUserSelect::kNone) return false; - // We allow selections to begin within |user-select: text| sub trees + // We allow selections to begin within |user-select: text/all| sub trees // but not if the element is draggable. if (style.UserDrag() != EUserDrag::kElement && - style.UserSelect() == EUserSelect::kText) + (style.UserSelect() == EUserSelect::kText || + style.UserSelect() == EUserSelect::kAll)) return true; } ContainerNode* parent = FlatTreeTraversal::Parent(*this); @@ -1153,15 +1175,14 @@ bool Node::IsStyledElement() const { bool Node::CanParticipateInFlatTree() const { // TODO(hayato): Return false for pseudo elements. - if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()) { + if (RuntimeEnabledFeatures::SlotInFlatTreeEnabled()) { return !IsShadowRoot() && !IsActiveV0InsertionPoint(*this); } return !IsShadowRoot() && !IsActiveSlotOrActiveV0InsertionPoint(); } bool Node::IsActiveSlotOrActiveV0InsertionPoint() const { - return (IsHTMLSlotElement(*this) && - ToHTMLSlotElement(*this).SupportsAssignment()) || + return ToHTMLSlotElementIfSupportsAssignmentOrNull(*this) || IsActiveV0InsertionPoint(*this); } @@ -1620,13 +1641,6 @@ unsigned short Node::compareDocumentPosition( if (!child1->IsShadowRoot()) return Node::kDocumentPositionPreceding | connection; - for (const ShadowRoot* child = ToShadowRoot(child2)->OlderShadowRoot(); - child; child = child->OlderShadowRoot()) { - if (child == child1) { - return Node::kDocumentPositionFollowing | connection; - } - } - return Node::kDocumentPositionPreceding | connection; } @@ -1694,11 +1708,7 @@ String Node::GetPath() const { for (unsigned index = chain.size(); index > 0; --index) { const Node* node = chain[index - 1]; if (node->IsShadowRoot()) { - int count = 0; - for (ShadowRoot* shadow_root = ToShadowRoot(node)->OlderShadowRoot(); - shadow_root; shadow_root = shadow_root->OlderShadowRoot()) - ++count; - path.Append(String::Format("/#shadow-root[%d]", count)); + path.Append("/#shadow-root[0]"); continue; } @@ -1743,38 +1753,20 @@ String Node::GetPath() const { static void DumpAttributeDesc(const Node& node, const QualifiedName& name, - std::ostream& ostream) { + StringBuilder& builder) { if (!node.IsElementNode()) return; const AtomicString& value = ToElement(node).getAttribute(name); if (value.IsEmpty()) return; - ostream << ' ' << name.ToString().Utf8().data() << '=' << value; + builder.Append(' '); + builder.Append(name.ToString()); + builder.Append("="); + builder.Append(String(value).EncodeForDebugging()); } std::ostream& operator<<(std::ostream& ostream, const Node& node) { - if (node.getNodeType() == Node::kProcessingInstructionNode) - return ostream << "?" << node.nodeName().Utf8().data(); - if (node.IsShadowRoot()) { - // nodeName of ShadowRoot is #document-fragment. It's confused with - // DocumentFragment. - return ostream << "#shadow-root(" << ToShadowRoot(node).GetType() << ")"; - } - if (node.IsDocumentTypeNode()) - return ostream << "DOCTYPE " << node.nodeName().Utf8().data(); - - // We avoid to print "" by utf8().data(). - ostream << node.nodeName().Utf8().data(); - if (node.IsTextNode()) - return ostream << " " << node.nodeValue(); - DumpAttributeDesc(node, HTMLNames::idAttr, ostream); - DumpAttributeDesc(node, HTMLNames::classAttr, ostream); - DumpAttributeDesc(node, HTMLNames::styleAttr, ostream); - if (HasEditableStyle(node)) - ostream << " (editable)"; - if (node.GetDocument().FocusedElement() == &node) - ostream << " (focused)"; - return ostream; + return ostream << node.ToString().Utf8().data(); } std::ostream& operator<<(std::ostream& ostream, const Node* node) { @@ -1783,16 +1775,39 @@ std::ostream& operator<<(std::ostream& ostream, const Node* node) { return ostream << *node; } -#ifndef NDEBUG - String Node::ToString() const { - // TODO(tkent): We implemented toString() with operator<<. We should - // implement operator<< with toString() instead. - std::stringstream stream; - stream << *this; - return String(stream.str().c_str()); + if (getNodeType() == Node::kProcessingInstructionNode) + return "?" + nodeName(); + if (IsShadowRoot()) { + // nodeName of ShadowRoot is #document-fragment. It's confused with + // DocumentFragment. + std::stringstream shadow_root_type; + shadow_root_type << ToShadowRoot(this)->GetType(); + String shadow_root_type_str(shadow_root_type.str().c_str()); + return "#shadow-root(" + shadow_root_type_str + ")"; + } + if (IsDocumentTypeNode()) + return "DOCTYPE " + nodeName(); + + StringBuilder builder; + builder.Append(nodeName()); + if (IsTextNode()) { + builder.Append(" "); + builder.Append(nodeValue().EncodeForDebugging()); + return builder.ToString(); + } + DumpAttributeDesc(*this, HTMLNames::idAttr, builder); + DumpAttributeDesc(*this, HTMLNames::classAttr, builder); + DumpAttributeDesc(*this, HTMLNames::styleAttr, builder); + if (HasEditableStyle(*this)) + builder.Append(" (editable)"); + if (GetDocument().FocusedElement() == this) + builder.Append(" (focused)"); + return builder.ToString(); } +#ifndef NDEBUG + String Node::ToTreeStringForThis() const { return ToMarkedTreeString(this, "*"); } @@ -1811,12 +1826,7 @@ void Node::PrintNodePathTo(std::ostream& stream) const { for (unsigned index = chain.size(); index > 0; --index) { const Node* node = chain[index - 1]; if (node->IsShadowRoot()) { - int count = 0; - for (const ShadowRoot* shadow_root = - ToShadowRoot(node)->OlderShadowRoot(); - shadow_root; shadow_root = shadow_root->OlderShadowRoot()) - ++count; - stream << "/#shadow-root[" << count << "]"; + stream << "/#shadow-root"; continue; } @@ -1895,13 +1905,8 @@ static void AppendMarkedTree(const String& base_indent, marked_node2, marked_label2, builder); } - if (node.IsShadowRoot()) { - if (ShadowRoot* younger_shadow_root = - ToShadowRoot(node).YoungerShadowRoot()) - AppendMarkedTree(indent.ToString(), younger_shadow_root, marked_node1, - marked_label1, marked_node2, marked_label2, builder); - } else if (ShadowRoot* oldest_shadow_root = OldestShadowRootFor(&node)) { - AppendMarkedTree(indent.ToString(), oldest_shadow_root, marked_node1, + if (ShadowRoot* shadow_root = node.GetShadowRoot()) { + AppendMarkedTree(indent.ToString(), shadow_root, marked_node1, marked_label1, marked_node2, marked_label2, builder); } } @@ -1981,19 +1986,12 @@ static void PrintSubTreeAcrossFrame(const Node* node, if (node == marked_node) stream << "*"; stream << indent.Utf8().data() << *node << "\n"; - if (node->IsShadowRoot()) { - if (ShadowRoot* younger_shadow_root = - ToShadowRoot(node)->YoungerShadowRoot()) - PrintSubTreeAcrossFrame(younger_shadow_root, marked_node, indent + "\t", - stream); - } else { - if (node->IsFrameOwnerElement()) - PrintSubTreeAcrossFrame(ToHTMLFrameOwnerElement(node)->contentDocument(), - marked_node, indent + "\t", stream); - if (ShadowRoot* oldest_shadow_root = OldestShadowRootFor(node)) - PrintSubTreeAcrossFrame(oldest_shadow_root, marked_node, indent + "\t", - stream); + if (node->IsFrameOwnerElement()) { + PrintSubTreeAcrossFrame(ToHTMLFrameOwnerElement(node)->contentDocument(), + marked_node, indent + "\t", stream); } + if (ShadowRoot* shadow_root = node->GetShadowRoot()) + PrintSubTreeAcrossFrame(shadow_root, marked_node, indent + "\t", stream); for (const Node* child = node->firstChild(); child; child = child->nextSibling()) PrintSubTreeAcrossFrame(child, marked_node, indent + "\t", stream); @@ -2112,8 +2110,7 @@ void Node::RemoveAllEventListenersRecursively() { ScriptForbiddenScope forbid_script_during_raw_iteration; for (Node& node : NodeTraversal::StartsAt(*this)) { node.RemoveAllEventListeners(); - for (ShadowRoot* root = node.YoungestShadowRoot(); root; - root = root->OlderShadowRoot()) + if (ShadowRoot* root = node.GetShadowRoot()) root->RemoveAllEventListenersRecursively(); } } @@ -2736,15 +2733,13 @@ void Node::CheckSlotChange(SlotChangeType slot_change_type) { slot->DidSlotChange(slot_change_type); } else if (IsInV1ShadowTree()) { // Checking for fallback content if the node is in a v1 shadow tree. - Element* parent = parentElement(); - if (parent && IsHTMLSlotElement(parent)) { - HTMLSlotElement& parent_slot = ToHTMLSlotElement(*parent); - DCHECK(parent_slot.SupportsAssignment()); + if (auto* parent_slot = ToHTMLSlotElementOrNull(parentElement())) { + DCHECK(parent_slot->SupportsAssignment()); // The parent_slot's assigned nodes might not be calculated because they // are lazy evaluated later at UpdateDistribution() so we have to check it // here. - if (!parent_slot.HasAssignedNodesSlow()) - parent_slot.DidSlotChange(slot_change_type); + if (!parent_slot->HasAssignedNodesSlow()) + parent_slot->DidSlotChange(slot_change_type); } } } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Node.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Node.h index 14bf77c73b..3dd2d0144b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Node.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/Node.h @@ -106,6 +106,8 @@ enum class SlotChangeType { kSuppressSlotChangeEvent, }; +enum class CloneChildrenFlag { kClone, kSkip }; + class NodeRenderingData { public: explicit NodeRenderingData(LayoutObject* layout_object, @@ -264,8 +266,11 @@ class CORE_EXPORT Node : public EventTarget { Node* appendChild(Node* new_child); bool hasChildren() const { return firstChild(); } - virtual Node* cloneNode(bool deep, ExceptionState&) = 0; - Node* cloneNode(bool deep); + Node* cloneNode(bool deep, ExceptionState&) const; + // https://dom.spec.whatwg.org/#concept-node-clone + virtual Node* Clone(Document&, CloneChildrenFlag) const = 0; + // This is not web-exposed. We should rename it or remove it. + Node* cloneNode(bool deep) const; void normalize(); bool isEqualNode(Node*) const; @@ -336,6 +341,7 @@ class CORE_EXPORT Node : public EventTarget { virtual bool IsCharacterDataNode() const { return false; } virtual bool IsFrameOwnerElement() const { return false; } virtual bool IsMediaRemotingInterstitial() const { return false; } + virtual bool IsPictureInPictureInterstitial() const { return false; } // Traverses the ancestors of this node and returns true if any of them are // either a MediaControlElement or MediaControls. @@ -371,7 +377,7 @@ class CORE_EXPORT Node : public EventTarget { // isInShadowTree() returns true. // This can happen when handling queued events (e.g. during execCommand()) ShadowRoot* ContainingShadowRoot() const; - ShadowRoot* YoungestShadowRoot() const; + ShadowRoot* GetShadowRoot() const; bool IsInUserAgentShadowRoot() const; // Returns nullptr, a child of ShadowRoot, or a legacy shadow root. @@ -557,6 +563,11 @@ class CORE_EXPORT Node : public EventTarget { return PixelSnappedIntRect(BoundingBox()); } + // BoundingBoxForScrollIntoView() is the node's scroll snap area. + // It is expanded from the BoundingBox() by scroll-margin. + // https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-area + LayoutRect BoundingBoxForScrollIntoView() const; + unsigned NodeIndex() const; // Returns the DOM ownerDocument attribute. This method never returns null, @@ -728,8 +739,9 @@ class CORE_EXPORT Node : public EventTarget { String GetPath() const; -#ifndef NDEBUG String ToString() const; + +#ifndef NDEBUG String ToTreeStringForThis() const; String ToFlatTreeStringForThis() const; void PrintNodePathTo(std::ostream&) const; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/NodeTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/NodeTest.cpp index b78df0f709..90d652bd8d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/NodeTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/NodeTest.cpp @@ -56,10 +56,10 @@ class NodeTest : public EditingTestBase { Node* InitializeUserAgentShadowTree(Element* test_node) { SetBodyContent("
"); Element* root = GetDocument().getElementById("root"); - ShadowRoot& first_shadow = root->CreateUserAgentShadowRootV1(); + ShadowRoot& first_shadow = root->CreateUserAgentShadowRoot(); first_shadow.AppendChild(test_node); - ShadowRoot& second_shadow = test_node->CreateUserAgentShadowRootV1(); + ShadowRoot& second_shadow = test_node->CreateUserAgentShadowRoot(); HTMLDivElement* class_div = HTMLDivElement::Create(GetDocument()); class_div->setAttribute("class", "test"); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/NthIndexCacheTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/NthIndexCacheTest.cpp index afd89b4d08..8984787d97 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/NthIndexCacheTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/NthIndexCacheTest.cpp @@ -4,28 +4,15 @@ #include "core/dom/NthIndexCache.h" +#include #include "core/dom/Document.h" #include "core/html/HTMLElement.h" -#include "core/testing/DummyPageHolder.h" +#include "core/testing/PageTestBase.h" #include "testing/gtest/include/gtest/gtest.h" -#include namespace blink { -class NthIndexCacheTest : public ::testing::Test { - protected: - void SetUp() override; - - Document& GetDocument() const { return dummy_page_holder_->GetDocument(); } - void SetHtmlInnerHTML(const char* html_content); - - private: - std::unique_ptr dummy_page_holder_; -}; - -void NthIndexCacheTest::SetUp() { - dummy_page_holder_ = DummyPageHolder::Create(IntSize(800, 600)); -} +class NthIndexCacheTest : public PageTestBase {}; TEST_F(NthIndexCacheTest, NthIndex) { GetDocument().documentElement()->SetInnerHTMLFromString(R"HTML( @@ -44,12 +31,10 @@ TEST_F(NthIndexCacheTest, NthIndex) { NthIndexCache nth_index_cache(GetDocument()); + EXPECT_EQ(nth_index_cache.NthChildIndex(*GetElementById("nth-child")), 12U); EXPECT_EQ( - nth_index_cache.NthChildIndex(*GetDocument().getElementById("nth-child")), + nth_index_cache.NthLastChildIndex(*GetElementById("nth-last-child")), 12U); - EXPECT_EQ(nth_index_cache.NthLastChildIndex( - *GetDocument().getElementById("nth-last-child")), - 12U); } } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/PresentationAttributeStyle.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/PresentationAttributeStyle.cpp index 82a3f73221..c50c6e8834 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/PresentationAttributeStyle.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/PresentationAttributeStyle.cpp @@ -37,7 +37,6 @@ #include "core/dom/Attribute.h" #include "core/dom/Element.h" #include "core/html/forms/HTMLInputElement.h" -#include "platform/Timer.h" #include "platform/scheduler/child/web_scheduler.h" #include "platform/wtf/HashFunctions.h" #include "platform/wtf/HashMap.h" @@ -81,53 +80,6 @@ static PresentationAttributeCache& GetPresentationAttributeCache() { return cache; } -// This is a singleton (held via DEFINE_STATIC_LOCAL). -// Thus it is appropriate to use the main thread's timer task runner, rather -// than one associated with a particular frame. -class PresentationAttributeCacheCleaner { - USING_FAST_MALLOC(PresentationAttributeCacheCleaner); - - public: - PresentationAttributeCacheCleaner() - : hit_count_(0), - clean_timer_( - Platform::Current()->MainThread()->Scheduler()->TimerTaskRunner(), - this, - &PresentationAttributeCacheCleaner::CleanCache) {} - - void DidHitPresentationAttributeCache() { - if (GetPresentationAttributeCache().size() < - kMinimumPresentationAttributeCacheSizeForCleaning) - return; - - hit_count_++; - - if (!clean_timer_.IsActive()) { - clean_timer_.StartOneShot(kPresentationAttributeCacheCleanTimeInSeconds, - FROM_HERE); - } - } - - private: - static const unsigned kPresentationAttributeCacheCleanTimeInSeconds = 60; - static const unsigned kMinimumPresentationAttributeCacheSizeForCleaning = 100; - static const unsigned kMinimumPresentationAttributeCacheHitCountPerMinute = - (100 * kPresentationAttributeCacheCleanTimeInSeconds) / 60; - - void CleanCache(TimerBase* timer) { - DCHECK_EQ(timer, &clean_timer_); - unsigned hit_count = hit_count_; - hit_count_ = 0; - if (hit_count > kMinimumPresentationAttributeCacheHitCountPerMinute) - return; - GetPresentationAttributeCache().clear(); - } - - unsigned hit_count_; - TaskRunnerTimer clean_timer_; - DISALLOW_COPY_AND_ASSIGN(PresentationAttributeCacheCleaner); -}; - static bool AttributeNameSort(const std::pair& p1, const std::pair& p2) { // Sort based on the attribute name pointers. It doesn't matter what the order @@ -179,8 +131,6 @@ static unsigned ComputePresentationAttributeCacheHash( } CSSPropertyValueSet* ComputePresentationAttributeStyle(Element& element) { - DEFINE_STATIC_LOCAL(PresentationAttributeCacheCleaner, cache_cleaner, ()); - DCHECK(element.IsStyledElement()); PresentationAttributeCacheKey cache_key; @@ -189,6 +139,7 @@ CSSPropertyValueSet* ComputePresentationAttributeStyle(Element& element) { unsigned cache_hash = ComputePresentationAttributeCacheHash(cache_key); PresentationAttributeCache::ValueType* cache_value; + if (cache_hash) { cache_value = GetPresentationAttributeCache() .insert(cache_hash, nullptr) @@ -199,10 +150,24 @@ CSSPropertyValueSet* ComputePresentationAttributeStyle(Element& element) { cache_value = nullptr; } + // Keep the entry value of |cache_value| here in order to assure that the + // value lives when it is used. Without this keeping, calling + // |GetPresentationAttributeCache().clear()| destroys |cache_value->value| and + // causes use-after-poison (crbug.com/810368). + PresentationAttributeCacheEntry* entry = nullptr; + if (cache_value) + entry = cache_value->value; + CSSPropertyValueSet* style = nullptr; if (cache_hash && cache_value->value) { style = cache_value->value->value; - cache_cleaner.DidHitPresentationAttributeCache(); + + static const unsigned kMinimumPresentationAttributeCacheSizeForCleaning = + 100; + if (GetPresentationAttributeCache().size() >= + kMinimumPresentationAttributeCacheSizeForCleaning) { + GetPresentationAttributeCache().clear(); + } } else { style = MutableCSSPropertyValueSet::Create( element.IsSVGElement() ? kSVGAttributeMode : kHTMLStandardMode); @@ -213,7 +178,7 @@ CSSPropertyValueSet* ComputePresentationAttributeStyle(Element& element) { } } - if (!cache_hash || cache_value->value) + if (!cache_hash || entry) return style; PresentationAttributeCacheEntry* new_entry = diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp index ee3b8ae55a..52fae3fca4 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ProcessingInstruction.cpp @@ -80,10 +80,10 @@ Node::NodeType ProcessingInstruction::getNodeType() const { return kProcessingInstructionNode; } -Node* ProcessingInstruction::cloneNode(bool /*deep*/, ExceptionState&) { +Node* ProcessingInstruction::Clone(Document& factory, CloneChildrenFlag) const { // FIXME: Is it a problem that this does not copy m_localHref? // What about other data members? - return Create(GetDocument(), target_, data_); + return Create(factory, target_, data_); } void ProcessingInstruction::DidAttributeChanged() { @@ -147,33 +147,22 @@ void ProcessingInstruction::Process(const String& href, const String& charset) { ClearResource(); - String url = GetDocument().CompleteURL(href).GetString(); + if (is_xsl_ && !RuntimeEnabledFeatures::XSLTEnabled()) + return; - TextResource* resource = nullptr; ResourceLoaderOptions options; options.initiator_info.name = FetchInitiatorTypeNames::processinginstruction; FetchParameters params(ResourceRequest(GetDocument().CompleteURL(href)), options); loading_ = true; if (is_xsl_) { - if (RuntimeEnabledFeatures::XSLTEnabled()) { - resource = - XSLStyleSheetResource::Fetch(params, GetDocument().Fetcher(), this); - } + DCHECK(RuntimeEnabledFeatures::XSLTEnabled()); + XSLStyleSheetResource::Fetch(params, GetDocument().Fetcher(), this); } else { params.SetCharset(charset.IsEmpty() ? GetDocument().Encoding() : WTF::TextEncoding(charset)); GetDocument().GetStyleEngine().AddPendingSheet(style_engine_context_); - resource = - CSSStyleSheetResource::Fetch(params, GetDocument().Fetcher(), this); - } - - if (!resource) { - loading_ = false; - if (!is_xsl_) { - GetDocument().GetStyleEngine().RemovePendingSheet(*this, - style_engine_context_); - } + CSSStyleSheetResource::Fetch(params, GetDocument().Fetcher(), this); } } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ProcessingInstruction.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ProcessingInstruction.h index 5c39ef63aa..fd83a05371 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ProcessingInstruction.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ProcessingInstruction.h @@ -76,7 +76,7 @@ class ProcessingInstruction final : public CharacterData, String nodeName() const override; NodeType getNodeType() const override; - Node* cloneNode(bool deep, ExceptionState&) override; + Node* Clone(Document&, CloneChildrenFlag) const override; InsertionNotificationRequest InsertedInto(ContainerNode*) override; void RemovedFrom(ContainerNode*) override; diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/QualifiedName.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/QualifiedName.cpp index 857a5cca15..9d6166612f 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/QualifiedName.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/QualifiedName.cpp @@ -149,4 +149,11 @@ void QualifiedName::CreateStatic(void* target_address, StringImpl* name) { QualifiedName(g_null_atom, AtomicString(name), g_null_atom, true); } +std::ostream& operator<<(std::ostream& ostream, const QualifiedName& qname) { + ostream << "QualifiedName(local=" << qname.LocalName() + << " ns=" << qname.NamespaceURI() << " prefix=" << qname.Prefix() + << ")"; + return ostream; +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/QualifiedName.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/QualifiedName.h index a3630fc1f0..f3a23300bb 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/QualifiedName.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/QualifiedName.h @@ -219,6 +219,8 @@ struct CORE_EXPORT QualifiedNameHash { static const bool safe_to_compare_to_empty_or_deleted = false; }; +CORE_EXPORT std::ostream& operator<<(std::ostream&, const QualifiedName&); + } // namespace blink namespace WTF { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/RangeTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/RangeTest.cpp index 70f8951b30..89607ebcd7 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/RangeTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/RangeTest.cpp @@ -38,7 +38,8 @@ class RangeTest : public EditingTestBase {}; TEST_F(RangeTest, extractContentsWithDOMMutationEvent) { GetDocument().body()->SetInnerHTMLFromString("abcdef"); GetDocument().GetSettings()->SetScriptEnabled(true); - Element* const script_element = GetDocument().createElement("script"); + Element* const script_element = + GetDocument().CreateRawElement(HTMLNames::scriptTag); script_element->setTextContent( "let count = 0;" "const span = document.querySelector('span');" @@ -52,7 +53,7 @@ TEST_F(RangeTest, extractContentsWithDOMMutationEvent) { Element* const span_element = GetDocument().QuerySelector("span"); Range* const range = Range::Create(GetDocument(), span_element, 0, span_element, 1); - Element* const result = GetDocument().createElement("div"); + Element* const result = GetDocument().CreateRawElement(HTMLNames::divTag); result->AppendChild(range->extractContents(ASSERT_NO_EXCEPTION)); EXPECT_EQ("abc", result->InnerHTMLAsString()) @@ -171,8 +172,8 @@ TEST_F(RangeTest, SplitTextNodeRangeOutsideText) { } TEST_F(RangeTest, updateOwnerDocumentIfNeeded) { - Element* foo = GetDocument().createElement("foo"); - Element* bar = GetDocument().createElement("bar"); + Element* foo = GetDocument().CreateElementForBinding("foo"); + Element* bar = GetDocument().CreateElementForBinding("bar"); foo->AppendChild(bar); Range* range = diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SandboxFlags.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SandboxFlags.cpp index d03420964f..bef814161d 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SandboxFlags.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SandboxFlags.cpp @@ -31,7 +31,7 @@ #include "platform/runtime_enabled_features.h" #include "platform/wtf/Assertions.h" #include "platform/wtf/text/StringBuilder.h" -#include "third_party/WebKit/common/sandbox_flags.h" +#include "third_party/WebKit/public/common/frame/sandbox_flags.h" namespace blink { diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationController.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationController.cpp index 1258441f26..2d12011818 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationController.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationController.cpp @@ -33,6 +33,7 @@ #include "core/inspector/InspectorTraceEvents.h" #include "core/loader/DocumentLoader.h" #include "core/probe/CoreProbes.h" +#include "platform/wtf/Time.h" namespace blink { @@ -135,13 +136,14 @@ void ScriptedAnimationController::ExecuteCallbacks(double monotonic_time_now) { if (!document_) return; + TimeTicks time = TimeTicksFromSeconds(monotonic_time_now); double high_res_now_ms = 1000.0 * document_->Loader()->GetTiming().MonotonicTimeToZeroBasedDocumentTime( - monotonic_time_now); + time); double legacy_high_res_now_ms = - 1000.0 * document_->Loader()->GetTiming().MonotonicTimeToPseudoWallTime( - monotonic_time_now); + 1000.0 * + document_->Loader()->GetTiming().MonotonicTimeToPseudoWallTime(time); callback_collection_.ExecuteCallbacks(high_res_now_ms, legacy_high_res_now_ms); } @@ -165,6 +167,7 @@ bool ScriptedAnimationController::HasScheduledItems() const { void ScriptedAnimationController::ServiceScriptedAnimations( double monotonic_time_now) { + current_frame_had_raf_ = HasCallback(); if (!HasScheduledItems()) return; @@ -172,6 +175,7 @@ void ScriptedAnimationController::ServiceScriptedAnimations( DispatchEvents(); RunTasks(); ExecuteCallbacks(monotonic_time_now); + next_frame_has_pending_raf_ = HasCallback(); ScheduleAnimationIfNeeded(); } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationController.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationController.h index 472bf5536b..6cada56bb3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationController.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationController.h @@ -81,6 +81,9 @@ class CORE_EXPORT ScriptedAnimationController void DispatchEventsAndCallbacksForPrinting(); + bool CurrentFrameHadRAF() const { return current_frame_had_raf_; } + bool NextFrameHasPendingRAF() const { return next_frame_has_pending_raf_; } + private: explicit ScriptedAnimationController(Document*); @@ -104,6 +107,10 @@ class CORE_EXPORT ScriptedAnimationController using MediaQueryListListeners = HeapListHashSet>; MediaQueryListListeners media_query_list_listeners_; + + // Used for animation metrics; see cc::CompositorTimingHistory::DidDraw. + bool current_frame_had_raf_; + bool next_frame_has_pending_raf_; }; } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationControllerTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationControllerTest.cpp index 97dad8d772..fef6985528 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationControllerTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedAnimationControllerTest.cpp @@ -183,4 +183,26 @@ TEST_F(ScriptedAnimationControllerTest, RegisterCallbackAndEnqueueTask) { EXPECT_EQ(1, observer.Order()[1]); } +TEST_F(ScriptedAnimationControllerTest, TestHasCallback) { + TaskOrderObserver observer; + + Controller().RegisterCallback(new RunTaskCallback(observer.CreateTask(1))); + EXPECT_TRUE(Controller().HasCallback()); + + Controller().CancelCallback(1); + EXPECT_FALSE(Controller().HasCallback()); + + Controller().RegisterCallback(new RunTaskCallback(observer.CreateTask(1))); + Controller().RegisterCallback(new RunTaskCallback(observer.CreateTask(2))); + EXPECT_TRUE(Controller().HasCallback()); + + Controller().CancelCallback(1); + EXPECT_TRUE(Controller().HasCallback()); + + // Servicing the scripted animations should call the remaining callback and + // clear it. + Controller().ServiceScriptedAnimations(0); + EXPECT_FALSE(Controller().HasCallback()); +} + } // namespace blink diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedIdleTaskController.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedIdleTaskController.cpp index ac6c55cadc..620398d353 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedIdleTaskController.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedIdleTaskController.cpp @@ -222,11 +222,6 @@ void ScriptedIdleTaskController::RunCallback( double allotted_time_millis = std::max((deadline_seconds - CurrentTimeTicksInSeconds()) * 1000, 0.0); - DEFINE_STATIC_LOCAL( - CustomCountHistogram, idle_callback_deadline_histogram, - ("WebCore.ScriptedIdleTaskController.IdleCallbackDeadline", 0, 50, 50)); - idle_callback_deadline_histogram.Count(allotted_time_millis); - probe::AsyncTask async_task(GetExecutionContext(), idle_task); probe::UserCallback probe(GetExecutionContext(), "requestIdleCallback", AtomicString(), true); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedIdleTaskControllerTest.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedIdleTaskControllerTest.cpp index 2f5547057c..24b75ddf32 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedIdleTaskControllerTest.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ScriptedIdleTaskControllerTest.cpp @@ -24,9 +24,10 @@ class MockScriptedIdleTaskControllerScheduler final : public WebScheduler { ~MockScriptedIdleTaskControllerScheduler() override = default; // WebScheduler implementation: - WebTaskRunner* TimerTaskRunner() override { return nullptr; } - WebTaskRunner* CompositorTaskRunner() override { return nullptr; } - WebTaskRunner* V8TaskRunner() override { return nullptr; } + base::SingleThreadTaskRunner* CompositorTaskRunner() override { + return nullptr; + } + base::SingleThreadTaskRunner* V8TaskRunner() override { return nullptr; } void Shutdown() override {} bool ShouldYieldForHighPriorityWork() override { return should_yield_; } bool CanExceedIdleDeadlineIfRequired() override { return false; } @@ -49,6 +50,10 @@ class MockScriptedIdleTaskControllerScheduler final : public WebScheduler { void RemovePendingNavigation( scheduler::RendererScheduler::NavigatingFrameType) override {} + base::TimeTicks MonotonicallyIncreasingVirtualTime() const override { + return base::TimeTicks(); + } + void RunIdleTask() { std::move(idle_task_).Run(0); } bool HasIdleTask() const { return !!idle_task_; } diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SecurityContext.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SecurityContext.cpp index 844cb60bcc..55c838e427 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SecurityContext.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SecurityContext.cpp @@ -105,23 +105,6 @@ String SecurityContext::addressSpaceForBindings() const { return "public"; } -// Enforces the given suborigin as part of the security origin for this -// security context. |name| must not be empty, although it may be null. A null -// name represents a lack of a suborigin. -// See: https://w3c.github.io/webappsec-suborigins/index.html -void SecurityContext::EnforceSuborigin(const Suborigin& suborigin) { - if (!RuntimeEnabledFeatures::SuboriginsEnabled()) - return; - - DCHECK(!suborigin.GetName().IsEmpty()); - DCHECK(RuntimeEnabledFeatures::SuboriginsEnabled()); - DCHECK(security_origin_.get()); - DCHECK(!security_origin_->HasSuborigin() || - security_origin_->GetSuborigin()->GetName() == suborigin.GetName()); - security_origin_->AddSuborigin(suborigin); - DidUpdateSecurityOrigin(); -} - void SecurityContext::InitializeFeaturePolicy( const ParsedFeaturePolicy& parsed_header, const ParsedFeaturePolicy& container_policy, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SecurityContext.h b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SecurityContext.h index 6bdafe29b7..3d8c31668b 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SecurityContext.h +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/SecurityContext.h @@ -29,17 +29,16 @@ #include "base/macros.h" #include "base/memory/scoped_refptr.h" -#include "common/net/ip_address_space.mojom-blink.h" #include "core/CoreExport.h" #include "core/dom/SandboxFlags.h" #include "platform/heap/Handle.h" -#include "platform/weborigin/Suborigin.h" #include "platform/wtf/HashSet.h" #include "platform/wtf/text/StringHash.h" #include "platform/wtf/text/WTFString.h" +#include "public/mojom/net/ip_address_space.mojom-blink.h" #include "public/platform/WebInsecureRequestPolicy.h" #include "public/platform/WebURLRequest.h" -#include "third_party/WebKit/common/feature_policy/feature_policy.h" +#include "third_party/WebKit/public/common/feature_policy/feature_policy.h" #include @@ -101,8 +100,6 @@ class CORE_EXPORT SecurityContext : public GarbageCollectedMixin { return insecure_request_policy_; } - void EnforceSuborigin(const Suborigin&); - FeaturePolicy* GetFeaturePolicy() const { return feature_policy_.get(); } void InitializeFeaturePolicy(const ParsedFeaturePolicy& parsed_header, const ParsedFeaturePolicy& container_policy, diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ShadowDOMV0Test.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ShadowDOMV0Test.cpp index 30f6d450f5..49a99c21da 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ShadowDOMV0Test.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ShadowDOMV0Test.cpp @@ -5,7 +5,6 @@ #include "core/dom/ElementShadow.h" #include "core/dom/ElementShadowV0.h" #include "core/html/HTMLBodyElement.h" -#include "core/testing/sim/SimDisplayItemList.h" #include "core/testing/sim/SimRequest.h" #include "core/testing/sim/SimTest.h" @@ -36,8 +35,8 @@ class ShadowDOMVTest : public SimTest {}; TEST_F(ShadowDOMVTest, FeatureSetId) { LoadURL("about:blank"); - auto* host = GetDocument().createElement("div"); - auto* content = GetDocument().createElement("content"); + auto* host = GetDocument().CreateRawElement(HTMLNames::divTag); + auto* content = GetDocument().CreateRawElement(HTMLNames::contentTag); content->setAttribute("select", "#foo"); host->CreateShadowRootInternal().AppendChild(content); EXPECT_TRUE(HasSelectorForIdInShadow(host, "foo")); @@ -53,8 +52,8 @@ TEST_F(ShadowDOMVTest, FeatureSetId) { TEST_F(ShadowDOMVTest, FeatureSetClassName) { LoadURL("about:blank"); - auto* host = GetDocument().createElement("div"); - auto* content = GetDocument().createElement("content"); + auto* host = GetDocument().CreateRawElement(HTMLNames::divTag); + auto* content = GetDocument().CreateRawElement(HTMLNames::contentTag); content->setAttribute("select", ".foo"); host->CreateShadowRootInternal().AppendChild(content); EXPECT_TRUE(HasSelectorForClassInShadow(host, "foo")); @@ -70,8 +69,8 @@ TEST_F(ShadowDOMVTest, FeatureSetClassName) { TEST_F(ShadowDOMVTest, FeatureSetAttributeName) { LoadURL("about:blank"); - auto* host = GetDocument().createElement("div"); - auto* content = GetDocument().createElement("content"); + auto* host = GetDocument().CreateRawElement(HTMLNames::divTag); + auto* content = GetDocument().CreateRawElement(HTMLNames::contentTag); content->setAttribute("select", "div[foo]"); host->CreateShadowRootInternal().AppendChild(content); EXPECT_TRUE(HasSelectorForAttributeInShadow(host, "foo")); @@ -87,8 +86,8 @@ TEST_F(ShadowDOMVTest, FeatureSetAttributeName) { TEST_F(ShadowDOMVTest, FeatureSetMultipleSelectors) { LoadURL("about:blank"); - auto* host = GetDocument().createElement("div"); - auto* content = GetDocument().createElement("content"); + auto* host = GetDocument().CreateRawElement(HTMLNames::divTag); + auto* content = GetDocument().CreateRawElement(HTMLNames::contentTag); content->setAttribute("select", "#foo,.bar,div[baz]"); host->CreateShadowRootInternal().AppendChild(content); EXPECT_TRUE(HasSelectorForIdInShadow(host, "foo")); @@ -104,7 +103,7 @@ TEST_F(ShadowDOMVTest, FeatureSetMultipleSelectors) { TEST_F(ShadowDOMVTest, FeatureSetSubtree) { LoadURL("about:blank"); - auto* host = GetDocument().createElement("div"); + auto* host = GetDocument().CreateRawElement(HTMLNames::divTag); host->CreateShadowRootInternal().SetInnerHTMLFromString(R"HTML(
@@ -122,12 +121,12 @@ TEST_F(ShadowDOMVTest, FeatureSetSubtree) { TEST_F(ShadowDOMVTest, FeatureSetMultipleShadowRoots) { LoadURL("about:blank"); - auto* host = GetDocument().createElement("div"); + auto* host = GetDocument().CreateRawElement(HTMLNames::divTag); auto& host_shadow = host->CreateShadowRootInternal(); host_shadow.SetInnerHTMLFromString(""); - auto* child = GetDocument().createElement("div"); + auto* child = GetDocument().CreateRawElement(HTMLNames::divTag); auto& child_root = child->CreateShadowRootInternal(); - auto* child_content = GetDocument().createElement("content"); + auto* child_content = GetDocument().CreateRawElement(HTMLNames::contentTag); child_content->setAttribute("select", "#bar"); child_root.AppendChild(child_content); host_shadow.AppendChild(child); diff --git a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ShadowRoot.cpp b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ShadowRoot.cpp index bcbd02b91e..3318cdded3 100644 --- a/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ShadowRoot.cpp +++ b/lgpl/sources/chromium/src/third_party/WebKit/Source/core/dom/ShadowRoot.cpp @@ -69,28 +69,6 @@ ShadowRoot::ShadowRoot(Document& document, ShadowRootType type) ShadowRoot::~ShadowRoot() = default; -ShadowRoot* ShadowRoot::YoungerShadowRoot() const { - if (GetType() == ShadowRootType::V0 && shadow_root_rare_data_v0_) - return shadow_root_rare_data_v0_->YoungerShadowRoot(); - return nullptr; -} - -ShadowRoot* ShadowRoot::OlderShadowRoot() const { - if (GetType() == ShadowRootType::V0 && shadow_root_rare_data_v0_) - return shadow_root_rare_data_v0_->OlderShadowRoot(); - return nullptr; -} - -void ShadowRoot::SetYoungerShadowRoot(ShadowRoot& root) { - DCHECK_EQ(GetType(), ShadowRootType::V0); - EnsureShadowRootRareDataV0().SetYoungerShadowRoot(root); -} - -void ShadowRoot::SetOlderShadowRoot(ShadowRoot& root) { - DCHECK_EQ(GetType(), ShadowRootType::V0); - EnsureShadowRootRareDataV0().SetOlderShadowRoot(root); -} - SlotAssignment& ShadowRoot::EnsureSlotAssignment() { if (!slot_assignment_) slot_assignment_ = SlotAssignment::Create(*this); @@ -115,9 +93,8 @@ void ShadowRoot::DidChangeHostChildSlotName(const AtomicString& old_value, slot_assignment_->DidChangeHostChildSlotName(old_value, new_value); } -Node* ShadowRoot::cloneNode(bool, ExceptionState& exception_state) { - exception_state.ThrowDOMException(kNotSupportedError, - "ShadowRoot nodes are not clonable."); +Node* ShadowRoot::Clone(Document&, CloneChildrenFlag) const { + NOTREACHED() << "ShadowRoot nodes are not clonable."; return nullptr; } @@ -201,7 +178,7 @@ Node::InsertionNotificationRequest ShadowRoot::InsertedInto( ContainerNode* insertion_point) { DocumentFragment::InsertedInto(insertion_point); - if (!insertion_point->isConnected() || !IsOldest()) + if (!insertion_point->isConnected()) return kInsertionDone; // FIXME: When parsing