亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? visible_units.cpp

?? It is WEB browser core module with source code. Very good!
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

#include "visible_units.h"

#include <qstring.h>

#include "htmltags.h"
#include "misc/helper.h"
#include "rendering/render_text.h"
#include "rendering/render_block.h"
#include "visible_position.h"
#include "visible_text.h"
#include "xml/dom_docimpl.h"
#include "xml/dom_elementimpl.h"

using DOM::DocumentImpl;
using DOM::ElementImpl;
using DOM::NodeImpl;
using DOM::Position;
using DOM::Range;

namespace khtml {

static VisiblePosition previousBoundary(const VisiblePosition &c, unsigned (*searchFunction)(const QChar *, unsigned))
{
    Position pos = c.deepEquivalent();
    NodeImpl *n = pos.node();
    if (!n)
        return VisiblePosition();
    DocumentImpl *d = n->getDocument();
    if (!d)
        return VisiblePosition();
    NodeImpl *de = d->documentElement();
    if (!de)
        return VisiblePosition();
    NodeImpl *boundary = n->enclosingBlockFlowElement();
    if (!boundary)
        return VisiblePosition();
    bool isContentEditable = boundary->isContentEditable();
    while (boundary && boundary != de && boundary->parentNode() && isContentEditable == boundary->parentNode()->isContentEditable()) {
        boundary = boundary->parentNode();
    }

    Range searchRange(d);
    searchRange.setStartBefore(boundary);
    Position end(pos.equivalentRangeCompliantPosition());
    searchRange.setEnd(end.node(), end.offset());
    SimplifiedBackwardsTextIterator it(searchRange);
    QString string;
    unsigned next = 0;
    while (!it.atEnd() && it.length() > 0) {
        // iterate to get chunks until the searchFunction returns a non-zero value.
        string.prepend(it.characters(), it.length());
        next = searchFunction(string.unicode(), string.length());
        if (next != 0)
            break;
        it.advance();
    }
    
    if (it.atEnd() && next == 0) {
        Range range(it.range());
        pos = Position(range.startContainer().handle(), range.startOffset());
    }
    else if (!it.atEnd() && it.length() == 0) {
        // Got a zero-length chunk.
        // This means we have hit a replaced element.
        // Make a check to see if the position should be before or after the replaced element
        // by performing an additional check with a modified string which uses an "X" 
        // character to stand in for the replaced element.
        QChar chars[2];
        chars[0] = 'X';
        chars[1] = ' ';
        string.prepend(chars, 2);
        unsigned pastImage = searchFunction(string.unicode(), string.length());
        Range range(it.range());
        if (pastImage == 0)
            pos = Position(range.startContainer().handle(), range.startOffset());
        else
            pos = Position(range.endContainer().handle(), range.endOffset());
    }
    else if (next != 0) {
        // The simpler iterator used in this function, as compared to the one used in 
        // nextWordPosition(), gives us results we can use directly without having to 
        // iterate again to translate the next value into a DOM position. 
        NodeImpl *node = it.range().startContainer().handle();
        if (node->isTextNode() || (node->renderer() && node->renderer()->isBR())) {
            // The next variable contains a usable index into a text node
            pos = Position(node, next);
        }
        else {
            // If we are not in a text node, we ended on a node boundary, so the
            // range start offset should be used.
            pos = Position(node, it.range().startOffset());
        }
    }

    return VisiblePosition(pos, DOWNSTREAM, VisiblePosition::INIT_DOWN);
}

static VisiblePosition nextBoundary(const VisiblePosition &c, unsigned (*searchFunction)(const QChar *, unsigned))
{
    Position pos = c.deepEquivalent();
    NodeImpl *n = pos.node();
    if (!n)
        return VisiblePosition();
    DocumentImpl *d = n->getDocument();
    if (!d)
        return VisiblePosition();
    NodeImpl *de = d->documentElement();
    if (!de)
        return VisiblePosition();
    NodeImpl *boundary = n->enclosingBlockFlowElement();
    if (!boundary)
        return VisiblePosition();
    bool isContentEditable = boundary->isContentEditable();
    while (boundary && boundary != de && boundary->parentNode() && isContentEditable == boundary->parentNode()->isContentEditable()) {
        boundary = boundary->parentNode();
    }

    Range searchRange(d);
    Position start(pos.equivalentRangeCompliantPosition());
    searchRange.setStart(start.node(), start.offset());
    searchRange.setEndAfter(boundary);
    TextIterator it(searchRange, RUNFINDER);
    QString string;
    unsigned next = 0;
    while (!it.atEnd() && it.length() > 0) {
        // Keep asking the iterator for chunks until the search function
        // returns an end value not equal to the length of the string passed to it.
        string.append(it.characters(), it.length());
        next = searchFunction(string.unicode(), string.length());
        if (next != string.length())
            break;
        it.advance();
    }
    
    if (it.atEnd() && next == string.length()) {
        Range range(it.range());
        pos = Position(range.startContainer().handle(), range.startOffset());
    }
    else if (!it.atEnd() && it.length() == 0) {
        // Got a zero-length chunk.
        // This means we have hit a replaced element.
        // Make a check to see if the position should be before or after the replaced element
        // by performing an additional check with a modified string which uses an "X" 
        // character to stand in for the replaced element.
        QChar chars[2];
        chars[0] = ' ';
        chars[1] = 'X';
        string.append(chars, 2);
        unsigned pastImage = searchFunction(string.unicode(), string.length());
        Range range(it.range());
        if (next != pastImage)
            pos = Position(range.endContainer().handle(), range.endOffset());
        else
            pos = Position(range.startContainer().handle(), range.startOffset());
    }
    else if (next != 0) {
        // Use the character iterator to translate the next value into a DOM position.
        CharacterIterator charIt(searchRange);
        charIt.advance(next - 1);
        pos = Position(charIt.range().endContainer().handle(), charIt.range().endOffset());
    }
    return VisiblePosition(pos, UPSTREAM, VisiblePosition::INIT_UP);
}

// ---------

static unsigned startWordBoundary(const QChar *characters, unsigned length)
{
    int start, end;
    findWordBoundary(characters, length, length, &start, &end);
    return start;
}

VisiblePosition startOfWord(const VisiblePosition &c, EWordSide side)
{
    VisiblePosition p = c;
    if (side == RightWordIfOnBoundary) {
        // at paragraph end, the startofWord is the current position
        if (isEndOfParagraph(c))
            return c;
        
        p = c.next();
        if (p.isNull())
            return c;
    }
    return previousBoundary(p, startWordBoundary);
}

static unsigned endWordBoundary(const QChar *characters, unsigned length)
{
    int start, end;
    findWordBoundary(characters, length, 0, &start, &end);
    return end;
}

VisiblePosition endOfWord(const VisiblePosition &c, EWordSide side)
{
    VisiblePosition p = c;
    if (side == LeftWordIfOnBoundary) {
        if (isStartOfParagraph(c))
            return c;
            
        p = c.previous();
        if (p.isNull())
            return c;
    } else {
        // at paragraph end, the endOfWord is the start of next paragraph
        if (isEndOfParagraph(c)) {
            p = c.next();
            return p.isNotNull() ? p : c;
        }
    }
    
    return nextBoundary(p, endWordBoundary);
}

static unsigned previousWordPositionBoundary(const QChar *characters, unsigned length)
{
    return nextWordFromIndex(characters, length, length, false);
}

VisiblePosition previousWordPosition(const VisiblePosition &c)
{
    return previousBoundary(c, previousWordPositionBoundary);
}

static unsigned nextWordPositionBoundary(const QChar *characters, unsigned length)
{
    return nextWordFromIndex(characters, length, 0, true);
}

VisiblePosition nextWordPosition(const VisiblePosition &c)
{
    return nextBoundary(c, nextWordPositionBoundary);
}

// ---------

static RootInlineBox *rootBoxForLine(const VisiblePosition &c)
{
    Position p = c.deepEquivalent();
    NodeImpl *node = p.node();
    if (!node)
        return 0;

    RenderObject *renderer = node->renderer();
    if (!renderer)
        return 0;
    
    InlineBox *box = renderer->inlineBox(p.offset(), c.affinity());
    if (!box)
        return 0;
    
    return box->root();
}

VisiblePosition startOfLine(const VisiblePosition &c)
{
    RootInlineBox *rootBox = rootBoxForLine(c);
    if (!rootBox)
        return VisiblePosition();
    
    InlineBox *startBox = rootBox->firstLeafChild();
    if (!startBox)
        return VisiblePosition();

    RenderObject *startRenderer = startBox->object();
    if (!startRenderer)
        return VisiblePosition();

    NodeImpl *startNode = startRenderer->element();
    if (!startNode)
        return VisiblePosition();

    long startOffset = 0;
    if (startBox->isInlineTextBox()) {
        InlineTextBox *startTextBox = static_cast<InlineTextBox *>(startBox);
        startOffset = startTextBox->m_start;
    }
    
    return VisiblePosition(startNode, startOffset, DOWNSTREAM);
}

VisiblePosition endOfLine(const VisiblePosition &c, EIncludeLineBreak includeLineBreak)
{
    // FIXME: Need to implement the "include line break" version.
    assert(includeLineBreak == DoNotIncludeLineBreak);

    RootInlineBox *rootBox = rootBoxForLine(c);
    if (!rootBox)
        return VisiblePosition();
    
    InlineBox *endBox = rootBox->lastLeafChild();
    if (!endBox)
        return VisiblePosition();

    RenderObject *endRenderer = endBox->object();
    if (!endRenderer)
        return VisiblePosition();

    NodeImpl *endNode = endRenderer->element();
    if (!endNode)
        return VisiblePosition();

    long endOffset = 1;
    if (endNode->id() == ID_BR) {
        endOffset = 0;
    } else if (endBox->isInlineTextBox()) {
        InlineTextBox *endTextBox = static_cast<InlineTextBox *>(endBox);
        endOffset = endTextBox->m_start + endTextBox->m_len;
    }

    // generate VisiblePosition with correct affinity
    VisiblePosition result = VisiblePosition(endNode, endOffset, DOWNSTREAM);
    VisiblePosition temp = result;
    temp.setAffinity(UPSTREAM);
    if (visiblePositionsOnDifferentLines(temp, result))
        result.setAffinity(UPSTREAM);
    
    return result;
}

bool inSameLine(const VisiblePosition &a, const VisiblePosition &b)
{
    return a.isNotNull() && startOfLine(a) == startOfLine(b);
}

bool isStartOfLine(const VisiblePosition &p)
{
    return p.isNotNull() && p == startOfLine(p);
}

bool isEndOfLine(const VisiblePosition &p)
{
    return p.isNotNull() && p == endOfLine(p, DoNotIncludeLineBreak);
}

VisiblePosition previousLinePosition(const VisiblePosition &c, int x)
{
    Position p = c.affinity() == UPSTREAM ? c.deepEquivalent() : c.downstreamDeepEquivalent();
    NodeImpl *node = p.node();
    if (!node || !node->getDocument())
        return VisiblePosition();
    
    node->getDocument()->updateLayout();
    
    RenderObject *renderer = node->renderer();
    if (!renderer)
        return VisiblePosition();

    RenderBlock *containingBlock = 0;
    RootInlineBox *root = 0;
    InlineBox *box = renderer->inlineBox(p.offset(), c.affinity());
    if (box) {
        root = box->root()->prevRootBox();
        if (root)
            containingBlock = renderer->containingBlock();
    }

    if (!root) {
        // This containing editable block does not have a previous line.
        // Need to move back to previous containing editable block in this root editable
        // block and find the last root line box in that block.
        NodeImpl *startBlock = node->enclosingBlockFlowElement();
        NodeImpl *n = node->previousEditable();
        while (n && startBlock == n->enclosingBlockFlowElement())
            n = n->previousEditable();
        while (n) {
            if (!n->inSameRootEditableElement(node))
                break;
            Position pos(n, n->caretMinOffset());
            if (pos.inRenderedContent()) {
                assert(n->renderer());
                box = n->renderer()->inlineBox(n->caretMaxOffset());
                if (box) {
                    // previous root line box found
                    root = box->root();
                    containingBlock = n->renderer()->containingBlock();
                    break;
                }

                // Work around <rdar://problem/4040763>.  Need to
                // doublecheck that pos is really on a different line,
                // because it might not be a viable VisiblePosition
                // (whereupon the next VP is returned, which could be
                // back on c's line)
                VisiblePosition c2 = VisiblePosition(pos, DOWNSTREAM);
                if (visiblePositionsOnDifferentLines(c, c2))
                    return c2;
            }
            n = n->previousEditable();
        }
    }
    
    if (root) {
        int absx, absy;
        containingBlock->absolutePosition(absx, absy);
        RenderObject *renderer = root->closestLeafChildForXPos(x, absx)->object();
        return renderer->positionForCoordinates(x, absy + root->topOverflow());
    }
    
    // Could not find a previous line. This means we must already be on the first line.
    // Move to the start of the content in this block, which effectively moves us
    // to the start of the line we're on.
    return VisiblePosition(node->rootEditableElement(), 0, DOWNSTREAM);
}

VisiblePosition nextLinePosition(const VisiblePosition &c, int x)
{
    Position p = c.affinity() == UPSTREAM ? c.deepEquivalent() : c.downstreamDeepEquivalent();
    NodeImpl *node = p.node();
    if (!node || !node->getDocument())
        return VisiblePosition();

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91福利资源站| 成人欧美一区二区三区黑人麻豆| 国产视频一区在线观看| 亚洲六月丁香色婷婷综合久久| 日本美女一区二区三区视频| 国产成人在线视频网站| 777亚洲妇女| 自拍偷在线精品自拍偷无码专区 | 91精品久久久久久久99蜜桃| 国产欧美一区二区精品忘忧草| 亚洲va欧美va国产va天堂影院| 不卡欧美aaaaa| 精品1区2区在线观看| 午夜视黄欧洲亚洲| 91在线视频官网| 国产日韩欧美在线一区| 久久电影国产免费久久电影| 欧美精品99久久久**| 依依成人综合视频| 91在线精品一区二区三区| 久久久www成人免费毛片麻豆 | 成人综合婷婷国产精品久久免费| 欧美一级黄色录像| 亚洲图片欧美综合| 色婷婷狠狠综合| 亚洲人123区| 成人av免费观看| 欧美精彩视频一区二区三区| 美国毛片一区二区三区| 欧美丰满少妇xxxxx高潮对白 | 亚洲美女视频在线观看| 国产成人免费在线观看| 精品久久久影院| 精品一区二区日韩| 日韩欧美一区二区三区在线| 免费在线观看精品| 日韩精品专区在线影院观看| 激情六月婷婷综合| 欧美tickling挠脚心丨vk| 男人的天堂久久精品| 欧美一区二区三区免费| 久久国产乱子精品免费女| 26uuu欧美| 国产电影一区在线| 国产精品久久久久久户外露出 | 国产精品一线二线三线精华| 久久九九久久九九| av一本久道久久综合久久鬼色| 亚洲另类中文字| 欧美电影一区二区| 精品一区二区三区欧美| 久久久久九九视频| 99久久99久久久精品齐齐| 一区二区三区欧美在线观看| 666欧美在线视频| 精品系列免费在线观看| 国产欧美一区二区三区网站| 日本韩国精品在线| 久久国产欧美日韩精品| 国产精品福利一区二区三区| 欧美在线播放高清精品| 蜜桃视频一区二区| 亚洲国产成人私人影院tom| 91久久精品午夜一区二区| 免费人成精品欧美精品 | 成人av午夜影院| 亚洲一区二区精品久久av| 日韩欧美另类在线| 99精品一区二区三区| 日韩中文字幕不卡| 国产精品每日更新| 欧美一区二区播放| www.综合网.com| 久久综合综合久久综合| 亚洲区小说区图片区qvod| 日韩欧美精品三级| 在线中文字幕不卡| 国产米奇在线777精品观看| 亚洲综合男人的天堂| 国产午夜亚洲精品不卡| 欧美精品v日韩精品v韩国精品v| 成人免费毛片嘿嘿连载视频| 免费看欧美美女黄的网站| 亚洲免费观看高清完整版在线观看| 日韩欧美一二三区| 欧美日韩在线精品一区二区三区激情| 国产一区二区在线观看免费| 午夜在线成人av| 亚洲欧美日韩国产另类专区 | 国产色产综合产在线视频| 一本久道久久综合中文字幕| 韩国精品久久久| 日韩成人一区二区三区在线观看| 中文字幕亚洲成人| 久久精品一区蜜桃臀影院| 欧美一区二区三区免费视频| 在线观看国产一区二区| 成人高清视频在线观看| 国产精品亚洲午夜一区二区三区| 亚洲成av人片一区二区三区| 一区二区三区精品| 成人欧美一区二区三区白人| 国产精品天美传媒| 久久久久久麻豆| 久久久久久久久一| 欧美电影免费观看完整版| 欧美精品v日韩精品v韩国精品v| 91免费看视频| eeuss鲁片一区二区三区| 国产综合久久久久久鬼色| 美女在线视频一区| 日韩在线卡一卡二| 亚洲精品国产高清久久伦理二区| 亚洲欧美日韩电影| 亚洲欧美日韩久久| 一区二区三区在线免费观看| 亚洲综合在线视频| 亚洲国产美国国产综合一区二区| 亚洲黄色免费电影| 一区二区三区欧美日韩| 亚洲最大成人综合| 日韩精品91亚洲二区在线观看| 石原莉奈在线亚洲二区| 日韩成人免费电影| 久久精品国产999大香线蕉| 激情综合一区二区三区| 韩国v欧美v亚洲v日本v| 国产乱妇无码大片在线观看| 国产91在线看| 91免费视频大全| 777久久久精品| 欧美变态口味重另类| 国产午夜精品一区二区三区视频| 中文字幕不卡在线播放| 亚洲综合在线免费观看| 日韩av午夜在线观看| 国产精品一卡二卡| 91亚洲精品久久久蜜桃| 51久久夜色精品国产麻豆| 欧美大肚乱孕交hd孕妇| 中文字幕+乱码+中文字幕一区| 国产精品久久久99| 午夜日韩在线电影| 国产精品资源在线| 91亚洲精品久久久蜜桃网站| 91精品国产综合久久久久久久| 精品国产免费人成电影在线观看四季| 久久色中文字幕| 亚洲在线视频网站| 精品在线观看免费| 色综合天天综合| 日韩片之四级片| 国产精品的网站| 亚洲国产精品麻豆| 国产精品2024| 欧美日韩激情一区二区三区| 精品国产1区2区3区| 亚洲欧美一区二区三区国产精品| 久久国产福利国产秒拍| 91成人网在线| 国产欧美一区二区在线| 亚洲成人福利片| 99久久国产综合精品女不卡| 欧美α欧美αv大片| 一区二区三区在线免费视频| 国产一区二区三区不卡在线观看| 91网上在线视频| 久久久久久久免费视频了| 污片在线观看一区二区| 99久久免费精品高清特色大片| 日韩欧美国产一二三区| 亚洲另类春色国产| 欧美日韩在线一区二区| 亚洲欧美在线aaa| 国产麻豆9l精品三级站| 日韩精品一区二区三区四区| 亚洲成人午夜电影| 色视频成人在线观看免| 国产精品久久久久久亚洲伦| 国产一区二区久久| 日韩一级成人av| 午夜欧美电影在线观看| 色猫猫国产区一区二在线视频| 国产日韩精品视频一区| 国产综合成人久久大片91| 日韩欧美在线一区二区三区| 午夜精品一区二区三区电影天堂 | 午夜免费久久看| 色妹子一区二区| 亚洲色图.com| av在线不卡电影| 国产嫩草影院久久久久| 国产福利精品一区| 久久精品水蜜桃av综合天堂| 美女一区二区三区| 91精品国产综合久久香蕉的特点 | 欧美成va人片在线观看| 蜜桃视频一区二区| 日韩欧美一区在线| 精品亚洲aⅴ乱码一区二区三区|