| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/editing/RenderedPosition.h" | 31 #include "core/editing/RenderedPosition.h" |
| 32 | 32 |
| 33 #include "core/editing/InlineBoxTraversal.h" |
| 33 #include "core/editing/TextAffinity.h" | 34 #include "core/editing/TextAffinity.h" |
| 34 #include "core/editing/VisiblePosition.h" | 35 #include "core/editing/VisiblePosition.h" |
| 35 #include "core/editing/VisibleUnits.h" | 36 #include "core/editing/VisibleUnits.h" |
| 36 #include "core/layout/api/LineLayoutAPIShim.h" | 37 #include "core/layout/api/LineLayoutAPIShim.h" |
| 37 #include "core/layout/compositing/CompositedSelectionBound.h" | 38 #include "core/layout/compositing/CompositedSelectionBound.h" |
| 38 #include "core/paint/PaintLayer.h" | 39 #include "core/paint/PaintLayer.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 template <typename Strategy> | 43 template <typename Strategy> |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 unsigned char RenderedPosition::BidiLevelOnRight() const { | 141 unsigned char RenderedPosition::BidiLevelOnRight() const { |
| 141 InlineBox* box = AtRightmostOffsetInBox() ? NextLeafChild() : inline_box_; | 142 InlineBox* box = AtRightmostOffsetInBox() ? NextLeafChild() : inline_box_; |
| 142 return box ? box->BidiLevel() : 0; | 143 return box ? box->BidiLevel() : 0; |
| 143 } | 144 } |
| 144 | 145 |
| 145 RenderedPosition RenderedPosition::LeftBoundaryOfBidiRun( | 146 RenderedPosition RenderedPosition::LeftBoundaryOfBidiRun( |
| 146 unsigned char bidi_level_of_run) { | 147 unsigned char bidi_level_of_run) { |
| 147 if (!inline_box_ || bidi_level_of_run > inline_box_->BidiLevel()) | 148 if (!inline_box_ || bidi_level_of_run > inline_box_->BidiLevel()) |
| 148 return RenderedPosition(); | 149 return RenderedPosition(); |
| 149 | 150 |
| 150 InlineBox* box = inline_box_; | 151 InlineBox* const box = |
| 151 do { | 152 InlineBoxTraversal::FindLeftBoundaryOfEntireBidiRunIgnoringLineBreak( |
| 152 InlineBox* prev = box->PrevLeafChildIgnoringLineBreak(); | 153 *inline_box_, bidi_level_of_run); |
| 153 if (!prev || prev->BidiLevel() < bidi_level_of_run) | 154 return RenderedPosition( |
| 154 return RenderedPosition( | 155 LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box, |
| 155 LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box, | 156 box->CaretLeftmostOffset()); |
| 156 box->CaretLeftmostOffset()); | |
| 157 box = prev; | |
| 158 } while (box); | |
| 159 | |
| 160 NOTREACHED(); | |
| 161 return RenderedPosition(); | |
| 162 } | 157 } |
| 163 | 158 |
| 164 RenderedPosition RenderedPosition::RightBoundaryOfBidiRun( | 159 RenderedPosition RenderedPosition::RightBoundaryOfBidiRun( |
| 165 unsigned char bidi_level_of_run) { | 160 unsigned char bidi_level_of_run) { |
| 166 if (!inline_box_ || bidi_level_of_run > inline_box_->BidiLevel()) | 161 if (!inline_box_ || bidi_level_of_run > inline_box_->BidiLevel()) |
| 167 return RenderedPosition(); | 162 return RenderedPosition(); |
| 168 | 163 |
| 169 InlineBox* box = inline_box_; | 164 InlineBox* const box = |
| 170 do { | 165 InlineBoxTraversal::FindRightBoundaryOfEntireBidiRunIgnoringLineBreak( |
| 171 InlineBox* next = box->NextLeafChildIgnoringLineBreak(); | 166 *inline_box_, bidi_level_of_run); |
| 172 if (!next || next->BidiLevel() < bidi_level_of_run) | 167 return RenderedPosition( |
| 173 return RenderedPosition( | 168 LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box, |
| 174 LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box, | 169 box->CaretRightmostOffset()); |
| 175 box->CaretRightmostOffset()); | |
| 176 box = next; | |
| 177 } while (box); | |
| 178 | |
| 179 NOTREACHED(); | |
| 180 return RenderedPosition(); | |
| 181 } | 170 } |
| 182 | 171 |
| 183 bool RenderedPosition::AtLeftBoundaryOfBidiRun( | 172 bool RenderedPosition::AtLeftBoundaryOfBidiRun( |
| 184 ShouldMatchBidiLevel should_match_bidi_level, | 173 ShouldMatchBidiLevel should_match_bidi_level, |
| 185 unsigned char bidi_level_of_run) const { | 174 unsigned char bidi_level_of_run) const { |
| 186 if (!inline_box_) | 175 if (!inline_box_) |
| 187 return false; | 176 return false; |
| 188 | 177 |
| 189 if (AtLeftmostOffsetInBox()) { | 178 if (AtLeftmostOffsetInBox()) { |
| 190 if (should_match_bidi_level == kIgnoreBidiLevel) | 179 if (should_match_bidi_level == kIgnoreBidiLevel) |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 for (LayoutObject* layout_object = LayoutObjectFromPosition(position); | 332 for (LayoutObject* layout_object = LayoutObjectFromPosition(position); |
| 344 layout_object && layout_object->GetNode(); | 333 layout_object && layout_object->GetNode(); |
| 345 layout_object = layout_object->Parent()) { | 334 layout_object = layout_object->Parent()) { |
| 346 if (layout_object == target) | 335 if (layout_object == target) |
| 347 return true; | 336 return true; |
| 348 } | 337 } |
| 349 return false; | 338 return false; |
| 350 } | 339 } |
| 351 | 340 |
| 352 } // namespace blink | 341 } // namespace blink |
| OLD | NEW |