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

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

Issue 716773002: Use union types for HTMLSelectElement.add()'s arguments (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: added FIXME 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 | « Source/core/html/HTMLOptionsCollection.h ('k') | Source/core/html/HTMLOptionsCollection.idl » ('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) 2006, 2011, 2012 Apple Computer, Inc. 2 * Copyright (C) 2006, 2011, 2012 Apple Computer, Inc.
3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 names.append(nameAttribute); 62 names.append(nameAttribute);
63 } 63 }
64 } 64 }
65 } 65 }
66 66
67 PassRefPtrWillBeRawPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(Cont ainerNode& select, CollectionType) 67 PassRefPtrWillBeRawPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(Cont ainerNode& select, CollectionType)
68 { 68 {
69 return adoptRefWillBeNoop(new HTMLOptionsCollection(select)); 69 return adoptRefWillBeNoop(new HTMLOptionsCollection(select));
70 } 70 }
71 71
72 void HTMLOptionsCollection::add(PassRefPtrWillBeRawPtr<HTMLOptionElement> elemen t, ExceptionState& exceptionState) 72 void HTMLOptionsCollection::add(const HTMLOptionElementOrHTMLOptGroupElement& el ement, const HTMLElementOrLong& before, ExceptionState& exceptionState)
73 { 73 {
74 add(element, length(), exceptionState); 74 toHTMLSelectElement(ownerNode()).add(element, before, exceptionState);
75 }
76
77 void HTMLOptionsCollection::add(PassRefPtrWillBeRawPtr<HTMLOptionElement> elemen t, int index, ExceptionState& exceptionState)
78 {
79 HTMLOptionElement* newOption = element.get();
80
81 if (!newOption) {
82 exceptionState.throwTypeError("The element provided was not an HTMLOptio nElement.");
83 return;
84 }
85
86 if (index < -1) {
87 exceptionState.throwDOMException(IndexSizeError, "The index provided (" + String::number(index) + ") is less than -1.");
88 return;
89 }
90
91 HTMLSelectElement& select = toHTMLSelectElement(ownerNode());
92
93 if (index == -1 || unsigned(index) >= length())
94 select.add(newOption, 0, exceptionState);
95 else
96 select.addBeforeOptionAtIndex(newOption, index, exceptionState);
97
98 ASSERT(!exceptionState.hadException());
99 } 75 }
100 76
101 void HTMLOptionsCollection::remove(int index) 77 void HTMLOptionsCollection::remove(int index)
102 { 78 {
103 toHTMLSelectElement(ownerNode()).remove(index); 79 toHTMLSelectElement(ownerNode()).remove(index);
104 } 80 }
105 81
106 int HTMLOptionsCollection::selectedIndex() const 82 int HTMLOptionsCollection::selectedIndex() const
107 { 83 {
108 return toHTMLSelectElement(ownerNode()).selectedIndex(); 84 return toHTMLSelectElement(ownerNode()).selectedIndex();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (!value) { // undefined or null 117 if (!value) { // undefined or null
142 base.remove(index); 118 base.remove(index);
143 return true; 119 return true;
144 } 120 }
145 base.setOption(index, value.get(), exceptionState); 121 base.setOption(index, value.get(), exceptionState);
146 return true; 122 return true;
147 } 123 }
148 124
149 } //namespace 125 } //namespace
150 126
OLDNEW
« no previous file with comments | « Source/core/html/HTMLOptionsCollection.h ('k') | Source/core/html/HTMLOptionsCollection.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698