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 (is<RenderBox>(renderer()))
downcast<RenderBox>(renderer()).setInlineBoxWrapper(nullptr);
else if (is<RenderLineBreak>(renderer()))
downcast<RenderLineBreak>(renderer()).setInlineBoxWrapper(nullptr);
}
delete this;
}
void InlineElementBox::extractLine()
{
setExtracted(true);
if (is<RenderBox>(renderer()))
downcast<RenderBox>(renderer()).setInlineBoxWrapper(nullptr);
else if (is<RenderLineBreak>(renderer()))
downcast<RenderLineBreak>(renderer()).setInlineBoxWrapper(nullptr);
}
void InlineElementBox::attachLine()
{
setExtracted(false);
if (is<RenderBox>(renderer()))
downcast<RenderBox>(renderer()).setInlineBoxWrapper(this);
else if (is<RenderLineBreak>(renderer()))
downcast<RenderLineBreak>(renderer()).setInlineBoxWrapper(this);
}
void InlineElementBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit , LayoutUnit )
{
if (!paintInfo.shouldPaintWithinRoot(renderer()))
return;
if (renderer().isAnonymousInlineBlock()) {
PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? PaintPhaseOutline : paintInfo.phase;
newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChildBlockBackground : newPhase;
PaintInfo info(paintInfo);
info.phase = newPhase;
info.updateSubtreePaintRootForChildren(&renderer());
ASSERT(!renderer().hasSelfPaintingLayer());
renderer().paint(info, paintOffset);
return;
}
if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection)
return;
LayoutPoint childPoint = paintOffset;
if (is<RenderBox>(renderer()) && parent()->renderer().style().isFlippedBlocksWritingMode()) childPoint = renderer().containingBlock()->flipForWritingModeForChild(&downcast<RenderBox>(renderer()), childPoint);
renderer().paintAsInlineBlock(paintInfo, childPoint);
}
bool InlineElementBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit , LayoutUnit ,
HitTestAction hitTestAction)
{
if (renderer().isAnonymousInlineBlock()) {
HitTestAction childHitTest = hitTestAction;
if (hitTestAction == HitTestChildBlockBackgrounds)
childHitTest = HitTestChildBlockBackground;
return renderer().nodeAtPoint(request, result, locationInContainer, accumulatedOffset, childHitTest);
}
LayoutPoint childPoint = accumulatedOffset;
if (is<RenderBox>(renderer()) && parent()->renderer().style().isFlippedBlocksWritingMode()) childPoint = renderer().containingBlock()->flipForWritingModeForChild(&downcast<RenderBox>(renderer()), childPoint);
return renderer().hitTest(request, result, locationInContainer, childPoint);
}
}