| OLD | NEW |
| 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) 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) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 #include "wtf/RefCountedLeakCounter.h" | 69 #include "wtf/RefCountedLeakCounter.h" |
| 70 #include "wtf/text/StringBuilder.h" | 70 #include "wtf/text/StringBuilder.h" |
| 71 #include "wtf/text/WTFString.h" | 71 #include "wtf/text/WTFString.h" |
| 72 #include <algorithm> | 72 #include <algorithm> |
| 73 #ifndef NDEBUG | 73 #ifndef NDEBUG |
| 74 #include <stdio.h> | 74 #include <stdio.h> |
| 75 #endif | 75 #endif |
| 76 | 76 |
| 77 namespace blink { | 77 namespace blink { |
| 78 | 78 |
| 79 namespace { | |
| 80 | |
| 81 static bool gModifyRenderTreeStructureAnyState = false; | |
| 82 | |
| 83 } // namespace | |
| 84 | |
| 85 #if ENABLE(ASSERT) | 79 #if ENABLE(ASSERT) |
| 86 | 80 |
| 87 RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Rende
rObject& renderObject) | 81 RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(Rende
rObject& renderObject) |
| 88 : m_renderObject(renderObject) | 82 : m_renderObject(renderObject) |
| 89 , m_preexistingForbidden(m_renderObject.isSetNeedsLayoutForbidden()) | 83 , m_preexistingForbidden(m_renderObject.isSetNeedsLayoutForbidden()) |
| 90 { | 84 { |
| 91 m_renderObject.setNeedsLayoutIsForbidden(true); | 85 m_renderObject.setNeedsLayoutIsForbidden(true); |
| 92 } | 86 } |
| 93 | 87 |
| 94 RenderObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() | 88 RenderObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() |
| (...skipping 2380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2475 if (ancestor->isPositioned()) | 2469 if (ancestor->isPositioned()) |
| 2476 break; | 2470 break; |
| 2477 } | 2471 } |
| 2478 | 2472 |
| 2479 return node && node->isElementNode() ? toElement(node) : 0; | 2473 return node && node->isElementNode() ? toElement(node) : 0; |
| 2480 } | 2474 } |
| 2481 | 2475 |
| 2482 PositionWithAffinity RenderObject::createPositionWithAffinity(int offset, EAffin
ity affinity) | 2476 PositionWithAffinity RenderObject::createPositionWithAffinity(int offset, EAffin
ity affinity) |
| 2483 { | 2477 { |
| 2484 // If this is a non-anonymous renderer in an editable area, then it's simple
. | 2478 // If this is a non-anonymous renderer in an editable area, then it's simple
. |
| 2485 if (Node* node = nonPseudoNode()) { | 2479 if (Node* node = this->node()) { |
| 2486 if (!node->hasEditableStyle()) { | 2480 if (!node->hasEditableStyle()) { |
| 2487 // If it can be found, we prefer a visually equivalent position that
is editable. | 2481 // If it can be found, we prefer a visually equivalent position that
is editable. |
| 2488 Position position = createLegacyEditingPosition(node, offset); | 2482 Position position = createLegacyEditingPosition(node, offset); |
| 2489 Position candidate = position.downstream(CanCrossEditingBoundary); | 2483 Position candidate = position.downstream(CanCrossEditingBoundary); |
| 2490 if (candidate.deprecatedNode()->hasEditableStyle()) | 2484 if (candidate.deprecatedNode()->hasEditableStyle()) |
| 2491 return PositionWithAffinity(candidate, affinity); | 2485 return PositionWithAffinity(candidate, affinity); |
| 2492 candidate = position.upstream(CanCrossEditingBoundary); | 2486 candidate = position.upstream(CanCrossEditingBoundary); |
| 2493 if (candidate.deprecatedNode()->hasEditableStyle()) | 2487 if (candidate.deprecatedNode()->hasEditableStyle()) |
| 2494 return PositionWithAffinity(candidate, affinity); | 2488 return PositionWithAffinity(candidate, affinity); |
| 2495 } | 2489 } |
| 2496 // FIXME: Eliminate legacy editing positions | 2490 // FIXME: Eliminate legacy editing positions |
| 2497 return PositionWithAffinity(createLegacyEditingPosition(node, offset), a
ffinity); | 2491 return PositionWithAffinity(createLegacyEditingPosition(node, offset), a
ffinity); |
| 2498 } | 2492 } |
| 2499 | 2493 |
| 2500 // We don't want to cross the boundary between editable and non-editable | 2494 // We don't want to cross the boundary between editable and non-editable |
| 2501 // regions of the document, but that is either impossible or at least | 2495 // regions of the document, but that is either impossible or at least |
| 2502 // extremely unlikely in any normal case because we stop as soon as we | 2496 // extremely unlikely in any normal case because we stop as soon as we |
| 2503 // find a single non-anonymous renderer. | 2497 // find a single non-anonymous renderer. |
| 2504 | 2498 |
| 2505 // Find a nearby non-anonymous renderer. | 2499 // Find a nearby non-anonymous renderer. |
| 2506 RenderObject* child = this; | 2500 RenderObject* child = this; |
| 2507 while (RenderObject* parent = child->parent()) { | 2501 while (RenderObject* parent = child->parent()) { |
| 2508 // Find non-anonymous content after. | 2502 // Find non-anonymous content after. |
| 2509 for (RenderObject* renderer = child->nextInPreOrder(parent); renderer; r
enderer = renderer->nextInPreOrder(parent)) { | 2503 for (RenderObject* renderer = child->nextInPreOrder(parent); renderer; r
enderer = renderer->nextInPreOrder(parent)) { |
| 2510 if (Node* node = renderer->nonPseudoNode()) | 2504 if (Node* node = renderer->node()) |
| 2511 return PositionWithAffinity(firstPositionInOrBeforeNode(node), D
OWNSTREAM); | 2505 return PositionWithAffinity(firstPositionInOrBeforeNode(node), D
OWNSTREAM); |
| 2512 } | 2506 } |
| 2513 | 2507 |
| 2514 // Find non-anonymous content before. | 2508 // Find non-anonymous content before. |
| 2515 for (RenderObject* renderer = child->previousInPreOrder(); renderer; ren
derer = renderer->previousInPreOrder()) { | 2509 for (RenderObject* renderer = child->previousInPreOrder(); renderer; ren
derer = renderer->previousInPreOrder()) { |
| 2516 if (renderer == parent) | 2510 if (renderer == parent) |
| 2517 break; | 2511 break; |
| 2518 if (Node* node = renderer->nonPseudoNode()) | 2512 if (Node* node = renderer->node()) |
| 2519 return PositionWithAffinity(lastPositionInOrAfterNode(node), DOW
NSTREAM); | 2513 return PositionWithAffinity(lastPositionInOrAfterNode(node), DOW
NSTREAM); |
| 2520 } | 2514 } |
| 2521 | 2515 |
| 2522 // Use the parent itself unless it too is anonymous. | 2516 // Use the parent itself unless it too is anonymous. |
| 2523 if (Node* node = parent->nonPseudoNode()) | 2517 if (Node* node = parent->node()) |
| 2524 return PositionWithAffinity(firstPositionInOrBeforeNode(node), DOWNS
TREAM); | 2518 return PositionWithAffinity(firstPositionInOrBeforeNode(node), DOWNS
TREAM); |
| 2525 | 2519 |
| 2526 // Repeat at the next level up. | 2520 // Repeat at the next level up. |
| 2527 child = parent; | 2521 child = parent; |
| 2528 } | 2522 } |
| 2529 | 2523 |
| 2530 // Everything was anonymous. Give up. | 2524 // Everything was anonymous. Give up. |
| 2531 return PositionWithAffinity(); | 2525 return PositionWithAffinity(); |
| 2532 } | 2526 } |
| 2533 | 2527 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2547 | 2541 |
| 2548 bool RenderObject::canUpdateSelectionOnRootLineBoxes() | 2542 bool RenderObject::canUpdateSelectionOnRootLineBoxes() |
| 2549 { | 2543 { |
| 2550 if (needsLayout()) | 2544 if (needsLayout()) |
| 2551 return false; | 2545 return false; |
| 2552 | 2546 |
| 2553 RenderBlock* containingBlock = this->containingBlock(); | 2547 RenderBlock* containingBlock = this->containingBlock(); |
| 2554 return containingBlock ? !containingBlock->needsLayout() : false; | 2548 return containingBlock ? !containingBlock->needsLayout() : false; |
| 2555 } | 2549 } |
| 2556 | 2550 |
| 2557 // We only create "generated" child renderers like one for first-letter if: | |
| 2558 // - the firstLetterBlock can have children in the DOM and | |
| 2559 // - the block doesn't have any special assumption on its text children. | |
| 2560 // This correctly prevents form controls from having such renderers. | |
| 2561 bool RenderObject::canHaveGeneratedChildren() const | |
| 2562 { | |
| 2563 return canHaveChildren(); | |
| 2564 } | |
| 2565 | |
| 2566 void RenderObject::setNeedsBoundariesUpdate() | |
| 2567 { | |
| 2568 if (RenderObject* renderer = parent()) | |
| 2569 renderer->setNeedsBoundariesUpdate(); | |
| 2570 } | |
| 2571 | |
| 2572 FloatRect RenderObject::objectBoundingBox() const | |
| 2573 { | |
| 2574 ASSERT_NOT_REACHED(); | |
| 2575 return FloatRect(); | |
| 2576 } | |
| 2577 | |
| 2578 FloatRect RenderObject::strokeBoundingBox() const | |
| 2579 { | |
| 2580 ASSERT_NOT_REACHED(); | |
| 2581 return FloatRect(); | |
| 2582 } | |
| 2583 | |
| 2584 // Returns the smallest rectangle enclosing all of the painted content | 2551 // Returns the smallest rectangle enclosing all of the painted content |
| 2585 // respecting clipping, masking, filters, opacity, stroke-width and markers | 2552 // respecting clipping, masking, filters, opacity, stroke-width and markers |
| 2586 FloatRect RenderObject::paintInvalidationRectInLocalCoordinates() const | 2553 FloatRect RenderObject::paintInvalidationRectInLocalCoordinates() const |
| 2587 { | 2554 { |
| 2588 ASSERT_NOT_REACHED(); | 2555 ASSERT_NOT_REACHED(); |
| 2589 return FloatRect(); | 2556 return FloatRect(); |
| 2590 } | 2557 } |
| 2591 | 2558 |
| 2592 AffineTransform RenderObject::localTransform() const | |
| 2593 { | |
| 2594 static const AffineTransform identity; | |
| 2595 return identity; | |
| 2596 } | |
| 2597 | |
| 2598 const AffineTransform& RenderObject::localToParentTransform() const | |
| 2599 { | |
| 2600 static const AffineTransform identity; | |
| 2601 return identity; | |
| 2602 } | |
| 2603 | |
| 2604 bool RenderObject::nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const
FloatPoint&, HitTestAction) | 2559 bool RenderObject::nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const
FloatPoint&, HitTestAction) |
| 2605 { | 2560 { |
| 2606 ASSERT_NOT_REACHED(); | 2561 ASSERT_NOT_REACHED(); |
| 2607 return false; | 2562 return false; |
| 2608 } | 2563 } |
| 2609 | 2564 |
| 2610 bool RenderObject::isRelayoutBoundaryForInspector() const | 2565 bool RenderObject::isRelayoutBoundaryForInspector() const |
| 2611 { | 2566 { |
| 2612 return objectIsRelayoutBoundary(this); | 2567 return objectIsRelayoutBoundary(this); |
| 2613 } | 2568 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2632 setShouldDoFullPaintInvalidationIfSelfPaintingLayer(false); | 2587 setShouldDoFullPaintInvalidationIfSelfPaintingLayer(false); |
| 2633 setOnlyNeededPositionedMovementLayout(false); | 2588 setOnlyNeededPositionedMovementLayout(false); |
| 2634 setNeededLayoutBecauseOfChildren(false); | 2589 setNeededLayoutBecauseOfChildren(false); |
| 2635 setShouldInvalidateOverflowForPaint(false); | 2590 setShouldInvalidateOverflowForPaint(false); |
| 2636 setLayoutDidGetCalled(false); | 2591 setLayoutDidGetCalled(false); |
| 2637 setMayNeedPaintInvalidation(false); | 2592 setMayNeedPaintInvalidation(false); |
| 2638 } | 2593 } |
| 2639 | 2594 |
| 2640 bool RenderObject::isAllowedToModifyRenderTreeStructure(Document& document) | 2595 bool RenderObject::isAllowedToModifyRenderTreeStructure(Document& document) |
| 2641 { | 2596 { |
| 2642 return DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTre
eStateInAnyState() | 2597 return document.lifecycle().stateAllowsRenderTreeMutations(); |
| 2643 || document.lifecycle().stateAllowsRenderTreeMutations(); | |
| 2644 } | |
| 2645 | |
| 2646 DeprecatedDisableModifyRenderTreeStructureAsserts::DeprecatedDisableModifyRender
TreeStructureAsserts() | |
| 2647 : m_disabler(gModifyRenderTreeStructureAnyState, true) | |
| 2648 { | |
| 2649 } | |
| 2650 | |
| 2651 bool DeprecatedDisableModifyRenderTreeStructureAsserts::canModifyRenderTreeState
InAnyState() | |
| 2652 { | |
| 2653 return gModifyRenderTreeStructureAnyState; | |
| 2654 } | 2598 } |
| 2655 | 2599 |
| 2656 } // namespace blink | 2600 } // namespace blink |
| 2657 | 2601 |
| 2658 #ifndef NDEBUG | 2602 #ifndef NDEBUG |
| 2659 | 2603 |
| 2660 void showTree(const blink::RenderObject* object) | 2604 void showTree(const blink::RenderObject* object) |
| 2661 { | 2605 { |
| 2662 if (object) | 2606 if (object) |
| 2663 object->showTreeForThis(); | 2607 object->showTreeForThis(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2678 { | 2622 { |
| 2679 if (object1) { | 2623 if (object1) { |
| 2680 const blink::RenderObject* root = object1; | 2624 const blink::RenderObject* root = object1; |
| 2681 while (root->parent()) | 2625 while (root->parent()) |
| 2682 root = root->parent(); | 2626 root = root->parent(); |
| 2683 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 2627 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 2684 } | 2628 } |
| 2685 } | 2629 } |
| 2686 | 2630 |
| 2687 #endif | 2631 #endif |
| OLD | NEW |