Title: [203262] trunk/Source/WebCore
- Revision
- 203262
- Author
- [email protected]
- Date
- 2016-07-14 19:07:45 -0700 (Thu, 14 Jul 2016)
Log Message
Modernize GlyphMetricsMap
https://bugs.webkit.org/show_bug.cgi?id=159788
Reviewed by Darin Adler.
Modernize GlyphMetricsMap a bit.
* platform/graphics/GlyphMetricsMap.h:
- Drop WTF_MAKE_NONCOPYABLE as the class is already non-copyable due to having
to having a std::unique_ptr data member.
- Drop GlyphMetricsMap default constructor and let the compiler generate it
instead. This required using inline initialization for m_filledPrimaryPage.
(WebCore::GlyphMetricsMap::GlyphMetricsPage::GlyphMetricsPage):
- Make m_metrics data member private as it does not need to be public.
- Make setMetricsForIndex(unsigned index, const T& metrics) setter private
as it does not need to be public.
- Make GlyphMetricsPage(const T& initialValue) constructor explicit as it
takes only 1 parameter.
(WebCore::GlyphMetricsMap<T>::locatePageSlowCase):
- Use HashMap::ensure() to make the code a bit nicer.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (203261 => 203262)
--- trunk/Source/WebCore/ChangeLog 2016-07-15 01:46:25 UTC (rev 203261)
+++ trunk/Source/WebCore/ChangeLog 2016-07-15 02:07:45 UTC (rev 203262)
@@ -1,3 +1,28 @@
+2016-07-14 Chris Dumez <[email protected]>
+
+ Modernize GlyphMetricsMap
+ https://bugs.webkit.org/show_bug.cgi?id=159788
+
+ Reviewed by Darin Adler.
+
+ Modernize GlyphMetricsMap a bit.
+
+ * platform/graphics/GlyphMetricsMap.h:
+ - Drop WTF_MAKE_NONCOPYABLE as the class is already non-copyable due to having
+ to having a std::unique_ptr data member.
+ - Drop GlyphMetricsMap default constructor and let the compiler generate it
+ instead. This required using inline initialization for m_filledPrimaryPage.
+
+ (WebCore::GlyphMetricsMap::GlyphMetricsPage::GlyphMetricsPage):
+ - Make m_metrics data member private as it does not need to be public.
+ - Make setMetricsForIndex(unsigned index, const T& metrics) setter private
+ as it does not need to be public.
+ - Make GlyphMetricsPage(const T& initialValue) constructor explicit as it
+ takes only 1 parameter.
+
+ (WebCore::GlyphMetricsMap<T>::locatePageSlowCase):
+ - Use HashMap::ensure() to make the code a bit nicer.
+
2016-07-14 Simon Fraser <[email protected]>
[iOS WK2] When scrolling apple.com/music on iPad Pro in landscape, left-hand tiles appear first
Modified: trunk/Source/WebCore/platform/graphics/GlyphMetricsMap.h (203261 => 203262)
--- trunk/Source/WebCore/platform/graphics/GlyphMetricsMap.h 2016-07-15 01:46:25 UTC (rev 203261)
+++ trunk/Source/WebCore/platform/graphics/GlyphMetricsMap.h 2016-07-15 02:07:45 UTC (rev 203262)
@@ -38,9 +38,8 @@
const float cGlyphSizeUnknown = -1;
template<class T> class GlyphMetricsMap {
- WTF_MAKE_NONCOPYABLE(GlyphMetricsMap); WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_FAST_ALLOCATED;
public:
- GlyphMetricsMap() : m_filledPrimaryPage(false) { }
T metricsForGlyph(Glyph glyph)
{
return locatePage(glyph / GlyphMetricsPage::size).metricsForGlyph(glyph);
@@ -56,10 +55,9 @@
WTF_MAKE_FAST_ALLOCATED;
public:
static const size_t size = 256; // Usually covers Latin-1 in a single page.
- std::array<T, size> m_metrics;
GlyphMetricsPage() = default;
- GlyphMetricsPage(const T& initialValue)
+ explicit GlyphMetricsPage(const T& initialValue)
{
fill(initialValue);
}
@@ -74,10 +72,14 @@
{
setMetricsForIndex(glyph % size, metrics);
}
+
+ private:
void setMetricsForIndex(unsigned index, const T& metrics)
{
m_metrics[index] = metrics;
}
+
+ std::array<T, size> m_metrics;
};
GlyphMetricsPage& locatePage(unsigned pageNumber)
@@ -91,7 +93,7 @@
static T unknownMetrics();
- bool m_filledPrimaryPage;
+ bool m_filledPrimaryPage { false };
GlyphMetricsPage m_primaryPage; // We optimize for the page that contains glyph indices 0-255.
std::unique_ptr<HashMap<int, std::unique_ptr<GlyphMetricsPage>>> m_pages;
};
@@ -117,10 +119,11 @@
if (!m_pages)
m_pages = std::make_unique<HashMap<int, std::unique_ptr<GlyphMetricsPage>>>();
- auto& pageInMap = m_pages->add(pageNumber, nullptr).iterator->value;
- if (!pageInMap)
- pageInMap = std::make_unique<GlyphMetricsPage>(unknownMetrics());
- return *pageInMap;
+
+ auto& page = m_pages->ensure(pageNumber, [] {
+ return std::make_unique<GlyphMetricsPage>(unknownMetrics());
+ }).iterator->value;
+ return *page;
}
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes