| 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, 2008, 2010 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv
ed. |
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 { | 68 { |
| 69 HTMLElement::parseAttribute(name, value); | 69 HTMLElement::parseAttribute(name, value); |
| 70 recalcSelectOptions(); | 70 recalcSelectOptions(); |
| 71 | 71 |
| 72 if (name == disabledAttr) | 72 if (name == disabledAttr) |
| 73 didAffectSelector(AffectedSelectorDisabled | AffectedSelectorEnabled); | 73 didAffectSelector(AffectedSelectorDisabled | AffectedSelectorEnabled); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void HTMLOptGroupElement::recalcSelectOptions() | 76 void HTMLOptGroupElement::recalcSelectOptions() |
| 77 { | 77 { |
| 78 ContainerNode* select = parentNode(); | 78 if (HTMLSelectElement* select = Traversal<HTMLSelectElement>::firstAncestor(
*this)) |
| 79 while (select && !isHTMLSelectElement(*select)) | 79 select->setRecalcListItems(); |
| 80 select = select->parentNode(); | |
| 81 if (select) | |
| 82 toHTMLSelectElement(select)->setRecalcListItems(); | |
| 83 } | 80 } |
| 84 | 81 |
| 85 void HTMLOptGroupElement::attach(const AttachContext& context) | 82 void HTMLOptGroupElement::attach(const AttachContext& context) |
| 86 { | 83 { |
| 87 if (context.resolvedStyle) { | 84 if (context.resolvedStyle) { |
| 88 ASSERT(!m_style || m_style == context.resolvedStyle); | 85 ASSERT(!m_style || m_style == context.resolvedStyle); |
| 89 m_style = context.resolvedStyle; | 86 m_style = context.resolvedStyle; |
| 90 } | 87 } |
| 91 HTMLElement::attach(context); | 88 HTMLElement::attach(context); |
| 92 } | 89 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 120 // In WinIE, leading and trailing whitespace is ignored in options and optgr
oups. We match this behavior. | 117 // In WinIE, leading and trailing whitespace is ignored in options and optgr
oups. We match this behavior. |
| 121 itemText = itemText.stripWhiteSpace(); | 118 itemText = itemText.stripWhiteSpace(); |
| 122 // We want to collapse our whitespace too. This will match other browsers. | 119 // We want to collapse our whitespace too. This will match other browsers. |
| 123 itemText = itemText.simplifyWhiteSpace(); | 120 itemText = itemText.simplifyWhiteSpace(); |
| 124 | 121 |
| 125 return itemText; | 122 return itemText; |
| 126 } | 123 } |
| 127 | 124 |
| 128 HTMLSelectElement* HTMLOptGroupElement::ownerSelectElement() const | 125 HTMLSelectElement* HTMLOptGroupElement::ownerSelectElement() const |
| 129 { | 126 { |
| 130 ContainerNode* select = parentNode(); | 127 return Traversal<HTMLSelectElement>::firstAncestor(*this); |
| 131 while (select && !isHTMLSelectElement(*select)) | |
| 132 select = select->parentNode(); | |
| 133 | |
| 134 if (!select) | |
| 135 return 0; | |
| 136 | |
| 137 return toHTMLSelectElement(select); | |
| 138 } | 128 } |
| 139 | 129 |
| 140 void HTMLOptGroupElement::accessKeyAction(bool) | 130 void HTMLOptGroupElement::accessKeyAction(bool) |
| 141 { | 131 { |
| 142 HTMLSelectElement* select = ownerSelectElement(); | 132 HTMLSelectElement* select = ownerSelectElement(); |
| 143 // send to the parent to bring focus to the list box | 133 // send to the parent to bring focus to the list box |
| 144 if (select && !select->focused()) | 134 if (select && !select->focused()) |
| 145 select->accessKeyAction(false); | 135 select->accessKeyAction(false); |
| 146 } | 136 } |
| 147 | 137 |
| 148 } // namespace | 138 } // namespace |
| OLD | NEW |