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

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

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLProgressElement.cpp ('k') | Source/core/html/HTMLTableElement.cpp » ('j') | 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return optionToListIndex(selectedIndex()); 200 return optionToListIndex(selectedIndex());
201 } 201 }
202 202
203 int HTMLSelectElement::activeSelectionEndListIndex() const 203 int HTMLSelectElement::activeSelectionEndListIndex() const
204 { 204 {
205 if (m_activeSelectionEndIndex >= 0) 205 if (m_activeSelectionEndIndex >= 0)
206 return m_activeSelectionEndIndex; 206 return m_activeSelectionEndIndex;
207 return lastSelectedListIndex(); 207 return lastSelectedListIndex();
208 } 208 }
209 209
210 void HTMLSelectElement::add(HTMLElement* element, HTMLElement* before, Exception State& es) 210 void HTMLSelectElement::add(HTMLElement* element, HTMLElement* before, Exception State& exceptionState)
211 { 211 {
212 // Make sure the element is ref'd and deref'd so we don't leak it. 212 // Make sure the element is ref'd and deref'd so we don't leak it.
213 RefPtr<HTMLElement> protectNewChild(element); 213 RefPtr<HTMLElement> protectNewChild(element);
214 214
215 if (!element || !(element->hasLocalName(optionTag) || element->hasLocalName( hrTag))) 215 if (!element || !(element->hasLocalName(optionTag) || element->hasLocalName( hrTag)))
216 return; 216 return;
217 217
218 insertBefore(element, before, es); 218 insertBefore(element, before, exceptionState);
219 setNeedsValidityCheck(); 219 setNeedsValidityCheck();
220 } 220 }
221 221
222 void HTMLSelectElement::remove(int optionIndex) 222 void HTMLSelectElement::remove(int optionIndex)
223 { 223 {
224 int listIndex = optionToListIndex(optionIndex); 224 int listIndex = optionToListIndex(optionIndex);
225 if (listIndex < 0) 225 if (listIndex < 0)
226 return; 226 return;
227 227
228 listItems()[listIndex]->remove(IGNORE_EXCEPTION); 228 listItems()[listIndex]->remove(IGNORE_EXCEPTION);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 Node* HTMLSelectElement::namedItem(const AtomicString& name) 406 Node* HTMLSelectElement::namedItem(const AtomicString& name)
407 { 407 {
408 return options()->namedItem(name); 408 return options()->namedItem(name);
409 } 409 }
410 410
411 Node* HTMLSelectElement::item(unsigned index) 411 Node* HTMLSelectElement::item(unsigned index)
412 { 412 {
413 return options()->item(index); 413 return options()->item(index);
414 } 414 }
415 415
416 void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, Exc eptionState& es) 416 void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, Exc eptionState& exceptionState)
417 { 417 {
418 if (index > maxSelectItems - 1) 418 if (index > maxSelectItems - 1)
419 index = maxSelectItems - 1; 419 index = maxSelectItems - 1;
420 int diff = index - length(); 420 int diff = index - length();
421 RefPtr<HTMLElement> before = 0; 421 RefPtr<HTMLElement> before = 0;
422 // Out of array bounds? First insert empty dummies. 422 // Out of array bounds? First insert empty dummies.
423 if (diff > 0) { 423 if (diff > 0) {
424 setLength(index, es); 424 setLength(index, exceptionState);
425 // Replace an existing entry? 425 // Replace an existing entry?
426 } else if (diff < 0) { 426 } else if (diff < 0) {
427 before = toHTMLElement(options()->item(index+1)); 427 before = toHTMLElement(options()->item(index+1));
428 remove(index); 428 remove(index);
429 } 429 }
430 // Finally add the new element. 430 // Finally add the new element.
431 if (!es.hadException()) { 431 if (!exceptionState.hadException()) {
432 add(option, before.get(), es); 432 add(option, before.get(), exceptionState);
433 if (diff >= 0 && option->selected()) 433 if (diff >= 0 && option->selected())
434 optionSelectionStateChanged(option, true); 434 optionSelectionStateChanged(option, true);
435 } 435 }
436 } 436 }
437 437
438 void HTMLSelectElement::setLength(unsigned newLen, ExceptionState& es) 438 void HTMLSelectElement::setLength(unsigned newLen, ExceptionState& exceptionStat e)
439 { 439 {
440 if (newLen > maxSelectItems) 440 if (newLen > maxSelectItems)
441 newLen = maxSelectItems; 441 newLen = maxSelectItems;
442 int diff = length() - newLen; 442 int diff = length() - newLen;
443 443
444 if (diff < 0) { // Add dummy elements. 444 if (diff < 0) { // Add dummy elements.
445 do { 445 do {
446 RefPtr<Element> option = document().createElement(optionTag, false); 446 RefPtr<Element> option = document().createElement(optionTag, false);
447 ASSERT(option); 447 ASSERT(option);
448 add(toHTMLElement(option), 0, es); 448 add(toHTMLElement(option), 0, exceptionState);
449 if (es.hadException()) 449 if (exceptionState.hadException())
450 break; 450 break;
451 } while (++diff); 451 } while (++diff);
452 } else { 452 } else {
453 const Vector<HTMLElement*>& items = listItems(); 453 const Vector<HTMLElement*>& items = listItems();
454 454
455 // Removing children fires mutation events, which might mutate the DOM f urther, so we first copy out a list 455 // Removing children fires mutation events, which might mutate the DOM f urther, so we first copy out a list
456 // of elements that we intend to remove then attempt to remove them one at a time. 456 // of elements that we intend to remove then attempt to remove them one at a time.
457 Vector<RefPtr<Element> > itemsToRemove; 457 Vector<RefPtr<Element> > itemsToRemove;
458 size_t optionIndex = 0; 458 size_t optionIndex = 0;
459 for (size_t i = 0; i < items.size(); ++i) { 459 for (size_t i = 0; i < items.size(); ++i) {
460 Element* item = items[i]; 460 Element* item = items[i];
461 if (item->hasLocalName(optionTag) && optionIndex++ >= newLen) { 461 if (item->hasLocalName(optionTag) && optionIndex++ >= newLen) {
462 ASSERT(item->parentNode()); 462 ASSERT(item->parentNode());
463 itemsToRemove.append(item); 463 itemsToRemove.append(item);
464 } 464 }
465 } 465 }
466 466
467 for (size_t i = 0; i < itemsToRemove.size(); ++i) { 467 for (size_t i = 0; i < itemsToRemove.size(); ++i) {
468 Element* item = itemsToRemove[i].get(); 468 Element* item = itemsToRemove[i].get();
469 if (item->parentNode()) 469 if (item->parentNode())
470 item->parentNode()->removeChild(item, es); 470 item->parentNode()->removeChild(item, exceptionState);
471 } 471 }
472 } 472 }
473 setNeedsValidityCheck(); 473 setNeedsValidityCheck();
474 } 474 }
475 475
476 bool HTMLSelectElement::isRequiredFormControl() const 476 bool HTMLSelectElement::isRequiredFormControl() const
477 { 477 {
478 return isRequired(); 478 return isRequired();
479 } 479 }
480 480
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 return options; 1556 return options;
1557 } 1557 }
1558 1558
1559 void HTMLSelectElement::finishParsingChildren() 1559 void HTMLSelectElement::finishParsingChildren()
1560 { 1560 {
1561 HTMLFormControlElementWithState::finishParsingChildren(); 1561 HTMLFormControlElementWithState::finishParsingChildren();
1562 m_isParsingInProgress = false; 1562 m_isParsingInProgress = false;
1563 updateListItemSelectedStates(); 1563 updateListItemSelectedStates();
1564 } 1564 }
1565 1565
1566 bool HTMLSelectElement::anonymousIndexedSetter(unsigned index, PassRefPtr<HTMLOp tionElement> value, ExceptionState& es) 1566 bool HTMLSelectElement::anonymousIndexedSetter(unsigned index, PassRefPtr<HTMLOp tionElement> value, ExceptionState& exceptionState)
1567 { 1567 {
1568 if (!value) { 1568 if (!value) {
1569 es.throwUninformativeAndGenericDOMException(TypeMismatchError); 1569 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
1570 return false; 1570 return false;
1571 } 1571 }
1572 setOption(index, value.get(), es); 1572 setOption(index, value.get(), exceptionState);
1573 return true; 1573 return true;
1574 } 1574 }
1575 1575
1576 bool HTMLSelectElement::anonymousIndexedSetterRemove(unsigned index, ExceptionSt ate& es) 1576 bool HTMLSelectElement::anonymousIndexedSetterRemove(unsigned index, ExceptionSt ate& exceptionState)
1577 { 1577 {
1578 remove(index); 1578 remove(index);
1579 return true; 1579 return true;
1580 } 1580 }
1581 1581
1582 bool HTMLSelectElement::isInteractiveContent() const 1582 bool HTMLSelectElement::isInteractiveContent() const
1583 { 1583 {
1584 return true; 1584 return true;
1585 } 1585 }
1586 1586
1587 } // namespace 1587 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLProgressElement.cpp ('k') | Source/core/html/HTMLTableElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698