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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Text.h ('k') | Source/core/html/BaseButtonInputType.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Text.cpp
diff --git a/Source/core/dom/Text.cpp b/Source/core/dom/Text.cpp
index eadc27ce186fbcb01710e0269858e70bb40f0a78..38572c7e6cc38cf2288114efc4ebd412fc170556 100644
--- a/Source/core/dom/Text.cpp
+++ b/Source/core/dom/Text.cpp
@@ -22,6 +22,7 @@
#include "config.h"
#include "core/dom/Text.h"
+#include "HTMLNames.h"
#include "SVGNames.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/ExceptionCode.h"
@@ -32,6 +33,7 @@
#include "core/dom/shadow/ShadowRoot.h"
#include "core/rendering/RenderCombineText.h"
#include "core/rendering/RenderText.h"
+#include "core/rendering/RenderTextFragment.h"
#include "core/rendering/svg/RenderSVGInlineText.h"
#include "wtf/text/CString.h"
#include "wtf/text/StringBuilder.h"
@@ -40,6 +42,8 @@ using namespace std;
namespace WebCore {
+using namespace HTMLNames;
+
PassRefPtr<Text> Text::create(Document* document, const String& data)
{
return adoptRef(new Text(document, data, CreateText));
@@ -256,7 +260,7 @@ void Text::createTextRendererIfNeeded()
NodeRenderingContext(this).createRendererForTextIfNeeded();
}
-RenderText* Text::createTextRenderer(RenderStyle* style)
+RenderText* Text::createTextRenderer(ContainerNode* renderingParent, RenderStyle* style)
{
if (isSVGText(this) || isSVGShadowText(this))
return new (document()->renderArena()) RenderSVGInlineText(this, dataImpl());
@@ -264,6 +268,16 @@ RenderText* Text::createTextRenderer(RenderStyle* style)
if (style->hasTextCombine())
return new (document()->renderArena()) RenderCombineText(this, dataImpl());
+ // button input types (submit, button, reset) have special selection behavior
+ // provided by RenderTextFragment's implementation of canBeSelectionLeaf()
+ // that makes it only selectable if the button is inside an editable region.
+ //
+ // FIXME: We should probably add a new css property like -webkit-user-select: editable
+ // that makes text selectable only if contenteditable is used around it and remove
+ // this special case.
+ if (renderingParent->hasTagName(inputTag) && renderingParent->renderer()->isRenderButton())
+ return new (document()->renderArena()) RenderTextFragment(this, dataImpl());
+
return new (document()->renderArena()) RenderText(this, dataImpl());
}
« 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