OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * Copyright (C) 2004, 2005, 2006, 2009, 2011 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2009, 2011 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #include "core/html/HTMLAreaElement.h" | 22 #include "core/html/HTMLAreaElement.h" |
23 | 23 |
24 #include "core/HTMLNames.h" | 24 #include "core/HTMLNames.h" |
25 #include "core/dom/ElementTraversal.h" | 25 #include "core/dom/ElementTraversal.h" |
26 #include "core/html/HTMLImageElement.h" | 26 #include "core/html/HTMLImageElement.h" |
27 #include "core/html/HTMLMapElement.h" | 27 #include "core/html/HTMLMapElement.h" |
| 28 #include "core/html/parser/HTMLParserIdioms.h" |
28 #include "core/layout/HitTestResult.h" | 29 #include "core/layout/HitTestResult.h" |
29 #include "core/layout/LayoutImage.h" | 30 #include "core/layout/LayoutImage.h" |
30 #include "core/layout/LayoutView.h" | 31 #include "core/layout/LayoutView.h" |
31 #include "platform/graphics/Path.h" | 32 #include "platform/graphics/Path.h" |
32 #include "platform/transforms/AffineTransform.h" | 33 #include "platform/transforms/AffineTransform.h" |
33 | 34 |
34 namespace blink { | 35 namespace blink { |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 // Adapt a Length to the allowed range of a LayoutUnit. | 39 // Adapt a double to the allowed range of a LayoutUnit and narrow it to float pr
ecision. |
39 float clampCoordinate(const Length& length) | 40 float clampCoordinate(double value) |
40 { | 41 { |
41 ASSERT(length.isFixed()); | 42 return LayoutUnit(value).toFloat(); |
42 return LayoutUnit(length.value()).toFloat(); | |
43 } | 43 } |
44 | 44 |
45 } | 45 } |
46 | 46 |
47 using namespace HTMLNames; | 47 using namespace HTMLNames; |
48 | 48 |
49 inline HTMLAreaElement::HTMLAreaElement(Document& document) | 49 inline HTMLAreaElement::HTMLAreaElement(Document& document) |
50 : HTMLAnchorElement(areaTag, document) | 50 : HTMLAnchorElement(areaTag, document) |
51 , m_lastSize(-1, -1) | 51 , m_lastSize(-1, -1) |
52 , m_shape(Rect) | 52 , m_shape(Rect) |
(...skipping 20 matching lines...) Expand all Loading... |
73 m_shape = Circle; | 73 m_shape = Circle; |
74 } else if (equalIgnoringASCIICase(value, "polygon") || equalIgnoringASCI
ICase(value, "poly")) { | 74 } else if (equalIgnoringASCIICase(value, "polygon") || equalIgnoringASCI
ICase(value, "poly")) { |
75 m_shape = Poly; | 75 m_shape = Poly; |
76 } else { | 76 } else { |
77 // The missing (and implicitly invalid) value default for the | 77 // The missing (and implicitly invalid) value default for the |
78 // 'shape' attribute is 'rect'. | 78 // 'shape' attribute is 'rect'. |
79 m_shape = Rect; | 79 m_shape = Rect; |
80 } | 80 } |
81 invalidateCachedRegion(); | 81 invalidateCachedRegion(); |
82 } else if (name == coordsAttr) { | 82 } else if (name == coordsAttr) { |
83 m_coords = parseHTMLAreaElementCoords(value.string()); | 83 m_coords = parseHTMLListOfFloatingPointNumbers(value.string()); |
84 invalidateCachedRegion(); | 84 invalidateCachedRegion(); |
85 } else if (name == altAttr || name == accesskeyAttr) { | 85 } else if (name == altAttr || name == accesskeyAttr) { |
86 // Do nothing. | 86 // Do nothing. |
87 } else { | 87 } else { |
88 HTMLAnchorElement::parseAttribute(name, oldValue, value); | 88 HTMLAnchorElement::parseAttribute(name, oldValue, value); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 void HTMLAreaElement::invalidateCachedRegion() | 92 void HTMLAreaElement::invalidateCachedRegion() |
93 { | 93 { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 if (m_coords.size() >= 6) { | 145 if (m_coords.size() >= 6) { |
146 int numPoints = m_coords.size() / 2; | 146 int numPoints = m_coords.size() / 2; |
147 path.moveTo(FloatPoint(clampCoordinate(m_coords[0]), clampCoordinate
(m_coords[1]))); | 147 path.moveTo(FloatPoint(clampCoordinate(m_coords[0]), clampCoordinate
(m_coords[1]))); |
148 for (int i = 1; i < numPoints; ++i) | 148 for (int i = 1; i < numPoints; ++i) |
149 path.addLineTo(FloatPoint(clampCoordinate(m_coords[i * 2]), clam
pCoordinate(m_coords[i * 2 + 1]))); | 149 path.addLineTo(FloatPoint(clampCoordinate(m_coords[i * 2]), clam
pCoordinate(m_coords[i * 2 + 1]))); |
150 path.closeSubpath(); | 150 path.closeSubpath(); |
151 path.setWindRule(RULE_EVENODD); | 151 path.setWindRule(RULE_EVENODD); |
152 } | 152 } |
153 break; | 153 break; |
154 case Circle: | 154 case Circle: |
155 if (m_coords.size() >= 3 && m_coords[2].value() > 0) { | 155 if (m_coords.size() >= 3 && m_coords[2] > 0) { |
156 float r = clampCoordinate(m_coords[2]); | 156 float r = clampCoordinate(m_coords[2]); |
157 path.addEllipse(FloatRect(clampCoordinate(m_coords[0]) - r, clampCoo
rdinate(m_coords[1]) - r, 2 * r, 2 * r)); | 157 path.addEllipse(FloatRect(clampCoordinate(m_coords[0]) - r, clampCoo
rdinate(m_coords[1]) - r, 2 * r, 2 * r)); |
158 } | 158 } |
159 break; | 159 break; |
160 case Rect: | 160 case Rect: |
161 if (m_coords.size() >= 4) { | 161 if (m_coords.size() >= 4) { |
162 float x0 = clampCoordinate(m_coords[0]); | 162 float x0 = clampCoordinate(m_coords[0]); |
163 float y0 = clampCoordinate(m_coords[1]); | 163 float y0 = clampCoordinate(m_coords[1]); |
164 float x1 = clampCoordinate(m_coords[2]); | 164 float x1 = clampCoordinate(m_coords[2]); |
165 float y1 = clampCoordinate(m_coords[3]); | 165 float y1 = clampCoordinate(m_coords[3]); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 void HTMLAreaElement::updateFocusAppearance(SelectionBehaviorOnFocus selectionBe
havior) | 221 void HTMLAreaElement::updateFocusAppearance(SelectionBehaviorOnFocus selectionBe
havior) |
222 { | 222 { |
223 if (!isFocusable()) | 223 if (!isFocusable()) |
224 return; | 224 return; |
225 | 225 |
226 if (HTMLImageElement* imageElement = this->imageElement()) | 226 if (HTMLImageElement* imageElement = this->imageElement()) |
227 imageElement->updateFocusAppearance(selectionBehavior); | 227 imageElement->updateFocusAppearance(selectionBehavior); |
228 } | 228 } |
229 | 229 |
230 } // namespace blink | 230 } // namespace blink |
OLD | NEW |