[webkit-changes] cvs commit: WebCore/khtml/editing
visible_position.cpp
Justin
justing at opensource.apple.com
Fri Dec 2 01:00:29 PST 2005
justing 05/12/02 01:00:29
Modified: . ChangeLog
khtml/editing visible_position.cpp
Log:
<http://bugzilla.opendarwin.org/show_bug.cgi?id=4003>
contentEditable div cannot be edited if it starts out with empty or <p/>
Reviewed/tweaked/landed by justin
* khtml/editing/visible_position.cpp:
(khtml::VisiblePosition::init): A position at the original block
shouldn't be considered 'outside' the original block.
(khtml::hasRenderedChildrenWithHeight): Added.
(khtml::VisiblePosition::isCandidate): A block flow element with
rendered children may be considered a candidate for a visible
position, as long as its children do not have a positive height.
Revision Changes Path
1.449 +15 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.448
retrieving revision 1.449
diff -u -r1.448 -r1.449
--- ChangeLog 2 Dec 2005 08:33:47 -0000 1.448
+++ ChangeLog 2 Dec 2005 09:00:25 -0000 1.449
@@ -1,3 +1,18 @@
+2005-12-01 Graham Dennis <Graham.Dennis at gmail.com>
+
+ <http://bugzilla.opendarwin.org/show_bug.cgi?id=4003>
+ contentEditable div cannot be edited if it starts out with empty or <p/>
+
+ Reviewed/tweaked/landed by justin
+
+ * khtml/editing/visible_position.cpp:
+ (khtml::VisiblePosition::init): A position at the original block
+ shouldn't be considered 'outside' the original block.
+ (khtml::hasRenderedChildrenWithHeight): Added.
+ (khtml::VisiblePosition::isCandidate): A block flow element with
+ rendered children may be considered a candidate for a visible
+ position, as long as its children do not have a positive height.
+
2005-12-01 Maciej Stachowiak <mjs at apple.com>
Reviewed by Tim Hatcher.
1.66 +17 -4 WebCore/khtml/editing/visible_position.cpp
Index: visible_position.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/editing/visible_position.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- visible_position.cpp 1 Dec 2005 10:32:14 -0000 1.65
+++ visible_position.cpp 2 Dec 2005 09:00:29 -0000 1.66
@@ -93,10 +93,10 @@
m_deepPosition = next;
else {
NodeImpl *originalBlock = pos.node() ? pos.node()->enclosingBlockFlowElement() : 0;
- bool nextIsInOriginalBlock = next.node()->isAncestor(originalBlock);
- bool prevIsInOriginalBlock = prev.node()->isAncestor(originalBlock);
+ bool nextIsOutsideOriginalBlock = !next.node()->isAncestor(originalBlock) && next.node() != originalBlock;
+ bool prevIsOutsideOriginalBlock = !prev.node()->isAncestor(originalBlock) && prev.node() != originalBlock;
- if (!nextIsInOriginalBlock && prevIsInOriginalBlock ||
+ if (nextIsOutsideOriginalBlock && !prevIsOutsideOriginalBlock ||
(deepPos.node()->hasTagName(brTag) && deepPos.offset() == 0))
m_deepPosition = prev;
else
@@ -192,6 +192,18 @@
return Position();
}
+bool hasRenderedChildrenWithHeight(RenderObject *renderer)
+{
+ if (!renderer->firstChild())
+ return false;
+
+ for (RenderObject *child = renderer->firstChild(); child; child = child->nextSibling())
+ if (child->height())
+ return true;
+
+ return false;
+}
+
bool VisiblePosition::isCandidate(const Position &pos)
{
if (pos.isNull())
@@ -231,7 +243,8 @@
}
}
- if (renderer->isBlockFlow() && (!renderer->firstChild() || !pos.node()->firstChild()) &&
+ if (renderer->isBlockFlow() &&
+ !hasRenderedChildrenWithHeight(renderer) &&
(renderer->height() || pos.node()->hasTagName(bodyTag))) {
// return true for offset 0 into rendered blocks that are empty of rendered kids, but have a height
return pos.offset() == 0;
More information about the webkit-changes
mailing list