Commit 459731e7 authored by thakis's avatar thakis Committed by Commit bot

blink style: Update one class cluster, delete one class, change comment style.

The C-style comments were confusing a regex.
No behavior change.

BUG=675877

Review-Url: https://codereview.chromium.org/2872133004
Cr-Commit-Position: refs/heads/master@{#471142}
parent 84869d69
...@@ -27,37 +27,33 @@ class TraceWrapperBase; ...@@ -27,37 +27,33 @@ class TraceWrapperBase;
template <typename T> template <typename T>
class TraceWrapperMember; class TraceWrapperMember;
/** // Declares non-virtual TraceWrappers method. Should be used on
* Declares non-virtual traceWrappers method. Should be used on // non-ScriptWrappable classes which should participate in wrapper tracing (e.g.
* non-ScriptWrappable classes which should participate in wrapper tracing (e.g. // StyleEngine):
* StyleEngine): //
* // class StyleEngine: public TraceWrapperBase {
* class StyleEngine: public TraceWrapperBase { // public:
* public: // DECLARE_TRACE_WRAPPERS();
* DECLARE_TRACE_WRAPPERS(); // };
* }; //
*/
#define DECLARE_TRACE_WRAPPERS() \ #define DECLARE_TRACE_WRAPPERS() \
void TraceWrappers(const WrapperVisitor* visitor) const void TraceWrappers(const WrapperVisitor* visitor) const
/** // Declares virtual TraceWrappers method. It is used in ScriptWrappable, can be
* Declares virtual traceWrappers method. It is used in ScriptWrappable, can be // used to override the method in the subclasses, and can be used by
* used to override the method in the subclasses, and can be used by // non-ScriptWrappable classes which expect to be inherited.
* non-ScriptWrappable classes which expect to be inherited.
*/
#define DECLARE_VIRTUAL_TRACE_WRAPPERS() virtual DECLARE_TRACE_WRAPPERS() #define DECLARE_VIRTUAL_TRACE_WRAPPERS() virtual DECLARE_TRACE_WRAPPERS()
/** // Provides definition of TraceWrappers method. Custom code will usually call
* Provides definition of traceWrappers method. Custom code will usually call // visitor->TraceWrappers with all objects which could contribute to the set of
* visitor->traceWrappers with all objects which could contribute to the set of // reachable wrappers:
* reachable wrappers: //
* // DEFINE_TRACE_WRAPPERS(NodeRareData)
* DEFINE_TRACE_WRAPPERS(NodeRareData) // {
* { // visitor->TraceWrappers(node_lists_);
* visitor->traceWrappers(m_nodeLists); // visitor->TraceWrappers(mutation_observer_data_);
* visitor->traceWrappers(m_mutationObserverData); // }
* } //
*/
#define DEFINE_TRACE_WRAPPERS(T) \ #define DEFINE_TRACE_WRAPPERS(T) \
void T::TraceWrappers(const WrapperVisitor* visitor) const void T::TraceWrappers(const WrapperVisitor* visitor) const
...@@ -106,25 +102,21 @@ class PLATFORM_EXPORT WrapperVisitor { ...@@ -106,25 +102,21 @@ class PLATFORM_EXPORT WrapperVisitor {
MarkAndPushToMarkingDeque(traceable); MarkAndPushToMarkingDeque(traceable);
} }
/** // Trace all wrappers of |t|.
* Trace all wrappers of |t|. //
* // If you cannot use TraceWrapperMember & the corresponding TraceWrappers()
* If you cannot use TraceWrapperMember & the corresponding traceWrappers() // for some reason (e.g., due to sizeof(TraceWrapperMember)), you can use
* for some reason (e.g., due to sizeof(TraceWrapperMember)), you can use // Member and |TraceWrappersWithManualWriteBarrier()|. See below.
* Member and |traceWrappersWithManualWriteBarrier()|. See below.
*/
template <typename T> template <typename T>
void TraceWrappers(const TraceWrapperMember<T>& t) const { void TraceWrappers(const TraceWrapperMember<T>& t) const {
TraceWrappers(t.Get()); TraceWrappers(t.Get());
} }
/** // Require all users of manual write barriers to make this explicit in their
* Require all users of manual write barriers to make this explicit in their // |TraceWrappers| definition. Be sure to add
* |traceWrappers| definition. Be sure to add // |ScriptWrappableVisitor::writeBarrier(this, new_value)| after all
* |ScriptWrappableVisitor::writeBarrier(this, new_value)| after all // assignments to the field. Otherwise, the objects may be collected
* assignments to the field. Otherwise, the objects may be collected // prematurely.
* prematurely.
*/
template <typename T> template <typename T>
void TraceWrappersWithManualWriteBarrier(const Member<T>& t) const { void TraceWrappersWithManualWriteBarrier(const Member<T>& t) const {
TraceWrappers(t.Get()); TraceWrappers(t.Get());
......
...@@ -9,21 +9,6 @@ ...@@ -9,21 +9,6 @@
#include <iomanip> // NOLINT #include <iomanip> // NOLINT
#include <ostream> // NOLINT #include <ostream> // NOLINT
namespace {
class StreamStateSaver : private std::ios {
WTF_MAKE_NONCOPYABLE(StreamStateSaver);
public:
StreamStateSaver(std::ios& other) : std::ios(nullptr), m_other(other) {
copyfmt(other);
}
~StreamStateSaver() { m_other.copyfmt(*this); }
private:
std::ios& m_other;
};
} // unnamed namespace
namespace blink { namespace blink {
void PrintTo(const PaintChunk& chunk, std::ostream* os) { void PrintTo(const PaintChunk& chunk, std::ostream* os) {
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "platform/wtf/text/CString.h" #include "platform/wtf/text/CString.h"
#include "platform/wtf/text/WTFString.h" #include "platform/wtf/text/WTFString.h"
namespace blink {
namespace { namespace {
class OutputBuffer { class OutputBuffer {
...@@ -44,53 +45,53 @@ class OutputBuffer { ...@@ -44,53 +45,53 @@ class OutputBuffer {
public: public:
OutputBuffer() {} OutputBuffer() {}
virtual char* allocate(size_t) = 0; virtual char* Allocate(size_t) = 0;
virtual void copy(const CString&) = 0; virtual void Copy(const CString&) = 0;
virtual ~OutputBuffer() {} virtual ~OutputBuffer() {}
}; };
class CStringBuffer final : public OutputBuffer { class CStringBuffer final : public OutputBuffer {
public: public:
CStringBuffer(CString& buffer) : m_buffer(buffer) {} CStringBuffer(CString& buffer) : buffer_(buffer) {}
~CStringBuffer() override {} ~CStringBuffer() override {}
char* allocate(size_t size) override { char* Allocate(size_t size) override {
char* ptr; char* ptr;
m_buffer = CString::CreateUninitialized(size, ptr); buffer_ = CString::CreateUninitialized(size, ptr);
return ptr; return ptr;
} }
void copy(const CString& source) override { m_buffer = source; } void Copy(const CString& source) override { buffer_ = source; }
const CString& buffer() const { return m_buffer; } const CString& Buffer() const { return buffer_; }
private: private:
CString m_buffer; CString buffer_;
}; };
class VectorCharAppendBuffer final : public OutputBuffer { class VectorCharAppendBuffer final : public OutputBuffer {
public: public:
VectorCharAppendBuffer(Vector<char>& buffer) : m_buffer(buffer) {} VectorCharAppendBuffer(Vector<char>& buffer) : buffer_(buffer) {}
~VectorCharAppendBuffer() override {} ~VectorCharAppendBuffer() override {}
char* allocate(size_t size) override { char* Allocate(size_t size) override {
size_t oldSize = m_buffer.size(); size_t old_size = buffer_.size();
m_buffer.Grow(oldSize + size); buffer_.Grow(old_size + size);
return m_buffer.data() + oldSize; return buffer_.data() + old_size;
} }
void copy(const CString& source) override { void Copy(const CString& source) override {
m_buffer.Append(source.data(), source.length()); buffer_.Append(source.data(), source.length());
} }
private: private:
Vector<char>& m_buffer; Vector<char>& buffer_;
}; };
void internalNormalizeLineEndingsToCRLF(const CString& from, void InternalNormalizeLineEndingsToCRLF(const CString& from,
OutputBuffer& buffer) { OutputBuffer& buffer) {
// Compute the new length. // Compute the new length.
size_t newLen = 0; size_t new_len = 0;
const char* p = from.data(); const char* p = from.data();
while (p < from.data() + from.length()) { while (p < from.data() + from.length()) {
char c = *p++; char c = *p++;
...@@ -98,26 +99,26 @@ void internalNormalizeLineEndingsToCRLF(const CString& from, ...@@ -98,26 +99,26 @@ void internalNormalizeLineEndingsToCRLF(const CString& from,
// Safe to look ahead because of trailing '\0'. // Safe to look ahead because of trailing '\0'.
if (*p != '\n') { if (*p != '\n') {
// Turn CR into CRLF. // Turn CR into CRLF.
newLen += 2; new_len += 2;
} }
} else if (c == '\n') { } else if (c == '\n') {
// Turn LF into CRLF. // Turn LF into CRLF.
newLen += 2; new_len += 2;
} else { } else {
// Leave other characters alone. // Leave other characters alone.
newLen += 1; new_len += 1;
} }
} }
if (newLen < from.length()) if (new_len < from.length())
return; return;
if (newLen == from.length()) { if (new_len == from.length()) {
buffer.copy(from); buffer.Copy(from);
return; return;
} }
p = from.data(); p = from.data();
char* q = buffer.allocate(newLen); char* q = buffer.Allocate(new_len);
// Make a copy of the string. // Make a copy of the string.
while (p < from.data() + from.length()) { while (p < from.data() + from.length()) {
...@@ -140,9 +141,7 @@ void internalNormalizeLineEndingsToCRLF(const CString& from, ...@@ -140,9 +141,7 @@ void internalNormalizeLineEndingsToCRLF(const CString& from,
} }
} }
} // namespace; } // namespace
namespace blink {
void NormalizeLineEndingsToLF(const CString& from, Vector<char>& result) { void NormalizeLineEndingsToLF(const CString& from, Vector<char>& result) {
// Compute the new length. // Compute the new length.
...@@ -198,14 +197,14 @@ CString NormalizeLineEndingsToCRLF(const CString& from) { ...@@ -198,14 +197,14 @@ CString NormalizeLineEndingsToCRLF(const CString& from) {
return from; return from;
CString result; CString result;
CStringBuffer buffer(result); CStringBuffer buffer(result);
internalNormalizeLineEndingsToCRLF(from, buffer); InternalNormalizeLineEndingsToCRLF(from, buffer);
return buffer.buffer(); return buffer.Buffer();
} }
void NormalizeLineEndingsToNative(const CString& from, Vector<char>& result) { void NormalizeLineEndingsToNative(const CString& from, Vector<char>& result) {
#if OS(WIN) #if OS(WIN)
VectorCharAppendBuffer buffer(result); VectorCharAppendBuffer buffer(result);
internalNormalizeLineEndingsToCRLF(from, buffer); InternalNormalizeLineEndingsToCRLF(from, buffer);
#else #else
NormalizeLineEndingsToLF(from, result); NormalizeLineEndingsToLF(from, result);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment