Changeset 112515 in webkit
- Timestamp:
- Mar 29, 2012 3:14:32 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r112514 r112515 1 2012-03-29 Zeno Albisser <zeno@webkit.org> 2 3 Fieldset disabled attribute does not work. 4 https://bugs.webkit.org/show_bug.cgi?id=58837 5 6 Add a test case for fieldset disabled attribute. 7 8 Reviewed by Kent Tamura. 9 10 * fast/forms/fieldset/fieldset-disabled-expected.txt: Added. 11 * fast/forms/fieldset/fieldset-disabled.html: Added. 12 1 13 2012-03-29 Csaba Osztrogonác <ossy@webkit.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r112513 r112515 1 2012-03-29 Zeno Albisser <zeno@webkit.org> 2 3 Fieldset disabled attribute does not work. 4 https://bugs.webkit.org/show_bug.cgi?id=58837 5 6 Make HTMLFormControlElements inherit the disabled state 7 from HTMLFieldSetElement ancestors. Subordinates of the 8 first HTMLLegendElement in a fieldset will never be disabled. 9 10 Patch by Zeno Albisser <zeno@webkit.org> 11 12 Test: fast/forms/fieldset-disabled.html 13 14 Reviewed by Kent Tamura. 15 16 * html/HTMLFieldSetElement.cpp: 17 (WebCore::HTMLFieldSetElement::disabledAttributeChanged): 18 (WebCore): 19 (WebCore::HTMLFieldSetElement::legend): 20 * html/HTMLFieldSetElement.h: 21 (HTMLFieldSetElement): 22 * html/HTMLFieldSetElement.idl: 23 * html/HTMLFormControlElement.cpp: 24 (WebCore::HTMLFormControlElement::HTMLFormControlElement): 25 (WebCore::HTMLFormControlElement::updateFieldSetAndLegendAncestor): 26 (WebCore): 27 (WebCore::HTMLFormControlElement::parseAttribute): 28 (WebCore::HTMLFormControlElement::disabledAttributeChanged): 29 (WebCore::HTMLFormControlElement::removedFromTree): 30 (WebCore::HTMLFormControlElement::disabled): 31 * html/HTMLFormControlElement.h: 32 (WebCore): 33 (HTMLFormControlElement): 34 1 35 2012-03-29 Tommy Widenflycht <tommyw@google.com> 2 36 -
trunk/Source/WebCore/html/HTMLFieldSetElement.cpp
r65986 r112515 25 25 #include "config.h" 26 26 #include "HTMLFieldSetElement.h" 27 #include "HTMLLegendElement.h" 27 28 28 29 #include "HTMLNames.h" … … 45 46 } 46 47 48 void HTMLFieldSetElement::disabledAttributeChanged() 49 { 50 // This element must be updated before the style of nodes in its subtree gets recalculated. 51 HTMLFormControlElement::disabledAttributeChanged(); 52 53 for (Node* currentNode = this; currentNode; currentNode = currentNode->traverseNextNode(this)) { 54 HTMLElement* element = toHTMLElement(currentNode); 55 if (element && element->isFormControlElement()) 56 static_cast<HTMLFormControlElement*>(element)->setNeedsStyleRecalc(); 57 } 58 } 59 47 60 bool HTMLFieldSetElement::supportsFocus() const 48 61 { … … 61 74 } 62 75 76 HTMLLegendElement* HTMLFieldSetElement::legend() const 77 { 78 for (Element* node = firstElementChild(); node; node = node->nextElementSibling()) { 79 if (node->hasTagName(legendTag)) 80 return static_cast<HTMLLegendElement*>(node); 81 } 82 return 0; 83 } 84 63 85 } // namespace -
trunk/Source/WebCore/html/HTMLFieldSetElement.h
r72835 r112515 32 32 public: 33 33 static PassRefPtr<HTMLFieldSetElement> create(const QualifiedName&, Document*, HTMLFormElement*); 34 HTMLLegendElement* legend() const; 35 36 protected: 37 virtual void disabledAttributeChanged() OVERRIDE; 34 38 35 39 private: -
trunk/Source/WebCore/html/HTMLFieldSetElement.idl
r109846 r112515 21 21 22 22 interface HTMLFieldSetElement : HTMLElement { 23 attribute [Reflect] boolean disabled; 23 24 readonly attribute HTMLFormElement form; 24 25 attribute [Reflect] DOMString name; -
trunk/Source/WebCore/html/HTMLFormControlElement.cpp
r112389 r112515 31 31 #include "EventNames.h" 32 32 #include "Frame.h" 33 #include "HTMLFieldSetElement.h" 33 34 #include "HTMLFormElement.h" 34 35 #include "HTMLInputElement.h" 36 #include "HTMLLegendElement.h" 35 37 #include "RenderBox.h" 36 38 #include "RenderTheme.h" … … 47 49 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form) 48 50 : LabelableElement(tagName, document) 51 , m_fieldSetAncestor(0) 52 , m_legendAncestor(0) 53 , m_fieldSetAncestorValid(false) 49 54 , m_disabled(false) 50 55 , m_readOnly(false) … … 96 101 } 97 102 103 void HTMLFormControlElement::updateFieldSetAndLegendAncestor() const 104 { 105 m_fieldSetAncestor = 0; 106 m_legendAncestor = 0; 107 for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) { 108 if (!m_legendAncestor && ancestor->hasTagName(legendTag)) 109 m_legendAncestor = static_cast<HTMLLegendElement*>(ancestor); 110 if (ancestor->hasTagName(fieldsetTag)) { 111 m_fieldSetAncestor = static_cast<HTMLFieldSetElement*>(ancestor); 112 break; 113 } 114 } 115 m_fieldSetAncestorValid = true; 116 } 117 98 118 void HTMLFormControlElement::parseAttribute(Attribute* attr) 99 119 { … … 103 123 bool oldDisabled = m_disabled; 104 124 m_disabled = !attr->isNull(); 105 if (oldDisabled != m_disabled) { 106 setNeedsStyleRecalc(); 107 if (renderer() && renderer()->style()->hasAppearance()) 108 renderer()->theme()->stateChanged(renderer(), EnabledState); 109 } 125 if (oldDisabled != m_disabled) 126 disabledAttributeChanged(); 110 127 } else if (attr->name() == readonlyAttr) { 111 128 bool oldReadOnly = m_readOnly; … … 126 143 } 127 144 145 void HTMLFormControlElement::disabledAttributeChanged() 146 { 147 setNeedsStyleRecalc(); 148 if (renderer() && renderer()->style()->hasAppearance()) 149 renderer()->theme()->stateChanged(renderer(), EnabledState); 150 } 151 128 152 void HTMLFormControlElement::requiredAttributeChanged() 129 153 { … … 206 230 void HTMLFormControlElement::removedFromTree(bool deep) 207 231 { 232 m_fieldSetAncestorValid = false; 208 233 FormAssociatedElement::removedFromTree(); 209 234 HTMLElement::removedFromTree(deep); … … 253 278 setChangedSinceLastFormControlChangeEvent(true); 254 279 HTMLElement::dispatchInputEvent(); 280 } 281 282 bool HTMLFormControlElement::disabled() const 283 { 284 if (m_disabled) 285 return true; 286 287 if (!m_fieldSetAncestorValid) 288 updateFieldSetAndLegendAncestor(); 289 290 // Form controls in the first legend element inside a fieldset are not affected by fieldset.disabled. 291 if (m_fieldSetAncestor && m_fieldSetAncestor->disabled()) 292 return !(m_legendAncestor && m_legendAncestor == m_fieldSetAncestor->legend()); 293 return false; 255 294 } 256 295 -
trunk/Source/WebCore/html/HTMLFormControlElement.h
r112389 r112515 31 31 32 32 class FormDataList; 33 class HTMLFieldSetElement; 33 34 class HTMLFormElement; 35 class HTMLLegendElement; 34 36 class ValidationMessage; 35 37 class ValidityState; … … 50 52 bool formNoValidate() const; 51 53 54 void updateFieldSetAndLegendAncestor() const; 55 52 56 virtual void reset() { } 53 57 … … 61 65 virtual void dispatchFormControlInputEvent(); 62 66 63 virtual bool disabled() const { return m_disabled; }67 virtual bool disabled() const; 64 68 void setDisabled(bool); 65 69 … … 115 119 virtual void parseAttribute(Attribute*) OVERRIDE; 116 120 virtual void requiredAttributeChanged(); 121 virtual void disabledAttributeChanged(); 117 122 virtual void attach(); 118 123 virtual void insertedIntoTree(bool deep); … … 148 153 String visibleValidationMessage() const; 149 154 155 mutable HTMLFieldSetElement* m_fieldSetAncestor; 156 mutable HTMLLegendElement* m_legendAncestor; 150 157 OwnPtr<ValidationMessage> m_validationMessage; 158 mutable bool m_fieldSetAncestorValid : 1; 151 159 bool m_disabled : 1; 152 160 bool m_readOnly : 1;
Note: See TracChangeset
for help on using the changeset viewer.