Commit ca1a425a authored by fs's avatar fs Committed by Commit bot

The missing value default for <area shape> is 'rect'

There is no invalid value default, so the missing value default will
apply in that case too.
The 'Unknown' HTMLAreaElement::Shape enumeration value is no longer
needed, so remove it.

Also add support for the non-conforming <area shape> values:

 * 'circ'     (alias for 'circle')
 * 'polygon'  (alias for 'poly')
 * 'rectangle (alias for 'rect')

Because 'rect' (and hence 'rectangle') is the same as the missing
value default we don't need any explicit checks for these values.

https://html.spec.whatwg.org/multipage/embedded-content.html#attr-area-shape

BUG=578125

Review URL: https://codereview.chromium.org/1632133007

Cr-Commit-Position: refs/heads/master@{#371731}
parent 4d24c2af
This is a testharness.js-based test.
PASS missing value default: "2,2,10,10" (null)
FAIL missing value default: "20,40,10" (null) assert_equals: elementFromPoint(21, 41) expected Element node <img src="resources/images/blue-border.png" usemap="#x" i... but got Element node <area id="area" shape="null" coords="20,40,10"></area>
PASS missing value default: null (null)
PASS invalid value default: "2,2,10,10" (foobar invalid)
PASS invalid value default: "2,2,10,10" ()
PASS empty string: "" (default)
PASS omitted coords: null (DEFAULT)
PASS simple: "20,40,10" (circle)
PASS simple: "20,40,10" (circ)
PASS simple: "20,40,10" (CIRCLE)
PASS simple: "20,40,10" (CIRC)
FAIL LATIN CAPITAL LETTER I WITH DOT ABOVE: "20,40,10" (CİRCLE) assert_equals: elementFromPoint(21, 41) expected Element node <img src="resources/images/blue-border.png" usemap="#x" i... but got Element node <area id="area" shape="CİRCLE" coords="20,40,10"></area>
FAIL LATIN SMALL LETTER DOTLESS I: "20,40,10" (cırcle) assert_equals: elementFromPoint(21, 41) expected Element node <img src="resources/images/blue-border.png" usemap="#x" i... but got Element node <area id="area" shape="cırcle" coords="20,40,10"></area>
PASS simple: "100,100,120,100,100,120" (poly)
PASS simple: "100,100,120,100,100,120" (polygon)
Harness: the test ran to completion.
......@@ -49,7 +49,7 @@ using namespace HTMLNames;
inline HTMLAreaElement::HTMLAreaElement(Document& document)
: HTMLAnchorElement(areaTag, document)
, m_lastSize(-1, -1)
, m_shape(Unknown)
, m_shape(Rect)
{
}
......@@ -67,14 +67,17 @@ DEFINE_NODE_FACTORY(HTMLAreaElement)
void HTMLAreaElement::parseAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& value)
{
if (name == shapeAttr) {
if (equalIgnoringASCIICase(value, "default"))
if (equalIgnoringASCIICase(value, "default")) {
m_shape = Default;
else if (equalIgnoringASCIICase(value, "circle"))
} else if (equalIgnoringASCIICase(value, "circle") || equalIgnoringASCIICase(value, "circ")) {
m_shape = Circle;
else if (equalIgnoringASCIICase(value, "poly"))
} else if (equalIgnoringASCIICase(value, "polygon") || equalIgnoringASCIICase(value, "poly")) {
m_shape = Poly;
else if (equalIgnoringASCIICase(value, "rect"))
} else {
// The missing (and implicitly invalid) value default for the
// 'shape' attribute is 'rect'.
m_shape = Rect;
}
invalidateCachedRegion();
} else if (name == coordsAttr) {
m_coords = parseHTMLAreaElementCoords(value.string());
......@@ -136,19 +139,8 @@ Path HTMLAreaElement::getRegion(const LayoutSize& size) const
if (m_coords.isEmpty() && m_shape != Default)
return Path();
// If element omits the shape attribute, select shape based on number of coordinates.
Shape shape = m_shape;
if (shape == Unknown) {
if (m_coords.size() == 3)
shape = Circle;
else if (m_coords.size() == 4)
shape = Rect;
else if (m_coords.size() >= 6)
shape = Poly;
}
Path path;
switch (shape) {
switch (m_shape) {
case Poly:
if (m_coords.size() >= 6) {
int numPoints = m_coords.size() / 2;
......@@ -177,8 +169,6 @@ Path HTMLAreaElement::getRegion(const LayoutSize& size) const
case Default:
path.addRect(FloatRect(FloatPoint(0, 0), FloatSize(size)));
break;
case Unknown:
break;
}
return path;
......
......@@ -59,7 +59,7 @@ private:
void updateFocusAppearance(SelectionBehaviorOnFocus) override;
void setFocus(bool) override;
enum Shape { Default, Poly, Rect, Circle, Unknown };
enum Shape { Default, Poly, Rect, Circle };
Path getRegion(const LayoutSize&) const;
void invalidateCachedRegion();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment