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

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

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

Powered by Google App Engine
This is Rietveld 408576698