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

Changeset 259581 in webkit


Ignore:
Timestamp:
Apr 6, 2020, 11:09:10 AM (6 years ago)
Author:
Simon Fraser
Message:

Make RenderObject TextStream-loggable
https://bugs.webkit.org/show_bug.cgi?id=210035

Post-landing followup. More use of StringBuilder's variadic append. Have Node::debugDescription() include
its address, and have derived classes get the base class debugDescription(). Add an override in Text.

  • dom/Element.cpp:

(WebCore::Element::debugDescription const):

  • dom/Node.cpp:

(WebCore::Node::debugDescription const):

  • dom/Text.cpp:

(WebCore::Text::debugDescription const):
(WebCore::Text::formatForDebugger const):

  • dom/Text.h:
  • rendering/RenderObject.cpp:

(WebCore::RenderObject::debugDescription const):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r259578 r259581  
     12020-04-06  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make RenderObject TextStream-loggable
     4        https://bugs.webkit.org/show_bug.cgi?id=210035
     5
     6        Post-landing followup. More use of StringBuilder's variadic append. Have Node::debugDescription() include
     7        its address, and have derived classes get the base class debugDescription(). Add an override in Text.
     8
     9        * dom/Element.cpp:
     10        (WebCore::Element::debugDescription const):
     11        * dom/Node.cpp:
     12        (WebCore::Node::debugDescription const):
     13        * dom/Text.cpp:
     14        (WebCore::Text::debugDescription const):
     15        (WebCore::Text::formatForDebugger const):
     16        * dom/Text.h:
     17        * rendering/RenderObject.cpp:
     18        (WebCore::RenderObject::debugDescription const):
     19
    1202020-04-06  Cathie Chen  <cathiechen@igalia.com>
    221
  • trunk/Source/WebCore/dom/Element.cpp

    r259577 r259581  
    26302630    StringBuilder builder;
    26312631
    2632     builder.append(nodeName());
    2633 
    2634     if (hasID()) {
    2635         builder.appendLiteral(" id=\'");
    2636         builder.append(getIdAttribute());
    2637         builder.append('\'');
    2638     }
     2632    builder.append(ContainerNode::debugDescription());
     2633
     2634    if (hasID())
     2635        builder.append(" id=\'", getIdAttribute(), '\'');
    26392636
    26402637    if (hasClass()) {
    26412638        builder.appendLiteral(" class=\'");
    26422639        size_t classNamesToDump = classNames().size();
    2643         const size_t maxNumClassNames = 7;
     2640        constexpr size_t maxNumClassNames = 7;
    26442641        bool addEllipsis = false;
    26452642        if (classNamesToDump > maxNumClassNames) {
     
    26542651        }
    26552652        if (addEllipsis)
    2656             builder.append("...");
     2653            builder.append(" ...");
    26572654        builder.append('\'');
    26582655    }
  • trunk/Source/WebCore/dom/Node.cpp

    r259557 r259581  
    7878#include "XMLNames.h"
    7979#include <JavaScriptCore/HeapInlines.h>
     80#include <wtf/HexNumber.h>
    8081#include <wtf/IsoMallocInlines.h>
    8182#include <wtf/RefCountedLeakCounter.h>
     
    17551756{
    17561757    StringBuilder builder;
    1757 
    1758     builder.append(nodeName());
    1759 
    1760     if (isTextNode()) {
    1761         String value = nodeValue();
    1762         value.replaceWithLiteral('\\', "\\\\");
    1763         value.replaceWithLiteral('\n', "\\n");
    1764        
    1765         const size_t maxDumpLength = 30;
    1766         if (value.length() > maxDumpLength) {
    1767             value.truncate(maxDumpLength - 10);
    1768             value.append("..."_s);
    1769         }
    1770        
    1771         builder.append(' ');
    1772         builder.append('\"');
    1773         builder.append(value);
    1774         builder.append('\"');
    1775     }
    1776 
     1758    builder.append(nodeName(), " 0x"_s, hex(reinterpret_cast<uintptr_t>(this), Lowercase));
    17771759    return builder.toString();
    17781760}
  • trunk/Source/WebCore/dom/Text.cpp

    r243163 r259581  
    222222}
    223223
     224String Text::debugDescription() const
     225{
     226    StringBuilder builder;
     227
     228    builder.append(CharacterData::debugDescription());
     229
     230    String value = data();
     231    builder.append(" length="_s, value.length());
     232
     233    value.replaceWithLiteral('\\', "\\\\");
     234    value.replaceWithLiteral('\n', "\\n");
     235   
     236    const size_t maxDumpLength = 30;
     237    if (value.length() > maxDumpLength) {
     238        value.truncate(maxDumpLength - 10);
     239        value.append("..."_s);
     240    }
     241
     242    builder.append(" \"", value, '\"');
     243
     244    return builder.toString();
     245}
     246
    224247#if ENABLE(TREE_DEBUGGING)
    225248void Text::formatForDebugger(char* buffer, unsigned length) const
    226249{
    227     StringBuilder result;
    228     String s;
    229 
    230     result.append(nodeName());
    231 
    232     s = data();
    233     if (s.length() > 0) {
    234         if (result.length())
    235             result.appendLiteral("; ");
    236         result.appendLiteral("length=");
    237         result.appendNumber(s.length());
    238         result.appendLiteral("; value=\"");
    239         result.append(s);
    240         result.append('"');
    241     }
    242 
    243     strncpy(buffer, result.toString().utf8().data(), length - 1);
     250    strncpy(buffer, debugDescription().utf8().data(), length - 1);
    244251    buffer[length - 1] = '\0';
    245252}
  • trunk/Source/WebCore/dom/Text.h

    r229694 r259581  
    5656    void updateRendererAfterContentChange(unsigned offsetOfReplacedData, unsigned lengthOfReplacedData);
    5757
     58    String debugDescription() const final;
     59
    5860protected:
    5961    Text(Document& document, const String& data, ConstructionType type)
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r259575 r259581  
    19071907    StringBuilder builder;
    19081908
    1909     builder.append(renderName());
    1910     builder.append(" 0x"_s);
    1911     builder.append(hex(reinterpret_cast<uintptr_t>(this), Lowercase));
    1912     builder.append(' ');
    1913 
     1909    builder.append(renderName(), " 0x"_s, hex(reinterpret_cast<uintptr_t>(this), Lowercase));
    19141910    if (node())
    1915         builder.append(node()->debugDescription());
     1911        builder.append(' ', node()->debugDescription());
    19161912   
    19171913    return builder.toString();
Note: See TracChangeset for help on using the changeset viewer.