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 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 5 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
6 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. |
7 * Copyright (C) 2010 Google Inc. All rights reserved. | 7 * Copyright (C) 2010 Google Inc. All rights reserved. |
8 * Copyright (C) 2011 Motorola Mobility, Inc. All rights reserved. | 8 * Copyright (C) 2011 Motorola Mobility, Inc. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 { | 125 { |
126 RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this); | 126 RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this); |
127 | 127 |
128 // Changing the text causes a recalc of a select's items, which will reset t he selected | 128 // Changing the text causes a recalc of a select's items, which will reset t he selected |
129 // index to the first item if the select is single selection with a menu lis t. We attempt to | 129 // index to the first item if the select is single selection with a menu lis t. We attempt to |
130 // preserve the selected item. | 130 // preserve the selected item. |
131 RefPtrWillBeRawPtr<HTMLSelectElement> select = ownerSelectElement(); | 131 RefPtrWillBeRawPtr<HTMLSelectElement> select = ownerSelectElement(); |
132 bool selectIsMenuList = select && select->usesMenuList(); | 132 bool selectIsMenuList = select && select->usesMenuList(); |
133 int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1; | 133 int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1; |
134 | 134 |
135 // Handle the common special case where there's exactly 1 child node, and it 's a text node. | 135 // Handle the common special case where there's exactly 1 child node, and it 's a text node. |
adamk
2014/11/04 00:56:56
This comment is now very redundant with the code,
| |
136 Node* child = firstChild(); | 136 if (hasOneTextChild()) |
137 if (child && child->isTextNode() && !child->nextSibling()) | 137 toText(firstChild())->setData(text); |
138 toText(child)->setData(text); | |
139 else { | 138 else { |
140 removeChildren(); | 139 removeChildren(); |
141 appendChild(Text::create(document(), text), exceptionState); | 140 appendChild(Text::create(document(), text), exceptionState); |
142 } | 141 } |
143 | 142 |
144 if (selectIsMenuList && select->selectedIndex() != oldSelectedIndex) | 143 if (selectIsMenuList && select->selectedIndex() != oldSelectedIndex) |
145 select->setSelectedIndex(oldSelectedIndex); | 144 select->setSelectedIndex(oldSelectedIndex); |
146 } | 145 } |
147 | 146 |
148 void HTMLOptionElement::accessKeyAction(bool) | 147 void HTMLOptionElement::accessKeyAction(bool) |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 ASSERT(parent); | 410 ASSERT(parent); |
412 if (isHTMLOptGroupElement(*parent)) { | 411 if (isHTMLOptGroupElement(*parent)) { |
413 RenderStyle* parentStyle = parent->renderStyle() ? parent->renderSty le() : parent->computedStyle(); | 412 RenderStyle* parentStyle = parent->renderStyle() ? parent->renderSty le() : parent->computedStyle(); |
414 return !parentStyle || parentStyle->display() == NONE; | 413 return !parentStyle || parentStyle->display() == NONE; |
415 } | 414 } |
416 } | 415 } |
417 return m_style->display() == NONE; | 416 return m_style->display() == NONE; |
418 } | 417 } |
419 | 418 |
420 } // namespace blink | 419 } // namespace blink |
OLD | NEW |