KHtml

GraphicsTypes.cpp
1 /*
2  * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "GraphicsTypes.h"
27 
28 #include "PlatformString.h"
29 #include <wtf/Assertions.h>
30 
31 namespace khtml
32 {
33 
34 static const char *const compositeOperatorNames[] = {
35  "clear",
36  "copy",
37  "source-over",
38  "source-in",
39  "source-out",
40  "source-atop",
41  "destination-over",
42  "destination-in",
43  "destination-out",
44  "destination-atop",
45  "xor",
46  "darker",
47  "highlight",
48  "lighter"
49 };
50 const int numCompositeOperatorNames = sizeof(compositeOperatorNames) / sizeof(compositeOperatorNames[0]);
51 
52 bool parseCompositeOperator(const DOM::DOMString &s, CompositeOperator &op)
53 {
54  for (int i = 0; i < numCompositeOperatorNames; i++)
55  if (s == compositeOperatorNames[i]) {
56  op = static_cast<CompositeOperator>(i);
57  return true;
58  }
59  return false;
60 }
61 
62 DOM::DOMString compositeOperatorName(CompositeOperator op)
63 {
64  ASSERT(op >= 0);
65  ASSERT(op < numCompositeOperatorNames);
66  return compositeOperatorNames[op];
67 }
68 
69 bool parseLineCap(const DOM::DOMString &s, LineCap &cap)
70 {
71  if (s == "butt") {
72  cap = ButtCap;
73  return true;
74  }
75  if (s == "round") {
76  cap = RoundCap;
77  return true;
78  }
79  if (s == "square") {
80  cap = SquareCap;
81  return true;
82  }
83  return false;
84 }
85 
86 DOM::DOMString lineCapName(LineCap cap)
87 {
88  ASSERT(cap >= 0);
89  ASSERT(cap < 3);
90  const char *const names[3] = { "butt", "round", "square" };
91  return names[cap];
92 }
93 
94 bool parseLineJoin(const DOM::DOMString &s, LineJoin &join)
95 {
96  if (s == "miter") {
97  join = MiterJoin;
98  return true;
99  }
100  if (s == "round") {
101  join = RoundJoin;
102  return true;
103  }
104  if (s == "bevel") {
105  join = BevelJoin;
106  return true;
107  }
108  return false;
109 }
110 
111 DOM::DOMString lineJoinName(LineJoin join)
112 {
113  ASSERT(join >= 0);
114  ASSERT(join < 3);
115  const char *const names[3] = { "miter", "round", "bevel" };
116  return names[join];
117 }
118 
119 }
This file is part of the HTML rendering engine for KDE.
RoundCap
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
MiterJoin
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:01 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.