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

📄 renderstyle.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 3 页
字号:
        content.set(newContentData);    newContentData->m_content.m_image = image.releaseRef();    newContentData->m_type = CONTENT_OBJECT;}void RenderStyle::setContent(StringImpl* s, bool add){    if (!s)        return; // The string is null. Nothing to do. Just bail.    OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;    ContentData* lastContent = content.get();    while (lastContent && lastContent->m_next)        lastContent = lastContent->m_next;    bool reuseContent = !add;    if (add && lastContent) {        if (lastContent->m_type == CONTENT_TEXT) {            // We can augment the existing string and share this ContentData node.            StringImpl* oldStr = lastContent->m_content.m_text;            String newStr = oldStr;            newStr.append(s);            newStr.impl()->ref();            oldStr->deref();            lastContent->m_content.m_text = newStr.impl();            return;        }    }    ContentData* newContentData = 0;    if (reuseContent && content) {        content->clear();        newContentData = content.release();    } else        newContentData = new ContentData;    if (lastContent && !reuseContent)        lastContent->m_next = newContentData;    else        content.set(newContentData);    newContentData->m_content.m_text = s;    newContentData->m_content.m_text->ref();    newContentData->m_type = CONTENT_TEXT;}void RenderStyle::setContent(CounterContent* c, bool add){    if (!c)        return;    OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;    ContentData* lastContent = content.get();    while (lastContent && lastContent->m_next)        lastContent = lastContent->m_next;    bool reuseContent = !add;    ContentData* newContentData = 0;    if (reuseContent && content) {        content->clear();        newContentData = content.release();    } else        newContentData = new ContentData;    if (lastContent && !reuseContent)        lastContent->m_next = newContentData;    else        content.set(newContentData);    newContentData->m_content.m_counter = c;    newContentData->m_type = CONTENT_COUNTER;}void RenderStyle::applyTransform(TransformationMatrix& transform, const IntSize& borderBoxSize, ApplyTransformOrigin applyOrigin) const{    // transform-origin brackets the transform with translate operations.    // Optimize for the case where the only transform is a translation, since the transform-origin is irrelevant    // in that case.    bool applyTransformOrigin = false;    unsigned s = rareNonInheritedData->m_transform->m_operations.operations().size();    unsigned i;    if (applyOrigin == IncludeTransformOrigin) {        for (i = 0; i < s; i++) {            TransformOperation::OperationType type = rareNonInheritedData->m_transform->m_operations.operations()[i]->getOperationType();            if (type != TransformOperation::TRANSLATE_X &&                    type != TransformOperation::TRANSLATE_Y &&                    type != TransformOperation::TRANSLATE &&                     type != TransformOperation::TRANSLATE_Z &&                     type != TransformOperation::TRANSLATE_3D                    ) {                applyTransformOrigin = true;                break;            }        }    }    if (applyTransformOrigin) {        transform.translate3d(transformOriginX().calcFloatValue(borderBoxSize.width()), transformOriginY().calcFloatValue(borderBoxSize.height()), transformOriginZ());    }    for (i = 0; i < s; i++)        rareNonInheritedData->m_transform->m_operations.operations()[i]->apply(transform, borderBoxSize);    if (applyTransformOrigin) {        transform.translate3d(-transformOriginX().calcFloatValue(borderBoxSize.width()), -transformOriginY().calcFloatValue(borderBoxSize.height()), -transformOriginZ());    }}#if ENABLE(XBL)void RenderStyle::addBindingURI(StringImpl* uri){    BindingURI* binding = new BindingURI(uri);    if (!bindingURIs())        SET_VAR(rareNonInheritedData, bindingURI, binding)    else        for (BindingURI* b = bindingURIs(); b; b = b->next()) {            if (!b->next())                b->setNext(binding);        }}#endifvoid RenderStyle::setTextShadow(ShadowData* val, bool add){    StyleRareInheritedData* rareData = rareInheritedData.access();    if (!add) {        delete rareData->textShadow;        rareData->textShadow = val;        return;    }    val->next = rareData->textShadow;    rareData->textShadow = val;}void RenderStyle::setBoxShadow(ShadowData* shadowData, bool add){    StyleRareNonInheritedData* rareData = rareNonInheritedData.access();    if (!add) {        rareData->m_boxShadow.set(shadowData);        return;    }    shadowData->next = rareData->m_boxShadow.release();    rareData->m_boxShadow.set(shadowData);}const CounterDirectiveMap* RenderStyle::counterDirectives() const{    return rareNonInheritedData->m_counterDirectives.get();}CounterDirectiveMap& RenderStyle::accessCounterDirectives(){    OwnPtr<CounterDirectiveMap>& map = rareNonInheritedData.access()->m_counterDirectives;    if (!map)        map.set(new CounterDirectiveMap);    return *map.get();}#if ENABLE(DASHBOARD_SUPPORT)const Vector<StyleDashboardRegion>& RenderStyle::initialDashboardRegions(){    DEFINE_STATIC_LOCAL(Vector<StyleDashboardRegion>, emptyList, ());    return emptyList;}const Vector<StyleDashboardRegion>& RenderStyle::noneDashboardRegions(){    DEFINE_STATIC_LOCAL(Vector<StyleDashboardRegion>, noneList, ());    static bool noneListInitialized = false;    if (!noneListInitialized) {        StyleDashboardRegion region;        region.label = "";        region.offset.m_top  = Length();        region.offset.m_right = Length();        region.offset.m_bottom = Length();        region.offset.m_left = Length();        region.type = StyleDashboardRegion::None;        noneList.append(region);        noneListInitialized = true;    }    return noneList;}#endifvoid RenderStyle::adjustAnimations(){    AnimationList* animationList = rareNonInheritedData->m_animations.get();    if (!animationList)        return;    // Get rid of empty animations and anything beyond them    for (size_t i = 0; i < animationList->size(); ++i) {        if (animationList->animation(i)->isEmpty()) {            animationList->resize(i);            break;        }    }    if (animationList->isEmpty()) {        clearAnimations();        return;    }    // Repeat patterns into layers that don't have some properties set.    animationList->fillUnsetProperties();}void RenderStyle::adjustTransitions(){    AnimationList* transitionList = rareNonInheritedData->m_transitions.get();    if (!transitionList)        return;    // Get rid of empty transitions and anything beyond them    for (size_t i = 0; i < transitionList->size(); ++i) {        if (transitionList->animation(i)->isEmpty()) {            transitionList->resize(i);            break;        }    }    if (transitionList->isEmpty()) {        clearTransitions();        return;    }    // Repeat patterns into layers that don't have some properties set.    transitionList->fillUnsetProperties();    // Make sure there are no duplicate properties. This is an O(n^2) algorithm    // but the lists tend to be very short, so it is probably ok    for (size_t i = 0; i < transitionList->size(); ++i) {        for (size_t j = i+1; j < transitionList->size(); ++j) {            if (transitionList->animation(i)->property() == transitionList->animation(j)->property()) {                // toss i                transitionList->remove(i);                j = i;            }        }    }}AnimationList* RenderStyle::accessAnimations(){    if (!rareNonInheritedData.access()->m_animations)        rareNonInheritedData.access()->m_animations.set(new AnimationList());    return rareNonInheritedData->m_animations.get();}AnimationList* RenderStyle::accessTransitions(){    if (!rareNonInheritedData.access()->m_transitions)        rareNonInheritedData.access()->m_transitions.set(new AnimationList());    return rareNonInheritedData->m_transitions.get();}const Animation* RenderStyle::transitionForProperty(int property) const{    if (transitions()) {        for (size_t i = 0; i < transitions()->size(); ++i) {            const Animation* p = transitions()->animation(i);            if (p->property() == cAnimateAll || p->property() == property) {                return p;            }        }    }    return 0;}void RenderStyle::setBlendedFontSize(int size){    FontDescription desc(fontDescription());    desc.setSpecifiedSize(size);    desc.setComputedSize(size);    setFontDescription(desc);    font().update(font().fontSelector());}} // namespace WebCore

⌨️ 快捷键说明

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