class HitTestResult;
class RootInlineBox;
+enum MarkLineBoxes { MarkLineBoxesDirty, DontMarkLineBoxes };
+
// InlineBox represents a rectangle that occurs on a line. It corresponds to
// some RenderObject (i.e., it represents a portion of that RenderObject).
class InlineBox {
+ WTF_MAKE_NONCOPYABLE(InlineBox);
public:
- InlineBox(RenderObject* obj)
+ InlineBox(RenderObject& obj)
: m_next(0)
, m_prev(0)
, m_parent(0)
{
}
- InlineBox(RenderObject* obj, FloatPoint topLeft, float logicalWidth, bool firstLine, bool constructed,
+ InlineBox(RenderObject& obj, FloatPoint topLeft, float logicalWidth, bool firstLine, bool constructed,
bool dirty, bool extracted, bool isHorizontal, InlineBox* next, InlineBox* prev, InlineFlowBox* parent)
: m_next(next)
, m_prev(prev)
void* operator new(size_t);
void operator delete(void*);
-public:
#ifndef NDEBUG
void showTreeForThis() const;
void showLineTreeForThis() const;
void setFirstLineStyleBit(bool firstLine) { m_bitfields.setFirstLine(firstLine); }
bool isFirstLineStyle() const { return m_bitfields.firstLine(); }
- void remove();
+ void remove(MarkLineBoxes = MarkLineBoxesDirty);
InlineBox* nextOnLine() const { return m_next; }
InlineBox* prevOnLine() const { return m_prev; }
InlineBox* nextLeafChildIgnoringLineBreak() const;
InlineBox* prevLeafChildIgnoringLineBreak() const;
- RenderObject* renderer() const { return m_renderer; }
+ RenderObject& renderer() const { return m_renderer; }
InlineFlowBox* parent() const
{
}
void setParent(InlineFlowBox* par) { m_parent = par; }
- const RootInlineBox* root() const;
- RootInlineBox* root();
+ const RootInlineBox& root() const;
+ RootInlineBox& root();
// x() is the left side of the box in the containing block's coordinate system.
void setX(float x) { m_topLeft.setX(x); }
const FloatPoint& topLeft() const { return m_topLeft; }
- float width() const { return isHorizontal() ? logicalWidth() : logicalHeight(); }
- float height() const { return isHorizontal() ? logicalHeight() : logicalWidth(); }
+ float width() const { return isHorizontal() ? logicalWidth() : hasVirtualLogicalHeight() ? virtualLogicalHeight() : logicalHeight(); }
+ float height() const { return isHorizontal() ? hasVirtualLogicalHeight() ? virtualLogicalHeight() : logicalHeight() : logicalWidth(); }
FloatSize size() const { return FloatSize(width(), height()); }
float right() const { return left() + width(); }
float bottom() const { return top() + height(); }
virtual void clearTruncation() { }
bool isDirty() const { return m_bitfields.dirty(); }
- virtual void markDirty(bool dirty = true) { m_bitfields.setDirty(dirty); }
+ virtual void markDirty() { m_bitfields.setDirty(true); }
virtual void dirtyLineBoxes();
int expansion() const { return m_bitfields.expansion(); }
- bool visibleToHitTestRequest(const HitTestRequest& request) const { return renderer()->visibleToHitTestRequest(request); }
+ bool visibleForTouchAction() const { return false; }
+ bool visibleToHitTestRequest(const HitTestRequest& request) const
+ {
+ if (request.touchAction() && !visibleForTouchAction())
+ return false;
+ return renderer().visibleToHitTestRequest(request);
+ }
- EVerticalAlign verticalAlign() const { return renderer()->style(m_bitfields.firstLine())->verticalAlign(); }
+ EVerticalAlign verticalAlign() const { return renderer().style(m_bitfields.firstLine())->verticalAlign(); }
// Use with caution! The type is not checked!
RenderBoxModelObject* boxModelObject() const
{
- if (!m_renderer->isText())
- return toRenderBoxModelObject(m_renderer);
+ if (!renderer().isText())
+ return toRenderBoxModelObject(&renderer());
return 0;
}
bool dirOverride() const { return m_bitfields.dirOverride(); }
void setDirOverride(bool dirOverride) { m_bitfields.setDirOverride(dirOverride); }
-private:
- InlineBox* m_next; // The next element on the same line as us.
- InlineBox* m_prev; // The previous element on the same line as us.
-
- InlineFlowBox* m_parent; // The box that contains us.
-
-public:
#define ADD_BOOLEAN_BITFIELD(name, Name) \
private:\
unsigned m_##name : 1;\
};
#undef ADD_BOOLEAN_BITFIELD
+private:
+ InlineBox* m_next; // The next element on the same line as us.
+ InlineBox* m_prev; // The previous element on the same line as us.
+
+ InlineFlowBox* m_parent; // The box that contains us.
+ RenderObject& m_renderer;
+
protected:
// For RootInlineBox
bool endsWithBreak() const { return m_bitfields.endsWithBreak(); }
// For InlineFlowBox and InlineTextBox
bool extracted() const { return m_bitfields.extracted(); }
- RenderObject* m_renderer;
-
FloatPoint m_topLeft;
float m_logicalWidth;
}
#endif
+#define DEFINE_INLINE_BOX_TYPE_CASTS(typeName) \
+ DEFINE_TYPE_CASTS(typeName, InlineBox, box, box->is##typeName(), box.is##typeName())
+
+// Allow equality comparisons of InlineBox's by reference or pointer, interchangeably.
+inline bool operator==(const InlineBox& a, const InlineBox& b) { return &a == &b; }
+inline bool operator==(const InlineBox& a, const InlineBox* b) { return &a == b; }
+inline bool operator==(const InlineBox* a, const InlineBox& b) { return a == &b; }
+inline bool operator!=(const InlineBox& a, const InlineBox& b) { return !(a == b); }
+inline bool operator!=(const InlineBox& a, const InlineBox* b) { return !(a == b); }
+inline bool operator!=(const InlineBox* a, const InlineBox& b) { return !(a == b); }
+
} // namespace WebCore
#ifndef NDEBUG