OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 } | 432 } |
433 | 433 |
434 unsigned prefix_length = prefix_string.Size(); | 434 unsigned prefix_length = prefix_string.Size(); |
435 ForwardsTextBuffer string; | 435 ForwardsTextBuffer string; |
436 string.PushRange(prefix_string.Data(), prefix_string.Size()); | 436 string.PushRange(prefix_string.Data(), prefix_string.Size()); |
437 | 437 |
438 const PositionTemplate<Strategy> search_start = | 438 const PositionTemplate<Strategy> search_start = |
439 PositionTemplate<Strategy>::EditingPositionOf( | 439 PositionTemplate<Strategy>::EditingPositionOf( |
440 start.AnchorNode(), start.OffsetInContainerNode()); | 440 start.AnchorNode(), start.OffsetInContainerNode()); |
441 const PositionTemplate<Strategy> search_end = | 441 const PositionTemplate<Strategy> search_end = |
442 PositionTemplate<Strategy>::LastPositionInNode(boundary); | 442 PositionTemplate<Strategy>::LastPositionInNode(*boundary); |
443 TextIteratorAlgorithm<Strategy> it( | 443 TextIteratorAlgorithm<Strategy> it( |
444 search_start, search_end, | 444 search_start, search_end, |
445 TextIteratorBehavior::Builder() | 445 TextIteratorBehavior::Builder() |
446 .SetEmitsCharactersBetweenAllVisiblePositions(true) | 446 .SetEmitsCharactersBetweenAllVisiblePositions(true) |
447 .Build()); | 447 .Build()); |
448 const unsigned kInvalidOffset = static_cast<unsigned>(-1); | 448 const unsigned kInvalidOffset = static_cast<unsigned>(-1); |
449 unsigned next = kInvalidOffset; | 449 unsigned next = kInvalidOffset; |
450 unsigned offset = prefix_length; | 450 unsigned offset = prefix_length; |
451 bool need_more_context = false; | 451 bool need_more_context = false; |
452 while (!it.AtEnd()) { | 452 while (!it.AtEnd()) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 template <typename Strategy> | 604 template <typename Strategy> |
605 static VisiblePositionTemplate<Strategy> EndOfDocumentAlgorithm( | 605 static VisiblePositionTemplate<Strategy> EndOfDocumentAlgorithm( |
606 const VisiblePositionTemplate<Strategy>& visible_position) { | 606 const VisiblePositionTemplate<Strategy>& visible_position) { |
607 DCHECK(visible_position.IsValid()) << visible_position; | 607 DCHECK(visible_position.IsValid()) << visible_position; |
608 Node* node = visible_position.DeepEquivalent().AnchorNode(); | 608 Node* node = visible_position.DeepEquivalent().AnchorNode(); |
609 if (!node || !node->GetDocument().documentElement()) | 609 if (!node || !node->GetDocument().documentElement()) |
610 return VisiblePositionTemplate<Strategy>(); | 610 return VisiblePositionTemplate<Strategy>(); |
611 | 611 |
612 Element* doc = node->GetDocument().documentElement(); | 612 Element* doc = node->GetDocument().documentElement(); |
613 return CreateVisiblePosition( | 613 return CreateVisiblePosition( |
614 PositionTemplate<Strategy>::LastPositionInNode(doc)); | 614 PositionTemplate<Strategy>::LastPositionInNode(*doc)); |
615 } | 615 } |
616 | 616 |
617 VisiblePosition EndOfDocument(const VisiblePosition& c) { | 617 VisiblePosition EndOfDocument(const VisiblePosition& c) { |
618 return EndOfDocumentAlgorithm<EditingStrategy>(c); | 618 return EndOfDocumentAlgorithm<EditingStrategy>(c); |
619 } | 619 } |
620 | 620 |
621 VisiblePositionInFlatTree EndOfDocument(const VisiblePositionInFlatTree& c) { | 621 VisiblePositionInFlatTree EndOfDocument(const VisiblePositionInFlatTree& c) { |
622 return EndOfDocumentAlgorithm<EditingInFlatTreeStrategy>(c); | 622 return EndOfDocumentAlgorithm<EditingInFlatTreeStrategy>(c); |
623 } | 623 } |
624 | 624 |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1989 if (!node) | 1989 if (!node) |
1990 return EphemeralRangeTemplate<Strategy>(); | 1990 return EphemeralRangeTemplate<Strategy>(); |
1991 Document& document = node->GetDocument(); | 1991 Document& document = node->GetDocument(); |
1992 if (!document.documentElement()) | 1992 if (!document.documentElement()) |
1993 return EphemeralRangeTemplate<Strategy>(); | 1993 return EphemeralRangeTemplate<Strategy>(); |
1994 Element* boundary = EnclosingBlockFlowElement(*node); | 1994 Element* boundary = EnclosingBlockFlowElement(*node); |
1995 if (!boundary) | 1995 if (!boundary) |
1996 return EphemeralRangeTemplate<Strategy>(); | 1996 return EphemeralRangeTemplate<Strategy>(); |
1997 | 1997 |
1998 return EphemeralRangeTemplate<Strategy>( | 1998 return EphemeralRangeTemplate<Strategy>( |
1999 pos, PositionTemplate<Strategy>::LastPositionInNode(boundary)); | 1999 pos, PositionTemplate<Strategy>::LastPositionInNode(*boundary)); |
2000 } | 2000 } |
2001 | 2001 |
2002 template <typename Strategy> | 2002 template <typename Strategy> |
2003 static PositionTemplate<Strategy> SkipWhitespaceAlgorithm( | 2003 static PositionTemplate<Strategy> SkipWhitespaceAlgorithm( |
2004 const PositionTemplate<Strategy>& position) { | 2004 const PositionTemplate<Strategy>& position) { |
2005 const EphemeralRangeTemplate<Strategy>& search_range = | 2005 const EphemeralRangeTemplate<Strategy>& search_range = |
2006 MakeSearchRange(position); | 2006 MakeSearchRange(position); |
2007 if (search_range.IsNull()) | 2007 if (search_range.IsNull()) |
2008 return position; | 2008 return position; |
2009 | 2009 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2075 | 2075 |
2076 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) { | 2076 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) { |
2077 return EnclosingIntRect(ComputeTextRectTemplate(range)); | 2077 return EnclosingIntRect(ComputeTextRectTemplate(range)); |
2078 } | 2078 } |
2079 | 2079 |
2080 FloatRect ComputeTextFloatRect(const EphemeralRange& range) { | 2080 FloatRect ComputeTextFloatRect(const EphemeralRange& range) { |
2081 return ComputeTextRectTemplate(range); | 2081 return ComputeTextRectTemplate(range); |
2082 } | 2082 } |
2083 | 2083 |
2084 } // namespace blink | 2084 } // namespace blink |
OLD | NEW |