Skip to content
Permalink
Browse files
InlineBox: Make paint() and nodeAtPoint() pure virtuals.
<https://webkit.org/b/123937>

...and move the current implementations to InlineElementBox.
All subclasses were already overriding these functions so the move
is completely natural.

Reviewed by Anders Carlsson.

Canonical link: https://commits.webkit.org/142128@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158812 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Nov 7, 2013
1 parent 0814ca6 commit 04d0d2afe7766a658e37aba1ac22f9a3cad39de8
Showing 6 changed files with 58 additions and 45 deletions.
@@ -1,3 +1,14 @@
2013-11-06 Andreas Kling <akling@apple.com>

InlineBox: Make paint() and nodeAtPoint() pure virtuals.
<https://webkit.org/b/123937>

...and move the current implementations to InlineElementBox.
All subclasses were already overriding these functions so the move
is completely natural.

Reviewed by Anders Carlsson.

2013-11-06 Andreas Kling <akling@apple.com>

Nothing should return std::unique_ptr<InlineBox>.
@@ -1323,12 +1323,10 @@ __ZN7WebCore9HTMLNames9scriptTagE
__ZN7WebCore9HTMLNames9selectTagE
__ZN7WebCore9HTMLNames9styleAttrE
__ZN7WebCore9HTMLNames9valueAttrE
__ZN7WebCore9InlineBox11nodeAtPointERKNS_14HitTestRequestERNS_13HitTestResultERKNS_15HitTestLocationERKNS_11LayoutPointENS_10LayoutUnitESC_
__ZN7WebCore9InlineBox14adjustPositionEff
__ZN7WebCore9InlineBox14dirtyLineBoxesEv
__ZN7WebCore9InlineBox14selectionStateEv
__ZN7WebCore9InlineBox16placeEllipsisBoxEbfffRfRb
__ZN7WebCore9InlineBox5paintERNS_9PaintInfoERKNS_11LayoutPointENS_10LayoutUnitES6_
__ZN7WebCore9JSElement6s_infoE
__ZN7WebCore9PageCache11setCapacityEi
__ZN7WebCore9PageCache33markPagesForVistedLinkStyleRecalcEv
@@ -164,47 +164,6 @@ void InlineBox::adjustPosition(float dx, float dy)
toRenderBox(renderer()).move(dx, dy);
}

void InlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/)
{
RenderElement& renderer = toRenderElement(this->renderer());
if (!paintInfo.shouldPaintWithinRoot(renderer) || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
return;

LayoutPoint childPoint = paintOffset;
if (parent()->renderer().style().isFlippedBlocksWritingMode() && renderer.isBox()) // Faster than calling containingBlock().
childPoint = m_renderer.containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer), childPoint);

// Paint all phases of replaced elements atomically, as though the replaced element established its
// own stacking context. (See Appendix E.2, section 6.4 on inline block/table elements in the CSS2.1
// specification.)
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 InlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/)
{
// Hit test all phases of replaced elements atomically, as though the replaced element established its
// own stacking context. (See Appendix E.2, section 6.4 on inline block/table elements in the CSS2.1
// specification.)
LayoutPoint childPoint = accumulatedOffset;
if (parent()->renderer().style().isFlippedBlocksWritingMode() && !renderer().isLineBreak()) // Faster than calling containingBlock().
childPoint = m_renderer.containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer()), childPoint);

return m_renderer.hitTest(request, result, locationInContainer, childPoint);
}

const RootInlineBox& InlineBox::root() const
{
if (m_parent)
@@ -65,8 +65,8 @@ class InlineBox {
adjustPosition(delta, 0);
}

virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom);
virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) = 0;
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) = 0;

public:
#ifndef NDEBUG
@@ -26,6 +26,8 @@
#include "config.h"
#include "InlineElementBox.h"

#include "PaintInfo.h"
#include "RenderBlock.h"
#include "RenderBox.h"
#include "RenderLineBreak.h"

@@ -60,4 +62,44 @@ void InlineElementBox::attachLine()
toRenderLineBreak(renderer()).setInlineBoxWrapper(this);
}

void InlineElementBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/)
{
if (!paintInfo.shouldPaintWithinRoot(renderer()) || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
return;

LayoutPoint childPoint = paintOffset;
if (renderer().isBox() && parent()->renderer().style().isFlippedBlocksWritingMode()) // Faster than calling containingBlock().
childPoint = renderer().containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer()), childPoint);

// Paint all phases of replaced elements atomically, as though the replaced element established its
// own stacking context. (See Appendix E.2, section 6.4 on inline block/table elements in the CSS2.1
// specification.)
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 /* lineTop */, LayoutUnit /*lineBottom*/)
{
// Hit test all phases of replaced elements atomically, as though the replaced element established its
// own stacking context. (See Appendix E.2, section 6.4 on inline block/table elements in the CSS2.1
// specification.)
LayoutPoint childPoint = accumulatedOffset;
if (renderer().isBox() && parent()->renderer().style().isFlippedBlocksWritingMode()) // Faster than calling containingBlock().
childPoint = renderer().containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer()), childPoint);

return renderer().hitTest(request, result, locationInContainer, childPoint);
}

}
@@ -47,6 +47,9 @@ class InlineElementBox : public InlineBox {
virtual void deleteLine() OVERRIDE;
virtual void extractLine() OVERRIDE;
virtual void attachLine() OVERRIDE;

virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) OVERRIDE;
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) OVERRIDE;
};

}

0 comments on commit 04d0d2a

Please sign in to comment.