Source/core/rendering/RenderBlock.cpp
// FIXME: This function should go on RenderObject as an instance method. Then
// all cases in which positionForPoint recurs could call this instead to
// prevent crossing editable boundaries. This would require many tests.
This function should go on RenderObject as an instance method. Then
all cases in which positionForPoint recurs could call this instead to
prevent crossing editable boundaries. This would require many tests.
This function should go on RenderObject as an instance method . Then all cases in which positionForPoint recurs could call this instead to prevent crossing editable boundaries . This would require many tests .
static PositionWithAffinity positionForPointRespectingEditingBoundaries(RenderBlock* parent, RenderBox* child, const LayoutPoint& pointInParentCoordinates)
{
    LayoutPoint childLocation = child->location();
    if (child->isInFlowPositioned())
        childLocation += child->offsetForInFlowPosition();
    LayoutPoint pointInChildCoordinates(toLayoutPoint(pointInParentCoordinates - childLocation));
    Node* childNode = child->nonPseudoNode();
    if (!childNode)
        return child->positionForPoint(pointInChildCoordinates);
    RenderObject* ancestor = parent;
    while (ancestor && !ancestor->nonPseudoNode())
        ancestor = ancestor->parent();
    if (isEditingBoundary(ancestor, child))
        return child->positionForPoint(pointInChildCoordinates);
    LayoutUnit childMiddle = parent->logicalWidthForChild(child) / 2;
    LayoutUnit logicalLeft = parent->isHorizontalWritingMode() ? pointInChildCoordinates.x() : pointInChildCoordinates.y();
    if (logicalLeft < childMiddle)
        return ancestor->createPositionWithAffinity(childNode->nodeIndex(), DOWNSTREAM);
    return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, UPSTREAM);
}
static PositionWithAffinity positionForPointRespectingEditingBoundaries ( RenderBlock * parent , RenderBox * child , const LayoutPoint & pointInParentCoordinates ) { LayoutPoint childLocation = child -> location ( ) ; if ( child -> isInFlowPositioned ( ) ) childLocation += child -> offsetForInFlowPosition ( ) ; LayoutPoint pointInChildCoordinates ( toLayoutPoint ( pointInParentCoordinates - childLocation ) ) ; Node * childNode = child -> nonPseudoNode ( ) ; if ( ! childNode ) return child -> positionForPoint ( pointInChildCoordinates ) ; RenderObject * ancestor = parent ; while ( ancestor && ! ancestor -> nonPseudoNode ( ) ) ancestor = ancestor -> parent ( ) ; if ( isEditingBoundary ( ancestor , child ) ) return child -> positionForPoint ( pointInChildCoordinates ) ; LayoutUnit childMiddle = parent -> logicalWidthForChild ( child ) / 2 ; LayoutUnit logicalLeft = parent -> isHorizontalWritingMode ( ) ? pointInChildCoordinates . x ( ) : pointInChildCoordinates . y ( ) ; if ( logicalLeft < childMiddle ) return ancestor -> createPositionWithAffinity ( childNode -> nodeIndex ( ) , DOWNSTREAM ) ; return ancestor -> createPositionWithAffinity ( childNode -> nodeIndex ( ) + 1 , UPSTREAM ) ; }
FIXME: This function should go on RenderObject as an instance method.
FIXME : This function should go on RenderObject as an instance method .
// FIXME: This is wrong if the child's writing-mode is different from the parent's. // If this is an anonymous renderer, we just recur normally // Otherwise, first make sure that the editability of the parent and child agree. // If they don't agree, then we return a visible position just before or after the child // If we can't find an ancestor to check editability on, or editability is unchanged, we recur like normal // Otherwise return before or after the child, depending on if the click was to the logical left or logical right of the child