Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: Source/core/rendering/RenderTextFragment.h

Issue 672953002: Convert first letter into a pseudo element. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderTableCell.cpp ('k') | Source/core/rendering/RenderTextFragment.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, 2005, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 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 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 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 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, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #ifndef RenderTextFragment_h 23 #ifndef RenderTextFragment_h
24 #define RenderTextFragment_h 24 #define RenderTextFragment_h
25 25
26 #include "core/rendering/RenderText.h" 26 #include "core/rendering/RenderText.h"
27 27
28 namespace blink { 28 namespace blink {
29 29
30 class FirstLetterPseudoElement;
31
30 // Used to represent a text substring of an element, e.g., for text runs that ar e split because of 32 // Used to represent a text substring of an element, e.g., for text runs that ar e split because of
31 // first letter and that must therefore have different styles (and positions in the render tree). 33 // first letter and that must therefore have different styles (and positions in the render tree).
32 // We cache offsets so that text transformations can be applied in such a way th at we can recover 34 // We cache offsets so that text transformations can be applied in such a way th at we can recover
33 // the original unaltered string from our corresponding DOM node. 35 // the original unaltered string from our corresponding DOM node.
34 class RenderTextFragment final : public RenderText { 36 class RenderTextFragment final : public RenderText {
35 public: 37 public:
36 RenderTextFragment(Node*, StringImpl*, int startOffset, int length); 38 RenderTextFragment(Node*, StringImpl*, int startOffset, int length);
37 RenderTextFragment(Node*, StringImpl*); 39 RenderTextFragment(Node*, StringImpl*);
38 virtual ~RenderTextFragment(); 40 virtual ~RenderTextFragment();
39 virtual void trace(Visitor*) override; 41 virtual void trace(Visitor*) override;
42 virtual void destroy() override;
40 43
41 virtual bool isTextFragment() const override { return true; } 44 virtual bool isTextFragment() const override { return true; }
42 45
43 virtual bool canBeSelectionLeaf() const override { return node() && node()-> hasEditableStyle(); } 46 virtual bool canBeSelectionLeaf() const override { return node() && node()-> hasEditableStyle(); }
44 47
45 unsigned start() const { return m_start; } 48 unsigned start() const { return m_start; }
46 unsigned end() const { return m_end; } 49 unsigned end() const { return m_end; }
47 virtual unsigned textStartOffset() const override { return start(); } 50 virtual unsigned textStartOffset() const override { return start(); }
48 51
49 RenderBoxModelObject* firstLetter() const { return m_firstLetter; } 52 void setContentString(StringImpl*);
50 void setFirstLetter(RenderBoxModelObject* firstLetter) { m_firstLetter = fir stLetter; } 53 StringImpl* contentString() const { return m_contentString.get(); }
51 RenderText* firstRenderTextInFirstLetter() const; 54 // The complete text is all of the text in the associated DOM text node.
55 PassRefPtr<StringImpl> completeText() const;
56 // The fragment text is the text which will be used by this RenderTextFragme nt. For
57 // things like first-letter this may differ from the completeText as we mayb e using
58 // only a portion of the text nodes content.
52 59
53 void setContentString(StringImpl*);
54 virtual PassRefPtr<StringImpl> originalText() const override; 60 virtual PassRefPtr<StringImpl> originalText() const override;
55 61
56 virtual void setText(PassRefPtr<StringImpl>, bool force = false) override; 62 virtual void setText(PassRefPtr<StringImpl>, bool force = false) override;
57 63
58 virtual void transformText() override; 64 virtual void transformText() override;
59 65
60 virtual const char* renderName() const override final { return "RenderTextFr agment"; } 66 virtual const char* renderName() const override final { return "RenderTextFr agment"; }
61 67
62 protected: 68 void setFirstLetterPseudoElement(FirstLetterPseudoElement* element) { m_firs tLetterPseudoElement = element; }
63 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) ov erride; 69 FirstLetterPseudoElement* firstLetterPseudoElement() const { return m_firstL etterPseudoElement; }
70
71 void setIsRemainingTextRenderer() { m_isRemainingTextRenderer = true; }
72 bool isRemainingTextRenderer() const { return m_isRemainingTextRenderer; }
64 73
65 private: 74 private:
66 virtual void willBeDestroyed() override; 75 RenderBlock* blockForAccompanyingFirstLetter() const;
76 virtual UChar previousCharacter() const override;
67 77
68 virtual UChar previousCharacter() const override; 78 Text* associatedTextNode() const;
69 RenderBlock* blockForAccompanyingFirstLetter() const;
70 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) overrid e;
71 79
72 unsigned m_start; 80 unsigned m_start;
73 unsigned m_end; 81 unsigned m_end;
82 bool m_isRemainingTextRenderer;
74 RefPtr<StringImpl> m_contentString; 83 RefPtr<StringImpl> m_contentString;
75 RawPtrWillBeMember<RenderBoxModelObject> m_firstLetter; 84 RawPtrWillBeMember<FirstLetterPseudoElement> m_firstLetterPseudoElement;
76 }; 85 };
77 86
78 DEFINE_TYPE_CASTS(RenderTextFragment, RenderObject, object, toRenderText(object) ->isTextFragment(), toRenderText(object).isTextFragment()); 87 DEFINE_TYPE_CASTS(RenderTextFragment, RenderObject, object, toRenderText(object) ->isTextFragment(), toRenderText(object).isTextFragment());
79 88
80 } // namespace blink 89 } // namespace blink
81 90
82 #endif // RenderTextFragment_h 91 #endif // RenderTextFragment_h
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderTableCell.cpp ('k') | Source/core/rendering/RenderTextFragment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698