| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 using namespace HTMLNames; | 42 using namespace HTMLNames; |
| 43 | 43 |
| 44 inline HTMLLabelElement::HTMLLabelElement(Document& document, HTMLFormElement* f
orm) | 44 inline HTMLLabelElement::HTMLLabelElement(Document& document, HTMLFormElement* f
orm) |
| 45 : HTMLElement(labelTag, document) | 45 : HTMLElement(labelTag, document) |
| 46 , m_processingClick(false) | 46 , m_processingClick(false) |
| 47 { | 47 { |
| 48 FormAssociatedElement::associateByParser(form); | 48 FormAssociatedElement::associateByParser(form); |
| 49 } | 49 } |
| 50 | 50 |
| 51 PassRefPtrWillBeRawPtr<HTMLLabelElement> HTMLLabelElement::create(Document& docu
ment, HTMLFormElement* form) | 51 RawPtr<HTMLLabelElement> HTMLLabelElement::create(Document& document, HTMLFormEl
ement* form) |
| 52 { | 52 { |
| 53 RefPtrWillBeRawPtr<HTMLLabelElement> labelElement = adoptRefWillBeNoop(new H
TMLLabelElement(document, form)); | 53 RawPtr<HTMLLabelElement> labelElement = (new HTMLLabelElement(document, form
)); |
| 54 return labelElement.release(); | 54 return labelElement.release(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 LabelableElement* HTMLLabelElement::control() const | 57 LabelableElement* HTMLLabelElement::control() const |
| 58 { | 58 { |
| 59 const AtomicString& controlId = getAttribute(forAttr); | 59 const AtomicString& controlId = getAttribute(forAttr); |
| 60 if (controlId.isNull()) { | 60 if (controlId.isNull()) { |
| 61 // Search the children and descendants of the label element for a form e
lement. | 61 // Search the children and descendants of the label element for a form e
lement. |
| 62 // per http://dev.w3.org/html5/spec/Overview.html#the-label-element | 62 // per http://dev.w3.org/html5/spec/Overview.html#the-label-element |
| 63 // the form element must be "labelable form-associated element". | 63 // the form element must be "labelable form-associated element". |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 if (node->isHTMLElement() && toHTMLElement(node)->isInteractiveContent()
) | 120 if (node->isHTMLElement() && toHTMLElement(node)->isInteractiveContent()
) |
| 121 return true; | 121 return true; |
| 122 node = node->parentOrShadowHostNode(); | 122 node = node->parentOrShadowHostNode(); |
| 123 } | 123 } |
| 124 return false; | 124 return false; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void HTMLLabelElement::defaultEventHandler(Event* evt) | 127 void HTMLLabelElement::defaultEventHandler(Event* evt) |
| 128 { | 128 { |
| 129 if (evt->type() == EventTypeNames::click && !m_processingClick) { | 129 if (evt->type() == EventTypeNames::click && !m_processingClick) { |
| 130 RefPtrWillBeRawPtr<HTMLElement> element = control(); | 130 RawPtr<HTMLElement> element = control(); |
| 131 | 131 |
| 132 // If we can't find a control or if the control received the click | 132 // If we can't find a control or if the control received the click |
| 133 // event, then there's no need for us to do anything. | 133 // event, then there's no need for us to do anything. |
| 134 if (!element || (evt->target() && element->containsIncludingShadowDOM(ev
t->target()->toNode()))) | 134 if (!element || (evt->target() && element->containsIncludingShadowDOM(ev
t->target()->toNode()))) |
| 135 return; | 135 return; |
| 136 | 136 |
| 137 if (evt->target() && isInInteractiveContent(evt->target()->toNode())) | 137 if (evt->target() && isInInteractiveContent(evt->target()->toNode())) |
| 138 return; | 138 return; |
| 139 | 139 |
| 140 // Behaviour of label element is as follows: | 140 // Behaviour of label element is as follows: |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 if (attributeName == forAttr) { | 279 if (attributeName == forAttr) { |
| 280 TreeScope& scope = treeScope(); | 280 TreeScope& scope = treeScope(); |
| 281 if (scope.shouldCacheLabelsByForAttribute()) | 281 if (scope.shouldCacheLabelsByForAttribute()) |
| 282 updateLabel(scope, oldValue, attributeValue); | 282 updateLabel(scope, oldValue, attributeValue); |
| 283 } | 283 } |
| 284 HTMLElement::parseAttribute(attributeName, oldValue, attributeValue); | 284 HTMLElement::parseAttribute(attributeName, oldValue, attributeValue); |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace blink | 288 } // namespace blink |
| OLD | NEW |