2006-11-26 23:11:20 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2006 Richard Wilson <info@tinct.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-11-26 23:11:20 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Frame and frameset creation and manipulation (implementation).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
2008-07-29 00:32:51 +04:00
|
|
|
#include <math.h>
|
2014-01-30 01:35:53 +04:00
|
|
|
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/utils.h"
|
2016-06-06 10:59:23 +03:00
|
|
|
#include "netsurf/content.h"
|
|
|
|
#include "content/hlcache.h"
|
2018-05-10 13:34:26 +03:00
|
|
|
#include "html/html.h"
|
|
|
|
#include "html/box.h"
|
2006-11-26 23:11:20 +03:00
|
|
|
|
2016-06-06 10:59:23 +03:00
|
|
|
#include "desktop/browser_private.h"
|
|
|
|
#include "desktop/frames.h"
|
|
|
|
#include "desktop/scrollbar.h"
|
|
|
|
|
2006-11-26 23:11:20 +03:00
|
|
|
/** maximum frame resize margin */
|
|
|
|
#define FRAME_RESIZE 6
|
|
|
|
|
|
|
|
static bool browser_window_resolve_frame_dimension(struct browser_window *bw,
|
|
|
|
struct browser_window *sibling, int x, int y, bool width,
|
|
|
|
bool height);
|
|
|
|
|
|
|
|
|
2011-07-06 00:13:28 +04:00
|
|
|
/**
|
|
|
|
* Callback for (i)frame scrollbars.
|
|
|
|
*/
|
|
|
|
void browser_window_scroll_callback(void *client_data,
|
|
|
|
struct scrollbar_msg_data *scrollbar_data)
|
|
|
|
{
|
|
|
|
struct browser_window *bw = client_data;
|
|
|
|
|
|
|
|
switch(scrollbar_data->msg) {
|
|
|
|
case SCROLLBAR_MSG_MOVED:
|
2011-09-04 21:24:45 +04:00
|
|
|
if (bw->browser_window_type == BROWSER_WINDOW_IFRAME) {
|
|
|
|
html_redraw_a_box(bw->parent->current_content, bw->box);
|
|
|
|
} else {
|
|
|
|
struct rect rect;
|
|
|
|
|
2011-12-02 20:10:13 +04:00
|
|
|
rect.x0 = scrollbar_get_offset(bw->scroll_x);
|
|
|
|
rect.y0 = scrollbar_get_offset(bw->scroll_y);
|
|
|
|
rect.x1 = rect.x0 + bw->width;
|
|
|
|
rect.y1 = rect.y0 + bw->height;
|
2011-09-04 21:24:45 +04:00
|
|
|
|
|
|
|
browser_window_update_box(bw, &rect);
|
|
|
|
}
|
2011-07-06 00:13:28 +04:00
|
|
|
break;
|
|
|
|
case SCROLLBAR_MSG_SCROLL_START:
|
2012-01-11 02:02:19 +04:00
|
|
|
{
|
|
|
|
struct rect rect = {
|
|
|
|
.x0 = scrollbar_data->x0,
|
|
|
|
.y0 = scrollbar_data->y0,
|
|
|
|
.x1 = scrollbar_data->x1,
|
|
|
|
.y1 = scrollbar_data->y1
|
|
|
|
};
|
|
|
|
|
2011-07-06 00:13:28 +04:00
|
|
|
if (scrollbar_is_horizontal(scrollbar_data->scrollbar))
|
2012-01-11 02:02:19 +04:00
|
|
|
browser_window_set_drag_type(bw, DRAGGING_SCR_X, &rect);
|
2011-07-06 00:13:28 +04:00
|
|
|
else
|
2012-01-11 02:02:19 +04:00
|
|
|
browser_window_set_drag_type(bw, DRAGGING_SCR_Y, &rect);
|
|
|
|
}
|
2011-07-06 00:13:28 +04:00
|
|
|
break;
|
|
|
|
case SCROLLBAR_MSG_SCROLL_FINISHED:
|
2012-01-11 02:02:19 +04:00
|
|
|
browser_window_set_drag_type(bw, DRAGGING_NONE, NULL);
|
2011-09-07 16:27:37 +04:00
|
|
|
|
2012-08-17 01:21:08 +04:00
|
|
|
browser_window_set_pointer(bw, BROWSER_POINTER_DEFAULT);
|
2011-07-06 00:13:28 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* exported interface, documented in browser.h */
|
|
|
|
void browser_window_handle_scrollbars(struct browser_window *bw)
|
|
|
|
{
|
2016-06-06 10:59:23 +03:00
|
|
|
struct hlcache_handle *h = bw->current_content;
|
2011-07-06 00:13:28 +04:00
|
|
|
bool scroll_x;
|
|
|
|
bool scroll_y;
|
|
|
|
int c_width = 0;
|
|
|
|
int c_height = 0;
|
|
|
|
|
|
|
|
assert(!bw->window); /* Core-handled windows only */
|
|
|
|
|
|
|
|
if (h != NULL) {
|
|
|
|
c_width = content_get_width(h);
|
|
|
|
c_height = content_get_height(h);
|
|
|
|
}
|
|
|
|
|
2014-10-25 15:04:11 +04:00
|
|
|
if (bw->scrolling == BW_SCROLLING_YES) {
|
2011-07-06 00:13:28 +04:00
|
|
|
scroll_x = true;
|
|
|
|
scroll_y = true;
|
2014-10-25 15:04:11 +04:00
|
|
|
} else if (bw->scrolling == BW_SCROLLING_AUTO &&
|
2011-07-06 00:13:28 +04:00
|
|
|
bw->current_content) {
|
|
|
|
int bw_width = bw->width;
|
|
|
|
int bw_height = bw->height;
|
|
|
|
|
|
|
|
/* subtract existing scrollbar width */
|
|
|
|
bw_width -= bw->scroll_y ? SCROLLBAR_WIDTH : 0;
|
|
|
|
bw_height -= bw->scroll_x ? SCROLLBAR_WIDTH : 0;
|
|
|
|
|
|
|
|
scroll_y = (c_height > bw_height) ? true : false;
|
|
|
|
scroll_x = (c_width > bw_width) ? true : false;
|
|
|
|
} else {
|
|
|
|
/* No scrollbars */
|
|
|
|
scroll_x = false;
|
|
|
|
scroll_y = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scroll_x && bw->scroll_x != NULL) {
|
|
|
|
scrollbar_destroy(bw->scroll_x);
|
|
|
|
bw->scroll_x = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scroll_y && bw->scroll_y != NULL) {
|
|
|
|
scrollbar_destroy(bw->scroll_y);
|
|
|
|
bw->scroll_y = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scroll_y) {
|
|
|
|
int length = bw->height;
|
|
|
|
int visible = bw->height - (scroll_x ? SCROLLBAR_WIDTH : 0);
|
|
|
|
|
|
|
|
if (bw->scroll_y == NULL) {
|
|
|
|
/* create vertical scrollbar */
|
2016-04-26 14:14:56 +03:00
|
|
|
if (scrollbar_create(false, length, c_height, visible,
|
|
|
|
bw, browser_window_scroll_callback,
|
|
|
|
&(bw->scroll_y)) != NSERROR_OK) {
|
2011-07-06 00:13:28 +04:00
|
|
|
return;
|
2016-04-26 14:14:56 +03:00
|
|
|
}
|
2011-07-06 00:13:28 +04:00
|
|
|
} else {
|
|
|
|
/* update vertical scrollbar */
|
|
|
|
scrollbar_set_extents(bw->scroll_y, length,
|
|
|
|
visible, c_height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scroll_x) {
|
|
|
|
int length = bw->width - (scroll_y ? SCROLLBAR_WIDTH : 0);
|
|
|
|
int visible = length;
|
|
|
|
|
|
|
|
if (bw->scroll_x == NULL) {
|
|
|
|
/* create horizontal scrollbar */
|
2016-04-26 14:14:56 +03:00
|
|
|
if (scrollbar_create(true, length, c_width, visible,
|
|
|
|
bw, browser_window_scroll_callback,
|
|
|
|
&(bw->scroll_x)) != NSERROR_OK) {
|
2011-07-06 00:13:28 +04:00
|
|
|
return;
|
2016-04-26 14:14:56 +03:00
|
|
|
}
|
2011-07-06 00:13:28 +04:00
|
|
|
} else {
|
|
|
|
/* update horizontal scrollbar */
|
|
|
|
scrollbar_set_extents(bw->scroll_x, length,
|
|
|
|
visible, c_width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scroll_x && scroll_y)
|
|
|
|
scrollbar_make_pair(bw->scroll_x, bw->scroll_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-10 18:05:56 +03:00
|
|
|
/* exported function documented in desktop/frames.h */
|
|
|
|
nserror browser_window_create_iframes(struct browser_window *bw,
|
2011-07-06 00:13:28 +04:00
|
|
|
struct content_html_iframe *iframe)
|
|
|
|
{
|
2006-11-26 23:11:20 +03:00
|
|
|
struct browser_window *window;
|
|
|
|
struct content_html_iframe *cur;
|
2011-06-24 13:30:33 +04:00
|
|
|
struct rect rect;
|
2006-11-26 23:11:20 +03:00
|
|
|
int iframes = 0;
|
|
|
|
int index;
|
2014-11-10 18:05:56 +03:00
|
|
|
nserror ret = NSERROR_OK;
|
|
|
|
|
|
|
|
if (iframe == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2006-11-26 23:11:20 +03:00
|
|
|
|
2014-11-10 18:05:56 +03:00
|
|
|
/* Count iframe list and allocate enough space within the
|
|
|
|
* browser window.
|
|
|
|
*/
|
|
|
|
for (cur = iframe; cur; cur = cur->next) {
|
2006-11-26 23:11:20 +03:00
|
|
|
iframes++;
|
2014-11-10 18:05:56 +03:00
|
|
|
}
|
2006-11-26 23:11:20 +03:00
|
|
|
bw->iframes = calloc(iframes, sizeof(*bw));
|
2014-11-10 18:05:56 +03:00
|
|
|
if (!bw->iframes) {
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
2006-11-26 23:11:20 +03:00
|
|
|
bw->iframe_count = iframes;
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
for (cur = iframe; cur; cur = cur->next) {
|
|
|
|
window = &(bw->iframes[index++]);
|
|
|
|
|
2007-08-07 11:58:04 +04:00
|
|
|
/* Initialise common parts */
|
2014-02-10 18:08:45 +04:00
|
|
|
browser_window_initialise_common(BW_CREATE_NONE,
|
|
|
|
window, NULL);
|
2006-11-26 23:11:20 +03:00
|
|
|
|
|
|
|
/* window characteristics */
|
|
|
|
window->browser_window_type = BROWSER_WINDOW_IFRAME;
|
|
|
|
window->scrolling = cur->scrolling;
|
|
|
|
window->border = cur->border;
|
|
|
|
window->border_colour = cur->border_colour;
|
|
|
|
window->no_resize = true;
|
|
|
|
window->margin_width = cur->margin_width;
|
|
|
|
window->margin_height = cur->margin_height;
|
2011-06-24 17:05:57 +04:00
|
|
|
window->scale = bw->scale;
|
2014-11-10 18:05:56 +03:00
|
|
|
if (cur->name != NULL) {
|
2006-11-26 23:11:20 +03:00
|
|
|
window->name = strdup(cur->name);
|
2014-11-10 18:05:56 +03:00
|
|
|
if (window->name == NULL) {
|
|
|
|
free(bw->iframes) ;
|
|
|
|
bw->iframes = 0;
|
|
|
|
bw->iframe_count = 0;
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
2007-04-08 03:27:28 +04:00
|
|
|
}
|
|
|
|
|
2006-11-26 23:11:20 +03:00
|
|
|
/* linking */
|
|
|
|
window->box = cur->box;
|
|
|
|
window->parent = bw;
|
2011-06-15 00:00:18 +04:00
|
|
|
window->box->iframe = window;
|
2011-06-24 13:30:33 +04:00
|
|
|
|
|
|
|
/* iframe dimensions */
|
|
|
|
box_bounds(window->box, &rect);
|
|
|
|
|
|
|
|
browser_window_set_position(window, rect.x0, rect.y0);
|
|
|
|
browser_window_set_dimensions(window, rect.x1 - rect.x0,
|
|
|
|
rect.y1 - rect.y0);
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* calculate dimensions */
|
2011-06-15 00:00:18 +04:00
|
|
|
browser_window_update_extent(bw);
|
2006-11-26 23:11:20 +03:00
|
|
|
browser_window_recalculate_iframes(bw);
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
for (cur = iframe; cur; cur = cur->next) {
|
|
|
|
window = &(bw->iframes[index++]);
|
2011-06-15 00:00:18 +04:00
|
|
|
if (cur->url) {
|
|
|
|
/* fetch iframe's content */
|
2014-11-10 18:05:56 +03:00
|
|
|
ret = browser_window_navigate(window,
|
2013-02-14 19:09:28 +04:00
|
|
|
cur->url,
|
|
|
|
hlcache_handle_get_url(bw->current_content),
|
2014-02-11 02:40:04 +04:00
|
|
|
BW_NAVIGATE_UNVERIFIABLE,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
bw->current_content);
|
2011-06-15 00:00:18 +04:00
|
|
|
}
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
2014-11-10 18:05:56 +03:00
|
|
|
|
|
|
|
return ret;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Recalculate iframe positions following a resize.
|
|
|
|
*
|
|
|
|
* \param bw The browser window to reposition iframes for
|
|
|
|
*/
|
|
|
|
|
2011-06-15 00:00:18 +04:00
|
|
|
void browser_window_recalculate_iframes(struct browser_window *bw)
|
|
|
|
{
|
2011-07-06 00:13:28 +04:00
|
|
|
struct browser_window *window;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
for (index = 0; index < bw->iframe_count; index++) {
|
|
|
|
window = &(bw->iframes[index]);
|
|
|
|
|
|
|
|
if (window != NULL) {
|
|
|
|
browser_window_handle_scrollbars(window);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-26 12:26:00 +03:00
|
|
|
/* exported interface documented in desktop/frames.h */
|
|
|
|
nserror browser_window_create_frameset(struct browser_window *bw,
|
2012-08-16 18:47:14 +04:00
|
|
|
struct content_html_frames *frameset)
|
|
|
|
{
|
2006-11-26 23:11:20 +03:00
|
|
|
int row, col, index;
|
|
|
|
struct content_html_frames *frame;
|
|
|
|
struct browser_window *window;
|
2010-03-28 16:56:39 +04:00
|
|
|
hlcache_handle *parent;
|
2006-11-26 23:11:20 +03:00
|
|
|
|
|
|
|
assert(bw && frameset);
|
|
|
|
|
2007-01-03 18:15:54 +03:00
|
|
|
/* 1. Create children */
|
2006-11-26 23:11:20 +03:00
|
|
|
assert(bw->children == NULL);
|
|
|
|
assert(frameset->cols + frameset->rows != 0);
|
|
|
|
|
|
|
|
bw->children = calloc((frameset->cols * frameset->rows), sizeof(*bw));
|
2016-04-26 12:26:00 +03:00
|
|
|
if (!bw->children) {
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
|
2006-11-26 23:11:20 +03:00
|
|
|
bw->cols = frameset->cols;
|
|
|
|
bw->rows = frameset->rows;
|
|
|
|
for (row = 0; row < bw->rows; row++) {
|
|
|
|
for (col = 0; col < bw->cols; col++) {
|
|
|
|
index = (row * bw->cols) + col;
|
|
|
|
frame = &frameset->children[index];
|
|
|
|
window = &bw->children[index];
|
|
|
|
|
2007-08-07 11:58:04 +04:00
|
|
|
/* Initialise common parts */
|
2014-02-10 18:08:45 +04:00
|
|
|
browser_window_initialise_common(BW_CREATE_NONE,
|
|
|
|
window, NULL);
|
2006-11-26 23:11:20 +03:00
|
|
|
|
|
|
|
/* window characteristics */
|
|
|
|
if (frame->children)
|
2007-01-27 23:58:20 +03:00
|
|
|
window->browser_window_type =
|
|
|
|
BROWSER_WINDOW_FRAMESET;
|
2006-11-26 23:11:20 +03:00
|
|
|
else
|
2007-01-27 23:58:20 +03:00
|
|
|
window->browser_window_type =
|
|
|
|
BROWSER_WINDOW_FRAME;
|
2006-11-26 23:11:20 +03:00
|
|
|
window->scrolling = frame->scrolling;
|
|
|
|
window->border = frame->border;
|
|
|
|
window->border_colour = frame->border_colour;
|
|
|
|
window->no_resize = frame->no_resize;
|
|
|
|
window->frame_width = frame->width;
|
|
|
|
window->frame_height = frame->height;
|
|
|
|
window->margin_width = frame->margin_width;
|
|
|
|
window->margin_height = frame->margin_height;
|
2007-04-08 03:08:31 +04:00
|
|
|
if (frame->name) {
|
2006-11-26 23:11:20 +03:00
|
|
|
window->name = strdup(frame->name);
|
2016-04-26 12:26:00 +03:00
|
|
|
if (!window->name) {
|
|
|
|
free(bw->children);
|
|
|
|
bw->children = NULL;
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
2007-04-08 03:08:31 +04:00
|
|
|
}
|
2006-11-26 23:11:20 +03:00
|
|
|
|
2011-09-04 21:24:45 +04:00
|
|
|
window->scale = bw->scale;
|
2011-06-15 00:00:18 +04:00
|
|
|
|
2006-11-26 23:11:20 +03:00
|
|
|
/* linking */
|
|
|
|
window->parent = bw;
|
|
|
|
|
2007-04-08 03:08:31 +04:00
|
|
|
if (window->name)
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Created frame '%s'",
|
|
|
|
window->name);
|
2007-04-08 03:08:31 +04:00
|
|
|
else
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"Created frame (unnamed)");
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-03 18:15:54 +03:00
|
|
|
/* 2. Calculate dimensions */
|
2011-06-15 00:00:18 +04:00
|
|
|
browser_window_update_extent(bw);
|
2006-11-26 23:11:20 +03:00
|
|
|
browser_window_recalculate_frameset(bw);
|
|
|
|
|
2007-01-03 18:15:54 +03:00
|
|
|
/* 3. Recurse for grandchildren */
|
|
|
|
for (row = 0; row < bw->rows; row++) {
|
|
|
|
for (col = 0; col < bw->cols; col++) {
|
|
|
|
index = (row * bw->cols) + col;
|
|
|
|
frame = &frameset->children[index];
|
|
|
|
window = &bw->children[index];
|
|
|
|
|
|
|
|
if (frame->children)
|
|
|
|
browser_window_create_frameset(window, frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-27 23:58:20 +03:00
|
|
|
/* Use the URL of the first ancestor window containing html content
|
|
|
|
* as the referer */
|
|
|
|
for (window = bw; window->parent; window = window->parent) {
|
2016-06-06 10:59:23 +03:00
|
|
|
if (window->current_content &&
|
|
|
|
content_get_type(window->current_content) ==
|
2010-03-28 16:56:39 +04:00
|
|
|
CONTENT_HTML)
|
2007-01-27 23:58:20 +03:00
|
|
|
break;
|
|
|
|
}
|
2009-07-10 04:26:37 +04:00
|
|
|
|
|
|
|
parent = window->current_content;
|
2007-01-27 23:58:20 +03:00
|
|
|
|
2007-01-03 18:15:54 +03:00
|
|
|
/* 4. Launch content */
|
2006-11-26 23:11:20 +03:00
|
|
|
for (row = 0; row < bw->rows; row++) {
|
|
|
|
for (col = 0; col < bw->cols; col++) {
|
|
|
|
index = (row * bw->cols) + col;
|
|
|
|
frame = &frameset->children[index];
|
|
|
|
window = &bw->children[index];
|
|
|
|
|
2007-01-27 23:58:20 +03:00
|
|
|
if (frame->url) {
|
2013-02-14 19:09:28 +04:00
|
|
|
browser_window_navigate(window,
|
|
|
|
frame->url,
|
|
|
|
hlcache_handle_get_url(parent),
|
2014-02-11 02:40:04 +04:00
|
|
|
BW_NAVIGATE_HISTORY |
|
|
|
|
BW_NAVIGATE_UNVERIFIABLE,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
parent);
|
2007-01-27 23:58:20 +03:00
|
|
|
}
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
}
|
2016-04-26 12:26:00 +03:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Recalculate frameset positions following a resize.
|
|
|
|
*
|
|
|
|
* \param bw The browser window to reposition framesets for
|
|
|
|
*/
|
|
|
|
|
2012-08-16 18:47:14 +04:00
|
|
|
void browser_window_recalculate_frameset(struct browser_window *bw)
|
|
|
|
{
|
2006-11-26 23:11:20 +03:00
|
|
|
int widths[bw->cols][bw->rows];
|
|
|
|
int heights[bw->cols][bw->rows];
|
|
|
|
int bw_width, bw_height;
|
|
|
|
int avail_width, avail_height;
|
|
|
|
int row, row2, col, index;
|
|
|
|
struct browser_window *window;
|
|
|
|
float relative;
|
2011-12-14 22:31:57 +04:00
|
|
|
int size, extent, applied;
|
2006-11-26 23:11:20 +03:00
|
|
|
int x, y;
|
2011-09-04 21:24:45 +04:00
|
|
|
int new_width, new_height;
|
2006-11-26 23:11:20 +03:00
|
|
|
|
|
|
|
assert(bw);
|
|
|
|
|
|
|
|
/* window dimensions */
|
|
|
|
if (!bw->parent) {
|
2019-08-02 13:52:56 +03:00
|
|
|
browser_window_get_dimensions(bw, &bw_width, &bw_height);
|
|
|
|
bw_width /= bw->scale;
|
|
|
|
bw_height /= bw->scale;
|
2011-09-04 21:24:45 +04:00
|
|
|
bw->x = 0;
|
|
|
|
bw->y = 0;
|
|
|
|
bw->width = bw_width;
|
|
|
|
bw->height = bw_height;
|
2006-11-26 23:11:20 +03:00
|
|
|
} else {
|
2011-09-04 21:24:45 +04:00
|
|
|
bw_width = bw->width;
|
|
|
|
bw_height = bw->height;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
bw_width++;
|
|
|
|
bw_height++;
|
|
|
|
|
|
|
|
/* widths */
|
|
|
|
for (row = 0; row < bw->rows; row++) {
|
|
|
|
avail_width = bw_width;
|
|
|
|
relative = 0;
|
|
|
|
for (col = 0; col < bw->cols; col++) {
|
|
|
|
index = (row * bw->cols) + col;
|
|
|
|
window = &bw->children[index];
|
|
|
|
|
|
|
|
switch (window->frame_width.unit) {
|
2010-07-07 01:09:20 +04:00
|
|
|
case FRAME_DIMENSION_PIXELS:
|
|
|
|
widths[col][row] = window->frame_width.value *
|
|
|
|
window->scale;
|
|
|
|
if (window->border) {
|
|
|
|
if (col != 0)
|
|
|
|
widths[col][row] += 1;
|
|
|
|
if (col != bw->cols - 1)
|
|
|
|
widths[col][row] += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FRAME_DIMENSION_PERCENT:
|
|
|
|
widths[col][row] = bw_width *
|
|
|
|
window->frame_width.value / 100;
|
|
|
|
break;
|
|
|
|
case FRAME_DIMENSION_RELATIVE:
|
|
|
|
widths[col][row] = 0;
|
|
|
|
relative += window->frame_width.value;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* unknown frame dimension unit */
|
|
|
|
assert(window->frame_width.unit ==
|
|
|
|
FRAME_DIMENSION_PIXELS ||
|
|
|
|
window->frame_width.unit ==
|
|
|
|
FRAME_DIMENSION_PERCENT ||
|
|
|
|
window->frame_width.unit ==
|
|
|
|
FRAME_DIMENSION_RELATIVE);
|
|
|
|
break;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
avail_width -= widths[col][row];
|
|
|
|
}
|
|
|
|
|
2012-01-06 18:44:01 +04:00
|
|
|
/* Redistribute to fit window */
|
2006-11-26 23:11:20 +03:00
|
|
|
if ((relative > 0) && (avail_width > 0)) {
|
2012-01-06 18:44:01 +04:00
|
|
|
/* Expand the relative sections to fill remainder */
|
2006-11-26 23:11:20 +03:00
|
|
|
for (col = 0; col < bw->cols; col++) {
|
|
|
|
index = (row * bw->cols) + col;
|
|
|
|
window = &bw->children[index];
|
|
|
|
|
2011-12-14 22:31:57 +04:00
|
|
|
if (window->frame_width.unit ==
|
|
|
|
FRAME_DIMENSION_RELATIVE) {
|
|
|
|
size = avail_width * window->
|
|
|
|
frame_width.value /
|
|
|
|
relative;
|
2006-11-26 23:11:20 +03:00
|
|
|
avail_width -= size;
|
|
|
|
relative -= window->frame_width.value;
|
|
|
|
widths[col][row] += size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (bw_width != avail_width) {
|
|
|
|
/* proportionally distribute error */
|
2011-12-14 22:31:57 +04:00
|
|
|
extent = avail_width;
|
|
|
|
applied = 0;
|
2006-11-26 23:11:20 +03:00
|
|
|
for (col = 0; col < bw->cols; col++) {
|
|
|
|
if (col == bw->cols - 1) {
|
2012-01-06 18:44:01 +04:00
|
|
|
/* Last cell, use up remainder */
|
|
|
|
widths[col][row] += extent - applied;
|
|
|
|
widths[col][row] =
|
|
|
|
widths[col][row] < 0 ?
|
|
|
|
0 : widths[col][row];
|
2006-11-26 23:11:20 +03:00
|
|
|
} else {
|
2011-12-14 22:31:57 +04:00
|
|
|
/* Find size of cell adjustment */
|
|
|
|
size = (widths[col][row] * extent) /
|
2012-01-06 18:44:01 +04:00
|
|
|
(bw_width - extent);
|
|
|
|
/* Modify cell */
|
2011-12-14 22:31:57 +04:00
|
|
|
widths[col][row] += size;
|
2012-01-06 18:44:01 +04:00
|
|
|
applied += size;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* heights */
|
|
|
|
for (col = 0; col < bw->cols; col++) {
|
|
|
|
avail_height = bw_height;
|
|
|
|
relative = 0;
|
|
|
|
for (row = 0; row < bw->rows; row++) {
|
|
|
|
index = (row * bw->cols) + col;
|
|
|
|
window = &bw->children[index];
|
|
|
|
|
|
|
|
switch (window->frame_height.unit) {
|
2010-07-07 01:09:20 +04:00
|
|
|
case FRAME_DIMENSION_PIXELS:
|
|
|
|
heights[col][row] = window->frame_height.value *
|
|
|
|
window->scale;
|
|
|
|
if (window->border) {
|
|
|
|
if (row != 0)
|
|
|
|
heights[col][row] += 1;
|
|
|
|
if (row != bw->rows - 1)
|
|
|
|
heights[col][row] += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FRAME_DIMENSION_PERCENT:
|
|
|
|
heights[col][row] = bw_height *
|
|
|
|
window->frame_height.value / 100;
|
|
|
|
break;
|
|
|
|
case FRAME_DIMENSION_RELATIVE:
|
|
|
|
heights[col][row] = 0;
|
|
|
|
relative += window->frame_height.value;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* unknown frame dimension unit */
|
|
|
|
assert(window->frame_height.unit ==
|
|
|
|
FRAME_DIMENSION_PIXELS ||
|
|
|
|
window->frame_height.unit ==
|
|
|
|
FRAME_DIMENSION_PERCENT ||
|
|
|
|
window->frame_height.unit ==
|
|
|
|
FRAME_DIMENSION_RELATIVE);
|
|
|
|
break;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
avail_height -= heights[col][row];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (avail_height == 0)
|
|
|
|
continue;
|
|
|
|
|
2012-01-06 18:44:01 +04:00
|
|
|
/* Redistribute to fit window */
|
2006-11-26 23:11:20 +03:00
|
|
|
if ((relative > 0) && (avail_height > 0)) {
|
2012-01-06 18:44:01 +04:00
|
|
|
/* Expand the relative sections to fill remainder */
|
2006-11-26 23:11:20 +03:00
|
|
|
for (row = 0; row < bw->rows; row++) {
|
|
|
|
index = (row * bw->cols) + col;
|
|
|
|
window = &bw->children[index];
|
|
|
|
|
2011-12-14 22:31:57 +04:00
|
|
|
if (window->frame_height.unit ==
|
|
|
|
FRAME_DIMENSION_RELATIVE) {
|
|
|
|
size = avail_height * window->
|
|
|
|
frame_height.value /
|
|
|
|
relative;
|
2006-11-26 23:11:20 +03:00
|
|
|
avail_height -= size;
|
|
|
|
relative -= window->frame_height.value;
|
|
|
|
heights[col][row] += size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (bw_height != avail_height) {
|
|
|
|
/* proportionally distribute error */
|
2011-12-14 22:31:57 +04:00
|
|
|
extent = avail_height;
|
|
|
|
applied = 0;
|
2006-11-26 23:11:20 +03:00
|
|
|
for (row = 0; row < bw->rows; row++) {
|
|
|
|
if (row == bw->rows - 1) {
|
2012-01-06 18:44:01 +04:00
|
|
|
/* Last cell, use up remainder */
|
|
|
|
heights[col][row] += extent - applied;
|
|
|
|
heights[col][row] =
|
|
|
|
heights[col][row] < 0 ?
|
|
|
|
0 : heights[col][row];
|
2006-11-26 23:11:20 +03:00
|
|
|
} else {
|
2011-12-14 22:31:57 +04:00
|
|
|
/* Find size of cell adjustment */
|
|
|
|
size = (heights[col][row] * extent) /
|
2012-01-06 18:44:01 +04:00
|
|
|
(bw_height - extent);
|
|
|
|
/* Modify cell */
|
2011-12-14 22:31:57 +04:00
|
|
|
heights[col][row] += size;
|
2012-01-06 18:44:01 +04:00
|
|
|
applied += size;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* position frames and calculate children */
|
|
|
|
for (row = 0; row < bw->rows; row++) {
|
|
|
|
x = 0;
|
|
|
|
for (col = 0; col < bw->cols; col++) {
|
|
|
|
index = (row * bw->cols) + col;
|
|
|
|
window = &bw->children[index];
|
|
|
|
|
|
|
|
y = 0;
|
|
|
|
for (row2 = 0; row2 < row; row2++)
|
|
|
|
y+= heights[col][row2];
|
2011-09-04 21:24:45 +04:00
|
|
|
|
|
|
|
window->x = x;
|
|
|
|
window->y = y;
|
|
|
|
|
|
|
|
new_width = widths[col][row] - 1;
|
|
|
|
new_height = heights[col][row] - 1;
|
|
|
|
|
|
|
|
if (window->width != new_width ||
|
|
|
|
window->height != new_height) {
|
|
|
|
/* Change in frame size */
|
|
|
|
browser_window_reformat(window, false,
|
|
|
|
new_width * bw->scale,
|
|
|
|
new_height * bw->scale);
|
|
|
|
window->width = new_width;
|
|
|
|
window->height = new_height;
|
|
|
|
|
|
|
|
browser_window_handle_scrollbars(window);
|
|
|
|
}
|
|
|
|
|
2006-11-26 23:11:20 +03:00
|
|
|
x += widths[col][row];
|
2011-09-04 21:24:45 +04:00
|
|
|
|
2006-11-26 23:11:20 +03:00
|
|
|
if (window->children)
|
|
|
|
browser_window_recalculate_frameset(window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resize a browser window that is a frame.
|
|
|
|
*
|
2014-11-10 00:49:33 +03:00
|
|
|
* \param bw The browser window to resize
|
|
|
|
* \param x The new width to set.
|
|
|
|
* \param y The new height to set.
|
2006-11-26 23:11:20 +03:00
|
|
|
*/
|
|
|
|
|
2012-08-16 18:47:14 +04:00
|
|
|
void browser_window_resize_frame(struct browser_window *bw, int x, int y)
|
|
|
|
{
|
2006-11-26 23:11:20 +03:00
|
|
|
struct browser_window *parent;
|
|
|
|
struct browser_window *sibling;
|
|
|
|
int col = -1, row = -1, i;
|
|
|
|
bool change = false;
|
|
|
|
|
|
|
|
parent = bw->parent;
|
|
|
|
assert(parent);
|
|
|
|
|
|
|
|
/* get frame location */
|
|
|
|
for (i = 0; i < (parent->cols * parent->rows); i++) {
|
|
|
|
if (&parent->children[i] == bw) {
|
|
|
|
col = i % parent->cols;
|
|
|
|
row = i / parent->cols;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert((col >= 0) && (row >= 0));
|
|
|
|
|
|
|
|
sibling = NULL;
|
2017-03-03 17:30:39 +03:00
|
|
|
if (bw->drag.resize_left) {
|
2006-11-26 23:11:20 +03:00
|
|
|
sibling = &parent->children[row * parent->cols + (col - 1)];
|
2017-03-03 17:30:39 +03:00
|
|
|
} else if (bw->drag.resize_right) {
|
2006-11-26 23:11:20 +03:00
|
|
|
sibling = &parent->children[row * parent->cols + (col + 1)];
|
2017-03-03 17:30:39 +03:00
|
|
|
}
|
|
|
|
if (sibling) {
|
2012-01-11 02:02:19 +04:00
|
|
|
change |= browser_window_resolve_frame_dimension(bw, sibling,
|
|
|
|
x, y, true, false);
|
2017-03-03 17:30:39 +03:00
|
|
|
}
|
2006-11-26 23:11:20 +03:00
|
|
|
|
|
|
|
sibling = NULL;
|
2017-03-03 17:30:39 +03:00
|
|
|
if (bw->drag.resize_up) {
|
2006-11-26 23:11:20 +03:00
|
|
|
sibling = &parent->children[(row - 1) * parent->cols + col];
|
2017-03-03 17:30:39 +03:00
|
|
|
} else if (bw->drag.resize_down) {
|
2006-11-26 23:11:20 +03:00
|
|
|
sibling = &parent->children[(row + 1) * parent->cols + col];
|
2017-03-03 17:30:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sibling) {
|
2012-01-11 02:02:19 +04:00
|
|
|
change |= browser_window_resolve_frame_dimension(bw, sibling,
|
|
|
|
x, y, false, true);
|
2017-03-03 17:30:39 +03:00
|
|
|
}
|
2006-11-26 23:11:20 +03:00
|
|
|
|
2017-03-03 17:30:39 +03:00
|
|
|
if (change) {
|
2006-11-26 23:11:20 +03:00
|
|
|
browser_window_recalculate_frameset(parent);
|
2017-03-03 17:30:39 +03:00
|
|
|
}
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-11 02:02:19 +04:00
|
|
|
bool browser_window_resolve_frame_dimension(struct browser_window *bw,
|
|
|
|
struct browser_window *sibling,
|
2012-08-16 18:47:14 +04:00
|
|
|
int x, int y, bool width, bool height)
|
|
|
|
{
|
2006-11-26 23:11:20 +03:00
|
|
|
int bw_dimension, sibling_dimension;
|
|
|
|
int bw_pixels, sibling_pixels;
|
|
|
|
struct frame_dimension *bw_d, *sibling_d;
|
|
|
|
float total_new;
|
|
|
|
int frame_size;
|
|
|
|
|
|
|
|
assert(!(width && height));
|
|
|
|
|
|
|
|
/* extend/shrink the box to the pointer */
|
|
|
|
if (width) {
|
2017-03-03 17:30:39 +03:00
|
|
|
if (bw->drag.resize_left) {
|
2011-09-06 14:44:00 +04:00
|
|
|
bw_dimension = bw->x + bw->width - x;
|
2017-03-03 17:30:39 +03:00
|
|
|
} else {
|
2011-09-06 14:44:00 +04:00
|
|
|
bw_dimension = x - bw->x;
|
2017-03-03 17:30:39 +03:00
|
|
|
}
|
2011-09-06 14:44:00 +04:00
|
|
|
bw_pixels = bw->width;
|
|
|
|
sibling_pixels = sibling->width;
|
2006-11-26 23:11:20 +03:00
|
|
|
bw_d = &bw->frame_width;
|
|
|
|
sibling_d = &sibling->frame_width;
|
2011-09-06 14:44:00 +04:00
|
|
|
frame_size = bw->parent->width;
|
2006-11-26 23:11:20 +03:00
|
|
|
} else {
|
2017-03-03 17:30:39 +03:00
|
|
|
if (bw->drag.resize_up) {
|
2011-09-06 14:44:00 +04:00
|
|
|
bw_dimension = bw->y + bw->height - y;
|
2017-03-03 17:30:39 +03:00
|
|
|
} else {
|
2011-09-06 14:44:00 +04:00
|
|
|
bw_dimension = y - bw->y;
|
2017-03-03 17:30:39 +03:00
|
|
|
}
|
2011-09-06 14:44:00 +04:00
|
|
|
bw_pixels = bw->height;
|
|
|
|
sibling_pixels = sibling->height;
|
2006-11-26 23:11:20 +03:00
|
|
|
bw_d = &bw->frame_height;
|
|
|
|
sibling_d = &sibling->frame_height;
|
2011-09-06 14:44:00 +04:00
|
|
|
frame_size = bw->parent->height;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
sibling_dimension = bw_pixels + sibling_pixels - bw_dimension;
|
|
|
|
|
|
|
|
/* check for no change or no frame size*/
|
|
|
|
if ((bw_dimension == bw_pixels) || (frame_size == 0))
|
|
|
|
return false;
|
|
|
|
/* check for both being 0 */
|
|
|
|
total_new = bw_dimension + sibling_dimension;
|
|
|
|
if ((bw_dimension + sibling_dimension) == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* our frame dimensions are now known to be:
|
|
|
|
*
|
2007-01-03 18:15:54 +03:00
|
|
|
* <-- frame_size --> [VISIBLE PIXELS]
|
2006-11-26 23:11:20 +03:00
|
|
|
* |<-- bw_pixels -->|<-- sibling_pixels -->| [VISIBLE PIXELS, BEFORE RESIZE]
|
|
|
|
* |<-- bw_d->value-->|<-- sibling_d->value-->| [SPECIFIED UNITS, BEFORE RESIZE]
|
|
|
|
* |<--bw_dimension-->|<--sibling_dimension-->| [VISIBLE PIXELS, AFTER RESIZE]
|
2007-01-03 18:15:54 +03:00
|
|
|
* |<-- total_new -->| [VISIBLE PIXELS, AFTER RESIZE]
|
2006-11-26 23:11:20 +03:00
|
|
|
*
|
|
|
|
* when we resize, we must retain the original unit specification such that any
|
|
|
|
* subsequent resizing of the parent window will recalculate the page as the
|
|
|
|
* author specified.
|
|
|
|
*
|
|
|
|
* if the units of both frames are the same then we can resize the values simply
|
|
|
|
* by updating the values to be a percentage of the original widths.
|
|
|
|
*/
|
|
|
|
if (bw_d->unit == sibling_d->unit) {
|
|
|
|
float total_specified = bw_d->value + sibling_d->value;
|
|
|
|
bw_d->value = (total_specified * bw_dimension) / total_new;
|
|
|
|
sibling_d->value = total_specified - bw_d->value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if one of the sizes is relative then we don't alter the relative width and
|
|
|
|
* just let it reflow across. the non-relative (pixel/percentage) value can
|
|
|
|
* simply be resolved to the specified width that will result in the required
|
|
|
|
* dimension.
|
|
|
|
*/
|
|
|
|
if (bw_d->unit == FRAME_DIMENSION_RELATIVE) {
|
2007-01-03 18:15:54 +03:00
|
|
|
if ((sibling_pixels == 0) && (bw_dimension == 0))
|
|
|
|
return false;
|
2007-10-28 20:05:39 +03:00
|
|
|
if (fabs(sibling_d->value) < 0.0001)
|
2007-01-03 18:15:54 +03:00
|
|
|
bw_d->value = 1;
|
|
|
|
if (sibling_pixels == 0)
|
|
|
|
sibling_d->value = (sibling_d->value * bw_pixels) / bw_dimension;
|
|
|
|
else
|
|
|
|
sibling_d->value =
|
|
|
|
(sibling_d->value * sibling_dimension) / sibling_pixels;
|
2006-11-26 23:11:20 +03:00
|
|
|
|
|
|
|
/* todo: the availble resize may have changed, update the drag box */
|
|
|
|
return true;
|
|
|
|
} else if (sibling_d->unit == FRAME_DIMENSION_RELATIVE) {
|
2007-01-03 18:15:54 +03:00
|
|
|
if ((bw_pixels == 0) && (sibling_dimension == 0))
|
|
|
|
return false;
|
2007-10-28 20:05:39 +03:00
|
|
|
if (fabs(bw_d->value) < 0.0001)
|
2007-01-03 18:15:54 +03:00
|
|
|
bw_d->value = 1;
|
|
|
|
if (bw_pixels == 0)
|
|
|
|
bw_d->value = (bw_d->value * sibling_pixels) / sibling_dimension;
|
|
|
|
else
|
|
|
|
bw_d->value = (bw_d->value * bw_dimension) / bw_pixels;
|
2006-11-26 23:11:20 +03:00
|
|
|
|
|
|
|
/* todo: the availble resize may have changed, update the drag box */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* finally we have a pixel/percentage mix. unlike relative values, percentages
|
|
|
|
* can easily be backwards-calculated as they can simply be scaled like pixel
|
|
|
|
* values
|
|
|
|
*/
|
|
|
|
if (bw_d->unit == FRAME_DIMENSION_PIXELS) {
|
|
|
|
float total_specified = bw_d->value + frame_size * sibling_d->value / 100;
|
|
|
|
bw_d->value = (total_specified * bw_dimension) / total_new;
|
|
|
|
sibling_d->value = (total_specified - bw_d->value) * 100 / frame_size;
|
|
|
|
return true;
|
|
|
|
} else if (sibling_d->unit == FRAME_DIMENSION_PIXELS) {
|
|
|
|
float total_specified = bw_d->value * frame_size / 100 + sibling_d->value;
|
|
|
|
sibling_d->value = (total_specified * sibling_dimension) / total_new;
|
|
|
|
bw_d->value = (total_specified - sibling_d->value) * 100 / frame_size;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
assert(!"Invalid frame dimension unit");
|
2007-01-03 18:15:54 +03:00
|
|
|
return false;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-16 18:55:20 +04:00
|
|
|
static bool browser_window_resize_frames(struct browser_window *bw,
|
2012-01-11 02:02:19 +04:00
|
|
|
browser_mouse_state mouse, int x, int y,
|
2012-08-17 01:21:08 +04:00
|
|
|
browser_pointer_shape *pointer)
|
2012-08-16 18:47:14 +04:00
|
|
|
{
|
2006-12-03 22:47:07 +03:00
|
|
|
struct browser_window *parent;
|
2006-11-26 23:11:20 +03:00
|
|
|
bool left, right, up, down;
|
|
|
|
int i, resize_margin;
|
|
|
|
|
2011-09-06 14:44:00 +04:00
|
|
|
if ((x < bw->x) || (x > bw->x + bw->width) ||
|
|
|
|
(y < bw->y) || (y > bw->y + bw->height))
|
2006-11-26 23:11:20 +03:00
|
|
|
return false;
|
|
|
|
|
2006-12-03 22:47:07 +03:00
|
|
|
parent = bw->parent;
|
|
|
|
if ((!bw->no_resize) && parent) {
|
2006-11-26 23:11:20 +03:00
|
|
|
resize_margin = FRAME_RESIZE;
|
2011-09-06 14:44:00 +04:00
|
|
|
if (resize_margin * 2 > bw->width)
|
|
|
|
resize_margin = bw->width / 2;
|
|
|
|
left = (x < bw->x + resize_margin);
|
|
|
|
right = (x > bw->x + bw->width - resize_margin);
|
2006-11-26 23:11:20 +03:00
|
|
|
resize_margin = FRAME_RESIZE;
|
2011-09-06 14:44:00 +04:00
|
|
|
if (resize_margin * 2 > bw->height)
|
|
|
|
resize_margin = bw->height / 2;
|
|
|
|
up = (y < bw->y + resize_margin);
|
|
|
|
down = (y > bw->y + bw-> height - resize_margin);
|
2006-11-26 23:11:20 +03:00
|
|
|
|
|
|
|
/* check if the edges can actually be moved */
|
|
|
|
if (left || right || up || down) {
|
|
|
|
int row = -1, col = -1;
|
|
|
|
switch (bw->browser_window_type) {
|
|
|
|
case BROWSER_WINDOW_NORMAL:
|
|
|
|
case BROWSER_WINDOW_IFRAME:
|
|
|
|
assert(0);
|
|
|
|
break;
|
|
|
|
case BROWSER_WINDOW_FRAME:
|
|
|
|
case BROWSER_WINDOW_FRAMESET:
|
|
|
|
break;
|
|
|
|
}
|
2006-12-03 22:47:07 +03:00
|
|
|
for (i = 0; i < (parent->cols * parent->rows); i++) {
|
|
|
|
if (&parent->children[i] == bw) {
|
|
|
|
col = i % parent->cols;
|
|
|
|
row = i / parent->cols;
|
|
|
|
break;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
assert((row >= 0) && (col >= 0));
|
|
|
|
|
2006-12-03 22:47:07 +03:00
|
|
|
/* check the sibling frame is within bounds */
|
2006-11-26 23:11:20 +03:00
|
|
|
left &= (col > 0);
|
2006-12-03 22:47:07 +03:00
|
|
|
right &= (col < parent->cols - 1);
|
2006-11-26 23:11:20 +03:00
|
|
|
up &= (row > 0);
|
2006-12-03 22:47:07 +03:00
|
|
|
down &= (row < parent->rows - 1);
|
2007-01-03 18:15:54 +03:00
|
|
|
|
2006-12-03 22:47:07 +03:00
|
|
|
/* check the sibling frames can be resized */
|
|
|
|
if (left)
|
2012-08-16 18:47:14 +04:00
|
|
|
left &= !parent->children[row *
|
|
|
|
parent->cols + (col - 1)].
|
|
|
|
no_resize;
|
2006-12-03 22:47:07 +03:00
|
|
|
if (right)
|
2012-08-16 18:47:14 +04:00
|
|
|
right &= !parent->children[row *
|
|
|
|
parent->cols + (col + 1)].
|
|
|
|
no_resize;
|
2006-12-03 22:47:07 +03:00
|
|
|
if (up)
|
2012-08-16 18:47:14 +04:00
|
|
|
up &= !parent->children[(row - 1) *
|
|
|
|
parent->cols + col].
|
|
|
|
no_resize;
|
2006-12-03 22:47:07 +03:00
|
|
|
if (down)
|
2012-08-16 18:47:14 +04:00
|
|
|
down &= !parent->children[(row + 1) *
|
|
|
|
parent->cols + col].
|
|
|
|
no_resize;
|
2006-12-03 22:47:07 +03:00
|
|
|
|
|
|
|
/* can't have opposite directions simultaneously */
|
|
|
|
if (up)
|
|
|
|
down = false;
|
|
|
|
if (left)
|
|
|
|
right = false;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (left || right || up || down) {
|
|
|
|
if (left) {
|
|
|
|
if (down)
|
2012-08-17 01:21:08 +04:00
|
|
|
*pointer = BROWSER_POINTER_LD;
|
2006-11-26 23:11:20 +03:00
|
|
|
else if (up)
|
2012-08-17 01:21:08 +04:00
|
|
|
*pointer = BROWSER_POINTER_LU;
|
2006-11-26 23:11:20 +03:00
|
|
|
else
|
2012-08-17 01:21:08 +04:00
|
|
|
*pointer = BROWSER_POINTER_LEFT;
|
2006-11-26 23:11:20 +03:00
|
|
|
} else if (right) {
|
|
|
|
if (down)
|
2012-08-17 01:21:08 +04:00
|
|
|
*pointer = BROWSER_POINTER_RD;
|
2006-11-26 23:11:20 +03:00
|
|
|
else if (up)
|
2012-08-17 01:21:08 +04:00
|
|
|
*pointer = BROWSER_POINTER_RU;
|
2006-11-26 23:11:20 +03:00
|
|
|
else
|
2012-08-17 01:21:08 +04:00
|
|
|
*pointer = BROWSER_POINTER_RIGHT;
|
2006-11-26 23:11:20 +03:00
|
|
|
} else if (up) {
|
2012-08-17 01:21:08 +04:00
|
|
|
*pointer = BROWSER_POINTER_UP;
|
2006-11-26 23:11:20 +03:00
|
|
|
} else {
|
2012-08-17 01:21:08 +04:00
|
|
|
*pointer = BROWSER_POINTER_DOWN;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
2012-01-11 02:02:19 +04:00
|
|
|
if (mouse & (BROWSER_MOUSE_DRAG_1 |
|
|
|
|
BROWSER_MOUSE_DRAG_2)) {
|
|
|
|
|
|
|
|
/* TODO: Pass appropriate rectangle to allow
|
|
|
|
* front end to clamp pointer range */
|
|
|
|
browser_window_set_drag_type(bw,
|
|
|
|
DRAGGING_FRAME, NULL);
|
2017-03-03 17:30:39 +03:00
|
|
|
bw->drag.start_x = x;
|
|
|
|
bw->drag.start_y = y;
|
|
|
|
bw->drag.resize_left = left;
|
|
|
|
bw->drag.resize_right = right;
|
|
|
|
bw->drag.resize_up = up;
|
|
|
|
bw->drag.resize_down = down;
|
2006-11-26 23:11:20 +03:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bw->children) {
|
|
|
|
for (i = 0; i < (bw->cols * bw->rows); i++)
|
2012-01-11 02:02:19 +04:00
|
|
|
if (browser_window_resize_frames(&bw->children[i],
|
2012-08-16 18:43:14 +04:00
|
|
|
mouse, x, y, pointer))
|
2006-11-26 23:11:20 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (bw->iframes) {
|
|
|
|
for (i = 0; i < bw->iframe_count; i++)
|
2012-01-11 02:02:19 +04:00
|
|
|
if (browser_window_resize_frames(&bw->iframes[i],
|
2012-08-16 18:43:14 +04:00
|
|
|
mouse, x, y, pointer))
|
2006-11-26 23:11:20 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-16 18:55:20 +04:00
|
|
|
|
|
|
|
|
|
|
|
bool browser_window_frame_resize_start(struct browser_window *bw,
|
|
|
|
browser_mouse_state mouse, int x, int y,
|
2012-08-17 01:21:08 +04:00
|
|
|
browser_pointer_shape *pointer)
|
2012-08-16 18:55:20 +04:00
|
|
|
{
|
2012-08-16 19:14:15 +04:00
|
|
|
struct browser_window *root = browser_window_get_root(bw);
|
|
|
|
int offx, offy;
|
|
|
|
|
|
|
|
browser_window_get_position(bw, true, &offx, &offy);
|
|
|
|
|
|
|
|
return browser_window_resize_frames(root, mouse,
|
|
|
|
x + offx, y + offy, pointer);
|
2012-08-16 18:55:20 +04:00
|
|
|
}
|