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

Side by Side Diff: third_party/WebKit/Source/core/html/forms/TypeAhead.cpp

Issue 2390563002: Reflow comments in core/html/forms/. (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * (C) 1999 Antti Koivisto (koivisto@kde.org)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
7 * reserved.
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
8 * Copyright (C) 2010 Google Inc. All rights reserved. 9 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 10 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
11 * (http://www.torchmobile.com/)
10 * 12 *
11 * This library is free software; you can redistribute it and/or 13 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public 14 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either 15 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version. 16 * version 2 of the License, or (at your option) any later version.
15 * 17 *
16 * This library is distributed in the hope that it will be useful, 18 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details. 21 * Library General Public License for more details.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } else { 86 } else {
85 m_repeatingChar = c; 87 m_repeatingChar = c;
86 } 88 }
87 } 89 }
88 90
89 if (!prefix.isEmpty()) { 91 if (!prefix.isEmpty()) {
90 int selected = m_dataSource->indexOfSelectedOption(); 92 int selected = m_dataSource->indexOfSelectedOption();
91 int index = (selected < 0 ? 0 : selected) + searchStartOffset; 93 int index = (selected < 0 ? 0 : selected) + searchStartOffset;
92 index %= optionCount; 94 index %= optionCount;
93 95
94 // Compute a case-folded copy of the prefix string before beginning the sear ch for 96 // Compute a case-folded copy of the prefix string before beginning the
95 // a matching element. This code uses foldCase to work around the fact that 97 // search for a matching element. This code uses foldCase to work around the
96 // String::startWith does not fold non-ASCII characters. This code can be ch anged 98 // fact that String::startWith does not fold non-ASCII characters. This code
97 // to use startWith once that is fixed. 99 // can be changed to use startWith once that is fixed.
98 String prefixWithCaseFolded(prefix.foldCase()); 100 String prefixWithCaseFolded(prefix.foldCase());
99 for (int i = 0; i < optionCount; ++i, index = (index + 1) % optionCount) { 101 for (int i = 0; i < optionCount; ++i, index = (index + 1) % optionCount) {
100 // Fold the option string and check if its prefix is equal to the folded p refix. 102 // Fold the option string and check if its prefix is equal to the folded
103 // prefix.
101 String text = m_dataSource->optionAtIndex(index); 104 String text = m_dataSource->optionAtIndex(index);
102 if (stripLeadingWhiteSpace(text).foldCase().startsWith( 105 if (stripLeadingWhiteSpace(text).foldCase().startsWith(
103 prefixWithCaseFolded)) 106 prefixWithCaseFolded))
104 return index; 107 return index;
105 } 108 }
106 } 109 }
107 110
108 if (matchMode & MatchIndex) { 111 if (matchMode & MatchIndex) {
109 bool ok = false; 112 bool ok = false;
110 int index = m_buffer.toString().toInt(&ok); 113 int index = m_buffer.toString().toInt(&ok);
111 if (index > 0 && index <= optionCount) 114 if (index > 0 && index <= optionCount)
112 return index - 1; 115 return index - 1;
113 } 116 }
114 return -1; 117 return -1;
115 } 118 }
116 119
117 bool TypeAhead::hasActiveSession(KeyboardEvent* event) { 120 bool TypeAhead::hasActiveSession(KeyboardEvent* event) {
118 double delta = event->platformTimeStamp() - m_lastTypeTime; 121 double delta = event->platformTimeStamp() - m_lastTypeTime;
119 return delta <= typeAheadTimeout; 122 return delta <= typeAheadTimeout;
120 } 123 }
121 124
122 void TypeAhead::resetSession() { 125 void TypeAhead::resetSession() {
123 m_lastTypeTime = 0; 126 m_lastTypeTime = 0;
124 m_buffer.clear(); 127 m_buffer.clear();
125 } 128 }
126 129
127 } // namespace blink 130 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698