| 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 11ffd7311a31beb671927a78a697d29056062b88..0e5572babe4cdf3db47eb4cd65385c7bfa7322bd 100644
|
| --- a/third_party/WebKit/Source/core/html/HTMLAreaElement.cpp
|
| +++ b/third_party/WebKit/Source/core/html/HTMLAreaElement.cpp
|
| @@ -48,7 +48,6 @@ using namespace HTMLNames;
|
|
|
| inline HTMLAreaElement::HTMLAreaElement(Document& document)
|
| : HTMLAnchorElement(areaTag, document)
|
| - , m_lastSize(-1, -1)
|
| , m_shape(Rect)
|
| {
|
| }
|
| @@ -78,10 +77,10 @@ void HTMLAreaElement::parseAttribute(const QualifiedName& name, const AtomicStri
|
| // 'shape' attribute is 'rect'.
|
| m_shape = Rect;
|
| }
|
| - invalidateCachedRegion();
|
| + invalidateCachedPath();
|
| } else if (name == coordsAttr) {
|
| m_coords = parseHTMLListOfFloatingPointNumbers(value.getString());
|
| - invalidateCachedRegion();
|
| + invalidateCachedPath();
|
| } else if (name == altAttr || name == accesskeyAttr) {
|
| // Do nothing.
|
| } else {
|
| @@ -89,36 +88,27 @@ void HTMLAreaElement::parseAttribute(const QualifiedName& name, const AtomicStri
|
| }
|
| }
|
|
|
| -void HTMLAreaElement::invalidateCachedRegion()
|
| +void HTMLAreaElement::invalidateCachedPath()
|
| {
|
| - m_lastSize = LayoutSize(-1, -1);
|
| + m_path = nullptr;
|
| }
|
|
|
| -bool HTMLAreaElement::pointInArea(LayoutPoint location, const LayoutSize& containerSize)
|
| +bool HTMLAreaElement::pointInArea(const LayoutPoint& location)
|
| {
|
| - if (m_lastSize != containerSize) {
|
| - m_region = adoptPtr(new Path(getRegion(containerSize)));
|
| - m_lastSize = containerSize;
|
| - }
|
| -
|
| - return m_region->contains(FloatPoint(location));
|
| + return getPath().contains(FloatPoint(location));
|
| }
|
|
|
| -Path HTMLAreaElement::computePath(const LayoutObject* obj) const
|
| +LayoutRect HTMLAreaElement::computeAbsoluteRect() const
|
| {
|
| - if (!obj)
|
| - return Path();
|
| + LayoutObject* object = imageElementLayoutObject();
|
| + if (!object)
|
| + return LayoutRect();
|
|
|
| // FIXME: This doesn't work correctly with transforms.
|
| - FloatPoint absPos = obj->localToAbsolute();
|
| -
|
| - // Default should default to the size of the containing object.
|
| - LayoutSize size = m_lastSize;
|
| - if (m_shape == Default)
|
| - size = obj->absoluteClippedOverflowRect().size();
|
| + FloatPoint absPos = object->localToAbsolute();
|
|
|
| - Path p = getRegion(size);
|
| - float zoomFactor = obj->style()->effectiveZoom();
|
| + Path p = getPath();
|
| + float zoomFactor = object->styleRef().effectiveZoom();
|
| if (zoomFactor != 1.0f) {
|
| AffineTransform zoomTransform;
|
| zoomTransform.scale(zoomFactor);
|
| @@ -126,35 +116,34 @@ Path HTMLAreaElement::computePath(const LayoutObject* obj) const
|
| }
|
|
|
| p.translate(toFloatSize(absPos));
|
| - return p;
|
| + return enclosingLayoutRect(p.boundingRect());
|
| }
|
|
|
| -LayoutRect HTMLAreaElement::computeRect(const LayoutObject* obj) const
|
| +const Path& HTMLAreaElement::getPath() const
|
| {
|
| - return enclosingLayoutRect(computePath(obj).boundingRect());
|
| -}
|
| + if (m_path)
|
| + return *m_path;
|
| +
|
| + m_path = adoptPtr(new Path);
|
|
|
| -Path HTMLAreaElement::getRegion(const LayoutSize& size) const
|
| -{
|
| if (m_coords.isEmpty() && m_shape != Default)
|
| - return Path();
|
| + return *m_path;
|
|
|
| - Path path;
|
| switch (m_shape) {
|
| case Poly:
|
| if (m_coords.size() >= 6) {
|
| int numPoints = m_coords.size() / 2;
|
| - path.moveTo(FloatPoint(clampCoordinate(m_coords[0]), clampCoordinate(m_coords[1])));
|
| + m_path->moveTo(FloatPoint(clampCoordinate(m_coords[0]), clampCoordinate(m_coords[1])));
|
| for (int i = 1; i < numPoints; ++i)
|
| - path.addLineTo(FloatPoint(clampCoordinate(m_coords[i * 2]), clampCoordinate(m_coords[i * 2 + 1])));
|
| - path.closeSubpath();
|
| - path.setWindRule(RULE_EVENODD);
|
| + m_path->addLineTo(FloatPoint(clampCoordinate(m_coords[i * 2]), clampCoordinate(m_coords[i * 2 + 1])));
|
| + m_path->closeSubpath();
|
| + m_path->setWindRule(RULE_EVENODD);
|
| }
|
| break;
|
| case Circle:
|
| if (m_coords.size() >= 3 && m_coords[2] > 0) {
|
| float r = clampCoordinate(m_coords[2]);
|
| - path.addEllipse(FloatRect(clampCoordinate(m_coords[0]) - r, clampCoordinate(m_coords[1]) - r, 2 * r, 2 * r));
|
| + m_path->addEllipse(FloatRect(clampCoordinate(m_coords[0]) - r, clampCoordinate(m_coords[1]) - r, 2 * r, 2 * r));
|
| }
|
| break;
|
| case Rect:
|
| @@ -163,15 +152,18 @@ Path HTMLAreaElement::getRegion(const LayoutSize& size) const
|
| 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));
|
| + m_path->addRect(FloatRect(x0, y0, x1 - x0, y1 - y0));
|
| }
|
| break;
|
| case Default:
|
| - path.addRect(FloatRect(FloatPoint(0, 0), FloatSize(size)));
|
| + if (LayoutObject* object = imageElementLayoutObject()) {
|
| + if (object->isBox())
|
| + m_path->addRect(FloatRect(toLayoutBox(object)->contentBoxRect()));
|
| + }
|
| break;
|
| }
|
|
|
| - return path;
|
| + return *m_path;
|
| }
|
|
|
| HTMLImageElement* HTMLAreaElement::imageElement() const
|
| @@ -181,6 +173,13 @@ HTMLImageElement* HTMLAreaElement::imageElement() const
|
| return nullptr;
|
| }
|
|
|
| +LayoutObject* HTMLAreaElement::imageElementLayoutObject() const
|
| +{
|
| + if (HTMLImageElement* imageElement = this->imageElement())
|
| + return imageElement->layoutObject();
|
| + return nullptr;
|
| +}
|
| +
|
| bool HTMLAreaElement::isKeyboardFocusable() const
|
| {
|
| return isFocusable();
|
|
|