Bug 136763 - Simplify DOM tree traversal in FrameSelection::setSelectionFromNone()
Summary: Simplify DOM tree traversal in FrameSelection::setSelectionFromNone()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-11 15:39 PDT by Chris Dumez
Modified: 2014-09-12 07:51 PDT (History)
2 users (show)

See Also:


Attachments
Patch (2.26 KB, patch)
2014-09-11 15:51 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2014-09-11 15:39:11 PDT
Simplify DOM Tree traversal in FrameSelection::setSelectionFromNone(). We only need to traverse the direct children of the Document element to find the body. The previous code was potentially traversing descendants.
The new code is consistent with Document::body() except that we only look for an HTMLBodyElement (and ignore HTMLFrameSetElement).
Comment 1 Chris Dumez 2014-09-11 15:51:47 PDT
Created attachment 237992 [details]
Patch
Comment 2 Ryosuke Niwa 2014-09-11 16:58:34 PDT
Comment on attachment 237992 [details]
Patch

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

> Source/WebCore/editing/FrameSelection.cpp:2117
> +    Element* documentElement = document->documentElement();
> +    if (!documentElement)
> +        return;

If I were you, I'd declare documentElement inside the if condition and nest the if's.
Comment 3 WebKit Commit Bot 2014-09-11 17:40:20 PDT
Comment on attachment 237992 [details]
Patch

Clearing flags on attachment: 237992

Committed r173549: <http://trac.webkit.org/changeset/173549>
Comment 4 WebKit Commit Bot 2014-09-11 17:40:23 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Darin Adler 2014-09-11 18:46:21 PDT
Comment on attachment 237992 [details]
Patch

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

> Source/WebCore/editing/FrameSelection.cpp:2115
> +    Element* documentElement = document->documentElement();

In a case like this I prefer to use auto*. Later we might make the documentElement() function return a more specific type and it would be nice not to have to visit this call site.
Comment 6 Chris Dumez 2014-09-12 07:51:40 PDT
Comment on attachment 237992 [details]
Patch

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

>> Source/WebCore/editing/FrameSelection.cpp:2115
>> +    Element* documentElement = document->documentElement();
> 
> In a case like this I prefer to use auto*. Later we might make the documentElement() function return a more specific type and it would be nice not to have to visit this call site.

Ok, it makes sense. Would you like me to land another patch for the nit fix or is this for future reference?