Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2574773002: Migrate WTF::Vector::append() to ::push_back() [part 4 of N] (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 5101 matching lines...) Expand 10 before | Expand all | Expand 10 after
5112 if (isHTMLScriptElement(script)) 5112 if (isHTMLScriptElement(script))
5113 scriptElement.setHTMLScriptElement(toHTMLScriptElement(script)); 5113 scriptElement.setHTMLScriptElement(toHTMLScriptElement(script));
5114 else if (isSVGScriptElement(script)) 5114 else if (isSVGScriptElement(script))
5115 scriptElement.setSVGScriptElement(toSVGScriptElement(script)); 5115 scriptElement.setSVGScriptElement(toSVGScriptElement(script));
5116 } 5116 }
5117 } 5117 }
5118 5118
5119 void Document::pushCurrentScript(Element* newCurrentScript) { 5119 void Document::pushCurrentScript(Element* newCurrentScript) {
5120 DCHECK(isHTMLScriptElement(newCurrentScript) || 5120 DCHECK(isHTMLScriptElement(newCurrentScript) ||
5121 isSVGScriptElement(newCurrentScript)); 5121 isSVGScriptElement(newCurrentScript));
5122 m_currentScriptStack.append(newCurrentScript); 5122 m_currentScriptStack.push_back(newCurrentScript);
5123 } 5123 }
5124 5124
5125 void Document::popCurrentScript() { 5125 void Document::popCurrentScript() {
5126 DCHECK(!m_currentScriptStack.isEmpty()); 5126 DCHECK(!m_currentScriptStack.isEmpty());
5127 m_currentScriptStack.pop_back(); 5127 m_currentScriptStack.pop_back();
5128 } 5128 }
5129 5129
5130 void Document::setTransformSource(std::unique_ptr<TransformSource> source) { 5130 void Document::setTransformSource(std::unique_ptr<TransformSource> source) {
5131 m_transformSource = std::move(source); 5131 m_transformSource = std::move(source);
5132 } 5132 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
5358 linkElement = Traversal<HTMLLinkElement>::nextSibling(*linkElement)) { 5358 linkElement = Traversal<HTMLLinkElement>::nextSibling(*linkElement)) {
5359 if (!(linkElement->getIconType() & iconTypesMask)) 5359 if (!(linkElement->getIconType() & iconTypesMask))
5360 continue; 5360 continue;
5361 if (linkElement->href().isEmpty()) 5361 if (linkElement->href().isEmpty())
5362 continue; 5362 continue;
5363 5363
5364 IconURL newURL(linkElement->href(), linkElement->iconSizes(), 5364 IconURL newURL(linkElement->href(), linkElement->iconSizes(),
5365 linkElement->type(), linkElement->getIconType()); 5365 linkElement->type(), linkElement->getIconType());
5366 if (linkElement->getIconType() == Favicon) { 5366 if (linkElement->getIconType() == Favicon) {
5367 if (firstFavicon.m_iconType != InvalidIcon) 5367 if (firstFavicon.m_iconType != InvalidIcon)
5368 secondaryIcons.append(firstFavicon); 5368 secondaryIcons.push_back(firstFavicon);
5369 firstFavicon = newURL; 5369 firstFavicon = newURL;
5370 } else if (linkElement->getIconType() == TouchIcon) { 5370 } else if (linkElement->getIconType() == TouchIcon) {
5371 if (firstTouchIcon.m_iconType != InvalidIcon) 5371 if (firstTouchIcon.m_iconType != InvalidIcon)
5372 secondaryIcons.append(firstTouchIcon); 5372 secondaryIcons.push_back(firstTouchIcon);
5373 firstTouchIcon = newURL; 5373 firstTouchIcon = newURL;
5374 } else if (linkElement->getIconType() == TouchPrecomposedIcon) { 5374 } else if (linkElement->getIconType() == TouchPrecomposedIcon) {
5375 if (firstTouchPrecomposedIcon.m_iconType != InvalidIcon) 5375 if (firstTouchPrecomposedIcon.m_iconType != InvalidIcon)
5376 secondaryIcons.append(firstTouchPrecomposedIcon); 5376 secondaryIcons.push_back(firstTouchPrecomposedIcon);
5377 firstTouchPrecomposedIcon = newURL; 5377 firstTouchPrecomposedIcon = newURL;
5378 } else { 5378 } else {
5379 NOTREACHED(); 5379 NOTREACHED();
5380 } 5380 }
5381 } 5381 }
5382 5382
5383 Vector<IconURL> iconURLs; 5383 Vector<IconURL> iconURLs;
5384 if (firstFavicon.m_iconType != InvalidIcon) 5384 if (firstFavicon.m_iconType != InvalidIcon)
5385 iconURLs.append(firstFavicon); 5385 iconURLs.push_back(firstFavicon);
5386 else if (m_url.protocolIsInHTTPFamily() && iconTypesMask & Favicon) 5386 else if (m_url.protocolIsInHTTPFamily() && iconTypesMask & Favicon)
5387 iconURLs.append(IconURL::defaultFavicon(m_url)); 5387 iconURLs.push_back(IconURL::defaultFavicon(m_url));
5388 5388
5389 if (firstTouchIcon.m_iconType != InvalidIcon) 5389 if (firstTouchIcon.m_iconType != InvalidIcon)
5390 iconURLs.append(firstTouchIcon); 5390 iconURLs.push_back(firstTouchIcon);
5391 if (firstTouchPrecomposedIcon.m_iconType != InvalidIcon) 5391 if (firstTouchPrecomposedIcon.m_iconType != InvalidIcon)
5392 iconURLs.append(firstTouchPrecomposedIcon); 5392 iconURLs.push_back(firstTouchPrecomposedIcon);
5393 for (int i = secondaryIcons.size() - 1; i >= 0; --i) 5393 for (int i = secondaryIcons.size() - 1; i >= 0; --i)
5394 iconURLs.append(secondaryIcons[i]); 5394 iconURLs.push_back(secondaryIcons[i]);
5395 return iconURLs; 5395 return iconURLs;
5396 } 5396 }
5397 5397
5398 Color Document::themeColor() const { 5398 Color Document::themeColor() const {
5399 auto rootElement = documentElement(); 5399 auto rootElement = documentElement();
5400 if (!rootElement) 5400 if (!rootElement)
5401 return Color(); 5401 return Color();
5402 for (HTMLMetaElement& metaElement : 5402 for (HTMLMetaElement& metaElement :
5403 Traversal<HTMLMetaElement>::descendantsOf(*rootElement)) { 5403 Traversal<HTMLMetaElement>::descendantsOf(*rootElement)) {
5404 Color color = Color::transparent; 5404 Color color = Color::transparent;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
5806 void Document::addToTopLayer(Element* element, const Element* before) { 5806 void Document::addToTopLayer(Element* element, const Element* before) {
5807 if (element->isInTopLayer()) 5807 if (element->isInTopLayer())
5808 return; 5808 return;
5809 5809
5810 DCHECK(!m_topLayerElements.contains(element)); 5810 DCHECK(!m_topLayerElements.contains(element));
5811 DCHECK(!before || m_topLayerElements.contains(before)); 5811 DCHECK(!before || m_topLayerElements.contains(before));
5812 if (before) { 5812 if (before) {
5813 size_t beforePosition = m_topLayerElements.find(before); 5813 size_t beforePosition = m_topLayerElements.find(before);
5814 m_topLayerElements.insert(beforePosition, element); 5814 m_topLayerElements.insert(beforePosition, element);
5815 } else { 5815 } else {
5816 m_topLayerElements.append(element); 5816 m_topLayerElements.push_back(element);
5817 } 5817 }
5818 element->setIsInTopLayer(true); 5818 element->setIsInTopLayer(true);
5819 } 5819 }
5820 5820
5821 void Document::removeFromTopLayer(Element* element) { 5821 void Document::removeFromTopLayer(Element* element) {
5822 if (!element->isInTopLayer()) 5822 if (!element->isInTopLayer())
5823 return; 5823 return;
5824 size_t position = m_topLayerElements.find(element); 5824 size_t position = m_topLayerElements.find(element);
5825 DCHECK_NE(position, kNotFound); 5825 DCHECK_NE(position, kNotFound);
5826 m_topLayerElements.remove(position); 5826 m_topLayerElements.remove(position);
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
6172 if (oldHoverObj != newHoverObj) { 6172 if (oldHoverObj != newHoverObj) {
6173 // If the old hovered node is not nil but it's layoutObject is, it was 6173 // If the old hovered node is not nil but it's layoutObject is, it was
6174 // probably detached as part of the :hover style (for instance by setting 6174 // probably detached as part of the :hover style (for instance by setting
6175 // display:none in the :hover pseudo-class). In this case, the old hovered 6175 // display:none in the :hover pseudo-class). In this case, the old hovered
6176 // element (and its ancestors) must be updated, to ensure it's normal style 6176 // element (and its ancestors) must be updated, to ensure it's normal style
6177 // is re-applied. 6177 // is re-applied.
6178 if (oldHoverNode && !oldHoverObj) { 6178 if (oldHoverNode && !oldHoverObj) {
6179 for (Node& node : NodeTraversal::inclusiveAncestorsOf(*oldHoverNode)) { 6179 for (Node& node : NodeTraversal::inclusiveAncestorsOf(*oldHoverNode)) {
6180 if (!mustBeInActiveChain || 6180 if (!mustBeInActiveChain ||
6181 (node.isElementNode() && toElement(node).inActiveChain())) 6181 (node.isElementNode() && toElement(node).inActiveChain()))
6182 nodesToRemoveFromChain.append(node); 6182 nodesToRemoveFromChain.push_back(node);
6183 } 6183 }
6184 } 6184 }
6185 6185
6186 // The old hover path only needs to be cleared up to (and not including) the 6186 // The old hover path only needs to be cleared up to (and not including) the
6187 // common ancestor; 6187 // common ancestor;
6188 for (LayoutObject* curr = oldHoverObj; curr && curr != ancestor; 6188 for (LayoutObject* curr = oldHoverObj; curr && curr != ancestor;
6189 curr = curr->hoverAncestor()) { 6189 curr = curr->hoverAncestor()) {
6190 if (curr->node() && !curr->isText() && 6190 if (curr->node() && !curr->isText() &&
6191 (!mustBeInActiveChain || curr->node()->inActiveChain())) 6191 (!mustBeInActiveChain || curr->node()->inActiveChain()))
6192 nodesToRemoveFromChain.append(curr->node()); 6192 nodesToRemoveFromChain.push_back(curr->node());
6193 } 6193 }
6194 6194
6195 // TODO(mustaq): The two loops above may push a single node twice into 6195 // TODO(mustaq): The two loops above may push a single node twice into
6196 // nodesToRemoveFromChain. There must be a better way. 6196 // nodesToRemoveFromChain. There must be a better way.
6197 } 6197 }
6198 6198
6199 // Now set the hover state for our new object up to the root. 6199 // Now set the hover state for our new object up to the root.
6200 for (LayoutObject* curr = newHoverObj; curr; curr = curr->hoverAncestor()) { 6200 for (LayoutObject* curr = newHoverObj; curr; curr = curr->hoverAncestor()) {
6201 if (curr->node() && !curr->isText() && 6201 if (curr->node() && !curr->isText() &&
6202 (!mustBeInActiveChain || curr->node()->inActiveChain())) 6202 (!mustBeInActiveChain || curr->node()->inActiveChain()))
6203 nodesToAddToChain.append(curr->node()); 6203 nodesToAddToChain.push_back(curr->node());
6204 } 6204 }
6205 6205
6206 size_t removeCount = nodesToRemoveFromChain.size(); 6206 size_t removeCount = nodesToRemoveFromChain.size();
6207 for (size_t i = 0; i < removeCount; ++i) { 6207 for (size_t i = 0; i < removeCount; ++i) {
6208 nodesToRemoveFromChain[i]->setHovered(false); 6208 nodesToRemoveFromChain[i]->setHovered(false);
6209 } 6209 }
6210 6210
6211 bool sawCommonAncestor = false; 6211 bool sawCommonAncestor = false;
6212 size_t addCount = nodesToAddToChain.size(); 6212 size_t addCount = nodesToAddToChain.size();
6213 for (size_t i = 0; i < addCount; ++i) { 6213 for (size_t i = 0; i < addCount; ++i) {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
6572 } 6572 }
6573 6573
6574 void showLiveDocumentInstances() { 6574 void showLiveDocumentInstances() {
6575 WeakDocumentSet& set = liveDocumentSet(); 6575 WeakDocumentSet& set = liveDocumentSet();
6576 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6576 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6577 for (Document* document : set) 6577 for (Document* document : set)
6578 fprintf(stderr, "- Document %p URL: %s\n", document, 6578 fprintf(stderr, "- Document %p URL: %s\n", document,
6579 document->url().getString().utf8().data()); 6579 document->url().getString().utf8().data());
6580 } 6580 }
6581 #endif 6581 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698