1e14391e94c850b8bd03680c23b38978db68687a8John Reck/* 2e14391e94c850b8bd03680c23b38978db68687a8John Reck * Copyright (C) Research In Motion Limited 2010. All rights reserved. 3f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Copyright (C) 2010 Joone Hur <joone@kldp.org> 4f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Copyright (C) 2009 Google Inc. All rights reserved. 52fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * Copyright (C) 2011 Igalia S.L. 6e14391e94c850b8bd03680c23b38978db68687a8John Reck * 7e14391e94c850b8bd03680c23b38978db68687a8John Reck * This library is free software; you can redistribute it and/or 8e14391e94c850b8bd03680c23b38978db68687a8John Reck * modify it under the terms of the GNU Lesser General Public 9e14391e94c850b8bd03680c23b38978db68687a8John Reck * License as published by the Free Software Foundation; either 10e14391e94c850b8bd03680c23b38978db68687a8John Reck * version 2 of the License, or (at your option) any later version. 11e14391e94c850b8bd03680c23b38978db68687a8John Reck * 12e14391e94c850b8bd03680c23b38978db68687a8John Reck * This library is distributed in the hope that it will be useful, 13e14391e94c850b8bd03680c23b38978db68687a8John Reck * but WITHOUT ANY WARRANTY; without even the implied warranty of 14e14391e94c850b8bd03680c23b38978db68687a8John Reck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15e14391e94c850b8bd03680c23b38978db68687a8John Reck * Lesser General Public License for more details. 16e14391e94c850b8bd03680c23b38978db68687a8John Reck * 17e14391e94c850b8bd03680c23b38978db68687a8John Reck * You should have received a copy of the GNU Lesser General Public 18e14391e94c850b8bd03680c23b38978db68687a8John Reck * License along with this library; if not, write to the Free Software 19e14391e94c850b8bd03680c23b38978db68687a8John Reck * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20e14391e94c850b8bd03680c23b38978db68687a8John Reck */ 21e14391e94c850b8bd03680c23b38978db68687a8John Reck 22e14391e94c850b8bd03680c23b38978db68687a8John Reck#include "config.h" 23e14391e94c850b8bd03680c23b38978db68687a8John Reck#include "DumpRenderTreeSupportGtk.h" 24e14391e94c850b8bd03680c23b38978db68687a8John Reck 256b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner#include "APICast.h" 26f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "AXObjectCache.h" 27cad810f21b803229eb11403f9209855525a25d57Steve Block#include "AccessibilityObjectWrapperAtk.h" 28cad810f21b803229eb11403f9209855525a25d57Steve Block#include "AnimationController.h" 29cad810f21b803229eb11403f9209855525a25d57Steve Block#include "DOMWrapperWorld.h" 306b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner#include "Document.h" 312daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch#include "Element.h" 32f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "FocusController.h" 33f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "FrameLoaderClientGtk.h" 34f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "FrameTree.h" 35cad810f21b803229eb11403f9209855525a25d57Steve Block#include "FrameView.h" 36f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "GCController.h" 37f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "GraphicsContext.h" 382bde8e466a4451c7319e3a072d118917957d6554Steve Block#include "HTMLInputElement.h" 392bde8e466a4451c7319e3a072d118917957d6554Steve Block#include "InputElement.h" 40f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "JSDOMWindow.h" 416b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner#include "JSDocument.h" 42f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "JSElement.h" 436b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner#include "JSLock.h" 446b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner#include "JSNodeList.h" 452daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch#include "JSRange.h" 466b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner#include "JSValue.h" 476b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner#include "NodeList.h" 48f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "PageGroup.h" 49f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "PlatformString.h" 50f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "PrintContext.h" 51f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "RenderListItem.h" 52f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "RenderTreeAsText.h" 53cad810f21b803229eb11403f9209855525a25d57Steve Block#include "RenderView.h" 54f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "SecurityOrigin.h" 5581bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch#include "Settings.h" 562fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#include "TextIterator.h" 572daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch#include "WebKitDOMRangePrivate.h" 58f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "WorkerThread.h" 592fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#include "webkitglobalsprivate.h" 60cad810f21b803229eb11403f9209855525a25d57Steve Block#include "webkitwebframe.h" 61f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "webkitwebframeprivate.h" 626b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner#include "webkitwebview.h" 63cad810f21b803229eb11403f9209855525a25d57Steve Block#include "webkitwebviewprivate.h" 64f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include <JavaScriptCore/APICast.h> 65e14391e94c850b8bd03680c23b38978db68687a8John Reck 66cad810f21b803229eb11403f9209855525a25d57Steve Block#if ENABLE(SVG) 6765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#include "SVGDocumentExtensions.h" 68cad810f21b803229eb11403f9209855525a25d57Steve Block#include "SVGSMILElement.h" 69cad810f21b803229eb11403f9209855525a25d57Steve Block#endif 70cad810f21b803229eb11403f9209855525a25d57Steve Block 716b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brennerusing namespace JSC; 72e14391e94c850b8bd03680c23b38978db68687a8John Reckusing namespace WebCore; 73f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochusing namespace WebKit; 74e14391e94c850b8bd03680c23b38978db68687a8John Reck 75e14391e94c850b8bd03680c23b38978db68687a8John Reckbool DumpRenderTreeSupportGtk::s_drtRun = false; 76e14391e94c850b8bd03680c23b38978db68687a8John Reckbool DumpRenderTreeSupportGtk::s_linksIncludedInTabChain = true; 7781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdochbool DumpRenderTreeSupportGtk::s_selectTrailingWhitespaceEnabled = false; 78e14391e94c850b8bd03680c23b38978db68687a8John Reck 79e14391e94c850b8bd03680c23b38978db68687a8John ReckDumpRenderTreeSupportGtk::DumpRenderTreeSupportGtk() 80e14391e94c850b8bd03680c23b38978db68687a8John Reck{ 81e14391e94c850b8bd03680c23b38978db68687a8John Reck} 82e14391e94c850b8bd03680c23b38978db68687a8John Reck 83e14391e94c850b8bd03680c23b38978db68687a8John ReckDumpRenderTreeSupportGtk::~DumpRenderTreeSupportGtk() 84e14391e94c850b8bd03680c23b38978db68687a8John Reck{ 85e14391e94c850b8bd03680c23b38978db68687a8John Reck} 86e14391e94c850b8bd03680c23b38978db68687a8John Reck 87e14391e94c850b8bd03680c23b38978db68687a8John Reckvoid DumpRenderTreeSupportGtk::setDumpRenderTreeModeEnabled(bool enabled) 88e14391e94c850b8bd03680c23b38978db68687a8John Reck{ 89e14391e94c850b8bd03680c23b38978db68687a8John Reck s_drtRun = enabled; 90e14391e94c850b8bd03680c23b38978db68687a8John Reck} 91e14391e94c850b8bd03680c23b38978db68687a8John Reck 92e14391e94c850b8bd03680c23b38978db68687a8John Reckbool DumpRenderTreeSupportGtk::dumpRenderTreeModeEnabled() 93e14391e94c850b8bd03680c23b38978db68687a8John Reck{ 94e14391e94c850b8bd03680c23b38978db68687a8John Reck return s_drtRun; 95e14391e94c850b8bd03680c23b38978db68687a8John Reck} 96e14391e94c850b8bd03680c23b38978db68687a8John Reckvoid DumpRenderTreeSupportGtk::setLinksIncludedInFocusChain(bool enabled) 97e14391e94c850b8bd03680c23b38978db68687a8John Reck{ 98e14391e94c850b8bd03680c23b38978db68687a8John Reck s_linksIncludedInTabChain = enabled; 99e14391e94c850b8bd03680c23b38978db68687a8John Reck} 100e14391e94c850b8bd03680c23b38978db68687a8John Reck 101e14391e94c850b8bd03680c23b38978db68687a8John Reckbool DumpRenderTreeSupportGtk::linksIncludedInFocusChain() 102e14391e94c850b8bd03680c23b38978db68687a8John Reck{ 103e14391e94c850b8bd03680c23b38978db68687a8John Reck return s_linksIncludedInTabChain; 104e14391e94c850b8bd03680c23b38978db68687a8John Reck} 105e14391e94c850b8bd03680c23b38978db68687a8John Reck 10681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdochvoid DumpRenderTreeSupportGtk::setSelectTrailingWhitespaceEnabled(bool enabled) 10781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch{ 10881bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch s_selectTrailingWhitespaceEnabled = enabled; 10981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch} 11081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 11181bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdochbool DumpRenderTreeSupportGtk::selectTrailingWhitespaceEnabled() 11281bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch{ 11381bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch return s_selectTrailingWhitespaceEnabled; 11481bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch} 11581bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 1166b70adc33054f8aee8c54d0f460458a9df11b8a5Russell BrennerJSValueRef DumpRenderTreeSupportGtk::nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping) 1176b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner{ 1186b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner JSLock lock(SilenceAssertionsOnly); 1196b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner ExecState* exec = toJS(context); 1206b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner if (!value) 1216b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner return JSValueMakeUndefined(context); 1226b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner JSValue jsValue = toJS(exec, value); 1236b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner if (!jsValue.inherits(&JSDocument::s_info)) 1246b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner return JSValueMakeUndefined(context); 1256b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner 1266b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner JSDocument* jsDocument = static_cast<JSDocument*>(asObject(jsValue)); 1276b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner Document* document = jsDocument->impl(); 1286b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner RefPtr<NodeList> nodes = document->nodesFromRect(x, y, top, right, bottom, left, ignoreClipping); 1296b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner return toRef(exec, toJS(exec, jsDocument->globalObject(), nodes.get())); 1306b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner} 131f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 1322daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben MurdochWebKitDOMRange* DumpRenderTreeSupportGtk::jsValueToDOMRange(JSContextRef context, JSValueRef value) 1332daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch{ 1342daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch if (!value) 1352daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch return 0; 1362daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 1372daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch JSLock lock(SilenceAssertionsOnly); 1382daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch ExecState* exec = toJS(context); 1392daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 1402daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch Range* range = toRange(toJS(exec, value)); 1412daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch if (!range) 1422daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch return 0; 1432daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch return kit(range); 1442daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch} 1452daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 146f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/** 147f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * getFrameChildren: 148f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @frame: a #WebKitWebFrame 149f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 150f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Return value: child frames of @frame 151f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */ 152f05b935882198ccf7d81675736e3aeb089c5113aBen MurdochGSList* DumpRenderTreeSupportGtk::getFrameChildren(WebKitWebFrame* frame) 153f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 154f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), 0); 155f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 156f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 157f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 158f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return 0; 159f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 160f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch GSList* children = 0; 161f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch for (Frame* child = coreFrame->tree()->firstChild(); child; child = child->tree()->nextSibling()) { 162f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch FrameLoader* loader = child->loader(); 163f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch WebKit::FrameLoaderClient* client = static_cast<WebKit::FrameLoaderClient*>(loader->client()); 164f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (client) 165f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch children = g_slist_append(children, client->webFrame()); 166f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch } 167f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 168f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return children; 169f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 170f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 171f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/** 172f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * getInnerText: 173f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @frame: a #WebKitWebFrame 174f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 175f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Return value: inner text of @frame 176f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */ 177f05b935882198ccf7d81675736e3aeb089c5113aBen MurdochCString DumpRenderTreeSupportGtk::getInnerText(WebKitWebFrame* frame) 178f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 179f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), CString("")); 180f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 181f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 182f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 183f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return CString(""); 184f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 185f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch FrameView* view = coreFrame->view(); 186f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 187f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (view && view->layoutPending()) 188f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch view->layout(); 189f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 190f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Element* documentElement = coreFrame->document()->documentElement(); 191f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return documentElement->innerText().utf8(); 192f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 193f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 194f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/** 195f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * dumpRenderTree: 196f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @frame: a #WebKitWebFrame 197f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 198f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Return value: Non-recursive render tree dump of @frame 199f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */ 200f05b935882198ccf7d81675736e3aeb089c5113aBen MurdochCString DumpRenderTreeSupportGtk::dumpRenderTree(WebKitWebFrame* frame) 201f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 202f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), CString("")); 203f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 204f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 205f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 206f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return CString(""); 207f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 208f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch FrameView* view = coreFrame->view(); 209f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 210f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (view && view->layoutPending()) 211f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch view->layout(); 212f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 213f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return externalRepresentation(coreFrame).utf8(); 214f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 215f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 216f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/** 217f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * counterValueForElementById: 218f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @frame: a #WebKitWebFrame 219f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @id: an element ID string 220f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 221f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Return value: The counter value of element @id in @frame 222f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */ 223f05b935882198ccf7d81675736e3aeb089c5113aBen MurdochCString DumpRenderTreeSupportGtk::counterValueForElementById(WebKitWebFrame* frame, const char* id) 224f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 225f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), CString()); 226f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 227f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 228f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 229f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return CString(); 230f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 231f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Element* coreElement = coreFrame->document()->getElementById(AtomicString(id)); 232f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreElement) 233f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return CString(); 234f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 235f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return counterValueForElement(coreElement).utf8(); 236f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 237f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 238f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/** 239f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * numberForElementById 240f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @frame: a #WebKitWebFrame 241f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @id: an element ID string 242f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @pageWidth: width of a page 243f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @pageHeight: height of a page 244f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 245f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Return value: The number of page where the specified element will be put 246f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */ 247f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochint DumpRenderTreeSupportGtk::pageNumberForElementById(WebKitWebFrame* frame, const char* id, float pageWidth, float pageHeight) 248f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 249f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), 0); 250f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 251f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 252f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 253f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return -1; 254f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 255f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Element* coreElement = coreFrame->document()->getElementById(AtomicString(id)); 256f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreElement) 257f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return -1; 258f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return PrintContext::pageNumberForElement(coreElement, FloatSize(pageWidth, pageHeight)); 259f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 260f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 261f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/** 262f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * numberOfPagesForFrame 263f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @frame: a #WebKitWebFrame 264f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @pageWidth: width of a page 265f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @pageHeight: height of a page 266f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 267f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Return value: The number of pages to be printed. 268f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */ 269f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochint DumpRenderTreeSupportGtk::numberOfPagesForFrame(WebKitWebFrame* frame, float pageWidth, float pageHeight) 270f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 271f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), 0); 272f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 273f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 274f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 275f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return -1; 276f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 277f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return PrintContext::numberOfPages(coreFrame, FloatSize(pageWidth, pageHeight)); 278f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 279f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 280f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/** 281f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * pageProperty 282f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @frame: a #WebKitWebFrame 283f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @propertyName: name of a property 284f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @pageNumber: number of a page 285f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 286f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Return value: The value of the given property name. 287f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */ 288f05b935882198ccf7d81675736e3aeb089c5113aBen MurdochCString DumpRenderTreeSupportGtk::pageProperty(WebKitWebFrame* frame, const char* propertyName, int pageNumber) 289f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 290f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), CString()); 291f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 292f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 293f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 294f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return CString(); 295f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 296f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return PrintContext::pageProperty(coreFrame, propertyName, pageNumber).utf8(); 297f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 298f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 299f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/** 300f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * isPageBoxVisible 301f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @frame: a #WebKitWebFrame 302f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @pageNumber: number of a page 303f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 304f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Return value: TRUE if a page box is visible. 305f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */ 306f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochbool DumpRenderTreeSupportGtk::isPageBoxVisible(WebKitWebFrame* frame, int pageNumber) 307f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 308f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), false); 309f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 310f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 311f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 312f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return false; 313f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 314f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return coreFrame->document()->isPageBoxVisible(pageNumber); 315f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 316f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 317f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/** 318f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * pageSizeAndMarginsInPixels 319f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @frame: a #WebKitWebFrame 320f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @pageNumber: number of a page 321f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @width: width of a page 322f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @height: height of a page 323f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @marginTop: top margin of a page 324f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @marginRight: right margin of a page 325f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @marginBottom: bottom margin of a page 326f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @marginLeft: left margin of a page 327f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 328f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Return value: The value of page size and margin. 329f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */ 330f05b935882198ccf7d81675736e3aeb089c5113aBen MurdochCString DumpRenderTreeSupportGtk::pageSizeAndMarginsInPixels(WebKitWebFrame* frame, int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) 331f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 332f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), CString()); 333f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 334f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 335f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 336f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return CString(); 337f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 338f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return PrintContext::pageSizeAndMarginsInPixels(coreFrame, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).utf8(); 339f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 340f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 341f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/** 342f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * addUserStyleSheet 343f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @frame: a #WebKitWebFrame 344f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @sourceCode: code of a user stylesheet 345f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 346f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */ 347f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochvoid DumpRenderTreeSupportGtk::addUserStyleSheet(WebKitWebFrame* frame, const char* sourceCode, bool allFrames) 348f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 349f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); 350f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 351f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 352f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 353f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return; 354f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 355f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch WebKitWebView* webView = getViewFromFrame(frame); 356f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Page* page = core(webView); 357f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch page->group().addUserStyleSheetToWorld(mainThreadNormalWorld(), sourceCode, KURL(), 0, 0, allFrames ? InjectInAllFrames : InjectInTopFrameOnly); 358f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 359f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 360f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/** 361f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * getPendingUnloadEventCount: 362f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * @frame: a #WebKitWebFrame 363f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 364f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Return value: number of pending unload events 365f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */ 366f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochguint DumpRenderTreeSupportGtk::getPendingUnloadEventCount(WebKitWebFrame* frame) 367f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 368f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), 0); 369f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 370f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return core(frame)->domWindow()->pendingUnloadEventListeners(); 371f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 372f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 373f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochbool DumpRenderTreeSupportGtk::pauseAnimation(WebKitWebFrame* frame, const char* name, double time, const char* element) 374f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 375f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ASSERT(core(frame)); 376f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Element* coreElement = core(frame)->document()->getElementById(AtomicString(element)); 377f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreElement || !coreElement->renderer()) 378f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return false; 379f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return core(frame)->animation()->pauseAnimationAtTime(coreElement->renderer(), AtomicString(name), time); 380f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 381f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 382f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochbool DumpRenderTreeSupportGtk::pauseTransition(WebKitWebFrame* frame, const char* name, double time, const char* element) 383f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 384f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ASSERT(core(frame)); 385f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Element* coreElement = core(frame)->document()->getElementById(AtomicString(element)); 386f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreElement || !coreElement->renderer()) 387f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return false; 388f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return core(frame)->animation()->pauseTransitionAtTime(coreElement->renderer(), AtomicString(name), time); 389f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 390f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 391f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochbool DumpRenderTreeSupportGtk::pauseSVGAnimation(WebKitWebFrame* frame, const char* animationId, double time, const char* elementId) 392f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 393f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ASSERT(core(frame)); 394f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#if ENABLE(SVG) 395f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Document* document = core(frame)->document(); 396f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!document || !document->svgExtensions()) 397f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return false; 398f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Element* coreElement = document->getElementById(AtomicString(animationId)); 399f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreElement || !SVGSMILElement::isSMILElement(coreElement)) 400f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return false; 401f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return document->accessSVGExtensions()->sampleAnimationAtTime(elementId, static_cast<SVGSMILElement*>(coreElement), time); 402f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#else 403f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return false; 404f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#endif 405f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 406f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 407f05b935882198ccf7d81675736e3aeb089c5113aBen MurdochCString DumpRenderTreeSupportGtk::markerTextForListItem(WebKitWebFrame* frame, JSContextRef context, JSValueRef nodeObject) 408f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 409f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch JSC::ExecState* exec = toJS(context); 410f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Element* element = toElement(toJS(exec, nodeObject)); 411f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!element) 412f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return CString(); 413f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 414f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return WebCore::markerTextForListItem(element).utf8(); 415f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 416f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 417f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochunsigned int DumpRenderTreeSupportGtk::numberOfActiveAnimations(WebKitWebFrame* frame) 418f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 419f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 420f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 421f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return 0; 422f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 423f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return coreFrame->animation()->numberOfActiveAnimations(); 424f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 425f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 426f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochvoid DumpRenderTreeSupportGtk::suspendAnimations(WebKitWebFrame* frame) 427f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 428f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 429f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 430f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return; 431f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 432f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return coreFrame->animation()->suspendAnimations(); 433f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 434f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 435f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochvoid DumpRenderTreeSupportGtk::resumeAnimations(WebKitWebFrame* frame) 436f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 437f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 438f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 439f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return; 440f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 441f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return coreFrame->animation()->resumeAnimations(); 442f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 443f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 444f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochvoid DumpRenderTreeSupportGtk::clearMainFrameName(WebKitWebFrame* frame) 445f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 446f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); 447f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 448f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch core(frame)->tree()->clearName(); 449f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 450f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 451cad810f21b803229eb11403f9209855525a25d57Steve BlockAtkObject* DumpRenderTreeSupportGtk::getRootAccessibleElement(WebKitWebFrame* frame) 452f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 453f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), 0); 454f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 455f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#if HAVE(ACCESSIBILITY) 456f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!AXObjectCache::accessibilityEnabled()) 457f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch AXObjectCache::enableAccessibility(); 458f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 459f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch WebKitWebFramePrivate* priv = frame->priv; 460f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!priv->coreFrame || !priv->coreFrame->document()) 461f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return 0; 462f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 463cad810f21b803229eb11403f9209855525a25d57Steve Block AtkObject* wrapper = priv->coreFrame->document()->axObjectCache()->rootObject()->wrapper(); 464cad810f21b803229eb11403f9209855525a25d57Steve Block if (!wrapper) 465f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return 0; 466f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 467cad810f21b803229eb11403f9209855525a25d57Steve Block return wrapper; 468cad810f21b803229eb11403f9209855525a25d57Steve Block#else 469cad810f21b803229eb11403f9209855525a25d57Steve Block return 0; 470cad810f21b803229eb11403f9209855525a25d57Steve Block#endif 471cad810f21b803229eb11403f9209855525a25d57Steve Block} 472cad810f21b803229eb11403f9209855525a25d57Steve Block 473cad810f21b803229eb11403f9209855525a25d57Steve BlockAtkObject* DumpRenderTreeSupportGtk::getFocusedAccessibleElement(WebKitWebFrame* frame) 474cad810f21b803229eb11403f9209855525a25d57Steve Block{ 475cad810f21b803229eb11403f9209855525a25d57Steve Block#if HAVE(ACCESSIBILITY) 476cad810f21b803229eb11403f9209855525a25d57Steve Block AtkObject* wrapper = getRootAccessibleElement(frame); 477f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!wrapper) 478f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return 0; 479f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 480f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return webkit_accessible_get_focused_element(WEBKIT_ACCESSIBLE(wrapper)); 481f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#else 482f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return 0; 483f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#endif 484f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 485f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 486f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochvoid DumpRenderTreeSupportGtk::executeCoreCommandByName(WebKitWebView* webView, const gchar* name, const gchar* value) 487f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 488f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 489f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_if_fail(name); 490f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_if_fail(value); 491f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 492f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch core(webView)->focusController()->focusedOrMainFrame()->editor()->command(name).execute(value); 493f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 494f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 495f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochbool DumpRenderTreeSupportGtk::isCommandEnabled(WebKitWebView* webView, const gchar* name) 496f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 497f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 498f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(name, FALSE); 499f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 500f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return core(webView)->focusController()->focusedOrMainFrame()->editor()->command(name).isEnabled(); 501f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 502f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 5032fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockvoid DumpRenderTreeSupportGtk::setComposition(WebKitWebView* webView, const char* text, int start, int end) 5042fc2651226baac27029e38c9d6ef883fa32084dbSteve Block{ 5052fc2651226baac27029e38c9d6ef883fa32084dbSteve Block g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 5062fc2651226baac27029e38c9d6ef883fa32084dbSteve Block g_return_if_fail(text); 5072fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5082fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 5092fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (!frame) 5102fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return; 5112fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5122fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Editor* editor = frame->editor(); 5132fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (!editor) 5142fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return; 5152fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (!editor->canEdit() && !editor->hasComposition()) 5162fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return; 5172fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5182fc2651226baac27029e38c9d6ef883fa32084dbSteve Block String compositionString = String::fromUTF8(text); 5192fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Vector<CompositionUnderline> underlines; 5202fc2651226baac27029e38c9d6ef883fa32084dbSteve Block underlines.append(CompositionUnderline(0, compositionString.length(), Color(0, 0, 0), false)); 5212fc2651226baac27029e38c9d6ef883fa32084dbSteve Block editor->setComposition(compositionString, underlines, start, end); 5222fc2651226baac27029e38c9d6ef883fa32084dbSteve Block} 5232fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5242fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockvoid DumpRenderTreeSupportGtk::confirmComposition(WebKitWebView* webView, const char* text) 5252fc2651226baac27029e38c9d6ef883fa32084dbSteve Block{ 5262fc2651226baac27029e38c9d6ef883fa32084dbSteve Block g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 5272fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5282fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 5292fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (!frame) 5302fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return; 5312fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5322fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Editor* editor = frame->editor(); 5332fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (!editor || (!editor->hasComposition() && !text)) 5342fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return; 5352fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5362fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (editor->hasComposition()) { 5372fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (text) 5382fc2651226baac27029e38c9d6ef883fa32084dbSteve Block editor->confirmComposition(String::fromUTF8(text)); 5392fc2651226baac27029e38c9d6ef883fa32084dbSteve Block else 5402fc2651226baac27029e38c9d6ef883fa32084dbSteve Block editor->confirmComposition(); 5412fc2651226baac27029e38c9d6ef883fa32084dbSteve Block } else 5422fc2651226baac27029e38c9d6ef883fa32084dbSteve Block editor->insertText(String::fromUTF8(text), 0); 5432fc2651226baac27029e38c9d6ef883fa32084dbSteve Block} 5442fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5452fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockbool DumpRenderTreeSupportGtk::firstRectForCharacterRange(WebKitWebView* webView, int location, int length, GdkRectangle* rect) 5462fc2651226baac27029e38c9d6ef883fa32084dbSteve Block{ 5472fc2651226baac27029e38c9d6ef883fa32084dbSteve Block g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false); 5482fc2651226baac27029e38c9d6ef883fa32084dbSteve Block g_return_val_if_fail(rect, false); 5492fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5502fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if ((location + length < location) && (location + length)) 5512fc2651226baac27029e38c9d6ef883fa32084dbSteve Block length = 0; 5522fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5532fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 5542fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (!frame) 5552fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return false; 5562fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5572fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Editor* editor = frame->editor(); 5582fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (!editor) 5592fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return false; 5602fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5612fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Element* selectionRoot = frame->selection()->rootEditableElement(); 5622fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement(); 5632fc2651226baac27029e38c9d6ef883fa32084dbSteve Block RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(scope, location, length); 5642fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (!range) 5652fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return false; 5662fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5672fc2651226baac27029e38c9d6ef883fa32084dbSteve Block *rect = editor->firstRectForRange(range.get()); 5682fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5692fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return true; 5702fc2651226baac27029e38c9d6ef883fa32084dbSteve Block} 5712fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5722fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockbool DumpRenderTreeSupportGtk::selectedRange(WebKitWebView* webView, int* start, int* end) 5732fc2651226baac27029e38c9d6ef883fa32084dbSteve Block{ 5742fc2651226baac27029e38c9d6ef883fa32084dbSteve Block g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false); 5752fc2651226baac27029e38c9d6ef883fa32084dbSteve Block g_return_val_if_fail(start, false); 5762fc2651226baac27029e38c9d6ef883fa32084dbSteve Block g_return_val_if_fail(end, false); 5772fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5782fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 5792fc2651226baac27029e38c9d6ef883fa32084dbSteve Block if (!frame) 5802fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return false; 5812fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5822fc2651226baac27029e38c9d6ef883fa32084dbSteve Block RefPtr<Range> range = frame->selection()->toNormalizedRange().get(); 5832fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5842fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Element* selectionRoot = frame->selection()->rootEditableElement(); 5852fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement(); 5862fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5872fc2651226baac27029e38c9d6ef883fa32084dbSteve Block RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset()); 5882fc2651226baac27029e38c9d6ef883fa32084dbSteve Block ASSERT(testRange->startContainer() == scope); 5892fc2651226baac27029e38c9d6ef883fa32084dbSteve Block *start = TextIterator::rangeLength(testRange.get()); 5902fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5912fc2651226baac27029e38c9d6ef883fa32084dbSteve Block ExceptionCode ec; 5922fc2651226baac27029e38c9d6ef883fa32084dbSteve Block testRange->setEnd(range->endContainer(), range->endOffset(), ec); 5932fc2651226baac27029e38c9d6ef883fa32084dbSteve Block ASSERT(testRange->startContainer() == scope); 5942fc2651226baac27029e38c9d6ef883fa32084dbSteve Block *end = TextIterator::rangeLength(testRange.get()); 5952fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 5962fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return true; 5972fc2651226baac27029e38c9d6ef883fa32084dbSteve Block} 5982fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 599f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochvoid DumpRenderTreeSupportGtk::whiteListAccessFromOrigin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains) 600f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 601f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch SecurityOrigin::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); 602f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 603f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 604f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochvoid DumpRenderTreeSupportGtk::resetOriginAccessWhiteLists() 605f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 606f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch SecurityOrigin::resetOriginAccessWhitelists(); 607f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 608f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 609f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochvoid DumpRenderTreeSupportGtk::gcCollectJavascriptObjects() 610f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 611f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch gcController().garbageCollectNow(); 612f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 613f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 614f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochvoid DumpRenderTreeSupportGtk::gcCollectJavascriptObjectsOnAlternateThread(bool waitUntilDone) 615f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 616f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone); 617f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 618f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 619f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochunsigned long DumpRenderTreeSupportGtk::gcCountJavascriptObjects() 620f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 621f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch JSC::JSLock lock(JSC::SilenceAssertionsOnly); 622f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return JSDOMWindow::commonJSGlobalData()->heap.objectCount(); 623f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 624f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 625f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochvoid DumpRenderTreeSupportGtk::layoutFrame(WebKitWebFrame* frame) 626f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 627f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch Frame* coreFrame = core(frame); 628f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!coreFrame) 629f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return; 630f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 631f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch FrameView* view = coreFrame->view(); 632f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (!view) 633f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return; 634f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 635f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch view->layout(); 636f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 637f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 638f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch// For testing fast/viewport. 63981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdochvoid DumpRenderTreeSupportGtk::dumpConfigurationForViewport(WebKitWebView* webView, gint deviceDPI, gint deviceWidth, gint deviceHeight, gint availableWidth, gint availableHeight) 640f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 641f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 642f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 643f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch ViewportArguments arguments = webView->priv->corePage->mainFrame()->document()->viewportArguments(); 64481bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch ViewportAttributes attrs = computeViewportAttributes(arguments, /* default layout width for non-mobile pages */ 980, deviceWidth, deviceHeight, deviceDPI, IntSize(availableWidth, availableHeight)); 645f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 6462bde8e466a4451c7319e3a072d118917957d6554Steve Block fprintf(stdout, "viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n", attrs.layoutSize.width(), attrs.layoutSize.height(), attrs.initialScale, attrs.minimumScale, attrs.maximumScale, attrs.userScalable); 647f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 648f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 64981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdochvoid DumpRenderTreeSupportGtk::clearOpener(WebKitWebFrame* frame) 65081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch{ 65181bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch Frame* coreFrame = core(frame); 65281bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch if (coreFrame) 65381bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch coreFrame->loader()->setOpener(0); 65481bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch} 65581bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 6562daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben MurdochJSValueRef DumpRenderTreeSupportGtk::shadowRoot(JSContextRef context, JSValueRef value) 6572daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch{ 6582daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch JSLock lock(SilenceAssertionsOnly); 6592daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch JSC::ExecState* exec = toJS(context); 6602daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch Element* element = toElement(toJS(exec, value)); 6612daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch if (!element) 6622daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch return JSValueMakeNull(context); 6632daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 6642daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch return toRef(exec, toJS(exec, element->shadowRoot())); 6652daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch} 6662daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 667f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochunsigned int DumpRenderTreeSupportGtk::workerThreadCount() 668f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 669f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#if ENABLE(WORKERS) 670f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return WebCore::WorkerThread::workerThreadCount(); 671f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#else 672f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return 0; 673f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#endif 674f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 675f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 676f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochbool DumpRenderTreeSupportGtk::webkitWebFrameSelectionHasSpellingMarker(WebKitWebFrame *frame, gint from, gint length) 677f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 678f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), FALSE); 679f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 6802bde8e466a4451c7319e3a072d118917957d6554Steve Block return core(frame)->editor()->selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); 681f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 6822fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 6832fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockbool DumpRenderTreeSupportGtk::findString(WebKitWebView* webView, const gchar* targetString, WebKitFindOptions findOptions) 6842fc2651226baac27029e38c9d6ef883fa32084dbSteve Block{ 6852fc2651226baac27029e38c9d6ef883fa32084dbSteve Block return core(webView)->findString(String::fromUTF8(targetString), findOptions); 6862fc2651226baac27029e38c9d6ef883fa32084dbSteve Block} 6872fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 68881bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdochdouble DumpRenderTreeSupportGtk::defaultMinimumTimerInterval() 68981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch{ 69081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch return Settings::defaultMinDOMTimerInterval(); 69181bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch} 69281bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 69381bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdochvoid DumpRenderTreeSupportGtk::setMinimumTimerInterval(WebKitWebView* webView, double interval) 69481bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch{ 69581bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch core(webView)->settings()->setMinDOMTimerInterval(interval); 69681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch} 6972bde8e466a4451c7319e3a072d118917957d6554Steve Block 6982daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdochstatic void modifyAccessibilityValue(AtkObject* axObject, bool increment) 6992daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch{ 7002daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch if (!axObject || !WEBKIT_IS_ACCESSIBLE(axObject)) 7012daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch return; 7022daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 7032daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch AccessibilityObject* coreObject = webkit_accessible_get_accessibility_object(WEBKIT_ACCESSIBLE(axObject)); 7042daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch if (!coreObject) 7052daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch return; 7062daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 7072daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch if (increment) 7082daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch coreObject->increment(); 7092daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch else 7102daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch coreObject->decrement(); 7112daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch} 7122daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 7132daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdochvoid DumpRenderTreeSupportGtk::incrementAccessibilityValue(AtkObject* axObject) 7142daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch{ 7152daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch modifyAccessibilityValue(axObject, true); 7162daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch} 7172daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 7182daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdochvoid DumpRenderTreeSupportGtk::decrementAccessibilityValue(AtkObject* axObject) 7192daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch{ 7202daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch modifyAccessibilityValue(axObject, false); 7212daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch} 7222daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 7232bde8e466a4451c7319e3a072d118917957d6554Steve Blockvoid DumpRenderTreeSupportGtk::setAutofilled(JSContextRef context, JSValueRef nodeObject, bool autofilled) 7242bde8e466a4451c7319e3a072d118917957d6554Steve Block{ 7252bde8e466a4451c7319e3a072d118917957d6554Steve Block JSC::ExecState* exec = toJS(context); 7262bde8e466a4451c7319e3a072d118917957d6554Steve Block Element* element = toElement(toJS(exec, nodeObject)); 7272bde8e466a4451c7319e3a072d118917957d6554Steve Block if (!element) 7282bde8e466a4451c7319e3a072d118917957d6554Steve Block return; 7292bde8e466a4451c7319e3a072d118917957d6554Steve Block InputElement* inputElement = element->toInputElement(); 7302bde8e466a4451c7319e3a072d118917957d6554Steve Block if (!inputElement) 7312bde8e466a4451c7319e3a072d118917957d6554Steve Block return; 7322bde8e466a4451c7319e3a072d118917957d6554Steve Block 7332bde8e466a4451c7319e3a072d118917957d6554Steve Block static_cast<HTMLInputElement*>(inputElement)->setAutofilled(autofilled); 7342bde8e466a4451c7319e3a072d118917957d6554Steve Block} 7352bde8e466a4451c7319e3a072d118917957d6554Steve Block 7362bde8e466a4451c7319e3a072d118917957d6554Steve Blockvoid DumpRenderTreeSupportGtk::setValueForUser(JSContextRef context, JSValueRef nodeObject, JSStringRef value) 7372bde8e466a4451c7319e3a072d118917957d6554Steve Block{ 7382bde8e466a4451c7319e3a072d118917957d6554Steve Block JSC::ExecState* exec = toJS(context); 7392bde8e466a4451c7319e3a072d118917957d6554Steve Block Element* element = toElement(toJS(exec, nodeObject)); 7402bde8e466a4451c7319e3a072d118917957d6554Steve Block if (!element) 7412bde8e466a4451c7319e3a072d118917957d6554Steve Block return; 7422bde8e466a4451c7319e3a072d118917957d6554Steve Block InputElement* inputElement = element->toInputElement(); 7432bde8e466a4451c7319e3a072d118917957d6554Steve Block if (!inputElement) 7442bde8e466a4451c7319e3a072d118917957d6554Steve Block return; 7452bde8e466a4451c7319e3a072d118917957d6554Steve Block 7462bde8e466a4451c7319e3a072d118917957d6554Steve Block size_t bufferSize = JSStringGetMaximumUTF8CStringSize(value); 7472bde8e466a4451c7319e3a072d118917957d6554Steve Block GOwnPtr<gchar> valueBuffer(static_cast<gchar*>(g_malloc(bufferSize))); 7482bde8e466a4451c7319e3a072d118917957d6554Steve Block JSStringGetUTF8CString(value, valueBuffer.get(), bufferSize); 7492bde8e466a4451c7319e3a072d118917957d6554Steve Block inputElement->setValueForUser(String::fromUTF8(valueBuffer.get())); 7502bde8e466a4451c7319e3a072d118917957d6554Steve Block} 7512daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 7522daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdochvoid DumpRenderTreeSupportGtk::rectangleForSelection(WebKitWebFrame* frame, GdkRectangle* rectangle) 7532daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch{ 7542daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch Frame* coreFrame = core(frame); 7552daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch if (!coreFrame) 7562daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch return; 7572daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch 7582daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch IntRect bounds = enclosingIntRect(coreFrame->selection()->bounds()); 7592daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch rectangle->x = bounds.x(); 7602daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch rectangle->y = bounds.y(); 7612daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch rectangle->width = bounds.width(); 7622daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch rectangle->height = bounds.height(); 7632daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch} 764