Title: [175388] trunk/Source
- Revision
- 175388
- Author
- [email protected]
- Date
- 2014-10-30 15:37:50 -0700 (Thu, 30 Oct 2014)
Log Message
Long spins under rangeExpandedAroundPosition on Yahoo Mail
https://bugs.webkit.org/show_bug.cgi?id=138223
<rdar://problem/18819547>
Reviewed by Enrica Casucci.
* WebCore.exp.in:
Export some things.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::rangeExpandedAroundPositionByCharacters):
Reimplement rangeExpandedAroundPosition to operate on characters instead of lines,
and to use Position. Moving VisiblePositions by line can be very expensive in some cases,
and for generating lookup/Data Detectors context, we don't care about that kind of precision.
This makes this function ~1000x faster when it hits on a row in the Yahoo Mail message list.
(WebKit::WebPage::performDictionaryLookupAtLocation):
(WebKit::scanForDataDetectedItems):
Adopt the new rangeExpandedAroundPositionByCharacters, expanding 250 characters
before and after, which roughly matches what we were usually getting going by line,
and is a reasonable amount of context for these operations.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (175387 => 175388)
--- trunk/Source/WebCore/ChangeLog 2014-10-30 22:33:55 UTC (rev 175387)
+++ trunk/Source/WebCore/ChangeLog 2014-10-30 22:37:50 UTC (rev 175388)
@@ -1,3 +1,14 @@
+2014-10-30 Tim Horton <[email protected]>
+
+ Long spins under rangeExpandedAroundPosition on Yahoo Mail
+ https://bugs.webkit.org/show_bug.cgi?id=138223
+ <rdar://problem/18819547>
+
+ Reviewed by Enrica Casucci.
+
+ * WebCore.exp.in:
+ Export some things.
+
2014-10-30 Ada Chan <[email protected]>
The Page's muted setting should not affect the HTMLMediaElement's 'muted' IDL attribute.
Modified: trunk/Source/WebCore/WebCore.exp.in (175387 => 175388)
--- trunk/Source/WebCore/WebCore.exp.in 2014-10-30 22:33:55 UTC (rev 175387)
+++ trunk/Source/WebCore/WebCore.exp.in 2014-10-30 22:37:50 UTC (rev 175388)
@@ -1048,6 +1048,7 @@
__ZN7WebCore25addLanguageChangeObserverEPvPFvS0_E
__ZN7WebCore25computeViewportAttributesENS_17ViewportArgumentsEiiifNS_7IntSizeE
__ZN7WebCore25createCanonicalUUIDStringEv
+__ZN7WebCore25directionOfEnclosingBlockERKNS_8PositionE
__ZN7WebCore25getOutOfLineCachedWrapperEPNS_17JSDOMGlobalObjectEPNS_4NodeE
__ZN7WebCore25updateRedirectChainStatusERNS_24RedirectChainCacheStatusERKNS_16ResourceResponseE
__ZN7WebCore26ContextDestructionObserver16contextDestroyedEv
@@ -2043,6 +2044,8 @@
__ZNK7WebCore8Position25leadingWhitespacePositionENS_9EAffinityEb
__ZNK7WebCore8Position26trailingWhitespacePositionENS_9EAffinityEb
__ZNK7WebCore8Position28offsetForPositionAfterAnchorEv
+__ZNK7WebCore8Position4nextENS_16PositionMoveTypeE
+__ZNK7WebCore8Position8previousENS_16PositionMoveTypeE
__ZNK7WebCore8Position8upstreamENS_27EditingBoundaryCrossingRuleE
__ZNK7WebCore8Settings15fixedFontFamilyE11UScriptCode
__ZNK7WebCore8Settings15serifFontFamilyE11UScriptCode
Modified: trunk/Source/WebKit2/ChangeLog (175387 => 175388)
--- trunk/Source/WebKit2/ChangeLog 2014-10-30 22:33:55 UTC (rev 175387)
+++ trunk/Source/WebKit2/ChangeLog 2014-10-30 22:37:50 UTC (rev 175388)
@@ -1,3 +1,24 @@
+2014-10-30 Tim Horton <[email protected]>
+
+ Long spins under rangeExpandedAroundPosition on Yahoo Mail
+ https://bugs.webkit.org/show_bug.cgi?id=138223
+ <rdar://problem/18819547>
+
+ Reviewed by Enrica Casucci.
+
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::rangeExpandedAroundPositionByCharacters):
+ Reimplement rangeExpandedAroundPosition to operate on characters instead of lines,
+ and to use Position. Moving VisiblePositions by line can be very expensive in some cases,
+ and for generating lookup/Data Detectors context, we don't care about that kind of precision.
+ This makes this function ~1000x faster when it hits on a row in the Yahoo Mail message list.
+
+ (WebKit::WebPage::performDictionaryLookupAtLocation):
+ (WebKit::scanForDataDetectedItems):
+ Adopt the new rangeExpandedAroundPositionByCharacters, expanding 250 characters
+ before and after, which roughly matches what we were usually getting going by line,
+ and is a reasonable amount of context for these operations.
+
2014-10-30 Brady Eidson <[email protected]>
IndexedDB is deleting data when a PK is shared amongst two objectStores
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (175387 => 175388)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2014-10-30 22:33:55 UTC (rev 175387)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2014-10-30 22:37:50 UTC (rev 175388)
@@ -501,32 +501,23 @@
return isPositionInRange(position, selectedRange.get());
}
-static PassRefPtr<Range> rangeExpandedAroundPosition(const VisiblePosition& position, int numberOfLinesToExpand)
+static PassRefPtr<Range> rangeExpandedAroundPositionByCharacters(const VisiblePosition& position, int numberOfCharactersToExpand)
{
- VisiblePosition contextStart = position;
- VisiblePosition contextEnd = position;
- for (int i = 0; i < numberOfLinesToExpand; i++) {
- VisiblePosition n = previousLinePosition(contextStart, contextStart.lineDirectionPointForBlockDirectionNavigation());
- if (n.isNull() || n == contextStart)
- break;
- contextStart = n;
+ Position start = position.deepEquivalent();
+ Position end = position.deepEquivalent();
+ for (int i = 0; i < numberOfCharactersToExpand; ++i) {
+ if (directionOfEnclosingBlock(start) == LTR)
+ start = start.previous(Character);
+ else
+ start = start.next(Character);
+
+ if (directionOfEnclosingBlock(end) == LTR)
+ end = end.next(Character);
+ else
+ end = end.previous(Character);
}
- for (int i = 0; i < numberOfLinesToExpand; i++) {
- VisiblePosition n = nextLinePosition(contextEnd, contextEnd.lineDirectionPointForBlockDirectionNavigation());
- if (n.isNull() || n == contextEnd)
- break;
- contextEnd = n;
- }
- VisiblePosition lineStart = startOfLine(contextStart);
- if (!lineStart.isNull())
- contextStart = lineStart;
-
- VisiblePosition lineEnd = endOfLine(contextEnd);
- if (!lineEnd.isNull())
- contextEnd = lineEnd;
-
- return makeRange(contextStart, contextEnd);
+ return makeRange(start, end);
}
PassRefPtr<Range> WebPage::rangeForDictionaryLookupAtHitTestResult(const WebCore::HitTestResult& hitTestResult, NSDictionary **options)
@@ -557,8 +548,8 @@
return nullptr;
}
- // As context, we are going to use four lines of text before and after the point. (Dictionary can sometimes look up things that are four lines long)
- RefPtr<Range> fullCharacterRange = rangeExpandedAroundPosition(position, 4);
+ // As context, we are going to use 250 characters of text before and after the point.
+ RefPtr<Range> fullCharacterRange = rangeExpandedAroundPositionByCharacters(position, 250);
NSRange rangeToPass = NSMakeRange(TextIterator::rangeLength(makeRange(fullCharacterRange->startPosition(), position).get()), 0);
String fullPlainTextString = plainText(fullCharacterRange.get());
@@ -1090,7 +1081,7 @@
if (position.isNull())
position = firstPositionInOrBeforeNode(node);
- RefPtr<Range> contextRange = rangeExpandedAroundPosition(position, 4);
+ RefPtr<Range> contextRange = rangeExpandedAroundPositionByCharacters(position, 250);
if (!contextRange)
return nullptr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes