Update CefRange type to match gfx::Range (fixes #3422)
This commit is contained in:
parent
e5334a5a18
commit
ecdfd467f8
|
@ -42,13 +42,13 @@
|
||||||
// way that may cause binary incompatibility with other builds. The universal
|
// way that may cause binary incompatibility with other builds. The universal
|
||||||
// hash value will change if any platform is affected whereas the platform hash
|
// hash value will change if any platform is affected whereas the platform hash
|
||||||
// values will change only if that particular platform is affected.
|
// values will change only if that particular platform is affected.
|
||||||
#define CEF_API_HASH_UNIVERSAL "cd16e1ab288ddddc4c13c67b05aed49a47db6e7f"
|
#define CEF_API_HASH_UNIVERSAL "a3f241333b0d0bdcb3b3ea7c2b003ff146019b54"
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#define CEF_API_HASH_PLATFORM "d80ddfd6897163f83a0acdc2a3d3e627916a1365"
|
#define CEF_API_HASH_PLATFORM "22809c1dd1e83a467160065822e4c5a2aa1a6f74"
|
||||||
#elif defined(OS_MAC)
|
#elif defined(OS_MAC)
|
||||||
#define CEF_API_HASH_PLATFORM "d19854c113f1549904ff4055f3a38901cac6af68"
|
#define CEF_API_HASH_PLATFORM "4366603b6ce969025e27b7d1834028df8e6ffbe4"
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
#define CEF_API_HASH_PLATFORM "0ba21a432d3b28ab79a0319a11a6e113ff1fcb07"
|
#define CEF_API_HASH_PLATFORM "d1f8e80f361ae3d013add51dcb1449341be9eff1"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -3000,8 +3000,8 @@ typedef enum {
|
||||||
/// Structure representing a range.
|
/// Structure representing a range.
|
||||||
///
|
///
|
||||||
typedef struct _cef_range_t {
|
typedef struct _cef_range_t {
|
||||||
int from;
|
uint32_t from;
|
||||||
int to;
|
uint32_t to;
|
||||||
} cef_range_t;
|
} cef_range_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
|
@ -215,7 +215,12 @@ class CefRange : public cef_range_t {
|
||||||
public:
|
public:
|
||||||
CefRange() : cef_range_t{} {}
|
CefRange() : cef_range_t{} {}
|
||||||
CefRange(const cef_range_t& r) : cef_range_t(r) {}
|
CefRange(const cef_range_t& r) : cef_range_t(r) {}
|
||||||
CefRange(int from, int to) : cef_range_t{from, to} {}
|
CefRange(uint32_t from, uint32_t to) : cef_range_t{from, to} {}
|
||||||
|
|
||||||
|
static CefRange InvalidRange() {
|
||||||
|
return CefRange(std::numeric_limits<uint32_t>::max(),
|
||||||
|
std::numeric_limits<uint32_t>::max());
|
||||||
|
}
|
||||||
|
|
||||||
void Set(int from_val, int to_val) { from = from_val, to = to_val; }
|
void Set(int from_val, int to_val) { from = from_val, to = to_val; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,12 +35,13 @@ bool IsSelectionAttribute(char attribute) {
|
||||||
// to get the target range that's selected by the user in the current
|
// to get the target range that's selected by the user in the current
|
||||||
// composition string.
|
// composition string.
|
||||||
void GetCompositionSelectionRange(HIMC imc,
|
void GetCompositionSelectionRange(HIMC imc,
|
||||||
int* target_start,
|
uint32_t* target_start,
|
||||||
int* target_end) {
|
uint32_t* target_end) {
|
||||||
int attribute_size = ::ImmGetCompositionString(imc, GCS_COMPATTR, nullptr, 0);
|
uint32_t attribute_size =
|
||||||
|
::ImmGetCompositionString(imc, GCS_COMPATTR, nullptr, 0);
|
||||||
if (attribute_size > 0) {
|
if (attribute_size > 0) {
|
||||||
int start = 0;
|
uint32_t start = 0;
|
||||||
int end = 0;
|
uint32_t end = 0;
|
||||||
std::vector<char> attribute_data(attribute_size);
|
std::vector<char> attribute_data(attribute_size);
|
||||||
|
|
||||||
::ImmGetCompositionString(imc, GCS_COMPATTR, &attribute_data[0],
|
::ImmGetCompositionString(imc, GCS_COMPATTR, &attribute_data[0],
|
||||||
|
@ -65,13 +66,13 @@ void GetCompositionSelectionRange(HIMC imc,
|
||||||
// underlines information of the current composition string.
|
// underlines information of the current composition string.
|
||||||
void GetCompositionUnderlines(
|
void GetCompositionUnderlines(
|
||||||
HIMC imc,
|
HIMC imc,
|
||||||
int target_start,
|
uint32_t target_start,
|
||||||
int target_end,
|
uint32_t target_end,
|
||||||
std::vector<CefCompositionUnderline>& underlines) {
|
std::vector<CefCompositionUnderline>& underlines) {
|
||||||
int clause_size = ::ImmGetCompositionString(imc, GCS_COMPCLAUSE, nullptr, 0);
|
int clause_size = ::ImmGetCompositionString(imc, GCS_COMPCLAUSE, nullptr, 0);
|
||||||
int clause_length = clause_size / sizeof(uint32);
|
int clause_length = clause_size / sizeof(uint32);
|
||||||
if (clause_length) {
|
if (clause_length) {
|
||||||
std::vector<uint32> clause_data(clause_length);
|
std::vector<uint32_t> clause_data(clause_length);
|
||||||
|
|
||||||
::ImmGetCompositionString(imc, GCS_COMPCLAUSE, &clause_data[0],
|
::ImmGetCompositionString(imc, GCS_COMPCLAUSE, &clause_data[0],
|
||||||
clause_size);
|
clause_size);
|
||||||
|
@ -99,7 +100,7 @@ OsrImeHandlerWin::OsrImeHandlerWin(HWND hwnd)
|
||||||
: is_composing_(false),
|
: is_composing_(false),
|
||||||
input_language_id_(LANG_USER_DEFAULT),
|
input_language_id_(LANG_USER_DEFAULT),
|
||||||
system_caret_(false),
|
system_caret_(false),
|
||||||
cursor_index_(-1),
|
cursor_index_(std::numeric_limits<uint32_t>::max()),
|
||||||
hwnd_(hwnd) {
|
hwnd_(hwnd) {
|
||||||
ime_rect_ = {-1, -1, 0, 0};
|
ime_rect_ = {-1, -1, 0, 0};
|
||||||
}
|
}
|
||||||
|
@ -157,10 +158,10 @@ void OsrImeHandlerWin::MoveImeWindow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRect rc = ime_rect_;
|
CefRect rc = ime_rect_;
|
||||||
int location = cursor_index_;
|
uint32_t location = cursor_index_;
|
||||||
|
|
||||||
// If location is not specified fall back to the composition range start.
|
// If location is not specified fall back to the composition range start.
|
||||||
if (location == -1) {
|
if (location == std::numeric_limits<uint32_t>::max()) {
|
||||||
location = composition_range_.from;
|
location = composition_range_.from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +170,7 @@ void OsrImeHandlerWin::MoveImeWindow() {
|
||||||
location -= composition_range_.from;
|
location -= composition_range_.from;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location < static_cast<int>(composition_bounds_.size())) {
|
if (location < composition_bounds_.size()) {
|
||||||
rc = composition_bounds_[location];
|
rc = composition_bounds_[location];
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
@ -240,7 +241,7 @@ void OsrImeHandlerWin::CleanupComposition() {
|
||||||
void OsrImeHandlerWin::ResetComposition() {
|
void OsrImeHandlerWin::ResetComposition() {
|
||||||
// Reset the composition status.
|
// Reset the composition status.
|
||||||
is_composing_ = false;
|
is_composing_ = false;
|
||||||
cursor_index_ = -1;
|
cursor_index_ = std::numeric_limits<uint32_t>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsrImeHandlerWin::GetCompositionInfo(
|
void OsrImeHandlerWin::GetCompositionInfo(
|
||||||
|
@ -253,11 +254,11 @@ void OsrImeHandlerWin::GetCompositionInfo(
|
||||||
// convert them into underlines and selection range respectively.
|
// convert them into underlines and selection range respectively.
|
||||||
underlines.clear();
|
underlines.clear();
|
||||||
|
|
||||||
int length = static_cast<int>(composition_text.length());
|
uint32_t length = static_cast<uint32_t>(composition_text.length());
|
||||||
|
|
||||||
// Find out the range selected by the user.
|
// Find out the range selected by the user.
|
||||||
int target_start = length;
|
uint32_t target_start = length;
|
||||||
int target_end = length;
|
uint32_t target_end = length;
|
||||||
if (lparam & GCS_COMPATTR) {
|
if (lparam & GCS_COMPATTR) {
|
||||||
GetCompositionSelectionRange(imc, &target_start, &target_end);
|
GetCompositionSelectionRange(imc, &target_start, &target_end);
|
||||||
}
|
}
|
||||||
|
@ -386,7 +387,7 @@ void OsrImeHandlerWin::EnableIME() {
|
||||||
::ImmAssociateContextEx(hwnd_, nullptr, IACE_DEFAULT);
|
::ImmAssociateContextEx(hwnd_, nullptr, IACE_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsrImeHandlerWin::UpdateCaretPosition(int index) {
|
void OsrImeHandlerWin::UpdateCaretPosition(uint32_t index) {
|
||||||
// Save the caret position.
|
// Save the caret position.
|
||||||
cursor_index_ = index;
|
cursor_index_ = index;
|
||||||
// Move the IME window.
|
// Move the IME window.
|
||||||
|
|
|
@ -60,7 +60,7 @@ class OsrImeHandlerWin {
|
||||||
virtual void CancelIME();
|
virtual void CancelIME();
|
||||||
|
|
||||||
// Updates the IME caret position of the given window.
|
// Updates the IME caret position of the given window.
|
||||||
void UpdateCaretPosition(int index);
|
void UpdateCaretPosition(uint32_t index);
|
||||||
|
|
||||||
// Updates the composition range. |selected_range| is the range of characters
|
// Updates the composition range. |selected_range| is the range of characters
|
||||||
// that have been selected. |character_bounds| is the bounds of each character
|
// that have been selected. |character_bounds| is the bounds of each character
|
||||||
|
@ -100,7 +100,7 @@ class OsrImeHandlerWin {
|
||||||
CefRect ime_rect_;
|
CefRect ime_rect_;
|
||||||
|
|
||||||
// The current cursor index in composition string.
|
// The current cursor index in composition string.
|
||||||
int cursor_index_;
|
uint32_t cursor_index_;
|
||||||
|
|
||||||
// The composition range in the string. This may be used to determine the
|
// The composition range in the string. This may be used to determine the
|
||||||
// offset in composition bounds.
|
// offset in composition bounds.
|
||||||
|
|
|
@ -418,8 +418,7 @@ void OsrWindowWin::OnIMEComposition(UINT message,
|
||||||
// Send the text to the browser. The |replacement_range| and
|
// Send the text to the browser. The |replacement_range| and
|
||||||
// |relative_cursor_pos| params are not used on Windows, so provide
|
// |relative_cursor_pos| params are not used on Windows, so provide
|
||||||
// default invalid values.
|
// default invalid values.
|
||||||
browser_->GetHost()->ImeCommitText(cTextStr,
|
browser_->GetHost()->ImeCommitText(cTextStr, CefRange::InvalidRange(), 0);
|
||||||
CefRange(UINT32_MAX, UINT32_MAX), 0);
|
|
||||||
ime_handler_->ResetComposition();
|
ime_handler_->ResetComposition();
|
||||||
// Continue reading the composition string - Japanese IMEs send both
|
// Continue reading the composition string - Japanese IMEs send both
|
||||||
// GCS_RESULTSTR and GCS_COMPSTR.
|
// GCS_RESULTSTR and GCS_COMPSTR.
|
||||||
|
@ -433,7 +432,7 @@ void OsrWindowWin::OnIMEComposition(UINT message,
|
||||||
// Send the composition string to the browser. The |replacement_range|
|
// Send the composition string to the browser. The |replacement_range|
|
||||||
// param is not used on Windows, so provide a default invalid value.
|
// param is not used on Windows, so provide a default invalid value.
|
||||||
browser_->GetHost()->ImeSetComposition(
|
browser_->GetHost()->ImeSetComposition(
|
||||||
cTextStr, underlines, CefRange(UINT32_MAX, UINT32_MAX),
|
cTextStr, underlines, CefRange::InvalidRange(),
|
||||||
CefRange(composition_start,
|
CefRange(composition_start,
|
||||||
static_cast<int>(composition_start + cTextStr.length())));
|
static_cast<int>(composition_start + cTextStr.length())));
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,9 @@ void ExtractUnderlines(NSAttributedString* string,
|
||||||
color = CefColorFromNSColor(
|
color = CefColorFromNSColor(
|
||||||
[colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]);
|
[colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]);
|
||||||
}
|
}
|
||||||
cef_composition_underline_t line = {{static_cast<int>(range.location),
|
cef_composition_underline_t line = {
|
||||||
static_cast<int>(NSMaxRange(range))},
|
{static_cast<uint32_t>(range.location),
|
||||||
|
static_cast<uint32_t>(NSMaxRange(range))},
|
||||||
color,
|
color,
|
||||||
0,
|
0,
|
||||||
[style intValue] > 1};
|
[style intValue] > 1};
|
||||||
|
@ -109,8 +110,8 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
|
||||||
if (handlingKeyDown_) {
|
if (handlingKeyDown_) {
|
||||||
textToBeInserted_.append([im_text UTF8String]);
|
textToBeInserted_.append([im_text UTF8String]);
|
||||||
} else {
|
} else {
|
||||||
cef_range_t range = {static_cast<int>(replacementRange.location),
|
cef_range_t range = {static_cast<uint32_t>(replacementRange.location),
|
||||||
static_cast<int>(NSMaxRange(replacementRange))};
|
static_cast<uint32_t>(NSMaxRange(replacementRange))};
|
||||||
browser_->GetHost()->ImeCommitText([im_text UTF8String], range, 0);
|
browser_->GetHost()->ImeCommitText([im_text UTF8String], range, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +132,7 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
|
||||||
|
|
||||||
BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]];
|
BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]];
|
||||||
NSString* im_text = isAttributedString ? [aString string] : aString;
|
NSString* im_text = isAttributedString ? [aString string] : aString;
|
||||||
int length = static_cast<int>([im_text length]);
|
uint32_t length = [im_text length];
|
||||||
|
|
||||||
// |markedRange_| will get set in a callback from ImeSetComposition().
|
// |markedRange_| will get set in a callback from ImeSetComposition().
|
||||||
selectedRange_ = newSelRange;
|
selectedRange_ = newSelRange;
|
||||||
|
@ -154,13 +155,14 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
|
||||||
// ongoing composition when we send empty text.
|
// ongoing composition when we send empty text.
|
||||||
if (handlingKeyDown_) {
|
if (handlingKeyDown_) {
|
||||||
setMarkedTextReplacementRange_ = {
|
setMarkedTextReplacementRange_ = {
|
||||||
static_cast<int>(replacementRange.location),
|
static_cast<uint32_t>(replacementRange.location),
|
||||||
static_cast<int>(NSMaxRange(replacementRange))};
|
static_cast<uint32_t>(NSMaxRange(replacementRange))};
|
||||||
} else if (!handlingKeyDown_) {
|
} else if (!handlingKeyDown_) {
|
||||||
CefRange replacement_range(static_cast<int>(replacementRange.location),
|
CefRange replacement_range(
|
||||||
static_cast<int>(NSMaxRange(replacementRange)));
|
static_cast<uint32_t>(replacementRange.location),
|
||||||
CefRange selection_range(static_cast<int>(newSelRange.location),
|
static_cast<uint32_t>(NSMaxRange(replacementRange)));
|
||||||
static_cast<int>(NSMaxRange(newSelRange)));
|
CefRange selection_range(static_cast<uint32_t>(newSelRange.location),
|
||||||
|
static_cast<uint32_t>(NSMaxRange(newSelRange)));
|
||||||
|
|
||||||
browser_->GetHost()->ImeSetComposition(markedText_, underlines_,
|
browser_->GetHost()->ImeSetComposition(markedText_, underlines_,
|
||||||
replacement_range, selection_range);
|
replacement_range, selection_range);
|
||||||
|
@ -268,7 +270,7 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
|
||||||
textToBeInserted_.clear();
|
textToBeInserted_.clear();
|
||||||
markedText_.clear();
|
markedText_.clear();
|
||||||
underlines_.clear();
|
underlines_.clear();
|
||||||
setMarkedTextReplacementRange_ = CefRange(UINT32_MAX, UINT32_MAX);
|
setMarkedTextReplacementRange_ = CefRange::InvalidRange();
|
||||||
unmarkTextCalled_ = NO;
|
unmarkTextCalled_ = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +308,7 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
|
||||||
if (textToBeInserted_.length() >
|
if (textToBeInserted_.length() >
|
||||||
((hasMarkedText_ || oldHasMarkedText_) ? 0u : 1u)) {
|
((hasMarkedText_ || oldHasMarkedText_) ? 0u : 1u)) {
|
||||||
browser_->GetHost()->ImeCommitText(textToBeInserted_,
|
browser_->GetHost()->ImeCommitText(textToBeInserted_,
|
||||||
CefRange(UINT32_MAX, UINT32_MAX), 0);
|
CefRange::InvalidRange(), 0);
|
||||||
textToBeInserted_.clear();
|
textToBeInserted_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,8 +319,8 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
|
||||||
// |selectedRange_| is the range being selected inside the marked text.
|
// |selectedRange_| is the range being selected inside the marked text.
|
||||||
browser_->GetHost()->ImeSetComposition(
|
browser_->GetHost()->ImeSetComposition(
|
||||||
markedText_, underlines_, setMarkedTextReplacementRange_,
|
markedText_, underlines_, setMarkedTextReplacementRange_,
|
||||||
CefRange(static_cast<int>(selectedRange_.location),
|
CefRange(static_cast<uint32_t>(selectedRange_.location),
|
||||||
static_cast<int>(NSMaxRange(selectedRange_))));
|
static_cast<uint32_t>(NSMaxRange(selectedRange_))));
|
||||||
} else if (oldHasMarkedText_ && !hasMarkedText_ && !textInserted) {
|
} else if (oldHasMarkedText_ && !hasMarkedText_ && !textInserted) {
|
||||||
// There was no marked text or inserted text. Complete or cancel the
|
// There was no marked text or inserted text. Complete or cancel the
|
||||||
// composition.
|
// composition.
|
||||||
|
@ -329,7 +331,7 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setMarkedTextReplacementRange_ = CefRange(UINT32_MAX, UINT32_MAX);
|
setMarkedTextReplacementRange_ = CefRange::InvalidRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)ChangeCompositionRange:(CefRange)range
|
- (void)ChangeCompositionRange:(CefRange)range
|
||||||
|
|
|
@ -1097,8 +1097,8 @@ class OSRTestHandler : public RoutingTestHandler,
|
||||||
const CefRange& range,
|
const CefRange& range,
|
||||||
const CefRenderHandler::RectList& bounds) override {
|
const CefRenderHandler::RectList& bounds) override {
|
||||||
if (test_type_ == OSR_TEST_IME_SET_COMPOSITION && started()) {
|
if (test_type_ == OSR_TEST_IME_SET_COMPOSITION && started()) {
|
||||||
EXPECT_EQ(range.from, 0);
|
EXPECT_EQ(range.from, 0U);
|
||||||
EXPECT_EQ(range.to, 1);
|
EXPECT_EQ(range.to, 1U);
|
||||||
EXPECT_EQ(1U, bounds.size());
|
EXPECT_EQ(1U, bounds.size());
|
||||||
DestroySucceededTestSoon();
|
DestroySucceededTestSoon();
|
||||||
}
|
}
|
||||||
|
@ -1586,7 +1586,7 @@ class OSRTestHandler : public RoutingTestHandler,
|
||||||
// This text should be honored instead of 'ka' added via key events
|
// This text should be honored instead of 'ka' added via key events
|
||||||
CefString markedText("osrimecommit");
|
CefString markedText("osrimecommit");
|
||||||
|
|
||||||
CefRange range(0, static_cast<int>(markedText.length()));
|
CefRange range(0, static_cast<uint32_t>(markedText.length()));
|
||||||
browser->GetHost()->ImeCommitText(markedText, range, 0);
|
browser->GetHost()->ImeCommitText(markedText, range, 0);
|
||||||
|
|
||||||
ClickButtonToNavigate(browser);
|
ClickButtonToNavigate(browser);
|
||||||
|
@ -1621,12 +1621,12 @@ class OSRTestHandler : public RoutingTestHandler,
|
||||||
std::vector<CefCompositionUnderline> underlines;
|
std::vector<CefCompositionUnderline> underlines;
|
||||||
|
|
||||||
// Use a thin black underline by default.
|
// Use a thin black underline by default.
|
||||||
CefRange range(0, static_cast<int>(markedText.length()));
|
CefRange range(0, static_cast<uint32_t>(markedText.length()));
|
||||||
cef_composition_underline_t line = {range, 0xFF000000, 0, false};
|
cef_composition_underline_t line = {range, 0xFF000000, 0, false};
|
||||||
underlines.push_back(line);
|
underlines.push_back(line);
|
||||||
|
|
||||||
CefRange replacement_range(0, static_cast<int>(markedText.length()));
|
CefRange replacement_range(0, static_cast<uint32_t>(markedText.length()));
|
||||||
CefRange selection_range(0, static_cast<int>(markedText.length()));
|
CefRange selection_range(0, static_cast<uint32_t>(markedText.length()));
|
||||||
|
|
||||||
// Composition should be updated
|
// Composition should be updated
|
||||||
browser->GetHost()->ImeSetComposition(markedText, underlines,
|
browser->GetHost()->ImeSetComposition(markedText, underlines,
|
||||||
|
@ -1646,12 +1646,12 @@ class OSRTestHandler : public RoutingTestHandler,
|
||||||
std::vector<CefCompositionUnderline> underlines;
|
std::vector<CefCompositionUnderline> underlines;
|
||||||
|
|
||||||
// Use a thin black underline by default.
|
// Use a thin black underline by default.
|
||||||
CefRange range(0, static_cast<int>(markedText.length()));
|
CefRange range(0, static_cast<uint32_t>(markedText.length()));
|
||||||
cef_composition_underline_t line = {range, 0xFF000000, 0, false};
|
cef_composition_underline_t line = {range, 0xFF000000, 0, false};
|
||||||
underlines.push_back(line);
|
underlines.push_back(line);
|
||||||
|
|
||||||
CefRange replacement_range(0, static_cast<int>(markedText.length()));
|
CefRange replacement_range(0, static_cast<uint32_t>(markedText.length()));
|
||||||
CefRange selection_range(0, static_cast<int>(markedText.length()));
|
CefRange selection_range(0, static_cast<uint32_t>(markedText.length()));
|
||||||
|
|
||||||
// This should update composition range and
|
// This should update composition range and
|
||||||
// trigger the compositionRangeChanged callback
|
// trigger the compositionRangeChanged callback
|
||||||
|
|
|
@ -64,12 +64,12 @@ void RunTextfieldContents(CefRefPtr<CefWindow> window) {
|
||||||
|
|
||||||
// Test select range.
|
// Test select range.
|
||||||
EXPECT_FALSE(textfield->HasSelection());
|
EXPECT_FALSE(textfield->HasSelection());
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(CefRange(static_cast<uint32_t>(cursor_pos),
|
||||||
CefRange(static_cast<int>(cursor_pos), static_cast<int>(cursor_pos)),
|
static_cast<uint32_t>(cursor_pos)),
|
||||||
textfield->GetSelectedRange());
|
textfield->GetSelectedRange());
|
||||||
textfield->SelectRange(CefRange(0, static_cast<int>(cursor_pos)));
|
textfield->SelectRange(CefRange(0, static_cast<uint32_t>(cursor_pos)));
|
||||||
EXPECT_TRUE(textfield->HasSelection());
|
EXPECT_TRUE(textfield->HasSelection());
|
||||||
EXPECT_EQ(CefRange(0, static_cast<int>(cursor_pos)),
|
EXPECT_EQ(CefRange(0, static_cast<uint32_t>(cursor_pos)),
|
||||||
textfield->GetSelectedRange());
|
textfield->GetSelectedRange());
|
||||||
EXPECT_STREQ(kText, textfield->GetSelectedText().ToString().c_str());
|
EXPECT_STREQ(kText, textfield->GetSelectedText().ToString().c_str());
|
||||||
EXPECT_EQ(cursor_pos, textfield->GetCursorPosition());
|
EXPECT_EQ(cursor_pos, textfield->GetCursorPosition());
|
||||||
|
@ -89,15 +89,15 @@ void RunTextfieldContents(CefRefPtr<CefWindow> window) {
|
||||||
EXPECT_TRUE(textfield->HasSelection());
|
EXPECT_TRUE(textfield->HasSelection());
|
||||||
|
|
||||||
cursor_pos = sizeof(kReplaceText) + sizeof(kAppendText) - 2;
|
cursor_pos = sizeof(kReplaceText) + sizeof(kAppendText) - 2;
|
||||||
EXPECT_EQ(CefRange(0, static_cast<int>(cursor_pos)),
|
EXPECT_EQ(CefRange(0, static_cast<uint32_t>(cursor_pos)),
|
||||||
textfield->GetSelectedRange());
|
textfield->GetSelectedRange());
|
||||||
EXPECT_EQ(cursor_pos, textfield->GetCursorPosition());
|
EXPECT_EQ(cursor_pos, textfield->GetCursorPosition());
|
||||||
|
|
||||||
// Test clear selection.
|
// Test clear selection.
|
||||||
textfield->ClearSelection();
|
textfield->ClearSelection();
|
||||||
EXPECT_FALSE(textfield->HasSelection());
|
EXPECT_FALSE(textfield->HasSelection());
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(CefRange(static_cast<uint32_t>(cursor_pos),
|
||||||
CefRange(static_cast<int>(cursor_pos), static_cast<int>(cursor_pos)),
|
static_cast<uint32_t>(cursor_pos)),
|
||||||
textfield->GetSelectedRange());
|
textfield->GetSelectedRange());
|
||||||
EXPECT_EQ(cursor_pos, textfield->GetCursorPosition());
|
EXPECT_EQ(cursor_pos, textfield->GetCursorPosition());
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void RunTextfieldContents(CefRefPtr<CefWindow> window) {
|
||||||
EXPECT_TRUE(textfield->IsCommandEnabled(CEF_TFC_SELECT_ALL));
|
EXPECT_TRUE(textfield->IsCommandEnabled(CEF_TFC_SELECT_ALL));
|
||||||
textfield->ExecuteCommand(CEF_TFC_SELECT_ALL);
|
textfield->ExecuteCommand(CEF_TFC_SELECT_ALL);
|
||||||
EXPECT_TRUE(textfield->HasSelection());
|
EXPECT_TRUE(textfield->HasSelection());
|
||||||
EXPECT_EQ(CefRange(0, static_cast<int>(cursor_pos)),
|
EXPECT_EQ(CefRange(0, static_cast<uint32_t>(cursor_pos)),
|
||||||
textfield->GetSelectedRange());
|
textfield->GetSelectedRange());
|
||||||
EXPECT_EQ(cursor_pos, textfield->GetCursorPosition());
|
EXPECT_EQ(cursor_pos, textfield->GetCursorPosition());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue