⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 render_style.cpp

📁 khtml在gtk上的移植版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* * This file is part of the DOM implementation for KDE. * * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) * Copyright (C) 2003 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 ),      palette( QApplication::palette() ){}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 ),      palette( o.palette ){}StyleBackgroundData::StyleBackgroundData()    : image( RenderStyle::initialBackgroundImage() ){}StyleBackgroundData::StyleBackgroundData(const StyleBackgroundData& o )    : Shared<StyleBackgroundData>(),      color( o.color ), image( o.image ),      x_position( o.x_position ), y_position( o.y_position ),      outline( o.outline ){}bool StyleBackgroundData::operator==(const StyleBackgroundData& o) const{    return	color == o.color &&	image == o.image &&	x_position == o.x_position &&	y_position == o.y_position &&	outline == o.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_CHANGESlineClamp(RenderStyle::initialLineClamp()),#endifopacity(RenderStyle::initialOpacity()),userDrag(RenderStyle::initialUserDrag()),userSelect(RenderStyle::initialUserSelect()),textOverflow(RenderStyle::initialTextOverflow())#ifndef KHTML_NO_XBL, bindingURI(0)#endif{}StyleCSS3NonInheritedData::StyleCSS3NonInheritedData(const StyleCSS3NonInheritedData& o):Shared<StyleCSS3NonInheritedData>(), #if APPLE_CHANGESlineClamp(o.lineClamp),#endifopacity(o.opacity), flexibleBox(o.flexibleBox), marquee(o.marquee),userDrag(o.userDrag), userSelect(o.userSelect), textOverflow(o.textOverflow){#ifndef KHTML_NO_XBL    bindingURI = o.bindingURI ? o.bindingURI->copy() : 0;#endif}StyleCSS3NonInheritedData::~StyleCSS3NonInheritedData(){#ifndef KHTML_NO_XBL    delete bindingURI;#endif}#ifndef KHTML_NO_XBLbool 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;}#endifbool 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#ifndef KHTML_NO_XBL           && bindingsEquivalent(o)#endif#if APPLE_CHANGES           && lineClamp == o.lineClamp#endif    ;}StyleCSS3InheritedData::StyleCSS3InheritedData():Shared<StyleCSS3InheritedData>(), textShadow(0), userModify(READ_ONLY)#if APPLE_CHANGES, textSizeAdjust(RenderStyle::initialTextSizeAdjust())#endif{}StyleCSS3InheritedData::StyleCSS3InheritedData(const StyleCSS3InheritedData& o):Shared<StyleCSS3InheritedData>(){    textShadow = o.textShadow ? new ShadowData(*o.textShadow) : 0;    userModify = o.userModify;#if APPLE_CHANGES    textSizeAdjust = o.textSizeAdjust;#endif}StyleCSS3InheritedData::~StyleCSS3InheritedData(){    delete textShadow;}bool StyleCSS3InheritedData::operator==(const StyleCSS3InheritedData& o) const{    return (userModify == o.userModify) && shadowDataEquivalent(o)#if APPLE_CHANGES            && (textSizeAdjust == o.textSizeAdjust)#endif    ;}bool StyleCSS3InheritedData::shadowDataEquivalent(const StyleCSS3InheritedData& o) const{    if (!textShadow && o.textShadow || textShadow && !o.textShadow)        return false;    if (textShadow && o.textShadow && (*textShadow != *o.textShadow))        return false;    return true;}StyleInheritedData::StyleInheritedData()    : indent( RenderStyle::initialTextIndent() ), line_height( RenderStyle::initialLineHeight() ),       style_image( RenderStyle::initialListStyleImage() ),      cursor_image( 0 ), font(), color( RenderStyle::initialColor() ),       horizontal_border_spacing( RenderStyle::initialHorizontalBorderSpacing() ),       vertical_border_spacing( RenderStyle::initialVerticalBorderSpacing() ),      widows( RenderStyle::initialWidows() ), orphans( RenderStyle::initialOrphans() ),      page_break_inside( RenderStyle::initialPageBreak() ){}StyleInheritedData::~StyleInheritedData(){}StyleInheritedData::StyleInheritedData(const StyleInheritedData& o )    : Shared<StyleInheritedData>(),      indent( o.indent ), line_height( o.line_height ), style_image( o.style_image ),      cursor_image( o.cursor_image ), font( o.font ),      color( o.color ),      horizontal_border_spacing( o.horizontal_border_spacing ),      vertical_border_spacing( o.vertical_border_spacing ),      widows(o.widows), orphans(o.orphans), page_break_inside(o.page_break_inside){}bool StyleInheritedData::operator==(const StyleInheritedData& o) const{    return	indent == o.indent &&	line_height == o.line_height &&	style_image == o.style_image &&	cursor_image == o.cursor_image &&	font == o.font &&	color == o.color &&        horizontal_border_spacing == o.horizontal_border_spacing &&        vertical_border_spacing == o.vertical_border_spacing &&        widows == o.widows &&        orphans == o.orphans &&        page_break_inside == o.page_break_inside;}// ----------------------------------------------------------void* RenderStyle::operator new(size_t sz, RenderArena* renderArena) throw(){    return renderArena->allocate(sz);}void RenderStyle::operator delete(void* ptr, size_t sz){    // Stash size where detach can find it.    *(size_t *)ptr = sz;}void RenderStyle::arenaDelete(RenderArena *arena){    RenderStyle *ps = pseudoStyle;    RenderStyle *prev = 0;        while (ps) {        prev = ps;        ps = ps->pseudoStyle;	// to prevent a double deletion.	// this works only because the styles below aren't really shared	// Dirk said we need another construct as soon as these are shared        prev->pseudoStyle = 0;        prev->deref(arena);    }    delete content;        delete this;        // Recover the size left there for us by operator delete and free the memory.    arena->free(*(size_t *)this, this);}RenderStyle::RenderStyle():m_pseudoState(PseudoUnknown), m_affectedByAttributeSelectors(false){    m_ref = 0;        if (!_default)	_default = ::new RenderStyle(true);    box = _default->box;    visual = _default->visual;    background = _default->background;    surround = _default->surround;    css3NonInheritedData = _default->css3NonInheritedData;    css3InheritedData = _default->css3InheritedData;        inherited = _default->inherited;    setBitDefaults();    pseudoStyle = 0;    content = 0;}RenderStyle::RenderStyle(bool):m_pseudoState(PseudoUnknown), m_affectedByAttributeSelectors(false){    setBitDefaults();    box.init();    visual.init();    background.init();    surround.init();    css3NonInheritedData.init();    css3NonInheritedData.access()->flexibleBox.init();    css3NonInheritedData.access()->marquee.init();    css3InheritedData.init();    inherited.init();    pseudoStyle = 0;    content = 0;    m_ref = 1;}RenderStyle::RenderStyle(const RenderStyle& o)    : inherited_flags( o.inherited_flags ), noninherited_flags( o.noninherited_flags ),      box( o.box ), visual( o.visual ), background( o.background ), surround( o.surround ),      css3NonInheritedData( o.css3NonInheritedData ), css3InheritedData( o.css3InheritedData ),      inherited( o.inherited ), pseudoStyle( 0 ), content( o.content ), m_pseudoState(o.m_pseudoState),      m_affectedByAttributeSelectors(false){    m_ref = 0;}void RenderStyle::inheritFrom(const RenderStyle* inheritParent){    css3InheritedData = inheritParent->css3InheritedData;    inherited = inheritParent->inherited;    inherited_flags = inheritParent->inherited_flags;}RenderStyle::~RenderStyle(){}bool RenderStyle::operator==(const RenderStyle& o) const{// compare everything except the pseudoStyle pointer    return (inherited_flags == o.inherited_flags &&            noninherited_flags == o.noninherited_flags &&	    box == o.box &&            visual == o.visual &&            background == o.background &&            surround == o.surround &&            css3NonInheritedData == o.css3NonInheritedData &&            css3InheritedData == o.css3InheritedData &&            inherited == o.inherited);}bool RenderStyle::isStyleAvailable() const{    return this != CSSStyleSelector::styleNotYetAvailable;}enum EPseudoBit { NO_BIT = 0x0, BEFORE_BIT = 0x1, AFTER_BIT = 0x2, FIRST_LINE_BIT = 0x4,                  FIRST_LETTER_BIT = 0x8, SELECTION_BIT = 0x10, FIRST_LINE_INHERITED_BIT = 0x20 };static int pseudoBit(RenderStyle::PseudoId pseudo){    switch (pseudo) {        case RenderStyle::BEFORE:            return BEFORE_BIT;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -