1 /* 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public License 17 * along with this library; see the file COPYING.LIB. If not, write to 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef RenderInline_h 24 #define RenderInline_h 25 26 #include "core/rendering/InlineFlowBox.h" 27 #include "core/rendering/RenderBoxModelObject.h" 28 #include "core/rendering/RenderLineBoxList.h" 29 30 namespace WebCore { 31 32 class Position; 33 34 class RenderInline : public RenderBoxModelObject { 35 public: 36 explicit RenderInline(Element*); 37 38 static RenderInline* createAnonymous(Document*); 39 firstChild()40 RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); } lastChild()41 RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); } 42 43 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0); 44 node()45 Element* node() const { return toElement(RenderBoxModelObject::node()); } 46 47 virtual LayoutUnit marginLeft() const OVERRIDE FINAL; 48 virtual LayoutUnit marginRight() const OVERRIDE FINAL; 49 virtual LayoutUnit marginTop() const OVERRIDE FINAL; 50 virtual LayoutUnit marginBottom() const OVERRIDE FINAL; 51 virtual LayoutUnit marginBefore(const RenderStyle* otherStyle = 0) const OVERRIDE FINAL; 52 virtual LayoutUnit marginAfter(const RenderStyle* otherStyle = 0) const OVERRIDE FINAL; 53 virtual LayoutUnit marginStart(const RenderStyle* otherStyle = 0) const OVERRIDE FINAL; 54 virtual LayoutUnit marginEnd(const RenderStyle* otherStyle = 0) const OVERRIDE FINAL; 55 56 virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const OVERRIDE FINAL; 57 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const; 58 59 virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const OVERRIDE FINAL; 60 61 IntRect linesBoundingBox() const; 62 LayoutRect linesVisualOverflowBoundingBox() const; 63 64 InlineFlowBox* createAndAppendInlineFlowBox(); 65 66 void dirtyLineBoxes(bool fullLayout); 67 void deleteLineBoxTree(); 68 lineBoxes()69 RenderLineBoxList* lineBoxes() { return &m_lineBoxes; } lineBoxes()70 const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; } 71 firstLineBox()72 InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); } lastLineBox()73 InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); } firstLineBoxIncludingCulling()74 InlineBox* firstLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? firstLineBox() : culledInlineFirstLineBox(); } lastLineBoxIncludingCulling()75 InlineBox* lastLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? lastLineBox() : culledInlineLastLineBox(); } 76 virtualContinuation()77 virtual RenderBoxModelObject* virtualContinuation() const OVERRIDE FINAL { return continuation(); } 78 RenderInline* inlineElementContinuation() const; 79 80 virtual void updateDragState(bool dragOn) OVERRIDE FINAL; 81 82 LayoutSize offsetForInFlowPositionedInline(const RenderBox* child) const; 83 84 virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) OVERRIDE FINAL; 85 void paintOutline(PaintInfo&, const LayoutPoint&); 86 87 using RenderBoxModelObject::continuation; 88 using RenderBoxModelObject::setContinuation; 89 alwaysCreateLineBoxes()90 bool alwaysCreateLineBoxes() const { return m_alwaysCreateLineBoxes; } setAlwaysCreateLineBoxes()91 void setAlwaysCreateLineBoxes() { m_alwaysCreateLineBoxes = true; } 92 void updateAlwaysCreateLineBoxes(bool fullLayout); 93 94 virtual LayoutRect localCaretRect(InlineBox*, int, LayoutUnit* extraWidthToEndOfLine) OVERRIDE FINAL; 95 96 bool hitTestCulledInline(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset); 97 98 protected: 99 virtual void willBeDestroyed(); 100 101 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE; 102 103 virtual void computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutPoint& layerOffset) const OVERRIDE; 104 105 private: virtualChildren()106 virtual RenderObjectChildList* virtualChildren() OVERRIDE FINAL { return children(); } virtualChildren()107 virtual const RenderObjectChildList* virtualChildren() const OVERRIDE FINAL { return children(); } children()108 const RenderObjectChildList* children() const { return &m_children; } children()109 RenderObjectChildList* children() { return &m_children; } 110 111 virtual const char* renderName() const; 112 isRenderInline()113 virtual bool isRenderInline() const OVERRIDE FINAL { return true; } 114 115 LayoutRect culledInlineVisualOverflowBoundingBox() const; 116 InlineBox* culledInlineFirstLineBox() const; 117 InlineBox* culledInlineLastLineBox() const; 118 119 template<typename GeneratorContext> 120 void generateLineBoxRects(GeneratorContext& yield) const; 121 template<typename GeneratorContext> 122 void generateCulledLineBoxRects(GeneratorContext& yield, const RenderInline* container) const; 123 124 void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild); 125 virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0) OVERRIDE FINAL; 126 127 void splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock, 128 RenderObject* beforeChild, RenderBoxModelObject* oldCont); 129 void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox, 130 RenderObject* newChild, RenderBoxModelObject* oldCont); 131 layout()132 virtual void layout() OVERRIDE FINAL { ASSERT_NOT_REACHED(); } // Do nothing for layout() 133 134 virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE FINAL; 135 136 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE FINAL; 137 requiresLayer()138 virtual bool requiresLayer() const { return isInFlowPositioned() || createsGroup() || hasClipPath(); } 139 140 virtual LayoutUnit offsetLeft() const OVERRIDE FINAL; 141 virtual LayoutUnit offsetTop() const OVERRIDE FINAL; offsetWidth()142 virtual LayoutUnit offsetWidth() const OVERRIDE FINAL { return linesBoundingBox().width(); } offsetHeight()143 virtual LayoutUnit offsetHeight() const OVERRIDE FINAL { return linesBoundingBox().height(); } 144 145 virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const OVERRIDE; 146 virtual LayoutRect rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const OVERRIDE FINAL; 147 virtual void computeRectForRepaint(const RenderLayerModelObject* repaintContainer, LayoutRect&, bool fixed) const OVERRIDE FINAL; 148 149 virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0) const OVERRIDE; 150 151 virtual PositionWithAffinity positionForPoint(const LayoutPoint&) OVERRIDE FINAL; 152 frameRectForStickyPositioning()153 virtual LayoutRect frameRectForStickyPositioning() const OVERRIDE FINAL { return linesBoundingBox(); } 154 borderBoundingBox()155 virtual IntRect borderBoundingBox() const OVERRIDE FINAL 156 { 157 IntRect boundingBox = linesBoundingBox(); 158 return IntRect(0, 0, boundingBox.width(), boundingBox.height()); 159 } 160 161 virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby 162 dirtyLinesFromChangedChild(RenderObject * child)163 virtual void dirtyLinesFromChangedChild(RenderObject* child) OVERRIDE FINAL { m_lineBoxes.dirtyLinesFromChangedChild(this, child); } 164 165 virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE FINAL; 166 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE FINAL; 167 168 virtual void childBecameNonInline(RenderObject* child) OVERRIDE FINAL; 169 170 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) OVERRIDE FINAL; 171 172 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE FINAL; 173 174 virtual void addAnnotatedRegions(Vector<AnnotatedRegionValue>&) OVERRIDE FINAL; 175 176 virtual void updateFromStyle() OVERRIDE FINAL; 177 178 RenderInline* clone() const; 179 180 void paintOutlineForLine(GraphicsContext*, const LayoutPoint&, const LayoutRect& prevLine, const LayoutRect& thisLine, 181 const LayoutRect& nextLine, const Color); 182 RenderBoxModelObject* continuationBefore(RenderObject* beforeChild); 183 184 RenderObjectChildList m_children; 185 RenderLineBoxList m_lineBoxes; // All of the line boxes created for this inline flow. For example, <i>Hello<br>world.</i> will have two <i> line boxes. 186 187 bool m_alwaysCreateLineBoxes : 1; 188 }; 189 190 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderInline, isRenderInline()); 191 192 } // namespace WebCore 193 194 #endif // RenderInline_h 195