| 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. | 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. |
| 7 * All rights reserved. | 7 * All rights reserved. |
| 8 * Copyright (C) 2009 Google Inc. All rights reserved. | 8 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 void setHasCounterNodeMap(bool hasCounterNodeMap) { | 570 void setHasCounterNodeMap(bool hasCounterNodeMap) { |
| 571 m_bitfields.setHasCounterNodeMap(hasCounterNodeMap); | 571 m_bitfields.setHasCounterNodeMap(hasCounterNodeMap); |
| 572 } | 572 } |
| 573 | 573 |
| 574 bool everHadLayout() const { return m_bitfields.everHadLayout(); } | 574 bool everHadLayout() const { return m_bitfields.everHadLayout(); } |
| 575 | 575 |
| 576 bool childrenInline() const { return m_bitfields.childrenInline(); } | 576 bool childrenInline() const { return m_bitfields.childrenInline(); } |
| 577 void setChildrenInline(bool b) { m_bitfields.setChildrenInline(b); } | 577 void setChildrenInline(bool b) { m_bitfields.setChildrenInline(b); } |
| 578 | 578 |
| 579 bool alwaysCreateLineBoxesForLayoutInline() const { | 579 bool alwaysCreateLineBoxesForLayoutInline() const { |
| 580 ASSERT(isLayoutInline()); | 580 DCHECK(isLayoutInline()); |
| 581 return m_bitfields.alwaysCreateLineBoxesForLayoutInline(); | 581 return m_bitfields.alwaysCreateLineBoxesForLayoutInline(); |
| 582 } | 582 } |
| 583 void setAlwaysCreateLineBoxesForLayoutInline(bool alwaysCreateLineBoxes) { | 583 void setAlwaysCreateLineBoxesForLayoutInline(bool alwaysCreateLineBoxes) { |
| 584 ASSERT(isLayoutInline()); | 584 DCHECK(isLayoutInline()); |
| 585 m_bitfields.setAlwaysCreateLineBoxesForLayoutInline(alwaysCreateLineBoxes); | 585 m_bitfields.setAlwaysCreateLineBoxesForLayoutInline(alwaysCreateLineBoxes); |
| 586 } | 586 } |
| 587 | 587 |
| 588 bool ancestorLineBoxDirty() const { | 588 bool ancestorLineBoxDirty() const { |
| 589 return m_bitfields.ancestorLineBoxDirty(); | 589 return m_bitfields.ancestorLineBoxDirty(); |
| 590 } | 590 } |
| 591 void setAncestorLineBoxDirty(bool value = true) { | 591 void setAncestorLineBoxDirty(bool value = true) { |
| 592 m_bitfields.setAncestorLineBoxDirty(value); | 592 m_bitfields.setAncestorLineBoxDirty(value); |
| 593 if (value) | 593 if (value) |
| 594 setNeedsLayoutAndFullPaintInvalidation( | 594 setNeedsLayoutAndFullPaintInvalidation( |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 bool isInFlowPositioned() const { | 743 bool isInFlowPositioned() const { |
| 744 return m_bitfields.isInFlowPositioned(); | 744 return m_bitfields.isInFlowPositioned(); |
| 745 } | 745 } |
| 746 bool isRelPositioned() const { | 746 bool isRelPositioned() const { |
| 747 return m_bitfields.isRelPositioned(); | 747 return m_bitfields.isRelPositioned(); |
| 748 } | 748 } |
| 749 bool isStickyPositioned() const { | 749 bool isStickyPositioned() const { |
| 750 return m_bitfields.isStickyPositioned(); | 750 return m_bitfields.isStickyPositioned(); |
| 751 } | 751 } |
| 752 bool isFixedPositioned() const { | 752 bool isFixedPositioned() const { |
| 753 return isOutOfFlowPositioned() && style()->position() == FixedPosition; | 753 return isOutOfFlowPositioned() && style()->position() == EPosition::kFixed; |
| 754 } | 754 } |
| 755 bool isAbsolutePositioned() const { | 755 bool isAbsolutePositioned() const { |
| 756 return isOutOfFlowPositioned() && style()->position() == AbsolutePosition; | 756 return isOutOfFlowPositioned() && |
| 757 style()->position() == EPosition::kAbsolute; |
| 757 } | 758 } |
| 758 bool isPositioned() const { return m_bitfields.isPositioned(); } | 759 bool isPositioned() const { return m_bitfields.isPositioned(); } |
| 759 | 760 |
| 760 bool isText() const { return m_bitfields.isText(); } | 761 bool isText() const { return m_bitfields.isText(); } |
| 761 bool isBox() const { return m_bitfields.isBox(); } | 762 bool isBox() const { return m_bitfields.isBox(); } |
| 762 bool isInline() const { return m_bitfields.isInline(); } // inline object | 763 bool isInline() const { return m_bitfields.isInline(); } // inline object |
| 763 bool isAtomicInlineLevel() const { return m_bitfields.isAtomicInlineLevel(); } | 764 bool isAtomicInlineLevel() const { return m_bitfields.isAtomicInlineLevel(); } |
| 764 bool isHorizontalWritingMode() const { | 765 bool isHorizontalWritingMode() const { |
| 765 return m_bitfields.horizontalWritingMode(); | 766 return m_bitfields.horizontalWritingMode(); |
| 766 } | 767 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 void clearNode() { m_node = nullptr; } | 875 void clearNode() { m_node = nullptr; } |
| 875 | 876 |
| 876 // Returns the styled node that caused the generation of this layoutObject. | 877 // Returns the styled node that caused the generation of this layoutObject. |
| 877 // This is the same as node() except for layoutObjects of :before, :after and | 878 // This is the same as node() except for layoutObjects of :before, :after and |
| 878 // :first-letter pseudo elements for which their parent node is returned. | 879 // :first-letter pseudo elements for which their parent node is returned. |
| 879 Node* generatingNode() const { | 880 Node* generatingNode() const { |
| 880 return isPseudoElement() ? node()->parentOrShadowHostNode() : node(); | 881 return isPseudoElement() ? node()->parentOrShadowHostNode() : node(); |
| 881 } | 882 } |
| 882 | 883 |
| 883 Document& document() const { | 884 Document& document() const { |
| 884 ASSERT(m_node || parent()); // crbug.com/402056 | 885 DCHECK(m_node || parent()); // crbug.com/402056 |
| 885 return m_node ? m_node->document() : parent()->document(); | 886 return m_node ? m_node->document() : parent()->document(); |
| 886 } | 887 } |
| 887 LocalFrame* frame() const { return document().frame(); } | 888 LocalFrame* frame() const { return document().frame(); } |
| 888 | 889 |
| 889 virtual LayoutMultiColumnSpannerPlaceholder* spannerPlaceholder() const { | 890 virtual LayoutMultiColumnSpannerPlaceholder* spannerPlaceholder() const { |
| 890 return nullptr; | 891 return nullptr; |
| 891 } | 892 } |
| 892 bool isColumnSpanAll() const { | 893 bool isColumnSpanAll() const { |
| 893 return style()->getColumnSpan() == ColumnSpanAll && spannerPlaceholder(); | 894 return style()->getColumnSpan() == ColumnSpanAll && spannerPlaceholder(); |
| 894 } | 895 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 setNeedsLayout(reason); | 1005 setNeedsLayout(reason); |
| 1005 setPreferredLogicalWidthsDirty(); | 1006 setPreferredLogicalWidthsDirty(); |
| 1006 } | 1007 } |
| 1007 void setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( | 1008 void setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( |
| 1008 LayoutInvalidationReasonForTracing reason) { | 1009 LayoutInvalidationReasonForTracing reason) { |
| 1009 setNeedsLayoutAndFullPaintInvalidation(reason); | 1010 setNeedsLayoutAndFullPaintInvalidation(reason); |
| 1010 setPreferredLogicalWidthsDirty(); | 1011 setPreferredLogicalWidthsDirty(); |
| 1011 } | 1012 } |
| 1012 | 1013 |
| 1013 void setPositionState(EPosition position) { | 1014 void setPositionState(EPosition position) { |
| 1014 ASSERT((position != AbsolutePosition && position != FixedPosition) || | 1015 DCHECK( |
| 1015 isBox()); | 1016 (position != EPosition::kAbsolute && position != EPosition::kFixed) || |
| 1017 isBox()); |
| 1016 m_bitfields.setPositionedState(position); | 1018 m_bitfields.setPositionedState(position); |
| 1017 } | 1019 } |
| 1018 void clearPositionedState() { m_bitfields.clearPositionedState(); } | 1020 void clearPositionedState() { m_bitfields.clearPositionedState(); } |
| 1019 | 1021 |
| 1020 void setFloating(bool isFloating) { m_bitfields.setFloating(isFloating); } | 1022 void setFloating(bool isFloating) { m_bitfields.setFloating(isFloating); } |
| 1021 void setInline(bool isInline) { m_bitfields.setIsInline(isInline); } | 1023 void setInline(bool isInline) { m_bitfields.setIsInline(isInline); } |
| 1022 | 1024 |
| 1023 void setHasBoxDecorationBackground(bool); | 1025 void setHasBoxDecorationBackground(bool); |
| 1024 | 1026 |
| 1025 enum BackgroundObscurationState { | 1027 enum BackgroundObscurationState { |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 virtual LayoutUnit maxPreferredLogicalWidth() const { return LayoutUnit(); } | 1314 virtual LayoutUnit maxPreferredLogicalWidth() const { return LayoutUnit(); } |
| 1313 | 1315 |
| 1314 const ComputedStyle* style() const { return m_style.get(); } | 1316 const ComputedStyle* style() const { return m_style.get(); } |
| 1315 ComputedStyle* mutableStyle() const { return m_style.get(); } | 1317 ComputedStyle* mutableStyle() const { return m_style.get(); } |
| 1316 | 1318 |
| 1317 // m_style can only be nullptr before the first style is set, thus most | 1319 // m_style can only be nullptr before the first style is set, thus most |
| 1318 // callers will never see a nullptr style and should use styleRef(). | 1320 // callers will never see a nullptr style and should use styleRef(). |
| 1319 // FIXME: It would be better if style() returned a const reference. | 1321 // FIXME: It would be better if style() returned a const reference. |
| 1320 const ComputedStyle& styleRef() const { return mutableStyleRef(); } | 1322 const ComputedStyle& styleRef() const { return mutableStyleRef(); } |
| 1321 ComputedStyle& mutableStyleRef() const { | 1323 ComputedStyle& mutableStyleRef() const { |
| 1322 ASSERT(m_style); | 1324 DCHECK(m_style); |
| 1323 return *m_style; | 1325 return *m_style; |
| 1324 } | 1326 } |
| 1325 | 1327 |
| 1326 /* The following methods are inlined in LayoutObjectInlines.h */ | 1328 /* The following methods are inlined in LayoutObjectInlines.h */ |
| 1327 inline const ComputedStyle* firstLineStyle() const; | 1329 inline const ComputedStyle* firstLineStyle() const; |
| 1328 inline const ComputedStyle& firstLineStyleRef() const; | 1330 inline const ComputedStyle& firstLineStyleRef() const; |
| 1329 inline const ComputedStyle* style(bool firstLine) const; | 1331 inline const ComputedStyle* style(bool firstLine) const; |
| 1330 inline const ComputedStyle& styleRef(bool firstLine) const; | 1332 inline const ComputedStyle& styleRef(bool firstLine) const; |
| 1331 | 1333 |
| 1332 static inline Color resolveColor(const ComputedStyle& styleToUse, | 1334 static inline Color resolveColor(const ComputedStyle& styleToUse, |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 // handled in the code by checking if documentBeingDestroyed() returns 'true'. | 1983 // handled in the code by checking if documentBeingDestroyed() returns 'true'. |
| 1982 // In this case, the code skips some unneeded expensive operations as we know | 1984 // In this case, the code skips some unneeded expensive operations as we know |
| 1983 // the tree is not reused (e.g. avoid clearing the containing block's line | 1985 // the tree is not reused (e.g. avoid clearing the containing block's line |
| 1984 // box). | 1986 // box). |
| 1985 virtual void willBeDestroyed(); | 1987 virtual void willBeDestroyed(); |
| 1986 | 1988 |
| 1987 virtual void insertedIntoTree(); | 1989 virtual void insertedIntoTree(); |
| 1988 virtual void willBeRemovedFromTree(); | 1990 virtual void willBeRemovedFromTree(); |
| 1989 | 1991 |
| 1990 void setDocumentForAnonymous(Document* document) { | 1992 void setDocumentForAnonymous(Document* document) { |
| 1991 ASSERT(isAnonymous()); | 1993 DCHECK(isAnonymous()); |
| 1992 m_node = document; | 1994 m_node = document; |
| 1993 } | 1995 } |
| 1994 | 1996 |
| 1995 // Add hit-test rects for the layout tree rooted at this node to the provided | 1997 // Add hit-test rects for the layout tree rooted at this node to the provided |
| 1996 // collection on a per-Layer basis. | 1998 // collection on a per-Layer basis. |
| 1997 // currentLayer must be the enclosing layer, and layerOffset is the current | 1999 // currentLayer must be the enclosing layer, and layerOffset is the current |
| 1998 // offset within this layer. Subclass implementations will add any offset for | 2000 // offset within this layer. Subclass implementations will add any offset for |
| 1999 // this layoutObject within it's container, so callers should provide only the | 2001 // this layoutObject within it's container, so callers should provide only the |
| 2000 // offset of the container within it's layer. | 2002 // offset of the container within it's layer. |
| 2001 // containerRect is a rect that has already been added for the currentLayer | 2003 // containerRect is a rect that has already been added for the currentLayer |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2452 return m_positionedState == IsStickyPositioned; | 2454 return m_positionedState == IsStickyPositioned; |
| 2453 } | 2455 } |
| 2454 bool isInFlowPositioned() const { | 2456 bool isInFlowPositioned() const { |
| 2455 return m_positionedState == IsRelativelyPositioned || | 2457 return m_positionedState == IsRelativelyPositioned || |
| 2456 m_positionedState == IsStickyPositioned; | 2458 m_positionedState == IsStickyPositioned; |
| 2457 } | 2459 } |
| 2458 bool isPositioned() const { | 2460 bool isPositioned() const { |
| 2459 return m_positionedState != IsStaticallyPositioned; | 2461 return m_positionedState != IsStaticallyPositioned; |
| 2460 } | 2462 } |
| 2461 | 2463 |
| 2462 void setPositionedState(int positionState) { | 2464 void setPositionedState(EPosition positionState) { |
| 2463 // This maps FixedPosition and AbsolutePosition to | 2465 // This maps FixedPosition and AbsolutePosition to |
| 2464 // IsOutOfFlowPositioned, saving one bit. | 2466 // IsOutOfFlowPositioned, saving one bit. |
| 2465 switch (positionState) { | 2467 switch (positionState) { |
| 2466 case StaticPosition: | 2468 case EPosition::kStatic: |
| 2467 m_positionedState = IsStaticallyPositioned; | 2469 m_positionedState = IsStaticallyPositioned; |
| 2468 break; | 2470 break; |
| 2469 case RelativePosition: | 2471 case EPosition::kRelative: |
| 2470 m_positionedState = IsRelativelyPositioned; | 2472 m_positionedState = IsRelativelyPositioned; |
| 2471 break; | 2473 break; |
| 2472 case AbsolutePosition: | 2474 case EPosition::kAbsolute: |
| 2473 case FixedPosition: | 2475 case EPosition::kFixed: |
| 2474 m_positionedState = IsOutOfFlowPositioned; | 2476 m_positionedState = IsOutOfFlowPositioned; |
| 2475 break; | 2477 break; |
| 2476 case StickyPosition: | 2478 case EPosition::kSticky: |
| 2477 m_positionedState = IsStickyPositioned; | 2479 m_positionedState = IsStickyPositioned; |
| 2478 break; | 2480 break; |
| 2479 default: | 2481 default: |
| 2480 NOTREACHED(); | 2482 NOTREACHED(); |
| 2481 break; | 2483 break; |
| 2482 } | 2484 } |
| 2483 } | 2485 } |
| 2484 void clearPositionedState() { m_positionedState = StaticPosition; } | 2486 void clearPositionedState() { |
| 2487 m_positionedState = static_cast<unsigned>(EPosition::kStatic); |
| 2488 } |
| 2485 | 2489 |
| 2486 ALWAYS_INLINE SelectionState getSelectionState() const { | 2490 ALWAYS_INLINE SelectionState getSelectionState() const { |
| 2487 return static_cast<SelectionState>(m_selectionState); | 2491 return static_cast<SelectionState>(m_selectionState); |
| 2488 } | 2492 } |
| 2489 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { | 2493 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { |
| 2490 m_selectionState = selectionState; | 2494 m_selectionState = selectionState; |
| 2491 } | 2495 } |
| 2492 | 2496 |
| 2493 ALWAYS_INLINE BackgroundObscurationState | 2497 ALWAYS_INLINE BackgroundObscurationState |
| 2494 getBackgroundObscurationState() const { | 2498 getBackgroundObscurationState() const { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2727 if (!has3DRendering) | 2731 if (!has3DRendering) |
| 2728 matrix.makeAffine(); | 2732 matrix.makeAffine(); |
| 2729 } | 2733 } |
| 2730 | 2734 |
| 2731 inline int adjustForAbsoluteZoom(int value, LayoutObject* layoutObject) { | 2735 inline int adjustForAbsoluteZoom(int value, LayoutObject* layoutObject) { |
| 2732 return adjustForAbsoluteZoom(value, layoutObject->style()); | 2736 return adjustForAbsoluteZoom(value, layoutObject->style()); |
| 2733 } | 2737 } |
| 2734 | 2738 |
| 2735 inline LayoutUnit adjustLayoutUnitForAbsoluteZoom(LayoutUnit value, | 2739 inline LayoutUnit adjustLayoutUnitForAbsoluteZoom(LayoutUnit value, |
| 2736 LayoutObject& layoutObject) { | 2740 LayoutObject& layoutObject) { |
| 2737 ASSERT(layoutObject.style()); | 2741 DCHECK(layoutObject.style()); |
| 2738 return adjustLayoutUnitForAbsoluteZoom(value, *layoutObject.style()); | 2742 return adjustLayoutUnitForAbsoluteZoom(value, *layoutObject.style()); |
| 2739 } | 2743 } |
| 2740 | 2744 |
| 2741 inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, | 2745 inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, |
| 2742 LayoutObject& layoutObject) { | 2746 LayoutObject& layoutObject) { |
| 2743 float zoom = layoutObject.style()->effectiveZoom(); | 2747 float zoom = layoutObject.style()->effectiveZoom(); |
| 2744 if (zoom != 1) | 2748 if (zoom != 1) |
| 2745 quad.scale(1 / zoom, 1 / zoom); | 2749 quad.scale(1 / zoom, 1 / zoom); |
| 2746 } | 2750 } |
| 2747 | 2751 |
| 2748 inline void adjustFloatRectForAbsoluteZoom(FloatRect& rect, | 2752 inline void adjustFloatRectForAbsoluteZoom(FloatRect& rect, |
| 2749 LayoutObject& layoutObject) { | 2753 LayoutObject& layoutObject) { |
| 2750 float zoom = layoutObject.style()->effectiveZoom(); | 2754 float zoom = layoutObject.style()->effectiveZoom(); |
| 2751 if (zoom != 1) | 2755 if (zoom != 1) |
| 2752 rect.scale(1 / zoom, 1 / zoom); | 2756 rect.scale(1 / zoom, 1 / zoom); |
| 2753 } | 2757 } |
| 2754 | 2758 |
| 2755 inline double adjustScrollForAbsoluteZoom(double value, | 2759 inline double adjustScrollForAbsoluteZoom(double value, |
| 2756 LayoutObject& layoutObject) { | 2760 LayoutObject& layoutObject) { |
| 2757 ASSERT(layoutObject.style()); | 2761 DCHECK(layoutObject.style()); |
| 2758 return adjustScrollForAbsoluteZoom(value, *layoutObject.style()); | 2762 return adjustScrollForAbsoluteZoom(value, *layoutObject.style()); |
| 2759 } | 2763 } |
| 2760 | 2764 |
| 2761 #define DEFINE_LAYOUT_OBJECT_TYPE_CASTS(thisType, predicate) \ | 2765 #define DEFINE_LAYOUT_OBJECT_TYPE_CASTS(thisType, predicate) \ |
| 2762 DEFINE_TYPE_CASTS(thisType, LayoutObject, object, object->predicate, \ | 2766 DEFINE_TYPE_CASTS(thisType, LayoutObject, object, object->predicate, \ |
| 2763 object.predicate) | 2767 object.predicate) |
| 2764 | 2768 |
| 2765 } // namespace blink | 2769 } // namespace blink |
| 2766 | 2770 |
| 2767 #ifndef NDEBUG | 2771 #ifndef NDEBUG |
| 2768 // Outside the blink namespace for ease of invocation from gdb. | 2772 // Outside the blink namespace for ease of invocation from gdb. |
| 2769 CORE_EXPORT void showTree(const blink::LayoutObject*); | 2773 CORE_EXPORT void showTree(const blink::LayoutObject*); |
| 2770 CORE_EXPORT void showLineTree(const blink::LayoutObject*); | 2774 CORE_EXPORT void showLineTree(const blink::LayoutObject*); |
| 2771 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); | 2775 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); |
| 2772 // We don't make object2 an optional parameter so that showLayoutTree | 2776 // We don't make object2 an optional parameter so that showLayoutTree |
| 2773 // can be called from gdb easily. | 2777 // can be called from gdb easily. |
| 2774 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, | 2778 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, |
| 2775 const blink::LayoutObject* object2); | 2779 const blink::LayoutObject* object2); |
| 2776 | 2780 |
| 2777 #endif | 2781 #endif |
| 2778 | 2782 |
| 2779 #endif // LayoutObject_h | 2783 #endif // LayoutObject_h |
| OLD | NEW |