Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add a new DrawDecomposedGlyphs display list item to avoid repeatedly …
…sending glyphs when using the GlyphDisplayListCache

https://bugs.webkit.org/show_bug.cgi?id=240497
<rdar://93387615>

Reviewed by Simon Fraser.

The GlyphDisplayListCache is used to record a display list for
frequently painting text content. With GPU Process DOM rendering, there
is significant overhead in sending the contents of these display lists
over IPC. The contents of these display lists don't change if the text
content in the document doesn't change, so we could greatly reduce the
overhead by treating the data inside a display list item for glyph
drawing as a remote resource.

This commit adds:

* a new display list item, DrawDecomposedGlyphs, to represent drawing
  a glyph list resource
* a new class, DecomposedGlyphs, which is the resource type
* a new struct, PositionedGlyphs, to provide a common place for the
  glyph drawing fields (the vector of glyph IDs, the anchor position,
  etc.) to live, so that we don't have duplication between
  DisplayList::DrawGlyphs and DecomposedGlyphs

So that a DrawDecomposedGlyphs command can be replayed from a
GlyphDisplayListCache's in-memory display list and recorded to a
RemoteDisplayListRecorder, the GraphicsContext API gains a new
drawDecomposedGlyphs function.

A new argument to the DisplayList::RecordImpl constructor (and the
DrawGlyphsRecorder) is added to represent how to record drawText
commands:

* DrawGlyphsMode::Normal, which records each GraphicsContext::drawText
  call with a single DrawText command
* DrawGlyphsMode::DeconstructToDrawGlyphsCommands, which ensures
  different text layers get deconstructed into separate DrawText
  commands
* DrawGlyphsMode::DeconstructToDrawDecomposedGlyphsCommands, which
  ensures different text layers get desconstructed into separate
  DrawDecomposedGlyphs commands

FontCascade::displayListForTextRun is updated to use that last value.

Additionally, GlyphDisplayListCache is extended to cache display lists
keyed off TextRun values. This allows sharing of the same cached display
list between different elements on the page that have the same text
content.

This sharing would not be valid if the two elements have different
values for the color property, and the text contains COLRv0 glyphs that
alternate painting of specific colors and the color fill color, since
the recording would incorrectly record a setFillBrush command
corresponding to the first element's fill color. Rather than extend the
glyph recorder to parameterize the current fill (and stroke) colors, we
detect when outlines are drawn with colors other than the context's
initial colors, and prevent sharing. This is done by checking whether
the recorded display list contains items that aren't known to be safe
for sharing.

Similarly, if the sharing would not be valid if the contains bitmap
images (like those from emoji fonts) or SVG glyphs, both of which are
captured as DrawNativeImage commands, if the text is drawn at different
scales. This is because the size of the images is dependent on the
scale. We detect and prevent reuse across different text runs if the
scale is different, by checking the recorded display list for
DrawNativeImage commands and by storing the context scale on the
GlyphDisplayListCache::Entry.

* LayoutTests/fast/text/glyph-display-lists/glyph-display-list-colr-unshared-expected.txt: Added.
* LayoutTests/fast/text/glyph-display-lists/glyph-display-list-colr-unshared.html: Added.
* LayoutTests/fast/text/glyph-display-lists/glyph-display-list-scaled-unshared-expected.txt: Added.
* LayoutTests/fast/text/glyph-display-lists/glyph-display-list-scaled-unshared.html: Added.
* LayoutTests/fast/text/glyph-display-lists/glyph-display-list-shadow-unshared-expected.txt: Added.
* LayoutTests/fast/text/glyph-display-lists/glyph-display-list-shadow-unshared.html: Added.
* LayoutTests/fast/text/glyph-display-lists/glyph-display-list-shared-expected.txt: Added.
* LayoutTests/fast/text/glyph-display-lists/glyph-display-list-shared.html: Added.
* LayoutTests/fast/text/glyph-display-lists/glyph-display-list-svg-unshared-expected.txt: Added.
* LayoutTests/fast/text/glyph-display-lists/glyph-display-list-svg-unshared.html: Added.
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp:
(WebCore::BifurcatedGraphicsContext::drawDecomposedGlyphs):
* Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h:
* Source/WebCore/platform/graphics/DecomposedGlyphs.cpp: Added.
(WebCore::DecomposedGlyphs::create):
(WebCore::DecomposedGlyphs::DecomposedGlyphs):
(WebCore::m_renderingResourceIdentifier):
* Source/WebCore/platform/graphics/DecomposedGlyphs.h: Added.
(WebCore::DecomposedGlyphs::positionedGlyphs const):
(WebCore::DecomposedGlyphs::bounds const):
(WebCore::DecomposedGlyphs::addObserver):
(WebCore::DecomposedGlyphs::removeObserver):
(WebCore::DecomposedGlyphs::renderingResourceIdentifier const):
* Source/WebCore/platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::displayListForTextRun const):
* Source/WebCore/platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::drawDecomposedGlyphs):
* Source/WebCore/platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContext::drawGlyphsAndCacheResources):
(WebCore::GraphicsContext::drawGlyphsAndCacheFont): Deleted.
* Source/WebCore/platform/graphics/NullGraphicsContext.h:
* Source/WebCore/platform/graphics/PositionedGlyphs.cpp: Copied from Source/WebCore/platform/graphics/win/DrawGlyphsRecorderWin.cpp.
(WebCore::PositionedGlyphs::computeBounds const):
* Source/WebCore/platform/graphics/PositionedGlyphs.h: Added.
(WebCore::PositionedGlyphs::PositionedGlyphs):
(WebCore::PositionedGlyphs::encode const):
(WebCore::PositionedGlyphs::decode):
* Source/WebCore/platform/graphics/TextRun.cpp:
(WebCore::operator<<):
* Source/WebCore/platform/graphics/TextRun.h:
(WebCore::TextRun::TextRun):
(WebCore::TextRun::isHashTableEmptyValue const):
(WebCore::TextRun::isHashTableDeletedValue const):
(WebCore::TextRun::cloneForStorage const):
* Source/WebCore/platform/graphics/TextRunHash.h: Added.
(WebCore::add):
(WebCore::TextRun::operator== const):
(WebCore::TextRunHash::hash):
(WebCore::TextRunHash::equal):
(WTF::HashTraits<WebCore::TextRun>::isDeletedValue):
(WTF::HashTraits<WebCore::TextRun>::isEmptyValue):
(WTF::HashTraits<WebCore::TextRun>::constructDeletedValue):
(WTF::HashTraits<WebCore::TextRun>::emptyValue):
* Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContextCairo::drawDecomposedGlyphs):
* Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.h:
* Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp:
(WebCore::DrawGlyphsRecorder::createInternalContext):
(WebCore::DrawGlyphsRecorder::updateCTM):
(WebCore::DrawGlyphsRecorder::recordDrawGlyphs):
* Source/WebCore/platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::DisplayList::description const):
(WebCore::DisplayList::DisplayList::append):
* Source/WebCore/platform/graphics/displaylists/DisplayList.h:
(WebCore::DisplayList::DisplayList::cacheDecomposedGlyphs):
* Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemHandle::apply):
(WebCore::DisplayList::ItemHandle::destroy):
(WebCore::DisplayList::ItemHandle::safeCopy const):
* Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp:
(WebCore::DisplayList::sizeOfItemInBytes):
(WebCore::DisplayList::isDrawingItem):
(WebCore::DisplayList::isInlineItem):
* Source/WebCore/platform/graphics/displaylists/DisplayListItemType.h:
* Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::DrawGlyphs::DrawGlyphs):
(WebCore::DisplayList::m_bounds):
(WebCore::DisplayList::DrawGlyphs::apply const):
(WebCore::DisplayList::DrawDecomposedGlyphs::apply const):
(WebCore::DisplayList::operator<<):
(WebCore::DisplayList::dumpItem):
(WebCore::DisplayList::dumpItemHandle):
(WebCore::DisplayList::DrawGlyphs::computeBounds): Deleted.
* Source/WebCore/platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::DrawGlyphs::localAnchor const):
(WebCore::DisplayList::DrawGlyphs::anchorPoint const):
(WebCore::DisplayList::DrawGlyphs::glyphs const):
(WebCore::DisplayList::DrawGlyphs::encode const):
(WebCore::DisplayList::DrawGlyphs::decode):
(WebCore::DisplayList::DrawDecomposedGlyphs::DrawDecomposedGlyphs):
(WebCore::DisplayList::DrawDecomposedGlyphs::fontIdentifier const):
(WebCore::DisplayList::DrawDecomposedGlyphs::decomposedGlyphsIdentifier const):
(WebCore::DisplayList::DrawDecomposedGlyphs::globalBounds const):
(WebCore::DisplayList::DrawDecomposedGlyphs::localBounds const):
* Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::Recorder):
(WebCore::DisplayList::Recorder::shouldDeconstructDrawGlyphs const):
(WebCore::DisplayList::Recorder::drawGlyphs):
(WebCore::DisplayList::Recorder::drawDecomposedGlyphs):
(WebCore::DisplayList::Recorder::drawGlyphsAndCacheResources):
(WebCore::DisplayList::Recorder::drawGlyphsAndCacheFont): Deleted.
* Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h:
* Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp:
(WebCore::DisplayList::RecorderImpl::RecorderImpl):
(WebCore::DisplayList::RecorderImpl::recordDrawDecomposedGlyphs):
(WebCore::DisplayList::RecorderImpl::recordResourceUse):
* Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h:
* Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp:
(WebCore::DisplayList::applyDrawDecomposedGlyphs):
(WebCore::DisplayList::Replayer::applyItem):
(WebCore::DisplayList::Replayer::replay):
* Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h:
* Source/WebCore/platform/graphics/displaylists/DisplayListResourceHeap.h:
(WebCore::DisplayList::LocalResourceHeap::add):
* Source/WebCore/platform/graphics/harfbuzz/DrawGlyphsRecorderHarfBuzz.cpp:
(WebCore::DrawGlyphsRecorder::drawGlyphs):
* Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp:
(Nicosia::CairoOperationRecorder::drawDecomposedGlyphs):
* Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h:
* Source/WebCore/platform/graphics/win/DrawGlyphsRecorderWin.cpp:
(WebCore::DrawGlyphsRecorder::drawGlyphs):
* Source/WebCore/platform/text/TextDirection.h:
(WebCore::operator<<):
* Source/WebCore/platform/text/TextFlags.cpp:
(WebCore::operator<<):
* Source/WebCore/platform/text/TextFlags.h:
(WebCore::ExpansionBehavior::operator== const):
* Source/WebCore/rendering/GlyphDisplayListCache.cpp: Added.
(WebCore::GlyphDisplayListCacheBase::displayListSharing):
* Source/WebCore/rendering/GlyphDisplayListCache.h:
(WebCore::GlyphDisplayListCacheBase::size const):
(WebCore::GlyphDisplayListCacheBase::sizeInBytes const):
(WebCore::GlyphDisplayListCacheBase::Entry::create):
(WebCore::GlyphDisplayListCacheBase::Entry::displayList):
(WebCore::GlyphDisplayListCacheBase::Entry::relevantScaleFactor const):
(WebCore::GlyphDisplayListCacheBase::Entry::Entry):
(WebCore::GlyphDisplayListCache::get):
(WebCore::GlyphDisplayListCache::getIfExists):
(WebCore::GlyphDisplayListCache::remove):
(WebCore::GlyphDisplayListCache::clear):
(WebCore::GlyphDisplayListCache::size const): Deleted.
(WebCore::GlyphDisplayListCache::sizeInBytes const): Deleted.
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
* Source/WebCore/rendering/TextPainter.cpp:
* Source/WebCore/testing/Internals.cpp:
(WebCore::toDisplayListFlags):
(WebCore::Internals::displayListForElement):
(WebCore::Internals::replayDisplayListForElement):
(WebCore::Internals::cachedGlyphDisplayListsForTextNode):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
* Source/WebKit/GPUProcess/graphics/QualifiedResourceHeap.h:
(WebKit::QualifiedResourceHeap::add):
(WebKit::QualifiedResourceHeap::getDecomposedGlyphs const):
(WebKit::QualifiedResourceHeap::removeDecomposedGlyphs):
(WebKit::QualifiedResourceHeap::checkInvariants const):
* Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp:
(WebKit::RemoteDisplayListRecorder::drawDecomposedGlyphs):
(WebKit::RemoteDisplayListRecorder::drawDecomposedGlyphsWithQualifiedIdentifiers):
* Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h:
* Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.messages.in:
* Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::cacheFontWithQualifiedIdentifier):
(WebKit::RemoteRenderingBackend::cacheDecomposedGlyphs):
(WebKit::RemoteRenderingBackend::cacheDecomposedGlyphsWithQualifiedIdentifier):
* Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h:
* Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in:
* Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp:
(WebKit::RemoteResourceCache::cacheDecomposedGlyphs):
(WebKit::RemoteResourceCache::cachedDecomposedGlyphs const):
(WebKit::RemoteResourceCache::releaseRemoteResource):
* Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<DecomposedGlyphs>::encode):
(IPC::ArgumentCoder<DecomposedGlyphs>::decode):
* Source/WebKit/Shared/WebCoreArgumentCoders.h:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp:
(WebKit::RemoteDisplayListRecorderProxy::RemoteDisplayListRecorderProxy):
(WebKit::RemoteDisplayListRecorderProxy::recordDrawDecomposedGlyphs):
(WebKit::RemoteDisplayListRecorderProxy::recordResourceUse):
* Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h:
* Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
(WebKit::RemoteRenderingBackendProxy::cacheDecomposedGlyphs):
* Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
* Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp:
(WebKit::RemoteResourceCacheProxy::~RemoteResourceCacheProxy):
(WebKit::RemoteResourceCacheProxy::recordDecomposedGlyphsUse):
(WebKit::RemoteResourceCacheProxy::releaseDecomposedGlyphs):
(WebKit::RemoteResourceCacheProxy::clearDecomposedGlyphsMap):
(WebKit::RemoteResourceCacheProxy::remoteResourceCacheWasDestroyed):
* Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h:

Canonical link: https://commits.webkit.org/251324@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295278 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
heycam committed Jun 6, 2022
1 parent ee85d8f commit 4556b07
Show file tree
Hide file tree
Showing 84 changed files with 1,429 additions and 220 deletions.
@@ -1,6 +1,3 @@

(draw-glyphs
(local-anchor (0,0))
(anchor-point (0,0))
(length 9) extent at (0,0) size 0x0)
(draw-decomposed-glyphs extent at (0,0) size 0x0)

@@ -0,0 +1 @@
PASS: Display lists do not match.
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<meta charset=utf-8>
<script>
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.dumpAsText();
}
if (window.internals)
internals.setForceUseGlyphDisplayListForTesting(true);
</script>
<body onload="run()">
<style>
@font-face {
font-family: "Ahem COLR";
src: url("../resources/Ahem-COLR.ttf") format("truetype");
}
span { font: 48px Ahem COLR; }
</style>
<div id=container>
<span id=first>A</span>
<span id=second>A</span>
</div>
<pre id=log></pre>
<script>
function run() {
requestAnimationFrame(function() {
requestAnimationFrame(function() {
if (window.internals) {
let firstDisplayListWithResourceIDs = internals.cachedGlyphDisplayListsForTextNode(first.firstChild, internals.DISPLAY_LIST_INCLUDE_RESOURCE_IDENTIFIERS);
let secondDisplayListWithResourceIDs = internals.cachedGlyphDisplayListsForTextNode(second.firstChild, internals.DISPLAY_LIST_INCLUDE_RESOURCE_IDENTIFIERS);
if (firstDisplayListWithResourceIDs == secondDisplayListWithResourceIDs)
log.textContent = "FAIL: Display lists match but shouldn't.\n" + internals.cachedGlyphDisplayListsForTextNode(first.firstChild);
else
log.textContent = "PASS: Display lists do not match.";
internals.setForceUseGlyphDisplayListForTesting(false);
container.remove();
}
if (window.testRunner)
testRunner.notifyDone();
});
});
}
</script>
@@ -0,0 +1 @@
PASS: Display lists do not match.
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<meta charset=utf-8>
<script>
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.dumpAsText();
}
if (window.internals)
internals.setForceUseGlyphDisplayListForTesting(true);
</script>
<body onload="run()">
<style>
#container { margin: 3em; }
#container > span { position: absolute; padding: 3em; }
#first { transform: scale(1.5); }
#second { transform: scale(2); }
</style>
<div id=container>
<span id=first>Some 😀 text</span>
<span id=second>Some 😀 text</span>
</div>
<pre id=log></pre>
<script>
function run() {
requestAnimationFrame(function() {
requestAnimationFrame(function() {
if (window.internals) {
let firstDisplayListWithResourceIDs = internals.cachedGlyphDisplayListsForTextNode(first.firstChild, internals.DISPLAY_LIST_INCLUDE_RESOURCE_IDENTIFIERS);
let secondDisplayListWithResourceIDs = internals.cachedGlyphDisplayListsForTextNode(second.firstChild, internals.DISPLAY_LIST_INCLUDE_RESOURCE_IDENTIFIERS);
if (firstDisplayListWithResourceIDs == secondDisplayListWithResourceIDs)
log.textContent = "FAIL: Display lists match but shouldn't.\n" + internals.cachedGlyphDisplayListsForTextNode(first.firstChild);
else
log.textContent = "PASS: Display lists do not match.";
internals.setForceUseGlyphDisplayListForTesting(false);
container.remove();
}
if (window.testRunner)
testRunner.notifyDone();
});
});
}
</script>
@@ -0,0 +1 @@
PASS: Display lists do not match.
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<script>
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.dumpAsText();
}
if (window.internals)
internals.setForceUseGlyphDisplayListForTesting(true);
</script>
<body onload="run()">
<style>
#first, #second { text-shdaow: 5px 5px blue; }
</style>
<div id=container>
<span id=first>Some text</span>
<span id=second>Some text</span>
</div>
<pre id=log></pre>
<script>
function run() {
requestAnimationFrame(function() {
requestAnimationFrame(function() {
if (window.internals) {
let firstDisplayListWithResourceIDs = internals.cachedGlyphDisplayListsForTextNode(first.firstChild, internals.DISPLAY_LIST_INCLUDE_RESOURCE_IDENTIFIERS);
let secondDisplayListWithResourceIDs = internals.cachedGlyphDisplayListsForTextNode(second.firstChild, internals.DISPLAY_LIST_INCLUDE_RESOURCE_IDENTIFIERS);
if (firstDisplayListWithResourceIDs == secondDisplayListWithResourceIDs)
log.textContent = "FAIL: Display lists match but shouldn't.\n" + internals.cachedGlyphDisplayListsForTextNode(first.firstChild);
else
log.textContent = "PASS: Display lists do not match.";
internals.setForceUseGlyphDisplayListForTesting(false);
container.remove();
}
if (window.testRunner)
testRunner.notifyDone();
});
});
}
</script>
@@ -0,0 +1 @@
All display lists match.
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<script>
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.dumpAsText();
}
if (window.internals)
internals.setForceUseGlyphDisplayListForTesting(true);
</script>
<body onload="run()">
<div id=container>
<p style="color: red;">Some text</p>
<p style="color: orange;">Some text</p>
<p style="color: yellow;">Some text</p>
<p style="color: green;">Some text</p>
<p style="color: blue;">Some text</p>
<p style="color: indigo;">Some text</p>
<p style="color: violet;">Some text</p>
</div>
<pre id=log></pre>
<script>
function run() {
requestAnimationFrame(function() {
requestAnimationFrame(function() {
if (window.internals) {
let ps = container.querySelectorAll("p");
let displayList = internals.cachedGlyphDisplayListsForTextNode(ps[0].firstChild);
let displayListWithResourceIDs = internals.cachedGlyphDisplayListsForTextNode(ps[0].firstChild, internals.DISPLAY_LIST_INCLUDE_RESOURCE_IDENTIFIERS);
let mismatch = false;
for (let i = 1; i < ps.length; ++i) {
if (internals.cachedGlyphDisplayListsForTextNode(ps[i].firstChild, internals.DISPLAY_LIST_INCLUDE_RESOURCE_IDENTIFIERS) != displayListWithResourceIDs) {
log.textContent += `Display list for ps[${i}] does not match.\n`;
mismatch = true;
}
}
if (!mismatch)
log.textContent += "All display lists match.";
internals.setForceUseGlyphDisplayListForTesting(false);
container.remove();
}
if (window.testRunner)
testRunner.notifyDone();
});
});
}
</script>
@@ -0,0 +1 @@
PASS: Display lists do not match.
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<meta charset=utf-8>
<script>
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.dumpAsText();
}
if (window.internals)
internals.setForceUseGlyphDisplayListForTesting(true);
</script>
<body onload="run()">
<style>
@font-face {
font-family: "Ahem SVG";
src: url("../resources/Ahem-SVG.ttf") format("truetype");
}
span { font: 48px Ahem SVG; }
</style>
<div id=container>
<span id=first>A</span>
<span id=second>A</span>
</div>
<pre id=log></pre>
<script>
function run() {
requestAnimationFrame(function() {
requestAnimationFrame(function() {
if (window.internals) {
let firstDisplayListWithResourceIDs = internals.cachedGlyphDisplayListsForTextNode(first.firstChild, internals.DISPLAY_LIST_INCLUDE_RESOURCE_IDENTIFIERS);
let secondDisplayListWithResourceIDs = internals.cachedGlyphDisplayListsForTextNode(second.firstChild, internals.DISPLAY_LIST_INCLUDE_RESOURCE_IDENTIFIERS);
if (firstDisplayListWithResourceIDs == secondDisplayListWithResourceIDs)
log.textContent = "FAIL: Display lists match but shouldn't.\n" + internals.cachedGlyphDisplayListsForTextNode(first.firstChild);
else
log.textContent = "PASS: Display lists do not match.";
internals.setForceUseGlyphDisplayListForTesting(false);
container.remove();
}
if (window.testRunner)
testRunner.notifyDone();
});
});
}
</script>
8 changes: 8 additions & 0 deletions Source/WTF/wtf/PlatformHave.h
Expand Up @@ -1203,3 +1203,11 @@
#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 160000)
#define HAVE_DDRESULT_DISABLE_URL_SCHEME_CHECKING 1
#endif

#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000) \
|| (PLATFORM(MACCATALYST) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 160000) \
|| (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 160000) \
|| (PLATFORM(APPLETV) && __TV_OS_VERSION_MAX_ALLOWED >= 160000) \
|| (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 90000)
#define HAVE_CORE_TEXT_FIX_FOR_RADAR_93925620 1
#endif
2 changes: 2 additions & 0 deletions Source/WebCore/Headers.cmake
Expand Up @@ -1468,6 +1468,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
platform/graphics/ContentTypeUtilities.h
platform/graphics/DashArray.h
platform/graphics/DecodingOptions.h
platform/graphics/DecomposedGlyphs.h
platform/graphics/DestinationColorSpace.h
platform/graphics/DisplayRefreshMonitor.h
platform/graphics/DisplayRefreshMonitorClient.h
Expand Down Expand Up @@ -1593,6 +1594,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
platform/graphics/PlatformVideoMatrixCoefficients.h
platform/graphics/PlatformVideoTrackConfiguration.h
platform/graphics/PlatformVideoTransferCharacteristics.h
platform/graphics/PositionedGlyphs.h
platform/graphics/Region.h
platform/graphics/RenderingResourceIdentifier.h
platform/graphics/RenderingMode.h
Expand Down
5 changes: 4 additions & 1 deletion Source/WebCore/Sources.txt
@@ -1,4 +1,4 @@
// Copyright (C) 2017-2021 Apple Inc. All rights reserved.
// Copyright (C) 2017-2022 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -2029,6 +2029,7 @@ platform/graphics/ColorUtilities.cpp
platform/graphics/ComplexTextController.cpp
platform/graphics/ContentTypeUtilities.cpp
platform/graphics/CrossfadeGeneratedImage.cpp
platform/graphics/DecomposedGlyphs.cpp
platform/graphics/DestinationColorSpace.cpp
platform/graphics/DisplayRefreshMonitor.cpp
platform/graphics/DisplayRefreshMonitorClient.cpp
Expand Down Expand Up @@ -2100,6 +2101,7 @@ platform/graphics/PixelBufferConversion.cpp
platform/graphics/PixelBufferFormat.cpp
platform/graphics/PixelFormat.cpp
platform/graphics/PlatformTimeRanges.cpp
platform/graphics/PositionedGlyphs.cpp
platform/graphics/Region.cpp
platform/graphics/RoundedRect.cpp
platform/graphics/ShadowBlur.cpp
Expand Down Expand Up @@ -2316,6 +2318,7 @@ rendering/Grid.cpp
rendering/GridBaselineAlignment.cpp
rendering/GridLayoutFunctions.cpp
rendering/GridTrackSizingAlgorithm.cpp
rendering/GlyphDisplayListCache.cpp
rendering/HighlightData.cpp
rendering/HitTestLocation.cpp
rendering/HitTestResult.cpp
Expand Down
18 changes: 18 additions & 0 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Expand Up @@ -1014,6 +1014,9 @@
31FB1A5D120A5D0600DC02A0 /* DeviceMotionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 31FB1A55120A5D0600DC02A0 /* DeviceMotionEvent.h */; };
31FB1A66120A5D3F00DC02A0 /* JSDeviceMotionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 31FB1A64120A5D3F00DC02A0 /* JSDeviceMotionEvent.h */; };
31FE6DFA15004C2A0004EBC4 /* NotificationPermissionCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 31EC1DAC14FF26EA00C94662 /* NotificationPermissionCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
321111B7283AE4410067D300 /* TextRunHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 321111B6283AE4400067D300 /* TextRunHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
32A70D532836134B0080060C /* DecomposedGlyphs.h in Headers */ = {isa = PBXBuildFile; fileRef = 32A70D522836134A0080060C /* DecomposedGlyphs.h */; settings = {ATTRIBUTES = (Private, ); }; };
32A70D582836138E0080060C /* PositionedGlyphs.h in Headers */ = {isa = PBXBuildFile; fileRef = 32A70D562836138D0080060C /* PositionedGlyphs.h */; settings = {ATTRIBUTES = (Private, ); }; };
33503C9A10179A74003B47E1 /* NotificationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 33503C9910179A74003B47E1 /* NotificationClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
33503CA410179AD7003B47E1 /* JSNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 33503CA010179AD7003B47E1 /* JSNotification.h */; settings = {ATTRIBUTES = (Private, ); }; };
33D0212D131DB37B004091A8 /* CookieStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = E13F01EA1270E10D00DFBA71 /* CookieStorage.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -8486,6 +8489,12 @@
31FB1A56120A5D0600DC02A0 /* DeviceMotionEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DeviceMotionEvent.idl; sourceTree = "<group>"; };
31FB1A63120A5D3F00DC02A0 /* JSDeviceMotionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDeviceMotionEvent.cpp; sourceTree = "<group>"; };
31FB1A64120A5D3F00DC02A0 /* JSDeviceMotionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDeviceMotionEvent.h; sourceTree = "<group>"; };
321111B6283AE4400067D300 /* TextRunHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextRunHash.h; sourceTree = "<group>"; };
32A70D522836134A0080060C /* DecomposedGlyphs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecomposedGlyphs.h; sourceTree = "<group>"; };
32A70D542836135A0080060C /* DecomposedGlyphs.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DecomposedGlyphs.cpp; sourceTree = "<group>"; };
32A70D552836138D0080060C /* PositionedGlyphs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PositionedGlyphs.cpp; sourceTree = "<group>"; };
32A70D562836138D0080060C /* PositionedGlyphs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PositionedGlyphs.h; sourceTree = "<group>"; };
32B0B0CF283C7483006217C6 /* GlyphDisplayListCache.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GlyphDisplayListCache.cpp; sourceTree = "<group>"; };
331FF67DE197B57393C46A7F /* RenderMathMLPadded.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLPadded.h; sourceTree = "<group>"; };
331FF67DE197B57393C46AA7 /* RenderMathMLSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLSpace.h; sourceTree = "<group>"; };
333F704E0FB49CA2008E12A6 /* Notification.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Notification.idl; sourceTree = "<group>"; };
Expand Down Expand Up @@ -29165,6 +29174,8 @@
2D2FC0551460CD6F00263633 /* CrossfadeGeneratedImage.h */,
A8CB41020E85B8A50032C4F0 /* DashArray.h */,
555130001E7CCCCA00A69E38 /* DecodingOptions.h */,
32A70D542836135A0080060C /* DecomposedGlyphs.cpp */,
32A70D522836134A0080060C /* DecomposedGlyphs.h */,
BC2CCA0F2655DDB200B8C035 /* DestinationColorSpace.cpp */,
BC2CCA0E2655DDB200B8C035 /* DestinationColorSpace.h */,
49FC7A4F1444AF5F00A5D864 /* DisplayRefreshMonitor.cpp */,
Expand Down Expand Up @@ -29373,6 +29384,8 @@
CD1F9AFD26FD38CB00617EB6 /* PlatformVideoMatrixCoefficients.h */,
CDD08AC1277E554E00EA3755 /* PlatformVideoTrackConfiguration.h */,
CD1F9AFC26FD38CA00617EB6 /* PlatformVideoTransferCharacteristics.h */,
32A70D552836138D0080060C /* PositionedGlyphs.cpp */,
32A70D562836138D0080060C /* PositionedGlyphs.h */,
BCAB417F13E356E800D8AAF3 /* Region.cpp */,
BCAB418013E356E800D8AAF3 /* Region.h */,
7299BC6623D686C600CC6883 /* RenderingMode.h */,
Expand All @@ -29398,6 +29411,7 @@
722AF2E327E1CF110078D997 /* TextBoxIterator.h */,
376DCCE013B4F966002EBEFC /* TextRun.cpp */,
A824B4640E2EF2EA0081A7B7 /* TextRun.h */,
321111B6283AE4400067D300 /* TextRunHash.h */,
CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */,
CDD1E525167BA56400CE820B /* TextTrackRepresentation.h */,
1AF89A411518FDEA00E547B5 /* TiledBacking.h */,
Expand Down Expand Up @@ -32248,6 +32262,7 @@
9A528E8117D7F52F00AA9518 /* FloatingObjects.cpp */,
9A528E8217D7F52F00AA9518 /* FloatingObjects.h */,
935C477409AC4D8D00A6AAB4 /* GapRects.h */,
32B0B0CF283C7483006217C6 /* GlyphDisplayListCache.cpp */,
5597FCCB2076C06800D35BB0 /* GlyphDisplayListCache.h */,
E112F4701E3A85F200D6CDFD /* Grid.cpp */,
E112F46F1E3A85D800D6CDFD /* Grid.h */,
Expand Down Expand Up @@ -34520,6 +34535,7 @@
715AD7202050513200D592DC /* DeclarativeAnimation.h in Headers */,
A8C228A111D5722E00D5A7D3 /* DecodedDataDocumentParser.h in Headers */,
555130011E7CCCCB00A69E38 /* DecodingOptions.h in Headers */,
32A70D532836134B0080060C /* DecomposedGlyphs.h in Headers */,
4162A451101145AE00DFF3ED /* DedicatedWorkerGlobalScope.h in Headers */,
41A3D58F101C152D00316D07 /* DedicatedWorkerThread.h in Headers */,
FD06DFA6134A4DEF006F5D7D /* DefaultAudioDestinationNode.h in Headers */,
Expand Down Expand Up @@ -37004,6 +37020,7 @@
37F567CE165358F400DDE92B /* PopupOpeningObserver.h in Headers */,
93F199DE08245E59001E9ABC /* Position.h in Headers */,
9746AF2C14F4DDE6003E7A70 /* PositionCallback.h in Headers */,
32A70D582836138E0080060C /* PositionedGlyphs.h in Headers */,
9746AF3014F4DDE6003E7A70 /* PositionErrorCallback.h in Headers */,
37919C240B7D188600A56998 /* PositionIterator.h in Headers */,
9746AF3214F4DDE6003E7A70 /* PositionOptions.h in Headers */,
Expand Down Expand Up @@ -38057,6 +38074,7 @@
F48B7D5325C341E6009E75DD /* TextRecognitionResult.h in Headers */,
93F198F608245E59001E9ABC /* TextResourceDecoder.h in Headers */,
A824B4650E2EF2EA0081A7B7 /* TextRun.h in Headers */,
321111B7283AE4410067D300 /* TextRunHash.h in Headers */,
448B1B7A0F3A2F9B0047A9E2 /* TextSizeAdjustment.h in Headers */,
9759E94014EF1CF80026A2DD /* TextTrack.h in Headers */,
CD1F9B212702565E00617EB6 /* TextTrackClient.h in Headers */,
Expand Down
8 changes: 8 additions & 0 deletions Source/WebCore/dom/Document.cpp
Expand Up @@ -91,6 +91,7 @@
#include "FullscreenManager.h"
#include "GCReachableRef.h"
#include "GenericCachedHTMLCollection.h"
#include "GlyphDisplayListCache.h"
#include "HTMLAllCollection.h"
#include "HTMLAnchorElement.h"
#include "HTMLAttachmentElement.h"
Expand Down Expand Up @@ -9176,6 +9177,13 @@ bool Document::isSameSiteForCookies(const URL& url) const
return domain.matches(url);
}

GlyphDisplayListCache& Document::glyphDisplayListCache()
{
if (!m_glyphDisplayListCache)
m_glyphDisplayListCache = makeUnique<GlyphDisplayListCache>();
return *m_glyphDisplayListCache;
}

} // namespace WebCore

#undef DOCUMENT_RELEASE_LOG
Expand Down

0 comments on commit 4556b07

Please sign in to comment.