⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 173549 in webkit


Ignore:
Timestamp:
Sep 11, 2014, 5:40:09 PM (12 years ago)
Author:
Chris Dumez
Message:

Simplify DOM tree traversal in FrameSelection::setSelectionFromNone()
​https://bugs.webkit.org/show_bug.cgi?id=136763

Reviewed by Ryosuke Niwa.

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).

Also update the code to use tighter typing for clarity.

No new tests, no behavior change.

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::setSelectionFromNone):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r173548 r173549  
     12014-09-11  Chris Dumez  <cdumez@apple.com>
     2
     3        Simplify DOM tree traversal in FrameSelection::setSelectionFromNone()
     4        https://bugs.webkit.org/show_bug.cgi?id=136763
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        We only need to traverse the direct children of the Document element to
     9        find the body. The previous code was potentially traversing descendants.
     10        The new code is consistent with Document::body() except that we only
     11        look for an HTMLBodyElement (and ignore HTMLFrameSetElement).
     12
     13        Also update the code to use tighter typing for clarity.
     14
     15        No new tests, no behavior change.
     16
     17        * editing/FrameSelection.cpp:
     18        (WebCore::FrameSelection::setSelectionFromNone):
     19
    1202014-09-11  Chris Fleizach  <cfleizach@apple.com>
    221
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r173246 r173549  
    4242#include "FrameView.h"
    4343#include "GraphicsContext.h"
     44#include "HTMLBodyElement.h"
    4445#include "HTMLFormElement.h"
    4546#include "HTMLFrameElementBase.h"
    … …  
    21122113#endif
    21132114
    2114     Node* node = document->documentElement();
    2115     while (node && !node->hasTagName(bodyTag))
    2116         node = NodeTraversal::next(node);
    2117     if (node)
    2118         setSelection(VisibleSelection(firstPositionInOrBeforeNode(node), DOWNSTREAM));
     2115    Element* documentElement = document->documentElement();
     2116    if (!documentElement)
     2117        return;
     2118    if (auto body = childrenOfType<HTMLBodyElement>(*documentElement).first())
     2119        setSelection(VisibleSelection(firstPositionInOrBeforeNode(body), DOWNSTREAM));
    21192120}
    21202121
Note: See TracChangeset for help on using the changeset viewer.