Changeset 107242 in webkit


Ignore:
Timestamp:
Feb 9, 2012 7:26:58 AM (12 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: fix setOuterHTML for the case that adds / removes duplicate.
https://bugs.webkit.org/show_bug.cgi?id=78235

Reviewed by Yury Semikhatsky.

Source/WebCore:

  • inspector/DOMEditor.cpp:

(WebCore::DOMEditor::diff):
(WebCore::DOMEditor::innerPatchChildren):
(WebCore):
(WebCore::nodeName):
(WebCore::DOMEditor::dumpMap):

  • inspector/DOMEditor.h:

(DOMEditor):

LayoutTests:

  • inspector/elements/set-outer-html-2-expected.txt:
  • inspector/elements/set-outer-html-2.html:
  • inspector/elements/set-outer-html-expected.txt:
  • inspector/elements/set-outer-html.html:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r107241 r107242  
     12012-02-09  Pavel Feldman  <pfeldman@google.com>
     2
     3        Web Inspector: fix setOuterHTML for the case that adds / removes duplicate.
     4        https://bugs.webkit.org/show_bug.cgi?id=78235
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        * inspector/elements/set-outer-html-2-expected.txt:
     9        * inspector/elements/set-outer-html-2.html:
     10        * inspector/elements/set-outer-html-expected.txt:
     11        * inspector/elements/set-outer-html.html:
     12
    1132012-02-09  Pavel Podivilov  <podivilov@chromium.org>
    214
  • trunk/LayoutTests/inspector/elements/set-outer-html-2-expected.txt

    r104920 r107242  
    1313==========8<==========
    1414<div id="container" style="display:none">
    15 <h2 foo="bar" bar="baz">Welcome to the website for the WebKit Open Source Project!</h2>
    16 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    17 
    18 <h2>Getting involved</h2>
    19 <a href="http://nightly.webkit.org/"></a>
     15<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
     16<h2 foo="bar" bar="baz">Getting involved</h2>
    2017<p id="identity">There are many ways to get involved. You can:</p>
    2118<ul>
     
    3633==========8<==========
    3734<div id="container" style="display:none">
    38 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    39 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    40 
    41 <h2>Getting involved</h2>
    42 <a href="http://nightly.webkit.org/"></a>
     35<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
     36<h2>Getting involved</h2>
    4337<p id="identity">There are many ways to get involved. You can:</p>
    4438<ul>
     
    6155==========8<==========
    6256<div id="container" style="display:none">
    63 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    64 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    65 
    66 <h2>Getting involved</h2>
    67 <a href="http://nightly.webkit.org/"></a>
     57<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
     58<h2>Getting involved</h2>
    6859<p id="identity">There are many ways to get involved. You can:</p>
    6960<div><ul>
     
    8374==========8<==========
    8475<div id="container" style="display:none">
    85 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    86 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    87 
    88 <h2>Getting involved</h2>
    89 <a href="http://nightly.webkit.org/"></a>
     76<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
     77<h2>Getting involved</h2>
    9078<p id="identity">There are many ways to get involved. You can:</p>
    9179<ul>
     
    10896==========8<==========
    10997<div id="container" style="display:none">
    110 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    111 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    112 
    113 
    114 <a href="http://nightly.webkit.org/"></a>
     98<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
     99
    115100<p id="identity">There are many ways to get involved. You can:</p>
    116101<ul>
     
    126111
    127112Wrapper identity: identity
    128 Event NodeInserted: A
    129113Event NodeInserted: H2
    130 Event NodeRemoved: A
     114Event NodeInserted: P
    131115Event NodeRemoved: H2
    132 ==========8<==========
    133 <div id="container" style="display:none">
    134 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    135 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    136 
    137 <h2>Getting involved</h2>
    138 <a href="http://nightly.webkit.org/"></a>
     116Event NodeRemoved: P
     117==========8<==========
     118<div id="container" style="display:none">
     119<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
     120<h2>Getting involved</h2>
    139121<p id="identity">There are many ways to get involved. You can:</p>
    140122<ul>
     
    156138==========8<==========
    157139<div id="container" style="display:none">
    158 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    159 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    160 
    161 <h2>Getting involved</h2>
    162 <a href="http://nightly.webkit.org/"></a>
    163 <p id="identity">There are many ways to get involved. You can:</p>
    164 <ul>
    165    <li></li>
    166 </ul>
    167 <ul>
    168    <li></li>
    169 </ul>
    170 </div>
    171 ==========>8==========
    172 
    173 Bringing things back
    174 
    175 Wrapper identity: identity
    176 ==========8<==========
    177 <div id="container" style="display:none">
    178 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    179 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    180 
    181 <h2>Getting involved</h2>
    182 <a href="http://nightly.webkit.org/"></a>
    183 <p id="identity">There are many ways to get involved. You can:</p>
    184 <ul>
    185    <li></li>
    186 </ul>
    187 <ul>
    188    <li></li>
    189 </ul>
    190 </div>
    191 ==========>8==========
    192 
    193 
    194 
    195 
    196 
     140<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
     141<h2>Getting involved</h2>
     142<p id="identity">There are many ways to get involved. You can:</p>
     143<ul>
     144   <li></li>
     145</ul>
     146<ul>
     147   <li></li>
     148</ul>
     149</div>
     150==========>8==========
     151
     152Bringing things back
     153
     154Wrapper identity: identity
     155==========8<==========
     156<div id="container" style="display:none">
     157<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
     158<h2>Getting involved</h2>
     159<p id="identity">There are many ways to get involved. You can:</p>
     160<ul>
     161   <li></li>
     162</ul>
     163<ul>
     164   <li></li>
     165</ul>
     166</div>
     167==========>8==========
     168
     169
     170
     171
     172
     173Running: testDupeNode
     174Replacing '<h2>Getting involved</h2>' with '<h2>Getting involved</h2><h2>Getting involved</h2>'
     175
     176Wrapper identity: identity
     177Event NodeInserted: H2
     178==========8<==========
     179<div id="container" style="display:none">
     180<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
     181<h2>Getting involved</h2><h2>Getting involved</h2>
     182<p id="identity">There are many ways to get involved. You can:</p>
     183<ul>
     184   <li></li>
     185</ul>
     186<ul>
     187   <li></li>
     188</ul>
     189</div>
     190==========>8==========
     191
     192Bringing things back
     193
     194Wrapper identity: identity
     195Event NodeRemoved: H2
     196==========8<==========
     197<div id="container" style="display:none">
     198<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
     199<h2>Getting involved</h2>
     200<p id="identity">There are many ways to get involved. You can:</p>
     201<ul>
     202   <li></li>
     203</ul>
     204<ul>
     205   <li></li>
     206</ul>
     207</div>
     208==========>8==========
     209
     210
     211
     212
     213
  • trunk/LayoutTests/inspector/elements/set-outer-html-2.html

    r104920 r107242  
    4646            var text = InspectorTest.containerText + "<div>Additional node</div>";
    4747            InspectorTest.setOuterHTML(text, next);
     48        },
     49
     50        function testDupeNode(next)
     51        {
     52            InspectorTest.patchOuterHTML("<h2>Getting involved</h2>", "<h2>Getting involved</h2><h2>Getting involved</h2>", next);
    4853        }
    4954    ]);
     
    5863
    5964<div id="container" style="display:none">
    60 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    61 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</a>.</p>
    62 
     65<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    6366<h2>Getting involved</h2>
    64 <a href="http://nightly.webkit.org/"></a>
    6567<p id="identity">There are many ways to get involved. You can:</p>
    6668<ul>
  • trunk/LayoutTests/inspector/elements/set-outer-html-expected.txt

    r104920 r107242  
    1111==========8<==========
    1212<div id="container" style="display:none">
    13 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    1413<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    15 
    1614<h2>Getting not involved</h2>
    17 <a href="http://nightly.webkit.org/"></a>
    1815<p id="identity">There are many ways to get involved. You can:</p>
    19 <ul>
    20    <li></li>
    21 </ul>
    22 <ul>
    23    <li></li>
    24 </ul>
    2516</div>
    2617==========>8==========
     
    3223==========8<==========
    3324<div id="container" style="display:none">
    34 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    3525<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    36 
    3726<h2>Getting involved</h2>
    38 <a href="http://nightly.webkit.org/"></a>
    3927<p id="identity">There are many ways to get involved. You can:</p>
    40 <ul>
    41    <li></li>
    42 </ul>
    43 <ul>
    44    <li></li>
    45 </ul>
    4628</div>
    4729==========>8==========
     
    6042==========8<==========
    6143<div id="container" style="display:none">
    62 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    6344<p>WebKit is used by <a foo="bar" href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    64 
    6545<h2>Getting involved</h2>
    66 <a href="http://nightly.webkit.org/"></a>
    6746<p id="identity">There are many ways to get involved. You can:</p>
    68 <ul>
    69    <li></li>
    70 </ul>
    71 <ul>
    72    <li></li>
    73 </ul>
    7447</div>
    7548==========>8==========
     
    8356==========8<==========
    8457<div id="container" style="display:none">
    85 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    8658<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    87 
    8859<h2>Getting involved</h2>
    89 <a href="http://nightly.webkit.org/"></a>
    9060<p id="identity">There are many ways to get involved. You can:</p>
    91 <ul>
    92    <li></li>
    93 </ul>
    94 <ul>
    95    <li></li>
    96 </ul>
    9761</div>
    9862==========>8==========
     
    10973==========8<==========
    11074<div id="container" style="display:none">
    111 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    11275<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    113 
    11476<h2></h2>
    115 <a href="http://nightly.webkit.org/"></a>
    11677<p id="identity">There are many ways to get involved. You can:</p>
    117 <ul>
    118    <li></li>
    119 </ul>
    120 <ul>
    121    <li></li>
    122 </ul>
    12378</div>
    12479==========>8==========
     
    13085==========8<==========
    13186<div id="container" style="display:none">
    132 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    13387<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    134 
    13588<h2>Getting involved</h2>
    136 <a href="http://nightly.webkit.org/"></a>
    13789<p id="identity">There are many ways to get involved. You can:</p>
    138 <ul>
    139    <li></li>
    140 </ul>
    141 <ul>
    142    <li></li>
    143 </ul>
    14490</div>
    14591==========>8==========
     
    158104==========8<==========
    159105<div id="container" style="display:none">
    160 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    161106<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    162 
    163107<h2>Getting</h2><h2>involved</h2>
    164 <a href="http://nightly.webkit.org/"></a>
    165108<p id="identity">There are many ways to get involved. You can:</p>
    166 <ul>
    167    <li></li>
    168 </ul>
    169 <ul>
    170    <li></li>
    171 </ul>
    172109</div>
    173110==========>8==========
     
    181118==========8<==========
    182119<div id="container" style="display:none">
    183 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    184120<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    185 
    186121<h2>Getting involved</h2>
    187 <a href="http://nightly.webkit.org/"></a>
    188122<p id="identity">There are many ways to get involved. You can:</p>
    189 <ul>
    190    <li></li>
    191 </ul>
    192 <ul>
    193    <li></li>
    194 </ul>
    195123</div>
    196124==========>8==========
     
    208136==========8<==========
    209137<div id="container" style="display:none">
    210 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    211138<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    212 
    213139<h3>Getting involved</h3>
    214 <a href="http://nightly.webkit.org/"></a>
    215140<p id="identity">There are many ways to get involved. You can:</p>
    216 <ul>
    217    <li></li>
    218 </ul>
    219 <ul>
    220    <li></li>
    221 </ul>
    222141</div>
    223142==========>8==========
     
    230149==========8<==========
    231150<div id="container" style="display:none">
    232 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    233151<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc..</p>
    234 
    235152<h2>Getting involved</h2>
    236 <a href="http://nightly.webkit.org/"></a>
    237153<p id="identity">There are many ways to get involved. You can:</p>
    238 <ul>
    239    <li></li>
    240 </ul>
    241 <ul>
    242    <li></li>
    243 </ul>
    244154</div>
    245155==========>8==========
  • trunk/LayoutTests/inspector/elements/set-outer-html.html

    r104920 r107242  
    5656
    5757<div id="container" style="display:none">
    58 <h2>Welcome to the website for the WebKit Open Source Project!</h2>
    5958<p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</a>.</p>
    60 
    6159<h2>Getting involved</h2>
    62 <a href="http://nightly.webkit.org/"></a>
    6360<p id="identity">There are many ways to get involved. You can:</p>
    64 <ul>
    65    <li></li>
    66 </ul>
    67 <ul>
    68    <li></li>
    69 </ul>
    7061</div>
    7162
  • trunk/Source/WebCore/ChangeLog

    r107239 r107242  
     12012-02-09  Pavel Feldman  <pfeldman@google.com>
     2
     3        Web Inspector: fix setOuterHTML for the case that adds / removes duplicate.
     4        https://bugs.webkit.org/show_bug.cgi?id=78235
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        * inspector/DOMEditor.cpp:
     9        (WebCore::DOMEditor::diff):
     10        (WebCore::DOMEditor::innerPatchChildren):
     11        (WebCore):
     12        (WebCore::nodeName):
     13        (WebCore::DOMEditor::dumpMap):
     14        * inspector/DOMEditor.h:
     15        (DOMEditor):
     16
    1172012-02-09  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
    218
  • trunk/Source/WebCore/inspector/DOMEditor.cpp

    r106833 r107242  
    261261    }
    262262
     263#ifdef DEBUG_DOM_EDITOR
     264    dumpMap(oldMap, "OLD");
     265    dumpMap(newMap, "NEW");
     266#endif
     267
    263268    return make_pair(oldMap, newMap);
    264269}
     
    275280    // 1. First strip everything except for the nodes that retain. Collect pending merges.
    276281    HashMap<Digest*, Digest*> merges;
     282    HashSet<size_t> usedNewOrdinals;
    277283    for (size_t i = 0; i < oldList.size(); ++i) {
    278         if (oldMap[i].first)
    279             continue;
     284        if (oldMap[i].first) {
     285            if (!usedNewOrdinals.contains(oldMap[i].second)) {
     286                usedNewOrdinals.add(oldMap[i].second);
     287                continue;
     288            }
     289            oldMap[i].first = 0;
     290            oldMap[i].second = 0;
     291        }
    280292
    281293        // Always match <head> and <body> tags with each other - we can't remove them from the DOM
     
    308320    }
    309321
    310     // Mark retained nodes as used.
     322    // Mark retained nodes as used, do not reuse node more than once.
     323    HashSet<size_t> usedOldOrdinals;
    311324    for (size_t i = 0; i < newList.size(); ++i) {
    312         if (newMap[i].first)
    313             markNodeAsUsed(newMap[i].first);
     325        if (!newMap[i].first)
     326            continue;
     327        size_t oldOrdinal = newMap[i].second;
     328        if (usedOldOrdinals.contains(oldOrdinal)) {
     329            // Do not map node more than once
     330            newMap[i].first = 0;
     331            newMap[i].second = 0;
     332            continue;
     333        }
     334        usedOldOrdinals.add(oldOrdinal);
     335        markNodeAsUsed(newMap[i].first);
    314336    }
    315337
     
    452474}
    453475
     476#ifdef DEBUG_DOM_EDITOR
     477static String nodeName(Node* node)
     478{
     479    if (node->document()->isXHTMLDocument())
     480         return node->nodeName();
     481    return node->nodeName().lower();
     482}
     483
     484void DOMEditor::dumpMap(const ResultMap& map, const String& name)
     485{
     486    fprintf(stderr, "\n\n");
     487    for (size_t i = 0; i < map.size(); ++i)
     488        fprintf(stderr, "%s[%lu]: %s (%p) - [%lu]\n", name.utf8().data(), i, map[i].first ? nodeName(map[i].first->m_node).utf8().data() : "", map[i].first, map[i].second);
     489}
     490#endif
     491
    454492} // namespace WebCore
    455493
  • trunk/Source/WebCore/inspector/DOMEditor.h

    r105067 r107242  
    6969    void removeChild(Digest*, ExceptionCode&);
    7070    void markNodeAsUsed(Digest*);
     71#ifdef DEBUG_DOM_EDITOR
     72    void dumpMap(const ResultMap&, const String& name);
     73#endif
    7174
    7275    Document* m_document;
Note: See TracChangeset for help on using the changeset viewer.