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

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

?? dom_stringimpl.cpp

?? It is WEB browser core module with source code. Very good!
?? CPP
字號:
/**
 * This file is part of the DOM implementation for KDE.
 *
 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
 *           (C) 2001 Dirk Mueller ( mueller@kde.org )
 * Copyright (C) 2003 Apple Computer, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 */

#include "dom_stringimpl.h"

#include <kdebug.h>

#include <string.h>
#include "dom_atomicstring.h"

using namespace khtml;

namespace DOM {

using khtml::Fixed;

DOMStringImpl* DOMStringImpl::empty()
{
    static WithOneRef w;
    static DOMStringImpl e(w);
    return &e;
}

DOMStringImpl::DOMStringImpl(const QChar *str, unsigned int len) {
    _hash = 0;
    _inTable = false;
    bool havestr = str && len;
    s = QT_ALLOC_QCHAR_VEC( havestr ? len : 1 );
    if(str && len) {
        memcpy( s, str, len * sizeof(QChar) );
        l = len;
    } else {
        // crash protection
        s[0] = 0x0;
        l = 0;
    }
}

DOMStringImpl::DOMStringImpl(const char *str)
{
    _hash = 0;
    _inTable = false;
    if(str && *str)
    {
        l = strlen(str);
        s = QT_ALLOC_QCHAR_VEC( l );
        int i = l;
        QChar* ptr = s;
        while( i-- )
            *ptr++ = *str++;
    }
    else
    {
        s = QT_ALLOC_QCHAR_VEC( 1 );  // crash protection
        s[0] = 0x0; // == QChar::null;
        l = 0;
    }
}

DOMStringImpl::DOMStringImpl(const char *str, unsigned int len)
{
    _hash = 0;
    _inTable = false;
    l = len;
    if (!l || !str)
        return;
    
    s = QT_ALLOC_QCHAR_VEC(l);
    int i = l;
    QChar* ptr = s;
    while( i-- )
        *ptr++ = *str++;
}

DOMStringImpl::DOMStringImpl(const QChar &ch) {
    _hash = 0;
    _inTable = false;
    s = QT_ALLOC_QCHAR_VEC( 1 );
    s[0] = ch;
    l = 1;
}

DOMStringImpl::~DOMStringImpl()
{
    if (_inTable)
        AtomicString::remove(this);
    if (s)
        QT_DELETE_QCHAR_VEC(s);
}

void DOMStringImpl::append(DOMStringImpl *str)
{
    assert(!_inTable);
    if(str && str->l != 0)
    {
        int newlen = l+str->l;
        QChar *c = QT_ALLOC_QCHAR_VEC(newlen);
        memcpy(c, s, l*sizeof(QChar));
        memcpy(c+l, str->s, str->l*sizeof(QChar));
        if(s) QT_DELETE_QCHAR_VEC(s);
        s = c;
        l = newlen;
    }
}

void DOMStringImpl::insert(DOMStringImpl *str, uint pos)
{
    assert(!_inTable);
    if(pos > l)
    {
        append(str);
        return;
    }
    if(str && str->l != 0)
    {
        int newlen = l+str->l;
        QChar *c = QT_ALLOC_QCHAR_VEC(newlen);
        memcpy(c, s, pos*sizeof(QChar));
        memcpy(c+pos, str->s, str->l*sizeof(QChar));
        memcpy(c+pos+str->l, s+pos, (l-pos)*sizeof(QChar));
        if(s) QT_DELETE_QCHAR_VEC(s);
        s = c;
        l = newlen;
    }
}

void DOMStringImpl::truncate(int len)
{
    assert(!_inTable);
    if(len > (int)l) return;

    int nl = len < 1 ? 1 : len;
    QChar *c = QT_ALLOC_QCHAR_VEC(nl);
    memcpy(c, s, nl*sizeof(QChar));
    if(s) QT_DELETE_QCHAR_VEC(s);
    s = c;
    l = len;
}

void DOMStringImpl::remove(uint pos, int len)
{
    assert(!_inTable);
    if(len <= 0) return;
    if(pos >= l ) return;
    if((unsigned)len > l - pos)
    len = l - pos;

    uint newLen = l-len;
    QChar *c = QT_ALLOC_QCHAR_VEC(newLen);
    memcpy(c, s, pos*sizeof(QChar));
    memcpy(c+pos, s+pos+len, (l-len-pos)*sizeof(QChar));
    if(s) QT_DELETE_QCHAR_VEC(s);
    s = c;
    l = newLen;
}

DOMStringImpl *DOMStringImpl::split(uint pos)
{
    assert(!_inTable);
    if( pos >=l ) return new DOMStringImpl();

    uint newLen = l-pos;

    DOMStringImpl *str = new DOMStringImpl(s + pos, newLen);
    truncate(pos);
    return str;
}

bool DOMStringImpl::containsOnlyWhitespace() const
{
    return containsOnlyWhitespace(0, l);
}

bool DOMStringImpl::containsOnlyWhitespace(unsigned int from, unsigned int len) const
{
    if (!s)
        return true;
    
    for (uint i = from; i < len; i++) {
        QChar c = s[i];
        if (c.unicode() <= 0x7F) {
            if (!isspace(c.unicode()))
                return false;
        } 
        else
            return false;
    }
    return true;
}
    
DOMStringImpl *DOMStringImpl::substring(uint pos, uint len)
{
    if (pos >=l) return new DOMStringImpl();
    if (len > l - pos)
    len = l - pos;
    return new DOMStringImpl(s + pos, len);
}

static Length parseLength(QChar *s, unsigned int l) {
    const QChar* last = s+l-1;
    
    if ( *last == QChar('%')) {
        // CSS allows one decimal after the point, like
        //  42.2%, but not 42.22%
        // we ignore the non-integer part for speed/space reasons
        int i = QConstString(s, l).string().findRev('.');
        if ( i >= 0 && i < (int)l-1 )
            l = i + 1;

        return Length(QConstString(s, l-1).string().toInt(), Percent);
    }

    if ( *last == QChar('*'))
    {
        if(l == 1)
            return Length(1, Relative);
        else
            return Length(QConstString(s, l-1).string().toInt(), Relative);
    }

    // should we strip of the non-integer part here also?
    // CSS says no, all important browsers do so, including Mozilla. sigh.
    bool ok;
    // this ugly construct helps in case someone specifies a length as "100."
    int v = (int) QConstString(s, l).string().toFloat(&ok);
    if(ok) {
        return Length(v, Fixed);
    }
    return Length(0, Variable);
}

Length DOMStringImpl::toLength() const
{
    return parseLength(s,l);
}

khtml::Length* DOMStringImpl::toLengthArray(int& len) const
{
#if !APPLE_CHANGES
    QString str(s, l);
#endif /* APPLE_CHANGES not defined */
    int pos = 0;
    int pos2;

    // web authors are so stupid. This is a workaround
    // to fix lists like "1,2px 3 ,4"
    // make sure not to break percentage or relative widths
    // ### what about "auto" ?
#if APPLE_CHANGES
    // This alternate version works around a limitation in our QString implementation.
    QChar* spacified = new QChar[l];
    QChar space(' ');
    for(unsigned int i=0; i < l; i++) {
        QChar cc = s[i];
        if ( cc > '9' || ( cc < '0' && cc != '-' && cc != '*' && cc != '%' && cc != '.') ){
            spacified[i] = space;
        }
        else {
            spacified[i] = cc;
        }
    }
    QString str(spacified, l);    
    delete [] spacified;
#else /* APPLE_CHANGES not defined */
    QChar space(' ');
    for(unsigned int i=0; i < l; i++) {
        char cc = str[i].latin1();
        if ( cc > '9' || ( cc < '0' && cc != '-' && cc != '*' && cc != '%' && cc != '.') )
            str[i] = space;
    }
#endif /* APPLE_CHANGES not defined */
    str = str.simplifyWhiteSpace();

    len = str.contains(' ') + 1;
    khtml::Length* r = new khtml::Length[len];
    int i = 0;
    while((pos2 = str.find(' ', pos)) != -1)
    {
        r[i++] = parseLength((QChar *) str.unicode()+pos, pos2-pos);
        pos = pos2+1;
    }
    r[i] = parseLength((QChar *) str.unicode()+pos, str.length()-pos);

    return r;
}

bool DOMStringImpl::isLower() const
{
    unsigned int i;
    for (i = 0; i < l; i++)
	if (s[i].lower() != s[i])
	    return false;
    return true;
}

DOMStringImpl *DOMStringImpl::lower() const
{
    DOMStringImpl *c = new DOMStringImpl;
    if(!l) return c;

    c->s = QT_ALLOC_QCHAR_VEC(l);
    c->l = l;

    for (unsigned int i = 0; i < l; i++)
	c->s[i] = s[i].lower();

    return c;
}

DOMStringImpl *DOMStringImpl::upper() const
{
    DOMStringImpl *c = new DOMStringImpl;
    if(!l) return c;

    c->s = QT_ALLOC_QCHAR_VEC(l);
    c->l = l;

    for (unsigned int i = 0; i < l; i++)
	c->s[i] = s[i].upper();

    return c;
}

DOMStringImpl *DOMStringImpl::capitalize() const
{
    DOMStringImpl *c = new DOMStringImpl;
    if(!l) return c;

    c->s = QT_ALLOC_QCHAR_VEC(l);
    c->l = l;

    if ( l ) c->s[0] = s[0].upper();
    for (unsigned int i = 1; i < l; i++)
	c->s[i] = s[i-1].isLetterOrNumber() ? s[i] : s[i].upper();

    return c;
}

int DOMStringImpl::toInt(bool *ok) const
{
    unsigned i = 0;

    // Allow leading spaces.
    for (; i != l; ++i) {
        if (!s[i].isSpace()) {
            break;
        }
    }
    
    // Allow sign.
    if (i != l) {
        if (s[i] == '+' || s[i] == '-') {
            ++i;
        }
    }
    
    // Allow digits.
    for (; i != l; ++i) {
        if (!s[i].isDigit()) {
            break;
        }
    }
    
    return QConstString(s, i).string().toInt(ok);
}

DOMStringImpl *DOMStringImpl::replace(QChar oldC, QChar newC)
{
    if (oldC == newC)
        return this;
    unsigned i;
    for (i = 0; i != l; ++i)
	if (s[i] == oldC)
            break;
    if (i == l)
        return this;

    DOMStringImpl *c = new DOMStringImpl;

    c->s = QT_ALLOC_QCHAR_VEC(l);
    c->l = l;

    for (i = 0; i != l; ++i) {
        QChar ch = s[i];
	if (ch == oldC)
            ch = newC;
        c->s[i] = ch;
    }

    return c;
}

// Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's
// or anything like that.
const unsigned PHI = 0x9e3779b9U;

// This hash algorithm comes from:
// http://burtleburtle.net/bob/hash/hashfaq.html
// http://burtleburtle.net/bob/hash/doobs.html
unsigned DOMStringImpl::computeHash(const QChar *s, int length)
{
    int prefixLength = length < 8 ? length : 8;
    int suffixPosition = length < 16 ? 8 : length - 8;
    
    unsigned h = PHI;
    h += length;
    h += (h << 10); 
    h ^= (h << 6); 
    
    for (int i = 0; i < prefixLength; i++) {
        h += s[i].unicode(); 
	h += (h << 10); 
	h ^= (h << 6); 
    }
    for (int i = suffixPosition; i < length; i++){
        h += s[i].unicode(); 
	h += (h << 10); 
	h ^= (h << 6); 
    }
    
    h += (h << 3);
    h ^= (h >> 11);
    h += (h << 15);
    
    if (h == 0)
        h = 0x80000000;
    
    return h;
}

// This hash algorithm comes from:
// http://burtleburtle.net/bob/hash/hashfaq.html
// http://burtleburtle.net/bob/hash/doobs.html
unsigned DOMStringImpl::computeHash(const char *s)
{
    int length = strlen(s);
    int prefixLength = length < 8 ? length : 8;
    int suffixPosition = length < 16 ? 8 : length - 8;
    
    unsigned h = PHI;
    h += length;
    h += (h << 10); 
    h ^= (h << 6); 
    
    for (int i = 0; i < prefixLength; i++) {
        h += (unsigned char)s[i];
	h += (h << 10); 
	h ^= (h << 6); 
    }
    for (int i = suffixPosition; i < length; i++) {
        h += (unsigned char)s[i];
	h += (h << 10); 
	h ^= (h << 6); 
    }
    
    h += (h << 3);
    h ^= (h >> 11);
    h += (h << 15);
    
    if (h == 0)
        h = 0x80000000;
    
    return h;
}

const char *DOMStringImpl::ascii() const
{
    char *buffer = new char[l + 1];
    char *p = buffer;
    for (unsigned i = 0; i != l; ++i) {
        unsigned short c = s[i].unicode();
        if (c >= 0x20 && c < 0x7F)
            *p++ = c;
        else
            *p++ = '?';
    }
    *p++ = '\0';
    return buffer;
}

} // namespace DOM

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
av电影天堂一区二区在线观看| 欧美tk—视频vk| 欧美一二三在线| 国产精品短视频| 免费成人在线网站| 在线亚洲高清视频| 国产精品剧情在线亚洲| 蜜臀av一区二区三区| 在线免费观看日韩欧美| 国产精品久久久久永久免费观看| 日韩精品乱码免费| 色综合天天综合在线视频| 26uuu欧美| 日本中文字幕一区二区有限公司| 色综合久久精品| 国产精品网站在线播放| 国内外精品视频| 日韩一区二区免费电影| 午夜不卡av免费| 色偷偷久久人人79超碰人人澡| 久久先锋资源网| 精品在线视频一区| 91精品国产91久久综合桃花| 亚洲不卡av一区二区三区| 色呦呦日韩精品| 悠悠色在线精品| 色综合激情久久| 一区二区三区蜜桃网| 91理论电影在线观看| 综合电影一区二区三区| 99久久精品国产麻豆演员表| 国产精品短视频| 91视频你懂的| 亚洲国产婷婷综合在线精品| 欧美优质美女网站| 亚洲第四色夜色| 欧美电影在线免费观看| 免费人成精品欧美精品| 欧美成人精品3d动漫h| 精品综合久久久久久8888| 久久久精品人体av艺术| 国产a久久麻豆| |精品福利一区二区三区| 91在线视频观看| 亚洲国产精品久久久久婷婷884| 欧美影院一区二区| 美女www一区二区| 欧美经典三级视频一区二区三区| 成人夜色视频网站在线观看| 亚洲女人****多毛耸耸8| 欧美亚洲国产一卡| 免费看日韩精品| 亚洲国产高清在线| 欧美在线小视频| 精品一区二区影视| 国产精品久久久久天堂| 欧美性生交片4| 国产一区亚洲一区| 亚洲综合色自拍一区| 91精品国产欧美一区二区成人 | www.欧美.com| 一区二区三区欧美在线观看| 日韩视频在线一区二区| 福利一区二区在线观看| 亚洲国产va精品久久久不卡综合| 日韩视频一区在线观看| 色综合网色综合| 韩国中文字幕2020精品| 亚洲精品视频在线| 欧美v亚洲v综合ⅴ国产v| 成熟亚洲日本毛茸茸凸凹| 丝袜亚洲另类丝袜在线| 中文字幕不卡在线| 欧美一区二区在线视频| 成人av午夜影院| 久久99国产精品久久99| 一区二区三区日韩欧美精品| 国产清纯白嫩初高生在线观看91| 欧亚一区二区三区| 成人激情午夜影院| 激情综合五月婷婷| 午夜精品久久一牛影视| 中文字幕在线一区免费| 精品国产91九色蝌蚪| 91电影在线观看| a级精品国产片在线观看| 激情欧美日韩一区二区| 亚洲高清视频在线| 亚洲欧洲无码一区二区三区| 久久综合狠狠综合久久激情| 欧美日韩一级黄| 99久久国产综合色|国产精品| 精品一区二区三区在线播放视频| 婷婷综合五月天| 亚洲一区二区中文在线| 日韩美女久久久| 国产精品免费视频观看| 中国色在线观看另类| 久久综合九色综合97婷婷女人 | 国产成人免费视频| 美国十次综合导航| 亚洲欧美日韩电影| 亚洲欧洲av一区二区三区久久| 国产欧美一区二区精品秋霞影院 | 欧美专区亚洲专区| 91免费观看视频| 从欧美一区二区三区| 国产夫妻精品视频| 国产主播一区二区| 国产在线一区观看| 国内精品自线一区二区三区视频| 日韩黄色免费电影| 视频一区免费在线观看| 日日摸夜夜添夜夜添精品视频 | 制服丝袜亚洲精品中文字幕| 欧美性生活久久| 欧美久久久久久久久中文字幕| 色婷婷精品久久二区二区蜜臀av | 成人国产精品免费观看动漫| 国产精品91xxx| 国产a视频精品免费观看| 成人免费三级在线| 97久久精品人人做人人爽| 91亚洲精品乱码久久久久久蜜桃 | 亚洲精选视频在线| 亚洲精品免费播放| 亚洲午夜激情av| 偷拍一区二区三区| 国内成人精品2018免费看| 国产精品123区| 99视频在线观看一区三区| 91麻豆国产福利精品| 欧美日韩二区三区| 日韩欧美国产一区二区在线播放 | 精品久久一区二区| 国产三级欧美三级日产三级99| 国产欧美一区二区三区沐欲| 一区二区三区影院| 日韩主播视频在线| 国产盗摄女厕一区二区三区| 97久久精品人人澡人人爽| 欧美日韩一区二区三区在线看| 欧美一区二区三区婷婷月色| 久久精品一二三| 一级精品视频在线观看宜春院 | 日韩精品国产欧美| 国产一区二区h| 色成年激情久久综合| 欧美成人vr18sexvr| 中文字幕在线不卡| 久久精品国产一区二区三| 99久久精品免费看| 日韩免费视频一区| 亚洲免费观看在线视频| 免费观看一级欧美片| 色综合中文字幕| 久久色在线视频| 亚洲www啪成人一区二区麻豆| 国产激情视频一区二区在线观看| 在线精品观看国产| 亚洲国产成人午夜在线一区| 日本人妖一区二区| 色中色一区二区| 中文字幕+乱码+中文字幕一区| 午夜激情一区二区三区| 99国产精品久久久久久久久久| 精品久久久影院| 视频一区在线播放| 91麻豆成人久久精品二区三区| 久久久蜜桃精品| 天堂蜜桃一区二区三区| 一本大道综合伊人精品热热| 久久久电影一区二区三区| 午夜久久电影网| av电影天堂一区二区在线观看| 久久你懂得1024| 免费看欧美女人艹b| 欧美日本视频在线| 一区二区三区在线视频观看| 不卡一区二区中文字幕| 国产午夜亚洲精品午夜鲁丝片| 蜜臀av一级做a爰片久久| 欧美色综合天天久久综合精品| 亚洲天堂久久久久久久| 丁香亚洲综合激情啪啪综合| 2023国产精华国产精品| 美女视频黄频大全不卡视频在线播放| 欧美日韩1234| 午夜精品久久久久久久久久 | 91蜜桃视频在线| 国产色综合一区| 豆国产96在线|亚洲| 久久久99精品免费观看不卡| 麻豆专区一区二区三区四区五区| 在线综合亚洲欧美在线视频| 日韩精品1区2区3区| 欧美一区二区视频在线观看2022| 午夜激情久久久| 日韩欧美一区二区视频| 久久成人av少妇免费|