Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1759)

Side by Side Diff: Source/core/dom/Position.cpp

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase to master Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "wtf/unicode/CharacterNames.h" 47 #include "wtf/unicode/CharacterNames.h"
48 #include <stdio.h> 48 #include <stdio.h>
49 49
50 namespace blink { 50 namespace blink {
51 51
52 using namespace HTMLNames; 52 using namespace HTMLNames;
53 53
54 static Node* nextRenderedEditable(Node* node) 54 static Node* nextRenderedEditable(Node* node)
55 { 55 {
56 for (node = node->nextLeafNode(); node; node = node->nextLeafNode()) { 56 for (node = node->nextLeafNode(); node; node = node->nextLeafNode()) {
57 LayoutObject* renderer = node->renderer(); 57 LayoutObject* renderer = node->layoutObject();
Julien - ping for review 2015/03/05 16:19:16 Ditto.
58 if (!renderer) 58 if (!renderer)
59 continue; 59 continue;
60 if (!node->hasEditableStyle()) 60 if (!node->hasEditableStyle())
61 continue; 61 continue;
62 if ((renderer->isBox() && toLayoutBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toLayoutText(renderer)->firstTextBox())) 62 if ((renderer->isBox() && toLayoutBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toLayoutText(renderer)->firstTextBox()))
63 return node; 63 return node;
64 } 64 }
65 return 0; 65 return 0;
66 } 66 }
67 67
68 static Node* previousRenderedEditable(Node* node) 68 static Node* previousRenderedEditable(Node* node)
69 { 69 {
70 for (node = node->previousLeafNode(); node; node = node->previousLeafNode()) { 70 for (node = node->previousLeafNode(); node; node = node->previousLeafNode()) {
71 LayoutObject* renderer = node->renderer(); 71 LayoutObject* renderer = node->layoutObject();
Julien - ping for review 2015/03/05 16:19:16 Ditto (tired of repeating this so no more ditto).
72 if (!renderer) 72 if (!renderer)
73 continue; 73 continue;
74 if (!node->hasEditableStyle()) 74 if (!node->hasEditableStyle())
75 continue; 75 continue;
76 if ((renderer->isBox() && toLayoutBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toLayoutText(renderer)->firstTextBox())) 76 if ((renderer->isBox() && toLayoutBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toLayoutText(renderer)->firstTextBox()))
77 return node; 77 return node;
78 } 78 }
79 return 0; 79 return 0;
80 } 80 }
81 81
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return createLegacyEditingPosition(node, (moveType == Character) ? unche ckedNextOffset(node, offset) : offset + 1); 357 return createLegacyEditingPosition(node, (moveType == Character) ? unche ckedNextOffset(node, offset) : offset + 1);
358 } 358 }
359 359
360 if (ContainerNode* parent = node->parentNode()) 360 if (ContainerNode* parent = node->parentNode())
361 return createLegacyEditingPosition(parent, node->nodeIndex() + 1); 361 return createLegacyEditingPosition(parent, node->nodeIndex() + 1);
362 return *this; 362 return *this;
363 } 363 }
364 364
365 int Position::uncheckedPreviousOffset(const Node* n, int current) 365 int Position::uncheckedPreviousOffset(const Node* n, int current)
366 { 366 {
367 return n->renderer() ? n->renderer()->previousOffset(current) : current - 1; 367 return n->layoutObject() ? n->layoutObject()->previousOffset(current) : curr ent - 1;
368 } 368 }
369 369
370 int Position::uncheckedPreviousOffsetForBackwardDeletion(const Node* n, int curr ent) 370 int Position::uncheckedPreviousOffsetForBackwardDeletion(const Node* n, int curr ent)
371 { 371 {
372 return n->renderer() ? n->renderer()->previousOffsetForBackwardDeletion(curr ent) : current - 1; 372 return n->layoutObject() ? n->layoutObject()->previousOffsetForBackwardDelet ion(current) : current - 1;
373 } 373 }
374 374
375 int Position::uncheckedNextOffset(const Node* n, int current) 375 int Position::uncheckedNextOffset(const Node* n, int current)
376 { 376 {
377 return n->renderer() ? n->renderer()->nextOffset(current) : current + 1; 377 return n->layoutObject() ? n->layoutObject()->nextOffset(current) : current + 1;
378 } 378 }
379 379
380 bool Position::atFirstEditingPositionForNode() const 380 bool Position::atFirstEditingPositionForNode() const
381 { 381 {
382 if (isNull()) 382 if (isNull())
383 return true; 383 return true;
384 // FIXME: Position before anchor shouldn't be considered as at the first edi ting position for node 384 // FIXME: Position before anchor shouldn't be considered as at the first edi ting position for node
385 // since that position resides outside of the node. 385 // since that position resides outside of the node.
386 switch (m_anchorType) { 386 switch (m_anchorType) {
387 case PositionIsOffsetInAnchor: 387 case PositionIsOffsetInAnchor:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 if (isNull()) 456 if (isNull())
457 return true; 457 return true;
458 return !deprecatedNode()->parentNode() && m_offset >= lastOffsetForEditing(d eprecatedNode()); 458 return !deprecatedNode()->parentNode() && m_offset >= lastOffsetForEditing(d eprecatedNode());
459 } 459 }
460 460
461 int Position::renderedOffset() const 461 int Position::renderedOffset() const
462 { 462 {
463 if (!deprecatedNode()->isTextNode()) 463 if (!deprecatedNode()->isTextNode())
464 return m_offset; 464 return m_offset;
465 465
466 if (!deprecatedNode()->renderer()) 466 if (!deprecatedNode()->layoutObject())
467 return m_offset; 467 return m_offset;
468 468
469 int result = 0; 469 int result = 0;
470 LayoutText* textRenderer = toLayoutText(deprecatedNode()->renderer()); 470 LayoutText* textRenderer = toLayoutText(deprecatedNode()->layoutObject());
471 for (InlineTextBox *box = textRenderer->firstTextBox(); box; box = box->next TextBox()) { 471 for (InlineTextBox *box = textRenderer->firstTextBox(); box; box = box->next TextBox()) {
472 int start = box->start(); 472 int start = box->start();
473 int end = box->start() + box->len(); 473 int end = box->start() + box->len();
474 if (m_offset < start) 474 if (m_offset < start)
475 return result; 475 return result;
476 if (m_offset <= end) { 476 if (m_offset <= end) {
477 result += m_offset - start; 477 result += m_offset - start;
478 return result; 478 return result;
479 } 479 }
480 result += box->len(); 480 result += box->len();
481 } 481 }
482 return result; 482 return result;
483 } 483 }
484 484
485 // Whether or not [node, 0] and [node, lastOffsetForEditing(node)] are their own VisiblePositions. 485 // Whether or not [node, 0] and [node, lastOffsetForEditing(node)] are their own VisiblePositions.
486 // If true, adjacent candidates are visually distinct. 486 // If true, adjacent candidates are visually distinct.
487 // FIXME: Disregard nodes with renderers that have no height, as we do in isCand idate. 487 // FIXME: Disregard nodes with renderers that have no height, as we do in isCand idate.
488 // FIXME: Share code with isCandidate, if possible. 488 // FIXME: Share code with isCandidate, if possible.
489 static bool endsOfNodeAreVisuallyDistinctPositions(Node* node) 489 static bool endsOfNodeAreVisuallyDistinctPositions(Node* node)
490 { 490 {
491 if (!node || !node->renderer()) 491 if (!node || !node->layoutObject())
492 return false; 492 return false;
493 493
494 if (!node->renderer()->isInline()) 494 if (!node->layoutObject()->isInline())
495 return true; 495 return true;
496 496
497 // Don't include inline tables. 497 // Don't include inline tables.
498 if (isHTMLTableElement(*node)) 498 if (isHTMLTableElement(*node))
499 return false; 499 return false;
500 500
501 // A Marquee elements are moving so we should assume their ends are always 501 // A Marquee elements are moving so we should assume their ends are always
502 // visibily distinct. 502 // visibily distinct.
503 if (isHTMLMarqueeElement(*node)) 503 if (isHTMLMarqueeElement(*node))
504 return true; 504 return true;
505 505
506 // There is a VisiblePosition inside an empty inline-block container. 506 // There is a VisiblePosition inside an empty inline-block container.
507 return node->renderer()->isReplaced() && canHaveChildrenForEditing(node) && toLayoutBox(node->renderer())->size().height() != 0 && !node->hasChildren(); 507 return node->layoutObject()->isReplaced() && canHaveChildrenForEditing(node) && toLayoutBox(node->layoutObject())->size().height() != 0 && !node->hasChildre n();
508 } 508 }
509 509
510 static Node* enclosingVisualBoundary(Node* node) 510 static Node* enclosingVisualBoundary(Node* node)
511 { 511 {
512 while (node && !endsOfNodeAreVisuallyDistinctPositions(node)) 512 while (node && !endsOfNodeAreVisuallyDistinctPositions(node))
513 node = node->parentNode(); 513 node = node->parentNode();
514 514
515 return node; 515 return node;
516 } 516 }
517 517
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 } 563 }
564 lastNode = currentNode; 564 lastNode = currentNode;
565 } 565 }
566 566
567 // If we've moved to a position that is visually distinct, return the la st saved position. There 567 // If we've moved to a position that is visually distinct, return the la st saved position. There
568 // is code below that terminates early if we're *about* to move to a vis ually distinct position. 568 // is code below that terminates early if we're *about* to move to a vis ually distinct position.
569 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentNode ! = boundary) 569 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentNode ! = boundary)
570 return lastVisible; 570 return lastVisible;
571 571
572 // skip position in unrendered or invisible node 572 // skip position in unrendered or invisible node
573 LayoutObject* renderer = currentNode->renderer(); 573 LayoutObject* renderer = currentNode->layoutObject();
574 if (!renderer || renderer->style()->visibility() != VISIBLE) 574 if (!renderer || renderer->style()->visibility() != VISIBLE)
575 continue; 575 continue;
576 576
577 if (rule == CanCrossEditingBoundary && boundaryCrossed) { 577 if (rule == CanCrossEditingBoundary && boundaryCrossed) {
578 lastVisible = currentPos; 578 lastVisible = currentPos;
579 break; 579 break;
580 } 580 }
581 581
582 // track last visible streamer position 582 // track last visible streamer position
583 if (isStreamer(currentPos)) 583 if (isStreamer(currentPos))
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 621
622 // The text continues on the next line only if the last text box is not on this line and 622 // The text continues on the next line only if the last text box is not on this line and
623 // none of the boxes on this line have a larger start offset. 623 // none of the boxes on this line have a larger start offset.
624 624
625 bool continuesOnNextLine = true; 625 bool continuesOnNextLine = true;
626 InlineBox* otherBox = box; 626 InlineBox* otherBox = box;
627 while (continuesOnNextLine) { 627 while (continuesOnNextLine) {
628 otherBox = otherBox->nextLeafChild(); 628 otherBox = otherBox->nextLeafChild();
629 if (!otherBox) 629 if (!otherBox)
630 break; 630 break;
631 if (otherBox == lastTextBox || (otherBox->renderer() == text Renderer && toInlineTextBox(otherBox)->start() > textOffset)) 631 if (otherBox == lastTextBox || (otherBox->layoutObject() == textRenderer && toInlineTextBox(otherBox)->start() > textOffset))
632 continuesOnNextLine = false; 632 continuesOnNextLine = false;
633 } 633 }
634 634
635 otherBox = box; 635 otherBox = box;
636 while (continuesOnNextLine) { 636 while (continuesOnNextLine) {
637 otherBox = otherBox->prevLeafChild(); 637 otherBox = otherBox->prevLeafChild();
638 if (!otherBox) 638 if (!otherBox)
639 break; 639 break;
640 if (otherBox == lastTextBox || (otherBox->renderer() == text Renderer && toInlineTextBox(otherBox)->start() > textOffset)) 640 if (otherBox == lastTextBox || (otherBox->layoutObject() == textRenderer && toInlineTextBox(otherBox)->start() > textOffset))
641 continuesOnNextLine = false; 641 continuesOnNextLine = false;
642 } 642 }
643 643
644 if (continuesOnNextLine) 644 if (continuesOnNextLine)
645 return currentPos; 645 return currentPos;
646 } 646 }
647 } 647 }
648 } 648 }
649 649
650 return lastVisible; 650 return lastVisible;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 // Do not move to a visually distinct position. 696 // Do not move to a visually distinct position.
697 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentNode ! = boundary) 697 if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentNode ! = boundary)
698 return lastVisible; 698 return lastVisible;
699 // Do not move past a visually disinct position. 699 // Do not move past a visually disinct position.
700 // Note: The first position after the last in a node whose ends are visu ally distinct 700 // Note: The first position after the last in a node whose ends are visu ally distinct
701 // positions will be [boundary->parentNode(), originalBlock->nodeIndex() + 1]. 701 // positions will be [boundary->parentNode(), originalBlock->nodeIndex() + 1].
702 if (boundary && boundary->parentNode() == currentNode) 702 if (boundary && boundary->parentNode() == currentNode)
703 return lastVisible; 703 return lastVisible;
704 704
705 // skip position in unrendered or invisible node 705 // skip position in unrendered or invisible node
706 LayoutObject* renderer = currentNode->renderer(); 706 LayoutObject* renderer = currentNode->layoutObject();
707 if (!renderer || renderer->style()->visibility() != VISIBLE) 707 if (!renderer || renderer->style()->visibility() != VISIBLE)
708 continue; 708 continue;
709 709
710 if (rule == CanCrossEditingBoundary && boundaryCrossed) { 710 if (rule == CanCrossEditingBoundary && boundaryCrossed) {
711 lastVisible = currentPos; 711 lastVisible = currentPos;
712 break; 712 break;
713 } 713 }
714 714
715 // track last visible streamer position 715 // track last visible streamer position
716 if (isStreamer(currentPos)) 716 if (isStreamer(currentPos))
(...skipping 28 matching lines...) Expand all
745 745
746 // The text continues on the next line only if the last text box is not on this line and 746 // The text continues on the next line only if the last text box is not on this line and
747 // none of the boxes on this line have a larger start offset. 747 // none of the boxes on this line have a larger start offset.
748 748
749 bool continuesOnNextLine = true; 749 bool continuesOnNextLine = true;
750 InlineBox* otherBox = box; 750 InlineBox* otherBox = box;
751 while (continuesOnNextLine) { 751 while (continuesOnNextLine) {
752 otherBox = otherBox->nextLeafChild(); 752 otherBox = otherBox->nextLeafChild();
753 if (!otherBox) 753 if (!otherBox)
754 break; 754 break;
755 if (otherBox == lastTextBox || (otherBox->renderer() == text Renderer && toInlineTextBox(otherBox)->start() >= textOffset)) 755 if (otherBox == lastTextBox || (otherBox->layoutObject() == textRenderer && toInlineTextBox(otherBox)->start() >= textOffset))
756 continuesOnNextLine = false; 756 continuesOnNextLine = false;
757 } 757 }
758 758
759 otherBox = box; 759 otherBox = box;
760 while (continuesOnNextLine) { 760 while (continuesOnNextLine) {
761 otherBox = otherBox->prevLeafChild(); 761 otherBox = otherBox->prevLeafChild();
762 if (!otherBox) 762 if (!otherBox)
763 break; 763 break;
764 if (otherBox == lastTextBox || (otherBox->renderer() == text Renderer && toInlineTextBox(otherBox)->start() >= textOffset)) 764 if (otherBox == lastTextBox || (otherBox->layoutObject() == textRenderer && toInlineTextBox(otherBox)->start() >= textOffset))
765 continuesOnNextLine = false; 765 continuesOnNextLine = false;
766 } 766 }
767 767
768 if (continuesOnNextLine) 768 if (continuesOnNextLine)
769 return currentPos; 769 return currentPos;
770 } 770 }
771 } 771 }
772 } 772 }
773 773
774 return lastVisible; 774 return lastVisible;
(...skipping 12 matching lines...) Expand all
787 if ((o->isText() && boundingBoxLogicalHeight(o, toLayoutText(o)->lin esBoundingBox())) 787 if ((o->isText() && boundingBoxLogicalHeight(o, toLayoutText(o)->lin esBoundingBox()))
788 || (o->isBox() && toLayoutBox(o)->pixelSnappedLogicalHeight()) 788 || (o->isBox() && toLayoutBox(o)->pixelSnappedLogicalHeight())
789 || (o->isLayoutInline() && isEmptyInline(o) && boundingBoxLogica lHeight(o, toLayoutInline(o)->linesBoundingBox()))) 789 || (o->isLayoutInline() && isEmptyInline(o) && boundingBoxLogica lHeight(o, toLayoutInline(o)->linesBoundingBox())))
790 return true; 790 return true;
791 } 791 }
792 return false; 792 return false;
793 } 793 }
794 794
795 bool Position::nodeIsUserSelectNone(Node* node) 795 bool Position::nodeIsUserSelectNone(Node* node)
796 { 796 {
797 return node && node->renderer() && !node->renderer()->isSelectable(); 797 return node && node->layoutObject() && !node->layoutObject()->isSelectable() ;
798 } 798 }
799 799
800 bool Position::nodeIsUserSelectAll(const Node* node) 800 bool Position::nodeIsUserSelectAll(const Node* node)
801 { 801 {
802 return RuntimeEnabledFeatures::userSelectAllEnabled() && node && node->rende rer() && node->renderer()->style()->userSelect() == SELECT_ALL; 802 return RuntimeEnabledFeatures::userSelectAllEnabled() && node && node->layou tObject() && node->layoutObject()->style()->userSelect() == SELECT_ALL;
803 } 803 }
804 804
805 Node* Position::rootUserSelectAllForNode(Node* node) 805 Node* Position::rootUserSelectAllForNode(Node* node)
806 { 806 {
807 if (!node || !nodeIsUserSelectAll(node)) 807 if (!node || !nodeIsUserSelectAll(node))
808 return 0; 808 return 0;
809 Node* parent = node->parentNode(); 809 Node* parent = node->parentNode();
810 if (!parent) 810 if (!parent)
811 return node; 811 return node;
812 812
813 Node* candidateRoot = node; 813 Node* candidateRoot = node;
814 while (parent) { 814 while (parent) {
815 if (!parent->renderer()) { 815 if (!parent->layoutObject()) {
816 parent = parent->parentNode(); 816 parent = parent->parentNode();
817 continue; 817 continue;
818 } 818 }
819 if (!nodeIsUserSelectAll(parent)) 819 if (!nodeIsUserSelectAll(parent))
820 break; 820 break;
821 candidateRoot = parent; 821 candidateRoot = parent;
822 parent = candidateRoot->parentNode(); 822 parent = candidateRoot->parentNode();
823 } 823 }
824 return candidateRoot; 824 return candidateRoot;
825 } 825 }
826 826
827 bool Position::isCandidate() const 827 bool Position::isCandidate() const
828 { 828 {
829 if (isNull()) 829 if (isNull())
830 return false; 830 return false;
831 831
832 LayoutObject* renderer = deprecatedNode()->renderer(); 832 LayoutObject* renderer = deprecatedNode()->layoutObject();
833 if (!renderer) 833 if (!renderer)
834 return false; 834 return false;
835 835
836 if (renderer->style()->visibility() != VISIBLE) 836 if (renderer->style()->visibility() != VISIBLE)
837 return false; 837 return false;
838 838
839 if (renderer->isBR()) 839 if (renderer->isBR())
840 // FIXME: The condition should be m_anchorType == PositionIsBeforeAnchor , but for now we still need to support legacy positions. 840 // FIXME: The condition should be m_anchorType == PositionIsBeforeAnchor , but for now we still need to support legacy positions.
841 return !m_offset && m_anchorType != PositionIsAfterAnchor && !nodeIsUser SelectNone(deprecatedNode()->parentNode()); 841 return !m_offset && m_anchorType != PositionIsAfterAnchor && !nodeIsUser SelectNone(deprecatedNode()->parentNode());
842 842
(...skipping 25 matching lines...) Expand all
868 } 868 }
869 869
870 return false; 870 return false;
871 } 871 }
872 872
873 bool Position::inRenderedText() const 873 bool Position::inRenderedText() const
874 { 874 {
875 if (isNull() || !deprecatedNode()->isTextNode()) 875 if (isNull() || !deprecatedNode()->isTextNode())
876 return false; 876 return false;
877 877
878 LayoutObject* renderer = deprecatedNode()->renderer(); 878 LayoutObject* renderer = deprecatedNode()->layoutObject();
879 if (!renderer) 879 if (!renderer)
880 return false; 880 return false;
881 881
882 LayoutText* textRenderer = toLayoutText(renderer); 882 LayoutText* textRenderer = toLayoutText(renderer);
883 for (InlineTextBox *box = textRenderer->firstTextBox(); box; box = box->next TextBox()) { 883 for (InlineTextBox *box = textRenderer->firstTextBox(); box; box = box->next TextBox()) {
884 if (m_offset < static_cast<int>(box->start()) && !textRenderer->contains ReversedText()) { 884 if (m_offset < static_cast<int>(box->start()) && !textRenderer->contains ReversedText()) {
885 // The offset we're looking for is before this node 885 // The offset we're looking for is before this node
886 // this means the offset must be in content that is 886 // this means the offset must be in content that is
887 // not rendered. Return false. 887 // not rendered. Return false.
888 return false; 888 return false;
889 } 889 }
890 if (box->containsCaretOffset(m_offset)) 890 if (box->containsCaretOffset(m_offset))
891 // Return false for offsets inside composed characters. 891 // Return false for offsets inside composed characters.
892 return m_offset == 0 || m_offset == textRenderer->nextOffset(textRen derer->previousOffset(m_offset)); 892 return m_offset == 0 || m_offset == textRenderer->nextOffset(textRen derer->previousOffset(m_offset));
893 } 893 }
894 894
895 return false; 895 return false;
896 } 896 }
897 897
898 bool Position::isRenderedCharacter() const 898 bool Position::isRenderedCharacter() const
899 { 899 {
900 if (isNull() || !deprecatedNode()->isTextNode()) 900 if (isNull() || !deprecatedNode()->isTextNode())
901 return false; 901 return false;
902 902
903 LayoutObject* renderer = deprecatedNode()->renderer(); 903 LayoutObject* renderer = deprecatedNode()->layoutObject();
904 if (!renderer) 904 if (!renderer)
905 return false; 905 return false;
906 906
907 LayoutText* textRenderer = toLayoutText(renderer); 907 LayoutText* textRenderer = toLayoutText(renderer);
908 for (InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->next TextBox()) { 908 for (InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->next TextBox()) {
909 if (m_offset < static_cast<int>(box->start()) && !textRenderer->contains ReversedText()) { 909 if (m_offset < static_cast<int>(box->start()) && !textRenderer->contains ReversedText()) {
910 // The offset we're looking for is before this node 910 // The offset we're looking for is before this node
911 // this means the offset must be in content that is 911 // this means the offset must be in content that is
912 // not rendered. Return false. 912 // not rendered. Return false.
913 return false; 913 return false;
914 } 914 }
915 if (m_offset >= static_cast<int>(box->start()) && m_offset < static_cast <int>(box->start() + box->len())) 915 if (m_offset >= static_cast<int>(box->start()) && m_offset < static_cast <int>(box->start() + box->len()))
916 return true; 916 return true;
917 } 917 }
918 918
919 return false; 919 return false;
920 } 920 }
921 921
922 bool Position::rendersInDifferentPosition(const Position &pos) const 922 bool Position::rendersInDifferentPosition(const Position &pos) const
923 { 923 {
924 if (isNull() || pos.isNull()) 924 if (isNull() || pos.isNull())
925 return false; 925 return false;
926 926
927 LayoutObject* renderer = deprecatedNode()->renderer(); 927 LayoutObject* renderer = deprecatedNode()->layoutObject();
928 if (!renderer) 928 if (!renderer)
929 return false; 929 return false;
930 930
931 LayoutObject* posRenderer = pos.deprecatedNode()->renderer(); 931 LayoutObject* posRenderer = pos.deprecatedNode()->layoutObject();
932 if (!posRenderer) 932 if (!posRenderer)
933 return false; 933 return false;
934 934
935 if (renderer->style()->visibility() != VISIBLE || 935 if (renderer->style()->visibility() != VISIBLE ||
936 posRenderer->style()->visibility() != VISIBLE) 936 posRenderer->style()->visibility() != VISIBLE)
937 return false; 937 return false;
938 938
939 if (deprecatedNode() == pos.deprecatedNode()) { 939 if (deprecatedNode() == pos.deprecatedNode()) {
940 if (isHTMLBRElement(*deprecatedNode())) 940 if (isHTMLBRElement(*deprecatedNode()))
941 return false; 941 return false;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 while (position != lastPosition) { 1062 while (position != lastPosition) {
1063 lastPosition = position; 1063 lastPosition = position;
1064 position = position.upstream(CanCrossEditingBoundary); 1064 position = position.upstream(CanCrossEditingBoundary);
1065 } 1065 }
1066 return position; 1066 return position;
1067 } 1067 }
1068 1068
1069 void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDi rection, InlineBox*& inlineBox, int& caretOffset) const 1069 void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDi rection, InlineBox*& inlineBox, int& caretOffset) const
1070 { 1070 {
1071 caretOffset = deprecatedEditingOffset(); 1071 caretOffset = deprecatedEditingOffset();
1072 LayoutObject* renderer = deprecatedNode()->renderer(); 1072 LayoutObject* renderer = deprecatedNode()->layoutObject();
1073 1073
1074 if (!renderer->isText()) { 1074 if (!renderer->isText()) {
1075 inlineBox = 0; 1075 inlineBox = 0;
1076 if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isLayoutBlo ckFlow() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) { 1076 if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isLayoutBlo ckFlow() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) {
1077 // Try a visually equivalent position with possibly opposite editabi lity. This helps in case |this| is in 1077 // Try a visually equivalent position with possibly opposite editabi lity. This helps in case |this| is in
1078 // an editable block but surrounded by non-editable positions. It ac ts to negate the logic at the beginning 1078 // an editable block but surrounded by non-editable positions. It ac ts to negate the logic at the beginning
1079 // of LayoutObject::createVisiblePosition(). 1079 // of LayoutObject::createVisiblePosition().
1080 Position equivalent = downstreamIgnoringEditingBoundaries(*this); 1080 Position equivalent = downstreamIgnoringEditingBoundaries(*this);
1081 if (equivalent == *this) { 1081 if (equivalent == *this) {
1082 equivalent = upstreamIgnoringEditingBoundaries(*this); 1082 equivalent = upstreamIgnoringEditingBoundaries(*this);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 inlineBox = tertiaryBox; 1218 inlineBox = tertiaryBox;
1219 } 1219 }
1220 caretOffset = inlineBox->caretRightmostOffset(); 1220 caretOffset = inlineBox->caretRightmostOffset();
1221 } 1221 }
1222 } 1222 }
1223 } 1223 }
1224 1224
1225 TextDirection Position::primaryDirection() const 1225 TextDirection Position::primaryDirection() const
1226 { 1226 {
1227 TextDirection primaryDirection = LTR; 1227 TextDirection primaryDirection = LTR;
1228 for (const LayoutObject* r = m_anchorNode->renderer(); r; r = r->parent()) { 1228 for (const LayoutObject* r = m_anchorNode->layoutObject(); r; r = r->parent( )) {
1229 if (r->isLayoutBlockFlow()) { 1229 if (r->isLayoutBlockFlow()) {
1230 primaryDirection = r->style()->direction(); 1230 primaryDirection = r->style()->direction();
1231 break; 1231 break;
1232 } 1232 }
1233 } 1233 }
1234 1234
1235 return primaryDirection; 1235 return primaryDirection;
1236 } 1236 }
1237 1237
1238 DEFINE_TRACE(Position) 1238 DEFINE_TRACE(Position)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 pos.showTreeForThis(); 1313 pos.showTreeForThis();
1314 } 1314 }
1315 1315
1316 void showTree(const blink::Position* pos) 1316 void showTree(const blink::Position* pos)
1317 { 1317 {
1318 if (pos) 1318 if (pos)
1319 pos->showTreeForThis(); 1319 pos->showTreeForThis();
1320 } 1320 }
1321 1321
1322 #endif 1322 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698