⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 102081 in webkit


Ignore:
Timestamp:
Dec 5, 2011, 6:04:16 PM (15 years ago)
Author:
Darin Adler
Message:

Some small improvements to ContainerNode.h
https://bugs.webkit.org/show_bug.cgi?id=73786

Reviewed by Alexey Proskuryakov.

  • dom/ContainerNode.cpp:

(WebCore::ContainerNode::suspendPostAttachCallbacks): Added a FIXME comment about the
peculiar behavior of this function. Somehow the post-attach suspend state is both
global and specific to a certain Page object. That can't be right. If it was truly
global then this would be a static member function. If it was truly per-page, then
the related functions could not be static.

  • dom/ContainerNode.h: Removed some unneeded argument names. Moved the hasChildNodes

function up with the other basic getters. Put the other getters, childNodeCount and
childNode, right after the basic getters. Used ASSERT_NO_EXCEPTION in all the basic
mutation functions so they can be used in a cleaner fashion in C++ code where we have
some reason to know an exception won't occur. Grouped all the overrides of functions
from Node into a single paragraph and used the OVERRIDE macro on all of them. Made the
queuePostAttachCallback and postAttachCallbacksAreSuspended functions protected.

  • dom/Element.h: Moved the include of ExceptionCodePlaceholder.h into ContainerNode.h.
  • dom/Node.cpp:

(WebCore::Node::lazyAttach): Use hasChildNodes instead of firstChild for clarity.
(WebCore::Node::isDescendantOf): Ditto.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102080 r102081  
     12011-12-05  Darin Adler  <darin@apple.com>
     2
     3        Some small improvements to ContainerNode.h
     4        https://bugs.webkit.org/show_bug.cgi?id=73786
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * dom/ContainerNode.cpp:
     9        (WebCore::ContainerNode::suspendPostAttachCallbacks): Added a FIXME comment about the
     10        peculiar behavior of this function. Somehow the post-attach suspend state is both
     11        global and specific to a certain Page object. That can't be right. If it was truly
     12        global then this would be a static member function. If it was truly per-page, then
     13        the related functions could not be static.
     14
     15        * dom/ContainerNode.h: Removed some unneeded argument names. Moved the hasChildNodes
     16        function up with the other basic getters. Put the other getters, childNodeCount and
     17        childNode, right after the basic getters. Used ASSERT_NO_EXCEPTION in all the basic
     18        mutation functions so they can be used in a cleaner fashion in C++ code where we have
     19        some reason to know an exception won't occur. Grouped all the overrides of functions
     20        from Node into a single paragraph and used the OVERRIDE macro on all of them. Made the
     21        queuePostAttachCallback and postAttachCallbacksAreSuspended functions protected.
     22
     23        * dom/Element.h: Moved the include of ExceptionCodePlaceholder.h into ContainerNode.h.
     24
     25        * dom/Node.cpp:
     26        (WebCore::Node::lazyAttach): Use hasChildNodes instead of firstChild for clarity.
     27        (WebCore::Node::isDescendantOf): Ditto.
     28
    1292011-12-05  Benjamin Poulain  <benjamin@webkit.org>
    230
  • trunk/Source/WebCore/dom/ContainerNode.cpp

    r99305 r102081  
    714714        ASSERT(!s_shouldReEnableMemoryCacheCallsAfterAttach);
    715715        if (Page* page = document()->page()) {
     716            // FIXME: How can this call be specific to one Page, while the
     717            // s_attachDepth is a global? Doesn't make sense.
    716718            if (page->areMemoryCacheClientCallsEnabled()) {
    717719                page->setMemoryCacheClientCallsEnabled(false);
  • trunk/Source/WebCore/dom/ContainerNode.h

    r93071 r102081  
    33 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserved.
     5 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    2525#define ContainerNode_h
    2626
     27#include "ExceptionCodePlaceholder.h"
    2728#include "Node.h"
    2829
     
    3536namespace Private {
    3637    template<class GenericNode, class GenericNodeContainer>
    37     void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer* container);
     38    void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer*);
    3839};
    3940
     
    4445    Node* firstChild() const { return m_firstChild; }
    4546    Node* lastChild() const { return m_lastChild; }
     47    bool hasChildNodes() const { return m_firstChild; }
    4648
    47     bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode&, bool shouldLazyAttach = false);
    48     bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode&, bool shouldLazyAttach = false);
    49     bool removeChild(Node* child, ExceptionCode&);
    50     bool appendChild(PassRefPtr<Node> newChild, ExceptionCode&, bool shouldLazyAttach = false);
     49    unsigned childNodeCount() const;
     50    Node* childNode(unsigned index) const;
     51
     52    bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& = ASSERT_NO_EXCEPTION, bool shouldLazyAttach = false);
     53    bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode& = ASSERT_NO_EXCEPTION, bool shouldLazyAttach = false);
     54    bool removeChild(Node* child, ExceptionCode& = ASSERT_NO_EXCEPTION);
     55    bool appendChild(PassRefPtr<Node> newChild, ExceptionCode& = ASSERT_NO_EXCEPTION, bool shouldLazyAttach = false);
    5156
    5257    // These methods are only used during parsing.
     
    5762    void parserInsertBefore(PassRefPtr<Node> newChild, Node* refChild);
    5863
    59     bool hasChildNodes() const { return m_firstChild; }
    60     virtual void attach();
    61     virtual void detach();
    62     virtual void willRemove();
    63     virtual LayoutRect getRect() const;
    64     virtual void setFocus(bool = true);
    65     virtual void setActive(bool active = true, bool pause = false);
    66     virtual void setHovered(bool = true);
    67     unsigned childNodeCount() const;
    68     Node* childNode(unsigned index) const;
    69 
    70     virtual void insertedIntoDocument();
    71     virtual void removedFromDocument();
    72     virtual void insertedIntoTree(bool deep);
    73     virtual void removedFromTree(bool deep);
    74     virtual void childrenChanged(bool createdByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
    75 
    7664    // FIXME: It's not good to have two functions with such similar names, especially public functions.
    7765    // How do removeChildren and removeAllChildren differ?
    7866    void removeChildren();
    7967    void removeAllChildren();
     68
    8069    void takeAllChildrenFrom(ContainerNode*);
    8170
     
    8372   
    8473    bool dispatchBeforeLoadEvent(const String& sourceURL);
     74   
     75    virtual void attach() OVERRIDE;
     76    virtual void detach() OVERRIDE;
     77    virtual void willRemove() OVERRIDE;
     78    virtual LayoutRect getRect() const OVERRIDE;
     79    virtual void setFocus(bool = true) OVERRIDE;
     80    virtual void setActive(bool active = true, bool pause = false) OVERRIDE;
     81    virtual void setHovered(bool = true) OVERRIDE;
     82    virtual void insertedIntoDocument() OVERRIDE;
     83    virtual void removedFromDocument() OVERRIDE;
     84    virtual void insertedIntoTree(bool deep) OVERRIDE;
     85    virtual void removedFromTree(bool deep) OVERRIDE;
     86    virtual void childrenChanged(bool createdByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE;
     87    virtual void scheduleSetNeedsStyleRecalc(StyleChangeType = FullStyleChange) OVERRIDE;
    8588
    86     virtual void scheduleSetNeedsStyleRecalc(StyleChangeType = FullStyleChange);
     89protected:
     90    ContainerNode(Document*, ConstructionType = CreateContainer);
    8791
    8892    static void queuePostAttachCallback(NodeCallback, Node*, unsigned = 0);
    8993    static bool postAttachCallbacksAreSuspended();
    90    
    91 protected:
    92     ContainerNode(Document*, ConstructionType = CreateContainer);
    93 
    9494    void suspendPostAttachCallbacks();
    9595    void resumePostAttachCallbacks();
    9696
    9797    template<class GenericNode, class GenericNodeContainer>
    98     friend void appendChildToContainer(GenericNode* child, GenericNodeContainer* container);
     98    friend void appendChildToContainer(GenericNode* child, GenericNodeContainer*);
    9999
    100100    template<class GenericNode, class GenericNodeContainer>
    101     friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer* container);
     101    friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer*);
    102102
    103103    void setFirstChild(Node* child) { m_firstChild = child; }
  • trunk/Source/WebCore/dom/Element.h

    r99778 r102081  
    2727
    2828#include "Document.h"
    29 #include "ExceptionCodePlaceholder.h"
    3029#include "FragmentScriptingPermission.h"
    3130#include "NamedNodeMap.h"
  • trunk/Source/WebCore/dom/Node.cpp

    r101995 r102081  
    932932{
    933933    for (Node* n = this; n; n = n->traverseNextNode(this)) {
    934         if (n->firstChild())
     934        if (n->hasChildNodes())
    935935            n->setChildNeedsStyleRecalc();
    936936        n->setStyleChange(FullStyleChange);
     
    13491349{
    13501350    // Return true if other is an ancestor of this, otherwise false
    1351     if (!other || !other->firstChild() || inDocument() != other->inDocument())
     1351    if (!other || !other->hasChildNodes() || inDocument() != other->inDocument())
    13521352        return false;
    13531353    if (other == other->document())
Note: See TracChangeset for help on using the changeset viewer.