在浏览器中需要将body透明,而body上面的控件或者字等不透明,寻找了很久。现在终于找到了,记录下来备用,原因在于webkit浏览器的内核在判断body是否有背景色的时候,如果alpha为0.会将其背景改为baseclor,就不再透明了。
在RenderBoxModelObject.cpp文件中有函数 :
voidRenderBoxModelObject::paintFillLayerExtended()中有如下注释:
// If we have an alpha and we are paintingthe root element, go ahead and blend with the base background color.
如果我们画的是根元素,就不管他的背景这些,直接用basecolor代替他的背景色。
since iframes/frames with no background inthe child document should show the parent's background.
没有背景的元素,使用父元素的背景代替。
Color baseColor =view()->frameView()->baseBackgroundColor();
可以直接修改这个baseColor,如果修改为baseColor = Color::transparent;这样一来所有页面的背景都透明了。
当然这需要各个平台的支持。
由于我也新手,也是无奈开始转向这个,不妥的还请指出,以增长见识。