summaryrefslogtreecommitdiff
path: root/desktop/textarea.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-02-23 17:44:20 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2013-02-23 17:44:20 +0000
commitbba74b7a0b414809e29d8b19978db1996a8822ac (patch)
treec8f95919650359a6b720fe0336c31bdbff5ea7c9 /desktop/textarea.c
parent3cc90f2f3022dd4b416c704e53b69a629fa6ff18 (diff)
downloadnetsurf-bba74b7a0b414809e29d8b19978db1996a8822ac.tar.gz
netsurf-bba74b7a0b414809e29d8b19978db1996a8822ac.tar.bz2
Handle readonly attribute for text inputs and textareas.
Diffstat (limited to 'desktop/textarea.c')
-rw-r--r--desktop/textarea.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 7444c9f3f..73781f261 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -852,9 +852,6 @@ static bool textarea_set_caret_xy(struct textarea *ta, int x, int y)
{
unsigned int c_off;
- if (ta->flags & TEXTAREA_READONLY)
- return true;
-
textarea_get_xy_offset(ta, x, y, &c_off);
return textarea_set_caret(ta, c_off);
@@ -949,7 +946,9 @@ static bool textarea_replace_text(struct textarea *ta, unsigned int start,
{
size_t b_start, b_end;
- if (ta->flags & TEXTAREA_READONLY)
+ if ((ta->flags & TEXTAREA_READONLY) &&
+ !(rep == NULL && rep_len == 0 && add_to_clipboard))
+ /* Can't edit if readonly, and we're not just copying */
return true;
if (start > ta->text.utf8_len)
@@ -1333,9 +1332,6 @@ bool textarea_set_caret(struct textarea *ta, int caret)
struct textarea_msg msg;
bool scrolled;
- if (ta->flags & TEXTAREA_READONLY)
- return true;
-
c_len = ta->show->utf8_len;
if (caret != -1 && caret > (signed)c_len)
@@ -2273,13 +2269,11 @@ bool textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse,
return textarea_select_paragraph(ta);
} else if (mouse & BROWSER_MOUSE_PRESS_1) {
- if (!(ta->flags & TEXTAREA_READONLY)) {
- /* Place caret */
- textarea_get_xy_offset(ta, x, y, &c_off);
- ta->drag_start_char = c_off;
+ /* Place caret */
+ textarea_get_xy_offset(ta, x, y, &c_off);
+ ta->drag_start_char = c_off;
- textarea_set_caret(ta, c_off);
- }
+ textarea_set_caret(ta, c_off);
if (ta->sel_start != -1) {
/* Clear selection */
textarea_clear_selection(ta);