/usr/include/dom/dom2_range.h is in kdelibs5-dev 4:4.14.2-5+deb8u2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | /*
* This file is part of the DOM implementation for KDE.
*
* Copyright 1999 Lars Knoll (knoll@kde.org)
* Copyright 2000 Gunnstein Lye (gunnstein@netcom.no)
* Copyright 2000 Frederik Holljen (frederik.holljen@hig.no)
* Copyright 2001 Peter Kelly (pmk@post.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* This file includes excerpts from the Document Object Model (DOM)
* Level 2 Specification (Candidate Recommendation)
* http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/
* Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved.
*
*/
#ifndef _dom2_range_h_
#define _dom2_range_h_
#include <dom/dom_doc.h>
#include <dom/dom_misc.h>
namespace DOM {
class DocumentFragment;
class Node;
class DOMString;
class DocumentImpl;
class RangeImpl;
class DOMException;
// Introduced in DOM Level 2:
class KHTML_EXPORT RangeException {
public:
RangeException(unsigned short _code) { code = _code; }
RangeException(const RangeException &other) { code = other.code; }
RangeException & operator = (const RangeException &other)
{ code = other.code; return *this; }
virtual ~RangeException() {}
/**
* An integer indicating the type of error generated.
*
*/
enum RangeExceptionCode {
BAD_BOUNDARYPOINTS_ERR = 1,
INVALID_NODE_TYPE_ERR = 2,
_EXCEPTION_OFFSET = 2000,
_EXCEPTION_MAX = 2999
};
unsigned short code;
/// Returns the name of this error
DOMString codeAsString() const;
/// Returns the name of given DOM error code
static DOMString codeAsString(int rangeCode);
/** @internal - checks to see whether internal code is a Range one */
static bool isRangeExceptionCode(int exceptioncode);
};
class KHTML_EXPORT Range
{
friend class DocumentImpl;
friend class Document;
friend class RangeImpl;
public:
Range();
Range(const Document rootContainer);
Range(const Range &other);
Range(const Node startContainer, const long startOffset, const Node endContainer, const long endOffset);
Range & operator = (const Range &other);
~Range();
/**
* Node within which the range begins
*
*/
Node startContainer() const;
/**
* Offset within the starting node of the range.
*
*/
long startOffset() const;
/**
* Node within which the range ends
*
*/
Node endContainer() const;
/**
* Offset within the ending node of the range.
*
*/
long endOffset() const;
/**
* true if the range is collapsed
*
*/
bool collapsed() const;
/**
* Gets the common ancestor container of the range's two end-points.
* Also sets it.
*
*/
// ### BIC make const in the next release
Node commonAncestorContainer();
/**
* Sets the attributes describing the start of the range.
*
* @param refNode The \c refNode value. This parameter
* must be different from \c null .
*
* @param offset The \c startOffset value.
*
* @return
*
* @exception RangeException
* NULL_NODE_ERR: Raised if \c refNode is \c null .
*
* INVALID_NODE_TYPE_ERR: Raised if \c refNode or an
* ancestor of \c refNode is an Attr, Entity,
* Notation, or DocumentType node.
*
* If an offset is out-of-bounds, should it just be fixed up or
* should an exception be raised.
*
*/
void setStart ( const Node &refNode, long offset );
/**
* Sets the attributes describing the end of a range.
*
* @param refNode The \c refNode value. This parameter
* must be different from \c null .
*
* @param offset The \c endOffset value.
*
* @return
*
* @exception RangeException
* NULL_NODE_ERR: Raised if \c refNode is \c null .
*
* INVALID_NODE_TYPE_ERR: Raised if \c refNode or an
* ancestor of \c refNode is an Attr, Entity,
* Notation, or DocumentType node.
*
*/
void setEnd ( const Node &refNode, long offset );
/**
* Sets the start position to be before a node
*
* @param refNode Range starts before \c refNode
*
* @return
*
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if an ancestor of \c refNode
* is an Attr, Entity, Notation, or DocumentType node or
* if \c refNode is a Document, DocumentFragment,
* Attr, Entity, or Notation node.
*
*/
void setStartBefore ( const Node &refNode );
/**
* Sets the start position to be after a node
*
* @param refNode Range starts after \c refNode
*
* @return
*
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if an ancestor of \c refNode
* is an Attr, Entity, Notation, or DocumentType node or
* if \c refNode is a Document, DocumentFragment,
* Attr, Entity, or Notation node.
*
*/
void setStartAfter ( const Node &refNode );
/**
* Sets the end position to be before a node.
*
* @param refNode Range ends before \c refNode
*
* @return
*
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if an ancestor of \c refNode
* is an Attr, Entity, Notation, or DocumentType node or
* if \c refNode is a Document, DocumentFragment,
* Attr, Entity, or Notation node.
*
*/
void setEndBefore ( const Node &refNode );
/**
* Sets the end of a range to be after a node
*
* @param refNode Range ends after \c refNode .
*
* @return
*
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if an ancestor of \c refNode
* is an Attr, Entity, Notation or DocumentType node or if
* \c refNode is a Document, DocumentFragment, Attr,
* Entity, or Notation node.
*
*/
void setEndAfter ( const Node &refNode );
/**
* Collapse a range onto one of its end-points
*
* @param toStart If true, collapses the Range onto its start; if
* false, collapses it onto its end.
*
* @return
*
*/
void collapse ( bool toStart );
/**
* Select a node and its contents
*
* @param refNode The node to select.
*
* @return
*
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if an ancestor of \c refNode
* is an Attr, Entity, Notation or DocumentType node or if
* \c refNode is a Document, DocumentFragment, Attr,
* Entity, or Notation node.
*
*/
void selectNode ( const Node &refNode );
/**
* Select the contents within a node
*
* @param refNode Node to select from
*
* @return
*
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if \c refNode or an
* ancestor of \c refNode is an Attr, Entity, Notation
* or DocumentType node.
*
*/
void selectNodeContents ( const Node &refNode );
enum CompareHow {
START_TO_START = 0,
START_TO_END = 1,
END_TO_END = 2,
END_TO_START = 3
};
/**
* Compare the end-points of two ranges in a document.
*
* @param how
*
* @param sourceRange
*
* @return -1, 0 or 1 depending on whether the corresponding
* end-point of the Range is before, equal to, or after the
* corresponding end-point of \c sourceRange .
*
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if the two Ranges are not in the
* same document or document fragment.
*
*/
short compareBoundaryPoints ( CompareHow how, const Range &sourceRange );
/**
* @internal
* not part of the DOM
*
* Compare the boundary-points of a range.
*
* Return true if the startContainer is before the endContainer,
* or if they are equal.
* Return false if the startContainer is after the endContainer.
*
*/
bool boundaryPointsValid ( );
/**
* Removes the contents of a range from the containing document or
* document fragment without returning a reference to the removed
* content.
*
* @return
*
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the
* content of the range is read-only or any of the nodes that
* contain any of the content of the range are read-only.
*
*/
void deleteContents ( );
/**
* Moves the contents of a range from the containing document or
* document fragment to a new DocumentFragment.
*
* @return A DocumentFragment containing the extracted contents.
*
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the
* content of the range is read-only or any of the nodes which
* contain any of the content of the range are read-only.
*
* HIERARCHY_REQUEST_ERR: Raised if a DocumentType node would be
* extracted into the new DocumentFragment.
*
*/
DocumentFragment extractContents ( );
/**
* Duplicates the contents of a range
*
* @return A DocumentFragment containing contents equivalent to
* those of this range.
*
* @exception DOMException
* HIERARCHY_REQUEST_ERR: Raised if a DocumentType node would be
* extracted into the new DocumentFragment.
*
*/
DocumentFragment cloneContents ( );
/**
* Inserts a node into the document or document fragment at the
* start of the range.
*
* @param newNode The node to insert at the start of the range
*
* @return
*
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of
* the start of the range is read-only.
*
* WRONG_DOCUMENT_ERR: Raised if \c newNode and the
* container of the start of the Range were not created from the
* same document.
*
* HIERARCHY_REQUEST_ERR: Raised if the container of the start of
* the Range is of a type that does not allow children of the type
* of \c newNode or if \c newNode is an
* ancestor of the container .
*
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if \c node is an
* Attr, Entity, Notation, DocumentFragment, or Document node.
*
*/
void insertNode ( const Node &newNode );
/**
* Reparents the contents of the range to the given node and
* inserts the node at the position of the start of the range.
*
* @param newParent The node to surround the contents with.
*
* @return
*
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of
* either end-point of the range is read-only.
*
* WRONG_DOCUMENT_ERR: Raised if \c newParent and the
* container of the start of the Range were not created from the
* same document.
*
* HIERARCHY_REQUEST_ERR: Raised if the container of the start of
* the Range is of a type that does not allow children of the type
* of \c newParent or if \c newParent is
* an ancestor of the container or if \c node would
* end up with a child node of a type not allowed by the type of
* \c node .
*
* @exception RangeException
* BAD_ENDPOINTS_ERR: Raised if the range partially selects a
* non-text node.
*
* INVALID_NODE_TYPE_ERR: Raised if \c node is an
* Attr, Entity, DocumentType, Notation, Document, or
* DocumentFragment node.
*
*/
void surroundContents ( const Node &newParent );
/**
* Produces a new range whose end-points are equal to the
* end-points of the range.
*
* @return The duplicated range.
*
*/
Range cloneRange ( );
/**
* Returns the contents of a range as a string.
*
* @return The contents of the range.
*
*/
DOMString toString ( );
/**
* @internal Not part of DOM
*/
DOMString toHTML ( );
/* Mozilla extension - only works for HTML documents. */
DocumentFragment createContextualFragment (const DOMString &html);
/**
* Called to indicate that the range is no longer in use and that
* the implementation may relinquish any resources associated with
* this range. Subsequent calls to any methods or attribute getters
* on this range will result in a DOMException being thrown with an
* error code of INVALID_STATE_ERR.
*
*/
void detach ( );
/**
* not part of the DOM
* true if the range is detached
*
*/
bool isDetached() const;
/**
* @internal
* not part of the DOM
*/
RangeImpl *handle() const;
bool isNull() const;
Range(RangeImpl *i);
protected:
RangeImpl *impl;
private:
void throwException(int exceptioncode) const;
};
} // namespace
#endif
|