Changeset 78219 in webkit


Ignore:
Timestamp:
Feb 10, 2011 6:47:26 AM (13 years ago)
Author:
rniwa@webkit.org
Message:

2011-02-10 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Eric Seidel.

Make canHaveChildrenForEditing more efficient
https://bugs.webkit.org/show_bug.cgi?id=53564

Improved the performance (1-2% in release and 20% in debug) by adding virtual member function
canContainRangeEndPoint to Node. It returns true whenever the associated node can have be a container
node for a position.

As of this revision, canContainRangeEndPoint returns true on Document, DocumentFragment, Text nodes
and any elements except:

HTML: applet, br, button, datagrid, embed, frame, frameset, hr, img, input,

meter, object, output, progress, and select.

WML: br, do, img, input, and select.

No new tests are added since this change cannot be tested directly.

  • dom/Document.h: (WebCore::Document::canContainRangeEndPoint): Added; returns false.
  • dom/DocumentFragment.h: (WebCore::DocumentFragment::canContainRangeEndPoint): Added; returns true.
  • dom/Element.h: (WebCore::Element::canContainRangeEndPoint): Ditto.
  • dom/Node.h: (WebCore::Node::canContainRangeEndPoint): Added; returns false.
  • dom/Text.h: (WebCore::Text::canContainRangeEndPoint): Added; returns true.
  • editing/htmlediting.cpp: Removed editingIgnoresContent and canHaveChildrenForEditing.
  • editing/htmlediting.h: (WebCore::editingIgnoresContent): Moved from htmlediting.cpp; made it inline. (WebCore::canHaveChildrenForEditing): Ditto.
  • html/HTMLBRElement.h: (WebCore::HTMLBRElement::canContainRangeEndPoint): Added; returns false.
  • html/HTMLButtonElement.h: (WebCore::HTMLButtonElement::canContainRangeEndPoint): Ditto.
  • html/HTMLDataGridElement.h: (WebCore::HTMLDataGridElement::canContainRangeEndPoint): Ditto.
  • html/HTMLFormControlElement.h: (WebCore::HTMLFormControlElementWithState::canContainRangeEndPoint): Ditto.
  • html/HTMLFrameElementBase.h: (WebCore::HTMLFrameElementBase::canContainRangeEndPoint): Ditto.
  • html/HTMLHRElement.h: (WebCore::HTMLHRElement::canContainRangeEndPoint): Ditto.
  • html/HTMLImageElement.h: (WebCore::HTMLImageElement::canContainRangeEndPoint): Ditto.
  • html/HTMLMeterElement.h: (WebCore::HTMLMeterElement::canContainRangeEndPoint): Ditto.
  • html/HTMLOutputElement.h: (WebCore::HTMLOutputElement::canContainRangeEndPoint): Ditto.
  • html/HTMLPlugInElement.h: (WebCore::HTMLPlugInElement::canContainRangeEndPoint): Ditto.
  • html/HTMLProgressElement.h: (WebCore::HTMLProgressElement::canContainRangeEndPoint): Ditto.
  • wml/WMLBRElement.h: (WebCore::WMLBRElement::canContainRangeEndPoint): Ditto.
  • wml/WMLDoElement.h: (WebCore::WMLDoElement::canContainRangeEndPoint): Ditto.
  • wml/WMLImageElement.h: (WebCore::WMLImageElement::canContainRangeEndPoint): Ditto.
  • wml/WMLInputElement.h: (WebCore::WMLInputElement::canContainRangeEndPoint): Ditto.
  • wml/WMLSelectElement.h: (WebCore::WMLSelectElement::canContainRangeEndPoint): Ditto.
Location:
trunk/Source/WebCore
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r78212 r78219  
     12011-02-10  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Make canHaveChildrenForEditing more efficient
     6        https://bugs.webkit.org/show_bug.cgi?id=53564
     7
     8        Improved the performance (1-2% in release and 20% in debug) by adding virtual member function
     9        canContainRangeEndPoint to Node. It returns true whenever the associated node can have be a container
     10        node for a position.
     11
     12        As of this revision, canContainRangeEndPoint returns true on Document, DocumentFragment, Text nodes
     13        and any elements except:
     14
     15        HTML: applet, br, button, datagrid, embed, frame, frameset, hr, img, input,
     16              meter, object, output, progress, and select.
     17
     18        WML: br, do, img, input, and select.
     19
     20        No new tests are added since this change cannot be tested directly.
     21
     22        * dom/Document.h:
     23        (WebCore::Document::canContainRangeEndPoint): Added; returns false.
     24        * dom/DocumentFragment.h:
     25        (WebCore::DocumentFragment::canContainRangeEndPoint): Added; returns true.
     26        * dom/Element.h:
     27        (WebCore::Element::canContainRangeEndPoint): Ditto.
     28        * dom/Node.h:
     29        (WebCore::Node::canContainRangeEndPoint): Added; returns false.
     30        * dom/Text.h:
     31        (WebCore::Text::canContainRangeEndPoint): Added; returns true.
     32        * editing/htmlediting.cpp: Removed editingIgnoresContent and canHaveChildrenForEditing.
     33        * editing/htmlediting.h:
     34        (WebCore::editingIgnoresContent): Moved from htmlediting.cpp; made it inline.
     35        (WebCore::canHaveChildrenForEditing): Ditto.
     36        * html/HTMLBRElement.h:
     37        (WebCore::HTMLBRElement::canContainRangeEndPoint): Added; returns false.
     38        * html/HTMLButtonElement.h:
     39        (WebCore::HTMLButtonElement::canContainRangeEndPoint): Ditto.
     40        * html/HTMLDataGridElement.h:
     41        (WebCore::HTMLDataGridElement::canContainRangeEndPoint): Ditto.
     42        * html/HTMLFormControlElement.h:
     43        (WebCore::HTMLFormControlElementWithState::canContainRangeEndPoint): Ditto.
     44        * html/HTMLFrameElementBase.h:
     45        (WebCore::HTMLFrameElementBase::canContainRangeEndPoint): Ditto.
     46        * html/HTMLHRElement.h:
     47        (WebCore::HTMLHRElement::canContainRangeEndPoint): Ditto.
     48        * html/HTMLImageElement.h:
     49        (WebCore::HTMLImageElement::canContainRangeEndPoint): Ditto.
     50        * html/HTMLMeterElement.h:
     51        (WebCore::HTMLMeterElement::canContainRangeEndPoint): Ditto.
     52        * html/HTMLOutputElement.h:
     53        (WebCore::HTMLOutputElement::canContainRangeEndPoint): Ditto.
     54        * html/HTMLPlugInElement.h:
     55        (WebCore::HTMLPlugInElement::canContainRangeEndPoint): Ditto.
     56        * html/HTMLProgressElement.h:
     57        (WebCore::HTMLProgressElement::canContainRangeEndPoint): Ditto.
     58        * wml/WMLBRElement.h:
     59        (WebCore::WMLBRElement::canContainRangeEndPoint): Ditto.
     60        * wml/WMLDoElement.h:
     61        (WebCore::WMLDoElement::canContainRangeEndPoint): Ditto.
     62        * wml/WMLImageElement.h:
     63        (WebCore::WMLImageElement::canContainRangeEndPoint): Ditto.
     64        * wml/WMLInputElement.h:
     65        (WebCore::WMLInputElement::canContainRangeEndPoint): Ditto.
     66        * wml/WMLSelectElement.h:
     67        (WebCore::WMLSelectElement::canContainRangeEndPoint): Ditto.
     68
    1692011-02-10  Pavel Feldman  <pfeldman@chromium.org>
    270
  • trunk/Source/WebCore/dom/Document.h

    r78147 r78219  
    439439    }
    440440
     441    virtual bool canContainRangeEndPoint() const { return true; }
     442
    441443    Element* getElementByAccessKey(const String& key) const;
    442444   
  • trunk/Source/WebCore/dom/DocumentFragment.h

    r65978 r78219  
    3636    void parseHTML(const String&, Element* contextElement, FragmentScriptingPermission = FragmentScriptingAllowed);
    3737    bool parseXML(const String&, Element* contextElement, FragmentScriptingPermission = FragmentScriptingAllowed);
     38   
     39    virtual bool canContainRangeEndPoint() const { return true; }
    3840
    3941private:
  • trunk/Source/WebCore/dom/Element.h

    r76727 r78219  
    314314    virtual bool isOutOfRange() const { return false; }
    315315
     316    virtual bool canContainRangeEndPoint() const { return true; }
     317
    316318    virtual bool formControlValueMatchesRenderer() const { return false; }
    317319    virtual void setFormControlValueMatchesRenderer(bool) { }
  • trunk/Source/WebCore/dom/Node.h

    r76115 r78219  
    231231    void setNextSibling(Node* next) { m_next = next; }
    232232
     233    virtual bool canContainRangeEndPoint() const { return false; }
     234
    233235    // FIXME: These two functions belong in editing -- "atomic node" is an editing concept.
    234236    Node* previousNodeConsideringAtomicNodes() const;
  • trunk/Source/WebCore/dom/Text.h

    r58914 r78219  
    4343
    4444    virtual void attach();
     45   
     46    virtual bool canContainRangeEndPoint() const { return true; }
    4547
    4648protected:
  • trunk/Source/WebCore/editing/htmlediting.cpp

    r78150 r78219  
    6565}
    6666
    67 // Returns true for nodes that either have no content, or have content that is ignored (skipped
    68 // over) while editing.  There are no VisiblePositions inside these nodes.
    69 bool editingIgnoresContent(const Node* node)
    70 {
    71     return !canHaveChildrenForEditing(node) && !node->isTextNode();
    72 }
    73 
    74 bool canHaveChildrenForEditing(const Node* node)
    75 {
    76     return !node->hasTagName(hrTag) &&
    77            !node->hasTagName(brTag) &&
    78            !node->hasTagName(imgTag) &&
    79            !node->hasTagName(buttonTag) &&
    80            !node->hasTagName(inputTag) &&
    81            !node->hasTagName(textareaTag) &&
    82            !node->hasTagName(objectTag) &&
    83            !node->hasTagName(iframeTag) &&
    84            !node->hasTagName(embedTag) &&
    85            !node->hasTagName(appletTag) &&
    86            !node->hasTagName(selectTag) &&
    87            !node->hasTagName(datagridTag) &&
    88 #if ENABLE(WML)
    89            !node->hasTagName(WMLNames::doTag) &&
    90 #endif
    91            !node->isTextNode();
    92 }
    93 
    9467// Compare two positions, taking into account the possibility that one or both
    9568// could be inside a shadow tree. Only works for non-null values.
  • trunk/Source/WebCore/editing/htmlediting.h

    r78150 r78219  
    7878// boolean functions on Node
    7979
    80 bool editingIgnoresContent(const Node*);
    81 bool canHaveChildrenForEditing(const Node*);
     80// FIXME: editingIgnoresContent, canHaveChildrenForEditing, and isAtomicNode
     81// should be renamed to reflect its usage.
     82
     83// Returns true for nodes that either have no content, or have content that is ignored (skipped
     84// over) while editing.  There are no VisiblePositions inside these nodes.
     85inline bool editingIgnoresContent(const Node* node)
     86{
     87    return !node->canContainRangeEndPoint();
     88}
     89
     90inline bool canHaveChildrenForEditing(const Node* node)
     91{
     92    return !node->isTextNode() && node->canContainRangeEndPoint();
     93}
     94
    8295bool isAtomicNode(const Node*);
    8396bool isBlock(const Node*);
  • trunk/Source/WebCore/html/HTMLBRElement.h

    r66057 r78219  
    3434    static PassRefPtr<HTMLBRElement> create(const QualifiedName&, Document*);
    3535
     36    virtual bool canContainRangeEndPoint() const { return false; }
     37
    3638private:
    3739    HTMLBRElement(const QualifiedName&, Document*);
  • trunk/Source/WebCore/html/HTMLButtonElement.h

    r74841 r78219  
    3535    String value() const;
    3636
     37    virtual bool canContainRangeEndPoint() const { return false; }
     38
    3739private:
    3840    HTMLButtonElement(const QualifiedName& tagName, Document*, HTMLFormElement*);
  • trunk/Source/WebCore/html/HTMLDataGridElement.h

    r65986 r78219  
    5454    DataGridColumnList* columns() const { return m_columns.get(); }
    5555
     56    virtual bool canContainRangeEndPoint() const { return false; }
     57
    5658private:
    5759    HTMLDataGridElement(const QualifiedName&, Document*);
  • trunk/Source/WebCore/html/HTMLFormControlElement.h

    r77114 r78219  
    169169    virtual ~HTMLFormControlElementWithState();
    170170
     171    virtual bool canContainRangeEndPoint() const { return false; }
     172
    171173protected:
    172174    HTMLFormControlElementWithState(const QualifiedName& tagName, Document*, HTMLFormElement*);
  • trunk/Source/WebCore/html/HTMLFrameElementBase.h

    r74700 r78219  
    4444
    4545    void setRemainsAliveOnRemovalFromTree(bool);
     46
     47    virtual bool canContainRangeEndPoint() const { return false; }
    4648
    4749protected:
  • trunk/Source/WebCore/html/HTMLHRElement.h

    r66057 r78219  
    3333    static PassRefPtr<HTMLHRElement> create(const QualifiedName&, Document*);
    3434
     35    virtual bool canContainRangeEndPoint() const { return false; }
     36
    3537private:
    3638    HTMLHRElement(const QualifiedName&, Document*);
  • trunk/Source/WebCore/html/HTMLImageElement.h

    r66057 r78219  
    7575    bool haveFiredLoadEvent() const { return m_imageLoader.haveFiredLoadEvent(); }
    7676
     77    virtual bool canContainRangeEndPoint() const { return false; }
     78
    7779protected:
    7880    HTMLImageElement(const QualifiedName&, Document*, HTMLFormElement* = 0);
  • trunk/Source/WebCore/html/HTMLMeterElement.h

    r73488 r78219  
    5656
    5757    GaugeRegion gaugeRegion() const;
     58
     59    virtual bool canContainRangeEndPoint() const { return false; }
     60
    5861private:
    5962    HTMLMeterElement(const QualifiedName&, Document*, HTMLFormElement*);
  • trunk/Source/WebCore/html/HTMLOutputElement.h

    r76115 r78219  
    5050    void setFor(const String&);
    5151    DOMSettableTokenList* htmlFor() const;
     52   
     53    virtual bool canContainRangeEndPoint() const { return false; }
    5254
    5355private:
  • trunk/Source/WebCore/html/HTMLPlugInElement.h

    r69596 r78219  
    5252    void setIsCapturingMouseEvents(bool capturing) { m_isCapturingMouseEvents = capturing; }
    5353
     54    virtual bool canContainRangeEndPoint() const { return false; }
     55
    5456protected:
    5557    HTMLPlugInElement(const QualifiedName& tagName, Document*);
  • trunk/Source/WebCore/html/HTMLProgressElement.h

    r77578 r78219  
    3939    double position() const;
    4040
     41    virtual bool canContainPosition() const { return false; }
     42
    4143private:
    4244    HTMLProgressElement(const QualifiedName&, Document*, HTMLFormElement*);
  • trunk/Source/WebCore/wml/WMLBRElement.h

    r66362 r78219  
    4141
    4242    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     43
     44    virtual bool canContainRangeEndPoint() const { return false; }
    4345};
    4446
  • trunk/Source/WebCore/wml/WMLDoElement.h

    r66362 r78219  
    5454    void setNoop(bool noop) { m_isNoop = noop;}
    5555
     56    virtual bool canContainRangeEndPoint() const { return false; }
     57
    5658private:
    5759    WMLTaskElement* m_task;
  • trunk/Source/WebCore/wml/WMLImageElement.h

    r66362 r78219  
    5050    void setUseFallbackAttribute(bool value) { m_useFallbackAttribute = value; }
    5151
     52    virtual bool canContainRangeEndPoint() const { return false; }
     53
    5254private:
    5355    WMLImageLoader m_imageLoader;
  • trunk/Source/WebCore/wml/WMLInputElement.h

    r76661 r78219  
    9898#endif
    9999
     100    virtual bool canContainRangeEndPoint() const { return false; }
     101
    100102private:
    101103    friend class WMLCardElement;
  • trunk/Source/WebCore/wml/WMLSelectElement.h

    r73606 r78219  
    9191   
    9292    virtual void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shift, bool fireOnChangeNow = true);
     93   
     94    virtual bool canContainRangeEndPoint() const { return false; }
     95
    9396private:
    9497    virtual void insertedIntoTree(bool);
Note: See TracChangeset for help on using the changeset viewer.