KHtml

kjs_context2d.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2004 Apple Computer, Inc.
4  * Copyright (C) 2005 Zack Rusin <[email protected]>
5  * Copyright (C) 2007, 2008 Maksim Orlovich <[email protected]>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef KJS_CONTEXT2D_H
22 #define KJS_CONTEXT2D_H
23 
24 #include "kjs_dom.h"
25 #include "kjs_binding.h"
26 #include "kjs_html.h"
27 #include <kjs/object.h>
28 
29 #include "misc/loader_client.h"
30 #include "html/html_canvasimpl.h"
31 
32 #include <QPainterPath>
33 
34 namespace DOM
35 {
36 class HTMLElementImpl;
37 }
38 
39 namespace KJS
40 {
41 
42 ////////////////////// Context2D Object ////////////////////////
43 DEFINE_PSEUDO_CONSTRUCTOR(Context2DPseudoCtor)
44 
45 class Context2D : public DOMWrapperObject<DOM::CanvasContext2DImpl>
46 {
47  friend class Context2DFunction;
48 public:
49  Context2D(ExecState *exec, DOM::CanvasContext2DImpl *ctx);
50 
51  using KJS::JSObject::getOwnPropertySlot;
52  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
53  JSValue *getValueProperty(ExecState *exec, int token) const;
54  using KJS::JSObject::put;
55  void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None) override;
56  void putValueProperty(ExecState *exec, int token, JSValue *value, int /*attr*/);
57 
58  const ClassInfo *classInfo() const override
59  {
60  return &info;
61  }
62  static const ClassInfo info;
63 
64  enum {
65  Canvas,
66  Save, Restore, // state
67  Scale, Rotate, Translate, Transform, SetTransform, // transformations
68  GlobalAlpha, GlobalCompositeOperation, // compositing
69  StrokeStyle, FillStyle, CreateLinearGradient, CreateRadialGradient, CreatePattern, // colors and styles.
70  LineWidth, LineCap, LineJoin, MiterLimit, // line properties
71  ShadowOffsetX, ShadowOffsetY, ShadowBlur, ShadowColor, // shadow properties
72  ClearRect, FillRect, StrokeRect, // rectangle ops
73  BeginPath, ClosePath, MoveTo, LineTo, QuadraticCurveTo, BezierCurveTo, ArcTo, Rect, Arc,
74  Fill, Stroke, Clip, IsPointInPath, // paths
75  DrawImage, // do we want backwards compat for drawImageFromRect?
76  GetImageData, PutImageData, CreateImageData // pixel ops. ewww.
77  };
78 };
79 
80 class CanvasGradient : public DOMWrapperObject<DOM::CanvasGradientImpl>
81 {
82 public:
83  CanvasGradient(ExecState *exec, DOM::CanvasGradientImpl *impl);
84 
85  const ClassInfo *classInfo() const override
86  {
87  return &info;
88  }
89  static const ClassInfo info;
90 
91  enum {
92  AddColorStop
93  };
94 };
95 
96 class CanvasPattern : public DOMWrapperObject<DOM::CanvasPatternImpl>
97 {
98 public:
99  CanvasPattern(ExecState *exec, DOM::CanvasPatternImpl *i);
100 
101  const ClassInfo *classInfo() const override
102  {
103  return &info;
104  }
105  static const ClassInfo info;
106 };
107 
108 // Return 0 if conversion failed
109 DOM::CanvasImageDataImpl *toCanvasImageData(ExecState *exec, JSValue *val);
110 
111 class CanvasImageDataArray;
112 class CanvasImageData : public DOMWrapperObject<DOM::CanvasImageDataImpl>
113 {
114 public:
115  CanvasImageData(ExecState *exec, DOM::CanvasImageDataImpl *i);
116 
117  const ClassInfo *classInfo() const override
118  {
119  return &info;
120  }
121  static const ClassInfo info;
122 
123  JSObject *valueClone(Interpreter *targetCtx) const override;
124 
125  void mark() override;
126 private:
127  CanvasImageDataArray *data;
128 };
129 
130 class CanvasImageDataArray : public JSObject
131 {
132 public:
133  CanvasImageDataArray(ExecState *exec, CanvasImageData *p);
134 
135  const ClassInfo *classInfo() const override
136  {
137  return &info;
138  }
139  static const ClassInfo info;
140 
141  void mark() override;
142 
143  // Performs conversion/claming/rounding of color components as specified in HTML5 spec.
144  static unsigned char decodeComponent(ExecState *exec, JSValue *val);
145 
146  bool getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot &slot) override;
147  bool getOwnPropertySlot(ExecState *exec, unsigned index, PropertySlot &slot) override;
148  void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr) override;
149  void put(ExecState *exec, unsigned index, JSValue *value, int attr) override;
150 
151  JSValue *indexGetter(ExecState *exec, unsigned index);
152 private:
153  unsigned size;
154  CanvasImageData *parent;
155 };
156 
157 DEFINE_PSEUDO_CONSTRUCTOR(SVGAnglePseudoCtor)
158 
159 } // namespace
160 
161 #endif
KIOCORE_EXPORT TransferJob * put(const QUrl &url, int permissions, JobFlags flags=DefaultFlags)
This library provides a full-featured HTML parser and widget.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:05 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.