MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / Widget

Method Widget

native/desc/Widget.cpp:26–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25
26 Widget::Widget(std::shared_ptr<Widget> parent, const ElementPtr &element) {
27 this->_parent = std::move(parent);
28 this->initFormElement(element);
29 // remove digits or blank space in string
30 auto removeIterator = this->_text.erase(
31 std::remove_if(this->_text.begin(), this->_text.end(), ifCharIsDigitOrBlank),
32 this->_text.end());
33 this->_text = std::string(this->_text.begin(), removeIterator);
34 if (STATE_WITH_TEXT || Preference::inst()->isForceUseTextModel()) {
35 bool overMaxLen = this->_text.size() > STATE_TEXT_MAX_LEN;
36 this->_text = this->_text.substr(0, STATE_TEXT_MAX_LEN * 4);
37 int cutLength = STATE_TEXT_MAX_LEN;
38 if (this->_text.length() > cutLength && isZhCn(this->_text[STATE_TEXT_MAX_LEN])) {
39 int ci = 0;
40 for (; ci < cutLength; ci++) {
41 if (isZhCn(this->_text[ci])) {
42 ci += 2;
43 }
44 }
45 cutLength = ci;
46 }
47
48 this->_text = this->_text.substr(0, cutLength);
49 if (!overMaxLen)
50 this->_hashcode ^= (0x79b9 + (std::hash<std::string>{}(this->_text) << 5));
51 }
52
53 if (STATE_WITH_INDEX) {
54 this->_hashcode ^= ((0x79b9 + (std::hash<int>{}(this->_index) << 6)) << 1);
55 }
56 }
57
58 void Widget::initFormElement(const ElementPtr &element) {
59 if (element->getCheckable())

Callers

nothing calls this directly

Calls 7

initFormElementMethod · 0.95
isZhCnFunction · 0.85
isForceUseTextModelMethod · 0.80
lengthMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected