Changeset 185287 in webkit


Ignore:
Timestamp:
Jun 6, 2015 1:21:20 AM (9 years ago)
Author:
rniwa@webkit.org
Message:

Typing is slow in Gmail on iPads
https://bugs.webkit.org/show_bug.cgi?id=145686

Reviewed by Enrica Casucci.

The bug was caused by nextCandidate and nextVisuallyDistinctCandidate traversing through each character
in a text node without a renderer. Skip any node that doesn't have a renderer in both of those functions
and corresponding previous* functions.

It's fine to skip unrendered nodes in PositionIterator because only other clients of PositionIterator
are Position::upstream and Position::downstream and they don't care about un-rendered nodes either.

  • dom/PositionIterator.cpp:

(WebCore::PositionIterator::increment):
(WebCore::PositionIterator::decrement):

  • editing/htmlediting.cpp:

(WebCore::nextVisuallyDistinctCandidate):
(WebCore::previousVisuallyDistinctCandidate):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185286 r185287  
     12015-06-06  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Typing is slow in Gmail on iPads
     4        https://bugs.webkit.org/show_bug.cgi?id=145686
     5
     6        Reviewed by Enrica Casucci.
     7
     8        The bug was caused by nextCandidate and nextVisuallyDistinctCandidate traversing through each character
     9        in a text node without a renderer. Skip any node that doesn't have a renderer in both of those functions
     10        and corresponding previous* functions.
     11
     12        It's fine to skip unrendered nodes in PositionIterator because only other clients of PositionIterator
     13        are Position::upstream and Position::downstream and they don't care about un-rendered nodes either.
     14
     15        * dom/PositionIterator.cpp:
     16        (WebCore::PositionIterator::increment):
     17        (WebCore::PositionIterator::decrement):
     18        * editing/htmlediting.cpp:
     19        (WebCore::nextVisuallyDistinctCandidate):
     20        (WebCore::previousVisuallyDistinctCandidate):
     21
    1222015-06-06  Mark Lam  <mark.lam@apple.com>
    223
  • trunk/Source/WebCore/dom/PositionIterator.cpp

    r180726 r185287  
    6767    }
    6868
    69     if (!m_anchorNode->hasChildNodes() && m_offsetInAnchor < lastOffsetForEditing(m_anchorNode))
     69    if (m_anchorNode->renderer() && !m_anchorNode->hasChildNodes() && m_offsetInAnchor < lastOffsetForEditing(m_anchorNode))
    7070        m_offsetInAnchor = Position::uncheckedNextOffset(m_anchorNode, m_offsetInAnchor);
    7171    else {
     
    9999        m_offsetInAnchor = m_anchorNode->hasChildNodes()? 0: lastOffsetForEditing(m_anchorNode);
    100100    } else {
    101         if (m_offsetInAnchor)
     101        if (m_offsetInAnchor && m_anchorNode->renderer())
    102102            m_offsetInAnchor = Position::uncheckedPreviousOffset(m_anchorNode, m_offsetInAnchor);
    103103        else {
  • trunk/Source/WebCore/editing/htmlediting.cpp

    r180809 r185287  
    243243Position nextVisuallyDistinctCandidate(const Position& position)
    244244{
     245    // FIXME: Use PositionIterator instead.
    245246    Position p = position;
    246247    Position downstreamStart = p.downstream();
     
    249250        if (p.isCandidate() && p.downstream() != downstreamStart)
    250251            return p;
     252        if (auto* node = p.containerNode()) {
     253            if (!node->renderer())
     254                p = lastPositionInOrAfterNode(node);
     255        }
    251256    }
    252257    return Position();
     
    266271Position previousVisuallyDistinctCandidate(const Position& position)
    267272{
     273    // FIXME: Use PositionIterator instead.
    268274    Position p = position;
    269275    Position downstreamStart = p.downstream();
     
    272278        if (p.isCandidate() && p.downstream() != downstreamStart)
    273279            return p;
     280        if (auto* node = p.containerNode()) {
     281            if (!node->renderer())
     282                p = firstPositionInOrBeforeNode(node);
     283        }
    274284    }
    275285    return Position();
Note: See TracChangeset for help on using the changeset viewer.