Commit 8a60ceb7 authored by tkent@chromium.org's avatar tkent@chromium.org

Oilpan: Prepare to move RenderSelectionInfoBase to Oilpan heap.

Because RenderSelectionInfoBase subclasses don't add Member<> fields,
RenderSelectionInfoBase::trace is not virtual.

BUG=398342

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

git-svn-id: svn://svn.chromium.org/blink/trunk@180263 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 74a30aa3
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
namespace blink { namespace blink {
class RenderSelectionInfoBase { class RenderSelectionInfoBase : public NoBaseWillBeGarbageCollected<RenderSelectionInfoBase> {
WTF_MAKE_NONCOPYABLE(RenderSelectionInfoBase); WTF_MAKE_FAST_ALLOCATED; WTF_MAKE_NONCOPYABLE(RenderSelectionInfoBase); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
public: public:
RenderSelectionInfoBase() RenderSelectionInfoBase()
: m_object(0) : m_object(nullptr)
, m_repaintContainer(0) , m_repaintContainer(nullptr)
, m_state(RenderObject::SelectionNone) , m_state(RenderObject::SelectionNone)
{ {
} }
...@@ -47,18 +47,24 @@ public: ...@@ -47,18 +47,24 @@ public:
{ {
} }
void trace(Visitor* visitor)
{
visitor->trace(m_object);
visitor->trace(m_repaintContainer);
}
RenderObject* object() const { return m_object; } RenderObject* object() const { return m_object; }
const RenderLayerModelObject* repaintContainer() const { return m_repaintContainer; } const RenderLayerModelObject* repaintContainer() const { return m_repaintContainer; }
RenderObject::SelectionState state() const { return m_state; } RenderObject::SelectionState state() const { return m_state; }
protected: protected:
RenderObject* m_object; RawPtrWillBeMember<RenderObject> m_object;
const RenderLayerModelObject* m_repaintContainer; RawPtrWillBeMember<const RenderLayerModelObject> m_repaintContainer;
RenderObject::SelectionState m_state; RenderObject::SelectionState m_state;
}; };
// This struct is used when the selection changes to cache the old and new state of the selection for each RenderObject. // This struct is used when the selection changes to cache the old and new state of the selection for each RenderObject.
class RenderSelectionInfo : public RenderSelectionInfoBase { class RenderSelectionInfo FINAL : public RenderSelectionInfoBase {
public: public:
RenderSelectionInfo(RenderObject* o, bool clipToVisibleContent) RenderSelectionInfo(RenderObject* o, bool clipToVisibleContent)
: RenderSelectionInfoBase(o) : RenderSelectionInfoBase(o)
...@@ -86,7 +92,7 @@ private: ...@@ -86,7 +92,7 @@ private:
// This struct is used when the selection changes to cache the old and new state of the selection for each RenderBlock. // This struct is used when the selection changes to cache the old and new state of the selection for each RenderBlock.
class RenderBlockSelectionInfo : public RenderSelectionInfoBase { class RenderBlockSelectionInfo FINAL : public RenderSelectionInfoBase {
public: public:
RenderBlockSelectionInfo(RenderBlock* b) RenderBlockSelectionInfo(RenderBlock* b)
: RenderSelectionInfoBase(b) : RenderSelectionInfoBase(b)
......
...@@ -542,7 +542,7 @@ static RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset ...@@ -542,7 +542,7 @@ static RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset
IntRect RenderView::selectionBounds(bool clipToVisibleContent) const IntRect RenderView::selectionBounds(bool clipToVisibleContent) const
{ {
typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectionMap; typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderObject>, OwnPtrWillBeMember<RenderSelectionInfo> > SelectionMap;
SelectionMap selectedObjects; SelectionMap selectedObjects;
RenderObject* os = m_selectionStart; RenderObject* os = m_selectionStart;
...@@ -550,13 +550,13 @@ IntRect RenderView::selectionBounds(bool clipToVisibleContent) const ...@@ -550,13 +550,13 @@ IntRect RenderView::selectionBounds(bool clipToVisibleContent) const
while (os && os != stop) { while (os && os != stop) {
if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) { if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) {
// Blocks are responsible for painting line gaps and margin gaps. They must be examined as well. // Blocks are responsible for painting line gaps and margin gaps. They must be examined as well.
selectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, clipToVisibleContent))); selectedObjects.set(os, adoptPtrWillBeNoop(new RenderSelectionInfo(os, clipToVisibleContent)));
RenderBlock* cb = os->containingBlock(); RenderBlock* cb = os->containingBlock();
while (cb && !cb->isRenderView()) { while (cb && !cb->isRenderView()) {
OwnPtr<RenderSelectionInfo>& blockInfo = selectedObjects.add(cb, nullptr).storedValue->value; OwnPtrWillBeMember<RenderSelectionInfo>& blockInfo = selectedObjects.add(cb, nullptr).storedValue->value;
if (blockInfo) if (blockInfo)
break; break;
blockInfo = adoptPtr(new RenderSelectionInfo(cb, clipToVisibleContent)); blockInfo = adoptPtrWillBeNoop(new RenderSelectionInfo(cb, clipToVisibleContent));
cb = cb->containingBlock(); cb = cb->containingBlock();
} }
} }
...@@ -646,14 +646,14 @@ void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e ...@@ -646,14 +646,14 @@ void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
int oldEndPos = m_selectionEndPos; int oldEndPos = m_selectionEndPos;
// Objects each have a single selection rect to examine. // Objects each have a single selection rect to examine.
typedef HashMap<RenderObject*, OwnPtr<RenderSelectionInfo> > SelectedObjectMap; typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderObject>, OwnPtrWillBeMember<RenderSelectionInfo> > SelectedObjectMap;
SelectedObjectMap oldSelectedObjects; SelectedObjectMap oldSelectedObjects;
SelectedObjectMap newSelectedObjects; SelectedObjectMap newSelectedObjects;
// Blocks contain selected objects and fill gaps between them, either on the left, right, or in between lines and blocks. // Blocks contain selected objects and fill gaps between them, either on the left, right, or in between lines and blocks.
// In order to get the repaint rect right, we have to examine left, middle, and right rects individually, since otherwise // In order to get the repaint rect right, we have to examine left, middle, and right rects individually, since otherwise
// the union of those rects might remain the same even when changes have occurred. // the union of those rects might remain the same even when changes have occurred.
typedef HashMap<RenderBlock*, OwnPtr<RenderBlockSelectionInfo> > SelectedBlockMap; typedef WillBeHeapHashMap<RawPtrWillBeMember<RenderBlock>, OwnPtrWillBeMember<RenderBlockSelectionInfo> > SelectedBlockMap;
SelectedBlockMap oldSelectedBlocks; SelectedBlockMap oldSelectedBlocks;
SelectedBlockMap newSelectedBlocks; SelectedBlockMap newSelectedBlocks;
...@@ -664,14 +664,14 @@ void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e ...@@ -664,14 +664,14 @@ void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
while (continueExploring) { while (continueExploring) {
if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) { if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) {
// Blocks are responsible for painting line gaps and margin gaps. They must be examined as well. // Blocks are responsible for painting line gaps and margin gaps. They must be examined as well.
oldSelectedObjects.set(os, adoptPtr(new RenderSelectionInfo(os, true))); oldSelectedObjects.set(os, adoptPtrWillBeNoop(new RenderSelectionInfo(os, true)));
if (blockRepaintMode == RepaintNewXOROld) { if (blockRepaintMode == RepaintNewXOROld) {
RenderBlock* cb = os->containingBlock(); RenderBlock* cb = os->containingBlock();
while (cb && !cb->isRenderView()) { while (cb && !cb->isRenderView()) {
OwnPtr<RenderBlockSelectionInfo>& blockInfo = oldSelectedBlocks.add(cb, nullptr).storedValue->value; OwnPtrWillBeMember<RenderBlockSelectionInfo>& blockInfo = oldSelectedBlocks.add(cb, nullptr).storedValue->value;
if (blockInfo) if (blockInfo)
break; break;
blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb)); blockInfo = adoptPtrWillBeNoop(new RenderBlockSelectionInfo(cb));
cb = cb->containingBlock(); cb = cb->containingBlock();
} }
} }
...@@ -720,13 +720,13 @@ void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e ...@@ -720,13 +720,13 @@ void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
continueExploring = o && (o != stop); continueExploring = o && (o != stop);
while (continueExploring) { while (continueExploring) {
if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionState() != SelectionNone) { if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionState() != SelectionNone) {
newSelectedObjects.set(o, adoptPtr(new RenderSelectionInfo(o, true))); newSelectedObjects.set(o, adoptPtrWillBeNoop(new RenderSelectionInfo(o, true)));
RenderBlock* cb = o->containingBlock(); RenderBlock* cb = o->containingBlock();
while (cb && !cb->isRenderView()) { while (cb && !cb->isRenderView()) {
OwnPtr<RenderBlockSelectionInfo>& blockInfo = newSelectedBlocks.add(cb, nullptr).storedValue->value; OwnPtrWillBeMember<RenderBlockSelectionInfo>& blockInfo = newSelectedBlocks.add(cb, nullptr).storedValue->value;
if (blockInfo) if (blockInfo)
break; break;
blockInfo = adoptPtr(new RenderBlockSelectionInfo(cb)); blockInfo = adoptPtrWillBeNoop(new RenderBlockSelectionInfo(cb));
cb = cb->containingBlock(); cb = cb->containingBlock();
} }
} }
......
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