IntPoint 描述一个点
有x、y两个变量,支持move、expandedTo、shrunkTo等方法
IntSize 描述一个大小
有width,height两个变量,支持scale、expand等接口
IntRect 描述一个巨星
有一个m_location和一个size,location是这个矩形左上角的坐标
right和bottom这个点,并不在这个矩形里面。
inflateX(int dx),向左右各扩x
intersect(IntRect other)求两个矩形的相交矩形
IntPoint Widget::
convertToContainingView(const IntPoint& localPoint)
对于Widget中一个点,这个点的位置是相对自己而言的。
函数目的是要得到这个点在其父窗口的位置,具体实现就是加上自身在父窗口位置。
比如Widget相对父窗口为(1,1),point相对自己为(2,2)
那么调用convertChildToSelf(widget, localPoint(2,2))
//传入child和child中的一个point,得到point在parent中位置
在其实现过程中,(2,2)moveto(1,1),返回(3,3)
IntPoint Widget::
convertToContainingWindow(const IntPoint& localPoint) const
对于Widget中的一个点,其坐标是相对widget而言,获取其在根窗口中的位置。
其实现,就是不停得调用上面的函数,直到parent为null
IntPoint Widget::
convertFromContainingView(const IntPoint& parentPoint) const
对于Widget中的一个点,这个点的位置是相对自己直接父类而言的。
函数目的是要得到这个点相对自己的位置,其实现就是用parentPoint减掉自己的位置。
IntPoint Widget::
convertFromContainingWindow(const IntPoint& windowPoint) const
对于一个Widget,传入一个相对根窗口的绝对位置的点,返回这个点在这个widget中的位置。
其实现是不停得减掉这个widget的ParentView的位置。
Widget
PlatformWidget m_widget;
在Android中为WebCoreViewBridge
ScrollView
viewPoint = contentsPoint - scrollOffset();
contentsPoint 只对于整个ScrollView而言
windowClipRect 返回一个区域
windowClipRectForLayer 返回一个与Layer相关区域
返回这2个Rect的交集
ClipRects
里面有三个IntRect
IntRect m_overflowClipRect;
IntRect m_fixedClipRect;
IntRect m_posClipRect;
PluginView::platformPluginWidget
返回
m_window,对于Android而言PluginWidgetAndroid
它包含了Android平台适配的成员和方法
pluginView、webViewCore、draw、sendEvent等等
不少是与skia有关的
SkIRect m_pluginBounds; // relative to the page
SkIRect m_visibleDocRect; // relative to the page
SkIRect m_requestedVisibleRect; // relative to the page
PlatformWidget
对于Android平台而言WebCoreViewBridge
里面有三个Rect
WebCore::IntRect m_bounds;
WebCore::IntRect m_windowBounds;
WebCore::IntRect m_visibleBounds;
PluginView
IntRect m_clipRect; // The clip rect to apply to a windowed plug-in
IntRect m_windowRect; // Our window rect.
IntRect m_pageRect;
PluginView
platformPluginWidget PluginWidgetAndroid
m_window
PlatformWidget WebCoreViewBridge
PluginMainThreadScheduler
Call 封装了一个函数指针和用户数据
performCall调用这个函数指针传入用户数据
PluginMainThreadScheduler 有一个“HashMap<NPP, Deque<Call> > CallQueueMap”的map
PluginMainThreadScheduler::registerPlugin(NPP npp)
在哈希map中加入NPP
PluginMainThreadScheduler::scheduleCall(NPP npp, MainThreadFunction function, void* userData)
在哈希map中找到NPP,加入function和userData,调用callOnMainThread
在主函数中调度。(会检查所有未执行的函数进行执行)
void PluginMainThreadScheduler::dispatchCallsForPlugin(NPP npp, const Deque<Call>& calls)
传入一个call队列,调用里面的函数。
void PluginMainThreadScheduler::dispatchCalls()
将map中的每一个队列取出,调用各个队列的各个call函数
Schedule process:
PluginMainThreadScheduler::scheduleCall(NPP npp,
MainThreadFunction function, void* userData)
-void callOnMainThread(MainThreadFunction*
function, void*
context)
functionQueue().append(
FunctionWithContext(function, context));
scheduleDispatchFunctionsOnMainThread
--MainThreadAndroid::scheduleDispatchFunctionsOnMainThread
AndroidThreading::scheduleDispatchFunctionsOnMainThread();
---PlatformBridge void AndroidThreading::scheduleDispatchFunctionsOnMainThread()
JavaSharedClient::EnqueueFunctionPtr(
timeoutFired, 0);
----void JavaSharedClient::EnqueueFunctionPtr(void (*
proc)(void*
payload),
void* payload)
gTimerClient->signalServiceFuncPtrQueue();
-----void JavaBridge::signalServiceFuncPtrQueue()
env->CallVoidMethod(obj.get(), mSignalFuncPtrQueue);
------JWebCoreJavaBridge .private void signalServiceFuncPtrQueue()
sendMessage(msg);//
key point, make sure run on the main thread
nativeServiceFuncPtrQueue
-------JavaBridge::ServiceFuncPtrQueue
JavaSharedClient::ServiceFunctionPtrQueue();
--------void JavaSharedClient::ServiceFunctionPtrQueue()
proc(payload);
---------
timeoutFired
dispatchFunctionsFromMainThread
----------dispatchFunctionsFromMainThread
invocation.function(invocation.context);