Commit a3aa50b1 authored by Alex Turner's avatar Alex Turner Committed by Commit Bot

Include most likely input digests in font indexer output

Currently, only typeface digests (i.e. the output) are included. We now
include two likely lookup values: where the family name or the
PostScript name were looked up with default FontSelectionRequests. While
there will be many input digests that map to the same typeface, this
should handle a good chunk.

We also remove the duplicate signed integer copy of the typeface digest,
leaving only the unsigned version.

Bug: 1150480
Change-Id: I7f36061b5da4022984a908ba9988258094e9c5b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2548311Reviewed-by: default avatarAsanka Herath <asanka@chromium.org>
Commit-Queue: Alex Turner <alexmt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829242}
parent 2a727f9f
...@@ -11,8 +11,10 @@ ...@@ -11,8 +11,10 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "content/public/browser/font_list_async.h" #include "content/public/browser/font_list_async.h"
#include "third_party/blink/public/common/privacy_budget/identifiable_token_builder.h"
#include "third_party/blink/renderer/platform/fonts/font_global_context.h" #include "third_party/blink/renderer/platform/fonts/font_global_context.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h" #include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
#include "third_party/blink/renderer/platform/privacy_budget/identifiability_digest_helpers.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h" #include "third_party/blink/renderer/platform/wtf/hash_set.h"
namespace privacy_budget { namespace privacy_budget {
...@@ -80,8 +82,9 @@ const std::pair<blink::FontSelectionValue, std::string> ...@@ -80,8 +82,9 @@ const std::pair<blink::FontSelectionValue, std::string>
}; };
const char kOutputHeader[] = const char kOutputHeader[] =
"Family name\tPostScript name\tweight\twidth\tslope\tdigest " "Family name\tPostScript name\tweight\twidth\tslope\ttypeface "
"(int64_t)\tdigest (uint64_t)"; "digest\tdefault family name lookup digest\tdefault PostScript name lookup "
"digest";
const char kOutputSeparator[] = "\t"; const char kOutputSeparator[] = "\t";
FontIndexer::FontIndexer() : font_cache_(blink::FontCache::GetFontCache()) {} FontIndexer::FontIndexer() : font_cache_(blink::FontCache::GetFontCache()) {}
...@@ -234,18 +237,47 @@ void FontIndexer::PrintAllFontsWithName(WTF::AtomicString name) { ...@@ -234,18 +237,47 @@ void FontIndexer::PrintAllFontsWithName(WTF::AtomicString name) {
if (scoped_refptr<blink::SimpleFontData> font_data = if (scoped_refptr<blink::SimpleFontData> font_data =
font_cache_->GetFontData(font_description, name)) { font_cache_->GetFontData(font_description, name)) {
int64_t digest = uint64_t typeface_digest =
blink::FontGlobalContext::Get() blink::FontGlobalContext::Get()
->GetOrComputeTypefaceDigest(font_data->PlatformData()) ->GetOrComputeTypefaceDigest(font_data->PlatformData())
.ToUkmMetricValue(); .ToUkmMetricValue();
if (set_of_digests.insert(digest).is_new_entry) { if (set_of_digests.insert(typeface_digest).is_new_entry) {
WTF::String postscript_name =
font_data->PlatformData().GetPostScriptName();
// Matches behavior in FontMatchingMetrics for lookups using the
// family name and the PostScript name, respectively, with default
// FontSelectionRequests.
uint64_t default_family_name_lookup_digest;
{
blink::IdentifiableTokenBuilder builder;
builder.AddValue(
blink::FontDescription().GetFontSelectionRequest().GetHash());
builder.AddToken(
blink::IdentifiabilityBenignCaseFoldingStringToken(name));
default_family_name_lookup_digest =
builder.GetToken().ToUkmMetricValue();
}
uint64_t default_postscript_name_lookup_digest;
{
blink::IdentifiableTokenBuilder builder;
builder.AddValue(
blink::FontDescription().GetFontSelectionRequest().GetHash());
builder.AddToken(
blink::IdentifiabilityBenignCaseFoldingStringToken(
postscript_name));
default_postscript_name_lookup_digest =
builder.GetToken().ToUkmMetricValue();
}
std::cout << name.Ascii() << kOutputSeparator std::cout << name.Ascii() << kOutputSeparator
<< font_data->PlatformData().GetPostScriptName().Ascii() << postscript_name.Ascii() << kOutputSeparator
<< kOutputSeparator << weight_pair.second << weight_pair.second << kOutputSeparator
<< kOutputSeparator << width_pair.second << width_pair.second << kOutputSeparator
<< kOutputSeparator << slope_pair.second << slope_pair.second << kOutputSeparator
<< kOutputSeparator << digest << kOutputSeparator << typeface_digest << kOutputSeparator
<< static_cast<uint64_t>(digest) << std::endl; << default_family_name_lookup_digest << kOutputSeparator
<< default_postscript_name_lookup_digest << std::endl;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment