[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:41:15 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 74f47bd07e3921d55936eeb17f84dcc412c310d8
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat May 22 06:53:51 2004 +0000
Reviewed by Maciej.
- fixed <rdar://problem/3663659>: (result of toString mistakenly includes all subsequent sibling content)
* khtml/xml/dom2_rangeimpl.h: Added private startNode() and pastEndNode() functions.
* khtml/xml/dom2_rangeimpl.cpp:
(DOM::RangeImpl::toString): Rewrote to use startNode(), pastEndNode(), and traverseNextNode().
The old code here was wrong, and it was easier to rewrite than fix.
(DOM::RangeImpl::checkDeleteExtract): Extracted the logic to compute the start node and the past-end
node into separate functions.
(DOM::RangeImpl::startNode): Added. Started with code extracted from checkDeleteExtract, but then
also fixed bugs by using the new traverseNextSibling. The old code handled cases where the offset was
past the last child in a container incorrectly.
(DOM::RangeImpl::pastEndNode): Added. Started with code extracted from checkDeleteExtract, but then
also fixed bugs by using the new traverseNextSibling. The old code hanlded cases where the offset was
past the last child in a container incorrectly, and also iterated one node too few in cases where the
end contaier was a text node.
* khtml/xml/dom2_traversalimpl.h: Removed a bunch of unused and unneeded member functions.
* khtml/xml/dom_nodeimpl.h: Added traverseNextSibling.
* khtml/xml/dom_nodeimpl.cpp:
(NodeImpl::traverseNextNode): Reformatted the code a little bit.
(NodeImpl::traverseNextSibling): Added. Like traverseNextNode except it starts after the node's children
instead of starting at the beginning of the first child.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 8195022..e1c9300 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,31 @@
+2004-05-21 Darin Adler <darin at apple.com>
+
+ Reviewed by Maciej.
+
+ - fixed <rdar://problem/3663659>: (result of toString mistakenly includes all subsequent sibling content)
+
+ * khtml/xml/dom2_rangeimpl.h: Added private startNode() and pastEndNode() functions.
+ * khtml/xml/dom2_rangeimpl.cpp:
+ (DOM::RangeImpl::toString): Rewrote to use startNode(), pastEndNode(), and traverseNextNode().
+ The old code here was wrong, and it was easier to rewrite than fix.
+ (DOM::RangeImpl::checkDeleteExtract): Extracted the logic to compute the start node and the past-end
+ node into separate functions.
+ (DOM::RangeImpl::startNode): Added. Started with code extracted from checkDeleteExtract, but then
+ also fixed bugs by using the new traverseNextSibling. The old code handled cases where the offset was
+ past the last child in a container incorrectly.
+ (DOM::RangeImpl::pastEndNode): Added. Started with code extracted from checkDeleteExtract, but then
+ also fixed bugs by using the new traverseNextSibling. The old code hanlded cases where the offset was
+ past the last child in a container incorrectly, and also iterated one node too few in cases where the
+ end contaier was a text node.
+
+ * khtml/xml/dom2_traversalimpl.h: Removed a bunch of unused and unneeded member functions.
+
+ * khtml/xml/dom_nodeimpl.h: Added traverseNextSibling.
+ * khtml/xml/dom_nodeimpl.cpp:
+ (NodeImpl::traverseNextNode): Reformatted the code a little bit.
+ (NodeImpl::traverseNextSibling): Added. Like traverseNextNode except it starts after the node's children
+ instead of starting at the beginning of the first child.
+
2004-05-21 Maciej Stachowiak <mjs at apple.com>
Reviewed by Trey.
diff --git a/WebCore/khtml/xml/dom2_rangeimpl.cpp b/WebCore/khtml/xml/dom2_rangeimpl.cpp
index 42bdc4f..4cd9b6f 100644
--- a/WebCore/khtml/xml/dom2_rangeimpl.cpp
+++ b/WebCore/khtml/xml/dom2_rangeimpl.cpp
@@ -5,7 +5,7 @@
* (C) 2000 Gunnstein Lye (gunnstein at netcom.no)
* (C) 2000 Frederik Holljen (frederik.holljen at hig.no)
* (C) 2001 Peter Kelly (pmk at post.com)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * Copyright (C) 2004 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,17 +23,18 @@
* Boston, MA 02111-1307, USA.
*/
-#include "dom/dom_exception.h"
-#include "dom_docimpl.h"
#include "dom2_rangeimpl.h"
+
+#include "dom/dom_exception.h"
#include "dom_textimpl.h"
#include "dom_xmlimpl.h"
#include "html/html_elementimpl.h"
#include "render_block.h"
-using namespace DOM;
-using namespace khtml;
+using khtml::RenderBlock;
+
+namespace DOM {
RangeImpl::RangeImpl(DocumentPtr *_ownerDocument)
{
@@ -813,32 +814,16 @@ DOMString RangeImpl::toString( int &exceptioncode )
}
DOMString text = "";
- NodeImpl *n = m_startContainer;
- while(n) {
- if(n->nodeType() == DOM::Node::TEXT_NODE ||
- n->nodeType() == DOM::Node::CDATA_SECTION_NODE) {
-
+ NodeImpl *pastEnd = pastEndNode();
+ for (NodeImpl *n = startNode(); n != pastEnd; n = n->traverseNextNode()) {
+ if (n->nodeType() == DOM::Node::TEXT_NODE || n->nodeType() == DOM::Node::CDATA_SECTION_NODE) {
DOMString str = static_cast<TextImpl *>(n)->data().copy();
if (n == m_endContainer)
str.truncate(m_endOffset);
if (n == m_startContainer)
- str.remove(0,m_startOffset);
+ str.remove(0, m_startOffset);
text += str;
- if (n == m_endContainer)
- break;
- }
- else if (n->parentNode() == m_endContainer && !n->nextSibling()) {
- break;
- }
- //if (n == m_endContainer) break;
- NodeImpl *next = n->firstChild();
- if (!next) next = n->nextSibling();
-
- while( !next && n->parentNode() ) {
- n = n->parentNode();
- next = n->nextSibling();
}
- n = next;
}
return text;
}
@@ -1293,44 +1278,10 @@ void RangeImpl::setEndContainer(NodeImpl *_endContainer)
m_endContainer->ref();
}
-void RangeImpl::checkDeleteExtract(int &exceptioncode) {
-
- NodeImpl *start;
- if (m_startContainer->nodeType() != Node::TEXT_NODE &&
- m_startContainer->nodeType() != Node::CDATA_SECTION_NODE &&
- m_startContainer->nodeType() != Node::COMMENT_NODE &&
- m_startContainer->nodeType() != Node::PROCESSING_INSTRUCTION_NODE) {
-
- start = m_startContainer->childNode(m_startOffset);
- if (!start) {
- if (m_startContainer->lastChild())
- start = m_startContainer->lastChild()->traverseNextNode();
- else
- start = m_startContainer->traverseNextNode();
- }
- }
- else
- start = m_startContainer;
-
- NodeImpl *end;
- if (m_endContainer->nodeType() != Node::TEXT_NODE &&
- m_endContainer->nodeType() != Node::CDATA_SECTION_NODE &&
- m_endContainer->nodeType() != Node::COMMENT_NODE &&
- m_endContainer->nodeType() != Node::PROCESSING_INSTRUCTION_NODE) {
-
- end = m_endContainer->childNode(m_endOffset);
- if (!end) {
- if (m_endContainer->lastChild())
- end = m_endContainer->lastChild()->traverseNextNode();
- else
- end = m_endContainer->traverseNextNode();
- }
- }
- else
- end = m_endContainer;
-
- NodeImpl *n;
- for (n = start; n != end; n = n->traverseNextNode()) {
+void RangeImpl::checkDeleteExtract(int &exceptioncode)
+{
+ NodeImpl *pastEnd = pastEndNode();
+ for (NodeImpl *n = startNode(); n != pastEnd; n = n->traverseNextNode()) {
if (n->isReadOnly()) {
exceptioncode = DOMException::NO_MODIFICATION_ALLOWED_ERR;
return;
@@ -1347,8 +1298,8 @@ void RangeImpl::checkDeleteExtract(int &exceptioncode) {
}
}
-
-bool RangeImpl::containedByReadOnly() {
+bool RangeImpl::containedByReadOnly() const
+{
NodeImpl *n;
for (n = m_startContainer; n; n = n->parentNode()) {
if (n->isReadOnly())
@@ -1361,10 +1312,34 @@ bool RangeImpl::containedByReadOnly() {
return false;
}
+NodeImpl *RangeImpl::startNode() const
+{
+ switch (m_startContainer->nodeType()) {
+ case Node::CDATA_SECTION_NODE:
+ case Node::COMMENT_NODE:
+ case Node::PROCESSING_INSTRUCTION_NODE:
+ case Node::TEXT_NODE:
+ return m_startContainer;
+ }
+ NodeImpl *child = m_startContainer->childNode(m_startOffset);
+ if (child)
+ return child;
+ return m_startContainer->traverseNextSibling();
+}
+NodeImpl *RangeImpl::pastEndNode() const
+{
+ switch (m_endContainer->nodeType()) {
+ case Node::CDATA_SECTION_NODE:
+ case Node::COMMENT_NODE:
+ case Node::PROCESSING_INSTRUCTION_NODE:
+ case Node::TEXT_NODE:
+ return m_endContainer->traverseNextSibling();
+ }
+ NodeImpl *child = m_endContainer->childNode(m_endOffset);
+ if (child)
+ return child->traverseNextSibling();
+ return m_endContainer->traverseNextSibling();
+}
-
-
-
-
-
+}
diff --git a/WebCore/khtml/xml/dom2_rangeimpl.h b/WebCore/khtml/xml/dom2_rangeimpl.h
index 1038ce7..cea110c 100644
--- a/WebCore/khtml/xml/dom2_rangeimpl.h
+++ b/WebCore/khtml/xml/dom2_rangeimpl.h
@@ -5,6 +5,7 @@
* (C) 2000 Gunnstein Lye (gunnstein at netcom.no)
* (C) 2000 Frederik Holljen (frederik.holljen at hig.no)
* (C) 2001 Peter Kelly (pmk at post.com)
+ * Copyright (C) 2004 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -26,11 +27,15 @@
#ifndef _DOM2_RangeImpl_h_
#define _DOM2_RangeImpl_h_
+#include <qptrlist.h>
#include "dom/dom2_range.h"
#include "misc/shared.h"
namespace DOM {
+class DocumentPtr;
+class NodeImpl;
+
class RangeImpl : public khtml::Shared<RangeImpl>
{
friend class DocumentImpl;
@@ -106,10 +111,13 @@ private:
void setStartContainer(NodeImpl *_startContainer);
void setEndContainer(NodeImpl *_endContainer);
void checkDeleteExtract(int &exceptioncode);
- bool containedByReadOnly();
+ bool containedByReadOnly() const;
+
+ NodeImpl *startNode() const;
+ NodeImpl *pastEndNode() const;
};
-}; // namespace
+} // namespace
#endif
diff --git a/WebCore/khtml/xml/dom2_traversalimpl.h b/WebCore/khtml/xml/dom2_traversalimpl.h
index d8426ea..2350e60 100644
--- a/WebCore/khtml/xml/dom2_traversalimpl.h
+++ b/WebCore/khtml/xml/dom2_traversalimpl.h
@@ -4,7 +4,7 @@
* (C) 1999 Lars Knoll (knoll at kde.org)
* (C) 2000 Frederik Holljen (frederik.holljen at hig.no)
* (C) 2001 Peter Kelly (pmk at post.com)
- * Copyright (C) 2004 Apple Computer, Inc.
+ * Copyright (C) 2004 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -39,22 +39,21 @@ class DocumentImpl;
class NodeFilterImpl : public khtml::Shared<NodeFilterImpl>
{
public:
- NodeFilterImpl() {}
NodeFilterImpl(NodeFilterCondition *);
~NodeFilterImpl();
short acceptNode(const Node &) const;
private:
- NodeFilterImpl(const NodeFilterImpl &) : khtml::Shared<NodeFilterImpl>() {}
- NodeFilterImpl &operator=(const NodeFilterImpl &) { return *this; }
+ NodeFilterImpl(const NodeFilterImpl &);
+ NodeFilterImpl &operator=(const NodeFilterImpl &);
+
NodeFilterCondition *m_condition;
};
class TraversalImpl : public khtml::Shared<TraversalImpl>
{
public:
- TraversalImpl();
TraversalImpl(NodeImpl *, long whatToShow, NodeFilterImpl *, bool expandEntityReferences);
~TraversalImpl();
@@ -74,6 +73,9 @@ public:
short acceptNode(NodeImpl *) const;
private:
+ TraversalImpl(const TraversalImpl &);
+ TraversalImpl &operator=(const TraversalImpl &);
+
NodeImpl *m_root;
long m_whatToShow;
NodeFilterImpl *m_filter;
@@ -101,9 +103,8 @@ public:
void notifyBeforeNodeRemoval(NodeImpl *removed);
private:
- NodeIteratorImpl() {};
- NodeIteratorImpl(const NodeIteratorImpl &) : TraversalImpl() {}
- NodeIteratorImpl &operator=(const NodeIteratorImpl &) { return *this; }
+ NodeIteratorImpl(const NodeIteratorImpl &);
+ NodeIteratorImpl &operator=(const NodeIteratorImpl &);
void setReferenceNode(NodeImpl *);
void setPointerBeforeReferenceNode(bool flag=true) { m_beforeReferenceNode = flag; }
@@ -135,9 +136,8 @@ public:
NodeImpl *nextNode();
private:
- TreeWalkerImpl() {};
- TreeWalkerImpl(const TreeWalkerImpl &) : TraversalImpl() {}
- TreeWalkerImpl &operator=(const TreeWalkerImpl &) { return *this; }
+ TreeWalkerImpl(const TreeWalkerImpl &);
+ TreeWalkerImpl &operator=(const TreeWalkerImpl &);
// convenience for when it is known there will be no exception
void setCurrentNode(NodeImpl *);
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index ff67947..1c81cf6 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -4,7 +4,7 @@
* Copyright (C) 1999 Lars Knoll (knoll at kde.org)
* (C) 1999 Antti Koivisto (koivisto at kde.org)
* (C) 2001 Dirk Mueller (mueller at kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * Copyright (C) 2004 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -888,15 +888,25 @@ NodeImpl *NodeImpl::traverseNextNode(NodeImpl *stayWithin) const
{
if (firstChild())
return firstChild();
- else if (nextSibling())
+ if (nextSibling())
return nextSibling();
- else {
- const NodeImpl *n = this;
- while (n && !n->nextSibling() && (!stayWithin || n->parentNode() != stayWithin))
- n = n->parentNode();
- if (n && (!stayWithin || n->parentNode() != stayWithin))
- return n->nextSibling();
- }
+ const NodeImpl *n = this;
+ while (n && !n->nextSibling() && (!stayWithin || n->parentNode() != stayWithin))
+ n = n->parentNode();
+ if (n && (!stayWithin || n->parentNode() != stayWithin))
+ return n->nextSibling();
+ return 0;
+}
+
+NodeImpl *NodeImpl::traverseNextSibling(NodeImpl *stayWithin) const
+{
+ if (nextSibling())
+ return nextSibling();
+ const NodeImpl *n = this;
+ while (n && !n->nextSibling() && (!stayWithin || n->parentNode() != stayWithin))
+ n = n->parentNode();
+ if (n && (!stayWithin || n->parentNode() != stayWithin))
+ return n->nextSibling();
return 0;
}
diff --git a/WebCore/khtml/xml/dom_nodeimpl.h b/WebCore/khtml/xml/dom_nodeimpl.h
index 0fdad91..80c27d1 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.h
+++ b/WebCore/khtml/xml/dom_nodeimpl.h
@@ -4,7 +4,7 @@
* Copyright (C) 1999 Lars Knoll (knoll at kde.org)
* (C) 1999 Antti Koivisto (koivisto at kde.org)
* (C) 2001 Dirk Mueller (mueller at kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * Copyright (C) 2004 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -318,6 +318,9 @@ public:
* see @ref traversePreviousNode()
*/
NodeImpl *traverseNextNode(NodeImpl *stayWithin = 0) const;
+
+ /* Like traverseNextNode, but skips children and starts with the next sibling. */
+ NodeImpl *traverseNextSibling(NodeImpl *stayWithin = 0) const;
/**
* Does a reverse pre-order traversal to find the node that comes before the current one in document order
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list