Title: [201278] releases/WebKitGTK/webkit-2.12/Source/WebCore
- Revision
- 201278
- Author
- carlo...@webkit.org
- Date
- 2016-05-23 05:52:41 -0700 (Mon, 23 May 2016)
Log Message
Merge r201023 - Regression(r177786): GlyphMetricsMap<T>::locatePageSlowCase() fills existing pages with unknown metrics
https://bugs.webkit.org/show_bug.cgi?id=157749
Reviewed by Antti Koivisto.
After r177786, GlyphMetricsMap<T>::locatePageSlowCase() would unconditionally fill
pages with unknown metrics. This patch updates the code to do so only if the page
is new, thus restoring the pre-r177786 behavior.
* platform/graphics/GlyphMetricsMap.h:
(WebCore::GlyphMetricsMap::metricsForGlyph):
(WebCore::GlyphMetricsMap::setMetricsForGlyph):
(WebCore::GlyphMetricsMap::GlyphMetricsPage::GlyphMetricsPage):
(WebCore::GlyphMetricsMap::GlyphMetricsPage::fill):
(WebCore::GlyphMetricsMap::locatePage):
(WebCore::GlyphMetricsMap<T>::locatePageSlowCase):
(WebCore::GlyphMetricsMap::GlyphMetricsPage::metricsForGlyph): Deleted.
(WebCore::GlyphMetricsMap::GlyphMetricsPage::setMetricsForGlyph): Deleted.
(WebCore::GlyphMetricsMap::GlyphMetricsPage::setMetricsForIndex): Deleted.
(WebCore::GlyphMetricsMap<float>::unknownMetrics): Deleted.
(WebCore::GlyphMetricsMap<FloatRect>::unknownMetrics): Deleted.
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog (201277 => 201278)
--- releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog 2016-05-23 12:36:24 UTC (rev 201277)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog 2016-05-23 12:52:41 UTC (rev 201278)
@@ -1,3 +1,27 @@
+2016-05-17 Chris Dumez <cdu...@apple.com>
+
+ Regression(r177786): GlyphMetricsMap<T>::locatePageSlowCase() fills existing pages with unknown metrics
+ https://bugs.webkit.org/show_bug.cgi?id=157749
+
+ Reviewed by Antti Koivisto.
+
+ After r177786, GlyphMetricsMap<T>::locatePageSlowCase() would unconditionally fill
+ pages with unknown metrics. This patch updates the code to do so only if the page
+ is new, thus restoring the pre-r177786 behavior.
+
+ * platform/graphics/GlyphMetricsMap.h:
+ (WebCore::GlyphMetricsMap::metricsForGlyph):
+ (WebCore::GlyphMetricsMap::setMetricsForGlyph):
+ (WebCore::GlyphMetricsMap::GlyphMetricsPage::GlyphMetricsPage):
+ (WebCore::GlyphMetricsMap::GlyphMetricsPage::fill):
+ (WebCore::GlyphMetricsMap::locatePage):
+ (WebCore::GlyphMetricsMap<T>::locatePageSlowCase):
+ (WebCore::GlyphMetricsMap::GlyphMetricsPage::metricsForGlyph): Deleted.
+ (WebCore::GlyphMetricsMap::GlyphMetricsPage::setMetricsForGlyph): Deleted.
+ (WebCore::GlyphMetricsMap::GlyphMetricsPage::setMetricsForIndex): Deleted.
+ (WebCore::GlyphMetricsMap<float>::unknownMetrics): Deleted.
+ (WebCore::GlyphMetricsMap<FloatRect>::unknownMetrics): Deleted.
+
2016-05-16 Brent Fulgham <bfulg...@apple.com>
heap use-after-free at WebCore::TimerBase::heapPopMin()
Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/GlyphMetricsMap.h (201277 => 201278)
--- releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/GlyphMetricsMap.h 2016-05-23 12:36:24 UTC (rev 201277)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/platform/graphics/GlyphMetricsMap.h 2016-05-23 12:52:41 UTC (rev 201278)
@@ -43,12 +43,12 @@
GlyphMetricsMap() : m_filledPrimaryPage(false) { }
T metricsForGlyph(Glyph glyph)
{
- return locatePage(glyph / GlyphMetricsPage::size)->metricsForGlyph(glyph);
+ return locatePage(glyph / GlyphMetricsPage::size).metricsForGlyph(glyph);
}
void setMetricsForGlyph(Glyph glyph, const T& metrics)
{
- locatePage(glyph / GlyphMetricsPage::size)->setMetricsForGlyph(glyph, metrics);
+ locatePage(glyph / GlyphMetricsPage::size).setMetricsForGlyph(glyph, metrics);
}
private:
@@ -58,6 +58,17 @@
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)
+ {
+ fill(initialValue);
+ }
+
+ void fill(const T& value)
+ {
+ m_metrics.fill(value);
+ }
+
T metricsForGlyph(Glyph glyph) const { return m_metrics[glyph % size]; }
void setMetricsForGlyph(Glyph glyph, const T& metrics)
{
@@ -69,14 +80,14 @@
}
};
- GlyphMetricsPage* locatePage(unsigned pageNumber)
+ GlyphMetricsPage& locatePage(unsigned pageNumber)
{
if (!pageNumber && m_filledPrimaryPage)
- return &m_primaryPage;
+ return m_primaryPage;
return locatePageSlowCase(pageNumber);
}
- GlyphMetricsPage* locatePageSlowCase(unsigned pageNumber);
+ GlyphMetricsPage& locatePageSlowCase(unsigned pageNumber);
static T unknownMetrics();
@@ -95,27 +106,21 @@
return FloatRect(0, 0, cGlyphSizeUnknown, cGlyphSizeUnknown);
}
-template<class T> typename GlyphMetricsMap<T>::GlyphMetricsPage* GlyphMetricsMap<T>::locatePageSlowCase(unsigned pageNumber)
+template<class T> typename GlyphMetricsMap<T>::GlyphMetricsPage& GlyphMetricsMap<T>::locatePageSlowCase(unsigned pageNumber)
{
- GlyphMetricsPage* page;
if (!pageNumber) {
ASSERT(!m_filledPrimaryPage);
- page = &m_primaryPage;
+ m_primaryPage.fill(unknownMetrics());
m_filledPrimaryPage = true;
- } else {
- 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>();
- page = pageInMap.get();
+ return m_primaryPage;
}
- // Fill in the whole page with the unknown glyph information.
- for (unsigned i = 0; i < GlyphMetricsPage::size; i++)
- page->setMetricsForIndex(i, unknownMetrics());
-
- return page;
+ 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;
}
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes