OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 } | 561 } |
562 | 562 |
563 return create(mainResource, subresources, subframeArchives); | 563 return create(mainResource, subresources, subframeArchives); |
564 } | 564 } |
565 | 565 |
566 PassRefPtr<LegacyWebArchive> LegacyWebArchive::createFromSelection(Frame* frame) | 566 PassRefPtr<LegacyWebArchive> LegacyWebArchive::createFromSelection(Frame* frame) |
567 { | 567 { |
568 if (!frame) | 568 if (!frame) |
569 return 0; | 569 return 0; |
570 | 570 |
571 RefPtr<Range> selectionRange = frame->selection()->toRange(); | 571 RefPtr<Range> selectionRange = frame->selection()->toNormalizedRange(); |
572 Vector<Node*> nodeList; | 572 Vector<Node*> nodeList; |
573 String markupString = frame->documentTypeString() + createMarkup(selectionRa
nge.get(), &nodeList, AnnotateForInterchange); | 573 String markupString = frame->documentTypeString() + createMarkup(selectionRa
nge.get(), &nodeList, AnnotateForInterchange); |
574 | 574 |
575 RefPtr<LegacyWebArchive> archive = create(markupString, frame, nodeList); | 575 RefPtr<LegacyWebArchive> archive = create(markupString, frame, nodeList); |
576 | 576 |
577 if (!frame->document() || !frame->document()->isFrameSet()) | 577 if (!frame->document() || !frame->document()->isFrameSet()) |
578 return archive.release(); | 578 return archive.release(); |
579 | 579 |
580 // Wrap the frameset document in an iframe so it can be pasted into | 580 // Wrap the frameset document in an iframe so it can be pasted into |
581 // another document (which will have a body or frameset of its own). | 581 // another document (which will have a body or frameset of its own). |
582 String iframeMarkup = String::format("<iframe frameborder=\"no\" marginwidth
=\"0\" marginheight=\"0\" width=\"98%%\" height=\"98%%\" src=\"%s\"></iframe>", | 582 String iframeMarkup = String::format("<iframe frameborder=\"no\" marginwidth
=\"0\" marginheight=\"0\" width=\"98%%\" height=\"98%%\" src=\"%s\"></iframe>", |
583 frame->loader()->documentLoader()->resp
onse().url().string().utf8().data()); | 583 frame->loader()->documentLoader()->resp
onse().url().string().utf8().data()); |
584 RefPtr<ArchiveResource> iframeResource = ArchiveResource::create(utf8Buffer(
iframeMarkup), blankURL(), "text/html", "UTF-8", String()); | 584 RefPtr<ArchiveResource> iframeResource = ArchiveResource::create(utf8Buffer(
iframeMarkup), blankURL(), "text/html", "UTF-8", String()); |
585 | 585 |
586 Vector<PassRefPtr<ArchiveResource> > subresources; | 586 Vector<PassRefPtr<ArchiveResource> > subresources; |
587 | 587 |
588 Vector<PassRefPtr<LegacyWebArchive> > subframeArchives; | 588 Vector<PassRefPtr<LegacyWebArchive> > subframeArchives; |
589 subframeArchives.append(archive); | 589 subframeArchives.append(archive); |
590 | 590 |
591 archive = LegacyWebArchive::create(iframeResource.release(), subresources, s
ubframeArchives); | 591 archive = LegacyWebArchive::create(iframeResource.release(), subresources, s
ubframeArchives); |
592 | 592 |
593 return archive.release(); | 593 return archive.release(); |
594 } | 594 } |
595 | 595 |
596 } | 596 } |
OLD | NEW |