summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Page
diff options
context:
space:
mode:
authorRewi Haar <rewi-github@whanau.org>2020-08-26 11:31:11 +1200
committerAndreas Kling <kling@serenityos.org>2020-08-26 08:44:31 +0200
commit521e730df107db3565880b79c6d6a7e66132787e (patch)
tree4d868ef012afd892bed95e0aa9980bd5b4b85066 /Libraries/LibWeb/Page
parentdd83f6a2666444cf5330e507ef2420181e0ea5ad (diff)
downloadserenity-521e730df107db3565880b79c6d6a7e66132787e.zip
LibWeb: Calculate selection based on glyph centers
Previously you had to drag all the way to the end of a glyph to select it; now you just need to drag past the center. Also fixes #2959.
Diffstat (limited to 'Libraries/LibWeb/Page')
-rw-r--r--Libraries/LibWeb/Page/Frame.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Libraries/LibWeb/Page/Frame.cpp b/Libraries/LibWeb/Page/Frame.cpp
index 826b5c510f..784702e7e0 100644
--- a/Libraries/LibWeb/Page/Frame.cpp
+++ b/Libraries/LibWeb/Page/Frame.cpp
@@ -26,12 +26,12 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
+#include <LibWeb/InProcessWebView.h>
#include <LibWeb/Layout/LayoutBreak.h>
#include <LibWeb/Layout/LayoutDocument.h>
#include <LibWeb/Layout/LayoutText.h>
#include <LibWeb/Layout/LayoutWidget.h>
#include <LibWeb/Page/Frame.h>
-#include <LibWeb/InProcessWebView.h>
namespace Web {
@@ -221,7 +221,7 @@ String Frame::selected_text() const
if (selection.start().layout_node == selection.end().layout_node) {
if (!is<LayoutText>(*selection.start().layout_node))
return "";
- return downcast<LayoutText>(*selection.start().layout_node).text_for_rendering().substring(selection.start().index_in_node, selection.end().index_in_node - selection.start().index_in_node + 1);
+ return downcast<LayoutText>(*selection.start().layout_node).text_for_rendering().substring(selection.start().index_in_node, selection.end().index_in_node - selection.start().index_in_node);
}
// Start node
@@ -246,7 +246,7 @@ String Frame::selected_text() const
ASSERT(layout_node == selection.end().layout_node);
if (is<LayoutText>(*layout_node)) {
auto& text = downcast<LayoutText>(*layout_node).text_for_rendering();
- builder.append(text.substring(0, selection.end().index_in_node + 1));
+ builder.append(text.substring(0, selection.end().index_in_node));
}
return builder.to_string();