📄 render_style.h
字号:
DOM::DOMStringImpl* text; // counters... } _content ; ContentData* _nextContent;};//------------------------------------------------enum EDisplay { INLINE, BLOCK, LIST_ITEM, RUN_IN, COMPACT, INLINE_BLOCK, TABLE, INLINE_TABLE, TABLE_ROW_GROUP, TABLE_HEADER_GROUP, TABLE_FOOTER_GROUP, TABLE_ROW, TABLE_COLUMN_GROUP, TABLE_COLUMN, TABLE_CELL, TABLE_CAPTION, BOX, INLINE_BOX, NONE};class RenderStyle{ friend class CSSStyleSelector;public: static void cleanup(); // static pseudo styles. Dynamic ones are produced on the fly. enum PseudoId { NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION, FIRST_LINE_INHERITED }; void ref() { m_ref++; } void deref(RenderArena* arena) { if (m_ref) m_ref--; if (!m_ref) arenaDelete(arena); } bool hasOneRef() { return m_ref==1; } int refCount() const { return m_ref; } // Overloaded new operator. Derived classes must override operator new // in order to allocate out of the RenderArena. void* operator new(size_t sz, RenderArena* renderArena) throw(); // Overridden to prevent the normal delete from being called. void operator delete(void* ptr, size_t sz); private: void arenaDelete(RenderArena *arena);protected:// !START SYNC!: Keep this in sync with the copy constructor in render_style.cpp // inherit struct InheritedFlags { bool operator==( const InheritedFlags &other ) const { return (_empty_cells == other._empty_cells) && (_caption_side == other._caption_side) && (_list_style_type == other._list_style_type) && (_list_style_position == other._list_style_position) && (_visibility == other._visibility) && (_text_align == other._text_align) && (_text_transform == other._text_transform) && (_text_decorations == other._text_decorations) && (_text_transform == other._text_transform) && (_cursor_style == other._cursor_style) && (_direction == other._direction) && (_border_collapse == other._border_collapse) && (_white_space == other._white_space) && (_box_direction == other._box_direction) && (_visuallyOrdered == other._visuallyOrdered) && (_htmlHacks == other._htmlHacks) && (_should_correct_text_color == other._should_correct_text_color); } bool operator!=( const InheritedFlags &other ) const { return !(*this == other); } EEmptyCell _empty_cells : 1 ; ECaptionSide _caption_side : 2; EListStyleType _list_style_type : 5 ; EListStylePosition _list_style_position :1; EVisibility _visibility : 2; ETextAlign _text_align : 4; ETextTransform _text_transform : 2; int _text_decorations : 4; ECursor _cursor_style : 4; EDirection _direction : 1; bool _border_collapse : 1 ; EWhiteSpace _white_space : 2; EBoxDirection _box_direction : 1; // CSS3 box_direction property (flexible box layout module) // non CSS2 inherited bool _visuallyOrdered : 1; bool _htmlHacks :1; bool _should_correct_text_color : 1; } inherited_flags;// don't inherit struct NonInheritedFlags { bool operator==( const NonInheritedFlags &other ) const { return (_effectiveDisplay == other._effectiveDisplay) && (_originalDisplay == other._originalDisplay) && (_bg_repeat == other._bg_repeat) && (_overflow == other._overflow) && (_vertical_align == other._vertical_align) && (_clear == other._clear) && (_position == other._position) && (_floating == other._floating) && (_table_layout == other._table_layout) && (_page_break_before == other._page_break_before) && (_page_break_after == other._page_break_after) && (_styleType == other._styleType) && (_affectedByHover == other._affectedByHover) && (_affectedByActive == other._affectedByActive) && (_affectedByDrag == other._affectedByDrag) && (_pseudoBits == other._pseudoBits) && (_unicodeBidi == other._unicodeBidi); } bool operator!=( const NonInheritedFlags &other ) const { return !(*this == other); } EDisplay _effectiveDisplay : 5; EDisplay _originalDisplay : 5; EBackgroundRepeat _bg_repeat : 2; bool _bg_attachment : 1; EOverflow _overflow : 4 ; EVerticalAlign _vertical_align : 4; EClear _clear : 2; EPosition _position : 2; EFloat _floating : 2; ETableLayout _table_layout : 1; EPageBreak _page_break_before : 2; EPageBreak _page_break_after : 2; PseudoId _styleType : 3; bool _affectedByHover : 1; bool _affectedByActive : 1; bool _affectedByDrag : 1; int _pseudoBits : 6; EUnicodeBidi _unicodeBidi : 2; } noninherited_flags;// non-inherited attributes DataRef<StyleBoxData> box; DataRef<StyleVisualData> visual; DataRef<StyleBackgroundData> background; DataRef<StyleSurroundData> surround; DataRef<StyleCSS3NonInheritedData> css3NonInheritedData; // inherited attributes DataRef<StyleCSS3InheritedData> css3InheritedData; DataRef<StyleInheritedData> inherited; // list of associated pseudo styles RenderStyle* pseudoStyle; // added this here, so we can get rid of the vptr in this class. // makes up for the same size. ContentData *content; PseudoState m_pseudoState : 3; bool m_affectedByAttributeSelectors : 1; int m_ref; // !END SYNC!// static default style static RenderStyle* _default;protected: void setBitDefaults() { inherited_flags._empty_cells = initialEmptyCells(); inherited_flags._caption_side = initialCaptionSide(); inherited_flags._list_style_type = initialListStyleType(); inherited_flags._list_style_position = initialListStylePosition(); inherited_flags._visibility = initialVisibility(); inherited_flags._text_align = initialTextAlign(); inherited_flags._text_transform = initialTextTransform(); inherited_flags._text_decorations = initialTextDecoration(); inherited_flags._cursor_style = initialCursor(); inherited_flags._direction = initialDirection(); inherited_flags._border_collapse = initialBorderCollapse(); inherited_flags._white_space = initialWhiteSpace(); inherited_flags._visuallyOrdered = false; inherited_flags._htmlHacks=false; inherited_flags._box_direction = initialBoxDirection(); inherited_flags._should_correct_text_color = false; noninherited_flags._effectiveDisplay = noninherited_flags._originalDisplay = initialDisplay(); noninherited_flags._bg_repeat = initialBackgroundRepeat(); noninherited_flags._bg_attachment = initialBackgroundAttachment(); noninherited_flags._overflow = initialOverflow(); noninherited_flags._vertical_align = initialVerticalAlign(); noninherited_flags._clear = initialClear(); noninherited_flags._position = initialPosition(); noninherited_flags._floating = initialFloating(); noninherited_flags._table_layout = initialTableLayout(); noninherited_flags._page_break_before = initialPageBreak(); noninherited_flags._page_break_after = initialPageBreak(); noninherited_flags._styleType = NOPSEUDO; noninherited_flags._affectedByHover = false; noninherited_flags._affectedByActive = false; noninherited_flags._affectedByDrag = false; noninherited_flags._pseudoBits = 0; noninherited_flags._unicodeBidi = initialUnicodeBidi(); }public: RenderStyle(); // used to create the default style. RenderStyle(bool); RenderStyle(const RenderStyle&); ~RenderStyle(); void inheritFrom(const RenderStyle* inheritParent); PseudoId styleType() { return noninherited_flags._styleType; } RenderStyle* getPseudoStyle(PseudoId pi); void addPseudoStyle(RenderStyle* pseudo); bool affectedByHoverRules() const { return noninherited_flags._affectedByHover; } bool affectedByActiveRules() const { return noninherited_flags._affectedByActive; } bool affectedByDragRules() const { return noninherited_flags._affectedByDrag; } void setAffectedByHoverRules(bool b) { noninherited_flags._affectedByHover = b; } void setAffectedByActiveRules(bool b) { noninherited_flags._affectedByActive = b; } void setAffectedByDragRules(bool b) { noninherited_flags._affectedByDrag = b; } bool operator==(const RenderStyle& other) const; bool isFloating() const { return !(noninherited_flags._floating == FNONE); } bool hasMargin() const { return surround->margin.nonZero(); } bool hasBorder() const { return surround->border.hasBorder(); } bool hasOffset() const { return surround->offset.nonZero(); } bool visuallyOrdered() const { return inherited_flags._visuallyOrdered; } void setVisuallyOrdered(bool b) { inherited_flags._visuallyOrdered = b; } bool isStyleAvailable() const; bool hasPseudoStyle(PseudoId pseudo) const; void setHasPseudoStyle(PseudoId pseudo); // attribute getter methods EDisplay display() const { return noninherited_flags._effectiveDisplay; } EDisplay originalDisplay() const { return noninherited_flags._originalDisplay; } Length left() const { return surround->offset.left; } Length right() const { return surround->offset.right; } Length top() const { return surround->offset.top; } Length bottom() const { return surround->offset.bottom; } EPosition position() const { return noninherited_flags._position; } EFloat floating() const { return noninherited_flags._floating; } Length width() const { return box->width; } Length height() const { return box->height; } Length minWidth() const { return box->min_width; } Length maxWidth() const { return box->max_width; } Length minHeight() const { return box->min_height; } Length maxHeight() const { return box->max_height; } const BorderValue& borderLeft() const { return surround->border.left; } const BorderValue& borderRight() const { return surround->border.right; } const BorderValue& borderTop() const { return surround->border.top; } const BorderValue& borderBottom() const { return surround->border.bottom; } unsigned short borderLeftWidth() const { if( surround->border.left.style == BNONE || surround->border.left.style == BHIDDEN) return 0; return surround->border.left.width; } EBorderStyle borderLeftStyle() const { return surround->border.left.style; } const QColor & borderLeftColor() const { return surround->border.left.color; } bool borderLeftIsTransparent() const { return surround->border.left.isTransparent(); } unsigned short borderRightWidth() const { if (surround->border.right.style == BNONE || surround->border.right.style == BHIDDEN) return 0; return surround->border.right.width; } EBorderStyle borderRightStyle() const { return surround->border.right.style; } const QColor & borderRightColor() const { return surround->border.right.color; } bool borderRightIsTransparent() const { return surround->border.right.isTransparent(); } unsigned short borderTopWidth() const { if(surround->border.top.style == BNONE || surround->border.top.style == BHIDDEN) return 0; return surround->border.top.width; } EBorderStyle borderTopStyle() const {return surround->border.top.style; } const QColor & borderTopColor() const { return surround->border.top.color; } bool borderTopIsTransparent() const { return surround->border.top.isTransparent(); } unsigned short borderBottomWidth() const { if(surround->border.bottom.style == BNONE || surround->border.bottom.style == BHIDDEN) return 0; return surround->border.bottom.width; } EBorderStyle borderBottomStyle() const { return surround->border.bottom.style; } const QColor & borderBottomColor() const { return surround->border.bottom.color; } bool borderBottomIsTransparent() const { return surround->border.bottom.isTransparent(); } unsigned short outlineSize() const { return outlineWidth() + outlineOffset(); } unsigned short outlineWidth() const { if (background->outline.style == BNONE || background->outline.style == BHIDDEN) return 0; return background->outline.width; } EBorderStyle outlineStyle() const { return background->outline.style; } bool outlineStyleIsAuto() const { return background->outline._auto; } const QColor & outlineColor() const { return background->outline.color; } EOverflow overflow() const { return noninherited_flags._overflow; } EVisibility visibility() const { return inherited_flags._visibility; } EVerticalAlign verticalAlign() const { return noninherited_flags._vertical_align; } Length verticalAlignLength() const { return box->vertical_align; } Length clipLeft() const { return visual->clip.left; } Length clipRight() const { return visual->clip.right; } Length clipTop() const { return visual->clip.top; } Length clipBottom() const { return visual->clip.bottom; } bool hasClip() const { return visual->hasClip; } EUnicodeBidi unicodeBidi() const { return noninherited_flags._unicodeBidi; } EClear clear() const { return noninherited_flags._clear; } ETableLayout tableLayout() const { return noninherited_flags._table_layout; } short colSpan() const { return visual->colspan; } const QFont & font() const { return inherited->font.f; } // use with care. call font->update() after modifications const Font &htmlFont() { return inherited->font; } const QFontMetrics & fontMetrics() const { return inherited->font.fm; } const QColor & color() const { return inherited->color; } Length textIndent() const { return inherited->indent; } ETextAlign textAlign() const { return inherited_flags._text_align; } ETextTransform textTransform() const { return inherited_flags._text_transform; } int textDecorationsInEffect() const { return inherited_flags._text_decorations; } int textDecoration() const { return visual->textDecoration; } int wordSpacing() const { return inherited->font.wordSpacing; } int letterSpacing() const { return inherited->font.letterSpacing; } EDirection direction() const { return inherited_flags._direction; } Length lineHeight() const { return inherited->line_height; } EWhiteSpace whiteSpace() const { return inherited_flags._white_space; } const QColor & backgroundColor() const { return background->color; } CachedImage *backgroundImage() const { return background->image; } EBackgroundRepeat backgroundRepeat() const { return noninherited_flags._bg_repeat; } bool backgroundAttachment() const { return noninherited_flags._bg_attachment; } Length backgroundXPosition() const { return background->x_position; } Length backgroundYPosition() const { return background->y_position; } // returns true for collapsing borders, false for separate borders bool borderCollapse() const { return inherited_flags._border_collapse; } short horizontalBorderSpacing() const { return inherited->horizontal_border_spacing; } short verticalBorderSpacing() const { return inherited->vertical_border_spacing; } EEmptyCell emptyCells() const { return inherited_flags._empty_cells; } ECaptionSide captionSide() const { return inherited_flags._caption_side; } short counterIncrement() const { return visual->counter_increment; } short counterReset() const { return visual->counter_reset; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -