| 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 Node* boundary = ParentEditingBoundary(pos); | 411 Node* boundary = ParentEditingBoundary(pos); |
| 412 if (!boundary) | 412 if (!boundary) |
| 413 return PositionTemplate<Strategy>(); | 413 return PositionTemplate<Strategy>(); |
| 414 | 414 |
| 415 Document& d = boundary->GetDocument(); | 415 Document& d = boundary->GetDocument(); |
| 416 const PositionTemplate<Strategy> start(pos.ParentAnchoredEquivalent()); | 416 const PositionTemplate<Strategy> start(pos.ParentAnchoredEquivalent()); |
| 417 | 417 |
| 418 BackwardsTextBuffer prefix_string; | 418 BackwardsTextBuffer prefix_string; |
| 419 if (RequiresContextForWordBoundary(CharacterAfter(c))) { | 419 if (RequiresContextForWordBoundary(CharacterAfter(c))) { |
| 420 SimplifiedBackwardsTextIteratorAlgorithm<Strategy> backwards_iterator( | 420 SimplifiedBackwardsTextIteratorAlgorithm<Strategy> backwards_iterator( |
| 421 PositionTemplate<Strategy>::FirstPositionInNode(&d), start); | 421 PositionTemplate<Strategy>::FirstPositionInNode(d), start); |
| 422 while (!backwards_iterator.AtEnd()) { | 422 while (!backwards_iterator.AtEnd()) { |
| 423 backwards_iterator.CopyTextTo(&prefix_string); | 423 backwards_iterator.CopyTextTo(&prefix_string); |
| 424 int context_start_index = StartOfLastWordBoundaryContext( | 424 int context_start_index = StartOfLastWordBoundaryContext( |
| 425 prefix_string.Data(), backwards_iterator.length()); | 425 prefix_string.Data(), backwards_iterator.length()); |
| 426 if (context_start_index > 0) { | 426 if (context_start_index > 0) { |
| 427 prefix_string.Shrink(context_start_index); | 427 prefix_string.Shrink(context_start_index); |
| 428 break; | 428 break; |
| 429 } | 429 } |
| 430 backwards_iterator.Advance(); | 430 backwards_iterator.Advance(); |
| 431 } | 431 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 | 583 |
| 584 template <typename Strategy> | 584 template <typename Strategy> |
| 585 static VisiblePositionTemplate<Strategy> StartOfDocumentAlgorithm( | 585 static VisiblePositionTemplate<Strategy> StartOfDocumentAlgorithm( |
| 586 const VisiblePositionTemplate<Strategy>& visible_position) { | 586 const VisiblePositionTemplate<Strategy>& visible_position) { |
| 587 DCHECK(visible_position.IsValid()) << visible_position; | 587 DCHECK(visible_position.IsValid()) << visible_position; |
| 588 Node* node = visible_position.DeepEquivalent().AnchorNode(); | 588 Node* node = visible_position.DeepEquivalent().AnchorNode(); |
| 589 if (!node || !node->GetDocument().documentElement()) | 589 if (!node || !node->GetDocument().documentElement()) |
| 590 return VisiblePositionTemplate<Strategy>(); | 590 return VisiblePositionTemplate<Strategy>(); |
| 591 | 591 |
| 592 return CreateVisiblePosition(PositionTemplate<Strategy>::FirstPositionInNode( | 592 return CreateVisiblePosition(PositionTemplate<Strategy>::FirstPositionInNode( |
| 593 node->GetDocument().documentElement())); | 593 *node->GetDocument().documentElement())); |
| 594 } | 594 } |
| 595 | 595 |
| 596 VisiblePosition StartOfDocument(const VisiblePosition& c) { | 596 VisiblePosition StartOfDocument(const VisiblePosition& c) { |
| 597 return StartOfDocumentAlgorithm<EditingStrategy>(c); | 597 return StartOfDocumentAlgorithm<EditingStrategy>(c); |
| 598 } | 598 } |
| 599 | 599 |
| 600 VisiblePositionInFlatTree StartOfDocument(const VisiblePositionInFlatTree& c) { | 600 VisiblePositionInFlatTree StartOfDocument(const VisiblePositionInFlatTree& c) { |
| 601 return StartOfDocumentAlgorithm<EditingInFlatTreeStrategy>(c); | 601 return StartOfDocumentAlgorithm<EditingInFlatTreeStrategy>(c); |
| 602 } | 602 } |
| 603 | 603 |
| (...skipping 1471 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 |