本文整理汇总了C++中RenderObject::hasCounterNodeMap方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderObject::hasCounterNodeMap方法的具体用法?C++ RenderObject::hasCounterNodeMap怎么用?C++ RenderObject::hasCounterNodeMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderObject
的用法示例。
在下文中一共展示了RenderObject::hasCounterNodeMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateCounters
static void updateCounters(RenderObject& renderer)
{
ASSERT(renderer.style());
const CounterDirectiveMap* directiveMap = renderer.style()->counterDirectives();
if (!directiveMap)
return;
CounterDirectiveMap::const_iterator end = directiveMap->end();
if (!renderer.hasCounterNodeMap()) {
for (CounterDirectiveMap::const_iterator it = directiveMap->begin(); it != end; ++it)
makeCounterNode(renderer, it->key, false);
return;
}
CounterMap* counterMap = counterMaps().get(&renderer);
ASSERT(counterMap);
for (CounterDirectiveMap::const_iterator it = directiveMap->begin(); it != end; ++it) {
RefPtr<CounterNode> node = counterMap->get(it->key);
if (!node) {
makeCounterNode(renderer, it->key, false);
continue;
}
RefPtr<CounterNode> newParent = nullptr;
RefPtr<CounterNode> newPreviousSibling = nullptr;
findPlaceForCounter(renderer, it->key, node->hasResetType(), newParent, newPreviousSibling);
if (node != counterMap->get(it->key))
continue;
CounterNode* parent = node->parent();
if (newParent == parent && newPreviousSibling == node->previousSibling())
continue;
if (parent)
parent->removeChild(node.get());
if (newParent)
newParent->insertAfter(node.get(), newPreviousSibling.get(), it->key);
}
}
示例2: makeCounterNode
static CounterNode* makeCounterNode(RenderObject* object, const AtomicString& identifier, bool alwaysCreateCounter)
{
ASSERT(object);
if (object->hasCounterNodeMap()) {
if (CounterMap* nodeMap = counterMaps().get(object)) {
if (CounterNode* node = nodeMap->get(identifier).get())
return node;
}
}
bool isReset = false;
int value = 0;
if (!planCounter(object, identifier, isReset, value) && !alwaysCreateCounter)
return 0;
RefPtr<CounterNode> newParent = 0;
RefPtr<CounterNode> newPreviousSibling = 0;
RefPtr<CounterNode> newNode = CounterNode::create(object, isReset, value);
if (findPlaceForCounter(object, identifier, isReset, newParent, newPreviousSibling))
newParent->insertAfter(newNode.get(), newPreviousSibling.get(), identifier);
CounterMap* nodeMap;
if (object->hasCounterNodeMap())
nodeMap = counterMaps().get(object);
else {
nodeMap = new CounterMap;
counterMaps().set(object, adoptPtr(nodeMap));
object->setHasCounterNodeMap(true);
}
nodeMap->set(identifier, newNode);
if (newNode->parent())
return newNode.get();
// Checking if some nodes that were previously counter tree root nodes
// should become children of this node now.
CounterMaps& maps = counterMaps();
Element* stayWithin = parentElement(object);
bool skipDescendants;
for (RenderObject* currentRenderer = nextInPreOrder(object, stayWithin); currentRenderer; currentRenderer = nextInPreOrder(currentRenderer, stayWithin, skipDescendants)) {
skipDescendants = false;
if (!currentRenderer->hasCounterNodeMap())
continue;
CounterNode* currentCounter = maps.get(currentRenderer)->get(identifier).get();
if (!currentCounter)
continue;
skipDescendants = true;
if (currentCounter->parent())
continue;
if (stayWithin == parentElement(currentRenderer) && currentCounter->hasResetType())
break;
newNode->insertAfter(currentCounter, newNode->lastChild(), identifier);
}
return newNode.get();
}
示例3: rendererStyleChanged
void RenderCounter::rendererStyleChanged(RenderObject& renderer, const RenderStyle* oldStyle, const RenderStyle* newStyle)
{
Node* node = renderer.generatingNode();
if (!node || node->needsAttach())
return; // cannot have generated content or if it can have, it will be handled during attaching
const CounterDirectiveMap* newCounterDirectives;
const CounterDirectiveMap* oldCounterDirectives;
if (oldStyle && (oldCounterDirectives = oldStyle->counterDirectives())) {
if (newStyle && (newCounterDirectives = newStyle->counterDirectives())) {
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;
RenderCounter::destroyCounterNode(renderer, 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(renderer, 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))
RenderCounter::destroyCounterNode(renderer, it->key);
}
} else {
if (renderer.hasCounterNodeMap())
RenderCounter::destroyCounterNodes(renderer);
}
} else if (newStyle && (newCounterDirectives = newStyle->counterDirectives())) {
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(renderer, it->key, false);
}
}
}