-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=274038 Speculative revert was not correct. Performance regression was introduced by different change. Relanding Reverted changeset: "Unreviewed, reverting 278591@main." https://bugs.webkit.org/show_bug.cgi?id=274023 https://commits.webkit.org/278631@main Canonical link: https://commits.webkit.org/278657@main
- Loading branch information
1 parent
1a3a465
commit a6189e1
Showing
38 changed files
with
554 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
LayoutTests/http/tests/site-isolation/scrolling/multiple-root-frames-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Verifies scrolling tree for page with multiple iframes in the same process. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
|
||
(scrolling tree | ||
(frame scrolling node | ||
(scrollable area size width=800 height=600) | ||
(total content size width=800 height=600) | ||
(last committed scroll position (0,0)) | ||
(scrollable area parameters | ||
(horizontal scroll elasticity 2) | ||
(vertical scroll elasticity 2) | ||
(horizontal scrollbar mode 0) | ||
(vertical scrollbar mode 0)) | ||
(layout viewport (0,0) width=800 height=600) | ||
(min layoutViewport origin (0,0)) | ||
(max layoutViewport origin (0,0)) | ||
(behavior for fixed 1) | ||
(frame hosting node | ||
(has hosting context identifier ) | ||
(frame scrolling node | ||
(scrollable area size width=300 height=400) | ||
(total content size width=300 height=400) | ||
(last committed scroll position (0,0)) | ||
(scrollable area parameters | ||
(horizontal scroll elasticity 0) | ||
(vertical scroll elasticity 0) | ||
(horizontal scrollbar mode 0) | ||
(vertical scrollbar mode 0)) | ||
(layout viewport (0,0) width=300 height=400) | ||
(min layoutViewport origin (0,0)) | ||
(max layoutViewport origin (0,0)) | ||
(behavior for fixed 1))) | ||
(frame hosting node | ||
(has hosting context identifier ) | ||
(frame scrolling node | ||
(scrollable area size width=200 height=100) | ||
(total content size width=200 height=100) | ||
(last committed scroll position (0,0)) | ||
(scrollable area parameters | ||
(horizontal scroll elasticity 0) | ||
(vertical scroll elasticity 0) | ||
(horizontal scrollbar mode 0) | ||
(vertical scrollbar mode 0)) | ||
(layout viewport (0,0) width=200 height=100) | ||
(min layoutViewport origin (0,0)) | ||
(max layoutViewport origin (0,0)) | ||
(behavior for fixed 1))))) | ||
|
27 changes: 27 additions & 0 deletions
27
LayoutTests/http/tests/site-isolation/scrolling/multiple-root-frames.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!-- webkit-test-runner [ SiteIsolationEnabled=true ] --> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
<script src="/js-test-resources/ui-helper.js"></script> | ||
<body> | ||
<pre id="scrollingTree"></pre> | ||
</body> | ||
<script> | ||
description("Verifies scrolling tree for page with multiple iframes in the same process."); | ||
jsTestIsAsync = true; | ||
|
||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
} | ||
|
||
window.addEventListener('load', async () => { | ||
if (!window.internals) | ||
return | ||
|
||
await UIHelper.ensurePresentationUpdate(); | ||
document.getElementById('scrollingTree').innerText = await UIHelper.getScrollingTree(); | ||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
}, false); | ||
</script> | ||
<iframe width="300" height="400" src="http://localhost:8000/site-isolation/scrolling/resources/empty-iframe.html"></iframe> | ||
<iframe width="200" height="100" src="http://localhost:8000/site-isolation/scrolling/resources/empty-iframe.html"></iframe> |
36 changes: 36 additions & 0 deletions
36
LayoutTests/http/tests/site-isolation/scrolling/remove-root-frame-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Verifies that root frames are successfully removed from scrolling trees when removed from the DOM. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
|
||
(scrolling tree | ||
(frame scrolling node | ||
(scrollable area size width=800 height=600) | ||
(total content size width=800 height=600) | ||
(last committed scroll position (0,0)) | ||
(scrollable area parameters | ||
(horizontal scroll elasticity 2) | ||
(vertical scroll elasticity 2) | ||
(horizontal scrollbar mode 0) | ||
(vertical scrollbar mode 0)) | ||
(layout viewport (0,0) width=800 height=600) | ||
(min layoutViewport origin (0,0)) | ||
(max layoutViewport origin (0,0)) | ||
(behavior for fixed 1) | ||
(frame hosting node | ||
(has hosting context identifier ) | ||
(frame scrolling node | ||
(scrollable area size width=300 height=400) | ||
(total content size width=300 height=400) | ||
(last committed scroll position (0,0)) | ||
(scrollable area parameters | ||
(horizontal scroll elasticity 0) | ||
(vertical scroll elasticity 0) | ||
(horizontal scrollbar mode 0) | ||
(vertical scrollbar mode 0)) | ||
(layout viewport (0,0) width=300 height=400) | ||
(min layoutViewport origin (0,0)) | ||
(max layoutViewport origin (0,0)) | ||
(behavior for fixed 1))))) | ||
|
30 changes: 30 additions & 0 deletions
30
LayoutTests/http/tests/site-isolation/scrolling/remove-root-frame.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!-- webkit-test-runner [ SiteIsolationEnabled=true ] --> | ||
<script src="/js-test-resources/js-test.js"></script> | ||
<script src="/js-test-resources/ui-helper.js"></script> | ||
<body> | ||
<pre id="scrollingTree"></pre> | ||
</body> | ||
<script> | ||
description("Verifies that root frames are successfully removed from scrolling trees when removed from the DOM."); | ||
jsTestIsAsync = true; | ||
|
||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
} | ||
|
||
window.addEventListener('load', async () => { | ||
if (!window.internals) | ||
return | ||
frameToRemove.parentElement.removeChild(frameToRemove); | ||
if (window.GCController) | ||
GCController.collect(); | ||
document.getElementById('scrollingTree').innerText = await UIHelper.getScrollingTree(); | ||
setTimeout(function() { | ||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
}, 500); | ||
}, false); | ||
</script> | ||
<iframe width="300" height="400" src="http://localhost:8000/site-isolation/scrolling/resources/empty-iframe.html"></iframe> | ||
<iframe width="200" height="100" id=frameToRemove src="http://localhost:8000/site-isolation/scrolling/resources/empty-iframe.html"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
* Copyright (C) 2024 Apple Inc. All Rights Reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <variant> | ||
#include <wtf/HashMap.h> | ||
#include <wtf/ScopedLambda.h> | ||
#include <wtf/StdLibExtras.h> | ||
|
||
namespace WTF { | ||
|
||
// This is a map optimized for holding 0 or 1 items with no hashing or allocations in those cases. | ||
template<typename Key, typename Value> | ||
class SmallMap { | ||
public: | ||
using Pair = KeyValuePair<Key, Value>; | ||
using Map = HashMap<Key, Value>; | ||
using Storage = std::variant<std::monostate, Pair, Map>; | ||
|
||
static_assert(sizeof(Pair) <= 4 * sizeof(uint64_t), "Don't use SmallMap with large types. It probably wastes memory."); | ||
|
||
Value& ensure(const Key& key, const auto& functor) | ||
{ | ||
ASSERT(Map::isValidKey(key)); | ||
if (std::holds_alternative<std::monostate>(m_storage)) { | ||
m_storage = Pair { key, functor() }; | ||
return std::get<Pair>(m_storage).value; | ||
} | ||
if (auto* pair = std::get_if<Pair>(&m_storage)) { | ||
if (pair->key == key) | ||
return pair->value; | ||
Map map; | ||
map.add(WTFMove(pair->key), WTFMove(pair->value)); | ||
m_storage = WTFMove(map); | ||
return std::get<Map>(m_storage).add(key, functor()).iterator->value; | ||
} | ||
return std::get<Map>(m_storage).ensure(key, functor).iterator->value; | ||
} | ||
|
||
void remove(const Key& key) | ||
{ | ||
ASSERT(Map::isValidKey(key)); | ||
if (auto* pair = std::get_if<Pair>(&m_storage)) { | ||
if (pair->key == key) | ||
m_storage = std::monostate { }; | ||
} else if (auto* map = std::get_if<Map>(&m_storage)) | ||
map->remove(key); | ||
} | ||
|
||
const Value* get(const Key& key) const | ||
{ | ||
ASSERT(Map::isValidKey(key)); | ||
if (auto* pair = std::get_if<Pair>(&m_storage)) { | ||
if (pair->key == key) | ||
return std::addressof(pair->value); | ||
} else if (auto* map = std::get_if<Map>(&m_storage)) { | ||
if (auto it = map->find(key); it != map->end()) | ||
return std::addressof(it->value); | ||
} | ||
return nullptr; | ||
} | ||
|
||
void forEach(const auto& callback) const | ||
{ | ||
switchOn(m_storage, [&] (const std::monostate&) { | ||
}, [&] (const Pair& pair) { | ||
callback(pair.key, pair.value); | ||
}, [&] (const Map& map) { | ||
for (auto& [key, value] : map) | ||
callback(key, value); | ||
}); | ||
} | ||
|
||
size_t size() const | ||
{ | ||
return switchOn(m_storage, [&] (const std::monostate&) { | ||
return 0u; | ||
}, [&] (const Pair&) { | ||
return 1u; | ||
}, [&] (const Map& map) { | ||
return map.size(); | ||
}); | ||
} | ||
|
||
const Storage& rawStorage() const { return m_storage; } | ||
|
||
private: | ||
Storage m_storage; | ||
}; | ||
|
||
} // namespace WTF | ||
|
||
using WTF::SmallMap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.