Reviewed by Darin Adler.
Use a HashMap for m_continuation to save memory
https://bugs.webkit.org/show_bug.cgi?id=43716
Saving memory consumption by applying a HashMap convention to
continuation pointers of RenderInline and RenderBlock classes.
* rendering/RenderBlock.cpp: Removed m_continuation.
(WebCore::RenderBlock::RenderBlock):
(WebCore::RenderBlock::destroy):
(WebCore::RenderBlock::inlineElementContinuation):
(WebCore::RenderBlock::blockElementContinuation):
* rendering/RenderBlock.h: Removed m_continuation.
* rendering/RenderBoxModelObject.cpp: Added a hash map for continuations.
(WebCore::RenderBoxModelObject::destroy): Added an assertion.
(WebCore::RenderBoxModelObject::continuation): Added.
(WebCore::RenderBoxModelObject::setContinuation): Added.
* rendering/RenderBoxModelObject.h:
* rendering/RenderInline.cpp: Removed m_continuation.
(WebCore::RenderInline::RenderInline):
(WebCore::RenderInline::destroy):
(WebCore::RenderInline::inlineElementContinuation):
* rendering/RenderInline.h: Removed m_continuation.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74775
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2010-12-29 Kenichi Ishibashi <bashi@google.com>
+
+ Reviewed by Darin Adler.
+
+ Use a HashMap for m_continuation to save memory
+ https://bugs.webkit.org/show_bug.cgi?id=43716
+
+ Saving memory consumption by applying a HashMap convention to
+ continuation pointers of RenderInline and RenderBlock classes.
+
+ * rendering/RenderBlock.cpp: Removed m_continuation.
+ (WebCore::RenderBlock::RenderBlock):
+ (WebCore::RenderBlock::destroy):
+ (WebCore::RenderBlock::inlineElementContinuation):
+ (WebCore::RenderBlock::blockElementContinuation):
+ * rendering/RenderBlock.h: Removed m_continuation.
+ * rendering/RenderBoxModelObject.cpp: Added a hash map for continuations.
+ (WebCore::RenderBoxModelObject::destroy): Added an assertion.
+ (WebCore::RenderBoxModelObject::continuation): Added.
+ (WebCore::RenderBoxModelObject::setContinuation): Added.
+ * rendering/RenderBoxModelObject.h:
+ * rendering/RenderInline.cpp: Removed m_continuation.
+ (WebCore::RenderInline::RenderInline):
+ (WebCore::RenderInline::destroy):
+ (WebCore::RenderInline::inlineElementContinuation):
+ * rendering/RenderInline.h: Removed m_continuation.
+
2010-12-27 Amruth Raj <amruthraj@motorola.com> and Ravi Kasibhatla <ravi.kasibhatla@motorola.com>
Reviewed by Martin Robinson.
: RenderBox(node)
, m_floatingObjects(0)
, m_positionedObjects(0)
- , m_continuation(0)
, m_rareData(0)
, m_lineHeight(-1)
{
// Destroy our continuation before anything other than anonymous children.
// The reason we don't destroy it before anonymous children is that they may
// have continuations of their own that are anonymous children of our continuation.
- if (m_continuation) {
- m_continuation->destroy();
- m_continuation = 0;
+ RenderBoxModelObject* continuation = this->continuation();
+ if (continuation) {
+ continuation->destroy();
+ setContinuation(0);
}
if (!documentBeingDestroyed()) {
RenderInline* RenderBlock::inlineElementContinuation() const
{
- return m_continuation && m_continuation->isInline() ? toRenderInline(m_continuation) : 0;
+ RenderBoxModelObject* continuation = this->continuation();
+ return continuation && continuation->isInline() ? toRenderInline(continuation) : 0;
}
RenderBlock* RenderBlock::blockElementContinuation() const
{
- if (!m_continuation || m_continuation->isInline())
+ RenderBoxModelObject* currentContinuation = continuation();
+ if (!currentContinuation || currentContinuation->isInline())
return 0;
- RenderBlock* nextContinuation = toRenderBlock(m_continuation);
+ RenderBlock* nextContinuation = toRenderBlock(currentContinuation);
if (nextContinuation->isAnonymousBlock())
return nextContinuation->blockElementContinuation();
return nextContinuation;
void addContinuationWithOutline(RenderInline*);
- RenderBoxModelObject* continuation() const { return m_continuation; }
- void setContinuation(RenderBoxModelObject* c) { m_continuation = c; }
virtual RenderBoxModelObject* virtualContinuation() const { return continuation(); }
bool isAnonymousBlockContinuation() const { return continuation() && isAnonymousBlock(); }
RenderInline* inlineElementContinuation() const;
RenderBlock* blockElementContinuation() const;
+ using RenderBoxModelObject::continuation;
+ using RenderBoxModelObject::setContinuation;
+
// This function is a convenience helper for creating an anonymous block that inherits its
// style from this RenderBlock.
RenderBlock* createAnonymousBlock(bool isFlexibleBox = false) const;
PositionedObjectsListHashSet* m_positionedObjects;
- // An inline can be split with blocks occurring in between the inline content.
- // When this occurs we need a pointer to our next object. We can basically be
- // split into a sequence of inlines and blocks. The continuation will either be
- // an anonymous block (that houses other blocks) or it will be an inline flow.
- RenderBoxModelObject* m_continuation;
-
// Allocated only when some of these fields have non-default values
struct RenderBlockRareData : Noncopyable {
RenderBlockRareData(const RenderBlock* block)
typedef pair<RenderBoxModelObject*, const void*> LastPaintSizeMapKey;
typedef HashMap<LastPaintSizeMapKey, IntSize> LastPaintSizeMap;
+// The HashMap for storing continuation pointers.
+// An inline can be split with blocks occuring in between the inline content.
+// When this occurs we need a pointer to the next object. We can basically be
+// split into a sequence of inlines and blocks. The continuation will either be
+// an anonymous block (that houses other blocks) or it will be an inline flow.
+// <b><i><p>Hello</p></i></b>. In this example the <i> will have a block as
+// its continuation but the <b> will just have an inline as its continuation.
+typedef HashMap<const RenderBoxModelObject*, RenderBoxModelObject*> ContinuationMap;
+static ContinuationMap* continuationMap = 0;
+
class ImageQualityController : public Noncopyable {
public:
ImageQualityController();
if (m_layer)
m_layer->clearClipRects();
+ // A continuation of this RenderObject should be destroyed at subclasses.
+ ASSERT(!continuation());
+
// RenderObject::destroy calls back to destroyLayer() for layer destruction
RenderObject::destroy();
}
return containingBlock()->availableLogicalWidth();
}
+RenderBoxModelObject* RenderBoxModelObject::continuation() const
+{
+ if (!continuationMap)
+ return 0;
+ return continuationMap->get(this);
+}
+
+void RenderBoxModelObject::setContinuation(RenderBoxModelObject* continuation)
+{
+ if (continuation) {
+ if (!continuationMap)
+ continuationMap = new ContinuationMap;
+ continuationMap->set(this, continuation);
+ } else {
+ if (continuationMap)
+ continuationMap->remove(this);
+ }
+}
+
} // namespace WebCore
bool shouldPaintAtLowQuality(GraphicsContext*, Image*, const void*, const IntSize&);
+ RenderBoxModelObject* continuation() const;
+ void setContinuation(RenderBoxModelObject*);
+
private:
virtual bool isBoxModelObject() const { return true; }
RenderInline::RenderInline(Node* node)
: RenderBoxModelObject(node)
- , m_continuation(0)
, m_lineHeight(-1)
{
setChildrenInline(true);
// Destroy our continuation before anything other than anonymous children.
// The reason we don't destroy it before anonymous children is that they may
// have continuations of their own that are anonymous children of our continuation.
- if (m_continuation) {
- m_continuation->destroy();
- m_continuation = 0;
+ RenderBoxModelObject* continuation = this->continuation();
+ if (continuation) {
+ continuation->destroy();
+ setContinuation(0);
}
if (!documentBeingDestroyed()) {
RenderInline* RenderInline::inlineElementContinuation() const
{
- if (!m_continuation || m_continuation->isInline())
- return toRenderInline(m_continuation);
- return toRenderBlock(m_continuation)->inlineElementContinuation();
+ RenderBoxModelObject* continuation = this->continuation();
+ if (!continuation || continuation->isInline())
+ return toRenderInline(continuation);
+ return toRenderBlock(continuation)->inlineElementContinuation();
}
void RenderInline::updateBoxModelInfoFromStyle()
InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
- RenderBoxModelObject* continuation() const { return m_continuation; }
- void setContinuation(RenderBoxModelObject* c) { m_continuation = c; }
virtual RenderBoxModelObject* virtualContinuation() const { return continuation(); }
RenderInline* inlineElementContinuation() const;
virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
void paintOutline(GraphicsContext*, int tx, int ty);
+ using RenderBoxModelObject::continuation;
+ using RenderBoxModelObject::setContinuation;
+
protected:
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
RenderObjectChildList m_children;
RenderLineBoxList m_lineBoxes; // All of the line boxes created for this inline flow. For example, <i>Hello<br>world.</i> will have two <i> line boxes.
- RenderBoxModelObject* m_continuation; // Can be either a block or an inline. <b><i><p>Hello</p></i></b>. In this example the <i> will have a block as its continuation but the
- // <b> will just have an inline as its continuation.
mutable int m_lineHeight;
};