| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 if (!firstSubmitButton && control->isSuccessfulSubmitButton()) | 95 if (!firstSubmitButton && control->isSuccessfulSubmitButton()) |
| 96 firstSubmitButton = control; | 96 firstSubmitButton = control; |
| 97 } | 97 } |
| 98 return firstSubmitButton; | 98 return firstSubmitButton; |
| 99 } | 99 } |
| 100 | 100 |
| 101 // Returns true if the selected state of all the options matches the default | 101 // Returns true if the selected state of all the options matches the default |
| 102 // selected state. | 102 // selected state. |
| 103 bool isSelectInDefaultState(const HTMLSelectElement& select) | 103 bool isSelectInDefaultState(const HTMLSelectElement& select) |
| 104 { | 104 { |
| 105 const HeapVector<Member<HTMLElement>>& listItems = select.listItems(); | |
| 106 if (select.multiple() || select.size() > 1) { | 105 if (select.multiple() || select.size() > 1) { |
| 107 for (const auto& item : listItems) { | 106 for (const auto& optionElement : select.optionList()) { |
| 108 if (!isHTMLOptionElement(*item)) | |
| 109 continue; | |
| 110 HTMLOptionElement* optionElement = toHTMLOptionElement(item); | |
| 111 if (optionElement->selected() != optionElement->fastHasAttribute(sel
ectedAttr)) | 107 if (optionElement->selected() != optionElement->fastHasAttribute(sel
ectedAttr)) |
| 112 return false; | 108 return false; |
| 113 } | 109 } |
| 114 return true; | 110 return true; |
| 115 } | 111 } |
| 116 | 112 |
| 117 // The select is rendered as a combobox (called menulist in WebKit). At | 113 // The select is rendered as a combobox (called menulist in WebKit). At |
| 118 // least one item is selected, determine which one. | 114 // least one item is selected, determine which one. |
| 119 HTMLOptionElement* initialSelected = nullptr; | 115 HTMLOptionElement* initialSelected = nullptr; |
| 120 for (const auto& item : listItems) { | 116 for (const auto& optionElement : select.optionList()) { |
| 121 if (!isHTMLOptionElement(*item)) | |
| 122 continue; | |
| 123 HTMLOptionElement* optionElement = toHTMLOptionElement(item); | |
| 124 if (optionElement->fastHasAttribute(selectedAttr)) { | 117 if (optionElement->fastHasAttribute(selectedAttr)) { |
| 125 // The page specified the option to select. | 118 // The page specified the option to select. |
| 126 initialSelected = optionElement; | 119 initialSelected = optionElement; |
| 127 break; | 120 break; |
| 128 } | 121 } |
| 129 if (!initialSelected) | 122 if (!initialSelected) |
| 130 initialSelected = optionElement; | 123 initialSelected = optionElement; |
| 131 } | 124 } |
| 132 return !initialSelected || initialSelected->selected(); | 125 return !initialSelected || initialSelected->selected(); |
| 133 } | 126 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 273 |
| 281 String action(formElement->action()); | 274 String action(formElement->action()); |
| 282 KURL url(formElement->document().completeURL(action.isNull() ? "" : action))
; | 275 KURL url(formElement->document().completeURL(action.isNull() ? "" : action))
; |
| 283 RefPtr<EncodedFormData> formData = EncodedFormData::create(encodedString); | 276 RefPtr<EncodedFormData> formData = EncodedFormData::create(encodedString); |
| 284 url.setQuery(formData->flattenToString()); | 277 url.setQuery(formData->flattenToString()); |
| 285 m_url = url; | 278 m_url = url; |
| 286 m_encoding = String(encoding.name()); | 279 m_encoding = String(encoding.name()); |
| 287 } | 280 } |
| 288 | 281 |
| 289 } // namespace blink | 282 } // namespace blink |
| OLD | NEW |