Changeset 20998 in webkit


Ignore:
Timestamp:
Apr 21, 2007, 3:31:09 PM (18 years ago)
Author:
hyatt
Message:

Fix for bug 13432, determineFlowSpacing is O(n2).

Reviewed by aroben

  • rendering/InlineBox.cpp: (WebCore::InlineBox::nextOnLineExists): (WebCore::InlineBox::prevOnLineExists):
  • rendering/InlineBox.h: (WebCore::InlineBox::InlineBox):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/WebCore/ChangeLog

    r20997 r20998  
     12007-04-21  David Hyatt  <hyatt@apple.com>
     2
     3        Fix for bug 13432, determineFlowSpacing is O(n^2).
     4
     5        Reviewed by aroben
     6
     7        * rendering/InlineBox.cpp:
     8        (WebCore::InlineBox::nextOnLineExists):
     9        (WebCore::InlineBox::prevOnLineExists):
     10        * rendering/InlineBox.h:
     11        (WebCore::InlineBox::InlineBox):
     12
    1132007-04-21  Lamar Goddard <lamargoddard@gmail.com>
    214
  • TabularUnified trunk/WebCore/rendering/InlineBox.cpp

    r20495 r20998  
    180180bool InlineBox::nextOnLineExists() const
    181181{
    182     if (!parent())
    183         return false;
    184    
    185     if (nextOnLine())
    186         return true;
    187    
    188     return parent()->nextOnLineExists();
     182    if (!m_determinedIfNextOnLineExists) {
     183        m_determinedIfNextOnLineExists = true;
     184
     185        if (!parent())
     186            m_nextOnLineExists = false;
     187        else if (nextOnLine())
     188            m_nextOnLineExists = true;
     189        else
     190            m_nextOnLineExists = parent()->nextOnLineExists();
     191    }
     192    return m_nextOnLineExists;
    189193}
    190194
    191195bool InlineBox::prevOnLineExists() const
    192196{
    193     if (!parent())
    194         return false;
    195    
    196     if (prevOnLine())
    197         return true;
    198    
    199     return parent()->prevOnLineExists();
     197    if (!m_determinedIfPrevOnLineExists) {
     198        m_determinedIfPrevOnLineExists = true;
     199       
     200        if (!parent())
     201            m_prevOnLineExists = false;
     202        else if (prevOnLine())
     203            m_prevOnLineExists = true;
     204        else
     205            m_prevOnLineExists = parent()->prevOnLineExists();
     206    }
     207    return m_prevOnLineExists;
    200208}
    201209
  • TabularUnified trunk/WebCore/rendering/InlineBox.h

    r20103 r20998  
    5959        , m_reversed(false)
    6060        , m_treatAsText(true)
     61        , m_determinedIfNextOnLineExists(false)
     62        , m_determinedIfPrevOnLineExists(false)
     63        , m_nextOnLineExists(false)
     64        , m_prevOnLineExists(false)
    6165        , m_toAdd(0)
    6266    {
     
    8690        , m_reversed(false)
    8791        , m_treatAsText(true)
     92        , m_determinedIfNextOnLineExists(false)
     93        , m_determinedIfPrevOnLineExists(false)
     94        , m_nextOnLineExists(false)
     95        , m_prevOnLineExists(false)
    8896        , m_toAdd(0)
    8997    {
     
    234242    bool m_dirOverride : 1;
    235243    bool m_treatAsText : 1; // Whether or not to treat a <br> as text for the purposes of line height.
     244    mutable bool m_determinedIfNextOnLineExists : 1;
     245    mutable bool m_determinedIfPrevOnLineExists : 1;
     246    mutable bool m_nextOnLineExists : 1;
     247    mutable bool m_prevOnLineExists : 1;
    236248    int m_toAdd : 13; // for justified text
    237249};
Note: See TracChangeset for help on using the changeset viewer.