| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2004-2009, 2013 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004-2009, 2013 Apple Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 class AbstractInlineTextBox; | 37 class AbstractInlineTextBox; |
| 38 class InlineTextBox; | 38 class InlineTextBox; |
| 39 | 39 |
| 40 class CORE_EXPORT LayoutText : public LayoutObject { | 40 class CORE_EXPORT LayoutText : public LayoutObject { |
| 41 public: | 41 public: |
| 42 // FIXME: If the node argument is not a Text node or the string argument is | 42 // FIXME: If the node argument is not a Text node or the string argument is |
| 43 // not the content of the Text node, updating text-transform property | 43 // not the content of the Text node, updating text-transform property |
| 44 // doesn't re-transform the string. | 44 // doesn't re-transform the string. |
| 45 LayoutText(Node*, PassRefPtr<StringImpl>); | 45 LayoutText(Node*, PassRefPtr<StringImpl>); |
| 46 #if ENABLE(ASSERT) | 46 #if ENABLE(ASSERT) |
| 47 virtual ~LayoutText(); | 47 ~LayoutText() override; |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 virtual const char* name() const override { return "LayoutText"; } | 50 const char* name() const override { return "LayoutText"; } |
| 51 | 51 |
| 52 virtual bool isTextFragment() const; | 52 virtual bool isTextFragment() const; |
| 53 virtual bool isWordBreak() const; | 53 virtual bool isWordBreak() const; |
| 54 | 54 |
| 55 virtual PassRefPtr<StringImpl> originalText() const; | 55 virtual PassRefPtr<StringImpl> originalText() const; |
| 56 | 56 |
| 57 void extractTextBox(InlineTextBox*); | 57 void extractTextBox(InlineTextBox*); |
| 58 void attachTextBox(InlineTextBox*); | 58 void attachTextBox(InlineTextBox*); |
| 59 void removeTextBox(InlineTextBox*); | 59 void removeTextBox(InlineTextBox*); |
| 60 | 60 |
| 61 const String& text() const { return m_text; } | 61 const String& text() const { return m_text; } |
| 62 virtual unsigned textStartOffset() const { return 0; } | 62 virtual unsigned textStartOffset() const { return 0; } |
| 63 String plainText() const; | 63 String plainText() const; |
| 64 | 64 |
| 65 InlineTextBox* createInlineTextBox(int start, unsigned short length); | 65 InlineTextBox* createInlineTextBox(int start, unsigned short length); |
| 66 void dirtyOrDeleteLineBoxesIfNeeded(bool fullLayout); | 66 void dirtyOrDeleteLineBoxesIfNeeded(bool fullLayout); |
| 67 void dirtyLineBoxes(); | 67 void dirtyLineBoxes(); |
| 68 | 68 |
| 69 virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedO
ffset) const override final; | 69 void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) c
onst final; |
| 70 void absoluteRectsForRange(Vector<IntRect>&, unsigned startOffset = 0, unsig
ned endOffset = INT_MAX, bool useSelectionHeight = false, bool* wasFixed = nullp
tr); | 70 void absoluteRectsForRange(Vector<IntRect>&, unsigned startOffset = 0, unsig
ned endOffset = INT_MAX, bool useSelectionHeight = false, bool* wasFixed = nullp
tr); |
| 71 | 71 |
| 72 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const overrid
e final; | 72 void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const final; |
| 73 void absoluteQuadsForRange(Vector<FloatQuad>&, unsigned startOffset = 0, uns
igned endOffset = INT_MAX, bool useSelectionHeight = false, bool* wasFixed = nul
lptr); | 73 void absoluteQuadsForRange(Vector<FloatQuad>&, unsigned startOffset = 0, uns
igned endOffset = INT_MAX, bool useSelectionHeight = false, bool* wasFixed = nul
lptr); |
| 74 | 74 |
| 75 enum ClippingOption { NoClipping, ClipToEllipsis }; | 75 enum ClippingOption { NoClipping, ClipToEllipsis }; |
| 76 void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed = nullptr, ClippingOpt
ion = NoClipping) const; | 76 void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed = nullptr, ClippingOpt
ion = NoClipping) const; |
| 77 | 77 |
| 78 virtual PositionWithAffinity positionForPoint(const LayoutPoint&) override; | 78 PositionWithAffinity positionForPoint(const LayoutPoint&) override; |
| 79 | 79 |
| 80 bool is8Bit() const { return m_text.is8Bit(); } | 80 bool is8Bit() const { return m_text.is8Bit(); } |
| 81 const LChar* characters8() const { return m_text.impl()->characters8(); } | 81 const LChar* characters8() const { return m_text.impl()->characters8(); } |
| 82 const UChar* characters16() const { return m_text.impl()->characters16(); } | 82 const UChar* characters16() const { return m_text.impl()->characters16(); } |
| 83 bool hasEmptyText() const { return m_text.isEmpty(); } | 83 bool hasEmptyText() const { return m_text.isEmpty(); } |
| 84 UChar characterAt(unsigned) const; | 84 UChar characterAt(unsigned) const; |
| 85 UChar uncheckedCharacterAt(unsigned) const; | 85 UChar uncheckedCharacterAt(unsigned) const; |
| 86 UChar operator[](unsigned i) const { return uncheckedCharacterAt(i); } | 86 UChar operator[](unsigned i) const { return uncheckedCharacterAt(i); } |
| 87 unsigned textLength() const { return m_text.length(); } // non virtual imple
mentation of length() | 87 unsigned textLength() const { return m_text.length(); } // non virtual imple
mentation of length() |
| 88 void positionLineBox(InlineBox*); | 88 void positionLineBox(InlineBox*); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 106 | 106 |
| 107 FloatPoint firstRunOrigin() const; | 107 FloatPoint firstRunOrigin() const; |
| 108 float firstRunX() const; | 108 float firstRunX() const; |
| 109 float firstRunY() const; | 109 float firstRunY() const; |
| 110 | 110 |
| 111 virtual void setText(PassRefPtr<StringImpl>, bool force = false); | 111 virtual void setText(PassRefPtr<StringImpl>, bool force = false); |
| 112 void setTextWithOffset(PassRefPtr<StringImpl>, unsigned offset, unsigned len
, bool force = false); | 112 void setTextWithOffset(PassRefPtr<StringImpl>, unsigned offset, unsigned len
, bool force = false); |
| 113 | 113 |
| 114 virtual void transformText(); | 114 virtual void transformText(); |
| 115 | 115 |
| 116 virtual bool canBeSelectionLeaf() const override { return true; } | 116 bool canBeSelectionLeaf() const override { return true; } |
| 117 virtual void setSelectionState(SelectionState) override final; | 117 void setSelectionState(SelectionState) final; |
| 118 virtual LayoutRect selectionRectForPaintInvalidation(const LayoutBoxModelObj
ect* paintInvalidationContainer) const override; | 118 LayoutRect selectionRectForPaintInvalidation(const LayoutBoxModelObject* pai
ntInvalidationContainer) const override; |
| 119 virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* e
xtraWidthToEndOfLine = nullptr) override; | 119 LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidt
hToEndOfLine = nullptr) override; |
| 120 | 120 |
| 121 InlineTextBox* firstTextBox() const { return m_firstTextBox; } | 121 InlineTextBox* firstTextBox() const { return m_firstTextBox; } |
| 122 InlineTextBox* lastTextBox() const { return m_lastTextBox; } | 122 InlineTextBox* lastTextBox() const { return m_lastTextBox; } |
| 123 | 123 |
| 124 virtual int caretMinOffset() const override; | 124 int caretMinOffset() const override; |
| 125 virtual int caretMaxOffset() const override; | 125 int caretMaxOffset() const override; |
| 126 unsigned resolvedTextLength() const; | 126 unsigned resolvedTextLength() const; |
| 127 | 127 |
| 128 virtual int previousOffset(int current) const override final; | 128 int previousOffset(int current) const final; |
| 129 virtual int previousOffsetForBackwardDeletion(int current) const override fi
nal; | 129 int previousOffsetForBackwardDeletion(int current) const final; |
| 130 virtual int nextOffset(int current) const override final; | 130 int nextOffset(int current) const final; |
| 131 | 131 |
| 132 bool containsReversedText() const { return m_containsReversedText; } | 132 bool containsReversedText() const { return m_containsReversedText; } |
| 133 | 133 |
| 134 bool isSecure() const { return style()->textSecurity() != TSNONE; } | 134 bool isSecure() const { return style()->textSecurity() != TSNONE; } |
| 135 void momentarilyRevealLastTypedCharacter(unsigned lastTypedCharacterOffset); | 135 void momentarilyRevealLastTypedCharacter(unsigned lastTypedCharacterOffset); |
| 136 | 136 |
| 137 bool isAllCollapsibleWhitespace() const; | 137 bool isAllCollapsibleWhitespace() const; |
| 138 | 138 |
| 139 bool canUseSimpleFontCodePath() const { return m_canUseSimpleFontCodePath; } | 139 bool canUseSimpleFontCodePath() const { return m_canUseSimpleFontCodePath; } |
| 140 | 140 |
| 141 void removeAndDestroyTextBoxes(); | 141 void removeAndDestroyTextBoxes(); |
| 142 | 142 |
| 143 PassRefPtr<AbstractInlineTextBox> firstAbstractInlineTextBox(); | 143 PassRefPtr<AbstractInlineTextBox> firstAbstractInlineTextBox(); |
| 144 | 144 |
| 145 float hyphenWidth(const Font&, TextDirection); | 145 float hyphenWidth(const Font&, TextDirection); |
| 146 | 146 |
| 147 protected: | 147 protected: |
| 148 virtual void willBeDestroyed() override; | 148 void willBeDestroyed() override; |
| 149 | 149 |
| 150 virtual void styleWillChange(StyleDifference, const ComputedStyle&) override
final { } | 150 void styleWillChange(StyleDifference, const ComputedStyle&) final { } |
| 151 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle)
override; | 151 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override
; |
| 152 | 152 |
| 153 virtual void setTextInternal(PassRefPtr<StringImpl>); | 153 virtual void setTextInternal(PassRefPtr<StringImpl>); |
| 154 virtual UChar previousCharacter() const; | 154 virtual UChar previousCharacter() const; |
| 155 | 155 |
| 156 virtual void addLayerHitTestRects(LayerHitTestRects&, const DeprecatedPaintL
ayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerR
ect) const override; | 156 void addLayerHitTestRects(LayerHitTestRects&, const DeprecatedPaintLayer* cu
rrentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) con
st override; |
| 157 | 157 |
| 158 virtual InlineTextBox* createTextBox(int start, unsigned short length); // S
ubclassed by SVG. | 158 virtual InlineTextBox* createTextBox(int start, unsigned short length); // S
ubclassed by SVG. |
| 159 | 159 |
| 160 virtual void invalidateDisplayItemClients(const LayoutBoxModelObject& paintI
nvalidationContainer) const override; | 160 void invalidateDisplayItemClients(const LayoutBoxModelObject& paintInvalidat
ionContainer) const override; |
| 161 | 161 |
| 162 private: | 162 private: |
| 163 void computePreferredLogicalWidths(float leadWidth); | 163 void computePreferredLogicalWidths(float leadWidth); |
| 164 void computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFont
Data*>& fallbackFonts, FloatRect& glyphBounds); | 164 void computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFont
Data*>& fallbackFonts, FloatRect& glyphBounds); |
| 165 | 165 |
| 166 bool computeCanUseSimpleFontCodePath() const; | 166 bool computeCanUseSimpleFontCodePath() const; |
| 167 | 167 |
| 168 // Make length() private so that callers that have a LayoutText* | 168 // Make length() private so that callers that have a LayoutText* |
| 169 // will use the more efficient textLength() instead, while | 169 // will use the more efficient textLength() instead, while |
| 170 // callers with a LayoutObject* can continue to use length(). | 170 // callers with a LayoutObject* can continue to use length(). |
| 171 virtual unsigned length() const override final { return textLength(); } | 171 unsigned length() const final { return textLength(); } |
| 172 | 172 |
| 173 virtual void paint(const PaintInfo&, const LayoutPoint&) override final { AS
SERT_NOT_REACHED(); } | 173 void paint(const PaintInfo&, const LayoutPoint&) final { ASSERT_NOT_REACHED(
); } |
| 174 virtual void layout() override final { ASSERT_NOT_REACHED(); } | 174 void layout() final { ASSERT_NOT_REACHED(); } |
| 175 virtual bool nodeAtPoint(HitTestResult&, const HitTestLocation&, const Layou
tPoint&, HitTestAction) override final { ASSERT_NOT_REACHED(); return false; } | 175 bool nodeAtPoint(HitTestResult&, const HitTestLocation&, const LayoutPoint&,
HitTestAction) final { ASSERT_NOT_REACHED(); return false; } |
| 176 | 176 |
| 177 void deleteTextBoxes(); | 177 void deleteTextBoxes(); |
| 178 bool containsOnlyWhitespace(unsigned from, unsigned len) const; | 178 bool containsOnlyWhitespace(unsigned from, unsigned len) const; |
| 179 float widthFromFont(const Font&, int start, int len, float leadWidth, float
textWidthSoFar, TextDirection, HashSet<const SimpleFontData*>* fallbackFonts, Fl
oatRect* glyphBoundsAccumulation) const; | 179 float widthFromFont(const Font&, int start, int len, float leadWidth, float
textWidthSoFar, TextDirection, HashSet<const SimpleFontData*>* fallbackFonts, Fl
oatRect* glyphBoundsAccumulation) const; |
| 180 | 180 |
| 181 void secureText(UChar mask); | 181 void secureText(UChar mask); |
| 182 | 182 |
| 183 bool isText() const = delete; // This will catch anyone doing an unnecessary
check. | 183 bool isText() const = delete; // This will catch anyone doing an unnecessary
check. |
| 184 | 184 |
| 185 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxMo
delObject* paintInvalidationContainer, const PaintInvalidationState* = nullptr)
const override; | 185 LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxModelObjec
t* paintInvalidationContainer, const PaintInvalidationState* = nullptr) const ov
erride; |
| 186 | 186 |
| 187 void checkConsistency() const; | 187 void checkConsistency() const; |
| 188 | 188 |
| 189 // We put the bitfield first to minimize padding on 64-bit. | 189 // We put the bitfield first to minimize padding on 64-bit. |
| 190 bool m_hasBreakableChar : 1; // Whether or not we can be broken into multipl
e lines. | 190 bool m_hasBreakableChar : 1; // Whether or not we can be broken into multipl
e lines. |
| 191 bool m_hasBreak : 1; // Whether or not we have a hard break (e.g., <pre> wit
h '\n'). | 191 bool m_hasBreak : 1; // Whether or not we have a hard break (e.g., <pre> wit
h '\n'). |
| 192 bool m_hasTab : 1; // Whether or not we have a variable width tab character
(e.g., <pre> with '\t'). | 192 bool m_hasTab : 1; // Whether or not we have a variable width tab character
(e.g., <pre> with '\t'). |
| 193 bool m_hasBreakableStart : 1; | 193 bool m_hasBreakableStart : 1; |
| 194 bool m_hasBreakableEnd : 1; | 194 bool m_hasBreakableEnd : 1; |
| 195 bool m_hasEndWhiteSpace : 1; | 195 bool m_hasEndWhiteSpace : 1; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 inline LayoutText* Text::layoutObject() const | 244 inline LayoutText* Text::layoutObject() const |
| 245 { | 245 { |
| 246 return toLayoutText(CharacterData::layoutObject()); | 246 return toLayoutText(CharacterData::layoutObject()); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void applyTextTransform(const ComputedStyle*, String&, UChar); | 249 void applyTextTransform(const ComputedStyle*, String&, UChar); |
| 250 | 250 |
| 251 } // namespace blink | 251 } // namespace blink |
| 252 | 252 |
| 253 #endif // LayoutText_h | 253 #endif // LayoutText_h |
| OLD | NEW |