1/*
2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef RenderTextLineBoxes_h
27#define RenderTextLineBoxes_h
28
29#include "LayoutRect.h"
30#include "RenderObject.h"
31#include "VisiblePosition.h"
32
33namespace WebCore {
34
35class InlineTextBox;
36class RenderStyle;
37class RenderText;
38
39class RenderTextLineBoxes {
40public:
41    RenderTextLineBoxes();
42
43    InlineTextBox* first() const { return m_first; }
44    InlineTextBox* last() const { return m_last; }
45
46    InlineTextBox* createAndAppendLineBox(RenderText&);
47
48    void extract(InlineTextBox&);
49    void attach(InlineTextBox&);
50    void remove(InlineTextBox&);
51
52    void removeAllFromParent(RenderText&);
53    void deleteAll();
54
55    void dirtyAll();
56    bool dirtyRange(RenderText&, unsigned start, unsigned end, int lengthDelta);
57
58    InlineTextBox* findNext(int offset, int& position) const;
59
60    bool hasRenderedText() const;
61    int caretMinOffset() const;
62    int caretMaxOffset(const RenderText&) const;
63    enum OffsetType { CaretOffset, CharacterOffset };
64    bool containsOffset(const RenderText&, unsigned, OffsetType) const;
65    unsigned countCharacterOffsetsUntil(unsigned) const;
66
67    VisiblePosition positionForPoint(const RenderText&, const LayoutPoint&) const;
68
69    void setSelectionState(RenderText&, RenderObject::SelectionState);
70    LayoutRect selectionRectForRange(unsigned start, unsigned end);
71    void collectSelectionRectsForRange(unsigned start, unsigned end, Vector<LayoutRect>& rects);
72
73    IntRect boundingBox(const RenderText&) const;
74    IntPoint firstRunLocation() const;
75    LayoutRect visualOverflowBoundingBox(const RenderText&) const;
76
77    Vector<IntRect> absoluteRects(const LayoutPoint& accumulatedOffset) const;
78    Vector<IntRect> absoluteRectsForRange(const RenderText&, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const;
79    enum ClippingOption { NoClipping, ClipToEllipsis };
80    Vector<FloatQuad> absoluteQuads(const RenderText&, bool* wasFixed, ClippingOption) const;
81    Vector<FloatQuad> absoluteQuadsForRange(const RenderText&, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const;
82
83#if !ASSERT_DISABLED
84    ~RenderTextLineBoxes();
85#endif
86
87#if !ASSERT_WITH_SECURITY_IMPLICATION_DISABLED
88    void invalidateParentChildLists();
89#endif
90
91private:
92    void checkConsistency() const;
93
94    InlineTextBox* m_first;
95    InlineTextBox* m_last;
96};
97
98}
99
100#endif
101