⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 html_formimpl.cpp

📁 将konqueror浏览器移植到ARM9 2410中
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        for (i = 0; i < m_listItems.size(); i++) {            if (m_listItems[i]->id() == ID_OPTION && m_listItems[i] != selectedOption)                static_cast<HTMLOptionElementImpl*>(m_listItems[i])->setSelected(false);        }    }    if (m_render && m_render->layouted())    {        static_cast<RenderSelect*>(m_render)->setSelectionChanged(true);        if(m_render->layouted())            static_cast<RenderSelect*>(m_render)->updateSelection();    }    setChanged(true);}// -------------------------------------------------------------------------HTMLOptGroupElementImpl::HTMLOptGroupElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)    : HTMLGenericFormElementImpl(doc, f){}HTMLOptGroupElementImpl::HTMLOptGroupElementImpl(DocumentPtr *doc)    : HTMLGenericFormElementImpl(doc){}HTMLOptGroupElementImpl::~HTMLOptGroupElementImpl(){}ushort HTMLOptGroupElementImpl::id() const{    return ID_OPTGROUP;}NodeImpl *HTMLOptGroupElementImpl::insertBefore ( NodeImpl *newChild, NodeImpl *refChild, int &exceptioncode ){    NodeImpl *result = HTMLGenericFormElementImpl::insertBefore(newChild,refChild, exceptioncode);    if ( !exceptioncode )        recalcSelectOptions();    return result;}NodeImpl *HTMLOptGroupElementImpl::replaceChild ( NodeImpl *newChild, NodeImpl *oldChild, int &exceptioncode ){    NodeImpl *result = HTMLGenericFormElementImpl::replaceChild(newChild,oldChild, exceptioncode);    if(!exceptioncode)        recalcSelectOptions();    return result;}NodeImpl *HTMLOptGroupElementImpl::removeChild ( NodeImpl *oldChild, int &exceptioncode ){    NodeImpl *result = HTMLGenericFormElementImpl::removeChild(oldChild, exceptioncode);    if( !exceptioncode )        recalcSelectOptions();    return result;}NodeImpl *HTMLOptGroupElementImpl::appendChild ( NodeImpl *newChild, int &exceptioncode ){    NodeImpl *result = HTMLGenericFormElementImpl::appendChild(newChild, exceptioncode);    if( !exceptioncode )        recalcSelectOptions();    return result;}void HTMLOptGroupElementImpl::parseAttribute(AttrImpl *attr){    HTMLGenericFormElementImpl::parseAttribute(attr);    recalcSelectOptions();}void HTMLOptGroupElementImpl::recalcSelectOptions(){    NodeImpl *select = parentNode();    while (select && select->id() != ID_SELECT)        select = select->parentNode();    if (select)        static_cast<HTMLSelectElementImpl*>(select)->recalcListItems();}void HTMLOptGroupElementImpl::setChanged( bool b ){    HTMLGenericFormElementImpl::setChanged( b );    if ( b )        recalcSelectOptions();}// -------------------------------------------------------------------------HTMLOptionElementImpl::HTMLOptionElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)    : HTMLGenericFormElementImpl(doc, f){    m_selected = false;}HTMLOptionElementImpl::HTMLOptionElementImpl(DocumentPtr *doc)    : HTMLGenericFormElementImpl(doc){    m_selected = false;}const DOMString HTMLOptionElementImpl::nodeName() const{    return "OPTION";}ushort HTMLOptionElementImpl::id() const{    return ID_OPTION;}DOMString HTMLOptionElementImpl::text(){    DOMString label = getAttribute(ATTR_LABEL);    if (label.isEmpty() && firstChild() && firstChild()->nodeType() == Node::TEXT_NODE) {	if (firstChild()->nextSibling()) {	    DOMString ret = "";	    NodeImpl *n = firstChild();	    for (; n; n = n->nextSibling()) {		if (n->nodeType() == Node::TEXT_NODE ||		    n->nodeType() == Node::CDATA_SECTION_NODE)		    ret += n->nodeValue();	    }	    return ret;	}	else	    return firstChild()->nodeValue();    }    else        return label;}long HTMLOptionElementImpl::index() const{    // ###    return 0;}void HTMLOptionElementImpl::setIndex( long  ){    // ###}void HTMLOptionElementImpl::parseAttribute(AttrImpl *attr){    switch(attr->attrId)    {    case ATTR_SELECTED:        m_selected = (attr->val() != 0);        break;    case ATTR_VALUE:        m_value = attr->value();        break;    default:        HTMLGenericFormElementImpl::parseAttribute(attr);    }}void HTMLOptionElementImpl::setSelected(bool _selected){    if(m_selected == _selected)        return;    m_selected = _selected;    HTMLSelectElementImpl *select = getSelect();    if (select)        select->notifyOptionSelected(this,_selected);}HTMLSelectElementImpl *HTMLOptionElementImpl::getSelect(){    NodeImpl *select = parentNode();    while (select && select->id() != ID_SELECT)        select = select->parentNode();    return static_cast<HTMLSelectElementImpl*>(select);}void HTMLOptionElementImpl::setChanged( bool b ){    HTMLGenericFormElementImpl::setChanged( b );    HTMLSelectElementImpl* s;    if ( b && ( s = getSelect() ) )        s->recalcListItems();}// -------------------------------------------------------------------------HTMLTextAreaElementImpl::HTMLTextAreaElementImpl(DocumentPtr *doc)    : HTMLGenericFormElementImpl(doc){    // DTD requires rows & cols be specified, but we will provide reasonable defaults    m_rows = 3;    m_cols = 60;    m_wrap = ta_Virtual;    m_dirtyvalue = true;}HTMLTextAreaElementImpl::HTMLTextAreaElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)    : HTMLGenericFormElementImpl(doc, f){    // DTD requires rows & cols be specified, but we will provide reasonable defaults    m_rows = 3;    m_cols = 60;    m_wrap = ta_Virtual;    m_dirtyvalue = true;}ushort HTMLTextAreaElementImpl::id() const{    return ID_TEXTAREA;}DOMString HTMLTextAreaElementImpl::type() const{    return "textarea";}QString HTMLTextAreaElementImpl::state( ){    // Make sure the string is not empty!    return value().string()+'.';}void HTMLTextAreaElementImpl::restoreState(const QString &state){    m_value = state.left(state.length()-1);    setChanged(true);}void HTMLTextAreaElementImpl::select(  ){    if (m_render)        static_cast<RenderTextArea*>(m_render)->select();    onSelect();}void HTMLTextAreaElementImpl::parseAttribute(AttrImpl *attr){    switch(attr->attrId)    {    case ATTR_ROWS:        m_rows = attr->val() ? attr->val()->toInt() : 3;        break;    case ATTR_COLS:        m_cols = attr->val() ? attr->val()->toInt() : 60;        break;    case ATTR_WRAP:        // virtual / physical is Netscape extension of HTML 3.0, now deprecated        // soft/ hard / off is recommendation for HTML 4 extension by IE and NS 4        if ( strcasecmp( attr->value(), "virtual" ) == 0  || strcasecmp( attr->value(), "soft") == 0)            m_wrap = ta_Virtual;        else if ( strcasecmp ( attr->value(), "physical" ) == 0 || strcasecmp( attr->value(), "hard") == 0)            m_wrap = ta_Physical;        else if(strcasecmp( attr->value(), "on" ) == 0)            m_wrap = ta_Physical;        else if(strcasecmp( attr->value(), "off") == 0)            m_wrap = ta_NoWrap;        break;    case ATTR_ACCESSKEY:        // ignore for the moment        break;    case ATTR_ONFOCUS:        setHTMLEventListener(EventImpl::FOCUS_EVENT,	    ownerDocument()->createHTMLEventListener(attr->value().string()));        break;    case ATTR_ONBLUR:        setHTMLEventListener(EventImpl::BLUR_EVENT,	    ownerDocument()->createHTMLEventListener(attr->value().string()));        break;    case ATTR_ONSELECT:        setHTMLEventListener(EventImpl::SELECT_EVENT,	    ownerDocument()->createHTMLEventListener(attr->value().string()));        break;    case ATTR_ONCHANGE:        setHTMLEventListener(EventImpl::CHANGE_EVENT,	    ownerDocument()->createHTMLEventListener(attr->value().string()));        break;    default:        HTMLGenericFormElementImpl::parseAttribute(attr);    }}void HTMLTextAreaElementImpl::attach(){    addCSSProperty(CSS_PROP_COLOR, "text");    setStyle(ownerDocument()->styleSelector()->styleForElement(this));    view = ownerDocument()->view();    khtml::RenderObject *r = _parent->renderer();    if(r && m_style->display() != NONE)    {        RenderTextArea *f = new RenderTextArea(view, this);        if (f)        {            m_render = f;            m_render->setStyle(m_style);            r->addChild(m_render, nextRenderer());            // registerElement and restoreState calls are in RenderTextArea::close        }    }    HTMLElementImpl::attach();}bool HTMLTextAreaElementImpl::encoding(const QTextCodec* codec, encodingList& encoding, bool){    if (_name.isEmpty() || !m_render) return false;    encoding += fixUpfromUnicode(codec, _name.string().stripWhiteSpace());    encoding += fixUpfromUnicode(codec, value().string());    return true;}void HTMLTextAreaElementImpl::reset(){    setValue(defaultValue());}DOMString HTMLTextAreaElementImpl::value(){    if ( m_dirtyvalue) {        if ( m_render )  m_value = static_cast<RenderTextArea*>( m_render )->text();        m_dirtyvalue = false;    }    if ( m_value.isNull() ) return "";    return m_value;}void HTMLTextAreaElementImpl::setValue(DOMString _value){    m_value = _value.string();    m_dirtyvalue = false;    setChanged(true);}DOMString HTMLTextAreaElementImpl::defaultValue(){    DOMString val = "";    // there may be comments - just grab the text nodes    NodeImpl *n;    for (n = firstChild(); n; n = n->nextSibling())        if (n->isTextNode())            val += static_cast<TextImpl*>(n)->data();    if (val[0] == '\r' && val[1] == '\n') {	val = val.copy();	val.remove(0,2);    }    else if (val[0] == '\r' || val[0] == '\n') {	val = val.copy();	val.remove(0,1);    }    return val;}void HTMLTextAreaElementImpl::setDefaultValue(DOMString _defaultValue){    // there may be comments - remove all the text nodes and replace them with one    QList<NodeImpl> toRemove;    NodeImpl *n;    for (n = firstChild(); n; n = n->nextSibling())        if (n->isTextNode())            toRemove.append(n);    QListIterator<NodeImpl> it(toRemove);    int exceptioncode;    for (; it.current(); ++it) {        removeChild(it.current(), exceptioncode);    }    insertBefore(ownerDocument()->createTextNode(_defaultValue),firstChild(), exceptioncode);    setValue(_defaultValue);}// -------------------------------------------------------------------------HTMLIsIndexElementImpl::HTMLIsIndexElementImpl(DocumentPtr *doc)    : HTMLInputElementImpl(doc){    m_type = TEXT;}HTMLIsIndexElementImpl::HTMLIsIndexElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)    : HTMLInputElementImpl(doc, f){    m_type = TEXT;}HTMLIsIndexElementImpl::~HTMLIsIndexElementImpl(){}const DOMString HTMLIsIndexElementImpl::nodeName() const{    return "ISINDEX";}ushort HTMLIsIndexElementImpl::id() const{    return ID_ISINDEX;}void HTMLIsIndexElementImpl::parseAttribute(AttrImpl* attr){    switch(attr->attrId)    {    case ATTR_PROMPT:        m_prompt = attr->value();    default:        // don't call HTMLInputElement::parseAttribute here, as it would        // accept attributes this element does not support        HTMLGenericFormElementImpl::parseAttribute(attr);    }}void HTMLIsIndexElementImpl::attach(){    HTMLInputElementImpl::attach();    _name = "isindex";    // ### fix this, this is just a crude hack    setValue(m_prompt);}// -------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -