| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2  * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 
| 3  * | 3  * | 
| 4  * This library is free software; you can redistribute it and/or | 4  * This library is free software; you can redistribute it and/or | 
| 5  * modify it under the terms of the GNU Library General Public | 5  * modify it under the terms of the GNU Library General Public | 
| 6  * License as published by the Free Software Foundation; either | 6  * License as published by the Free Software Foundation; either | 
| 7  * version 2 of the License, or (at your option) any later version. | 7  * version 2 of the License, or (at your option) any later version. | 
| 8  * | 8  * | 
| 9  * This library is distributed in the hope that it will be useful, | 9  * This library is distributed in the hope that it will be useful, | 
| 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
| 12  * Library General Public License for more details. | 12  * Library General Public License for more details. | 
| 13  * | 13  * | 
| 14  * You should have received a copy of the GNU Library General Public License | 14  * You should have received a copy of the GNU Library General Public License | 
| 15  * along with this library; see the file COPYING.LIB.  If not, write to | 15  * along with this library; see the file COPYING.LIB.  If not, write to | 
| 16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 
| 17  * Boston, MA 02110-1301, USA. | 17  * Boston, MA 02110-1301, USA. | 
| 18  */ | 18  */ | 
| 19 | 19 | 
| 20 #include "core/layout/svg/SVGTextMetrics.h" | 20 #include "core/layout/svg/SVGTextMetrics.h" | 
| 21 | 21 | 
| 22 #include "platform/fonts/FontOrientation.h" | 22 #include "platform/fonts/FontOrientation.h" | 
|  | 23 #include "platform/geometry/FloatSize.h" | 
|  | 24 #include "platform/wtf/MathExtras.h" | 
| 23 | 25 | 
| 24 namespace blink { | 26 namespace blink { | 
| 25 | 27 | 
| 26 SVGTextMetrics::SVGTextMetrics(unsigned length, float width, float height) | 28 SVGTextMetrics::SVGTextMetrics(unsigned length, float width, float height) | 
| 27     : width_(width), height_(height), length_(length) {} | 29     : width_(width), height_(height), length_(length) {} | 
| 28 | 30 | 
| 29 SVGTextMetrics::SVGTextMetrics(SVGTextMetrics::MetricsType) | 31 SVGTextMetrics::SVGTextMetrics(SVGTextMetrics::MetricsType) | 
| 30     : SVGTextMetrics(1, 0, 0) {} | 32     : SVGTextMetrics(1, 0, 0) {} | 
| 31 | 33 | 
|  | 34 FloatSize SVGTextMetrics::Extents() const { | 
|  | 35   // TODO(fs): Negative glyph extents seems kind of weird to have, but | 
|  | 36   // presently it can occur in some cases (like Arabic.) | 
|  | 37   return FloatSize(std::max<float>(width_, 0), std::max<float>(height_, 0)); | 
|  | 38 } | 
|  | 39 | 
| 32 float SVGTextMetrics::Advance(FontOrientation orientation) const { | 40 float SVGTextMetrics::Advance(FontOrientation orientation) const { | 
| 33   switch (orientation) { | 41   switch (orientation) { | 
| 34     case FontOrientation::kHorizontal: | 42     case FontOrientation::kHorizontal: | 
| 35     case FontOrientation::kVerticalRotated: | 43     case FontOrientation::kVerticalRotated: | 
| 36       return Width(); | 44       return width_; | 
| 37     case FontOrientation::kVerticalUpright: | 45     case FontOrientation::kVerticalUpright: | 
| 38       return Height(); | 46       return height_; | 
| 39     default: | 47     default: | 
| 40       NOTREACHED(); | 48       NOTREACHED(); | 
| 41       return Width(); | 49       return width_; | 
| 42   } | 50   } | 
| 43 } | 51 } | 
| 44 | 52 | 
| 45 }  // namespace blink | 53 }  // namespace blink | 
| OLD | NEW | 
|---|