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

Unified Diff: Source/core/page/PageSerializer.cpp

Issue 190953009: Use new is*Element() helper functions in page/ code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/page/FocusController.cpp ('k') | Source/core/page/SpatialNavigation.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/PageSerializer.cpp
diff --git a/Source/core/page/PageSerializer.cpp b/Source/core/page/PageSerializer.cpp
index 6cff82f3532b51622b593c30c1776647c8eedd4c..e0d33427e37c32458e7c29a82e17f749ffe84514 100644
--- a/Source/core/page/PageSerializer.cpp
+++ b/Source/core/page/PageSerializer.cpp
@@ -53,6 +53,7 @@
#include "core/html/HTMLImageElement.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLLinkElement.h"
+#include "core/html/HTMLMetaElement.h"
#include "core/html/HTMLStyleElement.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/page/Page.h"
@@ -70,12 +71,10 @@ namespace WebCore {
static bool isCharsetSpecifyingNode(const Node& node)
{
- if (!node.isHTMLElement())
+ if (!isHTMLMetaElement(node))
return false;
- const HTMLElement& element = toHTMLElement(node);
- if (!element.hasTagName(HTMLNames::metaTag))
- return false;
+ const HTMLMetaElement& element = toHTMLMetaElement(node);
HTMLAttributeList attributes;
if (element.hasAttributes()) {
unsigned attributeCount = element.attributeCount();
@@ -91,13 +90,13 @@ static bool isCharsetSpecifyingNode(const Node& node)
static bool shouldIgnoreElement(const Element& element)
{
- return element.hasTagName(HTMLNames::scriptTag) || element.hasTagName(HTMLNames::noscriptTag) || isCharsetSpecifyingNode(element);
+ return isHTMLScriptElement(element) || isHTMLNoScriptElement(element) || isCharsetSpecifyingNode(element);
}
static const QualifiedName& frameOwnerURLAttributeName(const HTMLFrameOwnerElement& frameOwner)
{
// FIXME: We should support all frame owners including applets.
- return frameOwner.hasTagName(HTMLNames::objectTag) ? HTMLNames::dataAttr : HTMLNames::srcAttr;
+ return isHTMLObjectElement(frameOwner) ? HTMLNames::dataAttr : HTMLNames::srcAttr;
}
class SerializerMarkupAccumulator FINAL : public MarkupAccumulator {
@@ -139,7 +138,7 @@ void SerializerMarkupAccumulator::appendElement(StringBuilder& out, Element& ele
if (!shouldIgnoreElement(element))
MarkupAccumulator::appendElement(out, element, namespaces);
- if (element.hasTagName(HTMLNames::headTag)) {
+ if (isHTMLHeadElement(element)) {
out.append("<meta charset=\"");
out.append(m_document.charset());
out.append("\">");
@@ -225,26 +224,26 @@ void PageSerializer::serializeFrame(LocalFrame* frame)
if (element.isStyledElement())
retrieveResourcesForProperties(element.inlineStyle(), document);
- if (element.hasTagName(HTMLNames::imgTag)) {
+ if (isHTMLImageElement(element)) {
HTMLImageElement& imageElement = toHTMLImageElement(element);
KURL url = document.completeURL(imageElement.getAttribute(HTMLNames::srcAttr));
ImageResource* cachedImage = imageElement.cachedImage();
addImageToResources(cachedImage, imageElement.renderer(), url);
- } else if (element.hasTagName(HTMLNames::inputTag)) {
+ } else if (isHTMLInputElement(element)) {
HTMLInputElement& inputElement = toHTMLInputElement(element);
if (inputElement.isImageButton() && inputElement.hasImageLoader()) {
KURL url = inputElement.src();
ImageResource* cachedImage = inputElement.imageLoader()->image();
addImageToResources(cachedImage, inputElement.renderer(), url);
}
- } else if (element.hasTagName(HTMLNames::linkTag)) {
+ } else if (isHTMLLinkElement(element)) {
HTMLLinkElement& linkElement = toHTMLLinkElement(element);
if (CSSStyleSheet* sheet = linkElement.sheet()) {
KURL url = document.completeURL(linkElement.getAttribute(HTMLNames::hrefAttr));
serializeCSSStyleSheet(sheet, url);
ASSERT(m_resourceURLs.contains(url));
}
- } else if (element.hasTagName(HTMLNames::styleTag)) {
+ } else if (isHTMLStyleElement(element)) {
HTMLStyleElement& styleElement = toHTMLStyleElement(element);
if (CSSStyleSheet* sheet = styleElement.sheet())
serializeCSSStyleSheet(sheet, KURL());
« no previous file with comments | « Source/core/page/FocusController.cpp ('k') | Source/core/page/SpatialNavigation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698