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

Unified Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp

Issue 2875933006: [LayoutNG] Misc fixes in ShapingLineBreaker (Closed)
Patch Set: eae review + RTL snapping fixes Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp b/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
index bd1254aea0376522dce5fbd9ccdcf9b8c047e93c..9e1d3f5a1436298880b19f5ee96f9472a8696c9d 100644
--- a/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
+++ b/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
@@ -183,12 +183,24 @@ size_t ShapeResult::ByteSize() const {
return self_byte_size;
}
+unsigned ShapeResult::StartIndexForResult() const {
+ return !Rtl() ? runs_.front()->start_index_ : runs_.back()->start_index_;
+}
+
+unsigned ShapeResult::EndIndexForResult() const {
+ return StartIndexForResult() + NumCharacters();
+}
+
+// If the position is outside of the result, returns the start or the end offset
+// depends on the position.
unsigned ShapeResult::OffsetForPosition(float target_x,
bool include_partial_glyphs) const {
unsigned characters_so_far = 0;
float current_x = 0;
if (Rtl()) {
+ if (target_x <= 0)
+ return num_characters_;
characters_so_far = num_characters_;
for (unsigned i = 0; i < runs_.size(); ++i) {
if (!runs_[i])
@@ -205,6 +217,8 @@ unsigned ShapeResult::OffsetForPosition(float target_x,
current_x = next_x;
}
} else {
+ if (target_x <= 0)
+ return 0;
for (unsigned i = 0; i < runs_.size(); ++i) {
if (!runs_[i])
continue;

Powered by Google App Engine
This is Rietveld 408576698