}
// These spans were added by us. If empty after font size changes, they can be removed.
- WillBeHeapVector<RefPtrWillBeMember<HTMLElement> > unstyledSpans;
+ WillBeHeapVector<RefPtrWillBeMember<HTMLElement>> unstyledSpans;
- Node* lastStyledNode = 0;
+ Node* lastStyledNode = nullptr;
for (Node* node = startNode; node != beyondEnd; node = NodeTraversal::next(*node)) {
ASSERT(node);
RefPtrWillBeRawPtr<HTMLElement> element = nullptr;
}
}
- size_t size = unstyledSpans.size();
- for (size_t i = 0; i < size; ++i)
- removeNodePreservingChildren(unstyledSpans[i].get());
+ for (const auto& unstyledSpan : unstyledSpans)
+ removeNodePreservingChildren(unstyledSpan.get());
}
static ContainerNode* dummySpanAncestorForNode(const Node* node)
if (!block)
return 0;
- ContainerNode* highestAncestorWithUnicodeBidi = 0;
- ContainerNode* nextHighestAncestorWithUnicodeBidi = 0;
+ ContainerNode* highestAncestorWithUnicodeBidi = nullptr;
+ ContainerNode* nextHighestAncestorWithUnicodeBidi = nullptr;
int highestAncestorUnicodeBidi = 0;
for (ContainerNode* n = node->parentNode(); n != block; n = n->parentNode()) {
int unicodeBidi = getIdentifierValue(CSSComputedStyleDeclaration::create(n).get(), CSSPropertyUnicodeBidi);
splitTextAtStart(start, end);
start = startPosition();
end = endPosition();
+ if (start.isNull() || end.isNull())
+ return;
startDummySpanAncestor = dummySpanAncestorForNode(start.deprecatedNode());
}
splitTextAtEnd(start, end);
start = startPosition();
end = endPosition();
+ if (start.isNull() || end.isNull())
+ return;
endDummySpanAncestor = dummySpanAncestorForNode(end.deprecatedNode());
}
runs.append(InlineRunToApplyStyle(runStart, runEnd, pastEndNode));
}
- for (size_t i = 0; i < runs.size(); i++) {
- removeConflictingInlineStyleFromRun(style, runs[i].start, runs[i].end, runs[i].pastEndNode);
- if (runs[i].startAndEndAreStillInDocument())
- runs[i].positionForStyleComputation = positionToComputeInlineStyleChange(runs[i].start, runs[i].dummyElement);
+ for (auto& run : runs) {
+ removeConflictingInlineStyleFromRun(style, run.start, run.end, run.pastEndNode);
+ if (run.startAndEndAreStillInDocument())
+ run.positionForStyleComputation = positionToComputeInlineStyleChange(run.start, run.dummyElement);
}
document().updateLayoutIgnorePendingStylesheets();
- for (size_t i = 0; i < runs.size(); i++) {
- if (runs[i].positionForStyleComputation.isNotNull())
- runs[i].change = StyleChange(style, runs[i].positionForStyleComputation);
+ for (auto& run : runs) {
+ if (run.positionForStyleComputation.isNotNull())
+ run.change = StyleChange(style, run.positionForStyleComputation);
}
- for (size_t i = 0; i < runs.size(); i++) {
- InlineRunToApplyStyle run = runs[i];
+ for (auto& run : runs) {
if (run.dummyElement)
removeNode(run.dummyElement);
if (run.startAndEndAreStillInDocument())
extractedStyle, attributes, mode == RemoveAlways ? EditingStyle::ExtractMatchingStyle : EditingStyle::DoNotExtractMatchingStyle))
return false;
- for (size_t i = 0; i < attributes.size(); i++)
- removeElementAttribute(element, attributes[i]);
+ for (const auto& attribute : attributes)
+ removeElementAttribute(element, attribute);
if (isEmptyFontTag(element) || isSpanWithoutAttributesOrUnstyledStyleSpan(element))
removeNodePreservingChildren(element);
return false;
// FIXME: We should use a mass-removal function here but we don't have an undoable one yet.
- for (size_t i = 0; i < properties.size(); i++)
- removeCSSProperty(element, properties[i]);
+ for (const auto& property : properties)
+ removeCSSProperty(element, property);
if (isSpanWithoutAttributesOrUnstyledStyleSpan(element))
removeNodePreservingChildren(element);
if (!node)
return 0;
- HTMLElement* result = 0;
+ HTMLElement* result = nullptr;
Node* unsplittableElement = unsplittableElementForPosition(firstPositionInOrBeforeNode(node));
for (Node *n = node; n; n = n->parentNode()) {
RefPtrWillBeRawPtr<Node> current = highestAncestor;
// Along the way, styled elements that contain targetNode are removed and accumulated into elementsToPushDown.
// Each child of the removed element, exclusing ancestors of targetNode, is then wrapped by clones of elements in elementsToPushDown.
- WillBeHeapVector<RefPtrWillBeMember<Element> > elementsToPushDown;
+ WillBeHeapVector<RefPtrWillBeMember<Element>> elementsToPushDown;
while (current && current != targetNode && current->contains(targetNode)) {
NodeVector currentChildren;
getChildNodes(toContainerNode(*current), currentChildren);
// The inner loop will go through children on each level
// FIXME: we should aggregate inline child elements together so that we don't wrap each child separately.
- for (size_t i = 0; i < currentChildren.size(); ++i) {
- Node* child = currentChildren[i].get();
+ for (const auto& currentChild : currentChildren) {
+ Node* child = currentChild.get();
if (!child->parentNode())
continue;
if (!child->contains(targetNode) && elementsToPushDown.size()) {
- for (size_t i = 0; i < elementsToPushDown.size(); i++) {
- RefPtrWillBeRawPtr<Element> wrapper = elementsToPushDown[i]->cloneElementWithoutChildren();
+ for (const auto& element : elementsToPushDown) {
+ RefPtrWillBeRawPtr<Element> wrapper = element->cloneElementWithoutChildren();
wrapper->removeAttribute(styleAttr);
surroundNodeRangeWithElement(child, child, wrapper);
}
bool ApplyStyleCommand::isValidCaretPositionInTextNode(const Position& position)
{
+ ASSERT(position.isNotNull());
+
Node* node = position.containerNode();
if (position.anchorType() != Position::PositionIsOffsetInAnchor || !node->isTextNode())
return false;
ASSERT(endNode->inDocument());
// Find appropriate font and span elements top-down.
- HTMLFontElement* fontContainer = 0;
- HTMLElement* styleContainer = 0;
+ HTMLFontElement* fontContainer = nullptr;
+ HTMLElement* styleContainer = nullptr;
for (Node* container = startNode.get(); container && startNode == endNode; container = container->firstChild()) {
if (isHTMLFontElement(*container))
fontContainer = toHTMLFontElement(container);
Position newStart = start;
Position newEnd = end;
- WillBeHeapVector<RefPtrWillBeMember<Text> > textNodes;
+ WillBeHeapVector<RefPtrWillBeMember<Text>> textNodes;
for (Node* curr = node->firstChild(); curr; curr = curr->nextSibling()) {
if (!curr->isTextNode())
continue;
textNodes.append(toText(curr));
}
- for (size_t i = 0; i < textNodes.size(); ++i) {
- Text* childText = textNodes[i].get();
+ for (const auto& textNode : textNodes) {
+ Text* childText = textNode.get();
Node* next = childText->nextSibling();
if (!next || !next->isTextNode())
continue;