内核 变换焦点颜色 实现过程

本文介绍了Android Webview内核中焦点变换的颜色处理过程,包括`JZFocus`和`JZIPanel`类的功能,如设置和获取边框宽度,以及焦点显示的控制。代码示例展示了如何创建、销毁和管理焦点对象,以及如何根据配置改变焦点显示。
摘要由CSDN通过智能技术生成

扩展cpp

#include "config.h"

#include "JZFocus.h"
#include "WebCoreJni.h"


#include <jni.h>
#include <JNIHelp.h>
#include <JNIUtility.h>
#include <time.h>


#include <wtf/CurrentTime.h>
#include <wtf/text/AtomicString.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringImpl.h>


#define DEBUG                                                                                                                                         
#ifdef DEBUG
 
#include <android/log.h>
#undef XLOG
#define XLOG(...) __android_log_print(ANDROID_LOG_INFO, "JZIPanel", __VA_ARGS__)
#else
 
#undef XLOG
#define XLOG(...)
 
#endif // DEBUG 


namespace WebCore {
JZFocus::JZFocus(Frame* frame)
:m_borders(0)
{

}

JZFocus::~JZFocus()
{
}


void JZFocus::disconnectFrame()
{
}


void JZFocus::setBorders(const int border)
{
m_borders = border;
}


int JZFocus::borders() const
{
return m_borders;
}

}

头文件

#ifndef WebCore_JZFocus_h
#define WebCore_JZFocus_h


#include "PlatformString.h"                                                                                                                              
#include "Frame.h"


#include <jni.h>
#include <JNIHelp.h>
#include <JNIUtility.h>


#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/HashMap.h>
#include <wtf/RefPtr.h>


namespace WebCore{
class JZFocus : public RefCounted<JZFocus> {
public:
~JZFocus();
        
        static PassRefPtr<JZFocus> create(Frame* frame)
        {
            return adoptRef(new JZFocus(frame));
        }


        void disconnectFrame();


        void setBorders(const int width);
        int borders() const;


    private:
    JZFocus(Frame*);


        int m_borders;
};
} // namespace WebCore


#endif


对应idl 

module core {

interface [
OmitConstructor
] JZFocus {
attribute [CustomSetter] long borders;
};
}

ipanel.cpp

#include "config.h"
#include "JZIPanel.h"
#include "JZFocus.h"
#include "WebCoreJni.h"


#include <jni.h>
#include <JNIHelp.h>
#include <JNIUtility.h>
#include <time.h>


#include <wtf/CurrentTime.h>
#include <wtf/text/AtomicString.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringImpl.h>


#define DEBUG
#ifdef DEBUG


#include <android/log.h>
#undef XLOG
#define XLOG(...) __android_log_print(ANDROID_LOG_INFO, "WebView", __VA_ARGS__)
#else


#undef XLOG
#define XLOG(...)


#endif // DEBUG 


bool g_iPanelIsDrawFocusRing = true;


namespace WebCore {


JZIPanel::JZIPanel(Frame* frame)
:m_frame(frame)
,m_focusWidth("3")
{
    XLOG("%d, JZIPanel::JZIPanel()", __LINE__);
}

JZIPanel::~JZIPanel()
{
    XLOG("%d, JZIPanel::~JZIPanel()", __LINE__);
}


void JZIPanel::disconnectFrame()
{
    XLOG("%d, JZIPanel::disconnectFrame()", __LINE__);
    if(m_focusWidth == "0")
    g_iPanelIsDrawFocusRing = true;
    clear();
}


void JZIPanel::clear()
{

if (m_focus)
    m_focus->disconnectFrame();
m_focus = 0;
}


JZFocus* JZIPanel::focus() const
{
    if (!m_focus)
        m_focus = JZFocus::create(m_frame);
    return m_focus.get();
}


void JZIPanel::setfocusWidth(const String& width)
{
XLOG("%d, JZIPanel::setfocusWidth() width = %s", __LINE__, width.utf8().data());


m_focusWidth = width;
if(m_focusWidth == "-1" || m_focusWidth == "0")
g_iPanelIsDrawFocusRing = false;
else
g_iPanelIsDrawFocusRing = true;



}


String JZIPanel::focusWidth() const
{
XLOG("%d, JZIPanel::focusWidth() width = %s", __LINE__, m_focusWidth.utf8().data());
return m_focusWidth;
}


void JZIPanel::debug(String& info)
{
}

void JZIPanel::ioctlWrite(String& ctrol, String& detail)
{
globalVarMap.add(ctrol, detail);
}

String JZIPanel::ioctlRead(String& content)
{
XLOG("%d, JZIPanel::ioctlRead() content ---> %s", __LINE__, content.utf8().data());

HashMap<String, String>::iterator m_it = globalVarMap.find(conten

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值