Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: sky/engine/core/rendering/style/RenderStyle.cpp

Issue 709213002: Remove ContentData. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/rendering/style/RenderStyle.h" 24 #include "core/rendering/style/RenderStyle.h"
25 25
26 #include <algorithm> 26 #include <algorithm>
27 #include "core/css/resolver/StyleResolver.h" 27 #include "core/css/resolver/StyleResolver.h"
28 #include "core/rendering/RenderTheme.h" 28 #include "core/rendering/RenderTheme.h"
29 #include "core/rendering/style/AppliedTextDecoration.h" 29 #include "core/rendering/style/AppliedTextDecoration.h"
30 #include "core/rendering/style/ContentData.h"
31 #include "core/rendering/style/DataEquivalency.h" 30 #include "core/rendering/style/DataEquivalency.h"
32 #include "core/rendering/style/QuotesData.h" 31 #include "core/rendering/style/QuotesData.h"
33 #include "core/rendering/style/ShadowList.h" 32 #include "core/rendering/style/ShadowList.h"
34 #include "core/rendering/style/StyleImage.h" 33 #include "core/rendering/style/StyleImage.h"
35 #include "core/rendering/style/StyleInheritedData.h" 34 #include "core/rendering/style/StyleInheritedData.h"
36 #include "platform/LengthFunctions.h" 35 #include "platform/LengthFunctions.h"
37 #include "platform/RuntimeEnabledFeatures.h" 36 #include "platform/RuntimeEnabledFeatures.h"
38 #include "platform/fonts/Font.h" 37 #include "platform/fonts/Font.h"
39 #include "platform/fonts/FontSelector.h" 38 #include "platform/fonts/FontSelector.h"
40 #include "platform/geometry/FloatRoundedRect.h" 39 #include "platform/geometry/FloatRoundedRect.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 139
141 StyleRecalcChange RenderStyle::stylePropagationDiff(const RenderStyle* oldStyle, const RenderStyle* newStyle) 140 StyleRecalcChange RenderStyle::stylePropagationDiff(const RenderStyle* oldStyle, const RenderStyle* newStyle)
142 { 141 {
143 if ((!oldStyle && newStyle) || (oldStyle && !newStyle)) 142 if ((!oldStyle && newStyle) || (oldStyle && !newStyle))
144 return Reattach; 143 return Reattach;
145 144
146 if (!oldStyle && !newStyle) 145 if (!oldStyle && !newStyle)
147 return NoChange; 146 return NoChange;
148 147
149 if (oldStyle->display() != newStyle->display() 148 if (oldStyle->display() != newStyle->display()
150 || !oldStyle->contentDataEquivalent(newStyle)
151 || oldStyle->justifyItems() != newStyle->justifyItems() 149 || oldStyle->justifyItems() != newStyle->justifyItems()
152 || oldStyle->alignItems() != newStyle->alignItems()) 150 || oldStyle->alignItems() != newStyle->alignItems())
153 return Reattach; 151 return Reattach;
154 152
155 if (*oldStyle == *newStyle) 153 if (*oldStyle == *newStyle)
156 return NoChange; 154 return NoChange;
157 155
158 if (oldStyle->inheritedNotEqual(newStyle) 156 if (oldStyle->inheritedNotEqual(newStyle)
159 || oldStyle->hasExplicitlyInheritedProperties() 157 || oldStyle->hasExplicitlyInheritedProperties()
160 || newStyle->hasExplicitlyInheritedProperties()) 158 || newStyle->hasExplicitlyInheritedProperties())
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 { 553 {
556 rareInheritedData.access()->quotes = q; 554 rareInheritedData.access()->quotes = q;
557 } 555 }
558 556
559 void RenderStyle::clearCursorList() 557 void RenderStyle::clearCursorList()
560 { 558 {
561 if (rareInheritedData->cursorData) 559 if (rareInheritedData->cursorData)
562 rareInheritedData.access()->cursorData = nullptr; 560 rareInheritedData.access()->cursorData = nullptr;
563 } 561 }
564 562
565 void RenderStyle::clearContent()
566 {
567 if (rareNonInheritedData->m_content)
568 rareNonInheritedData.access()->m_content = nullptr;
569 }
570
571 void RenderStyle::appendContent(PassOwnPtr<ContentData> contentData)
572 {
573 OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
574 ContentData* lastContent = content.get();
575 while (lastContent && lastContent->next())
576 lastContent = lastContent->next();
577
578 if (lastContent)
579 lastContent->setNext(contentData);
580 else
581 content = contentData;
582 }
583
584 void RenderStyle::setContent(PassRefPtr<StyleImage> image, bool add)
585 {
586 if (!image)
587 return;
588
589 if (add) {
590 appendContent(ContentData::create(image));
591 return;
592 }
593
594 rareNonInheritedData.access()->m_content = ContentData::create(image);
595 }
596
597 void RenderStyle::setContent(const String& string, bool add)
598 {
599 OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content;
600 if (add) {
601 ContentData* lastContent = content.get();
602 while (lastContent && lastContent->next())
603 lastContent = lastContent->next();
604
605 if (lastContent) {
606 // We attempt to merge with the last ContentData if possible.
607 if (lastContent->isText()) {
608 TextContentData* textContent = toTextContentData(lastContent);
609 textContent->setText(textContent->text() + string);
610 } else
611 lastContent->setNext(ContentData::create(string));
612
613 return;
614 }
615 }
616
617 content = ContentData::create(string);
618 }
619
620 WebBlendMode RenderStyle::blendMode() const 563 WebBlendMode RenderStyle::blendMode() const
621 { 564 {
622 if (RuntimeEnabledFeatures::cssCompositingEnabled()) 565 if (RuntimeEnabledFeatures::cssCompositingEnabled())
623 return static_cast<WebBlendMode>(rareNonInheritedData->m_effectiveBlendM ode); 566 return static_cast<WebBlendMode>(rareNonInheritedData->m_effectiveBlendM ode);
624 return WebBlendModeNormal; 567 return WebBlendModeNormal;
625 } 568 }
626 569
627 void RenderStyle::setBlendMode(WebBlendMode v) 570 void RenderStyle::setBlendMode(WebBlendMode v)
628 { 571 {
629 if (RuntimeEnabledFeatures::cssCompositingEnabled()) 572 if (RuntimeEnabledFeatures::cssCompositingEnabled())
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 // right 1318 // right
1376 radiiSum = radii.topRight().height() + radii.bottomRight().height(); 1319 radiiSum = radii.topRight().height() + radii.bottomRight().height();
1377 if (radiiSum > rect.height()) 1320 if (radiiSum > rect.height())
1378 factor = std::min(rect.height() / radiiSum, factor); 1321 factor = std::min(rect.height() / radiiSum, factor);
1379 1322
1380 ASSERT(factor <= 1); 1323 ASSERT(factor <= 1);
1381 return factor; 1324 return factor;
1382 } 1325 }
1383 1326
1384 } // namespace blink 1327 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/style/RenderStyle.h ('k') | sky/engine/core/rendering/style/StyleRareNonInheritedData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698