Commit e0298176 authored by kocienda's avatar kocienda
Browse files

Reviewed by John

        * khtml/editing/htmlediting_impl.cpp:
        (khtml::ApplyStyleCommandImpl::doApply): Remove the StayInBlock modifier from the
        call to upstream when passing the start position to removeStyle(). This makes the
        start position sufficiently upstream so that all relevant style tags are removed.
        (khtml::ApplyStyleCommandImpl::removeStyle): Pass the start position to nodeFullySelected.
        (khtml::ApplyStyleCommandImpl::nodeFullySelected): Change interface so start position
        for calculation is passed in, rather than recalculating it every time.
        * khtml/editing/htmlediting_impl.h: nodeFullySelected interface change.
        * khtml/xml/dom_position.h: Add a comment about the working of upstream() and
        downstream().


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@7373 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent aca16558
2004-08-26 Ken Kocienda <kocienda@apple.com>
Reviewed by John
* khtml/editing/htmlediting_impl.cpp:
(khtml::ApplyStyleCommandImpl::doApply): Remove the StayInBlock modifier from the
call to upstream when passing the start position to removeStyle(). This makes the
start position sufficiently upstream so that all relevant style tags are removed.
(khtml::ApplyStyleCommandImpl::removeStyle): Pass the start position to nodeFullySelected.
(khtml::ApplyStyleCommandImpl::nodeFullySelected): Change interface so start position
for calculation is passed in, rather than recalculating it every time.
* khtml/editing/htmlediting_impl.h: nodeFullySelected interface change.
* khtml/xml/dom_position.h: Add a comment about the working of upstream() and
downstream().
2004-08-26 Ken Kocienda <kocienda@apple.com>
 
Reviewed by me
......
......@@ -699,7 +699,7 @@ void ApplyStyleCommandImpl::doApply()
// This will ensure we remove all traces of the relevant styles from the selection
// and prevent us from adding redundant ones, as described in:
// <rdar://problem/3724344> Bolding and unbolding creates extraneous tags
removeStyle(start.upstream(StayInBlock), end);
removeStyle(start.upstream(), end);
bool splitStart = splitTextAtStartIfNeeded(start, end);
if (splitStart) {
......@@ -805,7 +805,7 @@ void ApplyStyleCommandImpl::removeStyle(const Position &start, const Position &e
NodeImpl *node = start.node();
while (1) {
NodeImpl *next = node->traverseNextNode();
if (node->isHTMLElement() && nodeFullySelected(node)) {
if (node->isHTMLElement() && nodeFullySelected(start, node)) {
HTMLElementImpl *elem = static_cast<HTMLElementImpl *>(node);
if (isHTMLStyleNode(elem))
removeHTMLStyleNode(elem);
......@@ -818,21 +818,19 @@ void ApplyStyleCommandImpl::removeStyle(const Position &start, const Position &e
}
}
bool ApplyStyleCommandImpl::nodeFullySelected(const NodeImpl *node) const
bool ApplyStyleCommandImpl::nodeFullySelected(const Position &start, const NodeImpl *node) const
{
ASSERT(node);
Position end(endingSelection().end().upstream(StayInBlock));
if (node == end.node())
return end.offset() >= node->caretMaxOffset();
if (node == start.node())
return start.offset() >= node->caretMaxOffset();
for (NodeImpl *child = node->lastChild(); child; child = child->lastChild()) {
if (child == end.node())
return end.offset() >= child->caretMaxOffset();
if (child == start.node())
return start.offset() >= child->caretMaxOffset();
}
return !end.node()->isAncestor(node);
return !start.node()->isAncestor(node);
}
//------------------------------------------------------------------------------------------
......
......@@ -217,7 +217,7 @@ private:
void removeHTMLStyleNode(DOM::HTMLElementImpl *);
void removeCSSStyle(DOM::HTMLElementImpl *);
void removeStyle(const DOM::Position &start, const DOM::Position &end);
bool nodeFullySelected(const DOM::NodeImpl *node) const;
bool nodeFullySelected(const DOM::Position &, const DOM::NodeImpl *node) const;
// style-application helpers
bool splitTextAtStartIfNeeded(const DOM::Position &start, const DOM::Position &end);
......
......@@ -79,8 +79,21 @@ public:
Position leadingWhitespacePosition() const;
Position trailingWhitespacePosition() const;
// These functions only consider leaf nodes, and if stayInBlock is true, blocks.
// Hence, the results from these functions are idiosyncratic, and until you
// become familiar with the results, you may find using these functions confusing.
// I have hopes to make the results of these functions less ambiguous in the near
// future, and have them consider all nodes, and have the Positions that are
// returned follow a simple rule: The upstream position is the position
// earliest in document order that will make the insertion point render in the
// same position as the caller's position. The same goes for downstream position
// except that it is the latest position for earliest position in the above
// description.
Position upstream(bool stayInBlock=false) const;
Position downstream(bool stayInBlock=false) const;
Position equivalentRangeCompliantPosition() const;
Position equivalentShallowPosition() const;
Position equivalentDeepPosition() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment