| 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 * |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 else if (equalIgnoringCase(value, "poly")) | 65 else if (equalIgnoringCase(value, "poly")) |
| 66 m_shape = Poly; | 66 m_shape = Poly; |
| 67 else if (equalIgnoringCase(value, "rect")) | 67 else if (equalIgnoringCase(value, "rect")) |
| 68 m_shape = Rect; | 68 m_shape = Rect; |
| 69 invalidateCachedRegion(); | 69 invalidateCachedRegion(); |
| 70 } else if (name == coordsAttr) { | 70 } else if (name == coordsAttr) { |
| 71 m_coords = parseHTMLAreaElementCoords(value.string()); | 71 m_coords = parseHTMLAreaElementCoords(value.string()); |
| 72 invalidateCachedRegion(); | 72 invalidateCachedRegion(); |
| 73 } else if (name == altAttr || name == accesskeyAttr) { | 73 } else if (name == altAttr || name == accesskeyAttr) { |
| 74 // Do nothing. | 74 // Do nothing. |
| 75 } else | 75 } else { |
| 76 HTMLAnchorElement::parseAttribute(name, value); | 76 HTMLAnchorElement::parseAttribute(name, value); |
| 77 } |
| 77 } | 78 } |
| 78 | 79 |
| 79 void HTMLAreaElement::invalidateCachedRegion() | 80 void HTMLAreaElement::invalidateCachedRegion() |
| 80 { | 81 { |
| 81 m_lastSize = LayoutSize(-1, -1); | 82 m_lastSize = LayoutSize(-1, -1); |
| 82 } | 83 } |
| 83 | 84 |
| 84 bool HTMLAreaElement::pointInArea(LayoutPoint location, const LayoutSize& contai
nerSize) | 85 bool HTMLAreaElement::pointInArea(LayoutPoint location, const LayoutSize& contai
nerSize) |
| 85 { | 86 { |
| 86 if (m_lastSize != containerSize) { | 87 if (m_lastSize != containerSize) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 if (m_coords.size() == 3) | 136 if (m_coords.size() == 3) |
| 136 shape = Circle; | 137 shape = Circle; |
| 137 else if (m_coords.size() == 4) | 138 else if (m_coords.size() == 4) |
| 138 shape = Rect; | 139 shape = Rect; |
| 139 else if (m_coords.size() >= 6) | 140 else if (m_coords.size() >= 6) |
| 140 shape = Poly; | 141 shape = Poly; |
| 141 } | 142 } |
| 142 | 143 |
| 143 Path path; | 144 Path path; |
| 144 switch (shape) { | 145 switch (shape) { |
| 145 case Poly: | 146 case Poly: |
| 146 if (m_coords.size() >= 6) { | 147 if (m_coords.size() >= 6) { |
| 147 int numPoints = m_coords.size() / 2; | 148 int numPoints = m_coords.size() / 2; |
| 148 path.moveTo(FloatPoint(minimumValueForLength(m_coords[0], width)
.toFloat(), minimumValueForLength(m_coords[1], height).toFloat())); | 149 path.moveTo(FloatPoint(minimumValueForLength(m_coords[0], width).toF
loat(), minimumValueForLength(m_coords[1], height).toFloat())); |
| 149 for (int i = 1; i < numPoints; ++i) | 150 for (int i = 1; i < numPoints; ++i) |
| 150 path.addLineTo(FloatPoint(minimumValueForLength(m_coords[i *
2], width).toFloat(), minimumValueForLength(m_coords[i * 2 + 1], height).toFloa
t())); | 151 path.addLineTo(FloatPoint(minimumValueForLength(m_coords[i * 2],
width).toFloat(), minimumValueForLength(m_coords[i * 2 + 1], height).toFloat())
); |
| 151 path.closeSubpath(); | 152 path.closeSubpath(); |
| 152 } | 153 } |
| 153 break; | 154 break; |
| 154 case Circle: | 155 case Circle: |
| 155 if (m_coords.size() >= 3) { | 156 if (m_coords.size() >= 3) { |
| 156 Length radius = m_coords[2]; | 157 Length radius = m_coords[2]; |
| 157 float r = std::min(minimumValueForLength(radius, width).toFloat(
), minimumValueForLength(radius, height).toFloat()); | 158 float r = std::min(minimumValueForLength(radius, width).toFloat(), m
inimumValueForLength(radius, height).toFloat()); |
| 158 path.addEllipse(FloatRect(minimumValueForLength(m_coords[0], wid
th).toFloat() - r, minimumValueForLength(m_coords[1], height).toFloat() - r, 2 *
r, 2 * r)); | 159 path.addEllipse(FloatRect(minimumValueForLength(m_coords[0], width).
toFloat() - r, minimumValueForLength(m_coords[1], height).toFloat() - r, 2 * r,
2 * r)); |
| 159 } | 160 } |
| 160 break; | 161 break; |
| 161 case Rect: | 162 case Rect: |
| 162 if (m_coords.size() >= 4) { | 163 if (m_coords.size() >= 4) { |
| 163 float x0 = minimumValueForLength(m_coords[0], width).toFloat(); | 164 float x0 = minimumValueForLength(m_coords[0], width).toFloat(); |
| 164 float y0 = minimumValueForLength(m_coords[1], height).toFloat(); | 165 float y0 = minimumValueForLength(m_coords[1], height).toFloat(); |
| 165 float x1 = minimumValueForLength(m_coords[2], width).toFloat(); | 166 float x1 = minimumValueForLength(m_coords[2], width).toFloat(); |
| 166 float y1 = minimumValueForLength(m_coords[3], height).toFloat(); | 167 float y1 = minimumValueForLength(m_coords[3], height).toFloat(); |
| 167 path.addRect(FloatRect(x0, y0, x1 - x0, y1 - y0)); | 168 path.addRect(FloatRect(x0, y0, x1 - x0, y1 - y0)); |
| 168 } | 169 } |
| 169 break; | 170 break; |
| 170 case Default: | 171 case Default: |
| 171 path.addRect(FloatRect(0, 0, width.toFloat(), height.toFloat())); | 172 path.addRect(FloatRect(0, 0, width.toFloat(), height.toFloat())); |
| 172 break; | 173 break; |
| 173 case Unknown: | 174 case Unknown: |
| 174 break; | 175 break; |
| 175 } | 176 } |
| 176 | 177 |
| 177 return path; | 178 return path; |
| 178 } | 179 } |
| 179 | 180 |
| 180 HTMLImageElement* HTMLAreaElement::imageElement() const | 181 HTMLImageElement* HTMLAreaElement::imageElement() const |
| 181 { | 182 { |
| 182 if (HTMLMapElement* mapElement = Traversal<HTMLMapElement>::firstAncestor(*t
his)) | 183 if (HTMLMapElement* mapElement = Traversal<HTMLMapElement>::firstAncestor(*t
his)) |
| 183 return mapElement->imageElement(); | 184 return mapElement->imageElement(); |
| 184 return nullptr; | 185 return nullptr; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 return; | 228 return; |
| 228 | 229 |
| 229 HTMLImageElement* imageElement = this->imageElement(); | 230 HTMLImageElement* imageElement = this->imageElement(); |
| 230 if (!imageElement) | 231 if (!imageElement) |
| 231 return; | 232 return; |
| 232 | 233 |
| 233 imageElement->updateFocusAppearance(restorePreviousSelection); | 234 imageElement->updateFocusAppearance(restorePreviousSelection); |
| 234 } | 235 } |
| 235 | 236 |
| 236 } | 237 } |
| OLD | NEW |