Commit 3c8dd144 authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Use range-based for loops for traversing <link> elements.

Change-Id: I40fc2ff294e2f8c66380d49f0d350e7eba3c7bc5
Reviewed-on: https://chromium-review.googlesource.com/762949Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515486}
parent d64c9120
......@@ -5920,32 +5920,30 @@ Color Document::ThemeColor() const {
return Color();
}
template <typename MatchFn>
static HTMLLinkElement* GetLinkElement(const Document* doc, MatchFn match_fn) {
static HTMLLinkElement* GetLinkElement(const Document* doc,
bool (*match_fn)(HTMLLinkElement&)) {
HTMLHeadElement* head = doc->head();
if (!head)
return nullptr;
// The first matching link element is used. Others are ignored.
for (HTMLLinkElement* link_element =
Traversal<HTMLLinkElement>::FirstChild(*head);
link_element;
link_element = Traversal<HTMLLinkElement>::NextSibling(*link_element)) {
for (HTMLLinkElement& link_element :
Traversal<HTMLLinkElement>::ChildrenOf(*head)) {
if (match_fn(link_element))
return link_element;
return &link_element;
}
return nullptr;
}
HTMLLinkElement* Document::LinkManifest() const {
return GetLinkElement(this, [](HTMLLinkElement* link_element) {
return link_element->RelAttribute().IsManifest();
return GetLinkElement(this, [](HTMLLinkElement& link_element) {
return link_element.RelAttribute().IsManifest();
});
}
HTMLLinkElement* Document::LinkCanonical() const {
return GetLinkElement(this, [](HTMLLinkElement* link_element) {
return link_element->RelAttribute().IsCanonical();
return GetLinkElement(this, [](HTMLLinkElement& link_element) {
return link_element.RelAttribute().IsCanonical();
});
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment