Chromium Code Reviews| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 struct AnnotatedRegionValue { | 89 struct AnnotatedRegionValue { |
| 90 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 90 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 91 bool operator==(const AnnotatedRegionValue& o) const { | 91 bool operator==(const AnnotatedRegionValue& o) const { |
| 92 return draggable == o.draggable && bounds == o.bounds; | 92 return draggable == o.draggable && bounds == o.bounds; |
| 93 } | 93 } |
| 94 | 94 |
| 95 LayoutRect bounds; | 95 LayoutRect bounds; |
| 96 bool draggable; | 96 bool draggable; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 #ifndef NDEBUG | 99 #if DCHECK_IS_ON() |
| 100 const int showTreeCharacterOffset = 39; | 100 const int showTreeCharacterOffset = 39; |
| 101 #endif | 101 #endif |
| 102 | 102 |
| 103 // LayoutObject is the base class for all layout tree objects. | 103 // LayoutObject is the base class for all layout tree objects. |
| 104 // | 104 // |
| 105 // LayoutObjects form a tree structure that is a close mapping of the DOM tree. | 105 // LayoutObjects form a tree structure that is a close mapping of the DOM tree. |
| 106 // The root of the LayoutObject tree is the LayoutView, which is the | 106 // The root of the LayoutObject tree is the LayoutView, which is the |
| 107 // LayoutObject associated with the Document. | 107 // LayoutObject associated with the Document. |
| 108 // | 108 // |
| 109 // Some LayoutObjects don't have an associated Node and are called "anonymous" | 109 // Some LayoutObjects don't have an associated Node and are called "anonymous" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 LayoutBox* enclosingScrollableBox() const; | 285 LayoutBox* enclosingScrollableBox() const; |
| 286 | 286 |
| 287 // Function to return our enclosing flow thread if we are contained inside | 287 // Function to return our enclosing flow thread if we are contained inside |
| 288 // one. This function follows the containing block chain. | 288 // one. This function follows the containing block chain. |
| 289 LayoutFlowThread* flowThreadContainingBlock() const { | 289 LayoutFlowThread* flowThreadContainingBlock() const { |
| 290 if (!isInsideFlowThread()) | 290 if (!isInsideFlowThread()) |
| 291 return nullptr; | 291 return nullptr; |
| 292 return locateFlowThreadContainingBlock(); | 292 return locateFlowThreadContainingBlock(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 #if ENABLE(ASSERT) | 295 #if DCHECK_IS_ON() |
| 296 void setHasAXObject(bool flag) { m_hasAXObject = flag; } | 296 void setHasAXObject(bool flag) { m_hasAXObject = flag; } |
| 297 bool hasAXObject() const { return m_hasAXObject; } | 297 bool hasAXObject() const { return m_hasAXObject; } |
| 298 | 298 |
| 299 // Helper class forbidding calls to setNeedsLayout() during its lifetime. | 299 // Helper class forbidding calls to setNeedsLayout() during its lifetime. |
| 300 class SetLayoutNeededForbiddenScope { | 300 class SetLayoutNeededForbiddenScope { |
| 301 public: | 301 public: |
| 302 explicit SetLayoutNeededForbiddenScope(LayoutObject&); | 302 explicit SetLayoutNeededForbiddenScope(LayoutObject&); |
| 303 ~SetLayoutNeededForbiddenScope(); | 303 ~SetLayoutNeededForbiddenScope(); |
| 304 | 304 |
| 305 private: | 305 private: |
| 306 LayoutObject& m_layoutObject; | 306 LayoutObject& m_layoutObject; |
| 307 bool m_preexistingForbidden; | 307 bool m_preexistingForbidden; |
| 308 }; | 308 }; |
| 309 | 309 |
| 310 void assertLaidOut() const { | 310 void assertLaidOut() const { |
| 311 #ifndef NDEBUG | |
| 312 if (needsLayout()) | 311 if (needsLayout()) |
| 313 showLayoutTreeForThis(); | 312 showLayoutTreeForThis(); |
| 314 #endif | |
| 315 SECURITY_DCHECK(!needsLayout()); | 313 SECURITY_DCHECK(!needsLayout()); |
| 316 } | 314 } |
| 317 | 315 |
| 318 void assertSubtreeIsLaidOut() const { | 316 void assertSubtreeIsLaidOut() const { |
| 319 for (const LayoutObject* layoutObject = this; layoutObject; | 317 for (const LayoutObject* layoutObject = this; layoutObject; |
| 320 layoutObject = layoutObject->nextInPreOrder()) | 318 layoutObject = layoutObject->nextInPreOrder()) |
| 321 layoutObject->assertLaidOut(); | 319 layoutObject->assertLaidOut(); |
| 322 } | 320 } |
| 323 | 321 |
| 324 void assertClearedPaintInvalidationFlags() const { | 322 void assertClearedPaintInvalidationFlags() const { |
| 325 #ifndef NDEBUG | |
| 326 if (paintInvalidationStateIsDirty()) { | 323 if (paintInvalidationStateIsDirty()) { |
| 327 showLayoutTreeForThis(); | 324 showLayoutTreeForThis(); |
| 328 ASSERT_NOT_REACHED(); | 325 ASSERT_NOT_REACHED(); |
| 329 } | 326 } |
| 330 #endif | |
| 331 } | 327 } |
| 332 | 328 |
| 333 void assertSubtreeClearedPaintInvalidationFlags() const { | 329 void assertSubtreeClearedPaintInvalidationFlags() const { |
| 334 for (const LayoutObject* layoutObject = this; layoutObject; | 330 for (const LayoutObject* layoutObject = this; layoutObject; |
| 335 layoutObject = layoutObject->nextInPreOrder()) | 331 layoutObject = layoutObject->nextInPreOrder()) |
| 336 layoutObject->assertClearedPaintInvalidationFlags(); | 332 layoutObject->assertClearedPaintInvalidationFlags(); |
| 337 } | 333 } |
| 338 | 334 |
| 339 #endif | 335 #endif |
| 340 | 336 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 // if we're not a LayoutFlowThread. | 408 // if we're not a LayoutFlowThread. |
| 413 // A LayoutFlowThread is always considered to be inside itself, so it never | 409 // A LayoutFlowThread is always considered to be inside itself, so it never |
| 414 // has to change its state in response to parent changes. | 410 // has to change its state in response to parent changes. |
| 415 bool insideFlowThread = parent && parent->isInsideFlowThread(); | 411 bool insideFlowThread = parent && parent->isInsideFlowThread(); |
| 416 if (insideFlowThread != isInsideFlowThread() && !isLayoutFlowThread()) | 412 if (insideFlowThread != isInsideFlowThread() && !isLayoutFlowThread()) |
| 417 setIsInsideFlowThreadIncludingDescendants(insideFlowThread); | 413 setIsInsideFlowThreadIncludingDescendants(insideFlowThread); |
| 418 } | 414 } |
| 419 | 415 |
| 420 ////////////////////////////////////////// | 416 ////////////////////////////////////////// |
| 421 private: | 417 private: |
| 422 #if ENABLE(ASSERT) | 418 #if DCHECK_IS_ON() |
| 423 bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; } | 419 bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; } |
| 424 void setNeedsLayoutIsForbidden(bool flag) { | 420 void setNeedsLayoutIsForbidden(bool flag) { |
| 425 m_setNeedsLayoutForbidden = flag; | 421 m_setNeedsLayoutForbidden = flag; |
| 426 } | 422 } |
| 427 #endif | 423 #endif |
| 428 | 424 |
| 429 void addAbsoluteRectForLayer(IntRect& result); | 425 void addAbsoluteRectForLayer(IntRect& result); |
| 430 bool requiresAnonymousTableWrappers(const LayoutObject*) const; | 426 bool requiresAnonymousTableWrappers(const LayoutObject*) const; |
| 431 | 427 |
| 432 // Gets pseudoStyle from Shadow host(in case of input elements) | 428 // Gets pseudoStyle from Shadow host(in case of input elements) |
| 433 // or from Parent element. | 429 // or from Parent element. |
| 434 PassRefPtr<ComputedStyle> getUncachedPseudoStyleFromParentOrShadowHost() | 430 PassRefPtr<ComputedStyle> getUncachedPseudoStyleFromParentOrShadowHost() |
| 435 const; | 431 const; |
| 436 | 432 |
| 437 public: | 433 public: |
| 438 #ifndef NDEBUG | 434 #if DCHECK_IS_ON() |
|
mstensho (USE GERRIT)
2016/11/29 12:06:12
I don't think these have anything to do with asser
| |
| 439 void showTreeForThis() const; | 435 void showTreeForThis() const; |
| 440 void showLayoutTreeForThis() const; | 436 void showLayoutTreeForThis() const; |
| 441 void showLineTreeForThis() const; | 437 void showLineTreeForThis() const; |
| 442 | 438 |
| 443 void showLayoutObject() const; | 439 void showLayoutObject() const; |
| 444 // We don't make stringBuilder an optional parameter so that | 440 // We don't make stringBuilder an optional parameter so that |
| 445 // showLayoutObject can be called from gdb easily. | 441 // showLayoutObject can be called from gdb easily. |
| 446 void showLayoutObject(StringBuilder&) const; | 442 void showLayoutObject(StringBuilder&) const; |
| 447 void showLayoutTreeAndMark(const LayoutObject* markedObject1 = nullptr, | 443 void showLayoutTreeAndMark(const LayoutObject* markedObject1 = nullptr, |
| 448 const char* markedLabel1 = nullptr, | 444 const char* markedLabel1 = nullptr, |
| (...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2032 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*); | 2028 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*); |
| 2033 | 2029 |
| 2034 ComputedStyle* cachedFirstLineStyle() const; | 2030 ComputedStyle* cachedFirstLineStyle() const; |
| 2035 StyleDifference adjustStyleDifference(StyleDifference) const; | 2031 StyleDifference adjustStyleDifference(StyleDifference) const; |
| 2036 | 2032 |
| 2037 Color selectionColor(int colorProperty, const GlobalPaintFlags) const; | 2033 Color selectionColor(int colorProperty, const GlobalPaintFlags) const; |
| 2038 | 2034 |
| 2039 void removeShapeImageClient(ShapeValue*); | 2035 void removeShapeImageClient(ShapeValue*); |
| 2040 void removeCursorImageClient(const CursorList*); | 2036 void removeCursorImageClient(const CursorList*); |
| 2041 | 2037 |
| 2042 #if ENABLE(ASSERT) | 2038 #if DCHECK_IS_ON() |
| 2043 void checkBlockPositionedObjectsNeedLayout(); | 2039 void checkBlockPositionedObjectsNeedLayout(); |
| 2044 #endif | 2040 #endif |
| 2045 | 2041 |
| 2046 bool isTextOrSVGChild() const { | 2042 bool isTextOrSVGChild() const { |
| 2047 return isText() || (isSVG() && !isSVGRoot()); | 2043 return isText() || (isSVG() && !isSVGRoot()); |
| 2048 } | 2044 } |
| 2049 | 2045 |
| 2050 static bool isAllowedToModifyLayoutTreeStructure(Document&); | 2046 static bool isAllowedToModifyLayoutTreeStructure(Document&); |
| 2051 | 2047 |
| 2052 // Returns the parent for paint invalidation. | 2048 // Returns the parent for paint invalidation. |
| 2053 // - For LayoutView, returns the owner layout object in the containing frame | 2049 // - For LayoutView, returns the owner layout object in the containing frame |
| 2054 // if any or nullptr; | 2050 // if any or nullptr; |
| 2055 // - For multi-column spanner, returns the spanner placeholder; | 2051 // - For multi-column spanner, returns the spanner placeholder; |
| 2056 // - Otherwise returns parent(). | 2052 // - Otherwise returns parent(). |
| 2057 LayoutObject* paintInvalidationParent() const; | 2053 LayoutObject* paintInvalidationParent() const; |
| 2058 | 2054 |
| 2059 RefPtr<ComputedStyle> m_style; | 2055 RefPtr<ComputedStyle> m_style; |
| 2060 | 2056 |
| 2061 // Oilpan: This untraced pointer to the owning Node is considered safe. | 2057 // Oilpan: This untraced pointer to the owning Node is considered safe. |
| 2062 UntracedMember<Node> m_node; | 2058 UntracedMember<Node> m_node; |
| 2063 | 2059 |
| 2064 LayoutObject* m_parent; | 2060 LayoutObject* m_parent; |
| 2065 LayoutObject* m_previous; | 2061 LayoutObject* m_previous; |
| 2066 LayoutObject* m_next; | 2062 LayoutObject* m_next; |
| 2067 | 2063 |
| 2068 #if ENABLE(ASSERT) | 2064 #if DCHECK_IS_ON() |
| 2069 unsigned m_hasAXObject : 1; | 2065 unsigned m_hasAXObject : 1; |
| 2070 unsigned m_setNeedsLayoutForbidden : 1; | 2066 unsigned m_setNeedsLayoutForbidden : 1; |
| 2071 #endif | 2067 #endif |
| 2072 | 2068 |
| 2073 #define ADD_BOOLEAN_BITFIELD(name, Name) \ | 2069 #define ADD_BOOLEAN_BITFIELD(name, Name) \ |
| 2074 private: \ | 2070 private: \ |
| 2075 unsigned m_##name : 1; \ | 2071 unsigned m_##name : 1; \ |
| 2076 \ | 2072 \ |
| 2077 public: \ | 2073 public: \ |
| 2078 bool name() const { return m_##name; } \ | 2074 bool name() const { return m_##name; } \ |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2513 setMayNeedPaintInvalidation(); | 2509 setMayNeedPaintInvalidation(); |
| 2514 | 2510 |
| 2515 // Clear needsLayout flags. | 2511 // Clear needsLayout flags. |
| 2516 setSelfNeedsLayout(false); | 2512 setSelfNeedsLayout(false); |
| 2517 setPosChildNeedsLayout(false); | 2513 setPosChildNeedsLayout(false); |
| 2518 setNeedsSimplifiedNormalFlowLayout(false); | 2514 setNeedsSimplifiedNormalFlowLayout(false); |
| 2519 setNormalChildNeedsLayout(false); | 2515 setNormalChildNeedsLayout(false); |
| 2520 setNeedsPositionedMovementLayout(false); | 2516 setNeedsPositionedMovementLayout(false); |
| 2521 setAncestorLineBoxDirty(false); | 2517 setAncestorLineBoxDirty(false); |
| 2522 | 2518 |
| 2523 #if ENABLE(ASSERT) | 2519 #if DCHECK_IS_ON() |
| 2524 checkBlockPositionedObjectsNeedLayout(); | 2520 checkBlockPositionedObjectsNeedLayout(); |
| 2525 #endif | 2521 #endif |
| 2526 | 2522 |
| 2527 setScrollAnchorDisablingStyleChanged(false); | 2523 setScrollAnchorDisablingStyleChanged(false); |
| 2528 } | 2524 } |
| 2529 | 2525 |
| 2530 inline void LayoutObject::setChildNeedsLayout(MarkingBehavior markParents, | 2526 inline void LayoutObject::setChildNeedsLayout(MarkingBehavior markParents, |
| 2531 SubtreeLayoutScope* layouter) { | 2527 SubtreeLayoutScope* layouter) { |
| 2532 ASSERT(!isSetNeedsLayoutForbidden()); | 2528 ASSERT(!isSetNeedsLayoutForbidden()); |
| 2533 bool alreadyNeededLayout = normalChildNeedsLayout(); | 2529 bool alreadyNeededLayout = normalChildNeedsLayout(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2632 ASSERT(layoutObject.style()); | 2628 ASSERT(layoutObject.style()); |
| 2633 return adjustScrollForAbsoluteZoom(value, *layoutObject.style()); | 2629 return adjustScrollForAbsoluteZoom(value, *layoutObject.style()); |
| 2634 } | 2630 } |
| 2635 | 2631 |
| 2636 #define DEFINE_LAYOUT_OBJECT_TYPE_CASTS(thisType, predicate) \ | 2632 #define DEFINE_LAYOUT_OBJECT_TYPE_CASTS(thisType, predicate) \ |
| 2637 DEFINE_TYPE_CASTS(thisType, LayoutObject, object, object->predicate, \ | 2633 DEFINE_TYPE_CASTS(thisType, LayoutObject, object, object->predicate, \ |
| 2638 object.predicate) | 2634 object.predicate) |
| 2639 | 2635 |
| 2640 } // namespace blink | 2636 } // namespace blink |
| 2641 | 2637 |
| 2642 #ifndef NDEBUG | 2638 #if DCHECK_IS_ON() |
| 2643 // Outside the blink namespace for ease of invocation from gdb. | 2639 // Outside the blink namespace for ease of invocation from gdb. |
| 2644 CORE_EXPORT void showTree(const blink::LayoutObject*); | 2640 CORE_EXPORT void showTree(const blink::LayoutObject*); |
| 2645 CORE_EXPORT void showLineTree(const blink::LayoutObject*); | 2641 CORE_EXPORT void showLineTree(const blink::LayoutObject*); |
| 2646 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); | 2642 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); |
| 2647 // We don't make object2 an optional parameter so that showLayoutTree | 2643 // We don't make object2 an optional parameter so that showLayoutTree |
| 2648 // can be called from gdb easily. | 2644 // can be called from gdb easily. |
| 2649 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, | 2645 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, |
| 2650 const blink::LayoutObject* object2); | 2646 const blink::LayoutObject* object2); |
| 2651 | 2647 |
| 2652 #endif | 2648 #endif |
| 2653 | 2649 |
| 2654 #endif // LayoutObject_h | 2650 #endif // LayoutObject_h |
| OLD | NEW |