/WebCore/rendering/RootInlineBox.h

http://github.com/CyanogenMod/android_external_webkit · C++ Header · 165 lines · 98 code · 43 blank · 24 comment · 1 complexity · 60c95fda66a1d1eba0660ed83341c002 MD5 · raw file

  1. /*
  2. * Copyright (C) 2003, 2006, 2007, 2008 Apple Inc. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public License
  15. * along with this library; see the file COPYING.LIB. If not, write to
  16. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. *
  19. */
  20. #ifndef RootInlineBox_h
  21. #define RootInlineBox_h
  22. #include "BidiContext.h"
  23. #include "InlineFlowBox.h"
  24. namespace WebCore {
  25. class EllipsisBox;
  26. class HitTestResult;
  27. struct BidiStatus;
  28. struct GapRects;
  29. class RootInlineBox : public InlineFlowBox {
  30. public:
  31. RootInlineBox(RenderObject* obj)
  32. : InlineFlowBox(obj)
  33. , m_lineBreakObj(0)
  34. , m_lineBreakPos(0)
  35. , m_lineTop(0)
  36. , m_lineBottom(0)
  37. {
  38. }
  39. virtual void destroy(RenderArena*);
  40. virtual bool isRootInlineBox() const { return true; }
  41. void detachEllipsisBox(RenderArena*);
  42. RootInlineBox* nextRootBox() const { return static_cast<RootInlineBox*>(m_nextLine); }
  43. RootInlineBox* prevRootBox() const { return static_cast<RootInlineBox*>(m_prevLine); }
  44. virtual void adjustPosition(int dx, int dy);
  45. int lineTop() const { return m_lineTop; }
  46. int lineBottom() const { return m_lineBottom; }
  47. int selectionTop() const;
  48. int selectionBottom() const { return lineBottom(); }
  49. int selectionHeight() const { return max(0, selectionBottom() - selectionTop()); }
  50. virtual int verticallyAlignBoxes(int heightOfBlock);
  51. void setLineTopBottomPositions(int top, int bottom);
  52. virtual RenderLineBoxList* rendererLineBoxes() const;
  53. #if ENABLE(SVG)
  54. virtual void computePerCharacterLayoutInformation() { }
  55. #endif
  56. RenderObject* lineBreakObj() const { return m_lineBreakObj; }
  57. BidiStatus lineBreakBidiStatus() const;
  58. void setLineBreakInfo(RenderObject*, unsigned breakPos, const BidiStatus&);
  59. unsigned lineBreakPos() const { return m_lineBreakPos; }
  60. void setLineBreakPos(unsigned p) { m_lineBreakPos = p; }
  61. int blockHeight() const { return m_blockHeight; }
  62. void setBlockHeight(int h) { m_blockHeight = h; }
  63. bool endsWithBreak() const { return m_endsWithBreak; }
  64. void setEndsWithBreak(bool b) { m_endsWithBreak = b; }
  65. void childRemoved(InlineBox* box);
  66. bool canAccommodateEllipsis(bool ltr, int blockEdge, int lineBoxEdge, int ellipsisWidth);
  67. void placeEllipsis(const AtomicString& ellipsisStr, bool ltr, int blockLeftEdge, int blockRightEdge, int ellipsisWidth, InlineBox* markupBox = 0);
  68. virtual int placeEllipsisBox(bool ltr, int blockLeftEdge, int blockRightEdge, int ellipsisWidth, bool& foundBox);
  69. EllipsisBox* ellipsisBox() const;
  70. void paintEllipsisBox(RenderObject::PaintInfo&, int tx, int ty) const;
  71. bool hitTestEllipsisBox(HitTestResult&, int x, int y, int tx, int ty, HitTestAction, bool);
  72. virtual void clearTruncation();
  73. #if PLATFORM(MAC)
  74. void addHighlightOverflow();
  75. void paintCustomHighlight(RenderObject::PaintInfo&, int tx, int ty, const AtomicString& highlightType);
  76. #endif
  77. virtual void paint(RenderObject::PaintInfo&, int tx, int ty);
  78. virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int, int, int, int);
  79. bool hasSelectedChildren() const { return m_hasSelectedChildren; }
  80. void setHasSelectedChildren(bool);
  81. virtual RenderObject::SelectionState selectionState();
  82. InlineBox* firstSelectedBox();
  83. InlineBox* lastSelectedBox();
  84. GapRects fillLineSelectionGap(int selTop, int selHeight, RenderBlock* rootBlock, int blockX, int blockY,
  85. int tx, int ty, const RenderObject::PaintInfo*);
  86. RenderBlock* block() const;
  87. InlineBox* closestLeafChildForXPos(int x, bool onlyEditableLeaves = false);
  88. Vector<RenderBox*>& floats()
  89. {
  90. ASSERT(!isDirty());
  91. if (!m_floats)
  92. m_floats.set(new Vector<RenderBox*>());
  93. return *m_floats;
  94. }
  95. Vector<RenderBox*>* floatsPtr() { ASSERT(!isDirty()); return m_floats.get(); }
  96. virtual void extractLineBoxFromRenderObject();
  97. virtual void attachLineBoxToRenderObject();
  98. virtual void removeLineBoxFromRenderObject();
  99. protected:
  100. // Where this line ended. The exact object and the position within that object are stored so that
  101. // we can create an InlineIterator beginning just after the end of this line.
  102. RenderObject* m_lineBreakObj;
  103. unsigned m_lineBreakPos;
  104. RefPtr<BidiContext> m_lineBreakContext;
  105. int m_lineTop;
  106. int m_lineBottom;
  107. // Floats hanging off the line are pushed into this vector during layout. It is only
  108. // good for as long as the line has not been marked dirty.
  109. OwnPtr<Vector<RenderBox*> > m_floats;
  110. // The height of the block at the end of this line. This is where the next line starts.
  111. int m_blockHeight;
  112. WTF::Unicode::Direction m_lineBreakBidiStatusEor : 5;
  113. WTF::Unicode::Direction m_lineBreakBidiStatusLastStrong : 5;
  114. WTF::Unicode::Direction m_lineBreakBidiStatusLast : 5;
  115. };
  116. inline void RootInlineBox::setLineTopBottomPositions(int top, int bottom)
  117. {
  118. m_lineTop = top;
  119. m_lineBottom = bottom;
  120. }
  121. } // namespace WebCore
  122. #endif // RootInlineBox_h