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

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

Issue 19510005: [oilpan] Completely move HTMLFormControlElement's hierarchy to the managed heap Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
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 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 setAttribute(formmethodAttr, value); 96 setAttribute(formmethodAttr, value);
97 } 97 }
98 98
99 bool HTMLFormControlElement::formNoValidate() const 99 bool HTMLFormControlElement::formNoValidate() const
100 { 100 {
101 return fastHasAttribute(formnovalidateAttr); 101 return fastHasAttribute(formnovalidateAttr);
102 } 102 }
103 103
104 void HTMLFormControlElement::updateAncestorDisabledState() const 104 void HTMLFormControlElement::updateAncestorDisabledState() const
105 { 105 {
106 HTMLFieldSetElement* fieldSetAncestor = 0; 106 Handle<HTMLFieldSetElement> fieldSetAncestor;
107 ContainerNode* legendAncestor = 0; 107 ContainerNode* legendAncestor = 0;
108 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor-> parentNode()) { 108 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor-> parentNode()) {
109 if (!legendAncestor && ancestor->hasTagName(legendTag)) 109 if (!legendAncestor && ancestor->hasTagName(legendTag))
110 legendAncestor = ancestor; 110 legendAncestor = ancestor;
111 if (ancestor->hasTagName(fieldsetTag)) { 111 if (ancestor->hasTagName(fieldsetTag)) {
112 fieldSetAncestor = static_cast<HTMLFieldSetElement*>(ancestor); 112 fieldSetAncestor = Handle<HTMLFieldSetElement>(static_cast<HTMLField SetElement*>(ancestor));
113 break; 113 break;
114 } 114 }
115 } 115 }
116 m_ancestorDisabledState = (fieldSetAncestor && fieldSetAncestor->isDisabledF ormControl() && !(legendAncestor && legendAncestor == fieldSetAncestor->legend() )) ? AncestorDisabledStateDisabled : AncestorDisabledStateEnabled; 116 m_ancestorDisabledState = (fieldSetAncestor && fieldSetAncestor->isDisabledF ormControl() && !(legendAncestor && legendAncestor == fieldSetAncestor->legend() )) ? AncestorDisabledStateDisabled : AncestorDisabledStateEnabled;
117 } 117 }
118 118
119 void HTMLFormControlElement::ancestorDisabledStateWasChanged() 119 void HTMLFormControlElement::ancestorDisabledStateWasChanged()
120 { 120 {
121 m_ancestorDisabledState = AncestorDisabledStateUnknown; 121 m_ancestorDisabledState = AncestorDisabledStateUnknown;
122 disabledAttributeChanged(); 122 disabledAttributeChanged();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 164
165 void HTMLFormControlElement::requiredAttributeChanged() 165 void HTMLFormControlElement::requiredAttributeChanged()
166 { 166 {
167 setNeedsValidityCheck(); 167 setNeedsValidityCheck();
168 // Style recalculation is needed because style selectors may include 168 // Style recalculation is needed because style selectors may include
169 // :required and :optional pseudo-classes. 169 // :required and :optional pseudo-classes.
170 setNeedsStyleRecalc(); 170 setNeedsStyleRecalc();
171 } 171 }
172 172
173 static bool shouldAutofocus(HTMLFormControlElement* element) 173 static bool shouldAutofocus(Handle<HTMLFormControlElement> element)
174 { 174 {
175 if (!element->fastHasAttribute(autofocusAttr)) 175 if (!element->fastHasAttribute(autofocusAttr))
176 return false; 176 return false;
177 if (!element->renderer()) 177 if (!element->renderer())
178 return false; 178 return false;
179 if (element->document()->ignoreAutofocus()) 179 if (element->document()->ignoreAutofocus())
180 return false; 180 return false;
181 if (element->document()->isSandboxed(SandboxAutomaticFeatures)) { 181 if (element->document()->isSandboxed(SandboxAutomaticFeatures)) {
182 // FIXME: This message should be moved off the console once a solution t o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. 182 // FIXME: This message should be moved off the console once a solution t o https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
183 element->document()->addConsoleMessage(SecurityMessageSource, ErrorMessa geLevel, "Blocked autofocusing on a form control because the form's frame is san dboxed and the 'allow-scripts' permission is not set."); 183 element->document()->addConsoleMessage(SecurityMessageSource, ErrorMessa geLevel, "Blocked autofocusing on a form control because the form's frame is san dboxed and the 'allow-scripts' permission is not set.");
184 return false; 184 return false;
185 } 185 }
186 if (element->hasAutofocused()) 186 if (element->hasAutofocused())
187 return false; 187 return false;
188 188
189 // FIXME: Should this set of hasTagName checks be replaced by a 189 // FIXME: Should this set of hasTagName checks be replaced by a
190 // virtual member function? 190 // virtual member function?
191 if (element->hasTagName(inputTag)) 191 if (element->hasTagName(inputTag))
192 return !static_cast<HTMLInputElement*>(element)->isInputTypeHidden(); 192 return !Handle<HTMLInputElement>::cast(element)->isInputTypeHidden();
193 if (element->hasTagName(selectTag)) 193 if (element->hasTagName(selectTag))
194 return true; 194 return true;
195 if (element->hasTagName(keygenTag)) 195 if (element->hasTagName(keygenTag))
196 return true; 196 return true;
197 if (element->hasTagName(buttonTag)) 197 if (element->hasTagName(buttonTag))
198 return true; 198 return true;
199 if (element->hasTagName(textareaTag)) 199 if (element->hasTagName(textareaTag))
200 return true; 200 return true;
201 201
202 return false; 202 return false;
(...skipping 10 matching lines...) Expand all
213 PostAttachCallbackDisabler disabler(this); 213 PostAttachCallbackDisabler disabler(this);
214 214
215 HTMLElement::attach(); 215 HTMLElement::attach();
216 216
217 // The call to updateFromElement() needs to go after the call through 217 // The call to updateFromElement() needs to go after the call through
218 // to the base class's attach() because that can sometimes do a close 218 // to the base class's attach() because that can sometimes do a close
219 // on the renderer. 219 // on the renderer.
220 if (renderer()) 220 if (renderer())
221 renderer()->updateFromElement(); 221 renderer()->updateFromElement();
222 222
223 if (shouldAutofocus(this)) { 223 if (shouldAutofocus(Handle<HTMLFormControlElement>(this))) {
224 setAutofocused(); 224 setAutofocused();
225 ref(); 225 ref();
226 queuePostAttachCallback(focusPostAttach, this); 226 queuePostAttachCallback(focusPostAttach, this);
227 } 227 }
228 } 228 }
229 229
230 void HTMLFormControlElement::didMoveToNewDocument(Document* oldDocument) 230 void HTMLFormControlElement::didMoveToNewDocument(Document* oldDocument)
231 { 231 {
232 FormAssociatedElement::didMoveToNewDocument(oldDocument); 232 FormAssociatedElement::didMoveToNewDocument(oldDocument);
233 HTMLElement::didMoveToNewDocument(oldDocument); 233 HTMLElement::didMoveToNewDocument(oldDocument);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 void HTMLFormControlElement::updateVisibleValidationMessage() 392 void HTMLFormControlElement::updateVisibleValidationMessage()
393 { 393 {
394 Page* page = document()->page(); 394 Page* page = document()->page();
395 if (!page) 395 if (!page)
396 return; 396 return;
397 String message; 397 String message;
398 if (renderer() && willValidate()) 398 if (renderer() && willValidate())
399 message = validationMessage().stripWhiteSpace(); 399 message = validationMessage().stripWhiteSpace();
400 if (!m_validationMessage) 400 if (!m_validationMessage)
401 m_validationMessage = ValidationMessage::create(this); 401 m_validationMessage = ValidationMessage::create(Handle<HTMLFormControlEl ement>(this));
402 m_validationMessage->updateValidationMessage(message); 402 m_validationMessage->updateValidationMessage(message);
403 } 403 }
404 404
405 void HTMLFormControlElement::hideVisibleValidationMessage() 405 void HTMLFormControlElement::hideVisibleValidationMessage()
406 { 406 {
407 if (m_validationMessage) 407 if (m_validationMessage)
408 m_validationMessage->requestToHideMessage(); 408 m_validationMessage->requestToHideMessage();
409 } 409 }
410 410
411 bool HTMLFormControlElement::checkValidity(Vector<RefPtr<FormAssociatedElement> >* unhandledInvalidControls) 411 bool HTMLFormControlElement::checkValidity(Vector<RefPtr<FormAssociatedElement> >* unhandledInvalidControls)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 HTMLFormElement* HTMLFormControlElement::virtualForm() const 466 HTMLFormElement* HTMLFormControlElement::virtualForm() const
467 { 467 {
468 return FormAssociatedElement::form(); 468 return FormAssociatedElement::form();
469 } 469 }
470 470
471 bool HTMLFormControlElement::isDefaultButtonForForm() const 471 bool HTMLFormControlElement::isDefaultButtonForForm() const
472 { 472 {
473 return isSuccessfulSubmitButton() && form() && form()->defaultButton() == th is; 473 return isSuccessfulSubmitButton() && form() && form()->defaultButton() == th is;
474 } 474 }
475 475
476 HTMLFormControlElement* HTMLFormControlElement::enclosingFormControlElement(Node * node) 476 Result<HTMLFormControlElement> HTMLFormControlElement::enclosingFormControlEleme nt(Node* node)
477 { 477 {
478 for (; node; node = node->parentNode()) { 478 for (; node; node = node->parentNode()) {
479 if (node->isElementNode() && toElement(node)->isFormControlElement()) 479 if (node->isElementNode() && toElement(node)->isFormControlElement())
480 return static_cast<HTMLFormControlElement*>(node); 480 return Handle<HTMLFormControlElement>(static_cast<HTMLFormControlEle ment*>(node));
481 } 481 }
482 return 0; 482 return nullptr;
483 } 483 }
484 484
485 void HTMLFormControlElement::reportMemoryUsage(MemoryObjectInfo* memoryObjectInf o) const 485 void HTMLFormControlElement::reportMemoryUsage(MemoryObjectInfo* memoryObjectInf o) const
486 { 486 {
487 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); 487 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
488 LabelableElement::reportMemoryUsage(memoryObjectInfo); 488 LabelableElement::reportMemoryUsage(memoryObjectInfo);
489 info.addMember(m_validationMessage, "validationMessage"); 489 info.addMember(m_validationMessage, "validationMessage");
490 } 490 }
491 491
492 void HTMLFormControlElement::acceptHeapVisitor(Visitor* visitor) const
493 {
494 LabelableElement::acceptHeapVisitor(visitor);
495 }
496
492 } // namespace Webcore 497 } // namespace Webcore
OLDNEW
« no previous file with comments | « Source/core/html/HTMLFormControlElement.h ('k') | Source/core/html/HTMLFormControlElementWithState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698