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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameSerializer.cpp

Issue 2393313002: reflow comments in core/frame (Closed)
Patch Set: tweak Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 const Attribute& attribute) { 150 const Attribute& attribute) {
151 return m_delegate.shouldIgnoreAttribute(attribute); 151 return m_delegate.shouldIgnoreAttribute(attribute);
152 } 152 }
153 153
154 void SerializerMarkupAccumulator::appendElement(StringBuilder& result, 154 void SerializerMarkupAccumulator::appendElement(StringBuilder& result,
155 Element& element, 155 Element& element,
156 Namespaces* namespaces) { 156 Namespaces* namespaces) {
157 if (!shouldIgnoreElement(element)) 157 if (!shouldIgnoreElement(element))
158 MarkupAccumulator::appendElement(result, element, namespaces); 158 MarkupAccumulator::appendElement(result, element, namespaces);
159 159
160 // TODO(tiger): Refactor MarkupAccumulator so it is easier to append an elemen t like this, without special cases for XHTML 160 // TODO(tiger): Refactor MarkupAccumulator so it is easier to append an
161 // element like this, without special cases for XHTML
161 if (isHTMLHeadElement(element)) { 162 if (isHTMLHeadElement(element)) {
162 result.append("<meta http-equiv=\"Content-Type\" content=\""); 163 result.append("<meta http-equiv=\"Content-Type\" content=\"");
163 appendAttributeValue(result, m_document->suggestedMIMEType()); 164 appendAttributeValue(result, m_document->suggestedMIMEType());
164 result.append("; charset="); 165 result.append("; charset=");
165 appendAttributeValue(result, m_document->characterSet()); 166 appendAttributeValue(result, m_document->characterSet());
166 if (m_document->isXHTMLDocument()) 167 if (m_document->isXHTMLDocument())
167 result.append("\" />"); 168 result.append("\" />");
168 else 169 else
169 result.append("\">"); 170 result.append("\">");
170 } 171 }
171 172
172 // FIXME: For object (plugins) tags and video tag we could replace them by an image of their current contents. 173 // FIXME: For object (plugins) tags and video tag we could replace them by an
174 // image of their current contents.
173 } 175 }
174 176
175 void SerializerMarkupAccumulator::appendAttribute(StringBuilder& out, 177 void SerializerMarkupAccumulator::appendAttribute(StringBuilder& out,
176 const Element& element, 178 const Element& element,
177 const Attribute& attribute, 179 const Attribute& attribute,
178 Namespaces* namespaces) { 180 Namespaces* namespaces) {
179 // Check if link rewriting can affect the attribute. 181 // Check if link rewriting can affect the attribute.
180 bool isLinkAttribute = element.hasLegalLinkAttribute(attribute.name()); 182 bool isLinkAttribute = element.hasLegalLinkAttribute(attribute.name());
181 bool isSrcDocAttribute = isHTMLFrameElementBase(element) && 183 bool isSrcDocAttribute = isHTMLFrameElementBase(element) &&
182 attribute.name() == HTMLNames::srcdocAttr; 184 attribute.name() == HTMLNames::srcdocAttr;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 void SerializerMarkupAccumulator::appendRewrittenAttribute( 228 void SerializerMarkupAccumulator::appendRewrittenAttribute(
227 StringBuilder& out, 229 StringBuilder& out,
228 const Element& element, 230 const Element& element,
229 const String& attributeName, 231 const String& attributeName,
230 const String& attributeValue) { 232 const String& attributeValue) {
231 if (m_elementsWithRewrittenLinks.contains(&element)) 233 if (m_elementsWithRewrittenLinks.contains(&element))
232 return; 234 return;
233 m_elementsWithRewrittenLinks.add(&element); 235 m_elementsWithRewrittenLinks.add(&element);
234 236
235 // Append the rewritten attribute. 237 // Append the rewritten attribute.
236 // TODO(tiger): Refactor MarkupAccumulator so it is easier to append an attrib ute like this. 238 // TODO(tiger): Refactor MarkupAccumulator so it is easier to append an
239 // attribute like this.
237 out.append(' '); 240 out.append(' ');
238 out.append(attributeName); 241 out.append(attributeName);
239 out.append("=\""); 242 out.append("=\"");
240 appendAttributeValue(out, attributeValue); 243 appendAttributeValue(out, attributeValue);
241 out.append("\""); 244 out.append("\"");
242 } 245 }
243 246
244 // TODO(tiger): Right now there is no support for rewriting URLs inside CSS 247 // TODO(tiger): Right now there is no support for rewriting URLs inside CSS
245 // documents which leads to bugs like <https://crbug.com/251898>. Not being 248 // documents which leads to bugs like <https://crbug.com/251898>. Not being
246 // able to rewrite URLs inside CSS documents means that resources imported from 249 // able to rewrite URLs inside CSS documents means that resources imported from
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 url, document.suggestedMIMEType(), 286 url, document.suggestedMIMEType(),
284 SharedBuffer::create(frameHTML.data(), frameHTML.length()))); 287 SharedBuffer::create(frameHTML.data(), frameHTML.length())));
285 } 288 }
286 289
287 for (Node* node : serializedNodes) { 290 for (Node* node : serializedNodes) {
288 ASSERT(node); 291 ASSERT(node);
289 if (!node->isElementNode()) 292 if (!node->isElementNode())
290 continue; 293 continue;
291 294
292 Element& element = toElement(*node); 295 Element& element = toElement(*node);
293 // We have to process in-line style as it might contain some resources (typi cally background images). 296 // We have to process in-line style as it might contain some resources
297 // (typically background images).
294 if (element.isStyledElement()) { 298 if (element.isStyledElement()) {
295 retrieveResourcesForProperties(element.inlineStyle(), document); 299 retrieveResourcesForProperties(element.inlineStyle(), document);
296 retrieveResourcesForProperties(element.presentationAttributeStyle(), 300 retrieveResourcesForProperties(element.presentationAttributeStyle(),
297 document); 301 document);
298 } 302 }
299 303
300 if (isHTMLImageElement(element)) { 304 if (isHTMLImageElement(element)) {
301 HTMLImageElement& imageElement = toHTMLImageElement(element); 305 HTMLImageElement& imageElement = toHTMLImageElement(element);
302 KURL url = 306 KURL url =
303 document.completeURL(imageElement.getAttribute(HTMLNames::srcAttr)); 307 document.completeURL(imageElement.getAttribute(HTMLNames::srcAttr));
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 484
481 addToResources(*font, data, font->url()); 485 addToResources(*font, data, font->url());
482 } 486 }
483 487
484 void FrameSerializer::retrieveResourcesForProperties( 488 void FrameSerializer::retrieveResourcesForProperties(
485 const StylePropertySet* styleDeclaration, 489 const StylePropertySet* styleDeclaration,
486 Document& document) { 490 Document& document) {
487 if (!styleDeclaration) 491 if (!styleDeclaration)
488 return; 492 return;
489 493
490 // The background-image and list-style-image (for ul or ol) are the CSS proper ties 494 // The background-image and list-style-image (for ul or ol) are the CSS
491 // that make use of images. We iterate to make sure we include any other 495 // properties that make use of images. We iterate to make sure we include any
492 // image properties there might be. 496 // other image properties there might be.
493 unsigned propertyCount = styleDeclaration->propertyCount(); 497 unsigned propertyCount = styleDeclaration->propertyCount();
494 for (unsigned i = 0; i < propertyCount; ++i) { 498 for (unsigned i = 0; i < propertyCount; ++i) {
495 const CSSValue& cssValue = styleDeclaration->propertyAt(i).value(); 499 const CSSValue& cssValue = styleDeclaration->propertyAt(i).value();
496 retrieveResourcesForCSSValue(cssValue, document); 500 retrieveResourcesForCSSValue(cssValue, document);
497 } 501 }
498 } 502 }
499 503
500 void FrameSerializer::retrieveResourcesForCSSValue(const CSSValue& cssValue, 504 void FrameSerializer::retrieveResourcesForCSSValue(const CSSValue& cssValue,
501 Document& document) { 505 Document& document) {
502 if (cssValue.isImageValue()) { 506 if (cssValue.isImageValue()) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 emitsMinus = ch == '-'; 545 emitsMinus = ch == '-';
542 builder.append(ch); 546 builder.append(ch);
543 } 547 }
544 CString escapedUrl = builder.toString().ascii(); 548 CString escapedUrl = builder.toString().ascii();
545 return String::format("saved from url=(%04d)%s", 549 return String::format("saved from url=(%04d)%s",
546 static_cast<int>(escapedUrl.length()), 550 static_cast<int>(escapedUrl.length()),
547 escapedUrl.data()); 551 escapedUrl.data());
548 } 552 }
549 553
550 } // namespace blink 554 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameSerializer.h ('k') | third_party/WebKit/Source/core/frame/FrameView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698