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

📄 html_imageimpl.cpp

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        else if (m_image && m_image->pixmap_size().isValid())            return m_image->pixmap_size().width();        else            return 0;    }    // ### make a unified call for this    if (changed()) {        getDocument()->updateRendering();        if (getDocument()->view())            getDocument()->view()->layout();    }    return m_render ? m_render->contentWidth() :                      getAttribute(ATTR_WIDTH).toInt();}long HTMLImageElementImpl::height() const{    if (!m_render) {        DOMString heightAttr = getAttribute(ATTR_HEIGHT);        if (!heightAttr.isNull())            return heightAttr.toInt();        else if (m_image && m_image->pixmap_size().isValid())            return m_image->pixmap_size().height();        else            return 0;    }    // ### make a unified call for this    if (changed()) {        getDocument()->updateRendering();        if (getDocument()->view())            getDocument()->view()->layout();    }    return m_render ? m_render->contentHeight() :                      getAttribute(ATTR_HEIGHT).toInt();}QImage HTMLImageElementImpl::currentImage() const{    RenderImage *r = static_cast<RenderImage*>(renderer());    if(r)        return r->pixmap().convertToImage();    return QImage();}QPixmap HTMLImageElementImpl::currentPixmap() const{    RenderImage *r = static_cast<RenderImage*>(renderer());    if(r)        return r->pixmap();    return QPixmap();}bool HTMLImageElementImpl::complete() const{    return m_image && m_image->valid_rect().size() == m_image->pixmap_size();}// -------------------------------------------------------------------------HTMLMapElementImpl::HTMLMapElementImpl(DocumentPtr *doc)    : HTMLElementImpl(doc){}HTMLMapElementImpl::~HTMLMapElementImpl(){    if(getDocument() && getDocument()->isHTMLDocument())        static_cast<HTMLDocumentImpl*>(getDocument())->mapMap.remove(name);}NodeImpl::Id HTMLMapElementImpl::id() const{    return ID_MAP;}boolHTMLMapElementImpl::mapMouseEvent(int x_, int y_, int width_, int height_,                                  RenderObject::NodeInfo& info){    //cout << "map:mapMouseEvent " << endl;    //cout << x_ << " " << y_ <<" "<< width_ <<" "<< height_ << endl;    QPtrStack<NodeImpl> nodeStack;    NodeImpl *current = firstChild();    while(1)    {        if(!current)        {            if(nodeStack.isEmpty()) break;            current = nodeStack.pop();            current = current->nextSibling();            continue;        }        if(current->id()==ID_AREA)        {            //cout << "area found " << endl;            HTMLAreaElementImpl* area=static_cast<HTMLAreaElementImpl*>(current);            if (area->mapMouseEvent(x_,y_,width_,height_, info))                return true;        }        NodeImpl *child = current->firstChild();        if(child)        {            nodeStack.push(current);            current = child;        }        else        {            current = current->nextSibling();        }    }    return false;}void HTMLMapElementImpl::parseAttribute(AttributeImpl *attr){    switch (attr->id())    {    case ATTR_ID:        if (getDocument()->htmlMode() != DocumentImpl::XHtml) {            HTMLElementImpl::parseAttribute(attr);            break;        }        // fall through    case ATTR_NAME:    {        DOMString s = attr->value();        if(*s.unicode() == '#')            name = QString(s.unicode()+1, s.length()-1);        else            name = s.string();	// ### make this work for XML documents, e.g. in case of <html:map...>        if(getDocument()->isHTMLDocument())            static_cast<HTMLDocumentImpl*>(getDocument())->mapMap[name] = this;        //fallthrough    }    default:        HTMLElementImpl::parseAttribute(attr);    }}// -------------------------------------------------------------------------HTMLAreaElementImpl::HTMLAreaElementImpl(DocumentPtr *doc)    : HTMLAnchorElementImpl(doc){    m_coords=0;    m_coordsLen = 0;    nohref = false;    shape = Unknown;    lasth = lastw = -1;}HTMLAreaElementImpl::~HTMLAreaElementImpl(){    delete [] m_coords;}NodeImpl::Id HTMLAreaElementImpl::id() const{    return ID_AREA;}void HTMLAreaElementImpl::parseAttribute(AttributeImpl *attr){    switch (attr->id())    {    case ATTR_SHAPE:        if ( strcasecmp( attr->value(), "default" ) == 0 )            shape = Default;        else if ( strcasecmp( attr->value(), "circle" ) == 0 )            shape = Circle;        else if ( strcasecmp( attr->value(), "poly" ) == 0 || strcasecmp( attr->value(),  "polygon" ) == 0 )            shape = Poly;        else if ( strcasecmp( attr->value(), "rect" ) == 0 )            shape = Rect;        break;    case ATTR_COORDS:        delete [] m_coords;        m_coords = attr->val()->toCoordsArray(m_coordsLen);        break;    case ATTR_NOHREF:        nohref = attr->val() != 0;        break;    case ATTR_TARGET:        m_hasTarget = attr->val() != 0;        break;    case ATTR_ALT:        break;    case ATTR_ACCESSKEY:        break;    default:        HTMLAnchorElementImpl::parseAttribute(attr);    }}bool HTMLAreaElementImpl::mapMouseEvent(int x_, int y_, int width_, int height_,                                   RenderObject::NodeInfo& info){    bool inside = false;    if (width_ != lastw || height_ != lasth)    {        region=getRegion(width_, height_);        lastw=width_; lasth=height_;    }    if (region.contains(QPoint(x_,y_)))    {        inside = true;        info.setInnerNode(this);        info.setURLElement(this);    }    return inside;}QRect HTMLAreaElementImpl::getRect() const{    if (parentNode()->renderer()==0)        return QRect();    int dx, dy;    if (!parentNode()->renderer()->absolutePosition(dx, dy))        return QRect();    QRegion region = getRegion(lastw,lasth);    region.translate(dx, dy);    return region.boundingRect();}QRegion HTMLAreaElementImpl::getRegion(int width_, int height_) const{    QRegion region;    if (!m_coords)        return region;    // added broken HTML support (Dirk): some pages omit the SHAPE    // attribute, so we try to guess by looking at the coords count    // what the HTML author tried to tell us.    // a Poly needs at least 3 points (6 coords), so this is correct    if ((shape==Poly || shape==Unknown) && m_coordsLen > 5) {        // make sure its even        int len = m_coordsLen >> 1;        QPointArray points(len);        for (int i = 0; i < len; ++i)            points.setPoint(i, m_coords[(i<<1)].minWidth(width_),                            m_coords[(i<<1)+1].minWidth(height_));        region = QRegion(points);    }    else if (shape==Circle && m_coordsLen>=3 || shape==Unknown && m_coordsLen == 3) {        int r = kMin(m_coords[2].minWidth(width_), m_coords[2].minWidth(height_));        region = QRegion(m_coords[0].minWidth(width_)-r,                         m_coords[1].minWidth(height_)-r, 2*r, 2*r,QRegion::Ellipse);    }    else if (shape==Rect && m_coordsLen>=4 || shape==Unknown && m_coordsLen == 4) {        int x0 = m_coords[0].minWidth(width_);        int y0 = m_coords[1].minWidth(height_);        int x1 = m_coords[2].minWidth(width_);        int y1 = m_coords[3].minWidth(height_);        region = QRegion(x0,y0,x1-x0,y1-y0);    }    else if (shape==Default)        region = QRegion(0,0,width_,height_);    // else       // return null region    return region;}

⌨️ 快捷键说明

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