Changeset 147008 in webkit


Ignore:
Timestamp:
Mar 27, 2013 1:51:11 PM (11 years ago)
Author:
rniwa@webkit.org
Message:

Selection code spends a lot of time in InlineTextBox::localSelectionRect
https://bugs.webkit.org/show_bug.cgi?id=113364

Reviewed by Enrica Casucci.

Avoid computing the font width when we're selecting the entire line box.

This appears to be 25-26% improvement on Interactive/SelectAll:Time.

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::localSelectionRect):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147004 r147008  
     12013-03-27  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Selection code spends a lot of time in InlineTextBox::localSelectionRect
     4        https://bugs.webkit.org/show_bug.cgi?id=113364
     5
     6        Reviewed by Enrica Casucci.
     7
     8        Avoid computing the font width when we're selecting the entire line box.
     9
     10        This appears to be 25-26% improvement on Interactive/SelectAll:Time.
     11
     12        * rendering/InlineTextBox.cpp:
     13        (WebCore::InlineTextBox::localSelectionRect):
     14
    1152013-03-26  Timothy Hatcher  <timothy@apple.com>
    216
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r146104 r147008  
    207207        endPos = textRun.length();
    208208
    209     LayoutRect r = enclosingIntRect(font.selectionRectForText(textRun, FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos));
     209    FloatPoint startingPoint = FloatPoint(logicalLeft(), selTop);
     210    LayoutRect r;
     211    if (sPos || ePos != static_cast<int>(m_len))
     212        r = enclosingIntRect(font.selectionRectForText(textRun, startingPoint, selHeight, sPos, ePos));
     213    else // Avoid computing the font width when the entire line box is selected as an optimization.
     214        r = enclosingIntRect(FloatRect(startingPoint, FloatSize(m_logicalWidth, selHeight)));
    210215
    211216    LayoutUnit logicalWidth = r.width();
Note: See TracChangeset for help on using the changeset viewer.