Index: Source/core/rendering/GraphicsContextAnnotator.cpp |
diff --git a/Source/core/platform/graphics/GraphicsContextAnnotation.cpp b/Source/core/rendering/GraphicsContextAnnotator.cpp |
similarity index 74% |
copy from Source/core/platform/graphics/GraphicsContextAnnotation.cpp |
copy to Source/core/rendering/GraphicsContextAnnotator.cpp |
index f64714f55876a0487481b5edaef7ca9015885280..824c93f80c21ce3c7a97879d8611bc80f6fc15e1 100644 |
--- a/Source/core/platform/graphics/GraphicsContextAnnotation.cpp |
+++ b/Source/core/rendering/GraphicsContextAnnotator.cpp |
@@ -1,5 +1,6 @@ |
/* |
* Copyright (C) 2013 Google Inc. All rights reserved. |
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are |
@@ -29,22 +30,15 @@ |
*/ |
#include "config.h" |
-#include "core/platform/graphics/GraphicsContextAnnotation.h" |
+#include "core/rendering/GraphicsContextAnnotator.h" |
-#include "core/platform/graphics/GraphicsContext.h" |
+#include "core/platform/graphics/GraphicsContextAnnotation.h" |
#include "core/rendering/PaintInfo.h" |
-#include "core/rendering/PaintPhase.h" |
#include "core/rendering/RenderObject.h" |
#include "wtf/text/StringBuilder.h" |
namespace { |
-const char* AnnotationKeyRendererName = "RENDERER"; |
-const char* AnnotationKeyPaintPhase = "PHASE"; |
-const char* AnnotationKeyElementId = "ID"; |
-const char* AnnotationKeyElementClass = "CLASS"; |
-const char* AnnotationKeyElementTag = "TAG"; |
- |
static const char* paintPhaseName(WebCore::PaintPhase phase) |
{ |
switch (phase) { |
@@ -84,26 +78,30 @@ static const char* paintPhaseName(WebCore::PaintPhase phase) |
namespace WebCore { |
-GraphicsContextAnnotation::GraphicsContextAnnotation(const PaintInfo& paintInfo, const RenderObject* object) |
- : m_rendererName(0) |
- , m_paintPhase(0) |
+void GraphicsContextAnnotator::annotate(const PaintInfo& paintInfo, const RenderObject* object) |
{ |
+ ASSERT(!m_context); |
+ |
ASSERT(paintInfo.context); |
ASSERT(object); |
AnnotationModeFlags mode = paintInfo.context->annotationMode(); |
Element* element = object->node() && object->node()->isElementNode() ? toElement(object->node()) : 0; |
+ const char* rendererName = 0; |
+ const char* paintPhase = 0; |
+ String elementId, elementClass, elementTag; |
+ |
if (mode & AnnotateRendererName) |
- m_rendererName = object->renderName(); |
+ rendererName = object->renderName(); |
if (mode & AnnotatePaintPhase) |
- m_paintPhase = paintPhaseName(paintInfo.phase); |
+ paintPhase = paintPhaseName(paintInfo.phase); |
if ((mode & AnnotateElementId) && element) { |
const AtomicString id = element->getIdAttribute(); |
if (!id.isNull() && !id.isEmpty()) |
- m_elementId = id.string(); |
+ elementId = id.string(); |
} |
if ((mode & AnnotateElementClass) && element && element->hasClass()) { |
@@ -116,40 +114,15 @@ GraphicsContextAnnotation::GraphicsContextAnnotation(const PaintInfo& paintInfo, |
classBuilder.append(classes[i]); |
} |
- m_elementClass = classBuilder.toString(); |
+ elementClass = classBuilder.toString(); |
} |
} |
if ((mode & AnnotateElementTag) && element) |
- m_elementTag = element->tagName(); |
-} |
- |
-void GraphicsContextAnnotation::asAnnotationList(AnnotationList &list) const |
-{ |
- list.clear(); |
- |
- if (m_rendererName) |
- list.append(std::make_pair(AnnotationKeyRendererName, m_rendererName)); |
- |
- if (m_paintPhase) |
- list.append(std::make_pair(AnnotationKeyPaintPhase, m_paintPhase)); |
- |
- if (!m_elementId.isEmpty()) |
- list.append(std::make_pair(AnnotationKeyElementId, m_elementId)); |
- |
- if (!m_elementClass.isEmpty()) |
- list.append(std::make_pair(AnnotationKeyElementClass, m_elementClass)); |
- |
- if (!m_elementTag.isEmpty()) |
- list.append(std::make_pair(AnnotationKeyElementTag, m_elementTag)); |
-} |
- |
-void GraphicsContextAnnotator::annotate(const PaintInfo& paintInfo, const RenderObject* object) |
-{ |
- ASSERT(!m_context); |
+ elementTag = element->tagName(); |
m_context = paintInfo.context; |
- m_context->beginAnnotation(GraphicsContextAnnotation(paintInfo, object)); |
+ m_context->beginAnnotation(GraphicsContextAnnotation(rendererName, paintPhase, elementId, elementClass, elementTag)); |
} |
void GraphicsContextAnnotator::finishAnnotation() |