OLD | NEW |
---|---|
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 , m_rewriteFolder(rewriteFolder) | 246 , m_rewriteFolder(rewriteFolder) |
247 { | 247 { |
248 } | 248 } |
249 | 249 |
250 void LinkChangeSerializerMarkupAccumulator::appendElement(StringBuilder& result, Element& element, Namespaces* namespaces) | 250 void LinkChangeSerializerMarkupAccumulator::appendElement(StringBuilder& result, Element& element, Namespaces* namespaces) |
251 { | 251 { |
252 if (element.hasTagName(HTMLNames::htmlTag)) { | 252 if (element.hasTagName(HTMLNames::htmlTag)) { |
253 // Add MOTW (Mark of the Web) declaration before html tag. | 253 // Add MOTW (Mark of the Web) declaration before html tag. |
254 // See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx. | 254 // See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx. |
255 result.append('\n'); | 255 result.append('\n'); |
256 MarkupFormatter::appendComment(result, String::format(" saved from url=( %04d)%s ", | 256 MarkupFormatter::appendComment(result, PageSerializer::markOfTheWebDecla ration(document().url())); |
257 static_cast<int>(document().url().string().utf8().length()), | |
258 document().url().string().utf8().data())); | |
259 result.append('\n'); | 257 result.append('\n'); |
260 } | 258 } |
261 | 259 |
262 if (element.hasTagName(HTMLNames::baseTag)) { | 260 if (element.hasTagName(HTMLNames::baseTag)) { |
263 // TODO(tiger): Refactor MarkupAccumulator so it is easier to append an element like this, without special cases for XHTML | 261 // TODO(tiger): Refactor MarkupAccumulator so it is easier to append an element like this, without special cases for XHTML |
264 // Append a new base tag declaration. | 262 // Append a new base tag declaration. |
265 result.appendLiteral("<base href=\".\""); | 263 result.appendLiteral("<base href=\".\""); |
266 if (!document().baseTarget().isEmpty()) { | 264 if (!document().baseTarget().isEmpty()) { |
267 result.appendLiteral(" target=\""); | 265 result.appendLiteral(" target=\""); |
268 MarkupFormatter::appendAttributeValue(result, document().baseTarget( ), document().isHTMLDocument()); | 266 MarkupFormatter::appendAttributeValue(result, document().baseTarget( ), document().isHTMLDocument()); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 m_blankFrameURLs.add(frame, fakeURL); | 568 m_blankFrameURLs.add(frame, fakeURL); |
571 | 569 |
572 return fakeURL; | 570 return fakeURL; |
573 } | 571 } |
574 | 572 |
575 PageSerializer::Delegate* PageSerializer::delegate() | 573 PageSerializer::Delegate* PageSerializer::delegate() |
576 { | 574 { |
577 return m_delegate.get(); | 575 return m_delegate.get(); |
578 } | 576 } |
579 | 577 |
578 // Returns MOTW (Mark of the Web) declaration before html tag which is in | |
579 // HTML comment, e.g. "<!-- saved from url=(%04zu)%s -->" | |
580 // See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx. | |
581 String PageSerializer::markOfTheWebDeclaration(const KURL& url) | |
582 { | |
583 StringBuilder builder; | |
584 bool emitsMinus = false; | |
585 CString orignalUrl = url.string().utf8(); | |
586 for (const char* string = orignalUrl.data(); *string; ++string) { | |
587 const char ch = *string; | |
588 if (ch == '-' && emitsMinus) { | |
589 builder.append("%2D"); | |
590 emitsMinus = false; | |
591 continue; | |
592 } | |
593 emitsMinus = ch == '-'; | |
594 builder.append(ch); | |
tkent
2015/09/30 09:01:46
This line adds a part of UTF8-encoded Unicode char
yosin_UTC9
2015/09/30 10:14:59
No. |url| should be ASCII characters.
I changed |u
| |
595 } | |
596 CString escapedUrl = builder.toString().utf8(); | |
597 return String::format("saved from url=(%04zu)%s", escapedUrl.length(), escap edUrl.data()); | |
yosin_UTC9
2015/09/30 10:14:59
It seems Windows doesn't like %04zu. I'll use %04d
| |
598 } | |
599 | |
580 } // namespace blink | 600 } // namespace blink |
OLD | NEW |