KHtml

kjs_range.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2001 Peter Kelly ([email protected])
4  * Copyright (C) 2009 Maksim Orlovich ([email protected])
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef _KJS_RANGE_H_
22 #define _KJS_RANGE_H_
23 
24 #include <QPointer>
25 
26 #include "ecma/kjs_dom.h"
27 #include "xml/dom_docimpl.h"
28 #include "xml/dom2_rangeimpl.h"
29 #include "xml/dom_selection.h"
30 
31 namespace KJS
32 {
33 
34 class DOMRange : public DOMObject
35 {
36 public:
37  DOMRange(ExecState *exec, DOM::RangeImpl *r);
38  ~DOMRange();
39  using KJS::JSObject::getOwnPropertySlot;
40  bool getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot &slot) override;
41  JSValue *getValueProperty(ExecState *exec, int token) const;
42  // no put - all read-only
43  const ClassInfo *classInfo() const override
44  {
45  return &info;
46  }
47  static const ClassInfo info;
48  enum { StartContainer, StartOffset, EndContainer, EndOffset, Collapsed,
49  CommonAncestorContainer,
50  SetStart, SetEnd, SetStartBefore, SetStartAfter, SetEndBefore,
51  SetEndAfter, Collapse, SelectNode, SelectNodeContents,
52  CompareBoundaryPoints, DeleteContents, ExtractContents,
53  CloneContents, InsertNode, SurroundContents, CloneRange, ToString,
54  Detach, CreateContextualFragment
55  };
56  DOM::RangeImpl *impl() const
57  {
58  return m_impl.get();
59  }
60 protected:
61  SharedPtr<DOM::RangeImpl> m_impl;
62 };
63 
64 class DOMSelection: public JSObject
65 {
66 public:
67  DOMSelection(ExecState *exec, DOM::DocumentImpl *parentDocument);
68 
69  using KJS::JSObject::getOwnPropertySlot;
70  bool getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot &slot) override;
71  JSValue *getValueProperty(ExecState *exec, int token) const;
72  // no put - all read-only
73 
74  const ClassInfo *classInfo() const override
75  {
76  return &info;
77  }
78  static const ClassInfo info;
79 
80  enum { AnchorNode, AnchorOffset, FocusNode, FocusOffset, IsCollapsed,
81  Collapsed, CollapseToStart, CollapseToEnd, SelectAllChildren,
82  DeleteFromDocument, RangeCount, GetRangeAt, AddRange, RemoveRange, RemoveAllRanges, ToString
83  };
84 
85  DOM::Selection currentSelection() const;
86  bool attached() const; // if document & part are still alive..
87  QPointer<DOM::DocumentImpl> m_document;
88 };
89 
90 // Constructor object Range
91 class RangeConstructor : public DOMObject
92 {
93 public:
94  RangeConstructor(ExecState *);
95  using KJS::JSObject::getOwnPropertySlot;
96  bool getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot &slot) override;
97  JSValue *getValueProperty(ExecState *, int token) const;
98  // no put - all read-only
99  const ClassInfo *classInfo() const override
100  {
101  return &info;
102  }
103  static const ClassInfo info;
104 };
105 
106 JSValue *getDOMRange(ExecState *exec, DOM::RangeImpl *r);
107 JSValue *getRangeConstructor(ExecState *exec);
108 JSObject *getRangeExceptionConstructor(ExecState *exec);
109 
110 /**
111  * Convert an object to a RangeImpl. Returns 0 if not possible
112  */
113 DOM::RangeImpl *toRange(JSValue *);
114 
115 DEFINE_PSEUDO_CONSTRUCTOR(RangeExceptionPseudoCtor)
116 
117 class RangeException : public DOMObject
118 {
119 public:
120  RangeException(ExecState *exec);
121  const ClassInfo *classInfo() const override
122  {
123  return &info;
124  }
125  static const ClassInfo info;
126 };
127 
128 } // namespace
129 
130 #endif
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.