Changeset 223886 in webkit


Ignore:
Timestamp:
Oct 24, 2017 1:54:42 AM (6 years ago)
Author:
rniwa@webkit.org
Message:

DocumentOrderedMap::add should release assert that tree scopes match
https://bugs.webkit.org/show_bug.cgi?id=178708

Reviewed by Antti Koivisto.

Assert that the tree scope of element matches the given tree scope instead of asserting that
element is in tree scope, and replaced the use of RELEASE_ASSERT by the newly added
RELEASE_ASSERT_WITH_SECURITY_IMPLICATION to clarify the semantics of these assertions.

Also removed now redudnant early exits which would never execute due to release assertions.

  • dom/DocumentOrderedMap.cpp:

(WebCore::DocumentOrderedMap::add):
(WebCore::DocumentOrderedMap::remove):
(WebCore::DocumentOrderedMap::get const):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r223885 r223886  
     12017-10-24  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        DocumentOrderedMap::add should release assert that tree scopes match
     4        https://bugs.webkit.org/show_bug.cgi?id=178708
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Assert that the tree scope of element matches the given tree scope instead of asserting that
     9        element is in tree scope, and replaced the use of RELEASE_ASSERT by the newly added
     10        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION to clarify the semantics of these assertions.
     11
     12        Also removed now redudnant early exits which would never execute due to release assertions.
     13
     14        * dom/DocumentOrderedMap.cpp:
     15        (WebCore::DocumentOrderedMap::add):
     16        (WebCore::DocumentOrderedMap::remove):
     17        (WebCore::DocumentOrderedMap::get const):
     18
    1192017-10-24  Michael Catanzaro  <mcatanzaro@igalia.com>
    220
  • trunk/Source/WebCore/dom/DocumentOrderedMap.cpp

    r223415 r223886  
    4949void DocumentOrderedMap::add(const AtomicStringImpl& key, Element& element, const TreeScope& treeScope)
    5050{
    51     UNUSED_PARAM(treeScope);
    52     RELEASE_ASSERT(element.isInTreeScope());
     51    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(&element.treeScope() == &treeScope);
    5352    ASSERT_WITH_SECURITY_IMPLICATION(treeScope.rootNode().containsIncludingShadowDOM(&element));
    5453
     
    6867        return;
    6968
    70     RELEASE_ASSERT(entry.count);
     69    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.count);
    7170    entry.element = nullptr;
    7271    entry.count++;
     
    7978    auto it = m_map.find(&key);
    8079
    81     RELEASE_ASSERT(it != m_map.end());
    82     if (it == m_map.end())
    83         return;
     80    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(it != m_map.end());
    8481
    8582    MapEntry& entry = it->value;
    8683    ASSERT_WITH_SECURITY_IMPLICATION(entry.registeredElements.remove(&element));
    87     RELEASE_ASSERT(entry.count);
     84    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.count);
    8885    if (entry.count == 1) {
    89         RELEASE_ASSERT(!entry.element || entry.element == &element);
     86        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!entry.element || entry.element == &element);
    9087        m_map.remove(it);
    9188    } else {
     
    109106    ASSERT(entry.count);
    110107    if (entry.element) {
    111         RELEASE_ASSERT(entry.element->isInTreeScope());
    112         RELEASE_ASSERT(&entry.element->treeScope() == &scope);
    113         ASSERT_WITH_SECURITY_IMPLICATION(entry.registeredElements.contains(entry.element));
    114         return entry.element;
     108        auto& element = *entry.element;
     109        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(&element.treeScope() == &scope);
     110        ASSERT_WITH_SECURITY_IMPLICATION(entry.registeredElements.contains(&element));
     111        return &element;
    115112    }
    116113
     
    120117            continue;
    121118        entry.element = &element;
    122         RELEASE_ASSERT(element.isInTreeScope());
    123         RELEASE_ASSERT(&element.treeScope() == &scope);
     119        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(&element.treeScope() == &scope);
    124120        ASSERT_WITH_SECURITY_IMPLICATION(entry.registeredElements.contains(entry.element));
    125121        return &element;
     
    188184
    189185    MapEntry& entry = it->value;
    190     RELEASE_ASSERT(entry.count);
    191     if (!entry.count)
    192         return nullptr;
     186    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.count);
    193187
    194188    if (entry.orderedList.isEmpty()) {
     
    203197            entry.orderedList.append(&element);
    204198        }
    205         RELEASE_ASSERT(entry.orderedList.size() == entry.count);
     199        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(entry.orderedList.size() == entry.count);
    206200    }
    207201
Note: See TracChangeset for help on using the changeset viewer.