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