Chromium Code Reviews

Side by Side Diff: Source/core/rendering/RenderBlock.h

Issue 22972002: Finish making FloatingObject a real class with private members (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/rendering/RenderBlock.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All r ights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All r ights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 636 matching lines...)
647 , rect(LayoutRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginWidth(), f->height() + f->marginHeight())) 647 , rect(LayoutRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginWidth(), f->height() + f->marginHeight()))
648 , everHadLayout(f->everHadLayout()) 648 , everHadLayout(f->everHadLayout())
649 { 649 {
650 } 650 }
651 651
652 RenderBox* object; 652 RenderBox* object;
653 LayoutRect rect; 653 LayoutRect rect;
654 bool everHadLayout; 654 bool everHadLayout;
655 }; 655 };
656 656
657 struct FloatingObject { 657 class FloatingObject {
658 WTF_MAKE_NONCOPYABLE(FloatingObject); WTF_MAKE_FAST_ALLOCATED; 658 WTF_MAKE_NONCOPYABLE(FloatingObject); WTF_MAKE_FAST_ALLOCATED;
659 public: 659 public:
660 // Note that Type uses bits so you can use FloatLeftRight as a mask to q uery for both left and right. 660 // Note that Type uses bits so you can use FloatLeftRight as a mask to q uery for both left and right.
661 enum Type { FloatLeft = 1, FloatRight = 2, FloatLeftRight = 3 }; 661 enum Type { FloatLeft = 1, FloatRight = 2, FloatLeftRight = 3 };
662 662
663 FloatingObject(EFloat type) 663 FloatingObject(EFloat type)
664 : m_renderer(0) 664 : m_renderer(0)
665 , m_originatingLine(0) 665 , m_originatingLine(0)
666 , m_paginationStrut(0) 666 , m_paginationStrut(0)
667 , m_shouldPaint(true) 667 , m_shouldPaint(true)
(...skipping 51 matching lines...)
719 inline LayoutUnit height() const { return m_frameRect.height(); } 719 inline LayoutUnit height() const { return m_frameRect.height(); }
720 720
721 void setX(LayoutUnit x) { ASSERT(!isInPlacedTree()); m_frameRect.setX(x) ; } 721 void setX(LayoutUnit x) { ASSERT(!isInPlacedTree()); m_frameRect.setX(x) ; }
722 void setY(LayoutUnit y) { ASSERT(!isInPlacedTree()); m_frameRect.setY(y) ; } 722 void setY(LayoutUnit y) { ASSERT(!isInPlacedTree()); m_frameRect.setY(y) ; }
723 void setWidth(LayoutUnit width) { ASSERT(!isInPlacedTree()); m_frameRect .setWidth(width); } 723 void setWidth(LayoutUnit width) { ASSERT(!isInPlacedTree()); m_frameRect .setWidth(width); }
724 void setHeight(LayoutUnit height) { ASSERT(!isInPlacedTree()); m_frameRe ct.setHeight(height); } 724 void setHeight(LayoutUnit height) { ASSERT(!isInPlacedTree()); m_frameRe ct.setHeight(height); }
725 725
726 const LayoutRect& frameRect() const { ASSERT(isPlaced()); return m_frame Rect; } 726 const LayoutRect& frameRect() const { ASSERT(isPlaced()); return m_frame Rect; }
727 void setFrameRect(const LayoutRect& frameRect) { ASSERT(!isInPlacedTree( )); m_frameRect = frameRect; } 727 void setFrameRect(const LayoutRect& frameRect) { ASSERT(!isInPlacedTree( )); m_frameRect = frameRect; }
728 728
729 int paginationStrut() const { return m_paginationStrut; }
730 void setPaginationStrut(int strut) { m_paginationStrut = strut; }
731
729 #ifndef NDEBUG 732 #ifndef NDEBUG
730 bool isInPlacedTree() const { return m_isInPlacedTree; } 733 bool isInPlacedTree() const { return m_isInPlacedTree; }
731 void setIsInPlacedTree(bool value) { m_isInPlacedTree = value; } 734 void setIsInPlacedTree(bool value) { m_isInPlacedTree = value; }
732 #endif 735 #endif
733 736
734 bool shouldPaint() const { return m_shouldPaint; } 737 bool shouldPaint() const { return m_shouldPaint; }
735 void setShouldPaint(bool shouldPaint) { m_shouldPaint = shouldPaint; } 738 void setShouldPaint(bool shouldPaint) { m_shouldPaint = shouldPaint; }
736 bool isDescendant() const { return m_isDescendant; } 739 bool isDescendant() const { return m_isDescendant; }
737 void setIsDescendant(bool isDescendant) { m_isDescendant = isDescendant; } 740 void setIsDescendant(bool isDescendant) { m_isDescendant = isDescendant; }
738 741
742 // FIXME: Callers of these methods are dangerous and should be whitelist ed explicitly or removed.
743 void setRenderer(RenderBox* renderer) { m_renderer = renderer; }
744 RootInlineBox* originatingLine() const { return m_originatingLine; }
745 void setOriginatingLine(RootInlineBox* line) { m_originatingLine = line; }
746
747 private:
739 RenderBox* m_renderer; 748 RenderBox* m_renderer;
740 RootInlineBox* m_originatingLine; 749 RootInlineBox* m_originatingLine;
741 LayoutRect m_frameRect; 750 LayoutRect m_frameRect;
742 int m_paginationStrut; 751 int m_paginationStrut; // FIXME: Is this class size-sensitive? Does this need 32-bits?
743 752
744 private:
745 unsigned m_type : 2; // Type (left or right aligned) 753 unsigned m_type : 2; // Type (left or right aligned)
746 unsigned m_shouldPaint : 1; 754 unsigned m_shouldPaint : 1;
747 unsigned m_isDescendant : 1; 755 unsigned m_isDescendant : 1;
748 unsigned m_isPlaced : 1; 756 unsigned m_isPlaced : 1;
749 #ifndef NDEBUG 757 #ifndef NDEBUG
750 unsigned m_isInPlacedTree : 1; 758 unsigned m_isInPlacedTree : 1;
751 #endif 759 #endif
752 }; 760 };
753 761
754 LayoutPoint flipFloatForWritingModeForChild(const FloatingObject*, const Lay outPoint&) const; 762 LayoutPoint flipFloatForWritingModeForChild(const FloatingObject*, const Lay outPoint&) const;
(...skipping 387 matching lines...)
1142 1150
1143 virtual bool canCollapseAnonymousBlockChild() const { return true; } 1151 virtual bool canCollapseAnonymousBlockChild() const { return true; }
1144 1152
1145 public: 1153 public:
1146 LayoutUnit offsetFromLogicalTopOfFirstPage() const; 1154 LayoutUnit offsetFromLogicalTopOfFirstPage() const;
1147 RenderRegion* regionAtBlockOffset(LayoutUnit) const; 1155 RenderRegion* regionAtBlockOffset(LayoutUnit) const;
1148 RenderRegion* clampToStartAndEndRegions(RenderRegion*) const; 1156 RenderRegion* clampToStartAndEndRegions(RenderRegion*) const;
1149 1157
1150 protected: 1158 protected:
1151 struct FloatingObjectHashFunctions { 1159 struct FloatingObjectHashFunctions {
1152 static unsigned hash(FloatingObject* key) { return DefaultHash<RenderBox *>::Hash::hash(key->m_renderer); } 1160 static unsigned hash(FloatingObject* key) { return DefaultHash<RenderBox *>::Hash::hash(key->renderer()); }
1153 static bool equal(FloatingObject* a, FloatingObject* b) { return a->m_re nderer == b->m_renderer; } 1161 static bool equal(FloatingObject* a, FloatingObject* b) { return a->rend erer() == b->renderer(); }
1154 static const bool safeToCompareToEmptyOrDeleted = true; 1162 static const bool safeToCompareToEmptyOrDeleted = true;
1155 }; 1163 };
1156 struct FloatingObjectHashTranslator { 1164 struct FloatingObjectHashTranslator {
1157 static unsigned hash(RenderBox* key) { return DefaultHash<RenderBox*>::H ash::hash(key); } 1165 static unsigned hash(RenderBox* key) { return DefaultHash<RenderBox*>::H ash::hash(key); }
1158 static bool equal(FloatingObject* a, RenderBox* b) { return a->m_rendere r == b; } 1166 static bool equal(FloatingObject* a, RenderBox* b) { return a->renderer( ) == b; }
1159 }; 1167 };
1160 typedef ListHashSet<FloatingObject*, 4, FloatingObjectHashFunctions> Floatin gObjectSet; 1168 typedef ListHashSet<FloatingObject*, 4, FloatingObjectHashFunctions> Floatin gObjectSet;
1161 typedef FloatingObjectSet::const_iterator FloatingObjectSetIterator; 1169 typedef FloatingObjectSet::const_iterator FloatingObjectSetIterator;
1162 typedef PODInterval<int, FloatingObject*> FloatingObjectInterval; 1170 typedef PODInterval<int, FloatingObject*> FloatingObjectInterval;
1163 typedef PODIntervalTree<int, FloatingObject*> FloatingObjectTree; 1171 typedef PODIntervalTree<int, FloatingObject*> FloatingObjectTree;
1164 typedef PODFreeListArena<PODRedBlackTree<FloatingObjectInterval>::Node> Inte rvalArena; 1172 typedef PODFreeListArena<PODRedBlackTree<FloatingObjectInterval>::Node> Inte rvalArena;
1165 1173
1166 template <FloatingObject::Type FloatTypeValue> 1174 template <FloatingObject::Type FloatTypeValue>
1167 class FloatIntervalSearchAdapter { 1175 class FloatIntervalSearchAdapter {
1168 public: 1176 public:
(...skipping 173 matching lines...)
1342 static String string(const int value); 1350 static String string(const int value);
1343 }; 1351 };
1344 template<> struct ValueToString<RenderBlock::FloatingObject*> { 1352 template<> struct ValueToString<RenderBlock::FloatingObject*> {
1345 static String string(const RenderBlock::FloatingObject*); 1353 static String string(const RenderBlock::FloatingObject*);
1346 }; 1354 };
1347 #endif 1355 #endif
1348 1356
1349 } // namespace WebCore 1357 } // namespace WebCore
1350 1358
1351 #endif // RenderBlock_h 1359 #endif // RenderBlock_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/rendering/RenderBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine