Streamline ListHashSet use in floating object code
https://bugs.webkit.org/show_bug.cgi?id=191957
Patch by Sam Weinig <sam@webkit.org> on 2018-11-26
Reviewed by Alex Christensen.
Source/WebCore:
Simplify use of ListHashSet by using new raw pointer overloads and
making use of reversed order of template arguments in the find() and
contains() overloads that take hash translators.
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObjects::remove):
Use raw pointer overloads of contains and remove. Remove seperate call
to find / check agains end() which is unnecessary as remove() already
does that.
* rendering/FloatingObjects.h:
(WebCore::FloatingObjectHashFunctions::hash):
(WebCore::FloatingObjectHashFunctions::equal):
(WebCore::FloatingObjectHashTranslator::hash):
(WebCore::FloatingObjectHashTranslator::equal):
Add hash()/equal() overloads for the raw pointer cases. As the FIXME
notes, this could be simplified by changing PtrHashBase to use designated
bottleneck functions for hash() and equal().
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::containsFloat const):
(WebCore::RenderBlockFlow::insertFloatingObject):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::hasOverhangingFloat):
(WebCore::RenderBlockFlow::addIntrudingFloats):
Use simplified calls.
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::layoutRunsAndFloatsInRange):
(WebCore::RenderBlockFlow::linkToEndLineIfNeeded):
Use simplified calls.
Source/WTF:
* wtf/ListHashSet.h:
Reverses the order of the template arguments for the find() and contains()
overload that allow specifying a hash translator to allow the compiler to
deduce type T. This simplifies call sites and matches other WTF containers.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@238504 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderBlockFlow.cpp b/Source/WebCore/rendering/RenderBlockFlow.cpp
index d9a75d2..6997970 100644
--- a/Source/WebCore/rendering/RenderBlockFlow.cpp
+++ b/Source/WebCore/rendering/RenderBlockFlow.cpp
@@ -1985,7 +1985,7 @@
bool RenderBlockFlow::containsFloat(RenderBox& renderer) const
{
- return m_floatingObjects && m_floatingObjects->set().contains<RenderBox&, FloatingObjectHashTranslator>(renderer);
+ return m_floatingObjects && m_floatingObjects->set().contains<FloatingObjectHashTranslator>(renderer);
}
void RenderBlockFlow::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
@@ -2233,7 +2233,7 @@
else {
// Don't insert the floatingObject again if it's already in the list
const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
- auto it = floatingObjectSet.find<RenderBox&, FloatingObjectHashTranslator>(floatBox);
+ auto it = floatingObjectSet.find<FloatingObjectHashTranslator>(floatBox);
if (it != floatingObjectSet.end())
return it->get();
}
@@ -2267,7 +2267,7 @@
{
if (m_floatingObjects) {
const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
- auto it = floatingObjectSet.find<RenderBox&, FloatingObjectHashTranslator>(floatBox);
+ auto it = floatingObjectSet.find<FloatingObjectHashTranslator>(floatBox);
if (it != floatingObjectSet.end()) {
auto& floatingObject = *it->get();
if (childrenInline()) {
@@ -2683,7 +2683,7 @@
return false;
const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
- const auto it = floatingObjectSet.find<RenderBox&, FloatingObjectHashTranslator>(renderer);
+ const auto it = floatingObjectSet.find<FloatingObjectHashTranslator>(renderer);
if (it == floatingObjectSet.end())
return false;
@@ -2709,7 +2709,7 @@
for (auto prevIt = prevSet.begin(); prevIt != prevEnd; ++prevIt) {
auto& floatingObject = *prevIt->get();
if (logicalBottomForFloat(floatingObject) > logicalTopOffset) {
- if (!m_floatingObjects || !m_floatingObjects->set().contains<FloatingObject&, FloatingObjectHashTranslator>(floatingObject)) {
+ if (!m_floatingObjects || !m_floatingObjects->set().contains(&floatingObject)) {
// We create the floating object list lazily.
if (!m_floatingObjects)
createFloatingObjects();