Skip to content
Permalink
Browse files
Eliminate DeprecatedPtrList from RenderBlock
https://bugs.webkit.org/show_bug.cgi?id=54972

Patch by Benjamin Poulain <ikipou@gmail.com> on 2011-02-27
Reviewed by Darin Adler.

Source/JavaScriptCore:

Add methods find() and contains() using an adaptor to ListHashSet.
Those method are like the one of HashSet, they allow to find objects
based on a different key than the one used to define the set.

Add convenience methods for direct access to the head and tail of the list.
Those methods are providing similar API/behavior as Vector.

* wtf/ListHashSet.h:
(WTF::::first):
(WTF::::last):
(WTF::::removeLast):
(WTF::ListHashSetTranslatorAdapter::hash):
(WTF::ListHashSetTranslatorAdapter::equal):
(WTF::::find):
(WTF::::contains):

Source/WebCore:

Refactor RenderBlock to get rid of the DeprecatedPtrList.
The floating objects are stored in a ListHashSet.

Refactoring covered by existing test.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::~RenderBlock):
(WebCore::RenderBlock::addOverflowFromFloats):
(WebCore::RenderBlock::repaintOverhangingFloats):
(WebCore::RenderBlock::paintFloats):
(WebCore::RenderBlock::selectionGaps):
(WebCore::RenderBlock::insertFloatingObject):
(WebCore::RenderBlock::removeFloatingObject):
(WebCore::RenderBlock::removeFloatingObjectsBelow):
(WebCore::RenderBlock::positionNewFloats):
(WebCore::RenderBlock::positionNewFloatOnLine):
(WebCore::RenderBlock::logicalLeftOffsetForLine):
(WebCore::RenderBlock::logicalRightOffsetForLine):
(WebCore::RenderBlock::nextFloatLogicalBottomBelow):
(WebCore::RenderBlock::lowestFloatLogicalBottom):
(WebCore::RenderBlock::clearFloats):
(WebCore::RenderBlock::addOverhangingFloats):
(WebCore::RenderBlock::addIntrudingFloats):
(WebCore::RenderBlock::containsFloat):
(WebCore::RenderBlock::hitTestFloats):
(WebCore::RenderBlock::adjustForBorderFit):
* rendering/RenderBlock.h:
(WebCore::RenderBlock::FloatingObjectHashFunctions::hash):
(WebCore::RenderBlock::FloatingObjectHashFunctions::equal):
(WebCore::RenderBlock::FloatingObjectHashTranslator::hash):
(WebCore::RenderBlock::FloatingObjectHashTranslator::equal):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::layoutInlineChildren):
(WebCore::RenderBlock::matchedEndLine):

Canonical link: https://commits.webkit.org/69734@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79817 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Benjamin Poulain authored and Benjamin Poulain committed Feb 27, 2011
1 parent 3dd9956 commit b479930db7a17518a1e82974bbfe4e99fb5dba53
Showing 6 changed files with 316 additions and 144 deletions.
@@ -1,3 +1,26 @@
2011-02-27 Benjamin Poulain <ikipou@gmail.com>

Reviewed by Darin Adler.

Eliminate DeprecatedPtrList from RenderBlock
https://bugs.webkit.org/show_bug.cgi?id=54972

Add methods find() and contains() using an adaptor to ListHashSet.
Those method are like the one of HashSet, they allow to find objects
based on a different key than the one used to define the set.

Add convenience methods for direct access to the head and tail of the list.
Those methods are providing similar API/behavior as Vector.

* wtf/ListHashSet.h:
(WTF::::first):
(WTF::::last):
(WTF::::removeLast):
(WTF::ListHashSetTranslatorAdapter::hash):
(WTF::ListHashSetTranslatorAdapter::equal):
(WTF::::find):
(WTF::::contains):

2011-02-26 Patrick Gansterer <paroga@webkit.org>

Reviewed by Andreas Kling.
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -90,10 +91,24 @@ namespace WTF {
const_iterator begin() const;
const_iterator end() const;

ValueType& first();
const ValueType& first() const;

ValueType& last();
const ValueType& last() const;
void removeLast();

iterator find(const ValueType&);
const_iterator find(const ValueType&) const;
bool contains(const ValueType&) const;

// An alternate version of find() that finds the object by hashing and comparing
// with some other type, to avoid the cost of type conversion.
// The HashTranslator interface is defined in HashSet.
template<typename T, typename HashTranslator> iterator find(const T&);
template<typename T, typename HashTranslator> const_iterator find(const T&) const;
template<typename T, typename HashTranslator> bool contains(const T&) const;

// the return value is a pair of an iterator to the new value's location,
// and a bool that is true if an new entry was added
pair<iterator, bool> add(const ValueType&);
@@ -441,6 +456,42 @@ namespace WTF {
return makeConstIterator(0);
}

template<typename T, size_t inlineCapacity, typename U>
inline T& ListHashSet<T, inlineCapacity, U>::first()
{
ASSERT(!isEmpty());
return m_head->m_value;
}

template<typename T, size_t inlineCapacity, typename U>
inline const T& ListHashSet<T, inlineCapacity, U>::first() const
{
ASSERT(!isEmpty());
return m_head->m_value;
}

template<typename T, size_t inlineCapacity, typename U>
inline T& ListHashSet<T, inlineCapacity, U>::last()
{
ASSERT(!isEmpty());
return m_tail->m_value;
}

template<typename T, size_t inlineCapacity, typename U>
inline const T& ListHashSet<T, inlineCapacity, U>::last() const
{
ASSERT(!isEmpty());
return m_tail->m_value;
}

template<typename T, size_t inlineCapacity, typename U>
inline void ListHashSet<T, inlineCapacity, U>::removeLast()
{
ASSERT(!isEmpty());
m_impl.remove(m_tail);
unlinkAndDelete(m_tail);
}

template<typename T, size_t inlineCapacity, typename U>
inline typename ListHashSet<T, inlineCapacity, U>::iterator ListHashSet<T, inlineCapacity, U>::find(const ValueType& value)
{
@@ -461,6 +512,45 @@ namespace WTF {
return makeConstIterator(*it);
}

template<typename ValueType, size_t inlineCapacity, typename T, typename Translator>
struct ListHashSetTranslatorAdapter {
private:
typedef ListHashSetNode<ValueType, inlineCapacity> Node;
public:
static unsigned hash(const T& key) { return Translator::hash(key); }
static bool equal(Node* const& a, const T& b) { return Translator::equal(a->m_value, b); }
};

template<typename ValueType, size_t inlineCapacity, typename U>
template<typename T, typename HashTranslator>
inline typename ListHashSet<ValueType, inlineCapacity, U>::iterator ListHashSet<ValueType, inlineCapacity, U>::find(const T& value)
{
typedef ListHashSetTranslatorAdapter<ValueType, inlineCapacity, T, HashTranslator> Adapter;
ImplTypeConstIterator it = m_impl.template find<T, Adapter>(value);
if (it == m_impl.end())
return end();
return makeIterator(*it);
}

template<typename ValueType, size_t inlineCapacity, typename U>
template<typename T, typename HashTranslator>
inline typename ListHashSet<ValueType, inlineCapacity, U>::const_iterator ListHashSet<ValueType, inlineCapacity, U>::find(const T& value) const
{
typedef ListHashSetTranslatorAdapter<ValueType, inlineCapacity, T, HashTranslator> Adapter;
ImplTypeConstIterator it = m_impl.template find<T, Adapter>(value);
if (it == m_impl.end())
return end();
return makeConstIterator(*it);
}

template<typename ValueType, size_t inlineCapacity, typename U>
template<typename T, typename HashTranslator>
inline bool ListHashSet<ValueType, inlineCapacity, U>::contains(const T& value) const
{
typedef ListHashSetTranslatorAdapter<ValueType, inlineCapacity, T, HashTranslator> Adapter;
return m_impl.template contains<T, Adapter>(value);
}

template<typename T, size_t inlineCapacity, typename U>
inline bool ListHashSet<T, inlineCapacity, U>::contains(const ValueType& value) const
{
@@ -1,3 +1,45 @@
2011-02-27 Benjamin Poulain <ikipou@gmail.com>

Reviewed by Darin Adler.

Eliminate DeprecatedPtrList from RenderBlock
https://bugs.webkit.org/show_bug.cgi?id=54972

Refactor RenderBlock to get rid of the DeprecatedPtrList.
The floating objects are stored in a ListHashSet.

Refactoring covered by existing test.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::~RenderBlock):
(WebCore::RenderBlock::addOverflowFromFloats):
(WebCore::RenderBlock::repaintOverhangingFloats):
(WebCore::RenderBlock::paintFloats):
(WebCore::RenderBlock::selectionGaps):
(WebCore::RenderBlock::insertFloatingObject):
(WebCore::RenderBlock::removeFloatingObject):
(WebCore::RenderBlock::removeFloatingObjectsBelow):
(WebCore::RenderBlock::positionNewFloats):
(WebCore::RenderBlock::positionNewFloatOnLine):
(WebCore::RenderBlock::logicalLeftOffsetForLine):
(WebCore::RenderBlock::logicalRightOffsetForLine):
(WebCore::RenderBlock::nextFloatLogicalBottomBelow):
(WebCore::RenderBlock::lowestFloatLogicalBottom):
(WebCore::RenderBlock::clearFloats):
(WebCore::RenderBlock::addOverhangingFloats):
(WebCore::RenderBlock::addIntrudingFloats):
(WebCore::RenderBlock::containsFloat):
(WebCore::RenderBlock::hitTestFloats):
(WebCore::RenderBlock::adjustForBorderFit):
* rendering/RenderBlock.h:
(WebCore::RenderBlock::FloatingObjectHashFunctions::hash):
(WebCore::RenderBlock::FloatingObjectHashFunctions::equal):
(WebCore::RenderBlock::FloatingObjectHashTranslator::hash):
(WebCore::RenderBlock::FloatingObjectHashTranslator::equal):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::layoutInlineChildren):
(WebCore::RenderBlock::matchedEndLine):

2011-02-26 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

0 comments on commit b479930

Please sign in to comment.