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

Side by Side Diff: Source/WebCore/html/HTMLSelectElement.cpp

Issue 10414055: Merge 116864 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1084/
Patch Set: Created 8 years, 7 months 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 | « LayoutTests/fast/dom/HTMLSelectElement/option-add-crash-expected.txt ('k') | 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) 2010 Nokia Corporation and/or its subsidiary(-ies). 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * (C) 1999 Antti Koivisto (koivisto@kde.org)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
10 * 10 *
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 { 403 {
404 return options()->item(index); 404 return options()->item(index);
405 } 405 }
406 406
407 void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, Exc eptionCode& ec) 407 void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, Exc eptionCode& ec)
408 { 408 {
409 ec = 0; 409 ec = 0;
410 if (index > maxSelectItems - 1) 410 if (index > maxSelectItems - 1)
411 index = maxSelectItems - 1; 411 index = maxSelectItems - 1;
412 int diff = index - length(); 412 int diff = index - length();
413 HTMLElement* before = 0; 413 RefPtr<HTMLElement> before = 0;
414 // Out of array bounds? First insert empty dummies. 414 // Out of array bounds? First insert empty dummies.
415 if (diff > 0) { 415 if (diff > 0) {
416 setLength(index, ec); 416 setLength(index, ec);
417 // Replace an existing entry? 417 // Replace an existing entry?
418 } else if (diff < 0) { 418 } else if (diff < 0) {
419 before = toHTMLElement(options()->item(index+1)); 419 before = toHTMLElement(options()->item(index+1));
420 remove(index); 420 remove(index);
421 } 421 }
422 // Finally add the new element. 422 // Finally add the new element.
423 if (!ec) { 423 if (!ec) {
424 add(option, before, ec); 424 add(option, before.get(), ec);
425 if (diff >= 0 && option->selected()) 425 if (diff >= 0 && option->selected())
426 optionSelectionStateChanged(option, true); 426 optionSelectionStateChanged(option, true);
427 } 427 }
428 } 428 }
429 429
430 void HTMLSelectElement::setLength(unsigned newLen, ExceptionCode& ec) 430 void HTMLSelectElement::setLength(unsigned newLen, ExceptionCode& ec)
431 { 431 {
432 ec = 0; 432 ec = 0;
433 if (newLen > maxSelectItems) 433 if (newLen > maxSelectItems)
434 newLen = maxSelectItems; 434 newLen = maxSelectItems;
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 1531
1532 const HTMLSelectElement* toHTMLSelectElement(const Node* node) 1532 const HTMLSelectElement* toHTMLSelectElement(const Node* node)
1533 { 1533 {
1534 ASSERT(!node || node->hasTagName(selectTag)); 1534 ASSERT(!node || node->hasTagName(selectTag));
1535 return static_cast<const HTMLSelectElement*>(node); 1535 return static_cast<const HTMLSelectElement*>(node);
1536 } 1536 }
1537 1537
1538 #endif 1538 #endif
1539 1539
1540 } // namespace 1540 } // namespace
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/HTMLSelectElement/option-add-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698