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

Unified Diff: third_party/WebKit/Source/core/html/HTMLAreaElement.cpp

Issue 1619793002: Remove use of minimumValueForLength in HTMLAreaElement::getRegion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLAreaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLAreaElement.cpp b/third_party/WebKit/Source/core/html/HTMLAreaElement.cpp
index d52b2d0fa23ee445cbdcd5541463667179aac376..d8155b445fad4557b793a4419342cf49cb068b5b 100644
--- a/third_party/WebKit/Source/core/html/HTMLAreaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLAreaElement.cpp
@@ -28,12 +28,22 @@
#include "core/layout/HitTestResult.h"
#include "core/layout/LayoutImage.h"
#include "core/layout/LayoutView.h"
-#include "platform/LengthFunctions.h"
#include "platform/graphics/Path.h"
#include "platform/transforms/AffineTransform.h"
namespace blink {
+namespace {
+
+// Adapt a Length to the allowed range of a LayoutUnit.
+float clampCoordinate(const Length& length)
+{
+ ASSERT(length.isFixed());
+ return LayoutUnit(length.value()).toFloat();
+}
+
+}
+
using namespace HTMLNames;
inline HTMLAreaElement::HTMLAreaElement(Document& document)
@@ -126,9 +136,6 @@ Path HTMLAreaElement::getRegion(const LayoutSize& size) const
if (m_coords.isEmpty() && m_shape != Default)
return Path();
- LayoutUnit width = size.width();
- LayoutUnit height = size.height();
-
// If element omits the shape attribute, select shape based on number of coordinates.
Shape shape = m_shape;
if (shape == Unknown) {
@@ -145,30 +152,29 @@ Path HTMLAreaElement::getRegion(const LayoutSize& size) const
case Poly:
if (m_coords.size() >= 6) {
int numPoints = m_coords.size() / 2;
- path.moveTo(FloatPoint(minimumValueForLength(m_coords[0], width).toFloat(), minimumValueForLength(m_coords[1], height).toFloat()));
+ path.moveTo(FloatPoint(clampCoordinate(m_coords[0]), clampCoordinate(m_coords[1])));
for (int i = 1; i < numPoints; ++i)
- path.addLineTo(FloatPoint(minimumValueForLength(m_coords[i * 2], width).toFloat(), minimumValueForLength(m_coords[i * 2 + 1], height).toFloat()));
+ path.addLineTo(FloatPoint(clampCoordinate(m_coords[i * 2]), clampCoordinate(m_coords[i * 2 + 1])));
path.closeSubpath();
}
break;
case Circle:
if (m_coords.size() >= 3) {
- Length radius = m_coords[2];
- float r = std::min(minimumValueForLength(radius, width).toFloat(), minimumValueForLength(radius, height).toFloat());
- path.addEllipse(FloatRect(minimumValueForLength(m_coords[0], width).toFloat() - r, minimumValueForLength(m_coords[1], height).toFloat() - r, 2 * r, 2 * r));
+ float r = clampCoordinate(m_coords[2]);
+ path.addEllipse(FloatRect(clampCoordinate(m_coords[0]) - r, clampCoordinate(m_coords[1]) - r, 2 * r, 2 * r));
}
break;
case Rect:
if (m_coords.size() >= 4) {
- float x0 = minimumValueForLength(m_coords[0], width).toFloat();
- float y0 = minimumValueForLength(m_coords[1], height).toFloat();
- float x1 = minimumValueForLength(m_coords[2], width).toFloat();
- float y1 = minimumValueForLength(m_coords[3], height).toFloat();
+ float x0 = clampCoordinate(m_coords[0]);
+ float y0 = clampCoordinate(m_coords[1]);
+ float x1 = clampCoordinate(m_coords[2]);
+ float y1 = clampCoordinate(m_coords[3]);
path.addRect(FloatRect(x0, y0, x1 - x0, y1 - y0));
}
break;
case Default:
- path.addRect(FloatRect(0, 0, width.toFloat(), height.toFloat()));
+ path.addRect(FloatRect(FloatPoint(0, 0), FloatSize(size)));
break;
case Unknown:
break;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698