Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp b/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp |
| index ebd781d489b5f128375c412680ba9a373ec7b232..c1e1ba7a5e5a134611b86c7b5915386c5f4e935e 100644 |
| --- a/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp |
| +++ b/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp |
| @@ -24,6 +24,7 @@ |
| #include "core/layout/line/InlineTextBox.h" |
| #include "core/layout/HitTestResult.h" |
| +#include "core/layout/api/LineLayoutAPIShim.h" |
| #include "core/layout/api/LineLayoutBR.h" |
| #include "core/layout/api/LineLayoutBox.h" |
| #include "core/layout/api/LineLayoutRubyRun.h" |
| @@ -188,16 +189,44 @@ SelectionState InlineTextBox::getSelectionState() const { |
| bool InlineTextBox::hasWrappedSelectionNewline() const { |
| DCHECK(!getLineLayoutItem().needsLayout()); |
| + |
| SelectionState state = getSelectionState(); |
| - return (state == SelectionStart || state == SelectionInside) |
| - // Checking last leaf child can be slow, so we make sure to do this |
| - // only after the other simple conditionals. |
| - && (root().lastLeafChild() == this) |
| - // It's possible to have mixed LTR/RTL on a single line, and we only |
| - // want to paint a newline when we're the last leaf child and we make |
| - // sure there isn't a differently-directioned box following us. |
| - && ((!isLeftToRightDirection() && root().firstSelectedBox() == this) || |
| - (isLeftToRightDirection() && root().lastSelectedBox() == this)); |
| + if (state != SelectionStart && state != SelectionInside) |
| + return false; |
| + |
| + // Checking last leaf child can be slow, so we make sure to do this |
| + // only after the other simple conditionals. |
| + if (root().lastLeafChild() != this) |
| + return false; |
| + |
| + // It's possible to have mixed LTR/RTL on a single line, and we only |
| + // want to paint a newline when we're the last leaf child and we make |
| + // sure there isn't a differently-directioned box following us. |
| + bool isLTR = isLeftToRightDirection(); |
| + if ((!isLTR && root().firstSelectedBox() != this) || |
| + (isLTR && root().lastSelectedBox() != this)) |
| + return false; |
| + |
| + // If we're the last inline text box in containing block, our containing block |
|
wkorman
2017/03/06 21:46:50
Below is new logic/comments, above is just an expl
|
| + // is inline, and the selection continues into that block, then rely on the |
| + // next inline text box (if any) to paint a wrapped new line as needed. |
| + // |
| + // TODO(wkorman): Note this is imperfect as it's possible the next inline text |
|
wkorman
2017/03/06 21:46:50
I'd like to fix this but it requires more line lay
|
| + // box (in a different containing block) is not on the same line as our inline |
| + // box. Look into how to test whether the next inline text box is logically on |
| + // same line as this one. |
| + |
| + if (nextTextBox()) |
|
wkorman
2017/03/06 21:46:50
This method appears a reasonable signal for the en
|
| + return true; |
| + |
| + LayoutBox* containingBox = |
| + toLayoutBox(LineLayoutAPIShim::layoutObjectFrom(root().block())); |
|
Xianzhu
2017/03/06 22:29:23
I think we don't need shim and cast.
auto block =
|
| + if (containingBox->isInline() && |
| + containingBox->getSelectionState() != SelectionEnd && |
| + containingBox->getSelectionState() != SelectionBoth) |
|
Xianzhu
2017/03/06 22:29:23
Will this work:
... &&
containingBox->inli
wkorman
2017/03/07 03:12:30
An exciting proposal, on initial investigation how
Xianzhu
2017/03/07 03:55:42
I think you can use InlineBox::nextOnLine().
wkorman
2017/03/07 17:41:31
This works, thanks. A question: fast/text/flexbox-
|
| + return false; |
| + |
| + return true; |
| } |
| float InlineTextBox::newlineSpaceWidth() const { |