Changeset 122559 in webkit
- Timestamp:
- Jul 13, 2012 3:59:59 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r122558 r122559 1 2012-07-13 Kent Tamura <tkent@chromium.org> 2 3 Change the timing of form state restore 4 https://bugs.webkit.org/show_bug.cgi?id=89962 5 6 Reviewed by Hajime Morita. 7 8 For a preparation to fix a form identification problem (Bug 91209), 9 restore controls states when the parsing of their owner forms is 10 completed. For controls without owners, their states are restored when 11 their parsing is completed as ever. 12 13 No new tests. This doesn't change observable behavior. 14 15 * html/FormController.cpp: 16 (WebCore::ownerFormForState): 17 Added. This code was used in formKey(), and restoreControlState*() use it. 18 (WebCore::FormKeyGenerator::formKey): Use ownerFormForState(). No behavior change. 19 (WebCore::FormController::restoreControlStateFor): 20 Moved some code from HTMLFormControlElementWithState::finishParsingChildren(). 21 The difference is we don't resotre state if this control is owned by a form. 22 (WebCore::FormController::restoreControlStateIn): 23 Restore states of associated controls. This is called from 24 finishParsingChildren() for <form>. 25 * html/FormController.h: 26 (FormController): 27 - Declare restoreControlStateFor() and restoreControlStateIn(). 28 - Make takeStateForFormElement() private. 29 30 * html/FormAssociatedElement.cpp: 31 (WebCore::FormAssociatedElement::isFormControlElementWithState): 32 Added. The default implementation returns false. 33 * html/FormAssociatedElement.h: 34 (FormAssociatedElement): 35 Added isFormControlElementWithState() for FormController::restoreControlStateIn(). 36 * html/HTMLFormControlElementWithState.cpp: 37 (WebCore::HTMLFormControlElementWithState::finishParsingChildren): 38 Some code was moved to FormController:restoreControlStateFor(). 39 (WebCore::HTMLFormControlElementWithState::isFormControlElementWithState): 40 Added. Returns true. 41 * html/HTMLFormControlElementWithState.h: 42 (HTMLFormControlElementWithState): Declare isFormControlElementWithState(). 43 * html/HTMLFormElement.cpp: 44 (WebCore::HTMLFormElement::finishParsingChildren): 45 Added. Calls FormController::restoreControlStateIn(). 46 * html/HTMLFormElement.h: 47 (HTMLFormElement): Declare finishParsingChildren(). 48 1 49 2012-07-13 Kent Tamura <tkent@chromium.org> 2 50 -
trunk/Source/WebCore/html/FormAssociatedElement.cpp
r120049 r122559 228 228 } 229 229 230 bool FormAssociatedElement::isFormControlElementWithState() const 231 { 232 return false; 233 } 234 230 235 const HTMLElement* toHTMLElement(const FormAssociatedElement* associatedElement) 231 236 { -
trunk/Source/WebCore/html/FormAssociatedElement.h
r120049 r122559 47 47 48 48 virtual bool isFormControlElement() const = 0; 49 virtual bool isFormControlElementWithState() const; 49 50 virtual bool isEnumeratable() const = 0; 50 51 -
trunk/Source/WebCore/html/FormController.cpp
r122422 r122559 30 30 using namespace HTMLNames; 31 31 32 static inline HTMLFormElement* ownerFormForState(const HTMLFormControlElementWithState& control) 33 { 34 // Assume controls with form attribute have no owners because we restore 35 // state during parsing and form owners of such controls might be 36 // indeterminate. 37 return control.fastHasAttribute(formAttr) ? 0 : control.form(); 38 } 39 32 40 // ---------------------------------------------------------------------------- 33 41 … … 104 112 AtomicString FormKeyGenerator::formKey(const HTMLFormControlElementWithState& control) 105 113 { 106 // Assume contorl with form attribute have no owners because we restores 107 // state during parsing and form owners of such controls might be 108 // indeterminate. 109 HTMLFormElement* form = control.fastHasAttribute(formAttr) ? 0 : control.form(); 114 HTMLFormElement* form = ownerFormForState(control); 110 115 if (!form) { 111 116 DEFINE_STATIC_LOCAL(AtomicString, formKeyForNoOwner, ("No owner")); … … 241 246 } 242 247 248 void FormController::restoreControlStateFor(HTMLFormControlElementWithState& control) 249 { 250 // We don't save state of a control with shouldSaveAndRestoreFormControlState() 251 // == false. But we need to skip restoring process too because a control in 252 // another form might have the same pair of name and type and saved its state. 253 if (!control.shouldSaveAndRestoreFormControlState()) 254 return; 255 if (ownerFormForState(control)) 256 return; 257 FormControlState state = takeStateForFormElement(control); 258 if (state.valueSize() > 0) 259 control.restoreFormControlState(state); 260 } 261 262 void FormController::restoreControlStateIn(HTMLFormElement& form) 263 { 264 const Vector<FormAssociatedElement*>& elements = form.associatedElements(); 265 for (size_t i = 0; i < elements.size(); ++i) { 266 if (!elements[i]->isFormControlElementWithState()) 267 continue; 268 HTMLFormControlElementWithState* control = static_cast<HTMLFormControlElementWithState*>(elements[i]); 269 if (!control->shouldSaveAndRestoreFormControlState()) 270 continue; 271 if (ownerFormForState(*control) != &form) 272 continue; 273 FormControlState state = takeStateForFormElement(*control); 274 if (state.valueSize() > 0) 275 control->restoreFormControlState(state); 276 } 277 } 278 243 279 void FormController::registerFormElementWithFormAttribute(FormAssociatedElement* element) 244 280 { -
trunk/Source/WebCore/html/FormController.h
r121420 r122559 130 130 // This should be callled only by Document::setStateForNewFormElements(). 131 131 void setStateForNewFormElements(const Vector<String>&); 132 FormControlState takeStateForFormElement(const HTMLFormControlElementWithState&);133 132 void willDeleteForm(HTMLFormElement*); 133 void restoreControlStateFor(HTMLFormControlElementWithState&); 134 void restoreControlStateIn(HTMLFormElement&); 134 135 135 136 void registerFormElementWithFormAttribute(FormAssociatedElement*); … … 139 140 private: 140 141 FormController(); 142 FormControlState takeStateForFormElement(const HTMLFormControlElementWithState&); 141 143 142 144 CheckedRadioButtons m_checkedRadioButtons; -
trunk/Source/WebCore/html/HTMLFormControlElementWithState.cpp
r121235 r122559 71 71 { 72 72 HTMLFormControlElement::finishParsingChildren(); 73 document()->formController()->restoreControlStateFor(*this); 74 } 73 75 74 // We don't save state of a control with shouldSaveAndRestoreFormControlState()=false. 75 // But we need to skip restoring process too because a control in another 76 // form might have the same pair of name and type and saved its state. 77 if (!shouldSaveAndRestoreFormControlState()) 78 return; 79 80 FormControlState state = document()->formController()->takeStateForFormElement(*this); 81 if (state.valueSize() > 0) 82 restoreFormControlState(state); 76 bool HTMLFormControlElementWithState::isFormControlElementWithState() const 77 { 78 return true; 83 79 } 84 80 -
trunk/Source/WebCore/html/HTMLFormControlElementWithState.h
r122414 r122559 48 48 virtual void finishParsingChildren(); 49 49 virtual void didMoveToNewDocument(Document* oldDocument) OVERRIDE; 50 virtual bool isFormControlElementWithState() const OVERRIDE; 50 51 }; 51 52 -
trunk/Source/WebCore/html/HTMLFormElement.cpp
r122115 r122559 686 686 } 687 687 688 void HTMLFormElement::finishParsingChildren() 689 { 690 HTMLElement::finishParsingChildren(); 691 document()->formController()->restoreControlStateIn(*this); 692 } 693 688 694 } // namespace -
trunk/Source/WebCore/html/HTMLFormElement.h
r122115 r122559 122 122 virtual void didNotifyDescendantInsertions(ContainerNode*) OVERRIDE; 123 123 virtual void removedFrom(ContainerNode*) OVERRIDE; 124 virtual void finishParsingChildren() OVERRIDE; 124 125 125 126 virtual void handleLocalEvents(Event*);
Note: See TracChangeset
for help on using the changeset viewer.