本文整理汇总了C++中RefPtrWillBePersistent类的典型用法代码示例。如果您正苦于以下问题:C++ RefPtrWillBePersistent类的具体用法?C++ RefPtrWillBePersistent怎么用?C++ RefPtrWillBePersistent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RefPtrWillBePersistent类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testMQEvaluator
void testMQEvaluator(TestCase* testCases, const MediaQueryEvaluator& mediaQueryEvaluator)
{
RefPtrWillBePersistent<MediaQuerySet> querySet = nullptr;
for (unsigned i = 0; testCases[i].input; ++i) {
querySet = MediaQuerySet::create(testCases[i].input);
ASSERT_EQ(testCases[i].output, mediaQueryEvaluator.eval(querySet.get()));
}
}
示例2: TEST
TEST(MediaQueryEvaluatorTest, DynamicNoView)
{
OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(500, 500));
RefPtrWillBePersistent<FrameView> view = pageHolder->frame().view();
pageHolder->frame().setView(nullptr);
MediaQueryEvaluator mediaQueryEvaluator(&pageHolder->frame());
RefPtrWillBePersistent<MediaQuerySet> querySet = MediaQuerySet::create("foobar");
bool output = false;
ASSERT_EQ(output, mediaQueryEvaluator.eval(querySet.get()));
pageHolder->frame().setView(view);
}
示例3: TEST_F
TEST_F(DocumentMarkerControllerTest, DidMoveToNewDocument)
{
setBodyInnerHTML("<b><i>foo</i></b>");
RefPtrWillBeRawPtr<Element> parent = toElement(document().body()->firstChild()->firstChild());
markNodeContents(parent.get());
EXPECT_EQ(1u, markerController().markers().size());
RefPtrWillBePersistent<Document> anotherDocument = Document::create();
anotherDocument->adoptNode(parent.get(), ASSERT_NO_EXCEPTION);
// No more reference to marked node.
Heap::collectAllGarbage();
EXPECT_EQ(0u, markerController().markers().size());
EXPECT_EQ(0u, anotherDocument->markers().markers().size());
}
示例4: TEST_F
TEST_F(PrintContextFrameTest, WithScrolledSubframe)
{
MockCanvas canvas;
document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/"));
setBodyInnerHTML("<style>::-webkit-scrollbar { display: none }</style>"
"<iframe id='frame' src='http://b.com/' width='500' height='500'"
" style='border-width: 5px; margin: 5px; position: absolute; top: 90px; left: 90px'></iframe>");
HTMLIFrameElement& iframe = *toHTMLIFrameElement(document().getElementById("frame"));
OwnPtrWillBeRawPtr<FrameLoaderClient> frameLoaderClient = FrameLoaderClientWithParent::create(document().frame());
RefPtrWillBePersistent<LocalFrame> subframe = LocalFrame::create(frameLoaderClient.get(), document().frame()->host(), &iframe);
subframe->setView(FrameView::create(subframe.get(), IntSize(500, 500)));
subframe->init();
static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())->setChild(subframe.get());
document().frame()->host()->incrementSubframeCount();
Document& frameDocument = *iframe.contentDocument();
frameDocument.setBaseURLOverride(KURL(ParsedURLString, "http://b.com/"));
frameDocument.body()->setInnerHTML(
absoluteBlockHtmlForLink(10, 10, 20, 20, "http://invisible.com")
+ absoluteBlockHtmlForLink(50, 60, 70, 80, "http://partly.visible.com")
+ absoluteBlockHtmlForLink(150, 160, 170, 180, "http://www.google.com")
+ absoluteBlockHtmlForLink(250, 260, 270, 280, "http://www.google.com#fragment")
+ absoluteBlockHtmlForLink(850, 860, 70, 80, "http://another.invisible.com"),
ASSERT_NO_EXCEPTION);
iframe.contentWindow()->scrollTo(100, 100);
printSinglePage(canvas);
const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations();
ASSERT_EQ(3u, operations.size());
EXPECT_EQ(MockCanvas::DrawRect, operations[0].type);
EXPECT_SKRECT_EQ(50, 60, 70, 80, operations[0].rect); // FIXME: the rect should be clipped.
EXPECT_EQ(MockCanvas::DrawRect, operations[1].type);
EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect);
EXPECT_EQ(MockCanvas::DrawRect, operations[2].type);
EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect);
subframe->detach(FrameDetachType::Remove);
static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())->setChild(nullptr);
document().frame()->host()->decrementSubframeCount();
}
示例5: TEST_F
// Verifies that HTMLImageElements are given an elevated CacheLiveResourcePriority when used to construct an ImageBitmap.
// ImageBitmaps that have crop rects outside of the bounds of the HTMLImageElement do not have elevated CacheLiveResourcePriority.
TEST_F(ImageBitmapTest, ImageBitmapLiveResourcePriority)
{
RefPtrWillBePersistent<HTMLImageElement> imageNoCrop = HTMLImageElement::create(*Document::create().get());
ResourcePtr<ImageResource> cachedImageNoCrop = new ImageResource(ResourceRequest("http://foo.com/1"), BitmapImage::create(NativeImageSkia::create(m_bitmap)).get());
imageNoCrop->setImageResource(cachedImageNoCrop.get());
RefPtrWillBePersistent<HTMLImageElement> imageInteriorCrop = HTMLImageElement::create(*Document::create().get());
ResourcePtr<ImageResource> cachedImageInteriorCrop = new ImageResource(ResourceRequest("http://foo.com/2"), BitmapImage::create(NativeImageSkia::create(m_bitmap)).get());
imageInteriorCrop->setImageResource(cachedImageInteriorCrop.get());
RefPtrWillBePersistent<HTMLImageElement> imageExteriorCrop = HTMLImageElement::create(*Document::create().get());
ResourcePtr<ImageResource> cachedImageExteriorCrop = new ImageResource(ResourceRequest("http://foo.com/3"), BitmapImage::create(NativeImageSkia::create(m_bitmap)).get());
imageExteriorCrop->setImageResource(cachedImageExteriorCrop.get());
RefPtrWillBePersistent<HTMLImageElement> imageOutsideCrop = HTMLImageElement::create(*Document::create().get());
ResourcePtr<ImageResource> cachedImageOutsideCrop = new ImageResource(ResourceRequest("http://foo.com/4"), BitmapImage::create(NativeImageSkia::create(m_bitmap)).get());
imageOutsideCrop->setImageResource(cachedImageOutsideCrop.get());
MockImageResourceClient mockClient1, mockClient2, mockClient3, mockClient4;
cachedImageNoCrop->addClient(&mockClient1);
cachedImageInteriorCrop->addClient(&mockClient2);
cachedImageExteriorCrop->addClient(&mockClient3);
cachedImageOutsideCrop->addClient(&mockClient4);
memoryCache()->add(cachedImageNoCrop.get());
memoryCache()->add(cachedImageInteriorCrop.get());
memoryCache()->add(cachedImageExteriorCrop.get());
memoryCache()->add(cachedImageOutsideCrop.get());
memoryCache()->updateDecodedResource(cachedImageNoCrop.get(), UpdateForPropertyChange);
memoryCache()->updateDecodedResource(cachedImageInteriorCrop.get(), UpdateForPropertyChange);
memoryCache()->updateDecodedResource(cachedImageExteriorCrop.get(), UpdateForPropertyChange);
memoryCache()->updateDecodedResource(cachedImageOutsideCrop.get(), UpdateForPropertyChange);
// HTMLImageElements should default to CacheLiveResourcePriorityLow.
ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
RefPtrWillBePersistent<ImageBitmap> imageBitmapInteriorCrop = ImageBitmap::create(imageInteriorCrop.get(), IntRect(m_bitmap.width() / 2, m_bitmap.height() / 2, m_bitmap.width(), m_bitmap.height()));
{
RefPtrWillBePersistent<ImageBitmap> imageBitmapNoCrop = ImageBitmap::create(imageNoCrop.get(), IntRect(0, 0, m_bitmap.width(), m_bitmap.height()));
RefPtrWillBePersistent<ImageBitmap> imageBitmapInteriorCrop2 = ImageBitmap::create(imageInteriorCrop.get(), IntRect(m_bitmap.width() / 2, m_bitmap.height() / 2, m_bitmap.width(), m_bitmap.height()));
RefPtrWillBePersistent<ImageBitmap> imageBitmapExteriorCrop = ImageBitmap::create(imageExteriorCrop.get(), IntRect(-m_bitmap.width() / 2, -m_bitmap.height() / 2, m_bitmap.width(), m_bitmap.height()));
RefPtrWillBePersistent<ImageBitmap> imageBitmapOutsideCrop = ImageBitmap::create(imageOutsideCrop.get(), IntRect(-m_bitmap.width(), -m_bitmap.height(), m_bitmap.width(), m_bitmap.height()));
// Images that are referenced by ImageBitmaps have CacheLiveResourcePriorityHigh.
ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLiveResourcePriorityHigh);
ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityHigh);
ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityHigh);
// ImageBitmaps that do not contain any of the source image do not elevate CacheLiveResourcePriority.
ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
}
// Force a garbage collection to sweep out the local ImageBitmaps.
Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
// CacheLiveResourcePriroity should return to CacheLiveResourcePriorityLow when no ImageBitmaps reference the image.
ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
// There is still an ImageBitmap that references this image.
ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityHigh);
imageBitmapInteriorCrop = nullptr;
}
示例6: TEST_F
// Verifies that HTMLImageElements are given an elevated CacheLiveResourcePriority when used to construct an ImageBitmap.
// ImageBitmaps that have crop rects outside of the bounds of the HTMLImageElement do not have elevated CacheLiveResourcePriority.
TEST_F(ImageBitmapTest, ImageBitmapLiveResourcePriority)
{
RefPtrWillBePersistent<HTMLImageElement> imageNoCrop = HTMLImageElement::create(*Document::create().get());
ResourcePtr<ImageResource> cachedImageNoCrop = new ImageResource(ResourceRequest("http://foo.com/1"),
StaticBitmapImage::create(m_image).get());
imageNoCrop->setImageResource(cachedImageNoCrop.get());
RefPtrWillBePersistent<HTMLImageElement> imageInteriorCrop = HTMLImageElement::create(*Document::create().get());
ResourcePtr<ImageResource> cachedImageInteriorCrop = new ImageResource(ResourceRequest("http://foo.com/2"),
StaticBitmapImage::create(m_image).get());
imageInteriorCrop->setImageResource(cachedImageInteriorCrop.get());
RefPtrWillBePersistent<HTMLImageElement> imageExteriorCrop = HTMLImageElement::create(*Document::create().get());
ResourcePtr<ImageResource> cachedImageExteriorCrop = new ImageResource(ResourceRequest("http://foo.com/3"),
StaticBitmapImage::create(m_image).get());
imageExteriorCrop->setImageResource(cachedImageExteriorCrop.get());
RefPtrWillBePersistent<HTMLImageElement> imageOutsideCrop = HTMLImageElement::create(*Document::create().get());
ResourcePtr<ImageResource> cachedImageOutsideCrop = new ImageResource(ResourceRequest("http://foo.com/4"),
StaticBitmapImage::create(m_image).get());
imageOutsideCrop->setImageResource(cachedImageOutsideCrop.get());
MockImageResourceClient mockClient1(cachedImageNoCrop);
MockImageResourceClient mockClient2(cachedImageInteriorCrop);
MockImageResourceClient mockClient3(cachedImageExteriorCrop);
MockImageResourceClient mockClient4(cachedImageOutsideCrop);
memoryCache()->add(cachedImageNoCrop.get());
memoryCache()->add(cachedImageInteriorCrop.get());
memoryCache()->add(cachedImageExteriorCrop.get());
memoryCache()->add(cachedImageOutsideCrop.get());
memoryCache()->updateDecodedResource(cachedImageNoCrop.get(), UpdateForPropertyChange);
memoryCache()->updateDecodedResource(cachedImageInteriorCrop.get(), UpdateForPropertyChange);
memoryCache()->updateDecodedResource(cachedImageExteriorCrop.get(), UpdateForPropertyChange);
memoryCache()->updateDecodedResource(cachedImageOutsideCrop.get(), UpdateForPropertyChange);
// HTMLImageElements should default to CacheLiveResourcePriorityLow.
ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
RefPtrWillBePersistent<ImageBitmap> imageBitmapInteriorCrop = ImageBitmap::create(imageInteriorCrop.get(),
IntRect(m_image->width() / 2, m_image->height() / 2, m_image->width(), m_image->height()));
{
RefPtrWillBePersistent<ImageBitmap> imageBitmapNoCrop = ImageBitmap::create(imageNoCrop.get(),
IntRect(0, 0, m_image->width(), m_image->height()));
RefPtrWillBePersistent<ImageBitmap> imageBitmapInteriorCrop2 = ImageBitmap::create(imageInteriorCrop.get(),
IntRect(m_image->width() / 2, m_image->height() / 2, m_image->width(), m_image->height()));
RefPtrWillBePersistent<ImageBitmap> imageBitmapExteriorCrop = ImageBitmap::create(imageExteriorCrop.get(),
IntRect(-m_image->width() / 2, -m_image->height() / 2, m_image->width(), m_image->height()));
RefPtrWillBePersistent<ImageBitmap> imageBitmapOutsideCrop = ImageBitmap::create(imageOutsideCrop.get(),
IntRect(-m_image->width(), -m_image->height(), m_image->width(), m_image->height()));
// Images are not referenced by ImageBitmap anymore, so always CacheLiveResourcePriorityLow
ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
// ImageBitmaps that do not contain any of the source image do not elevate CacheLiveResourcePriority.
ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
}
// Force a garbage collection to sweep out the local ImageBitmaps.
Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC);
// CacheLiveResourcePriroity should return to CacheLiveResourcePriorityLow when no ImageBitmaps reference the image.
ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
// There is still an ImageBitmap that references this image.
ASSERT_EQ(memoryCache()->priority(imageInteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
imageBitmapInteriorCrop = nullptr;
}
示例7: SetUp
void HTMLFormControlElementTest::SetUp()
{
Page::PageClients pageClients;
fillWithEmptyClients(pageClients);
m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients);
m_document = toHTMLDocument(&m_dummyPageHolder->document());
m_document->setMimeType("text/html");
m_document->setCharset("utf-8");
}
示例8: SetUp
void CanvasFontCacheTest::SetUp()
{
Page::PageClients pageClients;
fillWithEmptyClients(pageClients);
m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients);
m_document = toHTMLDocument(&m_dummyPageHolder->document());
m_document->documentElement()->setInnerHTML("<body><canvas id='c'></canvas></body>", ASSERT_NO_EXCEPTION);
m_document->view()->updateAllLifecyclePhases();
m_canvasElement = toHTMLCanvasElement(m_document->getElementById("c"));
String canvasType("2d");
CanvasContextCreationAttributes attributes;
attributes.setAlpha(true);
m_canvasElement->getCanvasRenderingContext(canvasType, attributes);
context2d(); // Calling this for the checks
}
示例9: SetUp
void HTMLTextFormControlElementTest::SetUp()
{
Page::PageClients pageClients;
fillWithEmptyClients(pageClients);
m_spellCheckerClient = adoptPtr(new DummySpellCheckerClient);
pageClients.spellCheckerClient = m_spellCheckerClient.get();
m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients);
m_document = toHTMLDocument(&m_dummyPageHolder->document());
m_document->documentElement()->setInnerHTML("<body><textarea id=textarea></textarea><input id=input /></body>", ASSERT_NO_EXCEPTION);
m_document->view()->updateAllLifecyclePhases();
m_textControl = toHTMLTextFormControlElement(m_document->getElementById("textarea"));
m_textControl->focus();
m_input = toHTMLInputElement(m_document->getElementById("input"));
}
示例10: SetUp
void RangeTest::SetUp()
{
m_document = HTMLDocument::create();
RefPtrWillBeRawPtr<HTMLHtmlElement> html = HTMLHtmlElement::create(*m_document);
html->appendChild(HTMLBodyElement::create(*m_document));
m_document->appendChild(html.release());
}
示例11: initialize
bool MockPagePopup::initialize()
{
const char scriptToSetUpPagePopupController[] = "<script>window.pagePopupController = parent.internals.pagePopupController;</script>";
RefPtr<SharedBuffer> data = SharedBuffer::create(scriptToSetUpPagePopupController, sizeof(scriptToSetUpPagePopupController));
m_popupClient->writeDocument(data.get());
LocalFrame* localFrame = toLocalFrame(m_iframe->contentFrame());
if (!localFrame)
return false;
localFrame->loader().load(FrameLoadRequest(0, blankURL(), SubstituteData(data, "text/html", "UTF-8", KURL(), ForceSynchronousLoad)));
return true;
}
示例12: MockPagePopup
inline MockPagePopup::MockPagePopup(PagePopupClient* client, const IntRect& originBoundsInRootView, LocalFrame* mainFrame)
: m_popupClient(client)
, m_closeTimer(this, &MockPagePopup::close)
{
Document* document = mainFrame->document();
ASSERT(document);
m_iframe = HTMLIFrameElement::create(*document);
m_iframe->setIdAttribute("mock-page-popup");
m_iframe->setInlineStyleProperty(CSSPropertyBorderWidth, 0.0, CSSPrimitiveValue::CSS_PX);
m_iframe->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
m_iframe->setInlineStyleProperty(CSSPropertyLeft, originBoundsInRootView.x(), CSSPrimitiveValue::CSS_PX, true);
m_iframe->setInlineStyleProperty(CSSPropertyTop, originBoundsInRootView.maxY(), CSSPrimitiveValue::CSS_PX, true);
if (document->body())
document->body()->appendChild(m_iframe.get());
}
示例13: wake
void wake()
{
timeline->wake();
}
示例14: focus
void ImeOnFocusTest::focus(const AtomicString& element)
{
m_document->body()->getElementById(element)->focus();
}