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

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, 10 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 String HTMLOptionElement::displayLabel() const 118 String HTMLOptionElement::displayLabel() const
119 { 119 {
120 Document& document = this->document(); 120 Document& document = this->document();
121 String text; 121 String text;
122 122
(...skipping 10 matching lines...) Expand all
133 return text.stripWhiteSpace(isHTMLSpace<UChar>).simplifyWhiteSpace(isHTMLSpa ce<UChar>); 133 return text.stripWhiteSpace(isHTMLSpace<UChar>).simplifyWhiteSpace(isHTMLSpa ce<UChar>);
134 } 134 }
135 135
136 String HTMLOptionElement::text() const 136 String HTMLOptionElement::text() const
137 { 137 {
138 return collectOptionInnerText().stripWhiteSpace(isHTMLSpace<UChar>).simplify WhiteSpace(isHTMLSpace<UChar>); 138 return collectOptionInnerText().stripWhiteSpace(isHTMLSpace<UChar>).simplify WhiteSpace(isHTMLSpace<UChar>);
139 } 139 }
140 140
141 void HTMLOptionElement::setText(const String &text, ExceptionState& exceptionSta te) 141 void HTMLOptionElement::setText(const String &text, ExceptionState& exceptionSta te)
142 { 142 {
143 RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this); 143 RawPtr<Node> protectFromMutationEvents(this);
144 144
145 // Changing the text causes a recalc of a select's items, which will reset t he selected 145 // Changing the text causes a recalc of a select's items, which will reset t he selected
146 // index to the first item if the select is single selection with a menu lis t. We attempt to 146 // index to the first item if the select is single selection with a menu lis t. We attempt to
147 // preserve the selected item. 147 // preserve the selected item.
148 RefPtrWillBeRawPtr<HTMLSelectElement> select = ownerSelectElement(); 148 RawPtr<HTMLSelectElement> select = ownerSelectElement();
149 bool selectIsMenuList = select && select->usesMenuList(); 149 bool selectIsMenuList = select && select->usesMenuList();
150 int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1; 150 int oldSelectedIndex = selectIsMenuList ? select->selectedIndex() : -1;
151 151
152 if (hasOneTextChild()) { 152 if (hasOneTextChild()) {
153 toText(firstChild())->setData(text); 153 toText(firstChild())->setData(text);
154 } else { 154 } else {
155 removeChildren(); 155 removeChildren();
156 appendChild(Text::create(document(), text), exceptionState); 156 appendChild(Text::create(document(), text), exceptionState);
157 } 157 }
158 158
(...skipping 10 matching lines...) Expand all
169 int HTMLOptionElement::index() const 169 int HTMLOptionElement::index() const
170 { 170 {
171 // It would be faster to cache the index, but harder to get it right in all cases. 171 // It would be faster to cache the index, but harder to get it right in all cases.
172 172
173 HTMLSelectElement* selectElement = ownerSelectElement(); 173 HTMLSelectElement* selectElement = ownerSelectElement();
174 if (!selectElement) 174 if (!selectElement)
175 return 0; 175 return 0;
176 176
177 int optionIndex = 0; 177 int optionIndex = 0;
178 178
179 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = selectEleme nt->listItems(); 179 const HeapVector<Member<HTMLElement>>& items = selectElement->listItems();
180 size_t length = items.size(); 180 size_t length = items.size();
181 for (size_t i = 0; i < length; ++i) { 181 for (size_t i = 0; i < length; ++i) {
182 if (!isHTMLOptionElement(*items[i])) 182 if (!isHTMLOptionElement(*items[i]))
183 continue; 183 continue;
184 if (items[i].get() == this) 184 if (items[i].get() == this)
185 return optionIndex; 185 return optionIndex;
186 ++optionIndex; 186 ++optionIndex;
187 } 187 }
188 188
189 return 0; 189 return 0;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 ASSERT(parent); 468 ASSERT(parent);
469 if (isHTMLOptGroupElement(*parent)) { 469 if (isHTMLOptGroupElement(*parent)) {
470 const ComputedStyle* parentStyle = parent->computedStyle() ? parent- >computedStyle() : parent->ensureComputedStyle(); 470 const ComputedStyle* parentStyle = parent->computedStyle() ? parent- >computedStyle() : parent->ensureComputedStyle();
471 return !parentStyle || parentStyle->display() == NONE; 471 return !parentStyle || parentStyle->display() == NONE;
472 } 472 }
473 } 473 }
474 return m_style->display() == NONE; 474 return m_style->display() == NONE;
475 } 475 }
476 476
477 } // namespace blink 477 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698