Diff
Modified: trunk/Source/WebCore/ChangeLog (158831 => 158832)
--- trunk/Source/WebCore/ChangeLog 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/ChangeLog 2013-11-07 10:08:04 UTC (rev 158832)
@@ -1,3 +1,17 @@
+2013-11-07 Andreas Kling <[email protected]>
+
+ Generate type casting helpers for line boxes and use them.
+ <https://webkit.org/b/123976>
+
+ Semi-automatically generate the full set of toFooInlineBox()
+ helpers with macros instead of having them (partially) hand-coded.
+ Replaced static_casts with the new helpers across the codebase.
+
+ Also made the isFooInlineBox() overrides private since they should
+ never be called when the type is already known.
+
+ Reviewed by Antti Koivisto.
+
2013-11-07 Ryosuke Niwa <[email protected]>
Simplify Attr by removing m_specified member variable and setter
Modified: trunk/Source/WebCore/dom/Position.cpp (158831 => 158832)
--- trunk/Source/WebCore/dom/Position.cpp 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/dom/Position.cpp 2013-11-07 10:08:04 UTC (rev 158832)
@@ -676,7 +676,7 @@
otherBox = otherBox->nextLeafChild();
if (!otherBox)
break;
- if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && static_cast<InlineTextBox*>(otherBox)->start() > textOffset))
+ if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && toInlineTextBox(otherBox)->start() > textOffset))
continuesOnNextLine = false;
}
@@ -685,7 +685,7 @@
otherBox = otherBox->prevLeafChild();
if (!otherBox)
break;
- if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && static_cast<InlineTextBox*>(otherBox)->start() > textOffset))
+ if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && toInlineTextBox(otherBox)->start() > textOffset))
continuesOnNextLine = false;
}
@@ -804,7 +804,7 @@
otherBox = otherBox->nextLeafChild();
if (!otherBox)
break;
- if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && static_cast<InlineTextBox*>(otherBox)->start() >= textOffset))
+ if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && toInlineTextBox(otherBox)->start() >= textOffset))
continuesOnNextLine = false;
}
@@ -813,7 +813,7 @@
otherBox = otherBox->prevLeafChild();
if (!otherBox)
break;
- if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && static_cast<InlineTextBox*>(otherBox)->start() >= textOffset))
+ if (otherBox == lastTextBox || (&otherBox->renderer() == &textRenderer && toInlineTextBox(otherBox)->start() >= textOffset))
continuesOnNextLine = false;
}
Modified: trunk/Source/WebCore/rendering/InlineBox.cpp (158831 => 158832)
--- trunk/Source/WebCore/rendering/InlineBox.cpp 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/InlineBox.cpp 2013-11-07 10:08:04 UTC (rev 158832)
@@ -169,7 +169,7 @@
if (m_parent)
return m_parent->root();
ASSERT_WITH_SECURITY_IMPLICATION(isRootInlineBox());
- return static_cast<const RootInlineBox&>(*this);
+ return toRootInlineBox(*this);
}
RootInlineBox& InlineBox::root()
@@ -177,7 +177,7 @@
if (m_parent)
return m_parent->root();
ASSERT_WITH_SECURITY_IMPLICATION(isRootInlineBox());
- return static_cast<RootInlineBox&>(*this);
+ return toRootInlineBox(*this);
}
bool InlineBox::nextOnLineExists() const
Modified: trunk/Source/WebCore/rendering/InlineBox.h (158831 => 158832)
--- trunk/Source/WebCore/rendering/InlineBox.h 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/InlineBox.h 2013-11-07 10:08:04 UTC (rev 158832)
@@ -80,7 +80,8 @@
bool behavesLikeText() const { return m_bitfields.behavesLikeText(); }
void setBehavesLikeText(bool behavesLikeText) { m_bitfields.setBehavesLikeText(behavesLikeText); }
-
+
+ virtual bool isInlineElementBox() const { return false; }
virtual bool isInlineFlowBox() const { return false; }
virtual bool isInlineTextBox() const { return false; }
virtual bool isRootInlineBox() const { return false; }
@@ -412,6 +413,9 @@
#endif
};
+#define INLINE_BOX_OBJECT_TYPE_CASTS(ToValueTypeName, predicate) \
+ TYPE_CASTS_BASE(ToValueTypeName, InlineBox, object, object->predicate, object.predicate)
+
#if ASSERT_DISABLED
inline InlineBox::~InlineBox()
{
Modified: trunk/Source/WebCore/rendering/InlineElementBox.h (158831 => 158832)
--- trunk/Source/WebCore/rendering/InlineElementBox.h 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/InlineElementBox.h 2013-11-07 10:08:04 UTC (rev 158832)
@@ -50,8 +50,13 @@
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;
+
+private:
+ virtual bool isInlineElementBox() const OVERRIDE FINAL { return true; }
};
+INLINE_BOX_OBJECT_TYPE_CASTS(InlineElementBox, isInlineElementBox())
+
}
#endif // InlineElementBox_h
Modified: trunk/Source/WebCore/rendering/InlineFlowBox.h (158831 => 158832)
--- trunk/Source/WebCore/rendering/InlineFlowBox.h 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.h 2013-11-07 10:08:04 UTC (rev 158832)
@@ -293,6 +293,8 @@
}
private:
+ virtual bool isInlineFlowBox() const OVERRIDE FINAL { return true; }
+
void addBoxShadowVisualOverflow(LayoutRect& logicalVisualOverflow);
void addBorderOutsetVisualOverflow(LayoutRect& logicalVisualOverflow);
void addTextBoxVisualOverflow(InlineTextBox*, GlyphOverflowAndFallbackFontsMap&, LayoutRect& logicalVisualOverflow);
@@ -302,8 +304,6 @@
protected:
OwnPtr<RenderOverflow> m_overflow;
- virtual bool isInlineFlowBox() const OVERRIDE FINAL { return true; }
-
InlineBox* m_firstChild;
InlineBox* m_lastChild;
@@ -344,21 +344,8 @@
#endif
};
-inline InlineFlowBox* toInlineFlowBox(InlineBox* object)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isInlineFlowBox());
- return static_cast<InlineFlowBox*>(object);
-}
+INLINE_BOX_OBJECT_TYPE_CASTS(InlineFlowBox, isInlineFlowBox())
-inline const InlineFlowBox* toInlineFlowBox(const InlineBox* object)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isInlineFlowBox());
- return static_cast<const InlineFlowBox*>(object);
-}
-
-// This will catch anyone doing an unnecessary cast.
-void toInlineFlowBox(const InlineFlowBox*);
-
#ifdef NDEBUG
inline void InlineFlowBox::checkConsistency() const
{
Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (158831 => 158832)
--- trunk/Source/WebCore/rendering/InlineTextBox.h 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h 2013-11-07 10:08:04 UTC (rev 158832)
@@ -195,21 +195,8 @@
unsigned short m_truncation;
};
-inline InlineTextBox* toInlineTextBox(InlineBox* inlineBox)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!inlineBox || inlineBox->isInlineTextBox());
- return static_cast<InlineTextBox*>(inlineBox);
-}
+INLINE_BOX_OBJECT_TYPE_CASTS(InlineTextBox, isInlineTextBox())
-inline const InlineTextBox* toInlineTextBox(const InlineBox* inlineBox)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!inlineBox || inlineBox->isInlineTextBox());
- return static_cast<const InlineTextBox*>(inlineBox);
-}
-
-// This will catch anyone doing an unnecessary cast.
-void toInlineTextBox(const InlineTextBox*);
-
void alignSelectionRectToDevicePixels(FloatRect&);
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (158831 => 158832)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.h 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h 2013-11-07 10:08:04 UTC (rev 158832)
@@ -308,8 +308,8 @@
RenderLineBoxList& lineBoxes() { return m_lineBoxes; }
const RenderLineBoxList& lineBoxes() const { return m_lineBoxes; }
- RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(m_lineBoxes.firstLineBox()); }
- RootInlineBox* lastRootBox() const { return static_cast<RootInlineBox*>(m_lineBoxes.lastLineBox()); }
+ RootInlineBox* firstRootBox() const { return toRootInlineBox(m_lineBoxes.firstLineBox()); }
+ RootInlineBox* lastRootBox() const { return toRootInlineBox(m_lineBoxes.lastLineBox()); }
virtual bool hasLines() const OVERRIDE FINAL;
Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (158831 => 158832)
--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2013-11-07 10:08:04 UTC (rev 158832)
@@ -1239,7 +1239,7 @@
// text selection in RTL boxes would not work as expected.
if (isSVGRootInlineBox) {
ASSERT_WITH_SECURITY_IMPLICATION(isSVGText());
- static_cast<SVGRootInlineBox*>(lineBox)->computePerCharacterLayoutInformation();
+ toSVGRootInlineBox(lineBox)->computePerCharacterLayoutInformation();
}
#endif
Modified: trunk/Source/WebCore/rendering/RootInlineBox.h (158831 => 158832)
--- trunk/Source/WebCore/rendering/RootInlineBox.h 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/RootInlineBox.h 2013-11-07 10:08:04 UTC (rev 158832)
@@ -40,13 +40,12 @@
explicit RootInlineBox(RenderBlockFlow&);
virtual ~RootInlineBox();
- virtual bool isRootInlineBox() const OVERRIDE FINAL { return true; }
RenderBlockFlow& blockFlow() const;
void detachEllipsisBox();
- RootInlineBox* nextRootBox() const { return static_cast<RootInlineBox*>(m_nextLineBox); }
- RootInlineBox* prevRootBox() const { return static_cast<RootInlineBox*>(m_prevLineBox); }
+ RootInlineBox* nextRootBox() const;
+ RootInlineBox* prevRootBox() const;
virtual void adjustPosition(float dx, float dy) OVERRIDE FINAL;
@@ -201,6 +200,8 @@
virtual const char* boxName() const OVERRIDE;
#endif
private:
+ virtual bool isRootInlineBox() const OVERRIDE FINAL { return true; }
+
LayoutUnit lineSnapAdjustment(LayoutUnit delta = 0) const;
LayoutUnit beforeAnnotationsAdjustment() const;
@@ -255,6 +256,18 @@
OwnPtr<Vector<RenderBox*>> m_floats;
};
+INLINE_BOX_OBJECT_TYPE_CASTS(RootInlineBox, isRootInlineBox())
+
+inline RootInlineBox* RootInlineBox::nextRootBox() const
+{
+ return toRootInlineBox(m_nextLineBox);
+}
+
+inline RootInlineBox* RootInlineBox::prevRootBox() const
+{
+ return toRootInlineBox(m_prevLineBox);
+}
+
} // namespace WebCore
#endif // RootInlineBox_h
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp (158831 => 158832)
--- trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp 2013-11-07 10:08:04 UTC (rev 158832)
@@ -118,7 +118,7 @@
if (!box || !box->isInlineTextBox())
return LayoutRect();
- InlineTextBox* textBox = static_cast<InlineTextBox*>(box);
+ InlineTextBox* textBox = toInlineTextBox(box);
if (static_cast<unsigned>(caretOffset) < textBox->start() || static_cast<unsigned>(caretOffset) > textBox->start() + textBox->len())
return LayoutRect();
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp (158831 => 158832)
--- trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp 2013-11-07 10:08:04 UTC (rev 158832)
@@ -484,7 +484,7 @@
ASSERT(!rootBox->nextRootBox());
ASSERT(childrenInline());
- InlineBox* closestBox = static_cast<SVGRootInlineBox*>(rootBox)->closestLeafChildForPosition(pointInContents);
+ InlineBox* closestBox = toSVGRootInlineBox(rootBox)->closestLeafChildForPosition(pointInContents);
if (!closestBox)
return createVisiblePosition(0, DOWNSTREAM);
Modified: trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.h (158831 => 158832)
--- trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.h 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.h 2013-11-07 10:08:04 UTC (rev 158832)
@@ -53,11 +53,7 @@
float m_logicalHeight;
};
-inline SVGInlineFlowBox* toSVGInlineFlowBox(InlineBox* box)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!box || box->isSVGInlineFlowBox());
- return static_cast<SVGInlineFlowBox*>(box);
-}
+INLINE_BOX_OBJECT_TYPE_CASTS(SVGInlineFlowBox, isSVGInlineFlowBox())
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h (158831 => 158832)
--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h 2013-11-07 10:08:04 UTC (rev 158832)
@@ -38,8 +38,6 @@
RenderSVGInlineText& renderer() const { return toRenderSVGInlineText(InlineTextBox::renderer()); }
- virtual bool isSVGInlineTextBox() const { return true; }
-
virtual float virtualLogicalHeight() const { return m_logicalHeight; }
void setLogicalHeight(float height) { m_logicalHeight = height; }
@@ -69,6 +67,8 @@
FloatRect selectionRectForTextFragment(const SVGTextFragment&, int fragmentStartPosition, int fragmentEndPosition, RenderStyle*) const;
private:
+ virtual bool isSVGInlineTextBox() const OVERRIDE { return true; }
+
TextRun constructTextRun(RenderStyle*, const SVGTextFragment&) const;
bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderBoxModelObject&, RenderStyle*);
@@ -92,11 +92,7 @@
Vector<SVGTextFragment> m_textFragments;
};
-inline SVGInlineTextBox* toSVGInlineTextBox(InlineBox* box)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!box || box->isSVGInlineTextBox());
- return static_cast<SVGInlineTextBox*>(box);
-}
+INLINE_BOX_OBJECT_TYPE_CASTS(SVGInlineTextBox, isSVGInlineTextBox())
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp (158831 => 158832)
--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp 2013-11-07 10:08:04 UTC (rev 158832)
@@ -378,7 +378,7 @@
static void writeRenderSVGTextBox(TextStream& ts, const RenderSVGText& text)
{
- SVGRootInlineBox* box = static_cast<SVGRootInlineBox*>(text.firstRootBox());
+ SVGRootInlineBox* box = toSVGRootInlineBox(text.firstRootBox());
if (!box)
return;
Modified: trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h (158831 => 158832)
--- trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h 2013-11-07 10:08:04 UTC (rev 158832)
@@ -37,7 +37,6 @@
public:
SVGRootInlineBox(RenderSVGText&);
- virtual bool isSVGRootInlineBox() const { return true; }
RenderSVGText& renderSVGText();
virtual float virtualLogicalHeight() const { return m_logicalHeight; }
@@ -53,6 +52,7 @@
InlineBox* closestLeafChildForPosition(const LayoutPoint&);
private:
+ virtual bool isSVGRootInlineBox() const OVERRIDE { return true; }
void reorderValueLists(Vector<SVGTextLayoutAttributes*>&);
void layoutCharactersInTextBoxes(InlineFlowBox*, SVGTextLayoutEngine&);
void layoutChildBoxes(InlineFlowBox*, FloatRect* = 0);
@@ -61,6 +61,8 @@
float m_logicalHeight;
};
+INLINE_BOX_OBJECT_TYPE_CASTS(SVGRootInlineBox, isSVGRootInlineBox())
+
} // namespace WebCore
#endif // ENABLE(SVG)
Modified: trunk/Source/WebCore/rendering/svg/SVGTextQuery.cpp (158831 => 158832)
--- trunk/Source/WebCore/rendering/svg/SVGTextQuery.cpp 2013-11-07 10:04:22 UTC (rev 158831)
+++ trunk/Source/WebCore/rendering/svg/SVGTextQuery.cpp 2013-11-07 10:08:04 UTC (rev 158832)
@@ -96,7 +96,7 @@
if (!child->renderer().node())
continue;
- collectTextBoxesInFlowBox(static_cast<InlineFlowBox*>(child));
+ collectTextBoxesInFlowBox(toInlineFlowBox(child));
continue;
}