Changeset 137119 in webkit


Ignore:
Timestamp:
Dec 10, 2012 1:03:06 AM (11 years ago)
Author:
morrita@google.com
Message:

[Shadow DOM][Refacdtoring] nextTo() and previousTo() can be part of ContentDistribution
https://bugs.webkit.org/show_bug.cgi?id=104514

Reviewed by Kentaro Hara.

InsertionPoint::nextTo() and InsertionPoint::previousTo() are an
query to distributed nodes, which is what ContentDistribution
represents. We can move them to better home.

No new tests. No behavior change.

  • html/shadow/ContentDistributor.cpp:

(WebCore::ContentDistribution::nextTo): Moved from InsertionPoint
(WebCore):
(WebCore::ContentDistribution::previousTo): Moved from InsertionPoint

  • html/shadow/ContentDistributor.h:

(ContentDistribution):

  • html/shadow/InsertionPoint.cpp:
  • html/shadow/InsertionPoint.h:

(WebCore::InsertionPoint::nextTo): Delegated to ContentDistribution
(WebCore::InsertionPoint::previousTo): Delegated to ContentDistribution

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r137114 r137119  
     12012-12-10  Hajime Morrita  <morrita@google.com>
     2
     3        [Shadow DOM][Refacdtoring] nextTo() and previousTo() can be part of ContentDistribution
     4        https://bugs.webkit.org/show_bug.cgi?id=104514
     5
     6        Reviewed by Kentaro Hara.
     7
     8        InsertionPoint::nextTo() and InsertionPoint::previousTo() are an
     9        query to distributed nodes, which is what ContentDistribution
     10        represents. We can move them to better home.
     11
     12        No new tests. No behavior change.
     13
     14        * html/shadow/ContentDistributor.cpp:
     15        (WebCore::ContentDistribution::nextTo): Moved from InsertionPoint
     16        (WebCore):
     17        (WebCore::ContentDistribution::previousTo): Moved from InsertionPoint
     18        * html/shadow/ContentDistributor.h:
     19        (ContentDistribution):
     20        * html/shadow/InsertionPoint.cpp:
     21        * html/shadow/InsertionPoint.h:
     22        (WebCore::InsertionPoint::nextTo): Delegated to ContentDistribution
     23        (WebCore::InsertionPoint::previousTo): Delegated to ContentDistribution
     24
    1252012-12-10  Joanmarie Diggs  <jdiggs@igalia.com>
    226
  • trunk/Source/WebCore/html/shadow/ContentDistributor.cpp

    r136924 r137119  
    5959}
    6060
     61Node* ContentDistribution::nextTo(const Node* node) const
     62{
     63    size_t index = find(node);
     64    if (index == notFound || index + 1 == size())
     65        return 0;
     66    return at(index + 1).get();
     67}
     68
     69Node* ContentDistribution::previousTo(const Node* node) const
     70{
     71    size_t index = find(node);
     72    if (index == notFound || !index)
     73        return 0;
     74    return at(index - 1).get();
     75}
     76
     77
    6178ShadowRootContentDistributionData::ShadowRootContentDistributionData()
    6279    : m_insertionPointAssignedTo(0)
  • trunk/Source/WebCore/html/shadow/ContentDistributor.h

    r136098 r137119  
    5959    bool contains(const Node* node) const { return m_indices.contains(node); }
    6060    size_t find(const Node*) const;
     61    Node* nextTo(const Node*) const;
     62    Node* previousTo(const Node*) const;
    6163
    6264    void swap(ContentDistribution& other);
  • trunk/Source/WebCore/html/shadow/InsertionPoint.cpp

    r137112 r137119  
    113113}
    114114
    115 Node* InsertionPoint::nextTo(const Node* node) const
    116 {
    117     size_t index = m_distribution.find(node);
    118     if (index == notFound || index + 1 == m_distribution.size())
    119         return 0;
    120     return m_distribution.at(index + 1).get();
    121 }
    122 
    123 Node* InsertionPoint::previousTo(const Node* node) const
    124 {
    125     size_t index = m_distribution.find(node);
    126     if (index == notFound || !index)
    127         return 0;
    128     return m_distribution.at(index - 1).get();
    129 }
    130 
    131115void InsertionPoint::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
    132116{
  • trunk/Source/WebCore/html/shadow/InsertionPoint.h

    r137112 r137119  
    7272    Node* first() const { return m_distribution.isEmpty() ? 0 : m_distribution.first().get(); }
    7373    Node* last() const { return m_distribution.isEmpty() ? 0 : m_distribution.last().get(); }
    74     Node* nextTo(const Node*) const;
    75     Node* previousTo(const Node*) const;
     74    Node* nextTo(const Node* node) const { return m_distribution.nextTo(node); }
     75    Node* previousTo(const Node* node) const { return m_distribution.previousTo(node); }
    7676
    7777protected:
Note: See TracChangeset for help on using the changeset viewer.