📄 render_style.cpp
字号:
/*
* This file is part of the DOM implementation for KDE.
*
* Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2004 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "xml/dom_stringimpl.h"
#include "render_style.h"
#include "css/cssstyleselector.h"
#include "render_arena.h"
#include "kdebug.h"
using namespace khtml;
using DOM::DOMStringImpl;
using DOM::DOMString;
StyleSurroundData::StyleSurroundData()
: margin( Fixed ), padding( Variable )
{
}
StyleSurroundData::StyleSurroundData(const StyleSurroundData& o )
: Shared<StyleSurroundData>(),
offset( o.offset ), margin( o.margin ), padding( o.padding ),
border( o.border )
{
}
bool StyleSurroundData::operator==(const StyleSurroundData& o) const
{
return offset==o.offset && margin==o.margin &&
padding==o.padding && border==o.border;
}
StyleBoxData::StyleBoxData()
: z_index( 0 ), z_auto(true)
{
// Initialize our min/max widths/heights.
min_width = min_height = RenderStyle::initialMinSize();
max_width = max_height = RenderStyle::initialMaxSize();
}
StyleBoxData::StyleBoxData(const StyleBoxData& o )
: Shared<StyleBoxData>(),
width( o.width ), height( o.height ),
min_width( o.min_width ), max_width( o.max_width ),
min_height ( o.min_height ), max_height( o.max_height ),
z_index( o.z_index ), z_auto( o.z_auto )
{
}
bool StyleBoxData::operator==(const StyleBoxData& o) const
{
return
width == o.width &&
height == o.height &&
min_width == o.min_width &&
max_width == o.max_width &&
min_height == o.min_height &&
max_height == o.max_height &&
z_index == o.z_index &&
z_auto == o.z_auto;
}
StyleVisualData::StyleVisualData()
: hasClip(false),
textDecoration(RenderStyle::initialTextDecoration()),
colspan( 1 ), counter_increment( 0 ), counter_reset( 0 )
#if !APPLE_CHANGES
, palette( QApplication::palette() )
#endif
{
}
StyleVisualData::~StyleVisualData() {
}
StyleVisualData::StyleVisualData(const StyleVisualData& o )
: Shared<StyleVisualData>(),
clip( o.clip ), hasClip( o.hasClip ), textDecoration(o.textDecoration), colspan( o.colspan ),
counter_increment( o.counter_increment ), counter_reset( o.counter_reset )
#if !APPLE_CHANGES
, palette( o.palette )
#endif
{
}
BackgroundLayer::BackgroundLayer()
:m_image(RenderStyle::initialBackgroundImage()),
m_bgAttachment(RenderStyle::initialBackgroundAttachment()),
m_bgRepeat(RenderStyle::initialBackgroundRepeat()),
m_next(0)
{
m_imageSet = m_attachmentSet = m_repeatSet = m_xPosSet = m_yPosSet = false;
}
BackgroundLayer::BackgroundLayer(const BackgroundLayer& o)
{
m_next = o.m_next ? new BackgroundLayer(*o.m_next) : 0;
m_image = o.m_image;
m_xPosition = o.m_xPosition;
m_yPosition = o.m_yPosition;
m_bgAttachment = o.m_bgAttachment;
m_bgRepeat = o.m_bgRepeat;
m_imageSet = o.m_imageSet;
m_attachmentSet = o.m_attachmentSet;
m_repeatSet = o.m_repeatSet;
m_xPosSet = o.m_xPosSet;
m_yPosSet = o.m_yPosSet;
}
BackgroundLayer::~BackgroundLayer()
{
delete m_next;
}
BackgroundLayer& BackgroundLayer::operator=(const BackgroundLayer& o) {
if (m_next != o.m_next) {
delete m_next;
m_next = o.m_next ? new BackgroundLayer(*o.m_next) : 0;
}
m_image = o.m_image;
m_xPosition = o.m_xPosition;
m_yPosition = o.m_yPosition;
m_bgAttachment = o.m_bgAttachment;
m_bgRepeat = o.m_bgRepeat;
m_imageSet = o.m_imageSet;
m_attachmentSet = o.m_attachmentSet;
m_repeatSet = o.m_repeatSet;
m_xPosSet = o.m_xPosSet;
m_yPosSet = o.m_yPosSet;
return *this;
}
bool BackgroundLayer::operator==(const BackgroundLayer& o) const {
return m_image == o.m_image && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition &&
m_bgAttachment == o.m_bgAttachment && m_bgRepeat == o.m_bgRepeat &&
m_imageSet == o.m_imageSet && m_attachmentSet == o.m_attachmentSet && m_repeatSet == o.m_repeatSet &&
m_xPosSet == o.m_xPosSet && m_yPosSet == o.m_yPosSet &&
((m_next && o.m_next) ? *m_next == *o.m_next : m_next == o.m_next);
}
void BackgroundLayer::fillUnsetProperties()
{
BackgroundLayer* curr;
for (curr = this; curr && curr->isBackgroundImageSet(); curr = curr->next());
if (curr && curr != this) {
// We need to fill in the remaining values with the pattern specified.
for (BackgroundLayer* pattern = this; curr; curr = curr->next()) {
curr->m_image = pattern->m_image;
pattern = pattern->next();
if (pattern == curr || !pattern)
pattern = this;
}
}
for (curr = this; curr && curr->isBackgroundXPositionSet(); curr = curr->next());
if (curr && curr != this) {
// We need to fill in the remaining values with the pattern specified.
for (BackgroundLayer* pattern = this; curr; curr = curr->next()) {
curr->m_xPosition = pattern->m_xPosition;
pattern = pattern->next();
if (pattern == curr || !pattern)
pattern = this;
}
}
for (curr = this; curr && curr->isBackgroundYPositionSet(); curr = curr->next());
if (curr && curr != this) {
// We need to fill in the remaining values with the pattern specified.
for (BackgroundLayer* pattern = this; curr; curr = curr->next()) {
curr->m_yPosition = pattern->m_yPosition;
pattern = pattern->next();
if (pattern == curr || !pattern)
pattern = this;
}
}
for (curr = this; curr && curr->isBackgroundAttachmentSet(); curr = curr->next());
if (curr && curr != this) {
// We need to fill in the remaining values with the pattern specified.
for (BackgroundLayer* pattern = this; curr; curr = curr->next()) {
curr->m_bgAttachment = pattern->m_bgAttachment;
pattern = pattern->next();
if (pattern == curr || !pattern)
pattern = this;
}
}
for (curr = this; curr && curr->isBackgroundRepeatSet(); curr = curr->next());
if (curr && curr != this) {
// We need to fill in the remaining values with the pattern specified.
for (BackgroundLayer* pattern = this; curr; curr = curr->next()) {
curr->m_bgRepeat = pattern->m_bgRepeat;
pattern = pattern->next();
if (pattern == curr || !pattern)
pattern = this;
}
}
}
void BackgroundLayer::cullEmptyLayers()
{
BackgroundLayer *next;
for (BackgroundLayer *p = this; p; p = next) {
next = p->m_next;
if (next && !next->isBackgroundImageSet() &&
!next->isBackgroundXPositionSet() && !next->isBackgroundYPositionSet() &&
!next->isBackgroundAttachmentSet() && !next->isBackgroundRepeatSet()) {
delete next;
p->m_next = 0;
break;
}
}
}
StyleBackgroundData::StyleBackgroundData()
{}
StyleBackgroundData::StyleBackgroundData(const StyleBackgroundData& o)
: Shared<StyleBackgroundData>(), m_background(o.m_background), m_outline(o.m_outline)
{}
bool StyleBackgroundData::operator==(const StyleBackgroundData& o) const
{
return m_background == o.m_background && m_color == o.m_color && m_outline == o.m_outline;
}
StyleMarqueeData::StyleMarqueeData()
{
increment = RenderStyle::initialMarqueeIncrement();
speed = RenderStyle::initialMarqueeSpeed();
direction = RenderStyle::initialMarqueeDirection();
behavior = RenderStyle::initialMarqueeBehavior();
loops = RenderStyle::initialMarqueeLoopCount();
}
StyleMarqueeData::StyleMarqueeData(const StyleMarqueeData& o)
:Shared<StyleMarqueeData>(), increment(o.increment), speed(o.speed), loops(o.loops),
behavior(o.behavior), direction(o.direction)
{}
bool StyleMarqueeData::operator==(const StyleMarqueeData& o) const
{
return (increment == o.increment && speed == o.speed && direction == o.direction &&
behavior == o.behavior && loops == o.loops);
}
StyleFlexibleBoxData::StyleFlexibleBoxData()
: Shared<StyleFlexibleBoxData>()
{
flex = RenderStyle::initialBoxFlex();
flex_group = RenderStyle::initialBoxFlexGroup();
ordinal_group = RenderStyle::initialBoxOrdinalGroup();
align = RenderStyle::initialBoxAlign();
pack = RenderStyle::initialBoxPack();
orient = RenderStyle::initialBoxOrient();
lines = RenderStyle::initialBoxLines();
}
StyleFlexibleBoxData::StyleFlexibleBoxData(const StyleFlexibleBoxData& o)
: Shared<StyleFlexibleBoxData>()
{
flex = o.flex;
flex_group = o.flex_group;
ordinal_group = o.ordinal_group;
align = o.align;
pack = o.pack;
orient = o.orient;
lines = o.lines;
}
bool StyleFlexibleBoxData::operator==(const StyleFlexibleBoxData& o) const
{
return flex == o.flex && flex_group == o.flex_group &&
ordinal_group == o.ordinal_group && align == o.align &&
pack == o.pack && orient == o.orient && lines == o.lines;
}
StyleCSS3NonInheritedData::StyleCSS3NonInheritedData()
:Shared<StyleCSS3NonInheritedData>(),
#if APPLE_CHANGES
lineClamp(RenderStyle::initialLineClamp()),
#endif
opacity(RenderStyle::initialOpacity()),
userDrag(RenderStyle::initialUserDrag()),
userSelect(RenderStyle::initialUserSelect()),
textOverflow(RenderStyle::initialTextOverflow()),
marginTopCollapse(MCOLLAPSE),
marginBottomCollapse(MCOLLAPSE)
#ifndef KHTML_NO_XBL
, bindingURI(0)
#endif
{
}
StyleCSS3NonInheritedData::StyleCSS3NonInheritedData(const StyleCSS3NonInheritedData& o)
:Shared<StyleCSS3NonInheritedData>(),
#if APPLE_CHANGES
lineClamp(o.lineClamp),
#endif
opacity(o.opacity), flexibleBox(o.flexibleBox), marquee(o.marquee),
userDrag(o.userDrag), userSelect(o.userSelect), textOverflow(o.textOverflow),
marginTopCollapse(o.marginTopCollapse), marginBottomCollapse(o.marginBottomCollapse)
{
#ifndef KHTML_NO_XBL
bindingURI = o.bindingURI ? o.bindingURI->copy() : 0;
#endif
}
StyleCSS3NonInheritedData::~StyleCSS3NonInheritedData()
{
#ifndef KHTML_NO_XBL
delete bindingURI;
#endif
}
#ifndef KHTML_NO_XBL
bool StyleCSS3NonInheritedData::bindingsEquivalent(const StyleCSS3NonInheritedData& o) const
{
if (this == &o) return true;
if (!bindingURI && o.bindingURI || bindingURI && !o.bindingURI)
return false;
if (bindingURI && o.bindingURI && (*bindingURI != *o.bindingURI))
return false;
return true;
}
#endif
bool StyleCSS3NonInheritedData::operator==(const StyleCSS3NonInheritedData& o) const
{
return opacity == o.opacity && flexibleBox == o.flexibleBox && marquee == o.marquee &&
userDrag == o.userDrag && userSelect == o.userSelect && textOverflow == o.textOverflow &&
marginTopCollapse == o.marginTopCollapse && marginBottomCollapse == o.marginBottomCollapse
#ifndef KHTML_NO_XBL
&& bindingsEquivalent(o)
#endif
#if APPLE_CHANGES
&& lineClamp == o.lineClamp && m_dashboardRegions == o.m_dashboardRegions
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -