Bug 108689

Summary: Web Inspector: fix "DOM Exception 8" when deleting lines containing decoration in DTE.
Product: WebKit Reporter: Andrey Lushnikov <lushnikov>
Component: Web Inspector (Deprecated)Assignee: Andrey Lushnikov <lushnikov>
Status: RESOLVED FIXED    
Severity: Normal CC: apavlov, keishi, loislo, pfeldman, pmuellr, vsevik, web-inspector-bugs, webkit.review.bot, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch none

Description Andrey Lushnikov 2013-02-01 14:03:31 PST
Fix "DOM Exception 8" when deleting lines containing decoration in DTE.
Comment 1 Andrey Lushnikov 2013-02-01 14:08:17 PST
Created attachment 186134 [details]
Patch
Comment 2 Alexander Pavlov (apavlov) 2013-02-01 14:16:26 PST
Comment on attachment 186134 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=186134&action=review

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:2931
> +            if (this.element.contains(this.element.decorationsElement))

We usually use the parentElement check, something like

if (this.element.decorationsElement.parentElement)
    this.element.decorationsElement.parentElement.removeChild(this.element.decorationsElement);

The node.contains() method is potentially slower, since it will check all the element's descendants, not only immediate children.
Comment 3 Andrey Lushnikov 2013-02-01 14:29:31 PST
Comment on attachment 186134 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=186134&action=review

>> Source/WebCore/inspector/front-end/DefaultTextEditor.js:2931
>> +            if (this.element.contains(this.element.decorationsElement))
> 
> We usually use the parentElement check, something like
> 
> if (this.element.decorationsElement.parentElement)
>     this.element.decorationsElement.parentElement.removeChild(this.element.decorationsElement);
> 
> The node.contains() method is potentially slower, since it will check all the element's descendants, not only immediate children.

That is reasonable!
Comment 4 Andrey Lushnikov 2013-02-01 15:15:01 PST
Created attachment 186157 [details]
Patch
Comment 5 Alexander Pavlov (apavlov) 2013-02-01 16:44:01 PST
Comment on attachment 186157 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=186157&action=review

> Source/WebCore/inspector/front-end/DefaultTextEditor.js:2931
> +            if (this.element.decorationsElement.parentElement)

I DO hope the parentElement is guaranteed to be this.element
Comment 6 WebKit Review Bot 2013-02-01 18:19:05 PST
Comment on attachment 186157 [details]
Patch

Clearing flags on attachment: 186157

Committed r141673: <http://trac.webkit.org/changeset/141673>
Comment 7 WebKit Review Bot 2013-02-01 18:19:09 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 Pavel Feldman 2013-02-02 04:11:09 PST
Comment on attachment 186157 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=186157&action=review

>> Source/WebCore/inspector/front-end/DefaultTextEditor.js:2931
>> +            if (this.element.decorationsElement.parentElement)
> 
> I DO hope the parentElement is guaranteed to be this.element

Should have been this.element.decorationElement.removeSelf();