Diff
Modified: trunk/LayoutTests/ChangeLog (204185 => 204186)
--- trunk/LayoutTests/ChangeLog 2016-08-05 19:29:55 UTC (rev 204185)
+++ trunk/LayoutTests/ChangeLog 2016-08-05 19:38:18 UTC (rev 204186)
@@ -1,3 +1,17 @@
+2016-08-05 Brent Fulgham <[email protected]>
+
+ validity assertion fails after removing a child of an <optgroup> element
+ https://bugs.webkit.org/show_bug.cgi?id=155720
+ <rdar://problem/27720746>
+
+ Reviewed by Brent Fulgham.
+
+ Add new test case that triggers a debug assertion when the HTMLSelectElement state
+ is not updated properly.
+
+ * fast/dom/HTMLSelectElement/select-remove-from-optgroup-expected.txt: Added.
+ * fast/dom/HTMLSelectElement/select-remove-from-optgroup.html: Added.
+
2016-08-05 Ryan Haddad <[email protected]>
Unreviewed, rolling out r204174.
Added: trunk/LayoutTests/fast/dom/HTMLSelectElement/select-remove-from-optgroup-expected.txt (0 => 204186)
--- trunk/LayoutTests/fast/dom/HTMLSelectElement/select-remove-from-optgroup-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/select-remove-from-optgroup-expected.txt 2016-08-05 19:38:18 UTC (rev 204186)
@@ -0,0 +1,4 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
Added: trunk/LayoutTests/fast/dom/HTMLSelectElement/select-remove-from-optgroup.html (0 => 204186)
--- trunk/LayoutTests/fast/dom/HTMLSelectElement/select-remove-from-optgroup.html (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/select-remove-from-optgroup.html 2016-08-05 19:38:18 UTC (rev 204186)
@@ -0,0 +1,15 @@
+<script>
+window._onload_ = function() {
+ var parent = document.getElementById('id_1');
+ parent.removeChild(parent.childNodes[0]);
+ parent.removeChild(parent.childNodes[0]);
+ document.getElementById('id_0').appendChild(document.activeElement);
+}
+</script>
+<template id="id_0"></template>
+<select required>
+ <optgroup id="id_1">
+ <option></option>
+ </optgroup>
+</select>
+The test passes if this does not cause a debug assert.
Modified: trunk/Source/WebCore/ChangeLog (204185 => 204186)
--- trunk/Source/WebCore/ChangeLog 2016-08-05 19:29:55 UTC (rev 204185)
+++ trunk/Source/WebCore/ChangeLog 2016-08-05 19:38:18 UTC (rev 204186)
@@ -1,3 +1,22 @@
+2016-08-05 Brent Fulgham <[email protected]>
+
+ validity assertion fails after removing a child of an <optgroup> element
+ https://bugs.webkit.org/show_bug.cgi?id=155720
+ <rdar://problem/27720746>
+
+ Reviewed by Brent Fulgham.
+
+ All calls to HTMLSelectElement::setRecalcListItems also need to call HTMLSelectElement::updateValidity.
+
+ Test: fast/dom/HTMLSelectElement/select-remove-from-optgroup.html
+
+ * html/HTMLOptGroupElement.cpp:
+ (WebCore::HTMLOptGroupElement::recalcSelectOptions): Call 'updateValidity' after 'setRecalcListItems'.
+ * html/HTMLOptionElement.cpp:
+ (WebCore::HTMLOptionElement::insertedInto): Ditto.
+ * html/HTMLSelectElement.cpp:
+ (WebCore::HTMLSelectElement::parseAttribute): Ditto.
+
2016-08-05 Ryan Haddad <[email protected]>
Unreviewed, rolling out r204174.
Modified: trunk/Source/WebCore/html/HTMLOptGroupElement.cpp (204185 => 204186)
--- trunk/Source/WebCore/html/HTMLOptGroupElement.cpp 2016-08-05 19:29:55 UTC (rev 204185)
+++ trunk/Source/WebCore/html/HTMLOptGroupElement.cpp 2016-08-05 19:38:18 UTC (rev 204186)
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll ([email protected])
* (C) 1999 Antti Koivisto ([email protected])
* (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2016 Apple Inc. All rights reserved.
* (C) 2006 Alexey Proskuryakov ([email protected])
*
* This library is free software; you can redistribute it and/or
@@ -26,6 +26,7 @@
#include "HTMLOptGroupElement.h"
#include "Document.h"
+#include "ElementAncestorIterator.h"
#include "HTMLNames.h"
#include "HTMLSelectElement.h"
#include "RenderMenuList.h"
@@ -85,11 +86,10 @@
void HTMLOptGroupElement::recalcSelectOptions()
{
- ContainerNode* select = parentNode();
- while (select && !is<HTMLSelectElement>(*select))
- select = select->parentNode();
- if (select)
- downcast<HTMLSelectElement>(*select).setRecalcListItems();
+ if (auto* selectElement = ancestorsOfType<HTMLSelectElement>(*this).first()) {
+ selectElement->setRecalcListItems();
+ selectElement->updateValidity();
+ }
}
String HTMLOptGroupElement::groupLabelText() const
Modified: trunk/Source/WebCore/html/HTMLOptionElement.cpp (204185 => 204186)
--- trunk/Source/WebCore/html/HTMLOptionElement.cpp 2016-08-05 19:29:55 UTC (rev 204185)
+++ trunk/Source/WebCore/html/HTMLOptionElement.cpp 2016-08-05 19:38:18 UTC (rev 204186)
@@ -316,6 +316,7 @@
{
if (HTMLSelectElement* select = ownerSelectElement()) {
select->setRecalcListItems();
+ select->updateValidity();
// Do not call selected() since calling updateListItemSelectedStates()
// at this time won't do the right thing. (Why, exactly?)
// FIXME: Might be better to call this unconditionally, always passing m_isSelected,
Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (204185 => 204186)
--- trunk/Source/WebCore/html/HTMLSelectElement.cpp 2016-08-05 19:29:55 UTC (rev 204185)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp 2016-08-05 19:38:18 UTC (rev 204186)
@@ -305,6 +305,7 @@
if (m_size != oldSize) {
setNeedsStyleRecalc(ReconstructRenderTree);
setRecalcListItems();
+ updateValidity();
}
} else if (name == multipleAttr)
parseMultipleAttribute(value);