📄 render_style.cpp
字号:
} else if (c1->_contentType == CONTENT_QUOTE) { if (c1->_content.quote != c2->_content.quote) 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(DOM::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 && lastContent) { 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;}void RenderStyle::setContent(DOM::CounterImpl* c, bool add){ if (!c) return; 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; c->ref(); newContentData->_content.counter = c; newContentData->_contentType = CONTENT_COUNTER;}void RenderStyle::setContent(EQuoteContent q, bool add){ if (q == NO_QUOTE) return; 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; newContentData->_content.quote = q; newContentData->_contentType = CONTENT_QUOTE;}void RenderStyle::setContentNormal() { delete content; content = 0;}void RenderStyle::setContentNone() { setContentNormal(); content = new ContentData;}ContentData::~ContentData(){ clearContent();}void ContentData::clearContent(){ delete _nextContent; _nextContent = 0; switch (_contentType) { case CONTENT_OBJECT: _content.object = 0; break; case CONTENT_TEXT: _content.text->deref(); _content.text = 0; break; case CONTENT_COUNTER: _content.counter->deref(); _content.counter = 0; break; case CONTENT_QUOTE: _content.quote = NO_QUOTE; break; default: ; }}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;}bool RenderStyle::counterDataEquivalent(RenderStyle* otherStyle){ // ### Should we compare content? return counter_reset == otherStyle->counter_reset && counter_increment == otherStyle->counter_increment;}static bool hasCounter(const DOM::DOMString& c, CSSValueListImpl *l){ int len = l->length(); for(int i=0; i<len; i++) { CounterActImpl* ca = static_cast<CounterActImpl*>(l->item(i)); Q_ASSERT(ca != 0); if (ca->m_counter == c) return true; } return false;}bool RenderStyle::hasCounterReset(const DOM::DOMString& c) const{ if (counter_reset) return hasCounter(c, counter_reset); else return false;}bool RenderStyle::hasCounterIncrement(const DOM::DOMString& c) const{ if (counter_increment) return hasCounter(c, counter_increment); else return false;}static short readCounter(const DOM::DOMString& c, CSSValueListImpl *l){ int len = l->length(); for(int i=0; i<len; i++) { CounterActImpl* ca = static_cast<CounterActImpl*>(l->item(i)); Q_ASSERT(ca != 0); if (ca->m_counter == c) return ca->m_value; } return 0;}short RenderStyle::counterReset(const DOM::DOMString& c) const{ if (counter_reset) return readCounter(c, counter_reset); else return 0;}short RenderStyle::counterIncrement(const DOM::DOMString& c) const{ if (counter_increment) return readCounter(c, counter_increment); else return 0;}void RenderStyle::setCounterReset(CSSValueListImpl *l){ CSSValueListImpl *t = counter_reset; counter_reset = l; if (l) l->ref(); if (t) t->deref();}void RenderStyle::setCounterIncrement(CSSValueListImpl *l){ CSSValueListImpl *t = counter_increment; counter_increment = l; if (l) l->ref(); if (t) t->deref();}#ifdef ENABLE_DUMPstatic QString describeFont( const QFont &f){ QString res = "'" + f.family() + "' "; if ( f.pointSize() > 0) res += QString::number( f.pointSize() ) + "pt"; else res += QString::number( f.pixelSize() ) + "px"; if ( f.bold() ) res += " bold"; if ( f.italic() ) res += " italic"; if ( f.underline() ) res += " underline"; if ( f.overline() ) res += " overline"; if ( f.strikeOut() ) res += " strikeout"; return res;}QString RenderStyle::createDiff( const RenderStyle &parent ) const{ QString res; if ( color().isValid() && parent.color() != color() ) res += " [color=" + color().name() + "]"; if ( backgroundColor().isValid() && parent.backgroundColor() != backgroundColor() ) res += " [bgcolor=" + backgroundColor().name() + "]"; if ( parent.font() != font() ) res += " [font=" + describeFont( font() ) + "]"; return res;}#endifRenderPageStyle::RenderPageStyle() : next(0), m_pageType(ANY_PAGE){}RenderPageStyle::~RenderPageStyle(){ delete next;}RenderPageStyle* RenderPageStyle::getPageStyle(PageType type){ RenderPageStyle *ps = 0; for (ps = this; ps; ps = ps->next) if (ps->m_pageType==type) break; return ps;}RenderPageStyle* RenderPageStyle::addPageStyle(PageType type){ RenderPageStyle *ps = getPageStyle(type); if (!ps) { ps = new RenderPageStyle(*this); // use the real copy constructor to get an identical copy ps->m_pageType = type; ps->next = next; next = ps; } return ps;}void RenderPageStyle::removePageStyle(PageType type){ RenderPageStyle *ps = next; RenderPageStyle *prev = this; while (ps) { if (ps->m_pageType==type) { prev->next = ps->next; delete ps; return; } prev = ps; ps = ps->next; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -