[Qt] REGRESSION(101967): It made editing/style/iframe-onload-crash-mac.html timeout
authorcaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2012 17:54:40 +0000 (17:54 +0000)
committercaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2012 17:54:40 +0000 (17:54 +0000)
commit7ca01d4fc8b2eff45f0cdcc339269b0b6691951f
tree07fa26f3a4af57c5a9c8e27d416696f054df670a
parent41ec1acc9066424a14957e47bd5366b32d0ca4f6
[Qt] REGRESSION(101967): It made editing/style/iframe-onload-crash-mac.html timeout
https://bugs.webkit.org/show_bug.cgi?id=73802

Reviewed by Ryosuke Niwa.

Source/WebCore:

Timeout was caused by an infinite in the outer loop of
pushDownInlineStyleAroundNode(). The outer loop variable 'current' should point at the
node containing 'targetNode'. The inner loop traverse the children of 'current'
and discover the children that contains 'targetNode'.

However, before the inner loop, we call removeInlineStyleFromElement() that can
potentially remove the 'current' node from the tree, moving its children to
'current' former parent. For that reason 'child' and 'lastChild' are collected
before this call.

The tricky part is that changing the 'current' children parent, we might trigger
further side-effects, that can remove either 'child' or 'lastChild' from the tree
too. The infinite loop was due to 'child' being off the document, so it's
nextSibling() is 0, and we go another run of outer loop without changing
'current' because the 'targetNode' wasn't in the first child that inner loop
couldn't reach.

When testing Qt on Mac, there was also a crash in RenderTextControl when the font
family was empty, this patch fixes it as well.

* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode): Use NodeVector
instead of relying on first/last child being valid after
removeInlineStyleFromElement() is called. Skip the child if it has no parent,
this is an indication that it was removed from the tree.

* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::hasValidAvgCharWidth): Empty AtomicStrings aren't
supported by HashSet, so we have to early return in this case.

LayoutTests:

* platform/qt/Skipped: Unskipped. Note that it is still skipped for wk2 because
setEditingBehavior is not implemented for WebKitTestRunner yet.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117463 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/platform/qt/Skipped
Source/WebCore/ChangeLog
Source/WebCore/editing/ApplyStyleCommand.cpp
Source/WebCore/rendering/RenderTextControl.cpp