void RenderStyle::setContent(CounterContent* c, bool add)
{
    if (!c)
        return;

    OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
    ContentData* lastContent = content.get();
    while (lastContent && lastContent->next())
        lastContent = lastContent->next();

    bool reuseContent = !add;
    ContentData* newContentData = 0;
    if (reuseContent && content) {
        content->clear();
        newContentData = content.release();
    } else
        newContentData = new ContentData;

    if (lastContent && !reuseContent)
        lastContent->setNext(newContentData);
    else
        content.set(newContentData);

    newContentData->setCounter(c);
}
ContentData* RenderStyle::prepareToSetContent(StringImpl* string, bool add)
{
    OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
    ContentData* lastContent = content.get();
    while (lastContent && lastContent->next())
        lastContent = lastContent->next();

    if (string && add && lastContent && lastContent->isText()) {
        // Augment the existing string and share the existing ContentData node.
        String newText = lastContent->text();
        newText.append(string);
        lastContent->setText(newText.impl());
        return 0;
    }

    bool reuseContent = !add;
    OwnPtr<ContentData> newContentData;
    if (reuseContent && content) {
        content->clear();
        newContentData = content.release();
    } else
        newContentData = adoptPtr(new ContentData);

    ContentData* result = newContentData.get();

    if (lastContent && !reuseContent)
        lastContent->setNext(newContentData.release());
    else
        content = newContentData.release();

    return result;
}
void RenderStyle::setContent(PassRefPtr<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->next())
        lastContent = lastContent->next();

    bool reuseContent = !add;
    if (add && lastContent) {
        if (lastContent->isText()) {
            // We can augment the existing string and share this ContentData node.
            String newStr = lastContent->text();
            newStr.append(s.get());
            lastContent->setText(newStr.impl());
            return;
        }
    }

    ContentData* newContentData = 0;
    if (reuseContent && content) {
        content->clear();
        newContentData = content.release();
    } else
        newContentData = new ContentData;

    if (lastContent && !reuseContent)
        lastContent->setNext(newContentData);
    else
        content.set(newContentData);

    newContentData->setText(s);
}
void RenderStyle::setContent(PassRefPtr<StyleImage> image, bool add)
{
    if (!image)
        return; // The object is null. Nothing to do. Just bail.

    OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
    ContentData* lastContent = content.get();
    while (lastContent && lastContent->next())
        lastContent = lastContent->next();

    bool reuseContent = !add;
    ContentData* newContentData;
    if (reuseContent && content) {
        content->clear();
        newContentData = content.release();
    } else
        newContentData = new ContentData;

    if (lastContent && !reuseContent)
        lastContent->setNext(newContentData);
    else
        content.set(newContentData);

    newContentData->setImage(image);
}
Esempio n. 5
0
PassOwnPtr<ContentData> ContentData::clone() const
{
    OwnPtr<ContentData> result = cloneInternal();

    ContentData* lastNewData = result.get();
    for (const ContentData* contentData = next(); contentData; contentData = contentData->next()) {
        OwnPtr<ContentData> newData = contentData->cloneInternal();
        lastNewData->setNext(newData.release());
        lastNewData = lastNewData->next();
    }

    return result.release();
}
Esempio n. 6
0
std::unique_ptr<ContentData> ContentData::clone() const
{
    auto result = cloneInternal();
    
    ContentData* lastNewData = result.get();
    for (const ContentData* contentData = next(); contentData; contentData = contentData->next()) {
        auto newData = contentData->cloneInternal();
        lastNewData->setNext(std::move(newData));
        lastNewData = lastNewData->next();
    }
        
    return result;
}
Esempio n. 7
0
ContentData* ContentData::clone() const {
  ContentData* result = cloneInternal();

  ContentData* lastNewData = result;
  for (const ContentData* contentData = next(); contentData;
       contentData = contentData->next()) {
    ContentData* newData = contentData->cloneInternal();
    lastNewData->setNext(newData);
    lastNewData = lastNewData->next();
  }

  return result;
}