Exemplo n.º 1
0
CachedImage* TextFieldDecoratorImpl::imageForNormalState()
{
    if (!m_cachedImageForNormalState) {
        WebCString imageName = m_client->imageNameForNormalState();
        ASSERT(!imageName.isEmpty());
        RefPtr<Image> image = Image::loadPlatformResource(imageName.data());
        m_cachedImageForNormalState = new CachedImage(image.get());
        // The CachedImage owns a RefPtr to the Image.
    }
    return m_cachedImageForNormalState.get();
}
Exemplo n.º 2
0
CachedImage* TextFieldDecoratorImpl::imageForDisabledState()
{
    if (!m_cachedImageForDisabledState) {
        WebCString imageName = m_client->imageNameForDisabledState();
        if (imageName.isEmpty())
            m_cachedImageForDisabledState = imageForNormalState();
        else {
            RefPtr<Image> image = Image::loadPlatformResource(imageName.data());
            m_cachedImageForDisabledState = new CachedImage(image.get());
        }
    }
    return m_cachedImageForDisabledState.get();
}
TEST_F(WebPageNewSerializeTest, TestMHTMLEncodingWithMorphingDataURL)
{
    // Load a page with some data urls.
    WebURL topFrameURL = toKURL(m_baseURL);
    registerMockedURLLoad(topFrameURL, WebString::fromUTF8("page_with_morphing_data.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType());
    loadURLInTopFrame(topFrameURL);

    WebCString mhtmlData = WebPageSerializer::serializeToMHTML(webView());
    ASSERT_FALSE(mhtmlData.isEmpty());

    // Read the MHTML data line and check that the string data:image is found
    // exactly two times.
    size_t nbDataURLs = 0;
    LineReader lineReader(std::string(mhtmlData.data()));
    std::string line;
    while (lineReader.getNextLine(&line)) {
        if (line.find("data:text") != std::string::npos)
            nbDataURLs++;
    }
    EXPECT_EQ(2u, nbDataURLs);
}