Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1147)

Unified Diff: Source/core/rendering/GraphicsContextAnnotator.cpp

Issue 55223002: Remove rendering dependency in GraphicsContextAnnotation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for relanding Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/GraphicsContextAnnotator.h ('k') | Source/core/rendering/RenderBlock.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « Source/core/rendering/GraphicsContextAnnotator.h ('k') | Source/core/rendering/RenderBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698