RESOLVED FIXED Bug 61011
[Refactoring] attach() following detach() should be replaced with Node::forceReattach()
https://bugs.webkit.org/show_bug.cgi?id=61011
Summary [Refactoring] attach() following detach() should be replaced with Node::force...
Hajime Morrita
Reported 2011-05-17 18:18:32 PDT
We are going to have the method.
Attachments
Patch (11.83 KB, patch)
2011-05-20 01:01 PDT, Hajime Morrita
no flags
Patch (11.67 KB, patch)
2011-05-22 23:30 PDT, Hajime Morrita
no flags
synced to HEAD (10.68 KB, patch)
2011-05-22 23:46 PDT, Hajime Morrita
dglazkov: review+
Dominic Cooney
Comment 1 2011-05-17 20:10:59 PDT
Is there anything special about forceReattach compared to detach and attach? (eg detach and attach a bug because ...?, or just slow because ...?)
Hajime Morrita
Comment 2 2011-05-17 21:51:25 PDT
(In reply to comment #1) > Is there anything special about forceReattach compared to detach and attach? (eg detach and attach a bug because ...?, or just slow because ...?) Nothing special, it's just a shorthand.
Dimitri Glazkov (Google)
Comment 3 2011-05-18 07:38:51 PDT
Also, it's something we should work to replace every instance of detach()/attach() (anti)pattern with something smarter or gentler. Rounding all occurrences into one place seems like a good start.
Hajime Morrita
Comment 4 2011-05-20 01:01:06 PDT
Dimitri Glazkov (Google)
Comment 5 2011-05-20 09:12:46 PDT
Comment on attachment 94184 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=94184&action=review Thank you for taking on this! > Source/WebCore/ChangeLog:9 > + - Replaced detach() following attach() with reattach() Great name! > Source/WebCore/dom/CharacterData.cpp:185 > + reattach(); This will never hit unless the node is already attached, so the value of ReattachType is irrelevant here. > Source/WebCore/dom/Node.h:454 > + void reattach(ReattachType = ReattachIfAttached); Looking at the callsites, I think ReattachAlways should be the default. > Source/WebCore/dom/Node.h:746 > + if (!attached()) { > + if (type == ReattachAlways) > + attach(); This seems wrong. Why are we attempting to attach here?
Hajime Morrita
Comment 6 2011-05-22 23:30:25 PDT
Hajime Morrita
Comment 7 2011-05-22 23:32:26 PDT
Comment on attachment 94184 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=94184&action=review Hi Dimitri, thank you for the first round! Here is update. >> Source/WebCore/dom/CharacterData.cpp:185 >> + reattach(); > > This will never hit unless the node is already attached, so the value of ReattachType is irrelevant here. I splited reattach() and reattachIfAttached() an use reattach() here. >> Source/WebCore/dom/Node.h:454 >> + void reattach(ReattachType = ReattachIfAttached); > > Looking at the callsites, I think ReattachAlways should be the default. Now there are reattach() and reattachIfAttached(). >> Source/WebCore/dom/Node.h:746 >> + attach(); > > This seems wrong. Why are we attempting to attach here? Makes sense. I clarified this by splitting the function into two.
Hajime Morrita
Comment 8 2011-05-22 23:46:58 PDT
Created attachment 94375 [details] synced to HEAD
Hajime Morrita
Comment 9 2011-05-23 20:31:56 PDT
Note You need to log in before you can comment on or make changes to this bug.