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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 // An explicit empty destructor should be in HTMLOptionElement.cpp, because 57 // An explicit empty destructor should be in HTMLOptionElement.cpp, because
58 // if an implicit destructor is used or an empty destructor is defined in 58 // if an implicit destructor is used or an empty destructor is defined in
59 // HTMLOptionElement.h, when including HTMLOptionElement.h, 59 // HTMLOptionElement.h, when including HTMLOptionElement.h,
60 // msvc tries to expand the destructor and causes 60 // msvc tries to expand the destructor and causes
61 // a compile error because of lack of ComputedStyle definition. 61 // a compile error because of lack of ComputedStyle definition.
62 HTMLOptionElement::~HTMLOptionElement() 62 HTMLOptionElement::~HTMLOptionElement()
63 { 63 {
64 } 64 }
65 65
66 PassRefPtrWillBeRawPtr<HTMLOptionElement> HTMLOptionElement::create(Document& do cument) 66 RawPtr<HTMLOptionElement> HTMLOptionElement::create(Document& document)
67 { 67 {
68 RefPtrWillBeRawPtr<HTMLOptionElement> option = adoptRefWillBeNoop(new HTMLOp tionElement(document)); 68 RawPtr<HTMLOptionElement> option = new HTMLOptionElement(document);
69 option->ensureUserAgentShadowRoot(); 69 option->ensureUserAgentShadowRoot();
70 return option.release(); 70 return option.release();
71 } 71 }
72 72
73 PassRefPtrWillBeRawPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstruc tor(Document& document, const String& data, const AtomicString& value, 73 RawPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document& do cument, const String& data, const AtomicString& value,
74 bool defaultSelected, bool selected, ExceptionState& exceptionState) 74 bool defaultSelected, bool selected, ExceptionState& exceptionState)
75 { 75 {
76 RefPtrWillBeRawPtr<HTMLOptionElement> element = adoptRefWillBeNoop(new HTMLO ptionElement(document)); 76 RawPtr<HTMLOptionElement> element = new HTMLOptionElement(document);
77 element->ensureUserAgentShadowRoot(); 77 element->ensureUserAgentShadowRoot();
78 element->appendChild(Text::create(document, data.isNull() ? "" : data), exce ptionState); 78 element->appendChild(Text::create(document, data.isNull() ? "" : data), exce ptionState);
79 if (exceptionState.hadException()) 79 if (exceptionState.hadException())
80 return nullptr; 80 return nullptr;
81 81
82 if (!value.isNull()) 82 if (!value.isNull())
83 element->setValue(value); 83 element->setValue(value);
84 if (defaultSelected) 84 if (defaultSelected)
85 element->setAttribute(selectedAttr, emptyAtom); 85 element->setAttribute(selectedAttr, emptyAtom);
86 element->setSelected(selected); 86 element->setSelected(selected);
(...skipping 15 matching lines...) Expand all
102 } 102 }
103 103
104 void HTMLOptionElement::detach(const AttachContext& context) 104 void HTMLOptionElement::detach(const AttachContext& context)
105 { 105 {
106 m_style.clear(); 106 m_style.clear();
107 HTMLElement::detach(context); 107 HTMLElement::detach(context);
108 } 108 }
109 109
110 bool HTMLOptionElement::supportsFocus() const 110 bool HTMLOptionElement::supportsFocus() const
111 { 111 {
112 RefPtrWillBeRawPtr<HTMLSelectElement> select = ownerSelectElement(); 112 RawPtr<HTMLSelectElement> select = ownerSelectElement();
113 if (select && select->usesMenuList()) 113 if (select && select->usesMenuList())
114 return false; 114 return false;
115 return HTMLElement::supportsFocus(); 115 return HTMLElement::supportsFocus();
116 } 116 }
117 117
118 bool HTMLOptionElement::matchesDefaultPseudoClass() const 118 bool HTMLOptionElement::matchesDefaultPseudoClass() const
119 { 119 {
120 return fastHasAttribute(selectedAttr); 120 return fastHasAttribute(selectedAttr);
121 } 121 }
122 122
(...skipping 15 matching lines...) Expand all
138 return text.stripWhiteSpace(isHTMLSpace<UChar>).simplifyWhiteSpace(isHTMLSpa ce<UChar>); 138 return text.stripWhiteSpace(isHTMLSpace<UChar>).simplifyWhiteSpace(isHTMLSpa ce<UChar>);
139 } 139 }
140 140
141 String HTMLOptionElement::text() const 141 String HTMLOptionElement::text() const
142 { 142 {
143 return collectOptionInnerText().stripWhiteSpace(isHTMLSpace<UChar>).simplify WhiteSpace(isHTMLSpace<UChar>); 143 return collectOptionInnerText().stripWhiteSpace(isHTMLSpace<UChar>).simplify WhiteSpace(isHTMLSpace<UChar>);
144 } 144 }
145 145
146 void HTMLOptionElement::setText(const String &text, ExceptionState& exceptionSta te) 146 void HTMLOptionElement::setText(const String &text, ExceptionState& exceptionSta te)
147 { 147 {
148 RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this); 148 RawPtr<Node> protectFromMutationEvents(this);
149 149
150 // Changing the text causes a recalc of a select's items, which will reset t he selected 150 // Changing the text causes a recalc of a select's items, which will reset t he selected
151 // index to the first item if the select is single selection with a menu lis t. We attempt to 151 // index to the first item if the select is single selection with a menu lis t. We attempt to
152 // preserve the selected item. 152 // preserve the selected item.
153 RefPtrWillBeRawPtr<HTMLSelectElement> select = ownerSelectElement(); 153 RawPtr<HTMLSelectElement> select = ownerSelectElement();
154 bool selectIsMenuList = select && select->usesMenuList(); 154 bool selectIsMenuList = select && select->usesMenuList();
155 int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1; 155 int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1;
156 156
157 if (hasOneTextChild()) { 157 if (hasOneTextChild()) {
158 toText(firstChild())->setData(text); 158 toText(firstChild())->setData(text);
159 } else { 159 } else {
160 removeChildren(); 160 removeChildren();
161 appendChild(Text::create(document(), text), exceptionState); 161 appendChild(Text::create(document(), text), exceptionState);
162 } 162 }
163 163
(...skipping 10 matching lines...) Expand all
174 int HTMLOptionElement::index() const 174 int HTMLOptionElement::index() const
175 { 175 {
176 // It would be faster to cache the index, but harder to get it right in all cases. 176 // It would be faster to cache the index, but harder to get it right in all cases.
177 177
178 HTMLSelectElement* selectElement = ownerSelectElement(); 178 HTMLSelectElement* selectElement = ownerSelectElement();
179 if (!selectElement) 179 if (!selectElement)
180 return 0; 180 return 0;
181 181
182 int optionIndex = 0; 182 int optionIndex = 0;
183 183
184 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = selectEleme nt->listItems(); 184 const HeapVector<Member<HTMLElement>>& items = selectElement->listItems();
185 size_t length = items.size(); 185 size_t length = items.size();
186 for (size_t i = 0; i < length; ++i) { 186 for (size_t i = 0; i < length; ++i) {
187 if (!isHTMLOptionElement(*items[i])) 187 if (!isHTMLOptionElement(*items[i]))
188 continue; 188 continue;
189 if (items[i].get() == this) 189 if (items[i].get() == this)
190 return optionIndex; 190 return optionIndex;
191 ++optionIndex; 191 ++optionIndex;
192 } 192 }
193 193
194 return 0; 194 return 0;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 ASSERT(parent); 469 ASSERT(parent);
470 if (isHTMLOptGroupElement(*parent)) { 470 if (isHTMLOptGroupElement(*parent)) {
471 const ComputedStyle* parentStyle = parent->computedStyle() ? parent- >computedStyle() : parent->ensureComputedStyle(); 471 const ComputedStyle* parentStyle = parent->computedStyle() ? parent- >computedStyle() : parent->ensureComputedStyle();
472 return !parentStyle || parentStyle->display() == NONE; 472 return !parentStyle || parentStyle->display() == NONE;
473 } 473 }
474 } 474 }
475 return m_style->display() == NONE; 475 return m_style->display() == NONE;
476 } 476 }
477 477
478 } // namespace blink 478 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLOptionElement.h ('k') | third_party/WebKit/Source/core/html/HTMLOptionsCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698