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

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

Issue 675413003: WebLocalFrameImpl::selectWordAroundPosition should select a word before space. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use VisibleUnit functions and add test cases Created 6 years, 1 month 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
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | Source/core/editing/FrameSelectionTest.cpp » ('j') | 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "core/rendering/HitTestResult.h" 65 #include "core/rendering/HitTestResult.h"
66 #include "core/rendering/InlineTextBox.h" 66 #include "core/rendering/InlineTextBox.h"
67 #include "core/rendering/RenderLayer.h" 67 #include "core/rendering/RenderLayer.h"
68 #include "core/rendering/RenderPart.h" 68 #include "core/rendering/RenderPart.h"
69 #include "core/rendering/RenderText.h" 69 #include "core/rendering/RenderText.h"
70 #include "core/rendering/RenderTheme.h" 70 #include "core/rendering/RenderTheme.h"
71 #include "core/rendering/RenderView.h" 71 #include "core/rendering/RenderView.h"
72 #include "platform/SecureTextInput.h" 72 #include "platform/SecureTextInput.h"
73 #include "platform/geometry/FloatQuad.h" 73 #include "platform/geometry/FloatQuad.h"
74 #include "platform/graphics/GraphicsContext.h" 74 #include "platform/graphics/GraphicsContext.h"
75 #include "platform/text/UnicodeUtilities.h"
75 #include "wtf/text/CString.h" 76 #include "wtf/text/CString.h"
76 #include <stdio.h> 77 #include <stdio.h>
77 78
78 #define EDIT_DEBUG 0 79 #define EDIT_DEBUG 0
79 80
80 namespace blink { 81 namespace blink {
81 82
82 using namespace HTMLNames; 83 using namespace HTMLNames;
83 84
84 static inline LayoutUnit NoXPosForVerticalArrowNavigation() 85 static inline LayoutUnit NoXPosForVerticalArrowNavigation()
(...skipping 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 } 1924 }
1924 1925
1925 void FrameSelection::scheduleVisualUpdate() const 1926 void FrameSelection::scheduleVisualUpdate() const
1926 { 1927 {
1927 if (!m_frame) 1928 if (!m_frame)
1928 return; 1929 return;
1929 if (Page* page = m_frame->page()) 1930 if (Page* page = m_frame->page())
1930 page->animator().scheduleVisualUpdate(); 1931 page->animator().scheduleVisualUpdate();
1931 } 1932 }
1932 1933
1934 bool FrameSelection::selectWordAroundPosition(const VisiblePosition& position)
1935 {
1936 EWordSide wordSideList[2] = { RightWordIfOnBoundary, LeftWordIfOnBoundary };
1937 for (auto& wordSide : wordSideList) {
yosin_UTC9 2014/11/14 04:19:51 Q: Do we need |&|?
yoichio 2014/11/14 04:50:21 Used EWordSide instead. http://chromium-cpp.appspo
1938 VisiblePosition start = startOfWord(position, wordSide);
1939 VisiblePosition end = endOfWord(position, wordSide);
1940
yosin_UTC9 2014/11/14 04:19:51 nit: We don't need to have a blank line.
yoichio 2014/11/14 04:50:22 Done.
1941 String text = plainText(start.deepEquivalent(), end.deepEquivalent());
1942
yosin_UTC9 2014/11/14 04:19:51 nit: We don't need to have a blank line.
yoichio 2014/11/14 04:50:21 Done.
1943 if (!text.isEmpty() && !isSeparator(text.characterStartingAt(0))) {
1944 setSelection(VisibleSelection(start, end), WordGranularity);
1945 return true;
1946 }
1947 }
1948
1949 return false;
1950 }
1951
1933 } 1952 }
1934 1953
1935 #ifndef NDEBUG 1954 #ifndef NDEBUG
1936 1955
1937 void showTree(const blink::FrameSelection& sel) 1956 void showTree(const blink::FrameSelection& sel)
1938 { 1957 {
1939 sel.showTreeForThis(); 1958 sel.showTreeForThis();
1940 } 1959 }
1941 1960
1942 void showTree(const blink::FrameSelection* sel) 1961 void showTree(const blink::FrameSelection* sel)
1943 { 1962 {
1944 if (sel) 1963 if (sel)
1945 sel->showTreeForThis(); 1964 sel->showTreeForThis();
1946 } 1965 }
1947 1966
1948 #endif 1967 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | Source/core/editing/FrameSelectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698