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

📄 graphicslayer.cpp

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 CPP
📖 第 1 页 / 共 2 页
字号:
{    ASSERT(!newChild->parent());    bool found = false;    for (unsigned i = 0; i < m_children.size(); i++) {        if (oldChild == m_children[i]) {            m_children[i] = newChild;            found = true;            break;        }    }    if (found) {        oldChild->setParent(0);        newChild->removeFromParent();        newChild->setParent(this);        return true;    }    return false;}void GraphicsLayer::removeAllChildren(){    while (m_children.size()) {        GraphicsLayer* curLayer = m_children[0];        ASSERT(curLayer->parent());        curLayer->removeFromParent();    }}void GraphicsLayer::removeFromParent(){    if (m_parent) {        unsigned i;        for (i = 0; i < m_parent->m_children.size(); i++) {            if (this == m_parent->m_children[i]) {                m_parent->m_children.remove(i);                break;            }        }        setParent(0);    }}void GraphicsLayer::setBackgroundColor(const Color& inColor, const Animation*, double /*beginTime*/){    m_backgroundColor = inColor;    m_backgroundColorSet = true;}void GraphicsLayer::clearBackgroundColor(){    m_backgroundColor = Color();    m_backgroundColorSet = false;}bool GraphicsLayer::setOpacity(float opacity, const Animation*, double){    m_opacity = opacity;    return false;       // not animating}void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const IntRect& clip){    m_client->paintContents(this, context, m_paintingPhase, clip);}String GraphicsLayer::propertyIdToString(AnimatedPropertyID property){    switch (property) {        case AnimatedPropertyWebkitTransform:            return "transform";        case AnimatedPropertyOpacity:            return "opacity";        case AnimatedPropertyBackgroundColor:            return "backgroundColor";        case AnimatedPropertyInvalid:            ASSERT_NOT_REACHED();    }    ASSERT_NOT_REACHED();    return "";}int GraphicsLayer::findAnimationEntry(AnimatedPropertyID property, short index) const{    for (size_t i = 0; i < m_animations.size(); ++i) {        if (m_animations[i].matches(property, index))            return static_cast<int>(i);    }    return -1;}void GraphicsLayer::addAnimationEntry(AnimatedPropertyID property, short index, bool isTransition, const Animation* transition){    int i = findAnimationEntry(property, index);        if (i >= 0)        m_animations[i].reset(transition, isTransition);    else        m_animations.append(AnimationEntry(transition, property, index, isTransition));}void GraphicsLayer::removeAllAnimations(){    size_t size = m_animations.size();    for (size_t i = 0; i < size; ++i)        removeAnimation(0, true);}void GraphicsLayer::removeAllAnimationsForProperty(AnimatedPropertyID property){    for (short j = 0; ; ++j) {        int i = findAnimationEntry(property, j);        if (i < 0)            break;        removeAnimation(i, false);    }}void GraphicsLayer::removeFinishedAnimations(const String& name, int /*index*/, bool reset){    size_t size = m_animations.size();    for (size_t i = 0; i < size; ) {        AnimationEntry& anim = m_animations[i];        if (!anim.isTransition() && anim.animation()->name() == name) {            removeAnimation(i, reset);            --size;        } else            ++i;    }}void GraphicsLayer::removeFinishedTransitions(AnimatedPropertyID property){    size_t size = m_animations.size();    for (size_t i = 0; i < size; ) {        AnimationEntry& anim = m_animations[i];        if (anim.isTransition() && property == anim.property()) {            removeAnimation(i, false);            --size;        } else            ++i;    }}void GraphicsLayer::suspendAnimations(){}void GraphicsLayer::resumeAnimations(){}#ifndef NDEBUGvoid GraphicsLayer::updateDebugIndicators(){    if (GraphicsLayer::showDebugBorders()) {        if (drawsContent()) {            if (m_usingTiledLayer)                setDebugBorder(Color(0, 255, 0, 204), 2.0f);    // tiled layer: green            else                setDebugBorder(Color(255, 0, 0, 204), 2.0f);    // normal layer: red        } else if (masksToBounds()) {            setDebugBorder(Color(128, 255, 255, 178), 2.0f);    // masking layer: pale blue            if (GraphicsLayer::showDebugBorders())                setDebugBackgroundColor(Color(128, 255, 255, 52));        } else            setDebugBorder(Color(255, 255, 0, 204), 2.0f);      // container: yellow    }}void GraphicsLayer::setZPosition(float position){    m_zPosition = position;}#endifstatic void writeIndent(TextStream& ts, int indent){    for (int i = 0; i != indent; ++i)        ts << "  ";}void GraphicsLayer::dumpLayer(TextStream& ts, int indent) const{    writeIndent(ts, indent);    ts << "(" << "GraphicsLayer" << " " << static_cast<void*>(const_cast<GraphicsLayer*>(this));    ts << " \"" << m_name << "\"\n";    dumpProperties(ts, indent);    writeIndent(ts, indent);    ts << ")\n";}void GraphicsLayer::dumpProperties(TextStream& ts, int indent) const{    writeIndent(ts, indent + 1);    ts << "(position " << m_position.x() << " " << m_position.y() << ")\n";    writeIndent(ts, indent + 1);    ts << "(anchor " << m_anchorPoint.x() << " " << m_anchorPoint.y() << ")\n";    writeIndent(ts, indent + 1);    ts << "(bounds " << m_size.width() << " " << m_size.height() << ")\n";    writeIndent(ts, indent + 1);    ts << "(opacity " << m_opacity << ")\n";        writeIndent(ts, indent + 1);    ts << "(usingTiledLayer " << m_usingTiledLayer << ")\n";    writeIndent(ts, indent + 1);    ts << "(m_preserves3D " << m_preserves3D << ")\n";    writeIndent(ts, indent + 1);    ts << "(drawsContent " << m_drawsContent << ")\n";    writeIndent(ts, indent + 1);    ts << "(m_backfaceVisibility " << (m_backfaceVisibility ? "visible" : "hidden") << ")\n";    writeIndent(ts, indent + 1);    ts << "(client ";    if (m_client)        ts << static_cast<void*>(m_client);    else        ts << "none";    ts << ")\n";    writeIndent(ts, indent + 1);    ts << "(backgroundColor ";    if (!m_backgroundColorSet)        ts << "none";    else        ts << m_backgroundColor.name();    ts << ")\n";    writeIndent(ts, indent + 1);    ts << "(transform ";    if (m_transform.isIdentity())        ts << "identity";    else {        ts << "[" << m_transform.m11() << " " << m_transform.m12() << " " << m_transform.m13() << " " << m_transform.m14() << "] ";        ts << "[" << m_transform.m21() << " " << m_transform.m22() << " " << m_transform.m23() << " " << m_transform.m24() << "] ";        ts << "[" << m_transform.m31() << " " << m_transform.m32() << " " << m_transform.m33() << " " << m_transform.m34() << "] ";        ts << "[" << m_transform.m41() << " " << m_transform.m42() << " " << m_transform.m43() << " " << m_transform.m44() << "]";    }    ts << ")\n";    writeIndent(ts, indent + 1);    ts << "(childrenTransform ";    if (m_childrenTransform.isIdentity())        ts << "identity";    else {        ts << "[" << m_childrenTransform.m11() << " " << m_childrenTransform.m12() << " " << m_childrenTransform.m13() << " " << m_childrenTransform.m14() << "] ";        ts << "[" << m_childrenTransform.m21() << " " << m_childrenTransform.m22() << " " << m_childrenTransform.m23() << " " << m_childrenTransform.m24() << "] ";        ts << "[" << m_childrenTransform.m31() << " " << m_childrenTransform.m32() << " " << m_childrenTransform.m33() << " " << m_childrenTransform.m34() << "] ";        ts << "[" << m_childrenTransform.m41() << " " << m_childrenTransform.m42() << " " << m_childrenTransform.m43() << " " << m_childrenTransform.m44() << "]";    }    ts << ")\n";    writeIndent(ts, indent + 1);    ts << "(children " << m_children.size() << "\n";        unsigned i;    for (i = 0; i < m_children.size(); i++)        m_children[i]->dumpLayer(ts, indent+2);    writeIndent(ts, indent + 1);    ts << ")\n";}} // namespace WebCore#endif // USE(ACCELERATED_COMPOSITING)

⌨️ 快捷键说明

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