#include "core/rendering/RenderBox.h"
#include "platform/geometry/IntRect.h"
-namespace WebCore {
+namespace blink {
-class RenderSelectionInfoBase {
- WTF_MAKE_NONCOPYABLE(RenderSelectionInfoBase); WTF_MAKE_FAST_ALLOCATED;
+class RenderSelectionInfoBase : public NoBaseWillBeGarbageCollected<RenderSelectionInfoBase> {
+ WTF_MAKE_NONCOPYABLE(RenderSelectionInfoBase); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
public:
RenderSelectionInfoBase()
- : m_object(0)
- , m_repaintContainer(0)
+ : m_object(nullptr)
+ , m_repaintContainer(nullptr)
, m_state(RenderObject::SelectionNone)
{
}
RenderSelectionInfoBase(RenderObject* o)
: m_object(o)
- , m_repaintContainer(o->containerForRepaint())
+ , m_repaintContainer(o->containerForPaintInvalidation())
, m_state(o->selectionState())
{
}
+ void trace(Visitor* visitor)
+ {
+ visitor->trace(m_object);
+ visitor->trace(m_repaintContainer);
+ }
+
RenderObject* object() const { return m_object; }
const RenderLayerModelObject* repaintContainer() const { return m_repaintContainer; }
RenderObject::SelectionState state() const { return m_state; }
protected:
- RenderObject* m_object;
- const RenderLayerModelObject* m_repaintContainer;
+ RawPtrWillBeMember<RenderObject> m_object;
+ RawPtrWillBeMember<const RenderLayerModelObject> m_repaintContainer;
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.
-class RenderSelectionInfo : public RenderSelectionInfoBase {
+class RenderSelectionInfo FINAL : public RenderSelectionInfoBase {
public:
RenderSelectionInfo(RenderObject* o, bool clipToVisibleContent)
: RenderSelectionInfoBase(o)
- , m_rect(o->canUpdateSelectionOnRootLineBoxes() ? o->selectionRectForRepaint(m_repaintContainer, clipToVisibleContent) : LayoutRect())
{
+ if (o->canUpdateSelectionOnRootLineBoxes()) {
+ m_rect = o->selectionRectForPaintInvalidation(m_repaintContainer, clipToVisibleContent);
+ // FIXME: groupedMapping() leaks the squashing abstraction. See RenderBlockSelectionInfo for more details.
+ if (m_repaintContainer && m_repaintContainer->layer()->groupedMapping())
+ RenderLayer::mapRectToPaintInvalidationBacking(m_repaintContainer, m_repaintContainer, m_rect);
+ } else {
+ m_rect = LayoutRect();
+ }
}
void repaint()
{
- m_object->repaintUsingContainer(m_repaintContainer, enclosingIntRect(m_rect), InvalidationSelection);
+ m_object->invalidatePaintUsingContainer(m_repaintContainer, enclosingIntRect(m_rect), InvalidationSelection);
}
LayoutRect rect() const { return m_rect; }
// 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:
RenderBlockSelectionInfo(RenderBlock* b)
: RenderSelectionInfoBase(b)
- , m_rects(b->canUpdateSelectionOnRootLineBoxes() ? block()->selectionGapRectsForRepaint(m_repaintContainer) : GapRects())
{
+ if (b->canUpdateSelectionOnRootLineBoxes())
+ m_rects = block()->selectionGapRectsForRepaint(m_repaintContainer);
+ else
+ m_rects = GapRects();
}
void repaint()
{
- m_object->repaintUsingContainer(m_repaintContainer, enclosingIntRect(m_rects), InvalidationSelection);
+ LayoutRect repaintRect = m_rects;
+ // FIXME: this is leaking the squashing abstraction. However, removing the groupedMapping() condiitional causes
+ // RenderBox::mapRectToPaintInvalidationBacking to get called, which makes rect adjustments even if you pass the same
+ // repaintContainer as the render object. Find out why it does that and fix.
+ if (m_repaintContainer && m_repaintContainer->layer()->groupedMapping())
+ RenderLayer::mapRectToPaintInvalidationBacking(m_repaintContainer, m_repaintContainer, repaintRect);
+ m_object->invalidatePaintUsingContainer(m_repaintContainer, enclosingIntRect(repaintRect), InvalidationSelection);
}
RenderBlock* block() const { return toRenderBlock(m_object); }
GapRects m_rects; // relative to repaint container
};
-} // namespace WebCore
+} // namespace blink
#endif // RenderSelectionInfo_h