<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[186624] branches/safari-600.8-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/186624">186624</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2015-07-09 14:03:10 -0700 (Thu, 09 Jul 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/186557">r186557</a>. rdar://problem/21716382</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6008branchLayoutTestsChangeLog">branches/safari-600.8-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6008branchSourceWebCoreChangeLog">branches/safari-600.8-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6008branchSourceWebCoredomElementcpp">branches/safari-600.8-branch/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#branchessafari6008branchSourceWebCoredomElementh">branches/safari-600.8-branch/Source/WebCore/dom/Element.h</a></li>
<li><a href="#branchessafari6008branchSourceWebCoredomTreeScopecpp">branches/safari-600.8-branch/Source/WebCore/dom/TreeScope.cpp</a></li>
<li><a href="#branchessafari6008branchSourceWebCoredomTreeScopeh">branches/safari-600.8-branch/Source/WebCore/dom/TreeScope.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari6008branchLayoutTestsfastformschangeformidtobeuniqueexpectedtxt">branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-expected.txt</a></li>
<li><a href="#branchessafari6008branchLayoutTestsfastformschangeformidtobeuniquethensubmitformexpectedtxt">branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-then-submit-form-expected.txt</a></li>
<li><a href="#branchessafari6008branchLayoutTestsfastformschangeformidtobeuniquethensubmitformhtml">branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-then-submit-form.html</a></li>
<li><a href="#branchessafari6008branchLayoutTestsfastformschangeformidtobeuniquehtml">branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6008branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.8-branch/LayoutTests/ChangeLog (186623 => 186624)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/LayoutTests/ChangeLog        2015-07-09 21:03:05 UTC (rev 186623)
+++ branches/safari-600.8-branch/LayoutTests/ChangeLog        2015-07-09 21:03:10 UTC (rev 186624)
</span><span class="lines">@@ -1,5 +1,29 @@
</span><span class="cx"> 2015-07-09  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r186557. rdar://problem/21716382
+
+    2015-07-08  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+            Merge r183436. rdar://problem/21716524
+
+        2015-04-27  Daniel Bates  &lt;dabates@apple.com&gt;
+
+                Form control may be associated with the wrong HTML Form element after form id change
+                https://bugs.webkit.org/show_bug.cgi?id=133456
+                &lt;rdar://problem/17095055&gt;
+
+                Reviewed by Andy Estes.
+
+                Add tests to ensure that we associate the correct HTML Form element with a
+                &lt;select&gt; after changing the id of its associated HTML form element.
+
+                * fast/forms/change-form-id-to-be-unique-expected.txt: Added.
+                * fast/forms/change-form-id-to-be-unique-then-submit-form-expected.txt: Added.
+                * fast/forms/change-form-id-to-be-unique-then-submit-form.html: Added.
+                * fast/forms/change-form-id-to-be-unique.html: Added.
+
+2015-07-09  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r186553. rdar://problem/21716372
</span><span class="cx"> 
</span><span class="cx">     2015-07-08  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6008branchLayoutTestsfastformschangeformidtobeuniqueexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-expected.txt (0 => 186624)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-expected.txt                                (rev 0)
+++ branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-expected.txt        2015-07-09 21:03:10 UTC (rev 186624)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+PASS did not cause an assertion failure.
</ins></span></pre></div>
<a id="branchessafari6008branchLayoutTestsfastformschangeformidtobeuniquethensubmitformexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-then-submit-form-expected.txt (0 => 186624)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-then-submit-form-expected.txt                                (rev 0)
+++ branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-then-submit-form-expected.txt        2015-07-09 21:03:10 UTC (rev 186624)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+This tests that we submit the form element associated with id &quot;a&quot; after changing the id of one of the &lt;form id=&quot;a&quot;&gt;s in a document that contains two such HTML Form elements.
+
+PASS submitted second &lt;form&gt;.
+
</ins></span></pre></div>
<a id="branchessafari6008branchLayoutTestsfastformschangeformidtobeuniquethensubmitformhtml"></a>
<div class="addfile"><h4>Added: branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-then-submit-form.html (0 => 186624)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-then-submit-form.html                                (rev 0)
+++ branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique-then-submit-form.html        2015-07-09 21:03:10 UTC (rev 186624)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+#test-container { visibility: hidden; }
+&lt;/style&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function logMessageAndDone(message)
+{
+    document.getElementById(&quot;console&quot;).textContent = message;
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+function runTest()
+{
+    var search = document.location.search;
+    if (search === &quot;?submitted=secondFormElement&quot;)
+        logMessageAndDone(&quot;PASS submitted second &lt;form&gt;.&quot;);
+    else if (search === &quot;?submitted=firstFormElement&quot;)
+        logMessageAndDone(&quot;FAIL should have submitted second &lt;form&gt;, but submitted first &lt;form&gt;.&quot;);
+    else {
+        document.getElementById(&quot;a&quot;).id = &quot;y&quot;; // Changes the id of the first &lt;form&gt; (traversing the DOM from top-to-bottom).
+        document.getElementById(&quot;submit&quot;).click();
+    }
+}
+
+window.onload = runTest;
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;This tests that we submit the form element associated with id &amp;quot;a&amp;quot; after changing the id of one of the &amp;lt;form id=&amp;quot;a&amp;quot;&amp;gt;s in a document that contains two such HTML Form elements.&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;test-container&quot;&gt;
+    &lt;form id=&quot;a&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;submitted&quot; value=&quot;firstFormElement&quot;&gt;&lt;/form&gt;
+    &lt;form id=&quot;a&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;submitted&quot; value=&quot;secondFormElement&quot;&gt;&lt;/form&gt;
+    &lt;input id=&quot;submit&quot; type=&quot;submit&quot; form=&quot;a&quot; value=&quot;Submit&quot;&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari6008branchLayoutTestsfastformschangeformidtobeuniquehtml"></a>
<div class="addfile"><h4>Added: branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique.html (0 => 186624)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique.html                                (rev 0)
+++ branches/safari-600.8-branch/LayoutTests/fast/forms/change-form-id-to-be-unique.html        2015-07-09 21:03:10 UTC (rev 186624)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;document.body.removeChild(document.getElementById('x'));&quot;&gt;
+&lt;p&gt;PASS did not cause an assertion failure.&lt;/p&gt;
+&lt;div id=&quot;x&quot;&gt;
+    &lt;form id=&quot;a&quot;&gt;&lt;/form&gt;
+    &lt;form id=&quot;a&quot;&gt;
+        &lt;select form=&quot;a&quot;&gt;&lt;/select&gt;
+    &lt;/form&gt;
+&lt;/div&gt;
+&lt;script&gt;
+document.getElementById(&quot;a&quot;).setAttribute(&quot;id&quot;, &quot;y&quot;);
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari6008branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.8-branch/Source/WebCore/ChangeLog (186623 => 186624)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/Source/WebCore/ChangeLog        2015-07-09 21:03:05 UTC (rev 186623)
+++ branches/safari-600.8-branch/Source/WebCore/ChangeLog        2015-07-09 21:03:10 UTC (rev 186624)
</span><span class="lines">@@ -1,5 +1,48 @@
</span><span class="cx"> 2015-07-09  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r186557. rdar://problem/21716382
+
+    2015-07-08  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+            Merge r183436. rdar://problem/21716524
+
+        2015-04-27  Daniel Bates  &lt;dabates@apple.com&gt;
+
+                Form control may be associated with the wrong HTML Form element after form id change
+                https://bugs.webkit.org/show_bug.cgi?id=133456
+                &lt;rdar://problem/17095055&gt;
+
+                Reviewed by Andy Estes.
+
+                Fixes an issue where a form control may be associated with the wrong HTML Form element
+                after the id of the HTML Form element associated with the form control is changed when
+                there is more than one HTML Form element with the same id in the document. Specifically,
+                a form control that has an HTML form attribute value X will always be associated with
+                some HTML Form element f where f.id = X regardless of whether f.id is subsequently
+                changed.
+
+                Tests: fast/forms/change-form-id-to-be-unique-then-submit-form.html
+                       fast/forms/change-form-id-to-be-unique.html
+
+                * dom/Element.cpp:
+                (WebCore::Element::attributeChanged): Notify observers when the id of an element changed.
+                (WebCore::Element::updateId): Added parameter NotifyObservers (defaults to NotifyObservers::Yes),
+                as to whether we should notify observers of the id change.
+                (WebCore::Element::updateIdForTreeScope): Ditto.
+                (WebCore::Element::willModifyAttribute): Do not notify observers of the id change immediately. As
+                indicated by the name of this method, we plan to modify the DOM attribute id of the element, but
+                we have not actually modified it when this method is called. Instead we will notify observers
+                in Element::attributeChanged(), which is called after the DOM attribute id is modified.
+                (WebCore::Element::cloneAttributesFromElement): Ditto.
+                * dom/Element.h: Defined enum class NotifyObservers.
+                * dom/TreeScope.cpp:
+                (WebCore::TreeScope::addElementById): Added boolean parameter notifyObservers (defaults to true)
+                as to whether we should dispatch a notification to all observers.
+                (WebCore::TreeScope::removeElementById): Ditto.
+                * dom/TreeScope.h:
+
+2015-07-09  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r186556. rdar://problem/21716415
</span><span class="cx"> 
</span><span class="cx">     2015-07-08  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6008branchSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.8-branch/Source/WebCore/dom/Element.cpp (186623 => 186624)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/Source/WebCore/dom/Element.cpp        2015-07-09 21:03:05 UTC (rev 186623)
+++ branches/safari-600.8-branch/Source/WebCore/dom/Element.cpp        2015-07-09 21:03:10 UTC (rev 186624)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> #include &quot;HTMLParserIdioms.h&quot;
</span><span class="cx"> #include &quot;HTMLSelectElement.h&quot;
</span><span class="cx"> #include &quot;HTMLTableRowsCollection.h&quot;
</span><ins>+#include &quot;IdTargetObserverRegistry.h&quot;
</ins><span class="cx"> #include &quot;InsertionPoint.h&quot;
</span><span class="cx"> #include &quot;KeyboardEvent.h&quot;
</span><span class="cx"> #include &quot;MutationObserverInterestGroup.h&quot;
</span><span class="lines">@@ -563,7 +564,7 @@
</span><span class="cx">         renderer()-&gt;theme().stateChanged(*renderer(), ControlStates::HoverState);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Element::scrollIntoView(bool alignToTop) 
</del><ins>+void Element::scrollIntoView(bool alignToTop)
</ins><span class="cx"> {
</span><span class="cx">     document().updateLayoutIgnorePendingStylesheets();
</span><span class="cx"> 
</span><span class="lines">@@ -786,7 +787,7 @@
</span><span class="cx">     bool inQuirksMode = document().inQuirksMode();
</span><span class="cx">     if ((!inQuirksMode &amp;&amp; document().documentElement() == this) || (inQuirksMode &amp;&amp; isHTMLElement() &amp;&amp; document().body() == this))
</span><span class="cx">         return adjustForAbsoluteZoom(renderView.frameView().layoutWidth(), renderView);
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (RenderBox* renderer = renderBox()) {
</span><span class="cx"> #if ENABLE(SUBPIXEL_LAYOUT)
</span><span class="cx">         LayoutUnit clientWidth = subpixelMetricsEnabled(renderer-&gt;document()) ? renderer-&gt;clientWidth() : LayoutUnit(renderer-&gt;pixelSnappedClientWidth());
</span><span class="lines">@@ -963,7 +964,7 @@
</span><span class="cx">         return document().view()-&gt;contentsToRootView(renderer-&gt;absoluteBoundingBoxRect());
</span><span class="cx">     return IntRect();
</span><span class="cx"> }
</span><del>-    
</del><ins>+
</ins><span class="cx"> IntRect Element::screenRect() const
</span><span class="cx"> {
</span><span class="cx">     if (RenderObject* renderer = this-&gt;renderer())
</span><span class="lines">@@ -1086,6 +1087,11 @@
</span><span class="cx">     bool shouldInvalidateStyle = false;
</span><span class="cx"> 
</span><span class="cx">     if (name == HTMLNames::idAttr) {
</span><ins>+        if (!oldValue.isEmpty())
+            treeScope().idTargetObserverRegistry().notifyObservers(*oldValue.impl());
+        if (!newValue.isEmpty())
+            treeScope().idTargetObserverRegistry().notifyObservers(*newValue.impl());
+
</ins><span class="cx">         AtomicString oldId = elementData()-&gt;idForStyleResolution();
</span><span class="cx">         AtomicString newId = makeIdForStyleResolution(newValue, document().inQuirksMode());
</span><span class="cx">         if (newId != oldId) {
</span><span class="lines">@@ -1581,7 +1587,7 @@
</span><span class="cx"> {
</span><span class="cx">     // :empty selector.
</span><span class="cx">     checkForEmptyStyleChange(*parent);
</span><del>-    
</del><ins>+
</ins><span class="cx">     if (parent-&gt;needsStyleRecalc() &amp;&amp; parent-&gt;childrenAffectedByPositionalRules())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -1923,7 +1929,7 @@
</span><span class="cx"> 
</span><span class="cx">     // If the stylesheets have already been loaded we can reliably check isFocusable.
</span><span class="cx">     // If not, we continue and set the focused node on the focus controller below so
</span><del>-    // that it can be updated soon after attach. 
</del><ins>+    // that it can be updated soon after attach.
</ins><span class="cx">     if (document().haveStylesheetsLoaded()) {
</span><span class="cx">         document().updateLayoutIgnorePendingStylesheets();
</span><span class="cx">         if (!isFocusable())
</span><span class="lines">@@ -1950,7 +1956,7 @@
</span><span class="cx">         ensureElementRareData().setNeedsFocusAppearanceUpdateSoonAfterAttach(true);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-        
</del><ins>+
</ins><span class="cx">     cancelFocusAppearanceUpdate();
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     // Focusing a form element triggers animation in UIKit to scroll to the right position.
</span><span class="lines">@@ -1986,14 +1992,14 @@
</span><span class="cx">         Frame* frame = document().frame();
</span><span class="cx">         if (!frame)
</span><span class="cx">             return;
</span><del>-        
</del><ins>+
</ins><span class="cx">         // When focusing an editable element in an iframe, don't reset the selection if it already contains a selection.
</span><span class="cx">         if (this == frame-&gt;selection().selection().rootEditableElement())
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         // FIXME: We should restore the previous selection if there is one.
</span><span class="cx">         VisibleSelection newSelection = VisibleSelection(firstPositionInOrBeforeNode(this), DOWNSTREAM);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (frame-&gt;selection().shouldChangeSelection(newSelection)) {
</span><span class="cx">             frame-&gt;selection().setSelection(newSelection);
</span><span class="cx">             frame-&gt;selection().revealSelection();
</span><span class="lines">@@ -2686,7 +2692,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void Element::updateId(const AtomicString&amp; oldId, const AtomicString&amp; newId)
</del><ins>+inline void Element::updateId(const AtomicString&amp; oldId, const AtomicString&amp; newId, NotifyObservers notifyObservers)
</ins><span class="cx"> {
</span><span class="cx">     if (!isInTreeScope())
</span><span class="cx">         return;
</span><span class="lines">@@ -2694,7 +2700,7 @@
</span><span class="cx">     if (oldId == newId)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    updateIdForTreeScope(treeScope(), oldId, newId);
</del><ins>+    updateIdForTreeScope(treeScope(), oldId, newId, notifyObservers);
</ins><span class="cx"> 
</span><span class="cx">     if (!inDocument())
</span><span class="cx">         return;
</span><span class="lines">@@ -2703,15 +2709,15 @@
</span><span class="cx">     updateIdForDocument(toHTMLDocument(document()), oldId, newId, UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Element::updateIdForTreeScope(TreeScope&amp; scope, const AtomicString&amp; oldId, const AtomicString&amp; newId)
</del><ins>+void Element::updateIdForTreeScope(TreeScope&amp; scope, const AtomicString&amp; oldId, const AtomicString&amp; newId, NotifyObservers notifyObservers)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isInTreeScope());
</span><span class="cx">     ASSERT(oldId != newId);
</span><span class="cx"> 
</span><span class="cx">     if (!oldId.isEmpty())
</span><del>-        scope.removeElementById(*oldId.impl(), *this);
</del><ins>+        scope.removeElementById(*oldId.impl(), *this, notifyObservers == NotifyObservers::Yes);
</ins><span class="cx">     if (!newId.isEmpty())
</span><del>-        scope.addElementById(*newId.impl(), *this);
</del><ins>+        scope.addElementById(*newId.impl(), *this, notifyObservers == NotifyObservers::Yes);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Element::updateIdForDocument(HTMLDocument&amp; document, const AtomicString&amp; oldId, const AtomicString&amp; newId, HTMLDocumentNamedItemMapsUpdatingCondition condition)
</span><span class="lines">@@ -2755,7 +2761,7 @@
</span><span class="cx"> void Element::willModifyAttribute(const QualifiedName&amp; name, const AtomicString&amp; oldValue, const AtomicString&amp; newValue)
</span><span class="cx"> {
</span><span class="cx">     if (name == HTMLNames::idAttr)
</span><del>-        updateId(oldValue, newValue);
</del><ins>+        updateId(oldValue, newValue, NotifyObservers::No); // Will notify observers after the attribute is actually changed.
</ins><span class="cx">     else if (name == HTMLNames::nameAttr)
</span><span class="cx">         updateName(oldValue, newValue);
</span><span class="cx">     else if (name == HTMLNames::forAttr &amp;&amp; hasTagName(labelTag)) {
</span><span class="lines">@@ -2973,7 +2979,7 @@
</span><span class="cx">     const AtomicString&amp; newID = other.getIdAttribute();
</span><span class="cx"> 
</span><span class="cx">     if (!oldID.isNull() || !newID.isNull())
</span><del>-        updateId(oldID, newID);
</del><ins>+        updateId(oldID, newID, NotifyObservers::No); // Will notify observers after the attribute is actually changed.
</ins><span class="cx"> 
</span><span class="cx">     const AtomicString&amp; oldName = getNameAttribute();
</span><span class="cx">     const AtomicString&amp; newName = other.getNameAttribute();
</span></span></pre></div>
<a id="branchessafari6008branchSourceWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.8-branch/Source/WebCore/dom/Element.h (186623 => 186624)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/Source/WebCore/dom/Element.h        2015-07-09 21:03:05 UTC (rev 186623)
+++ branches/safari-600.8-branch/Source/WebCore/dom/Element.h        2015-07-09 21:03:10 UTC (rev 186624)
</span><span class="lines">@@ -620,8 +620,11 @@
</span><span class="cx">     void updateName(const AtomicString&amp; oldName, const AtomicString&amp; newName);
</span><span class="cx">     void updateNameForTreeScope(TreeScope&amp;, const AtomicString&amp; oldName, const AtomicString&amp; newName);
</span><span class="cx">     void updateNameForDocument(HTMLDocument&amp;, const AtomicString&amp; oldName, const AtomicString&amp; newName);
</span><del>-    void updateId(const AtomicString&amp; oldId, const AtomicString&amp; newId);
-    void updateIdForTreeScope(TreeScope&amp;, const AtomicString&amp; oldId, const AtomicString&amp; newId);
</del><ins>+
+    enum class NotifyObservers { No, Yes };
+    void updateId(const AtomicString&amp; oldId, const AtomicString&amp; newId, NotifyObservers = NotifyObservers::Yes);
+    void updateIdForTreeScope(TreeScope&amp;, const AtomicString&amp; oldId, const AtomicString&amp; newId, NotifyObservers = NotifyObservers::Yes);
+
</ins><span class="cx">     enum HTMLDocumentNamedItemMapsUpdatingCondition { AlwaysUpdateHTMLDocumentNamedItemMaps, UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute };
</span><span class="cx">     void updateIdForDocument(HTMLDocument&amp;, const AtomicString&amp; oldId, const AtomicString&amp; newId, HTMLDocumentNamedItemMapsUpdatingCondition);
</span><span class="cx">     void updateLabel(TreeScope&amp;, const AtomicString&amp; oldForAttributeValue, const AtomicString&amp; newForAttributeValue);
</span></span></pre></div>
<a id="branchessafari6008branchSourceWebCoredomTreeScopecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.8-branch/Source/WebCore/dom/TreeScope.cpp (186623 => 186624)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/Source/WebCore/dom/TreeScope.cpp        2015-07-09 21:03:05 UTC (rev 186623)
+++ branches/safari-600.8-branch/Source/WebCore/dom/TreeScope.cpp        2015-07-09 21:03:10 UTC (rev 186624)
</span><span class="lines">@@ -129,20 +129,22 @@
</span><span class="cx">     return m_elementsById-&gt;getAllElementsById(*elementId.impl(), *this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TreeScope::addElementById(const AtomicStringImpl&amp; elementId, Element&amp; element)
</del><ins>+void TreeScope::addElementById(const AtomicStringImpl&amp; elementId, Element&amp; element, bool notifyObservers)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_elementsById)
</span><span class="cx">         m_elementsById = std::make_unique&lt;DocumentOrderedMap&gt;();
</span><span class="cx">     m_elementsById-&gt;add(elementId, element, *this);
</span><del>-    m_idTargetObserverRegistry-&gt;notifyObservers(elementId);
</del><ins>+    if (notifyObservers)
+        m_idTargetObserverRegistry-&gt;notifyObservers(elementId);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TreeScope::removeElementById(const AtomicStringImpl&amp; elementId, Element&amp; element)
</del><ins>+void TreeScope::removeElementById(const AtomicStringImpl&amp; elementId, Element&amp; element, bool notifyObservers)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_elementsById)
</span><span class="cx">         return;
</span><span class="cx">     m_elementsById-&gt;remove(elementId, element);
</span><del>-    m_idTargetObserverRegistry-&gt;notifyObservers(elementId);
</del><ins>+    if (notifyObservers)
+        m_idTargetObserverRegistry-&gt;notifyObservers(elementId);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Element* TreeScope::getElementByName(const AtomicString&amp; name) const
</span></span></pre></div>
<a id="branchessafari6008branchSourceWebCoredomTreeScopeh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.8-branch/Source/WebCore/dom/TreeScope.h (186623 => 186624)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.8-branch/Source/WebCore/dom/TreeScope.h        2015-07-09 21:03:05 UTC (rev 186623)
+++ branches/safari-600.8-branch/Source/WebCore/dom/TreeScope.h        2015-07-09 21:03:10 UTC (rev 186624)
</span><span class="lines">@@ -59,8 +59,8 @@
</span><span class="cx">     const Vector&lt;Element*&gt;* getAllElementsById(const AtomicString&amp;) const;
</span><span class="cx">     bool hasElementWithId(const AtomicStringImpl&amp;) const;
</span><span class="cx">     bool containsMultipleElementsWithId(const AtomicString&amp; id) const;
</span><del>-    void addElementById(const AtomicStringImpl&amp; elementId, Element&amp;);
-    void removeElementById(const AtomicStringImpl&amp; elementId, Element&amp;);
</del><ins>+    void addElementById(const AtomicStringImpl&amp; elementId, Element&amp;, bool notifyObservers = true);
+    void removeElementById(const AtomicStringImpl&amp; elementId, Element&amp;, bool notifyObservers = true);
</ins><span class="cx"> 
</span><span class="cx">     Element* getElementByName(const AtomicString&amp;) const;
</span><span class="cx">     bool hasElementWithName(const AtomicStringImpl&amp;) const;
</span></span></pre>
</div>
</div>

</body>
</html>