summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/Text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/Text.cpp')
-rw-r--r--Source/WebCore/dom/Text.cpp44
1 files changed, 31 insertions, 13 deletions
diff --git a/Source/WebCore/dom/Text.cpp b/Source/WebCore/dom/Text.cpp
index 3fd0f15ea..9ef159a2d 100644
--- a/Source/WebCore/dom/Text.cpp
+++ b/Source/WebCore/dom/Text.cpp
@@ -42,7 +42,12 @@ namespace WebCore {
PassRefPtr<Text> Text::create(Document* document, const String& data)
{
- return adoptRef(new Text(document, data));
+ return adoptRef(new Text(document, data, CreateText));
+}
+
+PassRefPtr<Text> Text::createEditingText(Document* document, const String& data)
+{
+ return adoptRef(new Text(document, data, CreateEditingText));
}
PassRefPtr<Text> Text::splitText(unsigned offset, ExceptionCode& ec)
@@ -192,6 +197,8 @@ PassRefPtr<Node> Text::cloneNode(bool /*deep*/)
bool Text::rendererIsNeeded(const NodeRenderingContext& context)
{
+ if (isEditingText())
+ return true;
if (!CharacterData::rendererIsNeeded(context))
return false;
@@ -231,11 +238,24 @@ bool Text::rendererIsNeeded(const NodeRenderingContext& context)
return true;
}
+#if ENABLE(SVG)
+static bool isSVGShadowText(Text* text)
+{
+ Node* parentNode = text->parentNode();
+ return parentNode->isShadowRoot() && toShadowRoot(parentNode)->host()->hasTagName(SVGNames::trefTag);
+}
+
+static bool isSVGText(Text* text)
+{
+ Node* parentOrHostNode = text->parentOrHostNode();
+ return parentOrHostNode->isSVGElement() && !parentOrHostNode->hasTagName(SVGNames::foreignObjectTag);
+}
+#endif
+
RenderObject* Text::createRenderer(RenderArena* arena, RenderStyle* style)
{
#if ENABLE(SVG)
- Node* parentOrHost = parentOrHostNode();
- if (parentOrHost->isSVGElement() && !parentOrHost->hasTagName(SVGNames::foreignObjectTag))
+ if (isSVGText(this) || isSVGShadowText(this))
return new (arena) RenderSVGInlineText(this, dataImpl());
#endif
@@ -253,15 +273,18 @@ void Text::attach()
void Text::recalcTextStyle(StyleChange change)
{
- if (hasCustomCallbacks())
- willRecalcTextStyle(change);
-
RenderObject* renderer = this->renderer();
// The only time we have a renderer and our parent doesn't is if our parent
// is a shadow root.
- if (change != NoChange && renderer && !parentNode()->isShadowRoot())
- renderer->setStyle(parentNode()->renderer()->style());
+ if (change != NoChange && renderer) {
+ if (!parentNode()->isShadowRoot())
+ renderer->setStyle(parentNode()->renderer()->style());
+#if ENABLE(SVG)
+ else if (isSVGShadowText(this))
+ renderer->setStyle(toShadowRoot(parentNode())->host()->renderer()->style());
+#endif
+ }
if (needsStyleRecalc()) {
if (renderer) {
@@ -296,11 +319,6 @@ PassRefPtr<Text> Text::createWithLengthLimit(Document* document, const String& d
return result;
}
-void Text::willRecalcTextStyle(StyleChange)
-{
- ASSERT_NOT_REACHED();
-}
-
#ifndef NDEBUG
void Text::formatForDebugger(char *buffer, unsigned length) const
{