Chromium Code Reviews| Index: Source/core/editing/markers/DocumentMarker.cpp |
| diff --git a/Source/core/editing/markers/DocumentMarker.cpp b/Source/core/editing/markers/DocumentMarker.cpp |
| index 90933b4a7a3094dd0f81d99e823266c5ff0c8a10..09fe5e8022fbc8a6628d82d3453928e78fed185a 100644 |
| --- a/Source/core/editing/markers/DocumentMarker.cpp |
| +++ b/Source/core/editing/markers/DocumentMarker.cpp |
| @@ -96,6 +96,41 @@ inline DocumentMarkerTextMatch* toDocumentMarkerTextMatch(DocumentMarkerDetails* |
| return 0; |
| } |
| +class DocumentMarkerComposition final : public DocumentMarkerDetails { |
|
yosin_UTC9
2015/09/04 06:20:42
|DocumentMarkerCompostion| can be misleading.
How
|
| +public: |
| + static PassRefPtrWillBeRawPtr<DocumentMarkerComposition> instanceFor(Color underlineColor, bool thick, Color backgroundColor); |
| + |
| + bool isComposition() const override { return true; } |
| + Color underlineColor() const { return m_underlineColor; } |
| + bool thick() const { return m_thick; } |
| + Color backgroundColor() const { return m_backgroundColor; } |
| + |
| +private: |
| + DocumentMarkerComposition(Color underlineColor, bool thick, Color backgroundColor) |
| + : m_underlineColor(underlineColor) |
| + , m_thick(thick) |
| + , m_backgroundColor(backgroundColor) |
| + { |
| + } |
| + |
| + Color m_underlineColor; |
| + bool m_thick; |
| + Color m_backgroundColor; |
| +}; |
| + |
| +PassRefPtrWillBeRawPtr<DocumentMarkerComposition> DocumentMarkerComposition::instanceFor(Color underlineColor, bool thick, Color backgroundColor) |
| +{ |
| + return adoptRefWillBeNoop(new DocumentMarkerComposition(underlineColor, thick, backgroundColor)); |
| +} |
| + |
| +inline DocumentMarkerComposition* toDocumentMarkerComposition(DocumentMarkerDetails* details) |
| +{ |
| + if (details && details->isComposition()) |
| + return static_cast<DocumentMarkerComposition*>(details); |
| + return 0; |
|
yosin_UTC9
2015/09/04 06:20:42
nit: s/0/nullptr/;
|
| +} |
| + |
| + |
| DocumentMarker::DocumentMarker(MarkerType type, unsigned startOffset, unsigned endOffset, const String& description, uint32_t hash) |
| : m_type(type) |
| , m_startOffset(startOffset) |
| @@ -114,6 +149,15 @@ DocumentMarker::DocumentMarker(unsigned startOffset, unsigned endOffset, bool ac |
| { |
| } |
| +DocumentMarker::DocumentMarker(unsigned startOffset, unsigned endOffset, Color underlineColor, bool thick, Color backgroundColor) |
| + : m_type(DocumentMarker::Composition) |
| + , m_startOffset(startOffset) |
| + , m_endOffset(endOffset) |
| + , m_details(DocumentMarkerComposition::instanceFor(underlineColor, thick, backgroundColor)) |
| + , m_hash(0) |
| +{ |
| +} |
| + |
| DocumentMarker::DocumentMarker(const DocumentMarker& marker) |
| : m_type(marker.type()) |
| , m_startOffset(marker.startOffset()) |
| @@ -148,6 +192,27 @@ bool DocumentMarker::activeMatch() const |
| return false; |
| } |
| +Color DocumentMarker::underlineColor() const |
| +{ |
| + if (DocumentMarkerComposition* details = toDocumentMarkerComposition(m_details.get())) |
| + return details->underlineColor(); |
| + return Color::transparent; |
| +} |
| + |
| +bool DocumentMarker::thick() const |
| +{ |
| + if (DocumentMarkerComposition* details = toDocumentMarkerComposition(m_details.get())) |
| + return details->thick(); |
| + return false; |
| +} |
| + |
| +Color DocumentMarker::backgroundColor() const |
| +{ |
| + if (DocumentMarkerComposition* details = toDocumentMarkerComposition(m_details.get())) |
| + return details->backgroundColor(); |
| + return Color::transparent; |
| +} |
| + |
| DEFINE_TRACE(DocumentMarker) |
| { |
| visitor->trace(m_details); |