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

📄 render_style.cpp

📁 khtml在gtk上的移植版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        case RenderStyle::AFTER:            return AFTER_BIT;        case RenderStyle::FIRST_LINE:            return FIRST_LINE_BIT;        case RenderStyle::FIRST_LETTER:            return FIRST_LETTER_BIT;        case RenderStyle::SELECTION:            return SELECTION_BIT;        case RenderStyle::FIRST_LINE_INHERITED:            return FIRST_LINE_INHERITED_BIT;        default:            return NO_BIT;    }}bool RenderStyle::hasPseudoStyle(PseudoId pseudo) const{    return (pseudoBit(pseudo) & noninherited_flags._pseudoBits) != 0;}void RenderStyle::setHasPseudoStyle(PseudoId pseudo){    noninherited_flags._pseudoBits |= pseudoBit(pseudo);}RenderStyle* RenderStyle::getPseudoStyle(PseudoId pid){    RenderStyle *ps = 0;    if (noninherited_flags._styleType==NOPSEUDO) {	ps = pseudoStyle;        while (ps) {            if (ps->noninherited_flags._styleType==pid)                    break;                ps = ps->pseudoStyle;        }    }    return ps;}void RenderStyle::addPseudoStyle(RenderStyle* pseudo){    if (!pseudo) return;        pseudo->ref();    pseudo->pseudoStyle = pseudoStyle;    pseudoStyle = pseudo;}bool RenderStyle::inheritedNotEqual( RenderStyle *other ) const{    return inherited_flags != other->inherited_flags ||           inherited != other->inherited ||           css3InheritedData != other->css3InheritedData;}/*  compares two styles. The result gives an idea of the action that  needs to be taken when replacing the old style with a new one.  CbLayout: The containing block of the object needs a relayout.  Layout: the RenderObject needs a relayout after the style change  Visible: The change is visible, but no relayout is needed  NonVisible: The object does need neither repaint nor relayout after       the change.  ### TODO:  A lot can be optimised here based on the display type, lots of  optimisations are unimplemented, and currently result in the  worst case result causing a relayout of the containing block.*/RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const{    // we anyway assume they are the same// 	EDisplay _effectiveDisplay : 5;    // NonVisible:// 	ECursor _cursor_style : 4;// ### this needs work to know more exactly if we need a relayout//     or just a repaint// non-inherited attributes//     DataRef<StyleBoxData> box;//     DataRef<StyleVisualData> visual;//     DataRef<StyleSurroundData> surround;// inherited attributes//     DataRef<StyleInheritedData> inherited;    if ( *box.get() != *other->box.get() ||         !(surround->margin == other->surround->margin) ||         !(surround->padding == other->surround->padding) ||         *css3NonInheritedData->flexibleBox.get() != *other->css3NonInheritedData->flexibleBox.get() ||#if APPLE_CHANGES         (css3NonInheritedData->lineClamp != other->css3NonInheritedData->lineClamp) ||         (css3InheritedData->textSizeAdjust != other->css3InheritedData->textSizeAdjust) ||#endif        !(inherited->indent == other->inherited->indent) ||        !(inherited->line_height == other->inherited->line_height) ||        !(inherited->style_image == other->inherited->style_image) ||        !(inherited->cursor_image == other->inherited->cursor_image) ||        !(inherited->font == other->inherited->font) ||        !(inherited->horizontal_border_spacing == other->inherited->horizontal_border_spacing) ||        !(inherited->vertical_border_spacing == other->inherited->vertical_border_spacing) ||        !(inherited_flags._box_direction == other->inherited_flags._box_direction) ||        !(inherited_flags._visuallyOrdered == other->inherited_flags._visuallyOrdered) ||        !(inherited_flags._htmlHacks == other->inherited_flags._htmlHacks) ||        !(noninherited_flags._position == other->noninherited_flags._position) ||        !(noninherited_flags._floating == other->noninherited_flags._floating) ||        !(noninherited_flags._originalDisplay == other->noninherited_flags._originalDisplay) ||         visual->colspan != other->visual->colspan ||         visual->counter_increment != other->visual->counter_increment ||         visual->counter_reset != other->visual->counter_reset ||         css3NonInheritedData->textOverflow != other->css3NonInheritedData->textOverflow)        return CbLayout;       // changes causing Layout changes:// only for tables:// 	_border_collapse// 	EEmptyCell _empty_cells : 2 ;// 	ECaptionSide _caption_side : 2;//     ETableLayout _table_layout : 1;//     EPosition _position : 2;//     EFloat _floating : 2;    if ( ((int)noninherited_flags._effectiveDisplay) >= TABLE ) {	// Stupid gcc gives a compile error on	// a != other->b if a and b are bitflags. Using	// !(a== other->b) instead.	if ( !(inherited_flags._border_collapse == other->inherited_flags._border_collapse) ||	     !(inherited_flags._empty_cells == other->inherited_flags._empty_cells) ||	     !(inherited_flags._caption_side == other->inherited_flags._caption_side) ||	     !(noninherited_flags._table_layout == other->noninherited_flags._table_layout))        return CbLayout;    }// only for lists:// 	EListStyleType _list_style_type : 5 ;// 	EListStylePosition _list_style_position :1;    if (noninherited_flags._effectiveDisplay == LIST_ITEM ) {	if ( !(inherited_flags._list_style_type == other->inherited_flags._list_style_type) ||	     !(inherited_flags._list_style_position == other->inherited_flags._list_style_position) )	    return Layout;    }// ### These could be better optimised// 	ETextAlign _text_align : 3;// 	ETextTransform _text_transform : 4;// 	EDirection _direction : 1;// 	EWhiteSpace _white_space : 2;// 	EFontVariant _font_variant : 1;//     EClear _clear : 2;    if ( !(inherited_flags._text_align == other->inherited_flags._text_align) ||	 !(inherited_flags._text_transform == other->inherited_flags._text_transform) ||	 !(inherited_flags._direction == other->inherited_flags._direction) ||	 !(inherited_flags._white_space == other->inherited_flags._white_space) ||	 !(noninherited_flags._clear == other->noninherited_flags._clear)	)	return Layout;// only for inline://     EVerticalAlign _vertical_align : 4;    if ( !(noninherited_flags._effectiveDisplay == INLINE) &&         !(noninherited_flags._vertical_align == other->noninherited_flags._vertical_align))        return Layout;    // If our border widths change, then we need to layout.  Other changes to borders    // only necessitate a repaint.    if (borderLeftWidth() != other->borderLeftWidth() ||        borderTopWidth() != other->borderTopWidth() ||        borderBottomWidth() != other->borderBottomWidth() ||        borderRightWidth() != other->borderRightWidth())        return Layout;    // Make sure these left/top/right/bottom checks stay below all layout checks and above    // all visible checks.    if (other->position() != STATIC && !(surround->offset == other->surround->offset)) {     // FIXME: would like to do this at some point, but will need a new hint that indicates     // descendants need to be repainted too.     //   if (other->position() == RELATIVE)     //       return Visible;     //   else            return Layout;    }    // Visible:// 	EVisibility _visibility : 2;//     EOverflow _overflow : 4 ;//     EBackgroundRepeat _bg_repeat : 2;//     bool _bg_attachment : 1;// 	int _text_decoration : 4;//     DataRef<StyleBackgroundData> background;    if (inherited->color != other->inherited->color ||        !(inherited_flags._visibility == other->inherited_flags._visibility) ||        !(noninherited_flags._overflow == other->noninherited_flags._overflow) ||        !(noninherited_flags._bg_repeat == other->noninherited_flags._bg_repeat) ||        !(noninherited_flags._bg_attachment == other->noninherited_flags._bg_attachment) ||        !(inherited_flags._text_decorations == other->inherited_flags._text_decorations) ||        !(inherited_flags._should_correct_text_color == other->inherited_flags._should_correct_text_color) ||        !(surround->border == other->surround->border) ||        *background.get() != *other->background.get() ||        !(visual->clip == other->visual->clip) ||        visual->hasClip != other->visual->hasClip ||        visual->textDecoration != other->visual->textDecoration ||        css3NonInheritedData->opacity != other->css3NonInheritedData->opacity ||        !css3InheritedData->shadowDataEquivalent(*other->css3InheritedData.get()) ||        css3InheritedData->userModify != other->css3InheritedData->userModify ||        css3NonInheritedData->userSelect != other->css3NonInheritedData->userSelect ||        css3NonInheritedData->userDrag != other->css3NonInheritedData->userDrag ||        !(visual->palette == other->visual->palette)	)        return Visible;    return Equal;}RenderStyle* RenderStyle::_default = 0;//int RenderStyle::counter = 0;//int SharedData::counter = 0;void RenderStyle::cleanup(){    delete _default;    _default = 0;//    counter = 0;//    SharedData::counter = 0;}void RenderStyle::setPaletteColor(QPalette::ColorGroup g, QColorGroup::ColorRole r, const QColor& c){    visual.access()->palette.setColor(g,r,c);}void RenderStyle::setClip( Length top, Length right, Length bottom, Length left ){    StyleVisualData *data = visual.access();    data->clip.top = top;    data->clip.right = right;    data->clip.bottom = bottom;    data->clip.left = left;}bool RenderStyle::contentDataEquivalent(RenderStyle* otherStyle){    ContentData* c1 = content;    ContentData* c2 = otherStyle->content;    while (c1 && c2) {        if (c1->_contentType != c2->_contentType)            return false;        if (c1->_contentType == CONTENT_TEXT) {            DOMString c1Str(c1->_content.text);            DOMString c2Str(c2->_content.text);            if (c1Str != c2Str)                return false;        }        else if (c1->_contentType == CONTENT_OBJECT) {            if (c1->_content.object != c2->_content.object)                return false;        }        c1 = c1->_nextContent;        c2 = c2->_nextContent;    }    return !c1 && !c2;}void RenderStyle::setContent(CachedObject* o, bool add){    if (!o)        return; // The object is null. Nothing to do. Just bail.    ContentData* lastContent = content;    while (lastContent && lastContent->_nextContent)        lastContent = lastContent->_nextContent;    bool reuseContent = !add;    ContentData* newContentData = 0;    if (reuseContent && content) {        content->clearContent();        newContentData = content;    }    else        newContentData = new ContentData;    if (lastContent && !reuseContent)        lastContent->_nextContent = newContentData;    else        content = newContentData;    //    o->ref();    newContentData->_content.object = o;    newContentData->_contentType = CONTENT_OBJECT;}void RenderStyle::setContent(DOMStringImpl* s, bool add){    if (!s)        return; // The string is null. Nothing to do. Just bail.        ContentData* lastContent = content;    while (lastContent && lastContent->_nextContent)        lastContent = lastContent->_nextContent;    bool reuseContent = !add;    if (add) {        if (!lastContent)            return; // Something's wrong.  We had no previous content, and we should have.        if (lastContent->_contentType == CONTENT_TEXT) {            // We can augment the existing string and share this ContentData node.            DOMStringImpl* oldStr = lastContent->_content.text;            DOMStringImpl* newStr = oldStr->copy();            newStr->ref();            oldStr->deref();            newStr->append(s);            lastContent->_content.text = newStr;            return;        }    }    ContentData* newContentData = 0;    if (reuseContent && content) {        content->clearContent();        newContentData = content;    }    else        newContentData = new ContentData;        if (lastContent && !reuseContent)        lastContent->_nextContent = newContentData;    else        content = newContentData;        newContentData->_content.text = s;    newContentData->_content.text->ref();    newContentData->_contentType = CONTENT_TEXT;}ContentData::~ContentData(){    clearContent();}void ContentData::clearContent(){    delete _nextContent;    _nextContent = 0;        switch (_contentType)    {        case CONTENT_OBJECT://            _content.object->deref();            _content.object = 0;            break;        case CONTENT_TEXT:            _content.text->deref();            _content.text = 0;        default:            ;    }}#ifndef KHTML_NO_XBLBindingURI::BindingURI(DOM::DOMStringImpl* uri) :m_next(0){     m_uri = uri;    if (uri) uri->ref();}BindingURI::~BindingURI(){    if (m_uri)        m_uri->deref();    delete m_next;}BindingURI* BindingURI::copy(){    BindingURI* newBinding = new BindingURI(m_uri);    if (next()) {        BindingURI* nextCopy = next()->copy();        newBinding->setNext(nextCopy);    }        return newBinding;}bool BindingURI::operator==(const BindingURI& o) const{    if ((m_next && !o.m_next) || (!m_next && o.m_next) ||        (m_next && o.m_next && *m_next != *o.m_next))        return false;        if (m_uri == o.m_uri)        return true;    if (!m_uri || !o.m_uri)        return false;        return DOMString(m_uri) == DOMString(o.m_uri);}void RenderStyle::addBindingURI(DOM::DOMStringImpl* uri){    BindingURI* binding = new BindingURI(uri);    if (!bindingURIs())        SET_VAR(css3NonInheritedData, bindingURI, binding)    else         for (BindingURI* b = bindingURIs(); b; b = b->next()) {            if (!b->next())                b->setNext(binding);        }}#endifvoid RenderStyle::setTextShadow(ShadowData* val, bool add){    StyleCSS3InheritedData* css3Data = css3InheritedData.access();     if (!add) {        delete css3Data->textShadow;        css3Data->textShadow = val;        return;    }    ShadowData* last = css3Data->textShadow;    while (last->next) last = last->next;    last->next = val;}ShadowData::ShadowData(const ShadowData& o):x(o.x), y(o.y), blur(o.blur), color(o.color){    next = o.next ? new ShadowData(*o.next) : 0;}bool ShadowData::operator==(const ShadowData& o) const{    if ((next && !o.next) || (!next && o.next) ||        (next && o.next && *next != *o.next))        return false;        return x == o.x && y == o.y && blur == o.blur && color == o.color;}

⌨️ 快捷键说明

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