<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From d3cabbc7321d349a9bffda482df5afc0d4df1ac2 Mon Sep 17 00:00:00 2001
From: Piotr Tworek &lt;ptworek@vewd.com&gt;
Date: Thu, 30 Apr 2020 21:33:47 +0000
Subject: [PATCH] Make some of blink custom iterators STL compatible.

Blink has recently started using functions like std::any_of with some of
the custom iterators it provides. On Linux this works in the default
setup using libcxx, but fails with even the most recent versions of
libstdc++. In all cases the error message (text in bug report) complains
about lack of matching std::__iterator_category definition.

From what I understand the error message is basically saying those
iterators are not STL compatible due to missing traits as described
in https://en.cppreference.com/w/cpp/iterator/iterator_traits. Such
traits are provided by custom iterators defined in //base, or //cc.

This patch adds the necessary traits to iterators that are currently
affected by this problem.

Bug: 1076869
Change-Id: I9950a7100c32499ba96647317fa70b87dc22eaf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2174199
Reviewed-by: Kentaro Hara &lt;haraken@chromium.org&gt;
Commit-Queue: Piotr Tworek &lt;ptworek@vewd.com&gt;
Cr-Commit-Position: refs/heads/master@{#764426}
---
 .../core/layout/ng/ng_physical_container_fragment.h  |  6 ++++++
 .../blink/renderer/platform/wtf/hash_iterators.h     | 12 ++++++++++++
 third_party/blink/renderer/platform/wtf/hash_table.h |  6 ++++++
 3 files changed, 24 insertions(+)

diff --git a/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h b/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h
index 1256e77c146..8b93107f2fc 100644
--- a/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h
+++ b/third_party/blink/renderer/core/layout/ng/ng_physical_container_fragment.h
@@ -38,6 +38,12 @@ class CORE_EXPORT NGPhysicalContainerFragment : public NGPhysicalFragment {
       STACK_ALLOCATED();
 
      public:
+      using iterator_category = std::bidirectional_iterator_tag;
+      using value_type = NGLink;
+      using difference_type = ptrdiff_t;
+      using pointer = value_type*;
+      using reference = value_type&amp;;
+
       ConstIterator(const NGLink* current) : current_(current) {}
 
       const NGLink&amp; operator*() const { return *PostLayoutOrCurrent(); }
diff --git a/third_party/blink/renderer/platform/wtf/hash_iterators.h b/third_party/blink/renderer/platform/wtf/hash_iterators.h
index f8e66e6be85..6003d02c509 100644
--- a/third_party/blink/renderer/platform/wtf/hash_iterators.h
+++ b/third_party/blink/renderer/platform/wtf/hash_iterators.h
@@ -53,6 +53,12 @@ struct HashTableConstIteratorAdapter&lt;HashTableType,
   typedef HashTableConstValuesIterator&lt;HashTableType, KeyType, MappedType&gt;
       ValuesIterator;
 
+  using iterator_category = std::bidirectional_iterator_tag;
+  using value_type = HashTableType;
+  using difference_type = ptrdiff_t;
+  using pointer = value_type*;
+  using reference = value_type&amp;;
+
   HashTableConstIteratorAdapter() = default;
   HashTableConstIteratorAdapter(
       const typename HashTableType::const_iterator&amp; impl)
@@ -94,6 +100,12 @@ struct HashTableIteratorAdapter&lt;HashTableType,
   typedef HashTableValuesIterator&lt;HashTableType, KeyType, MappedType&gt;
       ValuesIterator;
 
+  using iterator_category = std::bidirectional_iterator_tag;
+  using value_type = HashTableType;
+  using difference_type = ptrdiff_t;
+  using pointer = value_type*;
+  using reference = value_type&amp;;
+
   HashTableIteratorAdapter() = default;
   HashTableIteratorAdapter(const typename HashTableType::iterator&amp; impl)
       : impl_(impl) {}
diff --git a/third_party/blink/renderer/platform/wtf/hash_table.h b/third_party/blink/renderer/platform/wtf/hash_table.h
index f596fb5d41e..5a4468d6bd1 100644
--- a/third_party/blink/renderer/platform/wtf/hash_table.h
+++ b/third_party/blink/renderer/platform/wtf/hash_table.h
@@ -2204,6 +2204,12 @@ struct HashTableConstIteratorAdapter {
   STACK_ALLOCATED();
 
  public:
+  using iterator_category = std::bidirectional_iterator_tag;
+  using value_type = HashTableType;
+  using difference_type = ptrdiff_t;
+  using pointer = value_type*;
+  using reference = value_type&amp;;
+
   HashTableConstIteratorAdapter() = default;
   HashTableConstIteratorAdapter(
       const typename HashTableType::const_iterator&amp; impl)
</pre></body></html>