Title: [185287] trunk/Source/WebCore
Revision
185287
Author
[email protected]
Date
2015-06-06 01:21:20 -0700 (Sat, 06 Jun 2015)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (185286 => 185287)


--- trunk/Source/WebCore/ChangeLog	2015-06-06 07:55:21 UTC (rev 185286)
+++ trunk/Source/WebCore/ChangeLog	2015-06-06 08:21:20 UTC (rev 185287)
@@ -1,3 +1,24 @@
+2015-06-06  Ryosuke Niwa  <[email protected]>
+
+        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):
+
 2015-06-06  Mark Lam  <[email protected]>
 
         Returned Exception* values need to be initialized to nullptr when no exceptions are thrown.

Modified: trunk/Source/WebCore/dom/PositionIterator.cpp (185286 => 185287)


--- trunk/Source/WebCore/dom/PositionIterator.cpp	2015-06-06 07:55:21 UTC (rev 185286)
+++ trunk/Source/WebCore/dom/PositionIterator.cpp	2015-06-06 08:21:20 UTC (rev 185287)
@@ -66,7 +66,7 @@
         return;
     }
 
-    if (!m_anchorNode->hasChildNodes() && m_offsetInAnchor < lastOffsetForEditing(m_anchorNode))
+    if (m_anchorNode->renderer() && !m_anchorNode->hasChildNodes() && m_offsetInAnchor < lastOffsetForEditing(m_anchorNode))
         m_offsetInAnchor = Position::uncheckedNextOffset(m_anchorNode, m_offsetInAnchor);
     else {
         m_nodeAfterPositionInAnchor = m_anchorNode;
@@ -98,7 +98,7 @@
         m_anchorNode = m_anchorNode->lastChild();
         m_offsetInAnchor = m_anchorNode->hasChildNodes()? 0: lastOffsetForEditing(m_anchorNode);
     } else {
-        if (m_offsetInAnchor)
+        if (m_offsetInAnchor && m_anchorNode->renderer())
             m_offsetInAnchor = Position::uncheckedPreviousOffset(m_anchorNode, m_offsetInAnchor);
         else {
             m_nodeAfterPositionInAnchor = m_anchorNode;

Modified: trunk/Source/WebCore/editing/htmlediting.cpp (185286 => 185287)


--- trunk/Source/WebCore/editing/htmlediting.cpp	2015-06-06 07:55:21 UTC (rev 185286)
+++ trunk/Source/WebCore/editing/htmlediting.cpp	2015-06-06 08:21:20 UTC (rev 185287)
@@ -242,12 +242,17 @@
 
 Position nextVisuallyDistinctCandidate(const Position& position)
 {
+    // FIXME: Use PositionIterator instead.
     Position p = position;
     Position downstreamStart = p.downstream();
     while (!p.atEndOfTree()) {
         p = p.next(Character);
         if (p.isCandidate() && p.downstream() != downstreamStart)
             return p;
+        if (auto* node = p.containerNode()) {
+            if (!node->renderer())
+                p = lastPositionInOrAfterNode(node);
+        }
     }
     return Position();
 }
@@ -265,12 +270,17 @@
 
 Position previousVisuallyDistinctCandidate(const Position& position)
 {
+    // FIXME: Use PositionIterator instead.
     Position p = position;
     Position downstreamStart = p.downstream();
     while (!p.atStartOfTree()) {
         p = p.previous(Character);
         if (p.isCandidate() && p.downstream() != downstreamStart)
             return p;
+        if (auto* node = p.containerNode()) {
+            if (!node->renderer())
+                p = firstPositionInOrBeforeNode(node);
+        }
     }
     return Position();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to