OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 class InlineTextBox; | 44 class InlineTextBox; |
45 | 45 |
46 // High-level abstraction of InlineTextBox to allow the accessibility module to | 46 // High-level abstraction of InlineTextBox to allow the accessibility module to |
47 // get information about InlineTextBoxes without tight coupling. | 47 // get information about InlineTextBoxes without tight coupling. |
48 class CORE_EXPORT AbstractInlineTextBox : public RefCounted<AbstractInlineTextBo
x> { | 48 class CORE_EXPORT AbstractInlineTextBox : public RefCounted<AbstractInlineTextBo
x> { |
49 private: | 49 private: |
50 AbstractInlineTextBox(LayoutText* renderText, InlineTextBox* inlineTextBox) | 50 AbstractInlineTextBox(LayoutText* layoutText, InlineTextBox* inlineTextBox) |
51 : m_renderText(renderText) | 51 : m_renderText(layoutText) |
52 , m_inlineTextBox(inlineTextBox) | 52 , m_inlineTextBox(inlineTextBox) |
53 { | 53 { |
54 } | 54 } |
55 | 55 |
56 static PassRefPtr<AbstractInlineTextBox> getOrCreate(LayoutText*, InlineText
Box*); | 56 static PassRefPtr<AbstractInlineTextBox> getOrCreate(LayoutText*, InlineText
Box*); |
57 static void willDestroy(InlineTextBox*); | 57 static void willDestroy(InlineTextBox*); |
58 | 58 |
59 friend class LayoutText; | 59 friend class LayoutText; |
60 friend class InlineTextBox; | 60 friend class InlineTextBox; |
61 | 61 |
62 public: | 62 public: |
63 struct WordBoundaries { | 63 struct WordBoundaries { |
64 WordBoundaries(int startIndex, int endIndex) : startIndex(startIndex), e
ndIndex(endIndex) { } | 64 WordBoundaries(int startIndex, int endIndex) : startIndex(startIndex), e
ndIndex(endIndex) { } |
65 int startIndex; | 65 int startIndex; |
66 int endIndex; | 66 int endIndex; |
67 }; | 67 }; |
68 | 68 |
69 enum Direction { | 69 enum Direction { |
70 LeftToRight, | 70 LeftToRight, |
71 RightToLeft, | 71 RightToLeft, |
72 TopToBottom, | 72 TopToBottom, |
73 BottomToTop | 73 BottomToTop |
74 }; | 74 }; |
75 | 75 |
76 LayoutText* renderText() const { return m_renderText; } | 76 LayoutText* layoutText() const { return m_renderText; } |
77 | 77 |
78 PassRefPtr<AbstractInlineTextBox> nextInlineTextBox() const; | 78 PassRefPtr<AbstractInlineTextBox> nextInlineTextBox() const; |
79 LayoutRect bounds() const; | 79 LayoutRect bounds() const; |
80 unsigned len() const; | 80 unsigned len() const; |
81 Direction direction() const; | 81 Direction direction() const; |
82 void characterWidths(Vector<FloatWillBeLayoutUnit>&) const; | 82 void characterWidths(Vector<FloatWillBeLayoutUnit>&) const; |
83 void wordBoundaries(Vector<WordBoundaries>&) const; | 83 void wordBoundaries(Vector<WordBoundaries>&) const; |
84 String text() const; | 84 String text() const; |
85 | 85 |
86 private: | 86 private: |
87 void detach(); | 87 void detach(); |
88 | 88 |
89 // Weak ptrs; these are nulled when InlineTextBox::destroy() calls AbstractI
nlineTextBox::willDestroy. | 89 // Weak ptrs; these are nulled when InlineTextBox::destroy() calls AbstractI
nlineTextBox::willDestroy. |
90 LayoutText* m_renderText; | 90 LayoutText* m_renderText; |
91 InlineTextBox* m_inlineTextBox; | 91 InlineTextBox* m_inlineTextBox; |
92 | 92 |
93 typedef HashMap<InlineTextBox*, RefPtr<AbstractInlineTextBox>> InlineToAbstr
actInlineTextBoxHashMap; | 93 typedef HashMap<InlineTextBox*, RefPtr<AbstractInlineTextBox>> InlineToAbstr
actInlineTextBoxHashMap; |
94 static InlineToAbstractInlineTextBoxHashMap* gAbstractInlineTextBoxMap; | 94 static InlineToAbstractInlineTextBoxHashMap* gAbstractInlineTextBoxMap; |
95 }; | 95 }; |
96 | 96 |
97 } // namespace blink | 97 } // namespace blink |
98 | 98 |
99 #endif // AbstractInlineTextBox_h | 99 #endif // AbstractInlineTextBox_h |
OLD | NEW |