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

Unified Diff: Source/core/layout/svg/LayoutSVGText.cpp

Issue 1308983006: Don't drop type information returned from locateRenderSVGTextAncestor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Dedupe. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/layout/svg/LayoutSVGText.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/svg/LayoutSVGText.cpp
diff --git a/Source/core/layout/svg/LayoutSVGText.cpp b/Source/core/layout/svg/LayoutSVGText.cpp
index 1f76ce3a176786a71b937669163b679e8bd72946..63c6cf49d6ac17b1fe900fffcdc81516330b62cc 100644
--- a/Source/core/layout/svg/LayoutSVGText.cpp
+++ b/Source/core/layout/svg/LayoutSVGText.cpp
@@ -54,6 +54,20 @@
namespace blink {
+namespace {
+
+const LayoutSVGText* findTextRoot(const LayoutObject* start)
+{
+ ASSERT(start);
+ for (; start; start = start->parent()) {
+ if (start->isSVGText())
+ return toLayoutSVGText(start);
+ }
+ return nullptr;
+}
+
+}
+
LayoutSVGText::LayoutSVGText(SVGTextElement* node)
: LayoutSVGBlock(node)
, m_needsReordering(false)
@@ -75,22 +89,12 @@ bool LayoutSVGText::isChildAllowed(LayoutObject* child, const ComputedStyle&) co
LayoutSVGText* LayoutSVGText::locateLayoutSVGTextAncestor(LayoutObject* start)
{
- ASSERT(start);
- while (start && !start->isSVGText())
- start = start->parent();
- if (!start || !start->isSVGText())
- return nullptr;
- return toLayoutSVGText(start);
+ return const_cast<LayoutSVGText*>(findTextRoot(start));
}
const LayoutSVGText* LayoutSVGText::locateLayoutSVGTextAncestor(const LayoutObject* start)
{
- ASSERT(start);
- while (start && !start->isSVGText())
- start = start->parent();
- if (!start || !start->isSVGText())
- return nullptr;
- return toLayoutSVGText(start);
+ return findTextRoot(start);
}
static inline void collectLayoutAttributes(LayoutObject* text, Vector<SVGTextLayoutAttributes*>& attributes)
« no previous file with comments | « Source/core/layout/svg/LayoutSVGText.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698