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 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved. |
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 193 } |
194 | 194 |
195 void HTMLLabelElement::accessKeyAction(bool sendMouseEvents) | 195 void HTMLLabelElement::accessKeyAction(bool sendMouseEvents) |
196 { | 196 { |
197 if (HTMLElement* element = control()) | 197 if (HTMLElement* element = control()) |
198 element->accessKeyAction(sendMouseEvents); | 198 element->accessKeyAction(sendMouseEvents); |
199 else | 199 else |
200 HTMLElement::accessKeyAction(sendMouseEvents); | 200 HTMLElement::accessKeyAction(sendMouseEvents); |
201 } | 201 } |
202 | 202 |
| 203 void HTMLLabelElement::updateLabel(TreeScope& scope, const AtomicString& oldForA
ttributeValue, const AtomicString& newForAttributeValue) |
| 204 { |
| 205 if (!inDocument()) |
| 206 return; |
| 207 |
| 208 if (oldForAttributeValue == newForAttributeValue) |
| 209 return; |
| 210 |
| 211 if (!oldForAttributeValue.isEmpty()) |
| 212 scope.removeLabel(oldForAttributeValue, toHTMLLabelElement(this)); |
| 213 if (!newForAttributeValue.isEmpty()) |
| 214 scope.addLabel(newForAttributeValue, toHTMLLabelElement(this)); |
| 215 } |
| 216 |
| 217 void HTMLLabelElement::attributeWillChange(const QualifiedName& name, const Atom
icString& oldValue, const AtomicString& newValue) |
| 218 { |
| 219 if (name == HTMLNames::forAttr) { |
| 220 TreeScope& scope = treeScope(); |
| 221 if (scope.shouldCacheLabelsByForAttribute()) |
| 222 updateLabel(scope, oldValue, newValue); |
| 223 } |
| 224 HTMLElement::attributeWillChange(name, oldValue, newValue); |
| 225 } |
| 226 |
| 227 Node::InsertionNotificationRequest HTMLLabelElement::insertedInto(ContainerNode*
insertionPoint) |
| 228 { |
| 229 InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoi
nt); |
| 230 if (insertionPoint->isInTreeScope()) { |
| 231 TreeScope& scope = insertionPoint->treeScope(); |
| 232 if (scope == treeScope() && scope.shouldCacheLabelsByForAttribute()) |
| 233 updateLabel(scope, nullAtom, fastGetAttribute(forAttr)); |
| 234 } |
| 235 return result; |
| 236 } |
| 237 |
| 238 void HTMLLabelElement::removedFrom(ContainerNode* insertionPoint) |
| 239 { |
| 240 if (insertionPoint->isInTreeScope() && treeScope() == document()) { |
| 241 TreeScope& treeScope = insertionPoint->treeScope(); |
| 242 if (treeScope.shouldCacheLabelsByForAttribute()) |
| 243 updateLabel(treeScope, fastGetAttribute(forAttr), nullAtom); |
| 244 } |
| 245 HTMLElement::removedFrom(insertionPoint); |
| 246 } |
| 247 |
203 } // namespace | 248 } // namespace |
OLD | NEW |