当前位置: 首页>>代码示例>>Python>>正文


Python DOM.getNodeType方法代码示例

本文整理汇总了Python中pyjamas.DOM.getNodeType方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.getNodeType方法的具体用法?Python DOM.getNodeType怎么用?Python DOM.getNodeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyjamas.DOM的用法示例。


在下文中一共展示了DOM.getNodeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getAdjacentTextElement

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getNodeType [as 别名]
def getAdjacentTextElement(current, topMostNode, forward=None, traversingUp=False):
    if forward is None:
        forward = topMostNode
        topMostNode = None

    res = None

    #print "getAdjacentTextElement", current, topMostNode, forward, traversingUp

    # If traversingUp, then the children have already been processed
    if not traversingUp:
        if DOM.getChildCount(current) > 0:
            if forward:
                node = DOM.getFirstChild(current)
            else:
                node = DOM.getLastChild(current)

            if DOM.getNodeType(node) == DOM.TEXT_NODE:
                res = node
            else:
                # Depth first traversal, the recursive call deals with
                # siblings
                res = getAdjacentTextElement(node, topMostNode,
                                        forward, False)

    if res is None:
        if forward:
            node = current.nextSibling
        else:
            node = current.previousSibling
        # Traverse siblings
        if node is not None:
            if DOM.getNodeType(node) == DOM.TEXT_NODE:
                res = node
            else:
                #print node, DOM.getNodeType(node), node.innerHTML
                # Depth first traversal, the recursive call deals with
                # siblings
                res = getAdjacentTextElement(node, topMostNode,
                                        forward, False)

    # Go up and over if still not found
    if (res is None)  and  (not DOM.compare(current, topMostNode)):
        node = current.parentNode
        # Stop at document (technically could stop at "html" tag)
        if (node is not None)  and  \
                (DOM.getNodeType(node) != DOM.DOCUMENT_NODE):
            res = getAdjacentTextElement(node, topMostNode,
                                        forward, True)
    return res
开发者ID:Afey,项目名称:pyjs,代码行数:52,代码来源:RangeUtil.py

示例2: findTextPoint

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getNodeType [as 别名]
def findTextPoint(node, offset):
    """
    If the found range is not on a text node, this finds the cooresponding
    text node to where the selection is.  If it is on a text node, just
    directly creates the endpoint from it.

    @param node node returned as an endpoint of a range
    @param offset offset returned to the endpoint of a range
    @return A range end point with a proper (or None) text node
    """
    if DOM.getNodeType(node) == DOM.TEXT_NODE:
        res = RangeEndPoint(node, offset)
    else:
        # search backwards unless this is after the last node
        dirn = offset >= DOM.getChildCount(node)
        child = (DOM.getChildCount(node) == 0) and node or DOM.getChild(node, dirn and (offset - 1) or offset)
        # Get the previous/next text node
        text = RangeUtil.getAdjacentTextElement(child, dirn)
        if text is None:
            # If we didn't find a text node in the preferred direction,
            # try the other direction
            dirn = not dirn
            text = RangeUtil.getAdjacentTextElement(child, dirn)

        res = RangeEndPoint(text, dirn)

    return res
开发者ID:luiseduardohdbackup,项目名称:pyjs,代码行数:29,代码来源:Range.py

示例3: isTextNode

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getNodeType [as 别名]
def isTextNode(node):
    if node is None:
        return False
    return DOM.getNodeType(node) == DOM.TEXT_NODE
开发者ID:Afey,项目名称:pyjs,代码行数:6,代码来源:RangeEndPoint.py


注:本文中的pyjamas.DOM.getNodeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。