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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLOptionElement.cpp

Issue 1541753002: HTMLOptionElement.prototype.selected setter should not make an option dirty if it doesn't change it… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/forms/select/option-dirtiness.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 5 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
6 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * Copyright (C) 2011 Motorola Mobility, Inc. All rights reserved. 8 * Copyright (C) 2011 Motorola Mobility, Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 select->optionSelectionStateChanged(this, selected); 260 select->optionSelectionStateChanged(this, selected);
261 } 261 }
262 262
263 bool HTMLOptionElement::selectedForBinding() const 263 bool HTMLOptionElement::selectedForBinding() const
264 { 264 {
265 return selected(); 265 return selected();
266 } 266 }
267 267
268 void HTMLOptionElement::setSelectedForBinding(bool selected) 268 void HTMLOptionElement::setSelectedForBinding(bool selected)
269 { 269 {
270 bool wasSelected = m_isSelected;
270 setSelected(selected); 271 setSelected(selected);
272
273 // As of December 2015, the HTML specification says the dirtiness becomes
tfarina 2015/12/23 23:04:36 is it worth pointing to the link for that specific
274 // true by |selected| setter unconditionally. However it caused a real bug,
275 // crbug.com/570367, and is not compatible with other browsers.
276 // Firefox seems not to set dirtiness if an option is owned by a select
277 // element and selectedness is not changed.
278 if (ownerSelectElement() && wasSelected == m_isSelected)
279 return;
280
271 m_isDirty = true; 281 m_isDirty = true;
272 } 282 }
273 283
274 void HTMLOptionElement::setSelectedState(bool selected) 284 void HTMLOptionElement::setSelectedState(bool selected)
275 { 285 {
276 if (m_isSelected == selected) 286 if (m_isSelected == selected)
277 return; 287 return;
278 288
279 m_isSelected = selected; 289 m_isSelected = selected;
280 pseudoStateChanged(CSSSelector::PseudoChecked); 290 pseudoStateChanged(CSSSelector::PseudoChecked);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 ASSERT(parent); 469 ASSERT(parent);
460 if (isHTMLOptGroupElement(*parent)) { 470 if (isHTMLOptGroupElement(*parent)) {
461 const ComputedStyle* parentStyle = parent->computedStyle() ? parent- >computedStyle() : parent->ensureComputedStyle(); 471 const ComputedStyle* parentStyle = parent->computedStyle() ? parent- >computedStyle() : parent->ensureComputedStyle();
462 return !parentStyle || parentStyle->display() == NONE; 472 return !parentStyle || parentStyle->display() == NONE;
463 } 473 }
464 } 474 }
465 return m_style->display() == NONE; 475 return m_style->display() == NONE;
466 } 476 }
467 477
468 } // namespace blink 478 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/forms/select/option-dirtiness.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698