Changeset 266986 in webkit
- Timestamp:
- Sep 12, 2020 6:31:27 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r266985 r266986 1 2020-09-12 Simon Fraser <simon.fraser@apple.com> 2 3 Replace formatForDebugger() which uses raw char* with debugDescription() 4 https://bugs.webkit.org/show_bug.cgi?id=216447 5 6 Reviewed by Darin Adler. 7 8 formatForDebugger() relied on raw char* and buffer lengths. Replace with debugDescription() 9 which returns a String, and is already a convention used in various classes. 10 11 * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: 12 (-[WebAccessibilityObjectWrapper debugDescriptionForTextMarker:]): 13 (formatForDebugger): 14 * dom/Element.cpp: 15 (WebCore::Element::formatForDebugger const): Deleted. 16 * dom/Element.h: 17 * dom/Node.cpp: 18 (WebCore::Node::debugDescription const): 19 (WebCore::Node::formatForDebugger const): Deleted. 20 * dom/Node.h: 21 * dom/Position.cpp: 22 (WebCore::Position::debugDescription const): 23 (WebCore::Position::formatForDebugger const): Deleted. 24 * dom/Position.h: 25 * dom/Range.cpp: 26 (WebCore::Range::debugDescription const): 27 (WebCore::Range::formatForDebugger const): Deleted. 28 * dom/Range.h: 29 * dom/Text.cpp: 30 (WebCore::Text::formatForDebugger const): Deleted. 31 * dom/Text.h: 32 * editing/FrameSelection.cpp: 33 (WebCore::FrameSelection::debugDescription const): 34 (WebCore::FrameSelection::formatForDebugger const): Deleted. 35 * editing/FrameSelection.h: 36 * editing/VisiblePosition.cpp: 37 (WebCore::VisiblePosition::debugDescription const): 38 (WebCore::VisiblePosition::formatForDebugger const): Deleted. 39 * editing/VisiblePosition.h: 40 * editing/VisibleSelection.cpp: 41 (WebCore::VisibleSelection::debugDescription const): 42 (WebCore::VisibleSelection::formatForDebugger const): Deleted. 43 * editing/VisibleSelection.h: 44 1 45 2020-09-12 Simon Fraser <simon.fraser@apple.com> 2 46 -
trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
r266487 r266986 3689 3689 - (NSString *)debugDescriptionForTextMarker:(id)textMarker 3690 3690 { 3691 char description[1024]; 3692 [self visiblePositionForTextMarker:textMarker].formatForDebugger(description, sizeof(description)); 3693 return [NSString stringWithUTF8String:description]; 3691 return [self visiblePositionForTextMarker:textMarker].debugDescription(); 3694 3692 3695 3693 } … … 3729 3727 StringBuilder result; 3730 3728 3731 const int FormatBufferSize = 1024;3732 char format[FormatBufferSize];3733 3729 result.appendLiteral("from "); 3734 range.start.formatForDebugger(format, FormatBufferSize); 3735 result.append(format); 3730 result.append(range.start.debugDescription()); 3736 3731 result.appendLiteral(" to "); 3737 range.end.formatForDebugger(format, FormatBufferSize); 3738 result.append(format); 3732 result.append(range.end.debugDescription()); 3739 3733 3740 3734 strlcpy(buffer, result.toString().utf8().data(), length); -
trunk/Source/WebCore/dom/Element.cpp
r266899 r266986 2723 2723 } 2724 2724 2725 #if ENABLE(TREE_DEBUGGING)2726 2727 void Element::formatForDebugger(char* buffer, unsigned length) const2728 {2729 StringBuilder result;2730 String s;2731 2732 result.append(nodeName());2733 2734 s = getIdAttribute();2735 if (s.length() > 0) {2736 if (result.length() > 0)2737 result.appendLiteral("; ");2738 result.appendLiteral("id=");2739 result.append(s);2740 }2741 2742 s = getAttribute(classAttr);2743 if (s.length() > 0) {2744 if (result.length() > 0)2745 result.appendLiteral("; ");2746 result.appendLiteral("class=");2747 result.append(s);2748 }2749 2750 strncpy(buffer, result.toString().utf8().data(), length - 1);2751 }2752 2753 #endif2754 2755 2725 const Vector<RefPtr<Attr>>& Element::attrNodeList() 2756 2726 { -
trunk/Source/WebCore/dom/Element.h
r266776 r266986 700 700 LayoutRect absoluteEventBoundsOfElementAndDescendants(bool& includesFixedPositionElements); 701 701 702 #if ENABLE(TREE_DEBUGGING)703 void formatForDebugger(char* buffer, unsigned length) const override;704 #endif705 706 702 #if ENABLE(INTERSECTION_OBSERVER) 707 703 void disconnectFromIntersectionObservers(); -
trunk/Source/WebCore/dom/Node.cpp
r266776 r266986 1758 1758 String Node::debugDescription() const 1759 1759 { 1760 StringBuilder builder; 1761 builder.append(nodeName(), " 0x"_s, hex(reinterpret_cast<uintptr_t>(this), Lowercase)); 1762 return builder.toString(); 1760 auto name = nodeName(); 1761 return makeString(name.isEmpty() ? "<none>" : "", name, " 0x"_s, hex(reinterpret_cast<uintptr_t>(this), Lowercase)); 1763 1762 } 1764 1763 … … 1883 1882 String startingIndent; 1884 1883 traverseTreeAndMark(startingIndent, rootNode, markedNode1, markedLabel1, markedNode2, markedLabel2); 1885 }1886 1887 void Node::formatForDebugger(char* buffer, unsigned length) const1888 {1889 String result;1890 String s;1891 1892 s = nodeName();1893 if (s.isEmpty())1894 result = "<none>";1895 else1896 result = s;1897 1898 strncpy(buffer, result.utf8().data(), length - 1);1899 1884 } 1900 1885 -
trunk/Source/WebCore/dom/Node.h
r266887 r266986 424 424 425 425 #if ENABLE(TREE_DEBUGGING) 426 virtual void formatForDebugger(char* buffer, unsigned length) const;427 428 426 void showNode(const char* prefix = "") const; 429 427 void showTreeForThis() const; -
trunk/Source/WebCore/dom/Position.cpp
r266557 r266986 1380 1380 } 1381 1381 1382 void Position::formatForDebugger(char* buffer, unsigned length) const 1383 { 1384 StringBuilder result; 1385 1382 String Position::debugDescription() const 1383 { 1386 1384 if (isNull()) 1387 result.appendLiteral("<null>"); 1388 else { 1389 char s[1024]; 1390 result.appendLiteral("offset "); 1391 result.appendNumber(m_offset); 1392 result.appendLiteral(" of "); 1393 deprecatedNode()->formatForDebugger(s, sizeof(s)); 1394 result.append(s); 1395 } 1396 1397 strncpy(buffer, result.toString().utf8().data(), length - 1); 1385 return "<null>"_s; 1386 return makeString("offset ", m_offset, " of ", deprecatedNode()->debugDescription()); 1398 1387 } 1399 1388 -
trunk/Source/WebCore/dom/Position.h
r266487 r266986 194 194 195 195 #if ENABLE(TREE_DEBUGGING) 196 void formatForDebugger(char* buffer, unsigned length) const;196 String debugDescription() const; 197 197 void showAnchorTypeAndOffset() const; 198 198 void showTreeForThis() const; -
trunk/Source/WebCore/dom/Range.cpp
r266295 r266986 840 840 841 841 #if ENABLE(TREE_DEBUGGING) 842 void Range::formatForDebugger(char* buffer, unsigned length) const 843 { 844 StringBuilder result; 845 846 const int FormatBufferSize = 1024; 847 char s[FormatBufferSize]; 848 result.appendLiteral("from offset "); 849 result.appendNumber(m_start.offset()); 850 result.appendLiteral(" of "); 851 startContainer().formatForDebugger(s, FormatBufferSize); 852 result.append(s); 853 result.appendLiteral(" to offset "); 854 result.appendNumber(m_end.offset()); 855 result.appendLiteral(" of "); 856 endContainer().formatForDebugger(s, FormatBufferSize); 857 result.append(s); 858 859 strncpy(buffer, result.toString().utf8().data(), length - 1); 842 String Range::debugDescription() const 843 { 844 return makeString("from offset ", m_start.offset(), " of ", startContainer().debugDescription(), " to offset ", m_end.offset(), " of ", endContainer().debugDescription()); 860 845 } 861 846 #endif -
trunk/Source/WebCore/dom/Range.h
r266295 r266986 101 101 102 102 #if ENABLE(TREE_DEBUGGING) 103 void formatForDebugger(char* buffer, unsigned length) const;103 String debugDescription() const; 104 104 #endif 105 105 -
trunk/Source/WebCore/dom/Text.cpp
r264305 r266986 246 246 } 247 247 248 #if ENABLE(TREE_DEBUGGING)249 void Text::formatForDebugger(char* buffer, unsigned length) const250 {251 strncpy(buffer, debugDescription().utf8().data(), length - 1);252 buffer[length - 1] = '\0';253 }254 #endif255 256 248 void Text::setDataAndUpdate(const String& newData, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength) 257 249 { -
trunk/Source/WebCore/dom/Text.h
r264305 r266986 73 73 74 74 virtual Ref<Text> virtualCreate(const String&); 75 76 #if ENABLE(TREE_DEBUGGING)77 void formatForDebugger(char* buffer, unsigned length) const override;78 #endif79 75 }; 80 76 -
trunk/Source/WebCore/editing/FrameSelection.cpp
r266557 r266986 2484 2484 #if ENABLE(TREE_DEBUGGING) 2485 2485 2486 void FrameSelection::formatForDebugger(char* buffer, unsigned length) const2487 { 2488 m_selection.formatForDebugger(buffer, length);2486 String FrameSelection::debugDescription() const 2487 { 2488 return m_selection.debugDescription(); 2489 2489 } 2490 2490 -
trunk/Source/WebCore/editing/FrameSelection.h
r266557 r266986 218 218 219 219 #if ENABLE(TREE_DEBUGGING) 220 void formatForDebugger(char* buffer, unsigned length) const;220 String debugDescription() const; 221 221 void showTreeForThis() const; 222 222 #endif -
trunk/Source/WebCore/editing/VisiblePosition.cpp
r266557 r266986 682 682 } 683 683 684 void VisiblePosition::formatForDebugger(char* buffer, unsigned length) const685 { 686 m_deepPosition.formatForDebugger(buffer, length);684 String VisiblePosition::debugDescription() const 685 { 686 return m_deepPosition.debugDescription(); 687 687 } 688 688 -
trunk/Source/WebCore/editing/VisiblePosition.h
r266489 r266986 92 92 #if ENABLE(TREE_DEBUGGING) 93 93 void debugPosition(const char* msg = "") const; 94 void formatForDebugger(char* buffer, unsigned length) const;94 String debugDescription() const; 95 95 void showTreeForThis() const; 96 96 #endif -
trunk/Source/WebCore/editing/VisibleSelection.cpp
r266557 r266986 676 676 } 677 677 678 void VisibleSelection::formatForDebugger(char* buffer, unsigned length) const 679 { 680 StringBuilder result; 681 String s; 682 683 if (isNone()) { 684 result.appendLiteral("<none>"); 685 } else { 686 const int FormatBufferSize = 1024; 687 char s[FormatBufferSize]; 688 result.appendLiteral("from "); 689 start().formatForDebugger(s, FormatBufferSize); 690 result.append(s); 691 result.appendLiteral(" to "); 692 end().formatForDebugger(s, FormatBufferSize); 693 result.append(s); 694 } 695 696 strncpy(buffer, result.toString().utf8().data(), length - 1); 678 String VisibleSelection::debugDescription() const 679 { 680 if (isNone()) 681 return "<none>"_s; 682 return makeString("from ", start().debugDescription(), " to ", end().debugDescription()); 697 683 } 698 684 -
trunk/Source/WebCore/editing/VisibleSelection.h
r266557 r266986 107 107 #if ENABLE(TREE_DEBUGGING) 108 108 void debugPosition() const; 109 void formatForDebugger(char* buffer, unsigned length) const;109 String debugDescription() const; 110 110 void showTreeForThis() const; 111 111 #endif
Note: See TracChangeset
for help on using the changeset viewer.