SelectionRectGatherer.cpp [plain text]
#include "config.h"
#include "SelectionRectGatherer.h"
#if ENABLE(SERVICE_CONTROLS)
#include "Editor.h"
#include "EditorClient.h"
#include "Frame.h"
#include "MainFrame.h"
#include "RenderView.h"
#include "ServicesOverlayController.h"
namespace WebCore {
SelectionRectGatherer::SelectionRectGatherer(RenderView& renderView)
: m_renderView(renderView)
, m_isTextOnly(true)
{
}
void SelectionRectGatherer::addRect(RenderLayerModelObject *repaintContainer, const LayoutRect& rect)
{
if (!rect.isEmpty()) {
if (repaintContainer)
m_rects.append(LayoutRect(repaintContainer->localToAbsoluteQuad(FloatQuad(rect)).boundingBox()));
else
m_rects.append(rect);
}
}
void SelectionRectGatherer::addGapRects(RenderLayerModelObject *repaintContainer, const GapRects& rects)
{
if (repaintContainer) {
GapRects absoluteGapRects;
absoluteGapRects.uniteLeft(LayoutRect(repaintContainer->localToAbsoluteQuad(FloatQuad(rects.left())).boundingBox()));
absoluteGapRects.uniteCenter(LayoutRect(repaintContainer->localToAbsoluteQuad(FloatQuad(rects.center())).boundingBox()));
absoluteGapRects.uniteRight(LayoutRect(repaintContainer->localToAbsoluteQuad(FloatQuad(rects.right())).boundingBox()));
m_gapRects.append(absoluteGapRects);
} else
m_gapRects.append(rects);
}
SelectionRectGatherer::Notifier::Notifier(SelectionRectGatherer& gatherer)
: m_gatherer(gatherer)
{
}
SelectionRectGatherer::Notifier::~Notifier()
{
m_gatherer.m_renderView.view().frame().mainFrame().servicesOverlayController().selectionRectsDidChange(m_gatherer.m_rects, m_gatherer.m_gapRects, m_gatherer.isTextOnly());
}
std::unique_ptr<SelectionRectGatherer::Notifier> SelectionRectGatherer::clearAndCreateNotifier()
{
m_rects.clear();
m_gapRects.clear();
m_isTextOnly = true;
return std::make_unique<Notifier>(*this);
}
}
#endif // ENABLE(SERVICE_CONTROLS)