KHtml

render_br.cpp
1 /**
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright (C) 2000 Lars Knoll ([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 License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 #include "render_br.h"
23 
24 using namespace khtml;
25 using DOM::Position;
26 
27 RenderBR::RenderBR(DOM::NodeImpl *node)
28  : RenderText(node, new DOM::DOMStringImpl(QChar('\n')))
29 {
30  m_hasReturn = true;
31 }
32 
33 RenderBR::~RenderBR()
34 {
35 }
36 
37 long RenderBR::caretMinOffset() const
38 {
39  return 0;
40 }
41 
42 long RenderBR::caretMaxOffset() const
43 {
44  return 1;
45 }
46 
47 unsigned long RenderBR::caretMaxRenderedOffset() const
48 {
49  return 1;
50 }
51 
52 RenderPosition RenderBR::positionForCoordinates(int /*_x*/, int /*_y*/)
53 {
54  return RenderPosition(element(), 0);
55 }
56 
57 #if 0
58 void RenderBR::caretPos(int offset, int flags, int &_x, int &_y, int &width, int &height) const
59 {
60  RenderText::caretPos(offset, flags, _x, _y, width, height);
61  return;
62 #if 0
63  if (previousSibling() && !previousSibling()->isBR() && !previousSibling()->isFloating()) {
64  int offset = 0;
65  if (previousSibling()->isText()) {
66  offset = static_cast<RenderText *>(previousSibling())->maxOffset();
67  }
68 
69  // FIXME: this won't return a big width in override mode (LS)
70  previousSibling()->caretPos(offset, override, _x, _y, width, height);
71  return;
72  }
73 
74  int absx, absy;
75  absolutePosition(absx, absy);
76  if (absx == -1) {
77  // we don't know out absolute position, and there is no point returning
78  // just a relative one
79  _x = _y = -1;
80  } else {
81  _x += absx;
82  _y += absy;
83  }
84  height = RenderText::verticalPositionHint(false);
85  width = override ? height / 2 : 1;
86 #endif
87 }
88 #endif
89 
90 FindSelectionResult RenderBR::checkSelectionPoint(int _x, int _y, int _tx, int _ty, DOM::NodeImpl *&node, int &offset, SelPointState &state)
91 {
92  // Simply take result of previous one
93  RenderText *prev = static_cast<RenderText *>(previousSibling());
94  if (!prev || !prev->isText() || !prev->firstTextBox() || prev->isBR()) {
95  prev = this;
96  }
97 
98  //qCDebug(KHTML_LOG) << "delegated to " << prev->renderName() << "@" << prev;
99  return prev->RenderText::checkSelectionPoint(_x, _y, _tx, _ty, node, offset, state);
100 }
101 
102 InlineBox *RenderBR::inlineBox(long /*offset*/)
103 {
104  return firstTextBox();
105 }
This file is part of the HTML rendering engine for KDE.
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:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.