iOS Safari閱讀模式分析過程
本文為Safari閱讀模式分析過程記錄,沒有做很好的整理。最終的輸出見另一篇iOS Safari閱讀模式研究。
1. Break on evaluate
b JSC::evaluate(JSC::ExecState*, JSC::ScopeChainNode*, JSC::SourceCode const&, JSC::JSValue, JSC::JSValue*)
dump the source content from JSC::SourceCode
Printing description of source.m_provider.m_ptr->m_url:
(WTF::String) m_url = { length = 0, contents = '' } {
m_impl = {
m_ptr = 0x0000000000000000 { length = 0, is8bit = 0, contents = '' }
}
}
Printing description of source.m_provider.m_ptr->m_source:
(WTF::String) m_source = { length = 66370, contents = '/*
* Copyright © 2010 Apple Inc. All rights reserved.
*/
……
2. Call Stack
3. (lldb) image list
[ 0] 396DF4E9-18D6-3C39-B1FB-E783D7F9B947 0x00001000 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/Applications/MobileSafari.app/MobileSafari -> JSEvaluateScript
0x70224(0x702a5) ->
0x6fdc8(0x6fe19) ->
0x6fd9a(0x6fdb5) -> XREF:-[ReaderTestProcessor _processReaderTestResult:tabDocument:] & -[ReaderContext isReaderAvailable]
0x6eac5(0x6eae5) -> -[ReaderContext isReaderAvailable]
0xa3d84(0xa3dd3) -> XREF:-[TabDocument _detectReaderAvailabilityOnWebThread]
HandleRunSource
i. 查詢起點
3483 -> 0xa3d15 -[TabDocument _detectReaderAvailabilityOnWebThread]
3490 -> 0xa3f56(0xa404b) -[TabDocument _detectReaderAvailabilityNow]
ii. 誰發起了_detectReaderAvailabilityNow
-[BrowserController stopFromAddressView:]
-[TabDocument _progressDidStall]
-[TabDocument webView:didFinishLoadForFrame:]
-> -[TabDocument detectReaderAvailabilitySoon]
3496->0xa4279 -[TabDocument detectReaderAvailabilitySoon]
3274-> 0x9c16b (0x9c1ad) -[TabDocument webView:didFinishLoadForFrame:]
4. (FAILED)
b -[UIView setHidden:]
(lldb) showParameters 3
$56 = 0x09a43aa0 <ReaderButtonView: 0x1a39ca50; baseClass = UIButton; frame = (276 2; 49 27); alpha = 0; opaque = NO; layer = <CALayer: 0x1a398610>>
0x08d60840: "setHidden:"
$56 = 0x09a43aa0 <ReaderButtonView: 0x1a39ca50; baseClass = UIButton; frame = (276 2; 49 27); alpha = 0; opaque = NO; layer = <CALayer: 0x1a398610>>
0x08d60840: "setHidden:"
5.
b -[UIView setFrame:]
(lldb) showParameters 3$26 = 0x0a984730 <ReaderButtonView: 0x9af39d0; baseClass = UIButton; frame = (276 2; 49 27); alpha = 0; opaque = NO; layer = <CALayer: 0x9a6fb60>>
0x07b37881: "setFrame:"
0x07b3788b: "addSubview:"
96 -> 0x6d38 (0x6f9d): -[AddressView _layoutReloadButtonForProgressViewFrame:forEditing:textField:showInactiveFieldWhileEditing:]
257 -> 0x126a4 (0x1288a): -[AddressView layoutReaderButton]
3482 -> 0xa3927 (0xa3caf): -[TabDocument _didDetectReaderAvailability:]
3485 -> 0xa3e3f (0xa3e6b): (MEM:didDetectReaderAvailability)
-[AddressViewaccessibility(SafeCategory) layoutReaderButton]
6. (FAILED)
根據WebKit Objective-C Programming Guide, 獲取JS資料需要先獲取window物件:
id win = [webview windowScriptObject];
前且所有的JS物件是使用WebScriptObject包裝起來的。
Summary: WebCore`-[WebScriptObject valueForKey:] Address: WebCore[0x00d35b30] (WebCore.__TEXT.__text + 13843984)
(lldb) b WebCore`-[WebScriptObject valueForKey:]Breakpoint 14: where = WebCore`-[WebScriptObject valueForKey:], address = 0x03581700
7.
TabDocument::
- (void)_detectReaderAvailabilityNow; // IMP=0x000a3f56- (void)_detectReaderAvailabilityOnWebThread; // IMP=0x000a3d15
- (void)_didDetectReaderAvailability:(BOOL)arg1; // IMP=0x000a3927
8.
var ReaderArticleFinderJS = new ReaderArticleFinder(document);
6fdc8(6fe24) -> 1b3ba(1b3d6) -> isReaderModeAvailable
9. break at JSObjectGetProperty
(lldb) p/x `*(int*)($ebp+16)`(int) $33 = 0x000debdf
(lldb) mem read `$33`
0x000debdf: 69 73 52 65 61 64 65 72 4d 6f 64 65 41 76 61 69 isReaderModeAvai
0x000debef: 6c 61 62 6c 65 00 70 72 65 70 61 72 65 54 6f 54 lable.prepareToT
10. 還需要再獲取物件
450 -> 0x1b774(0x1b777) -> return ReaderArticleFinderJS
1656 -> 0x5a70c (0x5a76e) ->
2193 -> 0x70224 (0x70315) ->
2186 -> 0x6fdc8 (0x6fe19) ->
2185 ->0x6fd9a(0x6fdb5) -> XREF:-[ReaderTestProcessor _processReaderTestResult:tabDocument:] & -[ReaderContext isReaderAvailable]
2125 ->0x6eac5(0x6eae5) -> -[ReaderContext isReaderAvailable]
3484 -> 0xa3d84(0xa3dd3) -> XREF:-[TabDocument _detectReaderAvailabilityOnWebThread]
11. click the "Reader" button
0.
a.再次確認Reader Mode
2193->0x70224 (0x702a5)
2186->0x6fdc8(0x6fe19)
2195->0x70372(0x70387) WebThreadLock, call 6fdc8.
2146->0x6f3cd(0x6f3f1) -> -[ReaderContext createArticleFinder]
978-> 0x38445(0x384f5) [BrowserController setShowingReader:animated]
122 -> 0x995c(0x99bc) ->
bShowing = [[BrowserController sharedBrowserController] isShowingReader];
[[BrowserController sharedBrowserController] setShowingReader:bShowing animated:YES]
b. 顯示出內容
i.載入html檔案
-> loadRequest (Reader~ipad.html)
2132 ->0x6ee1e (0x6ee96) [ReaderContext loadReaderDocument]
2118 ->0x6e85b (0x6e959) [ReaderContext createWebViewIfNeeded]
3491->0xa4053 (0xa4097) [TabDocument createBrowserReaderViewIfNeeded]
979 ->0x38549 (0x38610) [BrowserController showReaderForTabDocument]
978-> 0x38445(0x38526) [BrowserController setShowingReader:animated]
122 ->0x995c(0x99bc)
bShowing = [[BrowserController sharedBrowserController] isShowingReader];
[[BrowserController sharedBrowserController] setShowingReader:bShowing animated:YES]
ii. 在WebView允許修改window object時,執行閱讀模式處理指令碼
2205 -> 0x705ce (0x7066f)
2127 -> 0x6eb17 (0x6eb62) -[ReaderContext initReaderJSController:]
1296 -> 0x4952c (0x49588) [BrowserReaderView uiWebView:didClearWindowObject:forFrame]
iii. 頁面載入後會執行JS:
<body class="preloading" onload="ReaderJS.loaded();" onscroll="articleHasScrolled();">
相關文章
- iOS Safari閱讀模式研究iOS模式
- 如何在Safari的閱讀檢視中開啟夜間模式?模式
- 如何更改Safari瀏覽器的閱讀樣式,使其更易於閱讀?瀏覽器
- spring原始碼閱讀--容器啟動過程Spring原始碼
- SOFAJRaft原始碼閱讀-模組啟動過程Raft原始碼
- 如何使Safari for Mac中的網頁更易於閱讀Mac網頁
- 主題閱讀-IT專案管理-CMMI過程改進專案管理
- iOS 系統分析(一) 閱讀核心準備知識iOS
- 如何讓Safari網頁中的內容更易於閱讀網頁
- TiCDC 原始碼閱讀(三)TiCDC 叢集工作過程解析原始碼
- Tomcat聯結器執行過程(原始碼閱讀)Tomcat原始碼
- 主題閱讀-IT專案管理-五大過程組專案管理
- 如何閱讀一本書——分析閱讀Pre
- iOS模式分析 策略模式iOS模式
- redis資料結構原始碼閱讀——字串編碼過程Redis資料結構原始碼字串編碼
- iOS PropertyList 文件閱讀記錄iOS
- iOS開發原始碼閱讀篇--FMDB原始碼分析1(FMResultSet)iOS原始碼
- iOS開發原始碼閱讀篇--FMDB原始碼分析2(FMResultSet)iOS原始碼
- Vuex原始碼閱讀分析Vue原始碼
- snabbdom 原始碼閱讀分析原始碼
- SpringBoot配置檔案讀取過程分析Spring Boot
- edge閱讀模式怎麼開啟 edge瀏覽器沉浸閱讀模式怎麼開啟模式瀏覽器
- HDFS讀檔案過程分析:讀取檔案的Block資料BloC
- 《流量的祕密》閱讀分析
- 家庭閱讀 數字時代下影響兒童閱讀的因素分析
- iOS開發原始碼閱讀篇--FMDB原始碼分析3(FMDatabaseQueue+FMDatabasePool)iOS原始碼Database
- goroutine排程原始碼閱讀筆記Go原始碼筆記
- iOSSafari(瀏覽器)iOS瀏覽器
- iOS 8.1.2 越獄過程詳解及相關漏洞分析iOS
- 【iOS印象】GLPubSub 原始碼閱讀筆記iOS原始碼筆記
- Vue原始碼閱讀--過濾器Vue原始碼過濾器
- Safari暗模式新增外掛:Noir Dark Mode for Safari Mac版模式Mac
- iOS App啟動過程iOSAPP
- Docker原始碼分析,附閱讀地址Docker原始碼
- 《重疊實驗框架》閱讀分析框架
- 如何實現一個HTTP請求庫——axios原始碼閱讀與分析HTTPiOS原始碼
- HDFS寫過程分析
- oracle邏輯讀過程Oracle