Skip to content

Commit

Permalink
Get rid of redundant function ComputeLocalRect() in "ng_paint_fragmen…
Browse files Browse the repository at this point in the history
…t.cc"


This patch gets rid of redundant function ComputeLocalRect() in
"ng_paint_fragment.cc" introduced by CL[1] by replacing to |NGInlineCursor|
version[2] for improving code health.

[1] http://crrev.com/c/1832843 Paint selection with NGFragmentItem, Oct 11
[2] http://crrev.com/c/1880890 Make LayoutText::GetTextBoxInfo() to use
NGInlineCursor, Oct 25


Bug: 982194
Change-Id: I9fdaadb0818d61b3aa2f4ac60482feec45886efd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1896476
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711994}
  • Loading branch information
yosinch authored and Commit Bot committed Nov 2, 2019
1 parent 03c534c commit 376d48c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 49 deletions.
19 changes: 1 addition & 18 deletions third_party/blink/renderer/core/paint/ng/ng_paint_fragment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,6 @@ const LayoutObject* ListMarkerFromMarkerOrMarkerContent(
return nullptr;
}

// TODO(yosin): Move to "ng_selection_painter.cc"
PhysicalRect ComputeLocalRect(const NGInlineCursor& cursor,
unsigned start_offset,
unsigned end_offset) {
DCHECK_LE(start_offset, end_offset);
if (const NGPaintFragment* paint_fragment = cursor.CurrentPaintFragment()) {
return To<NGPhysicalTextFragment>(paint_fragment->PhysicalFragment())
.LocalRect(start_offset, end_offset);
}
if (const NGFragmentItem* item = cursor.CurrentItem()) {
return item->LocalRect(cursor.Items().Text(item->UsesFirstLineStyle()),
start_offset, end_offset);
}
NOTREACHED();
return PhysicalRect();
}

} // namespace

NGPaintFragment::NGPaintFragment(
Expand Down Expand Up @@ -977,7 +960,7 @@ PhysicalRect ComputeLocalSelectionRectForText(
const NGInlineCursor& cursor,
const LayoutSelectionStatus& selection_status) {
const PhysicalRect selection_rect =
ComputeLocalRect(cursor, selection_status.start, selection_status.end);
cursor.CurrentLocalRect(selection_status.start, selection_status.end);
LogicalRect logical_rect = ComputeLogicalRectFor(selection_rect, cursor);
// Let LocalRect for line break have a space width to paint line break
// when it is only character in a line or only selected in a line.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ crbug.com/982194 editing/execCommand/dispatch-text-event-crash.html [ Crash ]
crbug.com/982194 editing/execCommand/findString-2.html [ Crash ]
crbug.com/982194 editing/execCommand/findString-3.html [ Crash Pass ]
crbug.com/982194 editing/execCommand/findString-diacriticals.html [ Crash Pass ]
crbug.com/982194 editing/execCommand/findString.html [ Crash ]
crbug.com/982194 editing/execCommand/findString.html [ Crash Pass ]
crbug.com/982194 editing/execCommand/insert-ordered-list-crash.html [ Crash ]
crbug.com/982194 editing/execCommand/insertNewLineInQuotedContent-outside-quote.html [ Crash ]
crbug.com/982194 editing/execCommand/queryCommandState-list.html [ Crash ]
Expand All @@ -223,7 +223,7 @@ crbug.com/982194 editing/input/keyboard-ctrl-enter-no-newline.html [ Crash ]
crbug.com/982194 editing/input/paste-text-ending-with-interchange-newline.html [ Crash ]
crbug.com/982194 editing/input/reveal-caret-of-transformed-input-scrollable-parent.html [ Crash ]
crbug.com/982194 editing/input/reveal-caret-of-transformed-multiline-input.html [ Crash ]
crbug.com/982194 editing/input/reveal-password.html [ Crash ]
crbug.com/982194 editing/input/reveal-password.html [ Crash Pass ]
crbug.com/982194 editing/input/scroll-with-tab-to-input-regression.html [ Crash ]
crbug.com/982194 editing/input/setting-input-value-cancel-ime-composition.html [ Crash ]
crbug.com/982194 editing/input/textcontrol-doubleclick-at-end.html [ Crash ]
Expand Down Expand Up @@ -289,7 +289,7 @@ crbug.com/982194 editing/selection/click-in-padding-with-multiple-line-boxes.htm
crbug.com/982194 editing/selection/click-on-anonymous-content-crash.html [ Crash ]
crbug.com/982194 editing/selection/collapseto_in_text_fields.html [ Crash ]
crbug.com/982194 editing/selection/commit-pending-selection-crash.html [ Crash ]
crbug.com/982194 editing/selection/containsNode.html [ Crash ]
crbug.com/982194 editing/selection/containsNode.html [ Crash Pass ]
crbug.com/982194 editing/selection/context-menu-on-text.html [ Crash ]
crbug.com/982194 editing/selection/context-menu-text-selection.html [ Crash ]
crbug.com/982194 editing/selection/continuations-with-move-caret-to-boundary.html [ Crash ]
Expand Down Expand Up @@ -322,7 +322,7 @@ crbug.com/982194 editing/selection/extend-selection-after-double-click.html [ Cr
crbug.com/982194 editing/selection/extend-to-line-boundary.html [ Failure Pass ]
crbug.com/982194 editing/selection/extend-to-trailing-spaces.html [ Crash ]
crbug.com/982194 editing/selection/extend.html [ Crash ]
crbug.com/982194 editing/selection/find-in-text-control.html [ Crash ]
crbug.com/982194 editing/selection/find-in-text-control.html [ Crash Pass ]
crbug.com/982194 editing/selection/first-letter-mouse-select-full-text.html [ Crash ]
crbug.com/982194 editing/selection/first-letter-selection-crash.html [ Crash ]
crbug.com/982194 editing/selection/firstRect-crash.html [ Crash ]
Expand Down Expand Up @@ -452,7 +452,7 @@ crbug.com/982194 editing/style/text-indent.html [ Crash ]
crbug.com/982194 editing/text-iterator/backward-textiterator-first-letter-crash.html [ Crash ]
crbug.com/982194 editing/text-iterator/findString-restarts-at-last-position.html [ Crash ]
crbug.com/982194 editing/text-iterator/findString-selection-disabled.html [ Crash ]
crbug.com/982194 editing/text-iterator/findString-start-search-after-selection.html [ Crash ]
crbug.com/982194 editing/text-iterator/findString-start-search-after-selection.html [ Crash Pass ]
crbug.com/982194 editing/text-iterator/first-letter-rtl-crash.html [ Crash ]
crbug.com/982194 editing/text-iterator/first_letter_find_string_crash.html [ Crash ]
crbug.com/982194 editing/text-iterator/selection-to-string-with-auto-fill.html [ Crash ]
Expand Down Expand Up @@ -2148,7 +2148,7 @@ crbug.com/982194 fast/events/inputevents/inputevent-ime.html [ Crash ]
crbug.com/982194 fast/events/keyboard-scroll-use-count.html [ Crash ]
crbug.com/982194 fast/events/keydown-1.html [ Crash ]
crbug.com/982194 fast/events/keypress-removed-node.html [ Crash ]
crbug.com/982194 fast/events/max-tabindex-focus.html [ Crash ]
crbug.com/982194 fast/events/max-tabindex-focus.html [ Crash Timeout ]
crbug.com/982194 fast/events/menu-key-context-menu-document-pinch-zoom.html [ Crash ]
crbug.com/982194 fast/events/menu-key-context-menu-document.html [ Crash ]
crbug.com/982194 fast/events/menu-key-context-menu-position.html [ Failure ]
Expand Down Expand Up @@ -2899,7 +2899,7 @@ crbug.com/982194 fast/sub-pixel/width-of-inline-in-float.html [ Failure Pass ]
crbug.com/982194 fast/table/026.html [ Failure ]
crbug.com/982194 fast/table/032.html [ Failure ]
crbug.com/982194 fast/table/align-right-within-left-aligned-div.html [ Failure ]
crbug.com/982194 fast/table/backgr_layers-hide.html [ Failure ]
crbug.com/982194 fast/table/backgr_layers-hide.html [ Failure Pass ]
crbug.com/982194 fast/table/border-collapsing/002-vertical.html [ Failure ]
crbug.com/982194 fast/table/change-tbody-border-width-crash.html [ Crash ]
crbug.com/982194 fast/table/click-near-anonymous-table.html [ Crash ]
Expand Down Expand Up @@ -3053,8 +3053,8 @@ crbug.com/982194 virtual/text-antialias/editing-text-crash.html [ Crash ]
crbug.com/982194 virtual/text-antialias/ellipsis-stroked.html [ Failure ]
crbug.com/982194 virtual/text-antialias/emoji-vertical-origin-visual.html [ Failure ]
crbug.com/982194 virtual/text-antialias/emphasis-height-crash.html [ Crash ]
crbug.com/982194 virtual/text-antialias/find-layout-crash.html [ Crash ]
crbug.com/982194 virtual/text-antialias/find-russian.html [ Crash ]
crbug.com/982194 virtual/text-antialias/find-layout-crash.html [ Crash Pass ]
crbug.com/982194 virtual/text-antialias/find-russian.html [ Crash Pass ]
crbug.com/982194 virtual/text-antialias/font-fallback-synthetic-italics.html [ Failure Pass ]
crbug.com/982194 virtual/text-antialias/font-format-support-color-cff2.html [ Crash ]
crbug.com/982194 virtual/text-antialias/font-ligature-letter-spacing.html [ Failure Pass ]
Expand Down Expand Up @@ -3083,25 +3083,25 @@ crbug.com/982194 virtual/text-antialias/remove-zero-length-run.html [ Failure ]
crbug.com/982194 virtual/text-antialias/selection/atsui-kerning-and-ligatures.html [ Crash Pass ]
crbug.com/982194 virtual/text-antialias/selection/atsui-partial-selection.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/atsui-rtl-override-selection.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/complex-text-rtl-selection-repaint.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/complex-text-rtl-selection-repaint.html [ Crash Pass ]
crbug.com/982194 virtual/text-antialias/selection/complex-text-spaces-selection.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/emphasis.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/emphasis.html [ Crash Failure ]
crbug.com/982194 virtual/text-antialias/selection/find-backwards.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/flexbox-selection-nested.html [ Crash Pass ]
crbug.com/982194 virtual/text-antialias/selection/flexbox-selection.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/hebrew-selection.html [ Crash ]
crbug.com/591099 virtual/text-antialias/selection/inline-block-in-selection-root.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/justified-selection-at-edge.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/justified-selection.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/justified-selection.html [ Crash Pass ]
crbug.com/982194 virtual/text-antialias/selection/khmer-crash.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/khmer-selection.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/offsetForPosition-complex-fallback.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/pre-wrap-overflow-selection.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/pre-wrap-overflow-selection.html [ Crash Pass ]
crbug.com/982194 virtual/text-antialias/selection/repaint-glyph-bounds.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/reset-drag-on-mouse-down.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/selection-hard-linebreak.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/selection-multiple-runs.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/selection-padding-quirks-mode.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/selection-hard-linebreak.html [ Crash Pass ]
crbug.com/982194 virtual/text-antialias/selection/selection-multiple-runs.html [ Crash Pass ]
crbug.com/982194 virtual/text-antialias/selection/selection-padding-quirks-mode.html [ Crash Pass ]
crbug.com/982194 virtual/text-antialias/selection/selection-painted-separately.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/selection-painting-hidpi.html [ Crash ]
crbug.com/982194 virtual/text-antialias/selection/selection-rect-line-height-too-big.html [ Crash ]
Expand Down Expand Up @@ -3204,7 +3204,7 @@ crbug.com/982194 http/tests/devtools/coverage/gutter-css.js [ Crash Timeout ]
crbug.com/982194 http/tests/devtools/coverage/gutter-html.js [ Crash Timeout ]
crbug.com/982194 http/tests/devtools/coverage/gutter-js.js [ Crash ]
crbug.com/982194 http/tests/devtools/coverage/multiple-instances-merge.js [ Crash Timeout ]
crbug.com/846471 http/tests/devtools/coverage/reveal-autoformat.js [ Timeout ]
crbug.com/846471 http/tests/devtools/coverage/reveal-autoformat.js [ Crash Timeout ]
crbug.com/678482 http/tests/devtools/debugger/fetch-breakpoints.js [ Crash Timeout ]
crbug.com/982194 http/tests/devtools/editor/text-editor-accessibility.js [ Crash ]
crbug.com/982194 http/tests/devtools/editor/text-editor-auto-whitespace-removing.js [ Crash Timeout ]
Expand Down Expand Up @@ -3518,7 +3518,7 @@ crbug.com/982194 http/tests/devtools/network/network-cyrillic-xhr.js [ Crash ]
crbug.com/679833 crbug.com/762529 http/tests/devtools/network/network-datareceived.js [ Crash Failure Timeout ]
crbug.com/759632 http/tests/devtools/network/network-datasaver-warning.js [ Crash Timeout ]
crbug.com/982194 http/tests/devtools/network/network-disable-cache-memory.js [ Crash ]
crbug.com/982194 http/tests/devtools/network/network-disable-cache-preloads-twice.js [ Crash ]
crbug.com/982194 http/tests/devtools/network/network-disable-cache-preloads-twice.js [ Crash Timeout ]
crbug.com/982194 http/tests/devtools/network/network-disable-cache-preloads.js [ Crash ]
crbug.com/982194 http/tests/devtools/network/network-disable-cache-xhrs.js [ Crash Timeout ]
crbug.com/982194 http/tests/devtools/network/network-disabling-check-no-memory-leak.js [ Crash ]
Expand Down Expand Up @@ -4121,7 +4121,7 @@ crbug.com/982194 paint/invalidation/selection/invalidation-rect-includes-newline
crbug.com/982194 paint/invalidation/selection/invalidation-rect-includes-newline.html [ Crash ]
crbug.com/982194 paint/invalidation/selection/invalidation-rect-with-br-includes-newline.html [ Crash ]
crbug.com/982194 paint/invalidation/selection/japanese-rl-selection-clear.html [ Crash ]
crbug.com/982194 paint/invalidation/selection/japanese-rl-selection-repaint.html [ Crash ]
crbug.com/982194 paint/invalidation/selection/japanese-rl-selection-repaint.html [ Crash Failure ]
crbug.com/982194 paint/invalidation/selection/selected-replaced.html [ Crash ]
crbug.com/982194 paint/invalidation/selection/selection-change-in-iframe-with-relative-parent.html [ Crash ]
crbug.com/982194 paint/invalidation/selection/selection-clear-after-move.html [ Crash ]
Expand Down Expand Up @@ -4203,17 +4203,17 @@ crbug.com/982194 paint/markers/vertical-lr.html [ Crash ]
crbug.com/982194 paint/markers/vertical-rl.html [ Crash ]
crbug.com/982194 paint/overflow/composited-rounded-clip-floating-element.html [ Failure ]
crbug.com/982194 paint/overflow/composited-scroll-vertical-rl.html [ Failure ]
crbug.com/982194 paint/selection/first_letter/first_letter_1ff.html [ Crash ]
crbug.com/982194 paint/selection/first_letter/first_letter_1fr.html [ Crash ]
crbug.com/982194 paint/selection/first_letter/first_letter_1rr.html [ Crash ]
crbug.com/982194 paint/selection/first_letter/first_letter_2ff.html [ Crash ]
crbug.com/982194 paint/selection/first_letter/first_letter_2fn.html [ Crash ]
crbug.com/982194 paint/selection/first_letter/first_letter_2fr.html [ Crash ]
crbug.com/982194 paint/selection/first_letter/first_letter_2nf.html [ Crash ]
crbug.com/982194 paint/selection/first_letter/first_letter_2nr.html [ Crash ]
crbug.com/982194 paint/selection/first_letter/first_letter_2rf.html [ Crash ]
crbug.com/982194 paint/selection/first_letter/first_letter_2rn.html [ Crash ]
crbug.com/982194 paint/selection/first_letter/first_letter_2rr.html [ Crash ]
crbug.com/982194 paint/selection/first_letter/first_letter_1ff.html [ Crash Pass ]
crbug.com/982194 paint/selection/first_letter/first_letter_1fr.html [ Crash Failure ]
crbug.com/982194 paint/selection/first_letter/first_letter_1rr.html [ Crash Pass ]
crbug.com/982194 paint/selection/first_letter/first_letter_2ff.html [ Crash Failure ]
crbug.com/982194 paint/selection/first_letter/first_letter_2fn.html [ Crash Failure ]
crbug.com/982194 paint/selection/first_letter/first_letter_2fr.html [ Crash Failure ]
crbug.com/982194 paint/selection/first_letter/first_letter_2nf.html [ Crash Failure ]
crbug.com/982194 paint/selection/first_letter/first_letter_2nr.html [ Crash Failure ]
crbug.com/982194 paint/selection/first_letter/first_letter_2rf.html [ Crash Failure ]
crbug.com/982194 paint/selection/first_letter/first_letter_2rn.html [ Crash Failure ]
crbug.com/982194 paint/selection/first_letter/first_letter_2rr.html [ Crash Failure ]
crbug.com/982194 paint/selection/image-writing-modes.html [ Crash ]
crbug.com/982194 paint/selection/selection-drag-image-in-iframe.html [ Crash ]
crbug.com/982194 paint/selection/text-selection-counter.html [ Crash ]
Expand Down Expand Up @@ -4581,6 +4581,7 @@ crbug.com/982194 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftest
crbug.com/982194 external/wpt/dom/nodes/Element-insertAdjacentText.html [ Crash ]
crbug.com/982194 external/wpt/fetch/corb/script-resource-with-nonsniffable-types.tentative.sub.html [ Pass Timeout ]
crbug.com/982194 external/wpt/forced-colors-mode/forced-colors-mode-19.html [ Pass ]
crbug.com/982194 external/wpt/html/semantics/forms/form-submission-0/implicit-submission.optional.html [ Crash ]
crbug.com/982194 external/wpt/html/semantics/forms/historical-search-event.html [ Failure ]
crbug.com/982194 external/wpt/html/semantics/interactive-elements/the-details-element/details.html [ Crash ]
crbug.com/982194 external/wpt/html/semantics/text-level-semantics/the-time-element/001.html [ Crash ]
Expand Down Expand Up @@ -4641,7 +4642,7 @@ crbug.com/982194 virtual/android/fullscreen/model/fully-exit-fullscreen-single.h
crbug.com/982194 virtual/audio-service/media/video-canvas-draw.html [ Failure Pass ]
crbug.com/982194 virtual/composite-after-paint/compositing/gestures/gesture-tapHighlight-simple-scaledY.html [ Failure ]
crbug.com/982194 virtual/composite-after-paint/paint/background/scrolling-background-with-negative-z-child.html [ Pass ]
crbug.com/982194 virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/button/button-appearance-basic.html [ Failure ]
crbug.com/982194 virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/button/button-appearance-basic.html [ Failure Pass ]
crbug.com/982194 virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/color/color-suggestion-picker-appearance-with-scrollbar.html [ Failure ]
crbug.com/982194 virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/color/color-suggestion-picker-appearance.html [ Failure ]
crbug.com/982194 virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance.html [ Crash ]
Expand Down

0 comments on commit 376d48c

Please sign in to comment.