Commit b174c4c8 authored by haraken@chromium.org's avatar haraken@chromium.org

Oilpan: Remove Document* pointers in objects

This CL replaces Document* pointers in objects with Member<Document>s.

- Move TextAutosizer to oilpan's heap.
- Move FastTextAutosizer to oilpan's heap.
- Make FastBulider STACK_ALLOCATED.
- Make ViewportStyleResolver::m_document a Member.

BUG=340522

Review URL: https://codereview.chromium.org/420273005

git-svn-id: svn://svn.chromium.org/blink/trunk@179066 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ffeebb21
...@@ -39,6 +39,7 @@ namespace blink { ...@@ -39,6 +39,7 @@ namespace blink {
// FIXME: This scoping class is a short-term fix to minimize the changes in // FIXME: This scoping class is a short-term fix to minimize the changes in
// Font-constructing logic. // Font-constructing logic.
class FontDescriptionChangeScope { class FontDescriptionChangeScope {
STACK_ALLOCATED();
public: public:
FontDescriptionChangeScope(FontBuilder* fontBuilder) FontDescriptionChangeScope(FontBuilder* fontBuilder)
: m_fontBuilder(fontBuilder) : m_fontBuilder(fontBuilder)
...@@ -56,12 +57,12 @@ public: ...@@ -56,12 +57,12 @@ public:
} }
private: private:
FontBuilder* m_fontBuilder; RawPtrWillBeMember<FontBuilder> m_fontBuilder;
FontDescription m_fontDescription; FontDescription m_fontDescription;
}; };
FontBuilder::FontBuilder() FontBuilder::FontBuilder()
: m_document(0) : m_document(nullptr)
, m_fontSizehasViewportUnits(false) , m_fontSizehasViewportUnits(false)
, m_style(0) , m_style(0)
, m_fontDirty(false) , m_fontDirty(false)
......
...@@ -38,7 +38,8 @@ class RenderStyle; ...@@ -38,7 +38,8 @@ class RenderStyle;
class FontDescriptionChangeScope; class FontDescriptionChangeScope;
class FontBuilder { class FontBuilder {
WTF_MAKE_NONCOPYABLE(FontBuilder); WTF_MAKE_FAST_ALLOCATED; STACK_ALLOCATED();
WTF_MAKE_NONCOPYABLE(FontBuilder);
public: public:
FontBuilder(); FontBuilder();
...@@ -112,7 +113,7 @@ private: ...@@ -112,7 +113,7 @@ private:
float getComputedSizeFromSpecifiedSize(FontDescription&, float effectiveZoom, float specifiedSize); float getComputedSizeFromSpecifiedSize(FontDescription&, float effectiveZoom, float specifiedSize);
const Document* m_document; RawPtrWillBeMember<const Document> m_document;
bool m_fontSizehasViewportUnits; bool m_fontSizehasViewportUnits;
// FIXME: This member is here on a short-term lease. The plan is to remove // FIXME: This member is here on a short-term lease. The plan is to remove
// any notion of RenderStyle from here, allowing FontBuilder to build Font objects // any notion of RenderStyle from here, allowing FontBuilder to build Font objects
......
...@@ -200,6 +200,7 @@ Length ViewportStyleResolver::viewportLengthValue(CSSPropertyID id) const ...@@ -200,6 +200,7 @@ Length ViewportStyleResolver::viewportLengthValue(CSSPropertyID id) const
void ViewportStyleResolver::trace(Visitor* visitor) void ViewportStyleResolver::trace(Visitor* visitor)
{ {
visitor->trace(m_propertySet); visitor->trace(m_propertySet);
visitor->trace(m_document);
} }
} // namespace blink } // namespace blink
...@@ -66,7 +66,7 @@ private: ...@@ -66,7 +66,7 @@ private:
float viewportArgumentValue(CSSPropertyID) const; float viewportArgumentValue(CSSPropertyID) const;
Length viewportLengthValue(CSSPropertyID) const; Length viewportLengthValue(CSSPropertyID) const;
Document* m_document; RawPtrWillBeMember<Document> m_document;
RefPtrWillBeMember<MutableStylePropertySet> m_propertySet; RefPtrWillBeMember<MutableStylePropertySet> m_propertySet;
bool m_hasAuthorStyle; bool m_hasAuthorStyle;
}; };
......
...@@ -5866,6 +5866,8 @@ void Document::trace(Visitor* visitor) ...@@ -5866,6 +5866,8 @@ void Document::trace(Visitor* visitor)
visitor->trace(m_styleSheetList); visitor->trace(m_styleSheetList);
visitor->trace(m_mediaQueryMatcher); visitor->trace(m_mediaQueryMatcher);
visitor->trace(m_scriptedAnimationController); visitor->trace(m_scriptedAnimationController);
visitor->trace(m_textAutosizer);
visitor->trace(m_fastTextAutosizer);
visitor->trace(m_registrationContext); visitor->trace(m_registrationContext);
visitor->trace(m_customElementMicrotaskRunQueue); visitor->trace(m_customElementMicrotaskRunQueue);
visitor->trace(m_elementDataCache); visitor->trace(m_elementDataCache);
......
...@@ -1357,8 +1357,8 @@ private: ...@@ -1357,8 +1357,8 @@ private:
RefPtrWillBeMember<ScriptedAnimationController> m_scriptedAnimationController; RefPtrWillBeMember<ScriptedAnimationController> m_scriptedAnimationController;
OwnPtr<MainThreadTaskRunner> m_taskRunner; OwnPtr<MainThreadTaskRunner> m_taskRunner;
OwnPtr<TextAutosizer> m_textAutosizer; OwnPtrWillBeMember<TextAutosizer> m_textAutosizer;
OwnPtr<FastTextAutosizer> m_fastTextAutosizer; OwnPtrWillBeMember<FastTextAutosizer> m_fastTextAutosizer;
RefPtrWillBeMember<CustomElementRegistrationContext> m_registrationContext; RefPtrWillBeMember<CustomElementRegistrationContext> m_registrationContext;
RefPtrWillBeMember<CustomElementMicrotaskRunQueue> m_customElementMicrotaskRunQueue; RefPtrWillBeMember<CustomElementMicrotaskRunQueue> m_customElementMicrotaskRunQueue;
......
...@@ -1154,4 +1154,9 @@ float FastTextAutosizer::computeAutosizedFontSize(float specifiedSize, float mul ...@@ -1154,4 +1154,9 @@ float FastTextAutosizer::computeAutosizedFontSize(float specifiedSize, float mul
return computedSize; return computedSize;
} }
void FastTextAutosizer::trace(Visitor* visitor)
{
visitor->trace(m_document);
}
} // namespace blink } // namespace blink
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "core/rendering/RenderObject.h" #include "core/rendering/RenderObject.h"
#include "core/rendering/RenderTable.h" #include "core/rendering/RenderTable.h"
#include "platform/heap/Handle.h"
#include "wtf/HashMap.h" #include "wtf/HashMap.h"
#include "wtf/HashSet.h" #include "wtf/HashSet.h"
#include "wtf/Noncopyable.h" #include "wtf/Noncopyable.h"
...@@ -49,13 +50,12 @@ class RenderListMarker; ...@@ -49,13 +50,12 @@ class RenderListMarker;
// Single-pass text autosizer. Documentation at: // Single-pass text autosizer. Documentation at:
// http://tinyurl.com/fasttextautosizer // http://tinyurl.com/fasttextautosizer
class FastTextAutosizer FINAL { class FastTextAutosizer FINAL : public NoBaseWillBeGarbageCollectedFinalized<FastTextAutosizer> {
WTF_MAKE_NONCOPYABLE(FastTextAutosizer); WTF_MAKE_NONCOPYABLE(FastTextAutosizer);
public: public:
static PassOwnPtr<FastTextAutosizer> create(const Document* document) static PassOwnPtrWillBeRawPtr<FastTextAutosizer> create(const Document* document)
{ {
return adoptPtr(new FastTextAutosizer(document)); return adoptPtrWillBeNoop(new FastTextAutosizer(document));
} }
static float computeAutosizedFontSize(float specifiedSize, float multiplier); static float computeAutosizedFontSize(float specifiedSize, float multiplier);
...@@ -65,6 +65,8 @@ public: ...@@ -65,6 +65,8 @@ public:
void destroy(const RenderBlock*); void destroy(const RenderBlock*);
void inflateListItem(RenderListItem*, RenderListMarker*); void inflateListItem(RenderListItem*, RenderListMarker*);
void trace(Visitor*);
class LayoutScope { class LayoutScope {
public: public:
explicit LayoutScope(RenderBlock*); explicit LayoutScope(RenderBlock*);
...@@ -287,7 +289,7 @@ private: ...@@ -287,7 +289,7 @@ private:
void writeClusterDebugInfo(Cluster*); void writeClusterDebugInfo(Cluster*);
#endif #endif
const Document* m_document; RawPtrWillBeMember<const Document> m_document;
const RenderBlock* m_firstBlockToBeginLayout; const RenderBlock* m_firstBlockToBeginLayout;
#if ENABLE(ASSERT) #if ENABLE(ASSERT)
BlockSet m_blocksThatHaveBegunLayout; // Used to ensure we don't compute properties of a block before beginLayout() is called on it. BlockSet m_blocksThatHaveBegunLayout; // Used to ensure we don't compute properties of a block before beginLayout() is called on it.
......
...@@ -825,4 +825,9 @@ void TextAutosizer::getNarrowDescendantsGroupedByWidth(const TextAutosizingClust ...@@ -825,4 +825,9 @@ void TextAutosizer::getNarrowDescendantsGroupedByWidth(const TextAutosizingClust
} }
} }
void TextAutosizer::trace(Visitor* visitor)
{
visitor->trace(m_document);
}
} // namespace blink } // namespace blink
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#define TextAutosizer_h #define TextAutosizer_h
#include "core/HTMLNames.h" #include "core/HTMLNames.h"
#include "platform/heap/Handle.h"
#include "platform/text/WritingMode.h" #include "platform/text/WritingMode.h"
#include "wtf/HashMap.h" #include "wtf/HashMap.h"
#include "wtf/Noncopyable.h" #include "wtf/Noncopyable.h"
...@@ -61,15 +62,19 @@ struct TextAutosizingClusterInfo { ...@@ -61,15 +62,19 @@ struct TextAutosizingClusterInfo {
Vector<TextAutosizingClusterInfo> narrowDescendants; Vector<TextAutosizingClusterInfo> narrowDescendants;
}; };
class TextAutosizer FINAL { class TextAutosizer FINAL : public NoBaseWillBeGarbageCollectedFinalized<TextAutosizer> {
WTF_MAKE_NONCOPYABLE(TextAutosizer); WTF_MAKE_NONCOPYABLE(TextAutosizer);
public: public:
static PassOwnPtr<TextAutosizer> create(Document* document) { return adoptPtr(new TextAutosizer(document)); } static PassOwnPtrWillBeRawPtr<TextAutosizer> create(Document* document)
{
return adoptPtrWillBeNoop(new TextAutosizer(document));
}
bool processSubtree(RenderObject* layoutRoot); bool processSubtree(RenderObject* layoutRoot);
void recalculateMultipliers(); void recalculateMultipliers();
void trace(Visitor*);
private: private:
friend class FastTextAutosizer; friend class FastTextAutosizer;
...@@ -126,7 +131,7 @@ private: ...@@ -126,7 +131,7 @@ private:
void secondPassProcessStaleNonAutosizedClusters(); void secondPassProcessStaleNonAutosizedClusters();
void processStaleContainer(float multiplier, RenderBlock* cluster, TextAutosizingClusterInfo&); void processStaleContainer(float multiplier, RenderBlock* cluster, TextAutosizingClusterInfo&);
Document* m_document; RawPtrWillBeMember<Document> m_document;
HashMap<const RenderObject*, unsigned> m_hashCache; HashMap<const RenderObject*, unsigned> m_hashCache;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment