OLD | NEW |
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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 StringBuilder result; | 296 StringBuilder result; |
297 // Do pre action for open tag. | 297 // Do pre action for open tag. |
298 result.append(preActionBeforeSerializeOpenTag(element, param, &needSkip)); | 298 result.append(preActionBeforeSerializeOpenTag(element, param, &needSkip)); |
299 if (needSkip) | 299 if (needSkip) |
300 return; | 300 return; |
301 // Add open tag | 301 // Add open tag |
302 result.append('<'); | 302 result.append('<'); |
303 result.append(element->nodeName().lower()); | 303 result.append(element->nodeName().lower()); |
304 // Go through all attributes and serialize them. | 304 // Go through all attributes and serialize them. |
305 if (element->hasAttributes()) { | 305 if (element->hasAttributes()) { |
306 unsigned numAttrs = element->attributeCount(); | 306 AttributeIteratorAccessor attributes = element->attributesIterator(); |
307 for (unsigned i = 0; i < numAttrs; i++) { | 307 AttributeConstIterator end = attributes.end(); |
| 308 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { |
308 result.append(' '); | 309 result.append(' '); |
309 // Add attribute pair | 310 // Add attribute pair |
310 const Attribute& attribute = element->attributeItem(i); | 311 result.append(it->name().toString()); |
311 result.append(attribute.name().toString()); | |
312 result.appendLiteral("=\""); | 312 result.appendLiteral("=\""); |
313 if (!attribute.value().isEmpty()) { | 313 if (!it->value().isEmpty()) { |
314 const String& attrValue = attribute.value(); | 314 const String& attrValue = it->value(); |
315 | 315 |
316 // Check whether we need to replace some resource links | 316 // Check whether we need to replace some resource links |
317 // with local resource paths. | 317 // with local resource paths. |
318 const QualifiedName& attrName = attribute.name(); | 318 const QualifiedName& attrName = it->name(); |
319 if (element->hasLegalLinkAttribute(attrName)) { | 319 if (element->hasLegalLinkAttribute(attrName)) { |
320 // For links start with "javascript:", we do not change it. | 320 // For links start with "javascript:", we do not change it. |
321 if (attrValue.startsWith("javascript:", false)) | 321 if (attrValue.startsWith("javascript:", false)) |
322 result.append(attrValue); | 322 result.append(attrValue); |
323 else { | 323 else { |
324 // Get the absolute link | 324 // Get the absolute link |
325 WebLocalFrameImpl* subFrame = WebLocalFrameImpl::fromFra
meOwnerElement(element); | 325 WebLocalFrameImpl* subFrame = WebLocalFrameImpl::fromFra
meOwnerElement(element); |
326 String completeURL = subFrame ? subFrame->frame()->docum
ent()->url() : | 326 String completeURL = subFrame ? subFrame->frame()->docum
ent()->url() : |
327 param->document->complet
eURL(attrValue); | 327 param->document->complet
eURL(attrValue); |
328 // Check whether we have local files for those link. | 328 // Check whether we have local files for those link. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 | 515 |
516 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p
aram, ForceFlush); | 516 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p
aram, ForceFlush); |
517 } | 517 } |
518 | 518 |
519 ASSERT(m_dataBuffer.isEmpty()); | 519 ASSERT(m_dataBuffer.isEmpty()); |
520 m_client->didSerializeDataForFrame(KURL(), WebCString("", 0), WebPageSeriali
zerClient::AllFramesAreFinished); | 520 m_client->didSerializeDataForFrame(KURL(), WebCString("", 0), WebPageSeriali
zerClient::AllFramesAreFinished); |
521 return didSerialization; | 521 return didSerialization; |
522 } | 522 } |
523 | 523 |
524 } // namespace blink | 524 } // namespace blink |
OLD | NEW |