Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: Source/core/html/HTMLOptionElement.cpp

Issue 692153002: Replace custom code by hasOneTextChild API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove obvious comment Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (hasOneTextChild())
haraken 2014/11/04 18:02:30 Nit: Add { } because the else clause has { }
136 Node* child = firstChild(); 136 toText(firstChild())->setData(text);
137 if (child && child->isTextNode() && !child->nextSibling())
138 toText(child)->setData(text);
139 else { 137 else {
140 removeChildren(); 138 removeChildren();
141 appendChild(Text::create(document(), text), exceptionState); 139 appendChild(Text::create(document(), text), exceptionState);
142 } 140 }
143 141
144 if (selectIsMenuList && select->selectedIndex() != oldSelectedIndex) 142 if (selectIsMenuList && select->selectedIndex() != oldSelectedIndex)
145 select->setSelectedIndex(oldSelectedIndex); 143 select->setSelectedIndex(oldSelectedIndex);
146 } 144 }
147 145
148 void HTMLOptionElement::accessKeyAction(bool) 146 void HTMLOptionElement::accessKeyAction(bool)
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 ASSERT(parent); 409 ASSERT(parent);
412 if (isHTMLOptGroupElement(*parent)) { 410 if (isHTMLOptGroupElement(*parent)) {
413 RenderStyle* parentStyle = parent->renderStyle() ? parent->renderSty le() : parent->computedStyle(); 411 RenderStyle* parentStyle = parent->renderStyle() ? parent->renderSty le() : parent->computedStyle();
414 return !parentStyle || parentStyle->display() == NONE; 412 return !parentStyle || parentStyle->display() == NONE;
415 } 413 }
416 } 414 }
417 return m_style->display() == NONE; 415 return m_style->display() == NONE;
418 } 416 }
419 417
420 } // namespace blink 418 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698