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

Side by Side Diff: sky/engine/core/rendering/GraphicsContextAnnotator.cpp

Issue 870393002: Remove GraphicsContext annotations. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include "sky/engine/config.h"
33 #include "sky/engine/core/rendering/GraphicsContextAnnotator.h"
34
35 #include "sky/engine/core/inspector/InspectorNodeIds.h"
36 #include "sky/engine/core/rendering/PaintInfo.h"
37 #include "sky/engine/core/rendering/RenderObject.h"
38 #include "sky/engine/platform/graphics/GraphicsContextAnnotation.h"
39 #include "sky/engine/wtf/text/StringBuilder.h"
40
41 namespace {
42
43 const char AnnotationKeyRendererName[] = "RENDERER";
44 const char AnnotationKeyPaintPhase[] = "PHASE";
45 const char AnnotationKeyElementId[] = "ID";
46 const char AnnotationKeyElementClass[] = "CLASS";
47 const char AnnotationKeyElementTag[] = "TAG";
48 const char AnnotationKeyInspectorNodeId[] = "INSPECTOR_ID";
49
50 static const char* paintPhaseName(blink::PaintPhase phase)
51 {
52 switch (phase) {
53 case blink::PaintPhaseBlockBackground:
54 return "BlockBackground";
55 case blink::PaintPhaseChildBlockBackground:
56 return "ChildBlockBackground";
57 case blink::PaintPhaseChildBlockBackgrounds:
58 return "ChildBlockBackgrounds";
59 case blink::PaintPhaseForeground:
60 return "Foreground";
61 case blink::PaintPhaseOutline:
62 return "Outline";
63 case blink::PaintPhaseChildOutlines:
64 return "ChildOutlines";
65 case blink::PaintPhaseSelfOutline:
66 return "SelfOutline";
67 case blink::PaintPhaseSelection:
68 return "Selection";
69 case blink::PaintPhaseMask:
70 return "Mask";
71 default:
72 ASSERT_NOT_REACHED();
73 return "<unknown>";
74 }
75 }
76
77 }
78
79 namespace blink {
80
81 void GraphicsContextAnnotator::annotate(const PaintInfo& paintInfo, const Render Object* object)
82 {
83 ASSERT(!m_context);
84
85 ASSERT(paintInfo.context);
86 ASSERT(object);
87
88 AnnotationList annotations;
89 AnnotationModeFlags mode = paintInfo.context->annotationMode();
90 Element* element = object->node() && object->node()->isElementNode() ? toEle ment(object->node()) : 0;
91
92 if (mode & AnnotateRendererName)
93 annotations.append(std::make_pair(AnnotationKeyRendererName, object->ren derName()));
94
95 if (mode & AnnotatePaintPhase)
96 annotations.append(std::make_pair(AnnotationKeyPaintPhase, paintPhaseNam e(paintInfo.phase)));
97
98 if ((mode & AnnotateElementId) && element && element->hasID())
99 annotations.append(std::make_pair(AnnotationKeyElementId, element->getId Attribute().string()));
100
101 if ((mode & AnnotateElementClass) && element && element->hasClass()) {
102 SpaceSplitString classes = element->classNames();
103 if (!classes.isNull() && classes.size() > 0) {
104 StringBuilder classBuilder;
105 for (size_t i = 0; i < classes.size(); ++i) {
106 if (i > 0)
107 classBuilder.append(' ');
108 classBuilder.append(classes[i]);
109 }
110
111 annotations.append(std::make_pair(AnnotationKeyElementClass, classBu ilder.toString()));
112 }
113 }
114
115 if ((mode & AnnotateElementTag) && element)
116 annotations.append(std::make_pair(AnnotationKeyElementTag, element->tagN ame()));
117
118 if (mode & AnnotateInspectorId) {
119 if (Node* ownerNode = object->node()) {
120 annotations.append(std::make_pair(AnnotationKeyInspectorNodeId,
121 String::number(InspectorNodeIds::idForNode(ownerNode))));
122 }
123 }
124
125 m_context = paintInfo.context;
126 m_context->beginAnnotation(annotations);
127 }
128
129 void GraphicsContextAnnotator::finishAnnotation()
130 {
131 ASSERT(m_context);
132 m_context->endAnnotation();
133 }
134
135 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/GraphicsContextAnnotator.h ('k') | sky/engine/core/rendering/RenderBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698