本文整理汇总了C++中LayoutObject::generatingNode方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutObject::generatingNode方法的具体用法?C++ LayoutObject::generatingNode怎么用?C++ LayoutObject::generatingNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutObject
的用法示例。
在下文中一共展示了LayoutObject::generatingNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: planCounter
static bool planCounter(LayoutObject& object, const AtomicString& identifier, bool& isReset, int& value)
{
// Real text nodes don't have their own style so they can't have counters.
// We can't even look at their styles or we'll see extra resets and increments!
if (object.isText() && !object.isBR())
return false;
Node* generatingNode = object.generatingNode();
// We must have a generating node or else we cannot have a counter.
if (!generatingNode)
return false;
const ComputedStyle& style = object.styleRef();
switch (style.styleType()) {
case NOPSEUDO:
// Sometimes nodes have more then one layoutObject. Only the first one gets the counter
// LayoutTests/http/tests/css/counter-crash.html
if (generatingNode->layoutObject() != &object)
return false;
break;
case BEFORE:
case AFTER:
break;
default:
return false; // Counters are forbidden from all other pseudo elements.
}
const CounterDirectives directives = style.getCounterDirectives(identifier);
if (directives.isDefined()) {
value = directives.combinedValue();
isReset = directives.isReset();
return true;
}
if (identifier == "list-item") {
if (object.isListItem()) {
if (toLayoutListItem(object).hasExplicitValue()) {
value = toLayoutListItem(object).explicitValue();
isReset = true;
return true;
}
value = 1;
isReset = false;
return true;
}
if (Node* e = object.node()) {
if (isHTMLOListElement(*e)) {
value = toHTMLOListElement(e)->start();
isReset = true;
return true;
}
if (isHTMLUListElement(*e) || isHTMLMenuElement(*e) || isHTMLDirectoryElement(*e)) {
value = 0;
isReset = true;
return true;
}
}
}
return false;
}
示例2: layoutObjectStyleChanged
void LayoutCounter::layoutObjectStyleChanged(LayoutObject& layoutObject, const ComputedStyle* oldStyle, const ComputedStyle& newStyle)
{
Node* node = layoutObject.generatingNode();
if (!node || node->needsAttach())
return; // cannot have generated content or if it can have, it will be handled during attaching
const CounterDirectiveMap* oldCounterDirectives = oldStyle ? oldStyle->counterDirectives() : 0;
const CounterDirectiveMap* newCounterDirectives = newStyle.counterDirectives();
if (oldCounterDirectives) {
if (newCounterDirectives) {
CounterDirectiveMap::const_iterator newMapEnd = newCounterDirectives->end();
CounterDirectiveMap::const_iterator oldMapEnd = oldCounterDirectives->end();
for (CounterDirectiveMap::const_iterator it = newCounterDirectives->begin(); it != newMapEnd; ++it) {
CounterDirectiveMap::const_iterator oldMapIt = oldCounterDirectives->find(it->key);
if (oldMapIt != oldMapEnd) {
if (oldMapIt->value == it->value)
continue;
LayoutCounter::destroyCounterNode(layoutObject, it->key);
}
// We must create this node here, because the changed node may be a node with no display such as
// as those created by the increment or reset directives and the re-layout that will happen will
// not catch the change if the node had no children.
makeCounterNode(layoutObject, it->key, false);
}
// Destroying old counters that do not exist in the new counterDirective map.
for (CounterDirectiveMap::const_iterator it = oldCounterDirectives->begin(); it !=oldMapEnd; ++it) {
if (!newCounterDirectives->contains(it->key))
LayoutCounter::destroyCounterNode(layoutObject, it->key);
}
} else {
if (layoutObject.hasCounterNodeMap())
LayoutCounter::destroyCounterNodes(layoutObject);
}
} else if (newCounterDirectives) {
if (layoutObject.hasCounterNodeMap())
LayoutCounter::destroyCounterNodes(layoutObject);
CounterDirectiveMap::const_iterator newMapEnd = newCounterDirectives->end();
for (CounterDirectiveMap::const_iterator it = newCounterDirectives->begin(); it != newMapEnd; ++it) {
// We must create this node here, because the added node may be a node with no display such as
// as those created by the increment or reset directives and the re-layout that will happen will
// not catch the change if the node had no children.
makeCounterNode(layoutObject, it->key, false);
}
}
}