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

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleUnits.cpp

Issue 2943623002: Reduce indentation in ComputeInlineBoxPositionTemplate() (Closed)
Patch Set: 2017-06-16T14:52:49 Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 TextDirection primary_direction) { 784 TextDirection primary_direction) {
785 int caret_offset = position.ComputeEditingOffset(); 785 int caret_offset = position.ComputeEditingOffset();
786 Node* const anchor_node = position.AnchorNode(); 786 Node* const anchor_node = position.AnchorNode();
787 LayoutObject* layout_object = 787 LayoutObject* layout_object =
788 anchor_node->IsShadowRoot() 788 anchor_node->IsShadowRoot()
789 ? ToShadowRoot(anchor_node)->host().GetLayoutObject() 789 ? ToShadowRoot(anchor_node)->host().GetLayoutObject()
790 : anchor_node->GetLayoutObject(); 790 : anchor_node->GetLayoutObject();
791 791
792 DCHECK(layout_object) << position; 792 DCHECK(layout_object) << position;
793 793
794 if (!layout_object->IsText()) { 794 if (layout_object->IsText()) {
795 if (CanHaveChildrenForEditing(anchor_node) && 795 return ComputeInlineBoxPositionForTextNode(layout_object, caret_offset,
796 layout_object->IsLayoutBlockFlow() && 796 affinity, primary_direction);
797 HasRenderedNonAnonymousDescendantsWithHeight(layout_object)) { 797 }
798 // Try a visually equivalent position with possibly opposite 798 if (CanHaveChildrenForEditing(anchor_node) &&
799 // editability. This helps in case |this| is in an editable block 799 layout_object->IsLayoutBlockFlow() &&
800 // but surrounded by non-editable positions. It acts to negate the 800 HasRenderedNonAnonymousDescendantsWithHeight(layout_object)) {
801 // logic at the beginning of 801 // Try a visually equivalent position with possibly opposite
802 // |LayoutObject::createPositionWithAffinity()|. 802 // editability. This helps in case |this| is in an editable block
803 const PositionTemplate<Strategy>& downstream_equivalent = 803 // but surrounded by non-editable positions. It acts to negate the
804 DownstreamIgnoringEditingBoundaries(position); 804 // logic at the beginning of
805 if (downstream_equivalent != position) { 805 // |LayoutObject::createPositionWithAffinity()|.
806 return ComputeInlineBoxPosition( 806 const PositionTemplate<Strategy>& downstream_equivalent =
807 downstream_equivalent, TextAffinity::kUpstream, primary_direction); 807 DownstreamIgnoringEditingBoundaries(position);
808 } 808 if (downstream_equivalent != position) {
809 const PositionTemplate<Strategy>& upstream_equivalent = 809 return ComputeInlineBoxPosition(
810 UpstreamIgnoringEditingBoundaries(position); 810 downstream_equivalent, TextAffinity::kUpstream, primary_direction);
811 if (upstream_equivalent == position || 811 }
812 DownstreamIgnoringEditingBoundaries(upstream_equivalent) == position) 812 const PositionTemplate<Strategy>& upstream_equivalent =
813 return InlineBoxPosition(); 813 UpstreamIgnoringEditingBoundaries(position);
814 if (upstream_equivalent == position ||
815 DownstreamIgnoringEditingBoundaries(upstream_equivalent) == position)
816 return InlineBoxPosition();
814 817
815 return ComputeInlineBoxPosition( 818 return ComputeInlineBoxPosition(upstream_equivalent,
816 upstream_equivalent, TextAffinity::kUpstream, primary_direction); 819 TextAffinity::kUpstream, primary_direction);
817 }
818 if (!layout_object->IsBox())
819 return InlineBoxPosition();
820 InlineBox* const inline_box =
821 ToLayoutBox(layout_object)->InlineBoxWrapper();
822 if (!inline_box)
823 return InlineBoxPosition();
824 if ((caret_offset > inline_box->CaretMinOffset() &&
825 caret_offset < inline_box->CaretMaxOffset()))
826 return InlineBoxPosition(inline_box, caret_offset);
827 return AdjustInlineBoxPositionForTextDirection(
828 inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
829 primary_direction);
830 } 820 }
831 821 if (!layout_object->IsBox())
832 return ComputeInlineBoxPositionForTextNode(layout_object, caret_offset, 822 return InlineBoxPosition();
833 affinity, primary_direction); 823 InlineBox* const inline_box = ToLayoutBox(layout_object)->InlineBoxWrapper();
824 if (!inline_box)
825 return InlineBoxPosition();
826 if ((caret_offset > inline_box->CaretMinOffset() &&
827 caret_offset < inline_box->CaretMaxOffset()))
828 return InlineBoxPosition(inline_box, caret_offset);
829 return AdjustInlineBoxPositionForTextDirection(
830 inline_box, caret_offset, layout_object->Style()->GetUnicodeBidi(),
831 primary_direction);
834 } 832 }
835 833
836 // TODO(yosin): We should make |ComputeInlineBoxPositionForTextNode()| to take 834 // TODO(yosin): We should make |ComputeInlineBoxPositionForTextNode()| to take
837 // |const LayoutText&|. 835 // |const LayoutText&|.
838 static InlineBoxPosition ComputeInlineBoxPositionForTextNode( 836 static InlineBoxPosition ComputeInlineBoxPositionForTextNode(
839 LayoutObject* layout_object, 837 LayoutObject* layout_object,
840 int caret_offset, 838 int caret_offset,
841 TextAffinity affinity, 839 TextAffinity affinity,
842 TextDirection primary_direction) { 840 TextDirection primary_direction) {
843 InlineBox* inline_box = nullptr; 841 InlineBox* inline_box = nullptr;
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 2079
2082 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) { 2080 IntRect ComputeTextRect(const EphemeralRangeInFlatTree& range) {
2083 return EnclosingIntRect(ComputeTextRectTemplate(range)); 2081 return EnclosingIntRect(ComputeTextRectTemplate(range));
2084 } 2082 }
2085 2083
2086 FloatRect ComputeTextFloatRect(const EphemeralRange& range) { 2084 FloatRect ComputeTextFloatRect(const EphemeralRange& range) {
2087 return ComputeTextRectTemplate(range); 2085 return ComputeTextRectTemplate(range);
2088 } 2086 }
2089 2087
2090 } // namespace blink 2088 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698