在Webkit中实现支持WML

Webkit里面,WML作为过时的技术,早已不支持了,但是国内运营商要求必须支持,呵呵,客户要求就是天,再落后也要支持,所以把以前支持WML相关代码全部拿回来,再一点一点适配到新版本上。酸爽,一点一点读代码,debug,终于搞定了。
贴出来部分修改的地方,因为本来就是基于opensource的,所以不存在confidential的问题。

Source/WebCore/css/CSSStyleSelector.cpp
// Important: Intrinsic margins get added to controls before the theme has adjusted the style, since the theme will
// alter fonts and heights/widths.
if (e && e->isFormControlElement() && style->fontSize() >= 11) {
// Don’t apply intrinsic margins to image buttons. The designer knows how big the images are,
// so we have to treat all image buttons as though they were explicitly sized.
if (!e->hasTagName(inputTag) || !static_cast<HTMLInputElement*>(e)->isImageButton()
#ifdef ENABLE(WML)
|| !e->hasTagName(WMLNames::inputTag)
#endif
)
addIntrinsicMargins(style);
}

Source/WebCore/editing/DeleteSelectionCommand.cpp

 // If the deletion is occurring in a text field, and we're not deleting to replace the selection, then let the frame call across the bridge to notify the form delegate. 
if (!m_replace) {
    Node* startNode = m_selectionToDelete.start().deprecatedNode();
    Node* ancestorNode = startNode ? startNode->shadowAncestorNode() : 0;
    if (ancestorNode && ancestorNode->hasTagName(inputTag)
            && static_cast<HTMLInputElement*>(ancestorNode)->isTextField()
            && ancestorNode->focused())
        document()->frame()->editor()->textWillBeDeletedInTextField(static_cast<Element*>(ancestorNode));

#if ENABLE(WML)
else if (ancestorNode && ancestorNode->hasTagName(WMLNames::inputTag)
&& static_cast<WMLInputElement*>(ancestorNode)->isTextField()
&& ancestorNode->focused())
document()->frame()->editor()->textWillBeDeletedInTextField(static_cast<Element*>(ancestorNode));
#endif
}

Source/WebCore/editing/ReplaceSelectionCommand.cpp

// Add spaces for smart replace.
if (m_smartReplace && currentRoot) {
    // Disable smart replace for password fields.
    Node* start = currentRoot->shadowAncestorNode();
    if (start->hasTagName(inputTag) && static_cast<HTMLInputElement*>(start)->isPasswordField())
        m_smartReplace = false;

#if ENABLE(WML)
else if (start->hasTagName(WMLNames::inputTag) && static_cast<WMLInputElement*>(start)->isPasswordField())
m_smartReplace = false;
#endif
}

Source/WebCore/editing/SelectionController.cpp
bool SelectionController::isInPasswordField() const
{
ASSERT(start().isNull() || start().anchorType() == Position::PositionIsOffsetInAnchor
|| start().containerNode() || !start().anchorNode()->

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值