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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 | 222 |
223 void HTMLLabelElement::accessKeyAction(bool sendMouseEvents) | 223 void HTMLLabelElement::accessKeyAction(bool sendMouseEvents) |
224 { | 224 { |
225 if (HTMLElement* element = control()) | 225 if (HTMLElement* element = control()) |
226 element->accessKeyAction(sendMouseEvents); | 226 element->accessKeyAction(sendMouseEvents); |
227 else | 227 else |
228 HTMLElement::accessKeyAction(sendMouseEvents); | 228 HTMLElement::accessKeyAction(sendMouseEvents); |
229 } | 229 } |
230 | 230 |
231 void HTMLLabelElement::updateLabel(TreeScope& scope, const AtomicString& oldForA
ttributeValue, const AtomicString& newForAttributeValue) | |
232 { | |
233 if (!inShadowIncludingDocument()) | |
234 return; | |
235 | |
236 if (oldForAttributeValue == newForAttributeValue) | |
237 return; | |
238 | |
239 if (!oldForAttributeValue.isEmpty()) | |
240 scope.removeLabel(oldForAttributeValue, this); | |
241 if (!newForAttributeValue.isEmpty()) | |
242 scope.addLabel(newForAttributeValue, this); | |
243 } | |
244 | |
245 Node::InsertionNotificationRequest HTMLLabelElement::insertedInto(ContainerNode*
insertionPoint) | 231 Node::InsertionNotificationRequest HTMLLabelElement::insertedInto(ContainerNode*
insertionPoint) |
246 { | 232 { |
247 InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoi
nt); | 233 InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoi
nt); |
248 if (insertionPoint->isInTreeScope()) { | |
249 TreeScope& scope = insertionPoint->treeScope(); | |
250 if (scope == treeScope() && scope.shouldCacheLabelsByForAttribute()) | |
251 updateLabel(scope, nullAtom, fastGetAttribute(forAttr)); | |
252 } | |
253 | 234 |
254 // Trigger for elements outside of forms. | 235 // Trigger for elements outside of forms. |
255 if (!formOwner() && insertionPoint->inShadowIncludingDocument()) | 236 if (!formOwner() && insertionPoint->inShadowIncludingDocument()) |
256 document().didAssociateFormControl(this); | 237 document().didAssociateFormControl(this); |
257 | 238 |
258 return result; | 239 return result; |
259 } | 240 } |
260 | 241 |
261 void HTMLLabelElement::removedFrom(ContainerNode* insertionPoint) | 242 void HTMLLabelElement::removedFrom(ContainerNode* insertionPoint) |
262 { | 243 { |
263 if (insertionPoint->isInTreeScope() && treeScope() == document()) { | |
264 TreeScope& treeScope = insertionPoint->treeScope(); | |
265 if (treeScope.shouldCacheLabelsByForAttribute()) | |
266 updateLabel(treeScope, fastGetAttribute(forAttr), nullAtom); | |
267 } | |
268 HTMLElement::removedFrom(insertionPoint); | 244 HTMLElement::removedFrom(insertionPoint); |
269 document().removeFormAssociation(this); | 245 document().removeFormAssociation(this); |
270 } | 246 } |
271 | 247 |
272 void HTMLLabelElement::parseAttribute(const QualifiedName& attributeName, const
AtomicString& oldValue, const AtomicString& attributeValue) | |
273 { | |
274 if (attributeName == forAttr) { | |
275 TreeScope& scope = treeScope(); | |
276 if (scope.shouldCacheLabelsByForAttribute()) | |
277 updateLabel(scope, oldValue, attributeValue); | |
278 } | |
279 HTMLElement::parseAttribute(attributeName, oldValue, attributeValue); | |
280 } | |
281 | |
282 } // namespace blink | 248 } // namespace blink |
OLD | NEW |