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..4d723ebefb71c53cb487cceb1bb08f480a67b1d3 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 TextCompositionMarkerDetails final : public DocumentMarkerDetails { |
| +public: |
| + static PassRefPtrWillBeRawPtr<TextCompositionMarkerDetails> instanceFor(Color underlineColor, bool thick, Color backgroundColor); |
|
yosin_UTC9
2015/09/08 06:34:05
nit: Could you use |create()| instead of |instance
|
| + |
| + 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: |
| + TextCompositionMarkerDetails(Color underlineColor, bool thick, Color backgroundColor) |
| + : m_underlineColor(underlineColor) |
| + , m_thick(thick) |
| + , m_backgroundColor(backgroundColor) |
| + { |
| + } |
| + |
| + Color m_underlineColor; |
| + bool m_thick; |
|
yosin_UTC9
2015/09/08 06:34:05
nit: Rather than having alignment padding in middl
|
| + Color m_backgroundColor; |
| +}; |
| + |
| +PassRefPtrWillBeRawPtr<TextCompositionMarkerDetails> TextCompositionMarkerDetails::instanceFor(Color underlineColor, bool thick, Color backgroundColor) |
| +{ |
| + return adoptRefWillBeNoop(new TextCompositionMarkerDetails(underlineColor, thick, backgroundColor)); |
| +} |
| + |
| +inline TextCompositionMarkerDetails* toTextCompositionMarkerDetails(DocumentMarkerDetails* details) |
| +{ |
| + if (details && details->isComposition()) |
| + return static_cast<TextCompositionMarkerDetails*>(details); |
| + return 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(TextCompositionMarkerDetails::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 (TextCompositionMarkerDetails* details = toTextCompositionMarkerDetails(m_details.get())) |
| + return details->underlineColor(); |
| + return Color::transparent; |
| +} |
| + |
| +bool DocumentMarker::thick() const |
| +{ |
| + if (TextCompositionMarkerDetails* details = toTextCompositionMarkerDetails(m_details.get())) |
| + return details->thick(); |
| + return false; |
| +} |
| + |
| +Color DocumentMarker::backgroundColor() const |
| +{ |
| + if (TextCompositionMarkerDetails* details = toTextCompositionMarkerDetails(m_details.get())) |
| + return details->backgroundColor(); |
| + return Color::transparent; |
| +} |
| + |
| DEFINE_TRACE(DocumentMarker) |
| { |
| visitor->trace(m_details); |