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

Side by Side Diff: Source/core/dom/Text.cpp

Issue 21182003: Remove NonSelectableText subclass of Text (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use createTextRenderer and RenderTextFragment Created 7 years, 4 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/dom/Text.h ('k') | Source/core/html/BaseButtonInputType.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 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 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 #include "config.h" 22 #include "config.h"
23 #include "core/dom/Text.h" 23 #include "core/dom/Text.h"
24 24
25 #include "HTMLNames.h"
25 #include "SVGNames.h" 26 #include "SVGNames.h"
26 #include "core/css/resolver/StyleResolver.h" 27 #include "core/css/resolver/StyleResolver.h"
27 #include "core/dom/ExceptionCode.h" 28 #include "core/dom/ExceptionCode.h"
28 #include "core/dom/ExceptionCodePlaceholder.h" 29 #include "core/dom/ExceptionCodePlaceholder.h"
29 #include "core/dom/NodeRenderStyle.h" 30 #include "core/dom/NodeRenderStyle.h"
30 #include "core/dom/NodeRenderingContext.h" 31 #include "core/dom/NodeRenderingContext.h"
31 #include "core/dom/ScopedEventQueue.h" 32 #include "core/dom/ScopedEventQueue.h"
32 #include "core/dom/shadow/ShadowRoot.h" 33 #include "core/dom/shadow/ShadowRoot.h"
33 #include "core/rendering/RenderCombineText.h" 34 #include "core/rendering/RenderCombineText.h"
34 #include "core/rendering/RenderText.h" 35 #include "core/rendering/RenderText.h"
36 #include "core/rendering/RenderTextFragment.h"
35 #include "core/rendering/svg/RenderSVGInlineText.h" 37 #include "core/rendering/svg/RenderSVGInlineText.h"
36 #include "wtf/text/CString.h" 38 #include "wtf/text/CString.h"
37 #include "wtf/text/StringBuilder.h" 39 #include "wtf/text/StringBuilder.h"
38 40
39 using namespace std; 41 using namespace std;
40 42
41 namespace WebCore { 43 namespace WebCore {
42 44
45 using namespace HTMLNames;
46
43 PassRefPtr<Text> Text::create(Document* document, const String& data) 47 PassRefPtr<Text> Text::create(Document* document, const String& data)
44 { 48 {
45 return adoptRef(new Text(document, data, CreateText)); 49 return adoptRef(new Text(document, data, CreateText));
46 } 50 }
47 51
48 PassRefPtr<Text> Text::createEditingText(Document* document, const String& data) 52 PassRefPtr<Text> Text::createEditingText(Document* document, const String& data)
49 { 53 {
50 return adoptRef(new Text(document, data, CreateEditingText)); 54 return adoptRef(new Text(document, data, CreateEditingText));
51 } 55 }
52 56
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 { 253 {
250 Node* parentOrShadowHostNode = text->parentOrShadowHostNode(); 254 Node* parentOrShadowHostNode = text->parentOrShadowHostNode();
251 return parentOrShadowHostNode->isSVGElement() && !parentOrShadowHostNode->ha sTagName(SVGNames::foreignObjectTag); 255 return parentOrShadowHostNode->isSVGElement() && !parentOrShadowHostNode->ha sTagName(SVGNames::foreignObjectTag);
252 } 256 }
253 257
254 void Text::createTextRendererIfNeeded() 258 void Text::createTextRendererIfNeeded()
255 { 259 {
256 NodeRenderingContext(this).createRendererForTextIfNeeded(); 260 NodeRenderingContext(this).createRendererForTextIfNeeded();
257 } 261 }
258 262
259 RenderText* Text::createTextRenderer(RenderStyle* style) 263 RenderText* Text::createTextRenderer(ContainerNode* renderingParent, RenderStyle * style)
260 { 264 {
261 if (isSVGText(this) || isSVGShadowText(this)) 265 if (isSVGText(this) || isSVGShadowText(this))
262 return new (document()->renderArena()) RenderSVGInlineText(this, dataImp l()); 266 return new (document()->renderArena()) RenderSVGInlineText(this, dataImp l());
263 267
264 if (style->hasTextCombine()) 268 if (style->hasTextCombine())
265 return new (document()->renderArena()) RenderCombineText(this, dataImpl( )); 269 return new (document()->renderArena()) RenderCombineText(this, dataImpl( ));
266 270
271 // button input types (submit, button, reset) have special selection behavio r
272 // provided by RenderTextFragment's implementation of canBeSelectionLeaf()
273 // that makes it only selectable if the button is inside an editable region.
274 //
275 // FIXME: We should probably add a new css property like -webkit-user-select : editable
276 // that makes text selectable only if contenteditable is used around it and remove
277 // this special case.
278 if (renderingParent->hasTagName(inputTag) && renderingParent->renderer()->is RenderButton())
279 return new (document()->renderArena()) RenderTextFragment(this, dataImpl ());
280
267 return new (document()->renderArena()) RenderText(this, dataImpl()); 281 return new (document()->renderArena()) RenderText(this, dataImpl());
268 } 282 }
269 283
270 void Text::attach(const AttachContext& context) 284 void Text::attach(const AttachContext& context)
271 { 285 {
272 createTextRendererIfNeeded(); 286 createTextRendererIfNeeded();
273 CharacterData::attach(context); 287 CharacterData::attach(context);
274 } 288 }
275 289
276 bool Text::recalcTextStyle(StyleChange change) 290 bool Text::recalcTextStyle(StyleChange change)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 result.appendLiteral("; "); 361 result.appendLiteral("; ");
348 result.appendLiteral("value="); 362 result.appendLiteral("value=");
349 result.append(s); 363 result.append(s);
350 } 364 }
351 365
352 strncpy(buffer, result.toString().utf8().data(), length - 1); 366 strncpy(buffer, result.toString().utf8().data(), length - 1);
353 } 367 }
354 #endif 368 #endif
355 369
356 } // namespace WebCore 370 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Text.h ('k') | Source/core/html/BaseButtonInputType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698