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

Side by Side Diff: Source/web/WebPageSerializerImpl.cpp

Issue 180723006: Have ElementData::attributeItem() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/WebElement.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 return; 302 return;
303 // Add open tag 303 // Add open tag
304 result.append('<'); 304 result.append('<');
305 result.append(element->nodeName().lower()); 305 result.append(element->nodeName().lower());
306 // Go through all attributes and serialize them. 306 // Go through all attributes and serialize them.
307 if (element->hasAttributes()) { 307 if (element->hasAttributes()) {
308 unsigned numAttrs = element->attributeCount(); 308 unsigned numAttrs = element->attributeCount();
309 for (unsigned i = 0; i < numAttrs; i++) { 309 for (unsigned i = 0; i < numAttrs; i++) {
310 result.append(' '); 310 result.append(' ');
311 // Add attribute pair 311 // Add attribute pair
312 const Attribute *attribute = element->attributeItem(i); 312 const Attribute& attribute = element->attributeItem(i);
313 result.append(attribute->name().toString()); 313 result.append(attribute.name().toString());
314 result.appendLiteral("=\""); 314 result.appendLiteral("=\"");
315 if (!attribute->value().isEmpty()) { 315 if (!attribute.value().isEmpty()) {
316 const String& attrValue = attribute->value(); 316 const String& attrValue = attribute.value();
317 317
318 // Check whether we need to replace some resource links 318 // Check whether we need to replace some resource links
319 // with local resource paths. 319 // with local resource paths.
320 const QualifiedName& attrName = attribute->name(); 320 const QualifiedName& attrName = attribute.name();
321 if (elementHasLegalLinkAttribute(element, attrName)) { 321 if (elementHasLegalLinkAttribute(element, attrName)) {
322 // For links start with "javascript:", we do not change it. 322 // For links start with "javascript:", we do not change it.
323 if (attrValue.startsWith("javascript:", false)) 323 if (attrValue.startsWith("javascript:", false))
324 result.append(attrValue); 324 result.append(attrValue);
325 else { 325 else {
326 // Get the absolute link 326 // Get the absolute link
327 WebFrameImpl* subFrame = WebFrameImpl::fromFrameOwnerEle ment(element); 327 WebFrameImpl* subFrame = WebFrameImpl::fromFrameOwnerEle ment(element);
328 String completeURL = subFrame ? subFrame->frame()->docum ent()->url() : 328 String completeURL = subFrame ? subFrame->frame()->docum ent()->url() :
329 param->document->complet eURL(attrValue); 329 param->document->complet eURL(attrValue);
330 // Check whether we have local files for those link. 330 // Check whether we have local files for those link.
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 517
518 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p aram, ForceFlush); 518 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p aram, ForceFlush);
519 } 519 }
520 520
521 ASSERT(m_dataBuffer.isEmpty()); 521 ASSERT(m_dataBuffer.isEmpty());
522 m_client->didSerializeDataForFrame(KURL(), WebCString("", 0), WebPageSeriali zerClient::AllFramesAreFinished); 522 m_client->didSerializeDataForFrame(KURL(), WebCString("", 0), WebPageSeriali zerClient::AllFramesAreFinished);
523 return didSerialization; 523 return didSerialization;
524 } 524 }
525 525
526 } // namespace blink 526 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698