1/* 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Library General Public 10 * License as published by the Free Software Foundation; either 11 * version 2 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Library General Public License for more details. 17 * 18 * You should have received a copy of the GNU Library General Public License 19 * along with this library; see the file COPYING.LIB. If not, write to 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * Boston, MA 02110-1301, USA. 22 * 23 */ 24 25#include "config.h" 26#include "HTMLFormControlElementWithState.h" 27 28#include "Chrome.h" 29#include "ChromeClient.h" 30#include "FormController.h" 31#include "Frame.h" 32#include "HTMLFormElement.h" 33#include "Page.h" 34 35namespace WebCore { 36 37HTMLFormControlElementWithState::HTMLFormControlElementWithState(const QualifiedName& tagName, Document* doc, HTMLFormElement* f) 38 : HTMLFormControlElement(tagName, doc, f) 39{ 40} 41 42HTMLFormControlElementWithState::~HTMLFormControlElementWithState() 43{ 44} 45 46Node::InsertionNotificationRequest HTMLFormControlElementWithState::insertedInto(ContainerNode* insertionPoint) 47{ 48 if (insertionPoint->inDocument() && !containingShadowRoot()) 49 document()->formController().registerFormElementWithState(this); 50 return HTMLFormControlElement::insertedInto(insertionPoint); 51} 52 53void HTMLFormControlElementWithState::removedFrom(ContainerNode* insertionPoint) 54{ 55 if (insertionPoint->inDocument() && !containingShadowRoot() && !insertionPoint->containingShadowRoot()) 56 document()->formController().unregisterFormElementWithState(this); 57 HTMLFormControlElement::removedFrom(insertionPoint); 58} 59 60bool HTMLFormControlElementWithState::shouldAutocomplete() const 61{ 62 if (!form()) 63 return true; 64 return form()->shouldAutocomplete(); 65} 66 67void HTMLFormControlElementWithState::notifyFormStateChanged() 68{ 69 Frame* frame = document()->frame(); 70 if (!frame) 71 return; 72 73 if (Page* page = frame->page()) 74 page->chrome().client()->formStateDidChange(this); 75} 76 77bool HTMLFormControlElementWithState::shouldSaveAndRestoreFormControlState() const 78{ 79 // We don't save/restore control state in a form with autocomplete=off. 80 return attached() && shouldAutocomplete(); 81} 82 83FormControlState HTMLFormControlElementWithState::saveFormControlState() const 84{ 85 return FormControlState(); 86} 87 88void HTMLFormControlElementWithState::finishParsingChildren() 89{ 90 HTMLFormControlElement::finishParsingChildren(); 91 document()->formController().restoreControlStateFor(*this); 92} 93 94bool HTMLFormControlElementWithState::isFormControlElementWithState() const 95{ 96 return true; 97} 98 99} // namespace Webcore 100