本文整理汇总了C++中RenderObject::destroy方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderObject::destroy方法的具体用法?C++ RenderObject::destroy怎么用?C++ RenderObject::destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderObject
的用法示例。
在下文中一共展示了RenderObject::destroy方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateMarkerLocation
void RenderListItem::updateMarkerLocation()
{
// Sanity check the location of our marker.
if (m_marker) {
RenderObject* markerPar = m_marker->parent();
RenderObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker);
if (!lineBoxParent) {
// If the marker is currently contained inside an anonymous box,
// then we are the only item in that anonymous box (since no line box
// parent was found). It's ok to just leave the marker where it is
// in this case.
if (markerPar && markerPar->isAnonymousBlock())
lineBoxParent = markerPar;
else
lineBoxParent = this;
}
if (markerPar != lineBoxParent || m_marker->preferredLogicalWidthsDirty()) {
// Removing and adding the marker can trigger repainting in
// containers other than ourselves, so we need to disable LayoutState.
LayoutStateDisabler layoutStateDisabler(view());
updateFirstLetter();
m_marker->remove();
if (!lineBoxParent)
lineBoxParent = this;
lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent));
m_marker->updateMarginsAndContent();
// If markerPar is an anonymous block that has lost all its children, destroy it.
if (markerPar && markerPar->isAnonymousBlock() && !markerPar->firstChild() && !toRenderBlock(markerPar)->continuation())
markerPar->destroy();
}
}
}
示例2: updateMarkerLocation
bool RenderListItem::updateMarkerLocation()
{
ASSERT(m_marker);
RenderObject* markerParent = m_marker->parent();
RenderObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker);
if (!lineBoxParent) {
// If the marker is currently contained inside an anonymous box, then we
// are the only item in that anonymous box (since no line box parent was
// found). It's ok to just leave the marker where it is in this case.
if (markerParent && markerParent->isAnonymousBlock())
lineBoxParent = markerParent;
else
lineBoxParent = this;
}
if (markerParent != lineBoxParent) {
m_marker->remove();
lineBoxParent->addChild(m_marker, firstNonMarkerChild(lineBoxParent));
m_marker->updateMarginsAndContent();
// If markerParent is an anonymous block with no children, destroy it.
if (markerParent && markerParent->isAnonymousBlock() && !toRenderBlock(markerParent)->firstChild() && !toRenderBlock(markerParent)->continuation())
markerParent->destroy();
return true;
}
return false;
}
示例3: attach
void PseudoElement::attach(const AttachContext& context)
{
ASSERT(!renderer());
Element::attach(context);
RenderObject* renderer = this->renderer();
if (!renderer)
return;
RenderStyle* style = renderer->style();
if (style->hasFlowFrom())
return;
if (style->styleType() != BEFORE && style->styleType() != AFTER)
return;
ASSERT(style->contentData());
for (const ContentData* content = style->contentData(); content; content = content->next()) {
RenderObject* child = content->createRenderer(document(), style);
if (renderer->isChildAllowed(child, style)) {
renderer->addChild(child);
if (child->isQuote())
toRenderQuote(child)->attachQuote();
} else
child->destroy();
}
}
示例4: ensureBeforeAfterContainer
static RenderObject* ensureBeforeAfterContainer(RenderObject* owner, PseudoId type, RenderStyle* pseudoElementStyle, Node* generatingNode, RenderObject* insertBefore)
{
// Make a generated box that might be any display type now that we are able to drill down into children
// to find the original content properly.
RenderObject* generatedContentContainer = RenderObject::createObject(owner->document(), pseudoElementStyle);
ASSERT(generatingNode); // The styled object cannot be anonymous or else it could not have ':before' or ':after' pseudo elements.
generatedContentContainer->setNode(generatingNode); // This allows access to the generatingNode.
generatedContentContainer->setStyle(pseudoElementStyle);
if (!owner->isChildAllowed(generatedContentContainer, pseudoElementStyle)) {
// The generated content container is not allowed here -> abort.
generatedContentContainer->destroy();
return 0;
}
// When we don't have a first child and are part of a continuation chain,
// insertBefore is incorrectly set to zero above, which causes the :before
// child to end up at the end of continuation chain.
// See https://bugs.webkit.org/show_bug.cgi?id=78380.
if (!insertBefore && type == BEFORE && owner->virtualContinuation())
owner->addChildIgnoringContinuation(generatedContentContainer, 0);
else
owner->addChild(generatedContentContainer, insertBefore);
return generatedContentContainer;
}
示例5: createRendererIfNeeded
static void createRendererIfNeeded(Element& element, RenderStyle* resolvedStyle)
{
ASSERT(!element.renderer());
Document& document = element.document();
ContainerNode* renderingParentNode = NodeRenderingTraversal::parent(&element);
RefPtr<RenderStyle> style = resolvedStyle;
element.setIsInsideRegion(false);
if (!shouldCreateRenderer(element, renderingParentNode) && !elementInsideRegionNeedsRenderer(element, renderingParentNode, style))
return;
if (!style)
style = element.styleForRenderer();
RenderNamedFlowThread* parentFlowRenderer = 0;
#if ENABLE(CSS_REGIONS)
parentFlowRenderer = moveToFlowThreadIfNeeded(element, *style);
#endif
if (!element.rendererIsNeeded(*style))
return;
RenderObject* parentRenderer;
RenderObject* nextRenderer;
if (parentFlowRenderer) {
parentRenderer = parentFlowRenderer;
nextRenderer = parentFlowRenderer->nextRendererForNode(&element);
} else {
parentRenderer = renderingParentNode->renderer();
nextRenderer = nextSiblingRenderer(element, renderingParentNode);
}
RenderObject* newRenderer = element.createRenderer(document.renderArena(), style.get());
if (!newRenderer)
return;
if (!parentRenderer->isChildAllowed(newRenderer, style.get())) {
newRenderer->destroy();
return;
}
// Make sure the RenderObject already knows it is going to be added to a RenderFlowThread before we set the style
// for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail.
newRenderer->setFlowThreadState(parentRenderer->flowThreadState());
element.setRenderer(newRenderer);
newRenderer->setAnimatableStyle(style.release()); // setAnimatableStyle() can depend on renderer() already being set.
#if ENABLE(FULLSCREEN_API)
if (document.webkitIsFullScreen() && document.webkitCurrentFullScreenElement() == &element) {
newRenderer = RenderFullScreen::wrapRenderer(newRenderer, parentRenderer, &document);
if (!newRenderer)
return;
}
#endif
// Note: Adding newRenderer instead of renderer(). renderer() may be a child of newRenderer.
parentRenderer->addChild(newRenderer, nextRenderer);
}
示例6: document
TEST_F(RenderPartTest, DestroyUpdatesImageQualityController)
{
RefPtrWillBeRawPtr<Element> element = HTMLElement::create(HTMLNames::divTag, document());
RenderObject* part = new RenderPart(element.get());
// The third and forth arguments are not important in this test.
ImageQualityController::imageQualityController()->set(part, 0, this, LayoutSize(1, 1));
EXPECT_TRUE(ImageQualityController::has(part));
part->destroy();
EXPECT_FALSE(ImageQualityController::has(part));
}
示例7: createRendererForElementIfNeeded
void NodeRenderingContext::createRendererForElementIfNeeded()
{
ASSERT(!m_node->renderer());
Element* element = toElement(m_node);
if (!shouldCreateRenderer())
return;
m_style = element->styleForRenderer();
ASSERT(m_style);
moveToFlowThreadIfNeeded();
if (!element->rendererIsNeeded(*this))
return;
RenderObject* parentRenderer = this->parentRenderer();
RenderObject* nextRenderer = this->nextRenderer();
#if ENABLE(DIALOG_ELEMENT)
if (element->isInTopLayer())
adjustInsertionPointForTopLayerElement(element, parentRenderer, nextRenderer);
#endif
Document* document = element->document();
RenderObject* newRenderer = element->createRenderer(document->renderArena(), m_style.get());
if (!newRenderer)
return;
if (!parentRenderer->isChildAllowed(newRenderer, m_style.get())) {
newRenderer->destroy();
return;
}
// Make sure the RenderObject already knows it is going to be added to a RenderFlowThread before we set the style
// for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail.
newRenderer->setInRenderFlowThread(parentRenderer->inRenderFlowThread());
element->setRenderer(newRenderer);
newRenderer->setAnimatableStyle(m_style.release()); // setAnimatableStyle() can depend on renderer() already being set.
#if ENABLE(FULLSCREEN_API)
if (document->webkitIsFullScreen() && document->webkitCurrentFullScreenElement() == element) {
newRenderer = RenderFullScreen::wrapRenderer(newRenderer, parentRenderer, document);
if (!newRenderer)
return;
}
#endif
// Note: Adding newRenderer instead of renderer(). renderer() may be a child of newRenderer.
parentRenderer->addChild(newRenderer, nextRenderer);
}
示例8: createRendererForElementIfNeeded
void NodeRenderingContext::createRendererForElementIfNeeded()
{
ASSERT(!m_node->renderer());
Element* element = toElement(m_node);
element->setIsInsideRegion(false);
if (!shouldCreateRenderer() && !elementInsideRegionNeedsRenderer())
return;
if (!m_style)
m_style = element->styleForRenderer();
ASSERT(m_style);
moveToFlowThreadIfNeeded();
if (!element->rendererIsNeeded(*this))
return;
RenderObject* newRenderer = element->createRenderer(m_style.get());
if (!newRenderer)
return;
RenderObject* parentRenderer = this->parentRenderer();
if (!parentRenderer->isChildAllowed(newRenderer, m_style.get())) {
newRenderer->destroy();
return;
}
// Make sure the RenderObject already knows it is going to be added to a RenderFlowThread before we set the style
// for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail.
newRenderer->setFlowThreadState(parentRenderer->flowThreadState());
RenderObject* nextRenderer = this->nextRenderer();
element->setRenderer(newRenderer);
newRenderer->setAnimatableStyle(m_style.release()); // setAnimatableStyle() can depend on renderer() already being set.
if (FullscreenElementStack::isActiveFullScreenElement(element)) {
newRenderer = RenderFullScreen::wrapRenderer(newRenderer, parentRenderer, element->document());
if (!newRenderer)
return;
}
// Note: Adding newRenderer instead of renderer(). renderer() may be a child of newRenderer.
parentRenderer->addChild(newRenderer, nextRenderer);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:48,代码来源:NodeRenderingContext.cpp
示例9: createRenderer
RenderObject* NodeRendererFactory::createRenderer()
{
Node* node = m_context.node();
RenderObject* newRenderer = node->createRenderer(node->document()->renderArena(), m_context.style());
if (!newRenderer)
return 0;
if (!m_context.parentRenderer()->isChildAllowed(newRenderer, m_context.style())) {
newRenderer->destroy();
return 0;
}
node->setRenderer(newRenderer);
newRenderer->setAnimatableStyle(m_context.releaseStyle()); // setAnimatableStyle() can depend on renderer() already being set.
return newRenderer;
}
示例10: createRendererIfNeeded
void NodeRenderingContext::createRendererIfNeeded()
{
ASSERT(!m_node->renderer());
if (!shouldCreateRenderer())
return;
Element* element = m_node->isElementNode() ? toElement(m_node) : 0;
m_style = element ? element->styleForRenderer() : parentRenderer()->style();
ASSERT(m_style);
moveToFlowThreadIfNeeded();
if (!m_node->rendererIsNeeded(*this)) {
if (element && m_style->affectedByEmpty())
element->setStyleAffectedByEmpty();
return;
}
RenderObject* parentRenderer = this->parentRenderer();
RenderObject* nextRenderer = this->nextRenderer();
#if ENABLE(DIALOG_ELEMENT)
if (element && element->isInTopLayer())
adjustInsertionPointForTopLayerElement(element, parentRenderer, nextRenderer);
#endif
Document* document = m_node->document();
RenderObject* newRenderer = m_node->createRenderer(document->renderArena(), m_style.get());
if (!newRenderer)
return;
if (!parentRenderer->isChildAllowed(newRenderer, m_style.get())) {
newRenderer->destroy();
return;
}
m_node->setRenderer(newRenderer);
newRenderer->setAnimatableStyle(m_style.release()); // setAnimatableStyle() can depend on renderer() already being set.
#if ENABLE(FULLSCREEN_API)
if (document->webkitIsFullScreen() && document->webkitCurrentFullScreenElement() == m_node) {
newRenderer = RenderFullScreen::wrapRenderer(newRenderer, parentRenderer, document);
if (!newRenderer)
return;
}
#endif
// Note: Adding newRenderer instead of renderer(). renderer() may be a child of newRenderer.
parentRenderer->addChild(newRenderer, nextRenderer);
}
示例11: createRendererForElementIfNeeded
void RenderTreeBuilder::createRendererForElementIfNeeded()
{
ASSERT(!m_node->renderer());
// If we're out of composition then we can't render since there's no parent to inherit from.
if (!m_renderingParent)
return;
Element* element = toElement(m_node);
if (!shouldCreateRenderer())
return;
RenderStyle& style = this->style();
if (!element->rendererIsNeeded(style))
return;
RenderObject* newRenderer = element->createRenderer(&style);
if (!newRenderer)
return;
RenderObject* parentRenderer = this->parentRenderer();
if (!parentRenderer->isChildAllowed(newRenderer, &style)) {
newRenderer->destroy();
return;
}
// Make sure the RenderObject already knows it is going to be added to a RenderFlowThread before we set the style
// for the first time. Otherwise code using inRenderFlowThread() in the styleWillChange and styleDidChange will fail.
newRenderer->setFlowThreadState(parentRenderer->flowThreadState());
RenderObject* nextRenderer = this->nextRenderer();
element->setRenderer(newRenderer);
newRenderer->setStyle(&style); // setStyle() can depend on renderer() already being set.
if (FullscreenElementStack::isActiveFullScreenElement(element)) {
newRenderer = RenderFullScreen::wrapRenderer(newRenderer, parentRenderer, &element->document());
if (!newRenderer)
return;
}
// Note: Adding newRenderer instead of renderer(). renderer() may be a child of newRenderer.
parentRenderer->addChild(newRenderer, nextRenderer);
}
示例12: didAttachRenderers
void PseudoElement::didAttachRenderers()
{
RenderObject* renderer = this->renderer();
if (!renderer || !renderer->style()->regionThread().isEmpty())
return;
RenderStyle* style = renderer->style();
ASSERT(style->contentData());
for (const ContentData* content = style->contentData(); content; content = content->next()) {
RenderObject* child = content->createRenderer(document(), style);
if (renderer->isChildAllowed(child, style)) {
renderer->addChild(child);
if (child->isQuote())
toRenderQuote(child)->attachQuote();
} else
child->destroy();
}
}
示例13: updateBeforeAfterContent
void RenderObjectChildList::updateBeforeAfterContent(RenderObject* owner, PseudoId type, const RenderObject* styledObject)
{
// Double check that the document did in fact use generated content rules. Otherwise we should not have been called.
ASSERT(owner->document()->usesBeforeAfterRules());
// In CSS2, before/after pseudo-content cannot nest. Check this first.
if (owner->style()->styleType() == BEFORE || owner->style()->styleType() == AFTER)
return;
if (!styledObject)
styledObject = owner;
RenderStyle* pseudoElementStyle = styledObject->getCachedPseudoStyle(type);
RenderObject* child;
switch (type) {
case BEFORE:
child = beforePseudoElementRenderer(owner);
break;
case AFTER:
child = afterPseudoElementRenderer(owner);
break;
default:
ASSERT_NOT_REACHED();
return;
}
// Whether or not we currently have generated content attached.
bool oldContentPresent = child;
// Whether or not we now want generated content.
bool newContentWanted = pseudoElementStyle && pseudoElementStyle->display() != NONE;
// For <q><p/></q>, if this object is the inline continuation of the <q>, we only want to generate
// :after content and not :before content.
if (newContentWanted && type == BEFORE && owner->isElementContinuation())
newContentWanted = false;
// Similarly, if we're the beginning of a <q>, and there's an inline continuation for our object,
// then we don't generate the :after content.
if (newContentWanted && type == AFTER && owner->virtualContinuation())
newContentWanted = false;
// If we don't want generated content any longer, or if we have generated content, but it's no longer
// identical to the new content data we want to build render objects for, then we nuke all
// of the old generated content.
if (oldContentPresent && (!newContentWanted || Node::diff(child->style(), pseudoElementStyle, owner->document()) == Node::Detach)) {
// Nuke the child.
if (child->style()->styleType() == type) {
oldContentPresent = false;
child->destroy();
child = (type == BEFORE) ? owner->virtualChildren()->firstChild() : owner->virtualChildren()->lastChild();
}
}
// If we have no pseudo-element style or if the pseudo-element style's display type is NONE, then we
// have no generated content and can now return.
if (!newContentWanted)
return;
if (owner->isRenderInline() && !pseudoElementStyle->isDisplayInlineType() && !pseudoElementStyle->isFloating() &&
!(pseudoElementStyle->position() == AbsolutePosition || pseudoElementStyle->position() == FixedPosition))
// According to the CSS2 spec (the end of section 12.1), the only allowed
// display values for the pseudo style are NONE and INLINE for inline flows.
// FIXME: CSS2.1 lifted this restriction, but block display types will crash.
// For now we at least relax the restriction to allow all inline types like inline-block
// and inline-table.
pseudoElementStyle->setDisplay(INLINE);
if (oldContentPresent) {
updateBeforeAfterStyle(child, type, pseudoElementStyle);
return; // We've updated the generated content. That's all we needed to do.
}
RenderObject* insertBefore = (type == BEFORE) ? owner->virtualChildren()->firstChild() : 0;
if (insertBefore && insertBefore->isAnonymousBlock() && insertBefore->childrenInline() && !insertBefore->isEmpty()) {
// We are going to add the "before" element. We have to check whether the "insertBefore" element
// is an anonymous block with inline children. If it is, then we should insert the "before" element
// before the first inline child of the anonymous block, otherwise we will end up with the "before"
// element in a different block. We do this only when the anonymous block has children, otherwise
// we end up with the before element in a wrong block.
insertBefore = insertBefore->firstChild();
}
// Nothing goes before the intruded run-in, not even generated content.
if (insertBefore && insertBefore->isRunIn() && owner->isRenderBlock()
&& toRenderBlock(owner)->runInIsPlacedIntoSiblingBlock(insertBefore))
insertBefore = insertBefore->nextSibling();
// Generated content consists of a single container that houses multiple children (specified
// by the content property). This generated content container gets the pseudo-element style set on it.
RenderObject* generatedContentContainer = 0;
// Walk our list of generated content and create render objects for each.
for (const ContentData* content = pseudoElementStyle->contentData(); content; content = content->next()) {
RenderObject* renderer = createRendererForBeforeAfterContent(owner, content, pseudoElementStyle);
if (renderer) {
if (!generatedContentContainer) {
// Make a generated box that might be any display type now that we are able to drill down into children
// to find the original content properly.
//.........这里部分代码省略.........