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

Unified Diff: third_party/WebKit/Source/core/layout/svg/SVGTextMetrics.cpp

Issue 2888623008: Remove SVGTextMetrics Width/Height getters (Closed)
Patch Set: Created 3 years, 7 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
Index: third_party/WebKit/Source/core/layout/svg/SVGTextMetrics.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGTextMetrics.cpp b/third_party/WebKit/Source/core/layout/svg/SVGTextMetrics.cpp
index 7f7a4d480f49be12d1626044d3179762dea7d4a7..93b77295becf11d80d1398719abfe9f532fd952c 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGTextMetrics.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/SVGTextMetrics.cpp
@@ -20,6 +20,8 @@
#include "core/layout/svg/SVGTextMetrics.h"
#include "platform/fonts/FontOrientation.h"
+#include "platform/geometry/FloatSize.h"
+#include "platform/wtf/MathExtras.h"
namespace blink {
@@ -29,16 +31,22 @@ SVGTextMetrics::SVGTextMetrics(unsigned length, float width, float height)
SVGTextMetrics::SVGTextMetrics(SVGTextMetrics::MetricsType)
: SVGTextMetrics(1, 0, 0) {}
+FloatSize SVGTextMetrics::Extents() const {
+ // TODO(fs): Negative glyph extents seems kind of weird to have, but
+ // presently it can occur in some cases (like Arabic.)
+ return FloatSize(std::max<float>(width_, 0), std::max<float>(height_, 0));
+}
+
float SVGTextMetrics::Advance(FontOrientation orientation) const {
switch (orientation) {
case FontOrientation::kHorizontal:
case FontOrientation::kVerticalRotated:
- return Width();
+ return width_;
case FontOrientation::kVerticalUpright:
- return Height();
+ return height_;
default:
NOTREACHED();
- return Width();
+ return width_;
}
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGTextMetrics.h ('k') | third_party/WebKit/Source/core/layout/svg/SVGTextQuery.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698