Elements contains first-letter style doesn't have selected background color |
|||
Issue description1. Visit https://jsfiddle.net/9n6dg2ah/ 2. See result Expected result: All texts have selection background color. Actual result: Only "top" and "bottom" have selection background color.
,
Aug 17 2017
,
Aug 24 2017
The root cause is LayoutTextFragment::CanBeSelectionLeaf() returns false for
non-editable. We should make it to return true always.
bool CanBeSelectionLeaf() const override {
return GetNode() && HasEditableStyle(*GetNode());
}
,
Aug 24 2017
,
Aug 28 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/e23563c533e0242fd20177971f7893d1c1d4b6e8 commit e23563c533e0242fd20177971f7893d1c1d4b6e8 Author: Yoshifumi Inoue <yosin@chromium.org> Date: Mon Aug 28 09:28:38 2017 Make LayoutSelection to handle "::first-letter" correctly This patch changes |LayoutSelection::CalcSelectionRangeAndSetSelectionState()| to mark both first-letter part layout object and remaining part layout object as selected. This patch also changes |LayoutTextFragment::CanBeSelectionLeaf()| to return |true| if it is associated to |Node| regardless editability because selection can be start/end in first-letter part and remaining part. # The representation of ::first-letter in layout tree When |Text| node has "::first-letter" style, it is represented by two |LayoutTextFragment| objects instead of one |LayoutText| for |Text| node without "::first-letter" style. The primary layout object, |Node::GetLayoutObject()| of |Text| node is remaining part of |LayoutTextFragment|. First letter part of|LayoutTextFragment| can be retrieved by |AssociatedLayoutObjectOf(Node&, dom_offset)|. Note: |LayoutTextFragment::Start()| returns DOM offset of part, e.g. for first-letter part |Start() == 0| and for remaining part |Start() > 0|. # Selection painting Selection painting is done by marking one of |SelectionState| to |LayoutObject| and holding layout objects and offsets of start and end boundaries of selection. Note: Offsets in |InlineTextBox| are offset in text in |LayoutTextFragment| instead of DOM offset. |SelectionState| are one of - |kNone| not part of selection - |kStart| the layout object contains start boundary of selection - |kEnd| the layout object contains end boundary(exclusive) of selection - |kStartAndEnd| the layout object contains both start and end boundaries. - |kInside| the layout object completely part of selection To paint ::first-letter correctly, we should mark |SelectionState| to both first-letter part and remaining part. Before this patch, we set remaining part only. From this patch, we set |SelectionState| to both first-letter part and remaining part with following cases. Case |kStartAndEnd|: assumes selection in |Text| node "(1) abc", "^" is selection base , and "|" is selection extent. 1. Start in first-letter part and end in first-letter part: "^(1|) abc" 2. Start in first-letter part and end in remaining part: "^(1) ab|c" 3. Start in remaining part end end in remaining part "(1) a^b|c" Case |kStart|, |kEnd|: assumes selection starts in "(1) abc" and ends in "(2) def". 1. Start in first-letter part and end in first-letter "(^1) abc" "(2|) def" 2. Start in first-letter part and end in remaining part "(1) a^bc" "(2) d|ef" 3. Start in remaining part and end in first-letter part "(1) a^bc" "(2|) def" 4. Start in remaining part and end in remaining part "(1) a^bc" "(2) d|ef" There are cases start or end don't have "::first-letter" style. In attached test, filename suffix - "f" means start/end in first-letter part - "n" means start/end in node without "::first-letter" style - "r" means start/end in remaining part Bug: 406218 , 756353 Change-Id: I70d2bafe3b03ca8c24b4b5ddac0afd3a0a6c680e Reviewed-on: https://chromium-review.googlesource.com/630341 Commit-Queue: Yoshifumi Inoue <yosin@chromium.org> Reviewed-by: Koji Ishii <kojii@chromium.org> Cr-Commit-Position: refs/heads/master@{#497725} [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_1ff-expected.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_1ff.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_1fr-expected.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_1fr.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_1rr-expected.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_1rr.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2ff-expected.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2ff.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2fn-expected.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2fn.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2fr-expected.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2fr.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2nf-expected.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2nf.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2nr-expected.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2nr.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2rf-expected.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2rf.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2rn-expected.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2rn.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2rr-expected.html [add] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/LayoutTests/paint/selection/first_letter/first_letter_2rr.html [modify] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/Source/core/editing/LayoutSelection.cpp [modify] https://crrev.com/e23563c533e0242fd20177971f7893d1c1d4b6e8/third_party/WebKit/Source/core/layout/LayoutTextFragment.h
,
Aug 29 2017
|
|||
►
Sign in to add a comment |
|||
Comment 1 by yosin@chromium.org
, Aug 17 20173.2 KB
3.2 KB View Download
17.0 KB
17.0 KB View Download