| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 using namespace HTMLNames; | 43 using namespace HTMLNames; |
| 44 | 44 |
| 45 inline HTMLLabelElement::HTMLLabelElement(Document& document, HTMLFormElement* f
orm) | 45 inline HTMLLabelElement::HTMLLabelElement(Document& document, HTMLFormElement* f
orm) |
| 46 : HTMLElement(labelTag, document) | 46 : HTMLElement(labelTag, document) |
| 47 , m_processingClick(false) | 47 , m_processingClick(false) |
| 48 { | 48 { |
| 49 FormAssociatedElement::associateByParser(form); | 49 FormAssociatedElement::associateByParser(form); |
| 50 } | 50 } |
| 51 | 51 |
| 52 PassRefPtrWillBeRawPtr<HTMLLabelElement> HTMLLabelElement::create(Document& docu
ment, HTMLFormElement* form) | 52 RawPtr<HTMLLabelElement> HTMLLabelElement::create(Document& document, HTMLFormEl
ement* form) |
| 53 { | 53 { |
| 54 RefPtrWillBeRawPtr<HTMLLabelElement> labelElement = adoptRefWillBeNoop(new H
TMLLabelElement(document, form)); | 54 RawPtr<HTMLLabelElement> labelElement = new HTMLLabelElement(document, form)
; |
| 55 return labelElement.release(); | 55 return labelElement.release(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 LabelableElement* HTMLLabelElement::control() const | 58 LabelableElement* HTMLLabelElement::control() const |
| 59 { | 59 { |
| 60 const AtomicString& controlId = getAttribute(forAttr); | 60 const AtomicString& controlId = getAttribute(forAttr); |
| 61 if (controlId.isNull()) { | 61 if (controlId.isNull()) { |
| 62 // Search the children and descendants of the label element for a form e
lement. | 62 // Search the children and descendants of the label element for a form e
lement. |
| 63 // per http://dev.w3.org/html5/spec/Overview.html#the-label-element | 63 // per http://dev.w3.org/html5/spec/Overview.html#the-label-element |
| 64 // the form element must be "labelable form-associated element". | 64 // the form element must be "labelable form-associated element". |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 if (node->isHTMLElement() && toHTMLElement(node)->isInteractiveContent()
) | 142 if (node->isHTMLElement() && toHTMLElement(node)->isInteractiveContent()
) |
| 143 return true; | 143 return true; |
| 144 node = node->parentOrShadowHostNode(); | 144 node = node->parentOrShadowHostNode(); |
| 145 } | 145 } |
| 146 return false; | 146 return false; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void HTMLLabelElement::defaultEventHandler(Event* evt) | 149 void HTMLLabelElement::defaultEventHandler(Event* evt) |
| 150 { | 150 { |
| 151 if (evt->type() == EventTypeNames::click && !m_processingClick) { | 151 if (evt->type() == EventTypeNames::click && !m_processingClick) { |
| 152 RefPtrWillBeRawPtr<HTMLElement> element = control(); | 152 RawPtr<HTMLElement> element = control(); |
| 153 | 153 |
| 154 // If we can't find a control or if the control received the click | 154 // If we can't find a control or if the control received the click |
| 155 // event, then there's no need for us to do anything. | 155 // event, then there's no need for us to do anything. |
| 156 if (!element || (evt->target() && element->containsIncludingShadowDOM(ev
t->target()->toNode()))) | 156 if (!element || (evt->target() && element->containsIncludingShadowDOM(ev
t->target()->toNode()))) |
| 157 return; | 157 return; |
| 158 | 158 |
| 159 if (evt->target() && isInInteractiveContent(evt->target()->toNode())) | 159 if (evt->target() && isInInteractiveContent(evt->target()->toNode())) |
| 160 return; | 160 return; |
| 161 | 161 |
| 162 // Behaviour of label element is as follows: | 162 // Behaviour of label element is as follows: |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 if (attributeName == forAttr) { | 301 if (attributeName == forAttr) { |
| 302 TreeScope& scope = treeScope(); | 302 TreeScope& scope = treeScope(); |
| 303 if (scope.shouldCacheLabelsByForAttribute()) | 303 if (scope.shouldCacheLabelsByForAttribute()) |
| 304 updateLabel(scope, oldValue, attributeValue); | 304 updateLabel(scope, oldValue, attributeValue); |
| 305 } | 305 } |
| 306 HTMLElement::parseAttribute(attributeName, oldValue, attributeValue); | 306 HTMLElement::parseAttribute(attributeName, oldValue, attributeValue); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 | 309 |
| 310 } // namespace blink | 310 } // namespace blink |
| OLD | NEW |