| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2012 Google Inc. All rights reserved. | 2  * Copyright (C) 2012 Google Inc. All rights reserved. | 
| 3  * | 3  * | 
| 4  * Redistribution and use in source and binary forms, with or without | 4  * Redistribution and use in source and binary forms, with or without | 
| 5  * modification, are permitted provided that the following conditions are | 5  * modification, are permitted provided that the following conditions are | 
| 6  * met: | 6  * met: | 
| 7  * | 7  * | 
| 8  *     * Redistributions of source code must retain the above copyright | 8  *     * Redistributions of source code must retain the above copyright | 
| 9  * notice, this list of conditions and the following disclaimer. | 9  * notice, this list of conditions and the following disclaimer. | 
| 10  *     * Redistributions in binary form must reproduce the above | 10  *     * Redistributions in binary form must reproduce the above | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 49 } | 49 } | 
| 50 | 50 | 
| 51 InsertionPoint::~InsertionPoint() | 51 InsertionPoint::~InsertionPoint() | 
| 52 { | 52 { | 
| 53 } | 53 } | 
| 54 | 54 | 
| 55 void InsertionPoint::setDistribution(ContentDistribution& distribution) | 55 void InsertionPoint::setDistribution(ContentDistribution& distribution) | 
| 56 { | 56 { | 
| 57     if (shouldUseFallbackElements()) { | 57     if (shouldUseFallbackElements()) { | 
| 58         for (Node* child = firstChild(); child; child = child->nextSibling()) | 58         for (Node* child = firstChild(); child; child = child->nextSibling()) | 
| 59             child->lazyReattachIfAttached(); | 59             child->scheduleRenderTreeRecreationIfAttached(); | 
| 60     } | 60     } | 
| 61 | 61 | 
| 62     // Attempt not to reattach nodes that would be distributed to the exact same | 62     // Attempt not to reattach nodes that would be distributed to the exact same | 
| 63     // location by comparing the old and new distributions. | 63     // location by comparing the old and new distributions. | 
| 64 | 64 | 
| 65     size_t i = 0; | 65     size_t i = 0; | 
| 66     size_t j = 0; | 66     size_t j = 0; | 
| 67 | 67 | 
| 68     for ( ; i < m_distribution.size() && j < distribution.size(); ++i, ++j) { | 68     for ( ; i < m_distribution.size() && j < distribution.size(); ++i, ++j) { | 
| 69         if (m_distribution.size() < distribution.size()) { | 69         if (m_distribution.size() < distribution.size()) { | 
| 70             // If the new distribution is larger than the old one, reattach all 
     nodes in | 70             // If the new distribution is larger than the old one, reattach all 
     nodes in | 
| 71             // the new distribution that were inserted. | 71             // the new distribution that were inserted. | 
| 72             for ( ; j < distribution.size() && m_distribution.at(i) != distribut
     ion.at(j); ++j) | 72             for ( ; j < distribution.size() && m_distribution.at(i) != distribut
     ion.at(j); ++j) | 
| 73                 distribution.at(j)->lazyReattachIfAttached(); | 73                 distribution.at(j)->scheduleRenderTreeRecreationIfAttached(); | 
| 74         } else if (m_distribution.size() > distribution.size()) { | 74         } else if (m_distribution.size() > distribution.size()) { | 
| 75             // If the old distribution is larger than the new one, reattach all 
     nodes in | 75             // If the old distribution is larger than the new one, reattach all 
     nodes in | 
| 76             // the old distribution that were removed. | 76             // the old distribution that were removed. | 
| 77             for ( ; i < m_distribution.size() && m_distribution.at(i) != distrib
     ution.at(j); ++i) | 77             for ( ; i < m_distribution.size() && m_distribution.at(i) != distrib
     ution.at(j); ++i) | 
| 78                 m_distribution.at(i)->lazyReattachIfAttached(); | 78                 m_distribution.at(i)->scheduleRenderTreeRecreationIfAttached(); | 
| 79         } else if (m_distribution.at(i) != distribution.at(j)) { | 79         } else if (m_distribution.at(i) != distribution.at(j)) { | 
| 80             // If both distributions are the same length reattach both old and n
     ew. | 80             // If both distributions are the same length reattach both old and n
     ew. | 
| 81             m_distribution.at(i)->lazyReattachIfAttached(); | 81             m_distribution.at(i)->scheduleRenderTreeRecreationIfAttached(); | 
| 82             distribution.at(j)->lazyReattachIfAttached(); | 82             distribution.at(j)->scheduleRenderTreeRecreationIfAttached(); | 
| 83         } | 83         } | 
| 84     } | 84     } | 
| 85 | 85 | 
| 86     // If we hit the end of either list above we need to reattach all remaining 
     nodes. | 86     // If we hit the end of either list above we need to reattach all remaining 
     nodes. | 
| 87 | 87 | 
| 88     for ( ; i < m_distribution.size(); ++i) | 88     for ( ; i < m_distribution.size(); ++i) | 
| 89         m_distribution.at(i)->lazyReattachIfAttached(); | 89         m_distribution.at(i)->scheduleRenderTreeRecreationIfAttached(); | 
| 90 | 90 | 
| 91     for ( ; j < distribution.size(); ++j) | 91     for ( ; j < distribution.size(); ++j) | 
| 92         distribution.at(j)->lazyReattachIfAttached(); | 92         distribution.at(j)->scheduleRenderTreeRecreationIfAttached(); | 
| 93 | 93 | 
| 94     m_distribution.swap(distribution); | 94     m_distribution.swap(distribution); | 
| 95     m_distribution.shrinkToFit(); | 95     m_distribution.shrinkToFit(); | 
| 96 } | 96 } | 
| 97 | 97 | 
| 98 void InsertionPoint::attach(const AttachContext& context) | 98 void InsertionPoint::createRenderTree(const AttachContext& context) | 
| 99 { | 99 { | 
| 100     // FIXME: This loop shouldn't be needed since the distributed nodes should | 100     // FIXME: This loop shouldn't be needed since the distributed nodes should | 
| 101     // never be detached, we can probably remove it. | 101     // never be detached, we can probably remove it. | 
| 102     for (size_t i = 0; i < m_distribution.size(); ++i) { | 102     for (size_t i = 0; i < m_distribution.size(); ++i) { | 
| 103         if (!m_distribution.at(i)->attached()) | 103         if (!m_distribution.at(i)->attached()) | 
| 104             m_distribution.at(i)->attach(context); | 104             m_distribution.at(i)->createRenderTree(context); | 
| 105     } | 105     } | 
| 106 | 106 | 
| 107     HTMLElement::attach(context); | 107     HTMLElement::createRenderTree(context); | 
| 108 } | 108 } | 
| 109 | 109 | 
| 110 void InsertionPoint::detach(const AttachContext& context) | 110 void InsertionPoint::destroyRenderTree(const AttachContext& context) | 
| 111 { | 111 { | 
| 112     for (size_t i = 0; i < m_distribution.size(); ++i) | 112     for (size_t i = 0; i < m_distribution.size(); ++i) | 
| 113         m_distribution.at(i)->lazyReattachIfAttached(); | 113         m_distribution.at(i)->scheduleRenderTreeRecreationIfAttached(); | 
| 114 | 114 | 
| 115     HTMLElement::detach(context); | 115     HTMLElement::destroyRenderTree(context); | 
| 116 } | 116 } | 
| 117 | 117 | 
| 118 void InsertionPoint::willRecalcStyle(StyleRecalcChange change) | 118 void InsertionPoint::willRecalcStyle(StyleRecalcChange change) | 
| 119 { | 119 { | 
| 120     if (change < Inherit) | 120     if (change < Inherit) | 
| 121         return; | 121         return; | 
| 122     for (size_t i = 0; i < m_distribution.size(); ++i) | 122     for (size_t i = 0; i < m_distribution.size(); ++i) | 
| 123         m_distribution.at(i)->setNeedsStyleRecalc(LocalStyleChange); | 123         m_distribution.at(i)->setNeedsStyleRecalc(LocalStyleChange); | 
| 124 } | 124 } | 
| 125 | 125 | 
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 283                 current = insertedTo; | 283                 current = insertedTo; | 
| 284                 results.append(insertedTo); | 284                 results.append(insertedTo); | 
| 285                 continue; | 285                 continue; | 
| 286             } | 286             } | 
| 287         } | 287         } | 
| 288         return; | 288         return; | 
| 289     } | 289     } | 
| 290 } | 290 } | 
| 291 | 291 | 
| 292 } // namespace WebCore | 292 } // namespace WebCore | 
| OLD | NEW | 
|---|