| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 bool isPositioned() const { return m_bitfields.isPositioned(); } | 335 bool isPositioned() const { return m_bitfields.isPositioned(); } |
| 336 | 336 |
| 337 bool isText() const { return m_bitfields.isText(); } | 337 bool isText() const { return m_bitfields.isText(); } |
| 338 bool isBox() const { return m_bitfields.isBox(); } | 338 bool isBox() const { return m_bitfields.isBox(); } |
| 339 bool isInline() const { return m_bitfields.isInline(); } // inline object | 339 bool isInline() const { return m_bitfields.isInline(); } // inline object |
| 340 bool isDragging() const { return m_bitfields.isDragging(); } | 340 bool isDragging() const { return m_bitfields.isDragging(); } |
| 341 bool isReplaced() const { return m_bitfields.isReplaced(); } // a "replaced"
element (see CSS) | 341 bool isReplaced() const { return m_bitfields.isReplaced(); } // a "replaced"
element (see CSS) |
| 342 | 342 |
| 343 bool hasLayer() const { return m_bitfields.hasLayer(); } | 343 bool hasLayer() const { return m_bitfields.hasLayer(); } |
| 344 | 344 |
| 345 // "Box decoration background" includes all box decorations and backgrounds | 345 bool hasBoxDecorationBackground() const { return m_bitfields.hasBoxDecoratio
nBackground(); } |
| 346 // that are painted as the background of the object. It includes borders, | |
| 347 // box-shadows, background-color and background-image, etc. | |
| 348 enum BoxDecorationBackgroundState { | |
| 349 NoBoxDecorationBackground, | |
| 350 HasBoxDecorationBackgroundObscurationStatusInvalid, | |
| 351 HasBoxDecorationBackgroundKnownToBeObscured, | |
| 352 HasBoxDecorationBackgroundMayBeVisible, | |
| 353 }; | |
| 354 bool hasBoxDecorationBackground() const { return m_bitfields.boxDecorationBa
ckgroundState() != NoBoxDecorationBackground; } | |
| 355 bool boxDecorationBackgroundIsKnownToBeObscured(); | |
| 356 bool canRenderBorderImage() const; | 346 bool canRenderBorderImage() const; |
| 357 bool hasBackground() const { return style()->hasBackground(); } | 347 bool hasBackground() const { return style()->hasBackground(); } |
| 358 bool hasEntirelyFixedBackground() const; | 348 bool hasEntirelyFixedBackground() const; |
| 359 | 349 |
| 360 bool needsLayoutBecauseOfChildren() const { return needsLayout() && !selfNee
dsLayout() && !needsPositionedMovementLayout() && !needsSimplifiedNormalFlowLayo
ut(); } | 350 bool needsLayoutBecauseOfChildren() const { return needsLayout() && !selfNee
dsLayout() && !needsPositionedMovementLayout() && !needsSimplifiedNormalFlowLayo
ut(); } |
| 361 | 351 |
| 362 bool needsLayout() const | 352 bool needsLayout() const |
| 363 { | 353 { |
| 364 return m_bitfields.selfNeedsLayout() || m_bitfields.normalChildNeedsLayo
ut() || m_bitfields.posChildNeedsLayout() | 354 return m_bitfields.selfNeedsLayout() || m_bitfields.normalChildNeedsLayo
ut() || m_bitfields.posChildNeedsLayout() |
| 365 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.need
sPositionedMovementLayout(); | 355 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.need
sPositionedMovementLayout(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 428 |
| 439 void setPositionState(EPosition position) | 429 void setPositionState(EPosition position) |
| 440 { | 430 { |
| 441 ASSERT(position != AbsolutePosition || isBox()); | 431 ASSERT(position != AbsolutePosition || isBox()); |
| 442 m_bitfields.setPositionedState(position); | 432 m_bitfields.setPositionedState(position); |
| 443 } | 433 } |
| 444 void clearPositionedState() { m_bitfields.clearPositionedState(); } | 434 void clearPositionedState() { m_bitfields.clearPositionedState(); } |
| 445 | 435 |
| 446 void setInline(bool isInline) { m_bitfields.setIsInline(isInline); } | 436 void setInline(bool isInline) { m_bitfields.setIsInline(isInline); } |
| 447 | 437 |
| 448 void setHasBoxDecorationBackground(bool); | |
| 449 void invalidateBackgroundObscurationStatus(); | |
| 450 virtual bool computeBackgroundIsKnownToBeObscured() { return false; } | |
| 451 | |
| 452 void setIsText() { m_bitfields.setIsText(true); } | 438 void setIsText() { m_bitfields.setIsText(true); } |
| 453 void setIsBox() { m_bitfields.setIsBox(true); } | 439 void setIsBox() { m_bitfields.setIsBox(true); } |
| 454 void setReplaced(bool isReplaced) { m_bitfields.setIsReplaced(isReplaced); } | 440 void setReplaced(bool isReplaced) { m_bitfields.setIsReplaced(isReplaced); } |
| 455 void setHasOverflowClip(bool hasOverflowClip) { m_bitfields.setHasOverflowCl
ip(hasOverflowClip); } | 441 void setHasOverflowClip(bool hasOverflowClip) { m_bitfields.setHasOverflowCl
ip(hasOverflowClip); } |
| 456 void setHasLayer(bool hasLayer) { m_bitfields.setHasLayer(hasLayer); } | 442 void setHasLayer(bool hasLayer) { m_bitfields.setHasLayer(hasLayer); } |
| 457 void setHasTransform(bool hasTransform) { m_bitfields.setHasTransform(hasTra
nsform); } | 443 void setHasTransform(bool hasTransform) { m_bitfields.setHasTransform(hasTra
nsform); } |
| 444 void setHasBoxDecorationBackground(bool b) { m_bitfields.setHasBoxDecoration
Background(b); } |
| 458 | 445 |
| 459 void scheduleRelayout(); | 446 void scheduleRelayout(); |
| 460 | 447 |
| 461 void updateFillImages(const FillLayer* oldLayers, const FillLayer& newLayers
); | 448 void updateFillImages(const FillLayer* oldLayers, const FillLayer& newLayers
); |
| 462 void updateImage(StyleImage*, StyleImage*); | 449 void updateImage(StyleImage*, StyleImage*); |
| 463 | 450 |
| 464 // paintOffset is the offset from the origin of the GraphicsContext at which
to paint the current object. | 451 // paintOffset is the offset from the origin of the GraphicsContext at which
to paint the current object. |
| 465 virtual void paint(PaintInfo&, const LayoutPoint& paintOffset); | 452 virtual void paint(PaintInfo&, const LayoutPoint& paintOffset); |
| 466 | 453 |
| 467 // Subclasses must reimplement this method to compute the size and position | 454 // Subclasses must reimplement this method to compute the size and position |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 , m_childNeedsOverflowRecalcAfterStyleChange(false) | 762 , m_childNeedsOverflowRecalcAfterStyleChange(false) |
| 776 , m_isAnonymous(!node) | 763 , m_isAnonymous(!node) |
| 777 , m_isText(false) | 764 , m_isText(false) |
| 778 , m_isBox(false) | 765 , m_isBox(false) |
| 779 , m_isInline(true) | 766 , m_isInline(true) |
| 780 , m_isReplaced(false) | 767 , m_isReplaced(false) |
| 781 , m_isDragging(false) | 768 , m_isDragging(false) |
| 782 , m_hasLayer(false) | 769 , m_hasLayer(false) |
| 783 , m_hasOverflowClip(false) | 770 , m_hasOverflowClip(false) |
| 784 , m_hasTransform(false) | 771 , m_hasTransform(false) |
| 772 , m_hasBoxDecorationBackground(false) |
| 785 , m_everHadLayout(false) | 773 , m_everHadLayout(false) |
| 786 , m_ancestorLineBoxDirty(false) | 774 , m_ancestorLineBoxDirty(false) |
| 787 , m_alwaysCreateLineBoxesForRenderInline(false) | 775 , m_alwaysCreateLineBoxesForRenderInline(false) |
| 788 , m_positionedState(IsStaticallyPositioned) | 776 , m_positionedState(IsStaticallyPositioned) |
| 789 , m_selectionState(SelectionNone) | 777 , m_selectionState(SelectionNone) |
| 790 , m_boxDecorationBackgroundState(NoBoxDecorationBackground) | |
| 791 { | 778 { |
| 792 } | 779 } |
| 793 | 780 |
| 794 // 32 bits have been used in the first word, and 11 in the second. | 781 // 32 bits have been used in the first word, and 11 in the second. |
| 795 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout); | 782 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout); |
| 796 ADD_BOOLEAN_BITFIELD(onlyNeededPositionedMovementLayout, OnlyNeededPosit
ionedMovementLayout); | 783 ADD_BOOLEAN_BITFIELD(onlyNeededPositionedMovementLayout, OnlyNeededPosit
ionedMovementLayout); |
| 797 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO
fChildren); | 784 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO
fChildren); |
| 798 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovem
entLayout); | 785 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovem
entLayout); |
| 799 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout); | 786 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout); |
| 800 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout); | 787 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout); |
| 801 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNor
malFlowLayout); | 788 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNor
malFlowLayout); |
| 802 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidths
Dirty); | 789 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidths
Dirty); |
| 803 ADD_BOOLEAN_BITFIELD(selfNeedsOverflowRecalcAfterStyleChange, SelfNeedsO
verflowRecalcAfterStyleChange); | 790 ADD_BOOLEAN_BITFIELD(selfNeedsOverflowRecalcAfterStyleChange, SelfNeedsO
verflowRecalcAfterStyleChange); |
| 804 ADD_BOOLEAN_BITFIELD(childNeedsOverflowRecalcAfterStyleChange, ChildNeed
sOverflowRecalcAfterStyleChange); | 791 ADD_BOOLEAN_BITFIELD(childNeedsOverflowRecalcAfterStyleChange, ChildNeed
sOverflowRecalcAfterStyleChange); |
| 805 | 792 |
| 806 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous); | 793 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous); |
| 807 ADD_BOOLEAN_BITFIELD(isText, IsText); | 794 ADD_BOOLEAN_BITFIELD(isText, IsText); |
| 808 ADD_BOOLEAN_BITFIELD(isBox, IsBox); | 795 ADD_BOOLEAN_BITFIELD(isBox, IsBox); |
| 809 ADD_BOOLEAN_BITFIELD(isInline, IsInline); | 796 ADD_BOOLEAN_BITFIELD(isInline, IsInline); |
| 810 ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced); | 797 ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced); |
| 811 ADD_BOOLEAN_BITFIELD(isDragging, IsDragging); | 798 ADD_BOOLEAN_BITFIELD(isDragging, IsDragging); |
| 812 | 799 |
| 813 ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer); | 800 ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer); |
| 814 ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); // Set in the ca
se of overflow:auto/scroll/hidden | 801 ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); // Set in the ca
se of overflow:auto/scroll/hidden |
| 815 ADD_BOOLEAN_BITFIELD(hasTransform, HasTransform); | 802 ADD_BOOLEAN_BITFIELD(hasTransform, HasTransform); |
| 803 ADD_BOOLEAN_BITFIELD(hasBoxDecorationBackground, HasBoxDecorationBackgro
und); |
| 816 | 804 |
| 817 ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout); | 805 ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout); |
| 818 ADD_BOOLEAN_BITFIELD(ancestorLineBoxDirty, AncestorLineBoxDirty); | 806 ADD_BOOLEAN_BITFIELD(ancestorLineBoxDirty, AncestorLineBoxDirty); |
| 819 | 807 |
| 820 // from RenderInline | 808 // from RenderInline |
| 821 ADD_BOOLEAN_BITFIELD(alwaysCreateLineBoxesForRenderInline, AlwaysCreateL
ineBoxesForRenderInline); | 809 ADD_BOOLEAN_BITFIELD(alwaysCreateLineBoxesForRenderInline, AlwaysCreateL
ineBoxesForRenderInline); |
| 822 | 810 |
| 823 private: | 811 private: |
| 824 unsigned m_positionedState : 2; // PositionedState | 812 unsigned m_positionedState : 2; // PositionedState |
| 825 unsigned m_selectionState : 3; // SelectionState | 813 unsigned m_selectionState : 3; // SelectionState |
| 826 unsigned m_boxDecorationBackgroundState : 2; // BoxDecorationBackgroundS
tate | |
| 827 | 814 |
| 828 public: | 815 public: |
| 829 bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOf
FlowPositioned; } | 816 bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOf
FlowPositioned; } |
| 830 bool isRelPositioned() const { return m_positionedState == IsRelativelyP
ositioned; } | 817 bool isRelPositioned() const { return m_positionedState == IsRelativelyP
ositioned; } |
| 831 bool isPositioned() const { return m_positionedState != IsStaticallyPosi
tioned; } | 818 bool isPositioned() const { return m_positionedState != IsStaticallyPosi
tioned; } |
| 832 | 819 |
| 833 void setPositionedState(int positionState) | 820 void setPositionedState(int positionState) |
| 834 { | 821 { |
| 835 m_positionedState = static_cast<PositionedState>(positionState); | 822 m_positionedState = static_cast<PositionedState>(positionState); |
| 836 } | 823 } |
| 837 void clearPositionedState() { m_positionedState = StaticPosition; } | 824 void clearPositionedState() { m_positionedState = StaticPosition; } |
| 838 | 825 |
| 839 ALWAYS_INLINE SelectionState selectionState() const { return static_cast
<SelectionState>(m_selectionState); } | 826 ALWAYS_INLINE SelectionState selectionState() const { return static_cast
<SelectionState>(m_selectionState); } |
| 840 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_
selectionState = selectionState; } | 827 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_
selectionState = selectionState; } |
| 841 | |
| 842 ALWAYS_INLINE BoxDecorationBackgroundState boxDecorationBackgroundState(
) const { return static_cast<BoxDecorationBackgroundState>(m_boxDecorationBackgr
oundState); } | |
| 843 ALWAYS_INLINE void setBoxDecorationBackgroundState(BoxDecorationBackgrou
ndState s) { m_boxDecorationBackgroundState = s; } | |
| 844 }; | 828 }; |
| 845 | 829 |
| 846 #undef ADD_BOOLEAN_BITFIELD | 830 #undef ADD_BOOLEAN_BITFIELD |
| 847 | 831 |
| 848 RenderObjectBitfields m_bitfields; | 832 RenderObjectBitfields m_bitfields; |
| 849 | 833 |
| 850 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); } | 834 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); } |
| 851 void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPosition
edMovementLayout(b); } | 835 void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPosition
edMovementLayout(b); } |
| 852 void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayo
ut(b); } | 836 void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayo
ut(b); } |
| 853 void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b);
} | 837 void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b);
} |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 } | 910 } |
| 927 | 911 |
| 928 inline void RenderObject::setSelectionStateIfNeeded(SelectionState state) | 912 inline void RenderObject::setSelectionStateIfNeeded(SelectionState state) |
| 929 { | 913 { |
| 930 if (selectionState() == state) | 914 if (selectionState() == state) |
| 931 return; | 915 return; |
| 932 | 916 |
| 933 setSelectionState(state); | 917 setSelectionState(state); |
| 934 } | 918 } |
| 935 | 919 |
| 936 inline void RenderObject::setHasBoxDecorationBackground(bool b) | |
| 937 { | |
| 938 if (!b) { | |
| 939 m_bitfields.setBoxDecorationBackgroundState(NoBoxDecorationBackground); | |
| 940 return; | |
| 941 } | |
| 942 if (hasBoxDecorationBackground()) | |
| 943 return; | |
| 944 m_bitfields.setBoxDecorationBackgroundState(HasBoxDecorationBackgroundObscur
ationStatusInvalid); | |
| 945 } | |
| 946 | |
| 947 inline void RenderObject::invalidateBackgroundObscurationStatus() | |
| 948 { | |
| 949 if (!hasBoxDecorationBackground()) | |
| 950 return; | |
| 951 m_bitfields.setBoxDecorationBackgroundState(HasBoxDecorationBackgroundObscur
ationStatusInvalid); | |
| 952 } | |
| 953 | |
| 954 inline bool RenderObject::boxDecorationBackgroundIsKnownToBeObscured() | |
| 955 { | |
| 956 if (m_bitfields.boxDecorationBackgroundState() == HasBoxDecorationBackground
ObscurationStatusInvalid) { | |
| 957 BoxDecorationBackgroundState state = computeBackgroundIsKnownToBeObscure
d() ? HasBoxDecorationBackgroundKnownToBeObscured : HasBoxDecorationBackgroundMa
yBeVisible; | |
| 958 m_bitfields.setBoxDecorationBackgroundState(state); | |
| 959 } | |
| 960 return m_bitfields.boxDecorationBackgroundState() == HasBoxDecorationBackgro
undKnownToBeObscured; | |
| 961 } | |
| 962 | |
| 963 inline void makeMatrixRenderable(TransformationMatrix& matrix) | 920 inline void makeMatrixRenderable(TransformationMatrix& matrix) |
| 964 { | 921 { |
| 965 // FIXME(sky): We shouldn't need to do this once Skia has 4x4 matrix support
. | 922 // FIXME(sky): We shouldn't need to do this once Skia has 4x4 matrix support
. |
| 966 // Until then, 3d transforms don't work right. | 923 // Until then, 3d transforms don't work right. |
| 967 matrix.makeAffine(); | 924 matrix.makeAffine(); |
| 968 } | 925 } |
| 969 | 926 |
| 970 #define DEFINE_RENDER_OBJECT_TYPE_CASTS(thisType, predicate) \ | 927 #define DEFINE_RENDER_OBJECT_TYPE_CASTS(thisType, predicate) \ |
| 971 DEFINE_TYPE_CASTS(thisType, RenderObject, object, object->predicate, object.
predicate) | 928 DEFINE_TYPE_CASTS(thisType, RenderObject, object, object->predicate, object.
predicate) |
| 972 | 929 |
| 973 } // namespace blink | 930 } // namespace blink |
| 974 | 931 |
| 975 #ifndef NDEBUG | 932 #ifndef NDEBUG |
| 976 // Outside the WebCore namespace for ease of invocation from gdb. | 933 // Outside the WebCore namespace for ease of invocation from gdb. |
| 977 void showTree(const blink::RenderObject*); | 934 void showTree(const blink::RenderObject*); |
| 978 void showLineTree(const blink::RenderObject*); | 935 void showLineTree(const blink::RenderObject*); |
| 979 void showRenderTree(const blink::RenderObject* object1); | 936 void showRenderTree(const blink::RenderObject* object1); |
| 980 // We don't make object2 an optional parameter so that showRenderTree | 937 // We don't make object2 an optional parameter so that showRenderTree |
| 981 // can be called from gdb easily. | 938 // can be called from gdb easily. |
| 982 void showRenderTree(const blink::RenderObject* object1, const blink::RenderObjec
t* object2); | 939 void showRenderTree(const blink::RenderObject* object1, const blink::RenderObjec
t* object2); |
| 983 | 940 |
| 984 #endif | 941 #endif |
| 985 | 942 |
| 986 #endif // SKY_ENGINE_CORE_RENDERING_RENDEROBJECT_H_ | 943 #endif // SKY_ENGINE_CORE_RENDERING_RENDEROBJECT_H_ |
| OLD | NEW |