欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

谷歌瀏覽器的源碼分析(10)

系統(tǒng) 2334 0
上一次已經(jīng)分析到輸入字符后,就需要把這些關(guān)鍵字去查找歷史的連接,或者相關(guān)的內(nèi)容,那么可多米的瀏覽器又是從那里去找到這些數(shù)據(jù)呢?現(xiàn)在就來(lái)分析這方面相關(guān)的內(nèi)容。它主要通下面的函數(shù)來(lái)實(shí)現(xiàn):

#001 ? void AutocompleteEdit::UpdatePopup() {

?

凍結(jié)輸入。

#002 ??? ScopedFreeze freeze(this, GetTextObjectModel());

?

設(shè)置正在輸入過(guò)程中。

#003 ??? SetInputInProgress(true);

#004 ?

?

如果輸入的 EDIT 框沒(méi)有焦點(diǎn),就直接返回。

#005 ??? if (!has_focus_) {

#006 ????? // When we're in the midst of losing focus, don't rerun autocomplete. ? This

#007 ????? // can happen when losing focus causes the IME to cancel/finalize a

#008 ????? // composition. ? We still want to note that user input is in progress, we

#009 ????? // just don't want to do anything else.

#010 ????? //

#011 ????? // Note that in this case the ScopedFreeze above was unnecessary; however,

#012 ????? // we're inside the callstack of OnKillFocus(), which has already frozen the

#013 ????? // edit, so this will never result in an unnecessary UpdateWindow() call.

#014 ????? return;

#015 ??? }

#016 ?

#017 ??? // Figure out whether the user is trying to compose something in an IME.

?

判斷是否從輸入法打開(kāi),如果是就從輸入法窗口里獲取字符串。

#018 ??? bool ime_composing = false;

#019 ??? HIMC context = ImmGetContext(m_hWnd);

#020 ??? if (context) {

#021 ????? ime_composing = !!ImmGetCompositionString(context, GCS_COMPSTR, NULL, 0);

#022 ????? ImmReleaseContext(m_hWnd, context);

#023 ??? }

#024 ?

#025 ??? // Don't inline autocomplete when:

#026 ??? // ?? * The user is deleting text

#027 ??? // ?? * The caret/selection isn't at the end of the text

#028 ??? // ?? * The user has just pasted in something that replaced all the text

#029 ??? // ?? * The user is trying to compose something in an IME

?

獲取當(dāng)前選擇的字符串。

#030 ??? CHARRANGE sel;

#031 ??? GetSel(sel);

?

根據(jù)用戶輸入的字符串來(lái)查找智能提示菜單的內(nèi)容。

#032 ??? popup_->StartAutocomplete(user_text_, GetDesiredTLD(),

#033 ??????? just_deleted_text_ || (sel.cpMax < GetTextLength()) ||

#034 ??????? (paste_state_ != NONE) || ime_composing);

#035 ? }

?

在這個(gè)函數(shù)里主要調(diào)用類 AutocompletePopupModel 的函數(shù) StartAutocomplete 來(lái)完成智能提示。而類 AutocompletePopupModel 的聲明如下:

class AutocompletePopupModel : public ACControllerListener, public Task {

? public:

? AutocompletePopupModel(const ChromeFont& font,

???????????????????????? AutocompleteEdit* editor,

???????????????????????? Profile* profile);

? ~AutocompletePopupModel();

從這個(gè)類里可以看到它是繼承類 ACControllerListener ,說(shuō)明它是響應(yīng)一個(gè)返回結(jié)果的監(jiān)聽(tīng)器;繼承類 Task 說(shuō)明它是一個(gè)任務(wù)線程類。由這兩個(gè)類可以看出,它是把關(guān)鍵字給一個(gè)線程,然后讓這個(gè)線程去查詢結(jié)果,當(dāng)結(jié)果返回時(shí),就再更新到顯示窗口里。

?

雖然上面理解它的查詢過(guò)程了,但是向誰(shuí)查詢呢?這是一個(gè)一定需要了解的問(wèn)題。現(xiàn)在就來(lái)分析類 AutocompleteController ,它在構(gòu)造函數(shù)時(shí),就會(huì)創(chuàng)建三個(gè)查詢的對(duì)象:

#001 ? AutocompleteController::AutocompleteController(ACControllerListener* listener,

#002 ???????????????????????????????????????????????? Profile* profile)

#003 ????? : listener_(listener) {

#004 ??? providers_.push_back(new SearchProvider (this, profile));

#005 ??? providers_.push_back(new HistoryURLProvider (this, profile));

#006 ??? keyword_provider_ = new KeywordProvider (this, profile);

#007 ??? providers_.push_back(keyword_provider_);

#008 ??? if (listener) {

#009 ????? // These providers are async-only, so there's no need to create them when

#010 ????? // we'll only be doing synchronous queries.

#011 ????? history_contents_provider_ = new HistoryContentsProvider (this, profile);

#012 ????? providers_.push_back(history_contents_provider_);

#013 ??? } else {

#014 ????? history_contents_provider_ = NULL;

#015 ??? }

#016 ??? for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i)

#017 ????? (*i)->AddRef();

#018 ? }

?

從上面的代碼,可以看到它是向 SearchProvider HistoryURLProvider KeywordProvider HistoryContentsProvider 來(lái)查找到合適的智能提示。類 SearchProvider 是從搜索引擎里查找合適的內(nèi)容;類 HistoryURLProvider 是從歷史的 URL 里查找合適的內(nèi)容;類 KeywordProvider 是從關(guān)鍵字搜索引擎里查找合適的內(nèi)容;類 HistoryContentsProvider 是從歷史內(nèi)容里查找合適內(nèi)容。從上面四種智能提示里,在以前的瀏覽器里一般只能做到從歷史的 URL 里提示,現(xiàn)在“可多米”可以做到從搜索引擎和關(guān)鍵字引擎里查找到相應(yīng)的結(jié)果回來(lái),可見(jiàn)它是智能提示完美的體現(xiàn),智能的水平可想而知了。這就是強(qiáng)大的云計(jì)算典型應(yīng)用,如果沒(méi)有強(qiáng)大的服務(wù)器群是做不到幾億人輸入關(guān)鍵字時(shí),還能快速返回結(jié)果的。

?

分析到這里,也許知道為什么 GOOGLE 開(kāi)發(fā)瀏覽器的原因了吧,如果其它瀏覽是不可能采用這樣的技術(shù)來(lái)分析用戶的輸入的,頂多是到歷史記錄里查找一下就算了。

?

雖然提供這么強(qiáng)大的搜索,它們又是怎么樣實(shí)現(xiàn)的呢?下一次再來(lái)分析它們。

谷歌瀏覽器的源碼分析(10)


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 日本激情在线视频 | 国产成人网 | 浮力影院最新地址 | 天天天天操 | 亚洲黄色片在线观看 | 欧美午夜a级限制福利片 | 温如玉二虎大结局1800 | 天堂在线网 | 亚洲三级在线 | 欧美午夜影院 | 二区在线视频 | 日韩女同一区二区三区 | 欧美自拍视频 | 国产视频大全 | 一区二区三区福利视频 | 性视频亚洲 | 日本三级不卡 | 一区二区高清 | 97色伦色在线综合视频 | 91精品久久久久久久久久 | 国产精品免费播放 | 91精品国产综合久久精品 | 久久精品久久精品国产大片 | 99精品丰满人妻无码A片 | 天天做天天爱夜夜大爽完整 | 色屁屁www影院免费观看软件 | 精品视频在线播放 | 日本理论片中文在线观看2828 | 成人18免费网站在线观看 | 一区二区久久 | 91麻豆精品国产91久久久更新时间 | 国产chinese中国hdxxxx | 欧美特黄aaaaaaaa大片 | 免费黄网站在线看 | 麻豆视频在线播放 | 8844aa在线毛片 | 色就是色欧美 | 国产精品国产成人国产三级 | 欧美不卡一区二区三区在线观看 | 综合色区 | 亚洲欧美日韩在线不卡中文 |