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

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

Issue 20681004: Make first-letter style to work with editing Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-09-20T18:27:32 Created 7 years, 3 months 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
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 #include "config.h" 23 #include "config.h"
24 #include "core/rendering/RenderTextFragment.h" 24 #include "core/rendering/RenderTextFragment.h"
25 25
26 #include "core/dom/Text.h" 26 #include "core/dom/Text.h"
27 #include "core/editing/VisiblePosition.h"
28 #include "core/rendering/HitTestResult.h"
27 #include "core/rendering/RenderBlock.h" 29 #include "core/rendering/RenderBlock.h"
28 30
29 namespace WebCore { 31 namespace WebCore {
30 32
31 RenderTextFragment::RenderTextFragment(Node* node, StringImpl* str, int startOff set, int length) 33 RenderTextFragment::RenderTextFragment(Node* node, StringImpl* str, int startOff set, int length)
32 : RenderText(node, str ? str->substring(startOffset, length) : PassRefPtr<St ringImpl>(0)) 34 : RenderText(node, str ? str->substring(startOffset, length) : PassRefPtr<St ringImpl>(0))
33 , m_start(startOffset) 35 , m_start(startOffset)
34 , m_end(length) 36 , m_end(length)
35 , m_firstLetter(0) 37 , m_firstLetter(0)
36 { 38 {
37 } 39 }
38 40
39 RenderTextFragment::RenderTextFragment(Node* node, StringImpl* str) 41 RenderTextFragment::RenderTextFragment(Node* node, StringImpl* str)
40 : RenderText(node, str) 42 : RenderText(node, str)
41 , m_start(0) 43 , m_start(0)
42 , m_end(str ? str->length() : 0) 44 , m_end(str ? str->length() : 0)
43 , m_contentString(str) 45 , m_contentString(str)
44 , m_firstLetter(0) 46 , m_firstLetter(0)
45 { 47 {
46 } 48 }
47 49
48 RenderTextFragment::~RenderTextFragment() 50 RenderTextFragment::~RenderTextFragment()
49 { 51 {
50 } 52 }
51 53
54 RenderText* RenderTextFragment::firstRenderTextInFirstLetter() const
55 {
56 for (RenderObject* current = m_firstLetter; current; current = current->next InPreOrder(m_firstLetter)) {
57 if (current->isText())
58 return toRenderText(current);
59 }
60 return 0;
61 }
62
52 PassRefPtr<StringImpl> RenderTextFragment::originalText() const 63 PassRefPtr<StringImpl> RenderTextFragment::originalText() const
53 { 64 {
54 Node* e = node(); 65 Node* e = node();
55 RefPtr<StringImpl> result = ((e && e->isTextNode()) ? toText(e)->dataImpl() : contentString()); 66 RefPtr<StringImpl> result = ((e && e->isTextNode()) ? toText(e)->dataImpl() : contentString());
56 if (!result) 67 if (!result)
57 return 0; 68 return 0;
58 return result->substring(start(), end()); 69 return result->substring(start(), end());
59 } 70 }
60 71
61 void RenderTextFragment::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) 72 void RenderTextFragment::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 { 126 {
116 if (!m_firstLetter) 127 if (!m_firstLetter)
117 return 0; 128 return 0;
118 for (RenderObject* block = m_firstLetter->parent(); block; block = block->pa rent()) { 129 for (RenderObject* block = m_firstLetter->parent(); block; block = block->pa rent()) {
119 if (block->style()->hasPseudoStyle(FIRST_LETTER) && block->canHaveChildr en() && block->isRenderBlock()) 130 if (block->style()->hasPseudoStyle(FIRST_LETTER) && block->canHaveChildr en() && block->isRenderBlock())
120 return toRenderBlock(block); 131 return toRenderBlock(block);
121 } 132 }
122 return 0; 133 return 0;
123 } 134 }
124 135
136 void RenderTextFragment::updateHitTestResult(HitTestResult& result, const Layout Point& point)
137 {
138 if (result.innerNode())
139 return;
140
141 RenderObject::updateHitTestResult(result, point);
142 if (m_firstLetter || !node())
143 return;
144 RenderObject* nodeRenderer = node()->renderer();
145 if (!nodeRenderer || !nodeRenderer->isText() || !toRenderText(nodeRenderer)- >isTextFragment())
146 return;
147
148 if (isDescendantOf(toRenderTextFragment(nodeRenderer)->m_firstLetter))
149 result.setIsFirstLetter(true);
150 }
151
125 } // namespace WebCore 152 } // namespace WebCore
OLDNEW
« Source/core/editing/Caret.cpp ('K') | « Source/core/rendering/RenderTextFragment.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698