[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
kocienda
kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:34:30 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 0ef4ed3fd63e84a4417f2db64a2790773a506df1
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Apr 15 23:23:11 2004 +0000
Reviewed by Dave
Improved selection behavior. As part of this work, I removed
almost all of the checkSelectionPoint() functions, leaving
only those associated with fonts, and all of the
checkSelectionPointIgnoringContinuations() functions. Each
of these has been replaced by a new function called
positionForCoordinates(), which returns a DOMPosition.
* WebCore.pbproj/project.pbxproj:
* khtml/khtml_events.cpp:
(khtml::MouseEvent::offset): Converted to use positionForCoordinates.
* khtml/khtml_part.cpp: Ditto.
(KHTMLPart::isPointInsideSelection):
(KHTMLPart::handleMousePressEventDoubleClick): Ditto.
(KHTMLPart::handleMousePressEventTripleClick): Ditto.
(KHTMLPart::handleMousePressEventSingleClick): Ditto.
(KHTMLPart::handleMouseMoveEventSelection): Ditto.
(KHTMLPart::khtmlMouseReleaseEvent): Ditto.
* khtml/khtml_part.h:
* khtml/rendering/render_block.cpp:
(khtml::RenderBlock::positionForBox): New helper.
(khtml::RenderBlock::positionForRenderer): New helper.
(khtml::RenderBlock::positionForCoordinates): New selection-node-offset-finder method.
* khtml/rendering/render_block.h:
* khtml/rendering/render_br.cpp: Removed checkSelectionPointIgnoringContinuations.
No special behavior is needed for this class anymore.
* khtml/rendering/render_br.h: Ditoo.
* khtml/rendering/render_container.cpp:
(RenderContainer::positionForCoordinates): New selection-node-offset-finder method.
* khtml/rendering/render_container.h:
* khtml/rendering/render_line.cpp:
(InlineBox::firstLeafChild): New helper.
(InlineBox::lastLeafChild): New helper.
(InlineFlowBox::firstLeafChild): New helper.
(InlineFlowBox::lastLeafChild): New helper.
* khtml/rendering/render_line.h:
* khtml/rendering/render_object.cpp:
(RenderObject::firstLeafChild): New helper.
(RenderObject::lastLeafChild): New helper.
(RenderObject::positionForCoordinates):
* khtml/rendering/render_object.h:
* khtml/rendering/render_replaced.cpp:
(RenderReplaced::positionForCoordinates): New selection-node-offset-finder method.
* khtml/rendering/render_replaced.h:
* khtml/rendering/render_text.cpp:
(InlineTextBox::offsetForPosition): New helper, replaces checkSelectionPoint()
(RenderText::positionForCoordinates): New selection-node-offset-finder method.
* khtml/rendering/render_text.h:
* khtml/xml/dom_nodeimpl.cpp: Added positionForCoordinates() convenience here. This
checks to see if the node has a renderer before doing the position check.
* khtml/xml/dom_nodeimpl.h: Ditto.
* kwq/DOM.mm:
(-[DOMNode isContentEditable]): Added this unrelated method, since without it, I crash when dragging an image.
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge moveCaretToPoint:]): Converted to use positionForCoordinates.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6392 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index ea900e7..c45c500 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,62 @@
+2004-04-15 Ken Kocienda <kocienda at apple.com>
+
+ Reviewed by Dave
+
+ Improved selection behavior. As part of this work, I removed
+ almost all of the checkSelectionPoint() functions, leaving
+ only those associated with fonts, and all of the
+ checkSelectionPointIgnoringContinuations() functions. Each
+ of these has been replaced by a new function called
+ positionForCoordinates(), which returns a DOMPosition.
+
+ * WebCore.pbproj/project.pbxproj:
+ * khtml/khtml_events.cpp:
+ (khtml::MouseEvent::offset): Converted to use positionForCoordinates.
+ * khtml/khtml_part.cpp: Ditto.
+ (KHTMLPart::isPointInsideSelection):
+ (KHTMLPart::handleMousePressEventDoubleClick): Ditto.
+ (KHTMLPart::handleMousePressEventTripleClick): Ditto.
+ (KHTMLPart::handleMousePressEventSingleClick): Ditto.
+ (KHTMLPart::handleMouseMoveEventSelection): Ditto.
+ (KHTMLPart::khtmlMouseReleaseEvent): Ditto.
+ * khtml/khtml_part.h:
+ * khtml/rendering/render_block.cpp:
+ (khtml::RenderBlock::positionForBox): New helper.
+ (khtml::RenderBlock::positionForRenderer): New helper.
+ (khtml::RenderBlock::positionForCoordinates): New selection-node-offset-finder method.
+ * khtml/rendering/render_block.h:
+ * khtml/rendering/render_br.cpp: Removed checkSelectionPointIgnoringContinuations.
+ No special behavior is needed for this class anymore.
+ * khtml/rendering/render_br.h: Ditoo.
+ * khtml/rendering/render_container.cpp:
+ (RenderContainer::positionForCoordinates): New selection-node-offset-finder method.
+ * khtml/rendering/render_container.h:
+ * khtml/rendering/render_line.cpp:
+ (InlineBox::firstLeafChild): New helper.
+ (InlineBox::lastLeafChild): New helper.
+ (InlineFlowBox::firstLeafChild): New helper.
+ (InlineFlowBox::lastLeafChild): New helper.
+ * khtml/rendering/render_line.h:
+ * khtml/rendering/render_object.cpp:
+ (RenderObject::firstLeafChild): New helper.
+ (RenderObject::lastLeafChild): New helper.
+ (RenderObject::positionForCoordinates):
+ * khtml/rendering/render_object.h:
+ * khtml/rendering/render_replaced.cpp:
+ (RenderReplaced::positionForCoordinates): New selection-node-offset-finder method.
+ * khtml/rendering/render_replaced.h:
+ * khtml/rendering/render_text.cpp:
+ (InlineTextBox::offsetForPosition): New helper, replaces checkSelectionPoint()
+ (RenderText::positionForCoordinates): New selection-node-offset-finder method.
+ * khtml/rendering/render_text.h:
+ * khtml/xml/dom_nodeimpl.cpp: Added positionForCoordinates() convenience here. This
+ checks to see if the node has a renderer before doing the position check.
+ * khtml/xml/dom_nodeimpl.h: Ditto.
+ * kwq/DOM.mm:
+ (-[DOMNode isContentEditable]): Added this unrelated method, since without it, I crash when dragging an image.
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge moveCaretToPoint:]): Converted to use positionForCoordinates.
+
2004-04-15 David Hyatt <hyatt at apple.com>
Fix for 3603455, block truncation support.
diff --git a/WebCore/khtml/khtml_events.cpp b/WebCore/khtml/khtml_events.cpp
index 98afc23..f920b47 100644
--- a/WebCore/khtml/khtml_events.cpp
+++ b/WebCore/khtml/khtml_events.cpp
@@ -20,6 +20,7 @@
#include "khtml_events.h"
#include "rendering/render_object.h"
#include "xml/dom_nodeimpl.h"
+#include "xml/dom_position.h"
using namespace khtml;
using namespace DOM;
@@ -52,19 +53,15 @@ khtml::MouseEvent::~MouseEvent()
long khtml::MouseEvent::offset() const
{
- int offset = 0;
- DOM::NodeImpl* tempNode = 0;
- int absX, absY;
- absX = absY = 0;
- if (innerNode().handle()->renderer()) {
+ DOMPosition pos;
+ if (innerNode().handle()) {
// FIXME: Shouldn't be necessary to skip text nodes.
DOM::Node inner = innerNode();
if (inner.nodeType() == Node::TEXT_NODE)
inner = inner.parentNode();
- inner.handle()->renderer()->absolutePosition(absX, absY);
- inner.handle()->renderer()->checkSelectionPoint(m_x, m_y, absX, absY, tempNode, offset );
+ pos = inner.handle()->positionForCoordinates(m_x, m_y);
}
- return offset;
+ return pos.offset();
}
const char *khtml::MousePressEvent::s_strMousePressEvent = "khtml/Events/MousePressEvent";
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index ecc1f54..cab37de 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -4481,24 +4481,22 @@ bool KHTMLPart::isPointInsideSelection(int x, int y)
return false;
}
- int offset = 0, ax, ay;
- DOM::NodeImpl* node = 0;
-
// FIXME: Shouldn't be necessary to skip text nodes.
if (innerNode->nodeType() == Node::TEXT_NODE) {
innerNode = innerNode->parentNode();
}
- innerNode->renderer()->absolutePosition (ax, ay);
- innerNode->renderer()->checkSelectionPoint( x, y, ax-innerNode->renderer()->xPos(), ay-innerNode->renderer()->yPos(), node, offset);
- if (!node) {
+ int ax, ay;
+ innerNode->renderer()->absolutePosition(ax, ay);
+ DOMPosition pos(innerNode->positionForCoordinates(ax, ay));
+ if (pos.isEmpty()) {
return false;
}
DOM::NodeImpl *n = d->m_selection.startNode();
while (n) {
- if (n == node) {
- if ((n == d->m_selection.startNode() && offset < d->m_selection.startOffset()) ||
- (n == d->m_selection.endNode() && offset > d->m_selection.endOffset())) {
+ if (n == pos.node()) {
+ if ((n == d->m_selection.startNode() && pos.offset() < d->m_selection.startOffset()) ||
+ (n == d->m_selection.endNode() && pos.offset() > d->m_selection.endOffset())) {
return false;
}
return true;
@@ -4521,20 +4519,6 @@ bool KHTMLPart::isPointInsideSelection(int x, int y)
#if APPLE_CHANGES
-void KHTMLPart::checkSelectionPoint(khtml::MouseEvent *event, DOM::NodeImpl *&node, int &offset)
-{
- DOM::Node innerNode = event->innerNode();
-
- // EDIT FIXME: Shouldn't be necessary to skip text nodes.
- if (innerNode.nodeType() == Node::TEXT_NODE)
- innerNode = innerNode.parentNode();
-
- innerNode.handle()->renderer()->checkSelectionPoint(event->x(), event->y(),
- event->absX()-innerNode.handle()->renderer()->xPos(),
- event->absY()-innerNode.handle()->renderer()->yPos(),
- node, offset);
-}
-
void KHTMLPart::handleMousePressEventDoubleClick(khtml::MousePressEvent *event)
{
QMouseEvent *mouse = event->qmouseEvent();
@@ -4543,11 +4527,9 @@ void KHTMLPart::handleMousePressEventDoubleClick(khtml::MousePressEvent *event)
KHTMLSelection selection;
if (mouse->button() == LeftButton && !innerNode.isNull() && innerNode.handle()->renderer()) {
- NodeImpl *node = 0;
- int offset = 0;
- checkSelectionPoint(event, node, offset);
- if (node && (node->nodeType() == Node::TEXT_NODE || node->nodeType() == Node::CDATA_SECTION_NODE)) {
- selection.moveTo(node, offset);
+ DOMPosition pos(innerNode.handle()->positionForCoordinates(event->x(), event->y()));
+ if (pos.node() && (pos.node()->nodeType() == Node::TEXT_NODE || pos.node()->nodeType() == Node::CDATA_SECTION_NODE)) {
+ selection.moveTo(pos);
selection.expandToElement(KHTMLSelection::WORD);
}
}
@@ -4568,11 +4550,9 @@ void KHTMLPart::handleMousePressEventTripleClick(khtml::MousePressEvent *event)
KHTMLSelection selection;
if (mouse->button() == LeftButton && !innerNode.isNull() && innerNode.handle()->renderer()) {
- NodeImpl* node = 0;
- int offset = 0;
- checkSelectionPoint(event, node, offset);
- if (node && (node->nodeType() == Node::TEXT_NODE || node->nodeType() == Node::CDATA_SECTION_NODE)) {
- selection.moveTo(node, offset);
+ DOMPosition pos(innerNode.handle()->positionForCoordinates(event->x(), event->y()));
+ if (pos.node() && (pos.node()->nodeType() == Node::TEXT_NODE || pos.node()->nodeType() == Node::CDATA_SECTION_NODE)) {
+ selection.moveTo(pos);
selection.expandToElement(KHTMLSelection::LINE);
}
}
@@ -4592,25 +4572,25 @@ void KHTMLPart::handleMousePressEventSingleClick(khtml::MousePressEvent *event)
QMouseEvent *mouse = event->qmouseEvent();
DOM::Node innerNode = event->innerNode();
- if (mouse->button() == LeftButton) {
+ if (mouse->button() == LeftButton) {
KHTMLSelection selection;
if (!innerNode.isNull() && innerNode.handle()->renderer()) {
#if APPLE_CHANGES
- // Don't restart the selection when the mouse is pressed on an
- // existing selection so we can allow for text dragging.
- if (isPointInsideSelection(event->x(), event->y())) {
- return;
- }
+ // Don't restart the selection when the mouse is pressed on an
+ // existing selection so we can allow for text dragging.
+ if (isPointInsideSelection(event->x(), event->y())) {
+ return;
+ }
#endif
- DOM::NodeImpl* node = 0;
- int offset = 0;
- checkSelectionPoint(event, node, offset);
- selection.moveTo(node, offset);
- }
+ DOMPosition pos(innerNode.handle()->positionForCoordinates(event->x(), event->y()));
+ if (pos.isEmpty())
+ pos = DOMPosition(innerNode.handle(), innerNode.handle()->caretMinOffset());
+ selection = pos;
+ }
setSelection(selection);
- startAutoScroll();
- }
+ startAutoScroll();
+ }
}
void KHTMLPart::khtmlMousePressEvent(khtml::MousePressEvent *event)
@@ -4803,14 +4783,11 @@ void KHTMLPart::handleMouseMoveEventSelection(khtml::MouseMoveEvent *event)
return;
// handle making selection
- DOM::NodeImpl* node = 0;
- int offset = 0;
-
- checkSelectionPoint(event, node, offset);
+ DOMPosition pos(innerNode.handle()->positionForCoordinates(event->x(), event->y()));
#if APPLE_CHANGES
// Don't modify the selection if we're not on a node.
- if (node == 0)
+ if (pos.isEmpty())
return;
// Restart the selection if this is the first mouse move. This work is usually
@@ -4819,11 +4796,11 @@ void KHTMLPart::handleMouseMoveEventSelection(khtml::MouseMoveEvent *event)
sel.clearModifyBias();
if (!d->m_mouseMovedSinceLastMousePress) {
d->m_mouseMovedSinceLastMousePress = true;
- sel.moveTo(node, offset);
+ sel.moveTo(pos);
}
#endif
- sel.setExtent(node, offset);
+ sel.setExtent(pos.node(), pos.offset());
#if APPLE_CHANGES
if (d->m_textElement != KHTMLSelection::CHARACTER) {
@@ -4894,12 +4871,8 @@ void KHTMLPart::khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event )
d->m_selection.state() == KHTMLSelection::RANGE &&
d->m_textElement == KHTMLSelection::CHARACTER) {
KHTMLSelection selection;
- if (isEditingAtNode(d->m_selection.baseNode())) {
- NodeImpl *node = 0;
- int offset = 0;
- checkSelectionPoint(event, node, offset);
- selection.moveTo(node, offset);
- }
+ if (isEditingAtNode(d->m_selection.baseNode()))
+ selection.moveTo(d->m_selection.baseNode()->positionForCoordinates(event->x(), event->y()));
setSelection(selection);
}
#endif
diff --git a/WebCore/khtml/khtml_part.h b/WebCore/khtml/khtml_part.h
index 76cad99..69c28f5 100644
--- a/WebCore/khtml/khtml_part.h
+++ b/WebCore/khtml/khtml_part.h
@@ -1187,8 +1187,6 @@ private:
void replaceContentsWithScriptResult( const KURL &url );
- void checkSelectionPoint(khtml::MouseEvent *event, DOM::NodeImpl *&node, int &offset);
-
bool handleMouseMoveEventDrag(khtml::MouseMoveEvent *event);
bool handleMouseMoveEventOver(khtml::MouseMoveEvent *event);
void handleMouseMoveEventSelection(khtml::MouseMoveEvent *event);
diff --git a/WebCore/khtml/rendering/render_block.cpp b/WebCore/khtml/rendering/render_block.cpp
index c914059..52e7240 100644
--- a/WebCore/khtml/rendering/render_block.cpp
+++ b/WebCore/khtml/rendering/render_block.cpp
@@ -33,6 +33,7 @@
#include "rendering/render_canvas.h"
#include "xml/dom_nodeimpl.h"
#include "xml/dom_docimpl.h"
+#include "xml/dom_position.h"
#include "html/html_formimpl.h"
#include "render_block.h"
@@ -2016,15 +2017,119 @@ bool RenderBlock::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty,
return inBox;
}
-FindSelectionResult RenderBlock::checkSelectionPointIgnoringContinuations(int _x, int _y, int _tx, int _ty, DOM::NodeImpl *&node, int &offset)
+DOMPosition RenderBlock::positionForBox(InlineBox *box, bool start) const
{
- if (!firstChild() && element()) {
- node = element();
- offset = 0;
- return SelectionPointBefore;
+ if (!box)
+ return DOMPosition();
+
+ if (!box->object()->element())
+ return DOMPosition(element(), start ? caretMinOffset() : caretMaxOffset());
+
+ if (!box->isInlineTextBox())
+ return DOMPosition(box->object()->element(), start ? box->object()->caretMinOffset() : box->object()->caretMaxOffset());
+
+ InlineTextBox *textBox = static_cast<InlineTextBox *>(box);
+ return DOMPosition(box->object()->element(), start ? textBox->start() : textBox->start() + textBox->len());
+}
+
+DOMPosition RenderBlock::positionForRenderer(RenderObject *renderer, bool start) const
+{
+ if (!renderer)
+ return DOMPosition();
+
+ NodeImpl *node = renderer->element() ? renderer->element() : element();
+ long offset = start ? node->caretMinOffset() : node->caretMaxOffset();
+ return DOMPosition(node, offset);
+}
+
+DOMPosition RenderBlock::positionForCoordinates(int _x, int _y)
+{
+ if (isTable())
+ return RenderFlow::positionForCoordinates(_x, _y);
+
+ int absx, absy;
+ absolutePosition(absx, absy);
+
+ int top = absy + borderTop() + paddingTop();
+ int bottom = top + contentHeight();
+
+ if (_y < top)
+ // y coordinate is above block
+ return positionForRenderer(firstLeafChild(), true);
+
+ if (_y >= bottom)
+ // y coordinate is below block
+ return positionForRenderer(lastLeafChild(), false);
+
+ if (childrenInline()) {
+ if (!firstRootBox())
+ return DOMPosition(element(), 0);
+
+ if (_y >= top && _y < absy + firstRootBox()->topOverflow())
+ // y coordinates is above first root line box
+ return positionForBox(firstRootBox()->firstLeafChild(), true);
+
+ if (_y < bottom && _y >= absy + lastRootBox()->bottomOverflow())
+ // y coordinates is below last root line box
+ return positionForBox(lastRootBox()->lastLeafChild(), false);
+
+ // look for the closest line box in the root box which is at the passed-in y coordinate
+ for (RootInlineBox *root = firstRootBox(); root; root = root->nextRootBox()) {
+ top = absy + root->topOverflow();
+ if (root->nextRootBox())
+ bottom = absy + root->nextRootBox()->topOverflow();
+ else
+ bottom = absy + root->bottomOverflow();
+ if (_y >= top && _y < bottom) {
+ InlineBox *closestBox = root->firstChild();
+ int min = INT_MAX;
+ bool start = true;
+ for (InlineBox *box = root->firstChild(); box; box = box->nextOnLine()) {
+ int cmp;
+ cmp = abs(_x - (absx + box->m_x));
+ if (cmp < min) {
+ closestBox = box;
+ min = cmp;
+ start = true;
+ }
+ cmp = abs(_x - (absx + box->m_x + box->m_width));
+ if (cmp < min) {
+ closestBox = box;
+ min = cmp;
+ start = false;
+ }
+ }
+ if (closestBox)
+ return positionForBox(start ? closestBox->firstLeafChild() : closestBox->lastLeafChild(), start);
+ }
+ }
+ return DOMPosition(element(), 0);
}
- return RenderFlow::checkSelectionPointIgnoringContinuations(_x, _y, _tx, _ty, node, offset);
+ // see if any child blocks exist at this y coordinate
+ for (RenderObject *renderer = firstChild(); renderer; renderer = renderer->nextSibling()) {
+ if (renderer->isFloatingOrPositioned())
+ continue;
+ renderer->absolutePosition(absx, top);
+ RenderObject *next = renderer->nextSibling();
+ while (next && next->isFloatingOrPositioned()) {
+ next = next->nextSibling();
+ }
+ if (next)
+ next->absolutePosition(absx, bottom);
+ else
+ bottom = top + contentHeight();
+ if (_y >= top && _y < bottom) {
+ return renderer->positionForCoordinates(_x, _y);
+ }
+ }
+
+ // pass along to the first child
+ if (firstChild())
+ return firstChild()->positionForCoordinates(_x, _y);
+
+ // still no luck...return this render object's element, if there isn't one, and offset 0
+ return DOMPosition(element(), 0);
}
void RenderBlock::calcMinMaxWidth()
diff --git a/WebCore/khtml/rendering/render_block.h b/WebCore/khtml/rendering/render_block.h
index d922d67..061bb0a 100644
--- a/WebCore/khtml/rendering/render_block.h
+++ b/WebCore/khtml/rendering/render_block.h
@@ -29,6 +29,10 @@
#include "render_flow.h"
+namespace DOM {
+ class DOMPosition;
+};
+
namespace khtml {
class RenderBlock : public RenderFlow
@@ -168,8 +172,7 @@ public:
bool isPointInScrollbar(int x, int y, int tx, int ty);
- virtual FindSelectionResult checkSelectionPointIgnoringContinuations
- (int _x, int _y, int _tx, int _ty, DOM::NodeImpl *&, int &);
+ virtual DOM::DOMPosition positionForCoordinates(int x, int y);
virtual void calcMinMaxWidth();
void calcInlineMinMaxWidth();
@@ -204,6 +207,10 @@ protected:
void newLine();
void removeChildrenFromLineBoxes();
+private:
+ DOM::DOMPosition positionForBox(InlineBox *box, bool start=true) const;
+ DOM::DOMPosition positionForRenderer(RenderObject *renderer, bool start=true) const;
+
protected:
struct FloatingObject {
enum Type {
diff --git a/WebCore/khtml/rendering/render_br.cpp b/WebCore/khtml/rendering/render_br.cpp
index aa0d9a6..3f5704e 100644
--- a/WebCore/khtml/rendering/render_br.cpp
+++ b/WebCore/khtml/rendering/render_br.cpp
@@ -82,21 +82,6 @@ void RenderBR::setStyle(RenderStyle* _style)
m_lineHeight = -1;
}
-FindSelectionResult RenderBR::checkSelectionPointIgnoringContinuations(int _x, int _y, int _tx, int _ty, DOM::NodeImpl*& node, int &offset)
-{
- FindSelectionResult result = RenderText::checkSelectionPointIgnoringContinuations(_x, _y, _tx, _ty, node, offset);
-
- // Since the DOM does not consider this to be a text element, we can't return an offset of 1,
- // because that means after the first child (and we have none) rather than after the
- // first character. Instead we return a result of "after" and an offset of 0.
- if (offset == 1 && node == element()) {
- offset = 0;
- result = SelectionPointAfter;
- }
-
- return result;
-}
-
long RenderBR::caretMinOffset() const
{
return 0;
diff --git a/WebCore/khtml/rendering/render_br.h b/WebCore/khtml/rendering/render_br.h
index 998451f..9e11c12 100644
--- a/WebCore/khtml/rendering/render_br.h
+++ b/WebCore/khtml/rendering/render_br.h
@@ -64,8 +64,6 @@ public:
virtual unsigned long caretMaxRenderedOffset() const;
virtual void caretPos(int offset, bool override, int &_x, int &_y, int &_w, int &_h);
-
- virtual FindSelectionResult checkSelectionPointIgnoringContinuations(int _x, int _y, int _tx, int _ty, DOM::NodeImpl*& node, int &offset);
private:
int m_x;
diff --git a/WebCore/khtml/rendering/render_container.cpp b/WebCore/khtml/rendering/render_container.cpp
index 10292d3..d3f8dcf 100644
--- a/WebCore/khtml/rendering/render_container.cpp
+++ b/WebCore/khtml/rendering/render_container.cpp
@@ -31,6 +31,7 @@
#include "render_image.h"
#include "render_canvas.h"
#include "xml/dom_docimpl.h"
+#include "xml/dom_position.h"
#include <kdebug.h>
#include <assert.h>
@@ -40,6 +41,7 @@
#include "KWQAccObjectCache.h"
#endif
+using DOM::DOMPosition;
using namespace khtml;
RenderContainer::RenderContainer(DOM::NodeImpl* node)
@@ -472,5 +474,33 @@ void RenderContainer::removeLeftoverAnonymousBoxes()
if ( parent() )
parent()->removeLeftoverAnonymousBoxes();
}
+
+DOMPosition RenderContainer::positionForCoordinates(int _x, int _y)
+{
+ // no children...return this render object's element, if there isn't one, and offset 0
+ if (!firstChild())
+ return DOMPosition(element(), 0);
+
+ // look for the geometically-closest child and pass off to that child
+ int min = INT_MAX;
+ int absx, absy;
+ absolutePosition(absx, absy);
+ RenderObject *closestRenderer = firstChild();
+ for (RenderObject *renderer = firstChild(); renderer; renderer = renderer->nextSibling()) {
+ renderer->absolutePosition(absx, absy);
+ int top = absy + borderTop() + paddingTop();
+ int bottom = top + renderer->contentHeight();
+ int left = absx + borderLeft() + paddingLeft();
+ int right = left + renderer->contentWidth();
+
+ int cmp;
+ cmp = abs(_y - top); if (cmp < min) { closestRenderer = renderer; min = cmp; }
+ cmp = abs(_y - bottom); if (cmp < min) { closestRenderer = renderer; min = cmp; }
+ cmp = abs(_x - left); if (cmp < min) { closestRenderer = renderer; min = cmp; }
+ cmp = abs(_x - right); if (cmp < min) { closestRenderer = renderer; min = cmp; }
+ }
+
+ return closestRenderer->positionForCoordinates(_x, _y);
+}
#undef DEBUG_LAYOUT
diff --git a/WebCore/khtml/rendering/render_container.h b/WebCore/khtml/rendering/render_container.h
index c254007..33869df 100644
--- a/WebCore/khtml/rendering/render_container.h
+++ b/WebCore/khtml/rendering/render_container.h
@@ -24,6 +24,10 @@
#include "render_object.h"
+namespace DOM {
+ class DOMPosition;
+};
+
namespace khtml
{
@@ -57,6 +61,8 @@ public:
void updatePseudoChild(RenderStyle::PseudoId type, RenderObject* child);
+ virtual DOM::DOMPosition positionForCoordinates(int x, int y);
+
private:
void setFirstChild(RenderObject *first) { m_first = first; }
void setLastChild(RenderObject *last) { m_last = last; }
diff --git a/WebCore/khtml/rendering/render_line.cpp b/WebCore/khtml/rendering/render_line.cpp
index c7ebab8..4859d66 100644
--- a/WebCore/khtml/rendering/render_line.cpp
+++ b/WebCore/khtml/rendering/render_line.cpp
@@ -155,6 +155,16 @@ bool InlineBox::prevOnLineExists() const
return parent()->prevOnLineExists();
}
+InlineBox* InlineBox::firstLeafChild()
+{
+ return this;
+}
+
+InlineBox* InlineBox::lastLeafChild()
+{
+ return this;
+}
+
int InlineFlowBox::marginLeft()
{
if (!includeLeftEdge())
@@ -719,6 +729,36 @@ void InlineFlowBox::paintDecorations(RenderObject::PaintInfo& i, int _tx, int _t
}
}
+InlineBox* InlineFlowBox::firstLeafChild()
+{
+ InlineBox *box = firstChild();
+ while (box) {
+ InlineBox* next = 0;
+ if (!box->isInlineFlowBox())
+ break;
+ next = static_cast<InlineFlowBox*>(box)->firstChild();
+ if (!next)
+ break;
+ box = next;
+ }
+ return box;
+}
+
+InlineBox* InlineFlowBox::lastLeafChild()
+{
+ InlineBox *box = lastChild();
+ while (box) {
+ InlineBox* next = 0;
+ if (!box->isInlineFlowBox())
+ break;
+ next = static_cast<InlineFlowBox*>(box)->lastChild();
+ if (!next)
+ break;
+ box = next;
+ }
+ return box;
+}
+
void RootInlineBox::adjustVerticalPosition(int delta)
{
InlineFlowBox::adjustVerticalPosition(delta);
diff --git a/WebCore/khtml/rendering/render_line.h b/WebCore/khtml/rendering/render_line.h
index 3b89d9d..7052ceb 100644
--- a/WebCore/khtml/rendering/render_line.h
+++ b/WebCore/khtml/rendering/render_line.h
@@ -89,7 +89,10 @@ public:
void setPrevOnLine(InlineBox* prev) { m_prev = prev; }
bool nextOnLineExists() const;
bool prevOnLineExists() const;
-
+
+ virtual InlineBox* firstLeafChild();
+ virtual InlineBox* lastLeafChild();
+
RenderObject* object() const { return m_object; }
InlineFlowBox* parent() const { return m_parent; }
@@ -189,7 +192,10 @@ public:
InlineBox* firstChild() { return m_firstChild; }
InlineBox* lastChild() { return m_lastChild; }
-
+
+ virtual InlineBox* firstLeafChild();
+ virtual InlineBox* lastLeafChild();
+
virtual void setConstructed() {
InlineBox::setConstructed();
if (m_firstChild)
@@ -270,7 +276,7 @@ public:
RootInlineBox* nextRootBox() { return static_cast<RootInlineBox*>(m_nextLine); }
RootInlineBox* prevRootBox() { return static_cast<RootInlineBox*>(m_prevLine); }
-
+
virtual void adjustVerticalPosition(int delta);
virtual bool isRootInlineBox() { return true; }
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index 983da89..c654e47 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -30,6 +30,7 @@
#include "rendering/render_canvas.h"
#include "xml/dom_elementimpl.h"
#include "xml/dom_docimpl.h"
+#include "xml/dom_position.h"
#include "css/cssstyleselector.h"
#include "misc/htmlhashes.h"
#include <kdebug.h>
@@ -359,6 +360,32 @@ RenderObject *RenderObject::previousEditable() const
return 0;
}
+RenderObject *RenderObject::firstLeafChild() const
+{
+ RenderObject *r = firstChild();
+ while (r) {
+ RenderObject *n = 0;
+ n = r->firstChild();
+ if (!n)
+ break;
+ r = n;
+ }
+ return r;
+}
+
+RenderObject *RenderObject::lastLeafChild() const
+{
+ RenderObject *r = lastChild();
+ while (r) {
+ RenderObject *n = 0;
+ n = r->lastChild();
+ if (!n)
+ break;
+ r = n;
+ }
+ return r;
+}
+
static void addLayers(RenderObject* obj, RenderLayer* parentLayer, RenderObject*& newObject,
RenderLayer*& beforeChild)
{
@@ -1694,61 +1721,9 @@ void RenderObject::arenaDelete(RenderArena *arena)
arenaDelete(arena, dynamic_cast<void *>(this));
}
-FindSelectionResult RenderObject::checkSelectionPoint(int _x, int _y, int _tx, int _ty, DOM::NodeImpl*& node, int & offset )
+DOMPosition RenderObject::positionForCoordinates(int x, int y)
{
- FindSelectionResult result = checkSelectionPointIgnoringContinuations(_x, _y, _tx, _ty, node, offset);
-
- if (isInline())
- for (RenderObject *c = continuation(); result == SelectionPointAfter && c; c = c->continuation())
- if (c->isInline()) {
- int ncx, ncy;
- c->absolutePosition(ncx, ncy);
- result = c->checkSelectionPointIgnoringContinuations(_x, _y, ncx - c->xPos(), ncy - c->yPos(), node, offset);
- }
-
- return result;
-}
-
-FindSelectionResult RenderObject::checkSelectionPointIgnoringContinuations(int _x, int _y, int _tx, int _ty, DOM::NodeImpl*& node, int & offset )
-{
- int lastOffset=0;
- int off = offset;
- DOM::NodeImpl* nod = node;
- DOM::NodeImpl* lastNode = 0;
-
- for (RenderObject *child = firstChild(); child; child=child->nextSibling()) {
- FindSelectionResult pos = child->checkSelectionPointIgnoringContinuations(_x, _y, _tx+xPos(), _ty+yPos(), nod, off);
- //kdDebug(6030) << this << " child->findSelectionNode returned " << pos << endl;
- switch(pos) {
- case SelectionPointBeforeInLine:
- case SelectionPointAfterInLine:
- case SelectionPointInside:
- node = nod;
- offset = off;
- return SelectionPointInside;
- case SelectionPointBefore:
- //x,y is before this element -> stop here
- if ( lastNode) {
- node = lastNode;
- offset = lastOffset;
-// kdDebug(6030) << "ElementImpl::findSelectionNode " << this << " before this child "
-// << node << "-> returning offset=" << offset << endl;
- return SelectionPointInside;
- } else {
-// kdDebug(6030) << "ElementImpl::findSelectionNode " << this << " before us -> returning -2" << endl;
- return SelectionPointBefore;
- }
- break;
- case SelectionPointAfter:
-// kdDebug(6030) << "ElementImpl::findSelectionNode: selection after: " << nod << " offset: " << off << endl;
- lastNode = nod;
- lastOffset = off;
- }
- }
-
- node = lastNode;
- offset = lastOffset;
- return SelectionPointAfter;
+ return DOMPosition(element(), caretMinOffset());
}
bool RenderObject::mouseInside() const
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index 0b3fb7e..0b86fa6 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -81,6 +81,7 @@ typedef enum {
namespace DOM {
class HTMLAreaElementImpl;
+ class DOMPosition;
class DOMString;
class DocumentImpl;
class ElementImpl;
@@ -125,6 +126,9 @@ public:
RenderObject *nextEditable() const;
RenderObject *previousEditable() const;
+
+ RenderObject *firstLeafChild() const;
+ RenderObject *lastLeafChild() const;
virtual RenderLayer* layer() const { return 0; }
RenderLayer* enclosingLayer();
@@ -473,11 +477,11 @@ public:
RepaintInfo(RenderObject* o, const QRect& r) :m_object(o), m_repaintRect(r) {}
};
- FindSelectionResult checkSelectionPoint(int x, int y, int tx, int ty, DOM::NodeImpl*&, int& offset);
- virtual FindSelectionResult checkSelectionPointIgnoringContinuations(int x, int y, int tx, int ty, DOM::NodeImpl*&, int& offset);
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty,
HitTestAction hitTestAction = HitTestAll, bool inside=false);
+ virtual DOM::DOMPosition positionForCoordinates(int x, int y);
+
virtual void dirtyLinesFromChangedChild(RenderObject* child);
// set the style of the object.
diff --git a/WebCore/khtml/rendering/render_replaced.cpp b/WebCore/khtml/rendering/render_replaced.cpp
index adfed15..0e0b2a3 100644
--- a/WebCore/khtml/rendering/render_replaced.cpp
+++ b/WebCore/khtml/rendering/render_replaced.cpp
@@ -37,6 +37,7 @@
#include "xml/dom2_eventsimpl.h"
#include "khtml_part.h"
#include "xml/dom_docimpl.h" // ### remove dependency
+#include "xml/dom_position.h"
#include <kdebug.h>
using namespace khtml;
@@ -126,26 +127,21 @@ unsigned long RenderReplaced::caretMaxRenderedOffset() const
return 1;
}
-FindSelectionResult RenderReplaced::checkSelectionPointIgnoringContinuations(int _x, int _y, int _tx, int _ty, DOM::NodeImpl *&node, int &offset)
+DOMPosition RenderReplaced::positionForCoordinates(int _x, int _y)
{
- int l = xPos() + _tx;
- int r = xPos() + _tx + width();
- int t = yPos() + _ty;
- int b = yPos() + _ty + height();
+ int absx, absy;
+ absolutePosition(absx, absy);
- bool pointIsInside = (_x >= l && _x <= r && _y >= t && _y <= b);
+ bool pointIsInside = (_x >= absx && _x < absx + width() &&
+ _y >= absy && _y < absx + height());
if (pointIsInside && element()) {
- node = element();
- if (_x < l + (width() / 2)) {
- offset = 0;
- return SelectionPointBefore;
- }
- offset = 1;
- return SelectionPointAfter;
+ if (_x <= absx + (width() / 2))
+ return DOMPosition(element(), 0);
+ return DOMPosition(element(), 1);
}
- return RenderBox::checkSelectionPointIgnoringContinuations(_x, _y, _tx, _ty, node, offset);
+ return RenderBox::positionForCoordinates(_x, _y);
}
// -----------------------------------------------------------------------------
diff --git a/WebCore/khtml/rendering/render_replaced.h b/WebCore/khtml/rendering/render_replaced.h
index 3a0a123..7120ea2 100644
--- a/WebCore/khtml/rendering/render_replaced.h
+++ b/WebCore/khtml/rendering/render_replaced.h
@@ -27,6 +27,10 @@
class KHTMLView;
class QWidget;
+namespace DOM {
+ class DOMPosition;
+}
+
namespace khtml {
class RenderReplaced : public RenderBox
@@ -55,9 +59,7 @@ public:
virtual long caretMinOffset() const;
virtual long caretMaxOffset() const;
virtual unsigned long caretMaxRenderedOffset() const;
-
- virtual FindSelectionResult checkSelectionPointIgnoringContinuations
- (int _x, int _y, int _tx, int _ty, DOM::NodeImpl *&, int &);
+ virtual DOM::DOMPosition positionForCoordinates(int x, int y);
private:
int m_intrinsicWidth;
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index fdb31d7..4f03423 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -29,6 +29,7 @@
#include "rendering/break_lines.h"
#include "xml/dom_nodeimpl.h"
#include "xml/dom_docimpl.h"
+#include "xml/dom_position.h"
#include "render_arena.h"
#include "misc/loader.h"
@@ -202,63 +203,46 @@ unsigned long InlineTextBox::caretMaxRenderedOffset() const
#define LOCAL_WIDTH_BUF_SIZE 1024
-FindSelectionResult InlineTextBox::checkSelectionPoint(int _x, int _y, int _tx, int _ty, const Font *f, RenderText *text, int & offset, short lineHeight)
+int InlineTextBox::offsetForPosition(int _x, int _tx, const Font *f, const RenderText *text)
{
-// kdDebug(6040) << "InlineTextBox::checkSelectionPoint " << this << " _x=" << _x << " _y=" << _y
-// << " _tx+m_x=" << _tx+m_x << " _ty+m_y=" << _ty+m_y << endl;
- offset = 0;
+ if (_x < _tx + m_x)
+ // we're to the left
+ return -1;
- if ( _y < _ty + root()->topOverflow() )
- return SelectionPointBefore; // above -> before
-
- if ( _y > _ty + root()->bottomOverflow() ) {
- // below -> after
- // Set the offset to the max
- offset = m_len;
- return SelectionPointAfter;
- }
- if ( _x > _tx + m_x + m_width ) {
- // to the right
- return m_reversed ? SelectionPointBeforeInLine : SelectionPointAfterInLine;
- }
-
- // The Y matches, check if we're on the left
- if ( _x < _tx + m_x ) {
- return m_reversed ? SelectionPointAfterInLine : SelectionPointBeforeInLine;
- }
+ if (_x >= _tx + m_x + m_width)
+ // we're to the right
+ return -1;
#if APPLE_CHANGES
- int pos = f->checkSelectionPoint (text->str->s, text->str->l, m_start, m_len, m_toAdd, _x - (_tx + m_x), m_reversed);
+ return f->checkSelectionPoint(text->str->s, text->str->l, m_start, m_len, m_toAdd, _x - (_tx + m_x), m_reversed);
#else
- int delta = _x - (_tx + m_x);
- //kdDebug(6040) << "InlineTextBox::checkSelectionPoint delta=" << delta << endl;
int pos = 0;
- if ( m_reversed ) {
- delta -= m_width;
- while(pos < m_len) {
- int w = f->width( text->str->s, text->str->l, m_start + pos);
- int w2 = w/2;
- w -= w2;
- delta += w2;
- if(delta >= 0) break;
- pos++;
- delta += w;
- }
- } else {
- while(pos < m_len) {
- int w = f->width( text->str->s, text->str->l, m_start + pos);
- int w2 = w/2;
- w -= w2;
- delta -= w2;
- if(delta <= 0) break;
- pos++;
- delta -= w;
- }
+ int delta = _x - (_tx + m_x);
+ if (m_reversed) {
+ delta -= m_width;
+ while (pos < m_len) {
+ int w = f->width( text->str->s, text->str->l, m_start + pos);
+ int w2 = w/2;
+ w -= w2;
+ delta += w2;
+ if(delta >= 0) break;
+ pos++;
+ delta += w;
+ }
+ }
+ else {
+ while (pos < m_len) {
+ int w = f->width( text->str->s, text->str->l, m_start + pos);
+ int w2 = w/2;
+ w -= w2;
+ delta -= w2;
+ if(delta <= 0) break;
+ pos++;
+ delta -= w;
+ }
}
+ return pos;
#endif
-// kdDebug( 6040 ) << " Text --> inside at position " << pos << endl;
- offset = pos;
- return SelectionPointInside;
}
// -------------------------------------------------------------------------------------
@@ -463,48 +447,33 @@ bool RenderText::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty,
return inside;
}
-FindSelectionResult RenderText::checkSelectionPointIgnoringContinuations(int _x, int _y, int _tx, int _ty, DOM::NodeImpl*& node, int &offset)
+DOMPosition RenderText::positionForCoordinates(int _x, int _y)
{
-// kdDebug(6040) << "RenderText::checkSelectionPoint " << this << " _x=" << _x << " _y=" << _y
-// << " _tx=" << _tx << " _ty=" << _ty << endl;
- InlineTextBox *lastPointAfterInline=0;
+ if (!firstTextBox() || stringLength() == 0)
+ return DOMPosition(element(), 0);
- for (InlineTextBox* s = firstTextBox(); s; s = s->nextTextBox()) {
- int result;
- const Font *f = htmlFont(s == firstTextBox());
- result = s->checkSelectionPoint(_x, _y, _tx, _ty, f, this, offset, lineHeight(false));
+ int absx, absy;
+ absolutePosition(absx, absy);
-// kdDebug(6040) << "RenderText::checkSelectionPoint " << this << " line " << si << " result=" << result << " offset=" << offset << endl;
- if ( result == SelectionPointInside ) // x,y is inside the InlineTextBox
- {
- offset += s->m_start; // add the offset from the previous lines
- //kdDebug(6040) << "RenderText::checkSelectionPoint inside -> " << offset << endl;
- node = element();
- return SelectionPointInside;
- } else if ( result == SelectionPointBefore ) {
- // x,y is before the InlineTextBox -> stop here
- if ( s != firstTextBox() && lastPointAfterInline ) {
- offset = lastPointAfterInline->m_start + lastPointAfterInline->m_len;
- //kdDebug(6040) << "RenderText::checkSelectionPoint before -> " << offset << endl;
- node = element();
- return SelectionPointInside;
- } else {
- offset = 0;
- //kdDebug(6040) << "RenderText::checkSelectionPoint " << this << "before us -> returning Before" << endl;
- node = element();
- return SelectionPointBefore;
- }
- } else if ( result == SelectionPointAfterInLine ) {
- lastPointAfterInline = s;
- }
+ int top = absy + firstTextBox()->root()->topOverflow();
+ int bottom = absy + lastTextBox()->root()->bottomOverflow();
+ if (_y < top)
+ return DOMPosition(element(), caretMinOffset()); // coordinates are above
+
+ if (_y >= bottom)
+ return DOMPosition(element(), caretMaxOffset()); // coordinates are below
+
+ for (InlineTextBox *box = firstTextBox(); box; box = box->nextTextBox()) {
+ if (_y >= absy + box->root()->topOverflow() && _y < absy + box->root()->bottomOverflow()) {
+ const Font *f = htmlFont(box == firstTextBox());
+ int offset = box->offsetForPosition(_x, absx, f, this);
+ if (offset != -1)
+ return DOMPosition(element(), offset + box->m_start);
+ }
}
-
- // set offset to max
- offset = str->l;
- //qDebug("setting node to %p", element());
- node = element();
- return SelectionPointAfter;
+
+ return DOMPosition(element(), 0);
}
void RenderText::caretPos(int offset, bool override, int &_x, int &_y, int &width, int &height)
diff --git a/WebCore/khtml/rendering/render_text.h b/WebCore/khtml/rendering/render_text.h
index 440003a..64ba6ef 100644
--- a/WebCore/khtml/rendering/render_text.h
+++ b/WebCore/khtml/rendering/render_text.h
@@ -36,6 +36,10 @@
class QPainter;
class QFontMetrics;
+namespace DOM {
+ class DOMPosition;
+};
+
// Define a constant for soft hyphen's unicode value.
#define SOFT_HYPHEN 173
@@ -95,9 +99,8 @@ public:
virtual long caretMaxOffset() const;
virtual unsigned long caretMaxRenderedOffset() const;
- // Return before, after (offset set to max), or inside the text, at @p offset
- FindSelectionResult checkSelectionPoint(int _x, int _y, int _tx, int _ty, const Font *f, RenderText *text, int & offset, short lineheight);
-
+ int offsetForPosition(int _x, int _tx, const Font *f, const RenderText *text);
+
/**
* if this text run was rendered @ref _ty pixels below the upper edge
* of a view, would the @ref _y -coordinate be inside the vertical range
@@ -151,9 +154,7 @@ public:
virtual void absoluteRects(QValueList<QRect>& rects, int _tx, int _ty);
- // Return before, after (offset set to max), or inside the text, at @p offset
- virtual FindSelectionResult checkSelectionPointIgnoringContinuations
- (int _x, int _y, int _tx, int _ty, DOM::NodeImpl*& node, int & offset);
+ virtual DOM::DOMPosition positionForCoordinates(int _x, int _y);
unsigned int length() const { return str->l; }
QChar *text() const { return str->s; }
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index 05e04b0..7cdbdfa 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -30,6 +30,7 @@
#include "xml/dom_textimpl.h"
#include "xml/dom2_eventsimpl.h"
#include "xml/dom_docimpl.h"
+#include "xml/dom_position.h"
#include "xml/dom2_rangeimpl.h"
#include "css/csshelper.h"
#include "css/cssstyleselector.h"
@@ -1421,6 +1422,14 @@ bool NodeImpl::inSameContainingEditableBlock(NodeImpl *n)
return n ? containingEditableBlock() == n->containingEditableBlock() : false;
}
+DOMPosition NodeImpl::positionForCoordinates(int x, int y)
+{
+ if (renderer())
+ return renderer()->positionForCoordinates(x, y);
+
+ return DOMPosition(this, 0);
+}
+
//-------------------------------------------------------------------------
NodeBaseImpl::NodeBaseImpl(DocumentPtr *doc)
diff --git a/WebCore/khtml/xml/dom_nodeimpl.h b/WebCore/khtml/xml/dom_nodeimpl.h
index 1b4774b..9099c6c 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.h
+++ b/WebCore/khtml/xml/dom_nodeimpl.h
@@ -49,6 +49,7 @@ namespace khtml {
namespace DOM {
+class DOMPosition;
class NodeListImpl;
class NamedNodeMapImpl;
class DocumentImpl;
@@ -166,6 +167,8 @@ public:
bool inSameRootEditableBlock(NodeImpl *);
bool inSameContainingEditableBlock(NodeImpl *);
+
+ DOMPosition positionForCoordinates(int x, int y);
// used by the parser. Doesn't do as many error checkings as
// appendChild(), and returns the node into which will be parsed next.
diff --git a/WebCore/kwq/DOM.mm b/WebCore/kwq/DOM.mm
index 1f866df..dc070de 100644
--- a/WebCore/kwq/DOM.mm
+++ b/WebCore/kwq/DOM.mm
@@ -408,6 +408,11 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
return reinterpret_cast<NodeImpl *>(_internal);
}
+- (BOOL)isContentEditable
+{
+ return [self _nodeImpl]->isContentEditable();
+}
+
@end
//------------------------------------------------------------------------------------------
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 6d1b3fe..000b1b8 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -406,14 +406,7 @@ static bool initializedKJS = FALSE;
return NO;
}
- NodeImpl *tempNode;
- int absX = 0;
- int absY = 0;
- int offset;
- node->renderer()->absolutePosition(absX, absY);
- node->renderer()->checkSelectionPoint((int)point.x, (int)point.y, absX, absY, tempNode, offset);
-
- KHTMLSelection selection(node, offset);
+ KHTMLSelection selection(node->positionForCoordinates((int)point.x, (int)point.y));
_part->setSelection(selection);
return YES;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list