📄 render_style.cpp
字号:
// only for lists:
// EListStyleType _list_style_type : 5 ;
// EListStylePosition _list_style_position :1;
if (noninherited_flags._effectiveDisplay == LIST_ITEM ) {
if ( !(inherited_flags._list_style_type == other->inherited_flags._list_style_type) ||
!(inherited_flags._list_style_position == other->inherited_flags._list_style_position) )
return Layout;
}
// ### These could be better optimised
// ETextAlign _text_align : 3;
// ETextTransform _text_transform : 4;
// EDirection _direction : 1;
// EWhiteSpace _white_space : 2;
// EFontVariant _font_variant : 1;
// EClear _clear : 2;
if ( !(inherited_flags._text_align == other->inherited_flags._text_align) ||
!(inherited_flags._text_transform == other->inherited_flags._text_transform) ||
!(inherited_flags._direction == other->inherited_flags._direction) ||
!(inherited_flags._white_space == other->inherited_flags._white_space) ||
!(noninherited_flags._clear == other->noninherited_flags._clear)
)
return Layout;
// only for inline:
// EVerticalAlign _vertical_align : 4;
if ( !(noninherited_flags._effectiveDisplay == INLINE) &&
!(noninherited_flags._vertical_align == other->noninherited_flags._vertical_align))
return Layout;
// If our border widths change, then we need to layout. Other changes to borders
// only necessitate a repaint.
if (borderLeftWidth() != other->borderLeftWidth() ||
borderTopWidth() != other->borderTopWidth() ||
borderBottomWidth() != other->borderBottomWidth() ||
borderRightWidth() != other->borderRightWidth())
return Layout;
#if APPLE_CHANGES
// If regions change trigger a relayout to re-calc regions.
if (!(css3NonInheritedData->m_dashboardRegions == other->css3NonInheritedData->m_dashboardRegions))
return Layout;
#endif
// Make sure these left/top/right/bottom checks stay below all layout checks and above
// all visible checks.
if (other->position() != STATIC) {
if (!(surround->offset == other->surround->offset)) {
// FIXME: We will need to do a bit of work in RenderObject/Box::setStyle before we
// can stop doing a layout when relative positioned objects move. In particular, we'll need
// to update scrolling positions and figure out how to do a repaint properly of the updated layer.
//if (other->position() == RELATIVE)
// return RepaintLayer;
//else
return Layout;
}
else if (box->z_index != other->box->z_index || box->z_auto != other->box->z_auto ||
!(visual->clip == other->visual->clip) || visual->hasClip != other->visual->hasClip)
return RepaintLayer;
}
if (css3NonInheritedData->opacity != other->css3NonInheritedData->opacity)
return RepaintLayer;
// Repaint:
// EVisibility _visibility : 2;
// EOverflow _overflow : 4 ;
// int _text_decoration : 4;
// DataRef<StyleBackgroundData> background;
if (inherited->color != other->inherited->color ||
!(inherited_flags._visibility == other->inherited_flags._visibility) ||
!(noninherited_flags._overflow == other->noninherited_flags._overflow) ||
!(inherited_flags._text_decorations == other->inherited_flags._text_decorations) ||
!(inherited_flags._force_backgrounds_to_white == other->inherited_flags._force_backgrounds_to_white) ||
!(surround->border == other->surround->border) ||
*background.get() != *other->background.get() ||
visual->textDecoration != other->visual->textDecoration ||
!css3InheritedData->shadowDataEquivalent(*other->css3InheritedData.get()) ||
css3InheritedData->userModify != other->css3InheritedData->userModify ||
css3NonInheritedData->userSelect != other->css3NonInheritedData->userSelect ||
css3NonInheritedData->userDrag != other->css3NonInheritedData->userDrag
#if !APPLE_CHANGES
|| !(visual->palette == other->visual->palette)
#endif
)
return Repaint;
return Equal;
}
RenderStyle* RenderStyle::_default = 0;
//int RenderStyle::counter = 0;
//int SharedData::counter = 0;
void RenderStyle::cleanup()
{
delete _default;
_default = 0;
// counter = 0;
// SharedData::counter = 0;
}
#if !APPLE_CHANGES
void RenderStyle::setPaletteColor(QPalette::ColorGroup g, QColorGroup::ColorRole r, const QColor& c)
{
visual.access()->palette.setColor(g,r,c);
}
#endif
void RenderStyle::adjustBackgroundLayers()
{
if (backgroundLayers()->next()) {
// First we cull out layers that have no properties set.
accessBackgroundLayers()->cullEmptyLayers();
// Next we repeat patterns into layers that don't have some properties set.
accessBackgroundLayers()->fillUnsetProperties();
}
}
void RenderStyle::setClip( Length top, Length right, Length bottom, Length left )
{
StyleVisualData *data = visual.access();
data->clip.top = top;
data->clip.right = right;
data->clip.bottom = bottom;
data->clip.left = left;
}
bool RenderStyle::contentDataEquivalent(RenderStyle* otherStyle)
{
ContentData* c1 = content;
ContentData* c2 = otherStyle->content;
while (c1 && c2) {
if (c1->_contentType != c2->_contentType)
return false;
if (c1->_contentType == CONTENT_TEXT) {
DOMString c1Str(c1->_content.text);
DOMString c2Str(c2->_content.text);
if (c1Str != c2Str)
return false;
}
else if (c1->_contentType == CONTENT_OBJECT) {
if (c1->_content.object != c2->_content.object)
return false;
}
c1 = c1->_nextContent;
c2 = c2->_nextContent;
}
return !c1 && !c2;
}
void RenderStyle::setContent(CachedObject* o, bool add)
{
if (!o)
return; // The object is null. Nothing to do. Just bail.
ContentData* lastContent = content;
while (lastContent && lastContent->_nextContent)
lastContent = lastContent->_nextContent;
bool reuseContent = !add;
ContentData* newContentData = 0;
if (reuseContent && content) {
content->clearContent();
newContentData = content;
}
else
newContentData = new ContentData;
if (lastContent && !reuseContent)
lastContent->_nextContent = newContentData;
else
content = newContentData;
// o->ref();
newContentData->_content.object = o;
newContentData->_contentType = CONTENT_OBJECT;
}
void RenderStyle::setContent(DOMStringImpl* s, bool add)
{
if (!s)
return; // The string is null. Nothing to do. Just bail.
ContentData* lastContent = content;
while (lastContent && lastContent->_nextContent)
lastContent = lastContent->_nextContent;
bool reuseContent = !add;
if (add) {
if (!lastContent)
return; // Something's wrong. We had no previous content, and we should have.
if (lastContent->_contentType == CONTENT_TEXT) {
// We can augment the existing string and share this ContentData node.
DOMStringImpl* oldStr = lastContent->_content.text;
DOMStringImpl* newStr = oldStr->copy();
newStr->ref();
oldStr->deref();
newStr->append(s);
lastContent->_content.text = newStr;
return;
}
}
ContentData* newContentData = 0;
if (reuseContent && content) {
content->clearContent();
newContentData = content;
}
else
newContentData = new ContentData;
if (lastContent && !reuseContent)
lastContent->_nextContent = newContentData;
else
content = newContentData;
newContentData->_content.text = s;
newContentData->_content.text->ref();
newContentData->_contentType = CONTENT_TEXT;
}
ContentData::~ContentData()
{
clearContent();
}
void ContentData::clearContent()
{
delete _nextContent;
_nextContent = 0;
switch (_contentType)
{
case CONTENT_OBJECT:
// _content.object->deref();
_content.object = 0;
break;
case CONTENT_TEXT:
_content.text->deref();
_content.text = 0;
default:
;
}
}
#ifndef KHTML_NO_XBL
BindingURI::BindingURI(DOM::DOMStringImpl* uri)
:m_next(0)
{
m_uri = uri;
if (uri) uri->ref();
}
BindingURI::~BindingURI()
{
if (m_uri)
m_uri->deref();
delete m_next;
}
BindingURI* BindingURI::copy()
{
BindingURI* newBinding = new BindingURI(m_uri);
if (next()) {
BindingURI* nextCopy = next()->copy();
newBinding->setNext(nextCopy);
}
return newBinding;
}
bool BindingURI::operator==(const BindingURI& o) const
{
if ((m_next && !o.m_next) || (!m_next && o.m_next) ||
(m_next && o.m_next && *m_next != *o.m_next))
return false;
if (m_uri == o.m_uri)
return true;
if (!m_uri || !o.m_uri)
return false;
return DOMString(m_uri) == DOMString(o.m_uri);
}
void RenderStyle::addBindingURI(DOM::DOMStringImpl* uri)
{
BindingURI* binding = new BindingURI(uri);
if (!bindingURIs())
SET_VAR(css3NonInheritedData, bindingURI, binding)
else
for (BindingURI* b = bindingURIs(); b; b = b->next()) {
if (!b->next())
b->setNext(binding);
}
}
#endif
void RenderStyle::setTextShadow(ShadowData* val, bool add)
{
StyleCSS3InheritedData* css3Data = css3InheritedData.access();
if (!add) {
delete css3Data->textShadow;
css3Data->textShadow = val;
return;
}
ShadowData* last = css3Data->textShadow;
while (last->next) last = last->next;
last->next = val;
}
ShadowData::ShadowData(const ShadowData& o)
:x(o.x), y(o.y), blur(o.blur), color(o.color)
{
next = o.next ? new ShadowData(*o.next) : 0;
}
bool ShadowData::operator==(const ShadowData& o) const
{
if ((next && !o.next) || (!next && o.next) ||
(next && o.next && *next != *o.next))
return false;
return x == o.x && y == o.y && blur == o.blur && color == o.color;
}
const QValueList<StyleDashboardRegion>& RenderStyle::initialDashboardRegions()
{
static QValueList<StyleDashboardRegion> emptyList;
return emptyList;
}
const QValueList<StyleDashboardRegion>& RenderStyle::noneDashboardRegions()
{
static QValueList<StyleDashboardRegion> noneList;
static bool noneListInitialized = false;
if (!noneListInitialized) {
StyleDashboardRegion region;
region.label = "";
region.offset.top = Length();
region.offset.right = Length();
region.offset.bottom = Length();
region.offset.left = Length();
region.type = StyleDashboardRegion::None;
noneList.append (region);
noneListInitialized = true;
}
return noneList;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -