| 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 | #pragma once |
| 27 | |
| 28 | #include "LayoutRect.h" |
| 29 | #include "RenderObject.h" |
| 30 | #include "VisiblePosition.h" |
| 31 | |
| 32 | namespace WebCore { |
| 33 | |
| 34 | class InlineTextBox; |
| 35 | class RenderStyle; |
| 36 | class RenderText; |
| 37 | |
| 38 | class RenderTextLineBoxes { |
| 39 | public: |
| 40 | RenderTextLineBoxes(); |
| 41 | |
| 42 | InlineTextBox* first() const { return m_first; } |
| 43 | InlineTextBox* last() const { return m_last; } |
| 44 | |
| 45 | InlineTextBox* createAndAppendLineBox(RenderText&); |
| 46 | |
| 47 | void (InlineTextBox&); |
| 48 | void attach(InlineTextBox&); |
| 49 | void remove(InlineTextBox&); |
| 50 | |
| 51 | void removeAllFromParent(RenderText&); |
| 52 | void deleteAll(); |
| 53 | |
| 54 | void dirtyAll(); |
| 55 | bool dirtyRange(RenderText&, unsigned start, unsigned end, int lengthDelta); |
| 56 | |
| 57 | InlineTextBox* findNext(int offset, int& position) const; |
| 58 | |
| 59 | bool hasRenderedText() const; |
| 60 | int caretMinOffset() const; |
| 61 | int caretMaxOffset(const RenderText&) const; |
| 62 | enum OffsetType { CaretOffset, CharacterOffset }; |
| 63 | bool containsOffset(const RenderText&, unsigned, OffsetType) const; |
| 64 | unsigned countCharacterOffsetsUntil(unsigned) const; |
| 65 | |
| 66 | VisiblePosition positionForPoint(const RenderText&, const LayoutPoint&) const; |
| 67 | |
| 68 | void setSelectionState(RenderText&, RenderObject::SelectionState); |
| 69 | LayoutRect selectionRectForRange(unsigned start, unsigned end); |
| 70 | void collectSelectionRectsForRange(unsigned start, unsigned end, Vector<LayoutRect>& rects); |
| 71 | |
| 72 | IntRect boundingBox(const RenderText&) const; |
| 73 | IntPoint firstRunLocation() const; |
| 74 | LayoutRect visualOverflowBoundingBox(const RenderText&) const; |
| 75 | |
| 76 | Vector<IntRect> absoluteRects(const LayoutPoint& accumulatedOffset) const; |
| 77 | Vector<IntRect> absoluteRectsForRange(const RenderText&, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const; |
| 78 | enum ClippingOption { NoClipping, ClipToEllipsis }; |
| 79 | Vector<FloatQuad> absoluteQuads(const RenderText&, bool* wasFixed, ClippingOption) const; |
| 80 | Vector<FloatQuad> absoluteQuadsForRange(const RenderText&, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const; |
| 81 | |
| 82 | #if !ASSERT_DISABLED |
| 83 | ~RenderTextLineBoxes(); |
| 84 | #endif |
| 85 | |
| 86 | #if !ASSERT_WITH_SECURITY_IMPLICATION_DISABLED |
| 87 | void invalidateParentChildLists(); |
| 88 | #endif |
| 89 | |
| 90 | private: |
| 91 | void checkConsistency() const; |
| 92 | |
| 93 | InlineTextBox* m_first; |
| 94 | InlineTextBox* m_last; |
| 95 | }; |
| 96 | |
| 97 | } // namespace WebCore |
| 98 | |