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

📄 html_baseimpl.cpp

📁 将konqueror浏览器移植到ARM9 2410中
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/** * 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) 2000 Simon Hausmann <hausmann@kde.org> * * 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. * * $Id: html_baseimpl.cpp,v 1.125.2.3 2001/11/30 06:24:07 mueller Exp $ */// -------------------------------------------------------------------------#include "html_baseimpl.h"#include "html_documentimpl.h"#include "khtmlview.h"#include "khtml_part.h"#include "rendering/render_frames.h"#include "rendering/render_html.h"#include "rendering/render_body.h"#include "css/cssstyleselector.h"#include "css/css_stylesheetimpl.h"#include "css/cssproperties.h"#include "css/cssvalues.h"#include "css/csshelper.h"#include "misc/loader.h"#include "misc/htmlhashes.h"#include "dom/dom_string.h"#include "xml/dom2_eventsimpl.h"#include <kurl.h>#include <kdebug.h>using namespace DOM;using namespace khtml;HTMLBodyElementImpl::HTMLBodyElementImpl(DocumentPtr *doc)    : HTMLElementImpl(doc){    m_styleSheet = 0;}HTMLBodyElementImpl::~HTMLBodyElementImpl(){    if(m_styleSheet) m_styleSheet->deref();}const DOMString HTMLBodyElementImpl::nodeName() const{    return "BODY";}ushort HTMLBodyElementImpl::id() const{    return ID_BODY;}void HTMLBodyElementImpl::parseAttribute(AttrImpl *attr){    switch(attr->attrId)    {    case ATTR_BACKGROUND:    {        KURL u = khtml::Cache::completeURL(attr->value(), static_cast<HTMLDocumentImpl *>(ownerDocument())->baseURL());        bgImage = u.url();        addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, "url('"+u.url()+"')" );        break;    }    case ATTR_MARGINWIDTH:        addCSSLength(CSS_PROP_MARGIN_RIGHT, attr->value() );        /* nobreak; */    case ATTR_LEFTMARGIN:        addCSSLength(CSS_PROP_MARGIN_LEFT, attr->value() );        break;    case ATTR_MARGINHEIGHT:        addCSSLength(CSS_PROP_MARGIN_BOTTOM, attr->value());        /* nobreak */    case ATTR_TOPMARGIN:        addCSSLength(CSS_PROP_MARGIN_TOP, attr->value());        break;    case ATTR_BGCOLOR:        bgColor = attr->value();        addCSSProperty(CSS_PROP_BACKGROUND_COLOR, attr->value());        break;    case ATTR_TEXT:        addCSSProperty(CSS_PROP_COLOR, attr->value());        break;    case ATTR_BGPROPERTIES:        if ( strcasecmp( attr->value(), "fixed" ) == 0)            addCSSProperty(CSS_PROP_BACKGROUND_ATTACHMENT, CSS_VAL_FIXED);        break;    case ATTR_VLINK:    case ATTR_ALINK:    case ATTR_LINK:    {        if(!m_styleSheet) {            m_styleSheet = new CSSStyleSheetImpl(this,0,true);            m_styleSheet->ref();        }        QString aStr;	if ( attr->attrId == ATTR_LINK )	    aStr = "a:link";	else if ( attr->attrId == ATTR_VLINK )	    aStr = "a:visited";	else if ( attr->attrId == ATTR_ALINK )	    aStr = "a:active";	aStr += " { color: " + attr->value().string() + "; }";        m_styleSheet->parseString(aStr);        m_styleSheet->setNonCSSHints();        if (attached())            getDocument()->createSelector();        break;    }    case ATTR_ONLOAD:        ownerDocument()->setWindowEventListener(EventImpl::LOAD_EVENT,	    ownerDocument()->createHTMLEventListener(attr->value().string()));        break;    case ATTR_ONUNLOAD:        ownerDocument()->setWindowEventListener(EventImpl::UNLOAD_EVENT,	    ownerDocument()->createHTMLEventListener(attr->value().string()));        break;    case ATTR_ONBLUR:        ownerDocument()->setWindowEventListener(EventImpl::BLUR_EVENT,	    ownerDocument()->createHTMLEventListener(attr->value().string()));        break;    case ATTR_ONFOCUS:        ownerDocument()->setWindowEventListener(EventImpl::FOCUS_EVENT,	    ownerDocument()->createHTMLEventListener(attr->value().string()));        break;    case ATTR_NOSAVE:	break;    default:        HTMLElementImpl::parseAttribute(attr);    }}void HTMLBodyElementImpl::attach(){    KHTMLView* w = ownerDocument()->view();    if(w->marginWidth() != -1) {        QString s;        s.sprintf( "%d", w->marginWidth() );        addCSSLength(CSS_PROP_MARGIN_LEFT, s);        addCSSLength(CSS_PROP_MARGIN_RIGHT, s);    }    if(w->marginHeight() != -1) {        QString s;        s.sprintf( "%d", w->marginHeight() );        addCSSLength(CSS_PROP_MARGIN_TOP, s);        addCSSLength(CSS_PROP_MARGIN_BOTTOM, s);    }    ownerDocument()->createSelector();    setStyle(ownerDocument()->styleSelector()->styleForElement( this ));    khtml::RenderObject *r = _parent->renderer();    // ignore display: none for this element!    if ( !r )      return;    m_render = new RenderBody(this);    m_render->setStyle(m_style);    r->addChild( m_render, nextRenderer() );    HTMLElementImpl::attach();}bool HTMLBodyElementImpl::prepareMouseEvent(int _x, int _y, int _tx, int _ty, MouseEvent *ev){    bool inside = HTMLElementImpl::prepareMouseEvent(_x, _y, _tx, _ty, ev);    if(!inside)	ev->innerNode = this;    return !inside;}// -------------------------------------------------------------------------HTMLFrameElementImpl::HTMLFrameElementImpl(DocumentPtr *doc)    : HTMLElementImpl(doc){    view = 0;    parentWidget = 0;    frameBorder = true;    frameBorderSet = false;    marginWidth = -1;    marginHeight = -1;    scrolling = QScrollView::Auto;    noresize = false;}HTMLFrameElementImpl::~HTMLFrameElementImpl(){}const DOMString HTMLFrameElementImpl::nodeName() const{    return "FRAME";}ushort HTMLFrameElementImpl::id() const{    return ID_FRAME;}void HTMLFrameElementImpl::parseAttribute(AttrImpl *attr){    switch(attr->attrId)    {    case ATTR_SRC:        url = khtml::parseURL(attr->val());        break;    case ATTR_NAME:        name = attr->value();        break;    case ATTR_FRAMEBORDER:    {        frameBorder = attr->value().toInt();        frameBorderSet = ( attr->val() != 0 );    }    break;    case ATTR_MARGINWIDTH:        marginWidth = attr->val()->toInt();        break;    case ATTR_MARGINHEIGHT:        marginHeight = attr->val()->toInt();        break;    case ATTR_NORESIZE:        noresize = true;        break;    case ATTR_SCROLLING:        kdDebug( 6031 ) << "set scroll mode" << endl;        if( strcasecmp( attr->value(), "auto" ) == 0 )            scrolling = QScrollView::Auto;        else if( strcasecmp( attr->value(), "yes" ) == 0 )            scrolling = QScrollView::AlwaysOn;        else if( strcasecmp( attr->value(), "no" ) == 0 )            scrolling = QScrollView::AlwaysOff;    default:        HTMLElementImpl::parseAttribute(attr);    }}void HTMLFrameElementImpl::attach(){    setStyle(ownerDocument()->styleSelector()->styleForElement( this ));    KHTMLView* w = ownerDocument()->view();    // limit to how deep we can nest frames    KHTMLPart *part = w->part();    int depth = 0;    while ((part = part->parentPart()))        depth++;    if (depth > 6) {        style()->setDisplay( NONE );        return;    }    // inherit default settings from parent frameset    HTMLElementImpl* node = static_cast<HTMLElementImpl*>(parentNode());    while(node)    {        if(node->id() == ID_FRAMESET)        {            HTMLFrameSetElementImpl* frameset = static_cast<HTMLFrameSetElementImpl*>(node);            if(!frameBorderSet)  frameBorder = frameset->frameBorder();            if(!noresize)  noresize = frameset->noResize();            break;        }        node = static_cast<HTMLElementImpl*>(node->parentNode());    }    khtml::RenderObject *r = _parent->renderer();    // ignore display: none for this element!    if ( !r )      return;    khtml::RenderFrame *renderFrame = new khtml::RenderFrame( w, this );    m_render = renderFrame;    m_render->setStyle(m_style);    r->addChild( m_render, nextRenderer() );    // we need a unique name for every frame in the frameset. Hope that's unique enough.    if(name.isEmpty() || w->part()->frameExists( name.string() ) )    {      name = DOMString(w->part()->requestFrameName());      kdDebug( 6030 ) << "creating frame name: " << name.string() << endl;    }    if (!url.isNull())    w->part()->requestFrame( renderFrame, url.string(), name.string() );    HTMLElementImpl::attach();    return;}void HTMLFrameElementImpl::detach(){    HTMLElementImpl::detach();    delete view;    parentWidget = 0;}bool HTMLFrameElementImpl::isSelectable() const{    return m_render!=0;}void HTMLFrameElementImpl::setFocus(bool received){    HTMLElementImpl::setFocus(received);    khtml::RenderFrame *renderFrame = static_cast<khtml::RenderFrame *>(m_render);    if (!renderFrame || !renderFrame->m_widget)        return;    if (received)        renderFrame->m_widget->setFocus();    else        renderFrame->m_widget->clearFocus();}// -------------------------------------------------------------------------HTMLFrameSetElementImpl::HTMLFrameSetElementImpl(DocumentPtr *doc)    : HTMLElementImpl(doc){    // default value for rows and cols...    m_totalRows = 1;    m_totalCols = 1;    m_rows = m_cols = 0;    frameborder = true;    frameBorderSet = false;    m_border = 4;    noresize = false;    m_resizing = false;

⌨️ 快捷键说明

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