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

Side by Side Diff: Source/core/editing/FrameSelection.cpp

Issue 1192053002: Templatize extractSelectedHTMLAlgorithm used by FrameSelection function (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | « no previous file | 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) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 if (caretBrowsing) 1662 if (caretBrowsing)
1663 m_frame->page()->focusController().setFocusedElement(0, m_frame); 1663 m_frame->page()->focusController().setFocusedElement(0, m_frame);
1664 } 1664 }
1665 1665
1666 static String extractSelectedText(const FrameSelection& selection, TextIteratorB ehavior behavior) 1666 static String extractSelectedText(const FrameSelection& selection, TextIteratorB ehavior behavior)
1667 { 1667 {
1668 // We remove '\0' characters because they are not visibly rendered to the us er. 1668 // We remove '\0' characters because they are not visibly rendered to the us er.
1669 return plainText(selection.toNormalizedRange().get(), behavior).replace(0, " "); 1669 return plainText(selection.toNormalizedRange().get(), behavior).replace(0, " ");
1670 } 1670 }
1671 1671
1672 template <typename Strategy>
1673 static String extractSelectedHTMLAlgorithm(const FrameSelection& selection)
1674 {
1675 using PositionType = typename Strategy::PositionType;
1676 PositionType start;
1677 PositionType end;
1678 VisibleSelection visibleSelection = selection.selection();
1679 VisibleSelection::normalizePositions(Strategy::selectionStart(visibleSelecti on), Strategy::selectionEnd(visibleSelection), &start, &end);
1680 return createMarkup(start, end, AnnotateForInterchange, ConvertBlocksToInlin es::NotConvert, ResolveNonLocalURLs);
1681 }
1682
1672 String FrameSelection::selectedHTMLForClipboard() const 1683 String FrameSelection::selectedHTMLForClipboard() const
1673 { 1684 {
1674 return createMarkup(m_selection.toNormalizedRange().get(), AnnotateForInterc hange, ConvertBlocksToInlines::NotConvert, ResolveNonLocalURLs); 1685 return extractSelectedHTMLAlgorithm<VisibleSelection::InDOMTree>(*this);
1675 } 1686 }
1676 1687
1677 String FrameSelection::selectedText() const 1688 String FrameSelection::selectedText() const
1678 { 1689 {
1679 return extractSelectedText(*this, TextIteratorDefaultBehavior); 1690 return extractSelectedText(*this, TextIteratorDefaultBehavior);
1680 } 1691 }
1681 1692
1682 String FrameSelection::selectedTextForClipboard() const 1693 String FrameSelection::selectedTextForClipboard() const
1683 { 1694 {
1684 if (m_frame->settings() && m_frame->settings()->selectionIncludesAltImageTex t()) 1695 if (m_frame->settings() && m_frame->settings()->selectionIncludesAltImageTex t())
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 1984
1974 void showTree(const blink::FrameSelection* sel) 1985 void showTree(const blink::FrameSelection* sel)
1975 { 1986 {
1976 if (sel) 1987 if (sel)
1977 sel->showTreeForThis(); 1988 sel->showTreeForThis();
1978 else 1989 else
1979 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); 1990 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n");
1980 } 1991 }
1981 1992
1982 #endif 1993 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698