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, 2010 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 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 ASSERT(hasTagName(legendTag)); | 42 ASSERT(hasTagName(legendTag)); |
43 ScriptWrappable::init(this); | 43 ScriptWrappable::init(this); |
44 } | 44 } |
45 | 45 |
46 PassRefPtr<HTMLLegendElement> HTMLLegendElement::create(const QualifiedName& tag
Name, Document* document) | 46 PassRefPtr<HTMLLegendElement> HTMLLegendElement::create(const QualifiedName& tag
Name, Document* document) |
47 { | 47 { |
48 return adoptRef(new HTMLLegendElement(tagName, document)); | 48 return adoptRef(new HTMLLegendElement(tagName, document)); |
49 } | 49 } |
50 | 50 |
51 HTMLFormControlElement* HTMLLegendElement::associatedControl() | 51 Result<HTMLFormControlElement> HTMLLegendElement::associatedControl() |
52 { | 52 { |
53 // Check if there's a fieldset belonging to this legend. | 53 // Check if there's a fieldset belonging to this legend. |
54 Element* fieldset = parentElement(); | 54 Element* fieldset = parentElement(); |
55 while (fieldset && !fieldset->hasTagName(fieldsetTag)) | 55 while (fieldset && !fieldset->hasTagName(fieldsetTag)) |
56 fieldset = fieldset->parentElement(); | 56 fieldset = fieldset->parentElement(); |
57 if (!fieldset) | 57 if (!fieldset) |
58 return 0; | 58 return nullptr; |
59 | 59 |
60 // Find first form element inside the fieldset that is not a legend element. | 60 // Find first form element inside the fieldset that is not a legend element. |
61 // FIXME: Should we consider tabindex? | 61 // FIXME: Should we consider tabindex? |
62 Element* element = fieldset; | 62 Element* element = fieldset; |
63 while ((element = ElementTraversal::next(element, fieldset))) { | 63 while ((element = ElementTraversal::next(element, fieldset))) { |
64 if (element->isFormControlElement()) | 64 if (element->isFormControlElement()) |
65 return static_cast<HTMLFormControlElement*>(element); | 65 return Handle<HTMLFormControlElement>(static_cast<HTMLFormControlEle
ment*>(element)); |
66 } | 66 } |
67 | 67 |
68 return 0; | 68 return nullptr; |
69 } | 69 } |
70 | 70 |
71 void HTMLLegendElement::focus(bool, FocusDirection direction) | 71 void HTMLLegendElement::focus(bool, FocusDirection direction) |
72 { | 72 { |
73 if (isFocusable()) | 73 if (isFocusable()) |
74 Element::focus(true, direction); | 74 Element::focus(true, direction); |
75 | 75 |
76 // To match other browsers' behavior, never restore previous selection. | 76 // To match other browsers' behavior, never restore previous selection. |
77 if (HTMLFormControlElement* control = associatedControl()) | 77 if (Handle<HTMLFormControlElement> control = associatedControl()) |
78 control->focus(false, direction); | 78 control->focus(false, direction); |
79 } | 79 } |
80 | 80 |
81 void HTMLLegendElement::accessKeyAction(bool sendMouseEvents) | 81 void HTMLLegendElement::accessKeyAction(bool sendMouseEvents) |
82 { | 82 { |
83 if (HTMLFormControlElement* control = associatedControl()) | 83 if (Handle<HTMLFormControlElement> control = associatedControl()) |
84 control->accessKeyAction(sendMouseEvents); | 84 control->accessKeyAction(sendMouseEvents); |
85 } | 85 } |
86 | 86 |
87 HTMLFormElement* HTMLLegendElement::virtualForm() const | 87 HTMLFormElement* HTMLLegendElement::virtualForm() const |
88 { | 88 { |
89 // According to the specification, If the legend has a fieldset element as | 89 // According to the specification, If the legend has a fieldset element as |
90 // its parent, then the form attribute must return the same value as the | 90 // its parent, then the form attribute must return the same value as the |
91 // form attribute on that fieldset element. Otherwise, it must return null. | 91 // form attribute on that fieldset element. Otherwise, it must return null. |
92 ContainerNode* fieldset = parentNode(); | 92 ContainerNode* fieldset = parentNode(); |
93 if (!fieldset || !fieldset->hasTagName(fieldsetTag)) | 93 if (!fieldset || !fieldset->hasTagName(fieldsetTag)) |
94 return 0; | 94 return 0; |
95 | 95 |
96 return static_cast<HTMLFieldSetElement*>(fieldset)->form(); | 96 return static_cast<HTMLFieldSetElement*>(fieldset)->form(); |
97 } | 97 } |
98 | 98 |
99 } // namespace | 99 } // namespace |
OLD | NEW |