InlineElementBox.cpp [plain text]
#include "config.h"
#include "InlineElementBox.h"
#include "InlineFlowBox.h"
#include "PaintInfo.h"
#include "RenderBlock.h"
#include "RenderBox.h"
#include "RenderLineBreak.h"
namespace WebCore {
void InlineElementBox::deleteLine()
{
if (!extracted()) {
if (renderer().isBox())
toRenderBox(renderer()).setInlineBoxWrapper(nullptr);
else if (renderer().isLineBreak())
toRenderLineBreak(renderer()).setInlineBoxWrapper(nullptr);
}
delete this;
}
void InlineElementBox::extractLine()
{
setExtracted(true);
if (renderer().isBox())
toRenderBox(renderer()).setInlineBoxWrapper(nullptr);
else if (renderer().isLineBreak())
toRenderLineBreak(renderer()).setInlineBoxWrapper(nullptr);
}
void InlineElementBox::attachLine()
{
setExtracted(false);
if (renderer().isBox())
toRenderBox(renderer()).setInlineBoxWrapper(this);
else if (renderer().isLineBreak())
toRenderLineBreak(renderer()).setInlineBoxWrapper(this);
}
void InlineElementBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit , LayoutUnit )
{
if (!paintInfo.shouldPaintWithinRoot(renderer()) || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
return;
LayoutPoint childPoint = paintOffset;
if (renderer().isBox() && parent()->renderer().style().isFlippedBlocksWritingMode()) childPoint = renderer().containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer()), childPoint);
bool preservePhase = paintInfo.phase == PaintPhaseSelection || paintInfo.phase == PaintPhaseTextClip;
PaintInfo info(paintInfo);
info.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground;
renderer().paint(info, childPoint);
if (!preservePhase) {
info.phase = PaintPhaseChildBlockBackgrounds;
renderer().paint(info, childPoint);
info.phase = PaintPhaseFloat;
renderer().paint(info, childPoint);
info.phase = PaintPhaseForeground;
renderer().paint(info, childPoint);
info.phase = PaintPhaseOutline;
renderer().paint(info, childPoint);
}
}
bool InlineElementBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit , LayoutUnit )
{
LayoutPoint childPoint = accumulatedOffset;
if (renderer().isBox() && parent()->renderer().style().isFlippedBlocksWritingMode()) childPoint = renderer().containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer()), childPoint);
return renderer().hitTest(request, result, locationInContainer, childPoint);
}
}