OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // | 59 // |
60 // When frame content is replaced, all subframes are destroyed. This happens | 60 // When frame content is replaced, all subframes are destroyed. This happens |
61 // in FrameLoader::detachFromParent for each subframe in a pre-order depth-first | 61 // in FrameLoader::detachFromParent for each subframe in a pre-order depth-first |
62 // traversal. Note that child node order may not match DOM node order! | 62 // traversal. Note that child node order may not match DOM node order! |
63 // detachFromParent() calls FrameLoaderClient::detachedFromParent(), which calls | 63 // detachFromParent() calls FrameLoaderClient::detachedFromParent(), which calls |
64 // WebFrame::frameDetached(). This triggers WebFrame to clear its reference to | 64 // WebFrame::frameDetached(). This triggers WebFrame to clear its reference to |
65 // LocalFrame, and also notifies the embedder via WebFrameClient that the frame
is | 65 // LocalFrame, and also notifies the embedder via WebFrameClient that the frame
is |
66 // detached. Most embedders will invoke close() on the WebFrame at this point, | 66 // detached. Most embedders will invoke close() on the WebFrame at this point, |
67 // triggering its deletion unless something else is still retaining a reference. | 67 // triggering its deletion unless something else is still retaining a reference. |
68 // | 68 // |
69 // Thie client is expected to be set whenever the WebFrameImpl is attached to | 69 // Thie client is expected to be set whenever the WebLocalFrameImpl is attached
to |
70 // the DOM. | 70 // the DOM. |
71 | 71 |
72 #include "config.h" | 72 #include "config.h" |
73 #include "WebFrameImpl.h" | 73 #include "WebLocalFrameImpl.h" |
74 | 74 |
75 #include <algorithm> | |
76 #include "AssociatedURLLoader.h" | 75 #include "AssociatedURLLoader.h" |
77 #include "CompositionUnderlineVectorBuilder.h" | 76 #include "CompositionUnderlineVectorBuilder.h" |
78 #include "EventListenerWrapper.h" | 77 #include "EventListenerWrapper.h" |
79 #include "FindInPageCoordinates.h" | 78 #include "FindInPageCoordinates.h" |
80 #include "HTMLNames.h" | 79 #include "HTMLNames.h" |
81 #include "PageOverlay.h" | 80 #include "PageOverlay.h" |
82 #include "SharedWorkerRepositoryClientImpl.h" | 81 #include "SharedWorkerRepositoryClientImpl.h" |
83 #include "TextFinder.h" | 82 #include "TextFinder.h" |
84 #include "WebConsoleMessage.h" | 83 #include "WebConsoleMessage.h" |
85 #include "WebDOMEvent.h" | 84 #include "WebDOMEvent.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 #include "core/editing/InputMethodController.h" | 123 #include "core/editing/InputMethodController.h" |
125 #include "core/editing/PlainTextRange.h" | 124 #include "core/editing/PlainTextRange.h" |
126 #include "core/editing/SpellChecker.h" | 125 #include "core/editing/SpellChecker.h" |
127 #include "core/editing/TextAffinity.h" | 126 #include "core/editing/TextAffinity.h" |
128 #include "core/editing/TextIterator.h" | 127 #include "core/editing/TextIterator.h" |
129 #include "core/editing/htmlediting.h" | 128 #include "core/editing/htmlediting.h" |
130 #include "core/editing/markup.h" | 129 #include "core/editing/markup.h" |
131 #include "core/frame/Console.h" | 130 #include "core/frame/Console.h" |
132 #include "core/frame/DOMWindow.h" | 131 #include "core/frame/DOMWindow.h" |
133 #include "core/frame/FrameView.h" | 132 #include "core/frame/FrameView.h" |
| 133 #include "core/frame/Settings.h" |
134 #include "core/html/HTMLCollection.h" | 134 #include "core/html/HTMLCollection.h" |
135 #include "core/html/HTMLFormElement.h" | 135 #include "core/html/HTMLFormElement.h" |
136 #include "core/html/HTMLFrameElementBase.h" | 136 #include "core/html/HTMLFrameElementBase.h" |
137 #include "core/html/HTMLFrameOwnerElement.h" | 137 #include "core/html/HTMLFrameOwnerElement.h" |
138 #include "core/html/HTMLHeadElement.h" | 138 #include "core/html/HTMLHeadElement.h" |
139 #include "core/html/HTMLInputElement.h" | 139 #include "core/html/HTMLInputElement.h" |
140 #include "core/html/HTMLLinkElement.h" | 140 #include "core/html/HTMLLinkElement.h" |
141 #include "core/html/PluginDocument.h" | 141 #include "core/html/PluginDocument.h" |
142 #include "core/inspector/InspectorController.h" | 142 #include "core/inspector/InspectorController.h" |
143 #include "core/inspector/ScriptCallStack.h" | 143 #include "core/inspector/ScriptCallStack.h" |
144 #include "core/loader/DocumentLoader.h" | 144 #include "core/loader/DocumentLoader.h" |
145 #include "core/loader/FrameLoadRequest.h" | 145 #include "core/loader/FrameLoadRequest.h" |
146 #include "core/loader/FrameLoader.h" | 146 #include "core/loader/FrameLoader.h" |
147 #include "core/loader/HistoryItem.h" | 147 #include "core/loader/HistoryItem.h" |
148 #include "core/loader/SubstituteData.h" | 148 #include "core/loader/SubstituteData.h" |
149 #include "core/page/Chrome.h" | 149 #include "core/page/Chrome.h" |
150 #include "core/page/EventHandler.h" | 150 #include "core/page/EventHandler.h" |
151 #include "core/page/FocusController.h" | 151 #include "core/page/FocusController.h" |
152 #include "core/page/FrameTree.h" | 152 #include "core/page/FrameTree.h" |
153 #include "core/page/Page.h" | 153 #include "core/page/Page.h" |
154 #include "core/page/PrintContext.h" | 154 #include "core/page/PrintContext.h" |
155 #include "core/frame/Settings.h" | |
156 #include "core/rendering/HitTestResult.h" | 155 #include "core/rendering/HitTestResult.h" |
157 #include "core/rendering/RenderBox.h" | 156 #include "core/rendering/RenderBox.h" |
158 #include "core/rendering/RenderFrame.h" | 157 #include "core/rendering/RenderFrame.h" |
159 #include "core/rendering/RenderLayer.h" | 158 #include "core/rendering/RenderLayer.h" |
160 #include "core/rendering/RenderObject.h" | 159 #include "core/rendering/RenderObject.h" |
161 #include "core/rendering/RenderTreeAsText.h" | 160 #include "core/rendering/RenderTreeAsText.h" |
162 #include "core/rendering/RenderView.h" | 161 #include "core/rendering/RenderView.h" |
163 #include "core/rendering/style/StyleInheritedData.h" | 162 #include "core/rendering/style/StyleInheritedData.h" |
164 #include "core/timing/Performance.h" | 163 #include "core/timing/Performance.h" |
165 #include "modules/notifications/NotificationController.h" | 164 #include "modules/notifications/NotificationController.h" |
166 #include "platform/TraceEvent.h" | 165 #include "platform/TraceEvent.h" |
167 #include "platform/UserGestureIndicator.h" | 166 #include "platform/UserGestureIndicator.h" |
168 #include "platform/clipboard/ClipboardUtilities.h" | 167 #include "platform/clipboard/ClipboardUtilities.h" |
169 #include "platform/fonts/FontCache.h" | 168 #include "platform/fonts/FontCache.h" |
170 #include "platform/graphics/GraphicsContext.h" | 169 #include "platform/graphics/GraphicsContext.h" |
171 #include "platform/graphics/GraphicsLayerClient.h" | 170 #include "platform/graphics/GraphicsLayerClient.h" |
172 #include "platform/graphics/skia/SkiaUtils.h" | 171 #include "platform/graphics/skia/SkiaUtils.h" |
173 #include "platform/heap/Handle.h" | 172 #include "platform/heap/Handle.h" |
174 #include "platform/network/ResourceRequest.h" | 173 #include "platform/network/ResourceRequest.h" |
| 174 #include "platform/scroll/ScrollTypes.h" |
175 #include "platform/scroll/ScrollbarTheme.h" | 175 #include "platform/scroll/ScrollbarTheme.h" |
176 #include "platform/scroll/ScrollTypes.h" | |
177 #include "platform/weborigin/KURL.h" | 176 #include "platform/weborigin/KURL.h" |
178 #include "platform/weborigin/SchemeRegistry.h" | 177 #include "platform/weborigin/SchemeRegistry.h" |
179 #include "platform/weborigin/SecurityPolicy.h" | 178 #include "platform/weborigin/SecurityPolicy.h" |
180 #include "public/platform/Platform.h" | 179 #include "public/platform/Platform.h" |
181 #include "public/platform/WebFloatPoint.h" | 180 #include "public/platform/WebFloatPoint.h" |
182 #include "public/platform/WebFloatRect.h" | 181 #include "public/platform/WebFloatRect.h" |
183 #include "public/platform/WebLayer.h" | 182 #include "public/platform/WebLayer.h" |
184 #include "public/platform/WebPoint.h" | 183 #include "public/platform/WebPoint.h" |
185 #include "public/platform/WebRect.h" | 184 #include "public/platform/WebRect.h" |
186 #include "public/platform/WebSize.h" | 185 #include "public/platform/WebSize.h" |
187 #include "public/platform/WebURLError.h" | 186 #include "public/platform/WebURLError.h" |
188 #include "public/platform/WebVector.h" | 187 #include "public/platform/WebVector.h" |
189 #include "wtf/CurrentTime.h" | 188 #include "wtf/CurrentTime.h" |
190 #include "wtf/HashMap.h" | 189 #include "wtf/HashMap.h" |
| 190 #include <algorithm> |
191 | 191 |
192 using namespace WebCore; | 192 using namespace WebCore; |
193 | 193 |
194 namespace blink { | 194 namespace blink { |
195 | 195 |
196 static int frameCount = 0; | 196 static int frameCount = 0; |
197 | 197 |
198 // Key for a StatsCounter tracking how many WebFrames are active. | 198 // Key for a StatsCounter tracking how many WebFrames are active. |
199 static const char webFrameActiveCount[] = "WebFrameActiveCount"; | 199 static const char webFrameActiveCount[] = "WebFrameActiveCount"; |
200 | 200 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 if (output.length() >= maxChars - frameSeparatorLength) | 252 if (output.length() >= maxChars - frameSeparatorLength) |
253 return; | 253 return; |
254 | 254 |
255 output.append(frameSeparator, frameSeparatorLength); | 255 output.append(frameSeparator, frameSeparatorLength); |
256 frameContentAsPlainText(maxChars, curChild, output); | 256 frameContentAsPlainText(maxChars, curChild, output); |
257 if (output.length() >= maxChars) | 257 if (output.length() >= maxChars) |
258 return; // Filled up the buffer. | 258 return; // Filled up the buffer. |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 WebPluginContainerImpl* WebFrameImpl::pluginContainerFromFrame(LocalFrame* frame
) | 262 WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromFrame(LocalFrame*
frame) |
263 { | 263 { |
264 if (!frame) | 264 if (!frame) |
265 return 0; | 265 return 0; |
266 if (!frame->document() || !frame->document()->isPluginDocument()) | 266 if (!frame->document() || !frame->document()->isPluginDocument()) |
267 return 0; | 267 return 0; |
268 PluginDocument* pluginDocument = toPluginDocument(frame->document()); | 268 PluginDocument* pluginDocument = toPluginDocument(frame->document()); |
269 return toWebPluginContainerImpl(pluginDocument->pluginWidget()); | 269 return toWebPluginContainerImpl(pluginDocument->pluginWidget()); |
270 } | 270 } |
271 | 271 |
272 WebPluginContainerImpl* WebFrameImpl::pluginContainerFromNode(WebCore::LocalFram
e* frame, const WebNode& node) | 272 WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromNode(WebCore::Loca
lFrame* frame, const WebNode& node) |
273 { | 273 { |
274 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame); | 274 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame); |
275 if (pluginContainer) | 275 if (pluginContainer) |
276 return pluginContainer; | 276 return pluginContainer; |
277 return toWebPluginContainerImpl(node.pluginContainer()); | 277 return toWebPluginContainerImpl(node.pluginContainer()); |
278 } | 278 } |
279 | 279 |
280 // Simple class to override some of PrintContext behavior. Some of the methods | 280 // Simple class to override some of PrintContext behavior. Some of the methods |
281 // made virtual so that they can be overridden by ChromePluginPrintContext. | 281 // made virtual so that they can be overridden by ChromePluginPrintContext. |
282 class ChromePrintContext : public PrintContext { | 282 class ChromePrintContext : public PrintContext { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 WebLocalFrame* WebLocalFrame::frameForCurrentContext() | 461 WebLocalFrame* WebLocalFrame::frameForCurrentContext() |
462 { | 462 { |
463 v8::Handle<v8::Context> context = v8::Isolate::GetCurrent()->GetCurrentConte
xt(); | 463 v8::Handle<v8::Context> context = v8::Isolate::GetCurrent()->GetCurrentConte
xt(); |
464 if (context.IsEmpty()) | 464 if (context.IsEmpty()) |
465 return 0; | 465 return 0; |
466 return frameForContext(context); | 466 return frameForContext(context); |
467 } | 467 } |
468 | 468 |
469 WebLocalFrame* WebLocalFrame::frameForContext(v8::Handle<v8::Context> context) | 469 WebLocalFrame* WebLocalFrame::frameForContext(v8::Handle<v8::Context> context) |
470 { | 470 { |
471 return WebFrameImpl::fromFrame(toFrameIfNotDetached(context)); | 471 return WebLocalFrameImpl::fromFrame(toFrameIfNotDetached(context)); |
472 } | 472 } |
473 | 473 |
474 WebLocalFrame* WebLocalFrame::fromFrameOwnerElement(const WebElement& element) | 474 WebLocalFrame* WebLocalFrame::fromFrameOwnerElement(const WebElement& element) |
475 { | 475 { |
476 return WebFrameImpl::fromFrameOwnerElement(PassRefPtr<Element>(element).get(
)); | 476 return WebLocalFrameImpl::fromFrameOwnerElement(PassRefPtr<Element>(element)
.get()); |
477 } | 477 } |
478 | 478 |
479 void WebFrameImpl::close() | 479 bool WebLocalFrameImpl::isWebLocalFrame() const |
| 480 { |
| 481 return true; |
| 482 } |
| 483 |
| 484 WebLocalFrame* WebLocalFrameImpl::toWebLocalFrame() |
| 485 { |
| 486 return this; |
| 487 } |
| 488 |
| 489 bool WebLocalFrameImpl::isWebRemoteFrame() const |
| 490 { |
| 491 return false; |
| 492 } |
| 493 |
| 494 WebRemoteFrame* WebLocalFrameImpl::toWebRemoteFrame() |
| 495 { |
| 496 ASSERT_NOT_REACHED(); |
| 497 return 0; |
| 498 } |
| 499 |
| 500 void WebLocalFrameImpl::close() |
480 { | 501 { |
481 m_client = 0; | 502 m_client = 0; |
482 deref(); // Balances ref() acquired in WebFrame::create | 503 deref(); // Balances ref() acquired in WebFrame::create |
483 } | 504 } |
484 | 505 |
485 WebString WebFrameImpl::uniqueName() const | 506 WebString WebLocalFrameImpl::uniqueName() const |
486 { | 507 { |
487 return frame()->tree().uniqueName(); | 508 return frame()->tree().uniqueName(); |
488 } | 509 } |
489 | 510 |
490 WebString WebFrameImpl::assignedName() const | 511 WebString WebLocalFrameImpl::assignedName() const |
491 { | 512 { |
492 return frame()->tree().name(); | 513 return frame()->tree().name(); |
493 } | 514 } |
494 | 515 |
495 void WebFrameImpl::setName(const WebString& name) | 516 void WebLocalFrameImpl::setName(const WebString& name) |
496 { | 517 { |
497 frame()->tree().setName(name); | 518 frame()->tree().setName(name); |
498 } | 519 } |
499 | 520 |
500 WebVector<WebIconURL> WebFrameImpl::iconURLs(int iconTypesMask) const | 521 WebVector<WebIconURL> WebLocalFrameImpl::iconURLs(int iconTypesMask) const |
501 { | 522 { |
502 // The URL to the icon may be in the header. As such, only | 523 // The URL to the icon may be in the header. As such, only |
503 // ask the loader for the icon if it's finished loading. | 524 // ask the loader for the icon if it's finished loading. |
504 if (frame()->loader().state() == FrameStateComplete) | 525 if (frame()->loader().state() == FrameStateComplete) |
505 return frame()->document()->iconURLs(iconTypesMask); | 526 return frame()->document()->iconURLs(iconTypesMask); |
506 return WebVector<WebIconURL>(); | 527 return WebVector<WebIconURL>(); |
507 } | 528 } |
508 | 529 |
509 void WebFrameImpl::setIsRemote(bool isRemote) | 530 void WebLocalFrameImpl::setIsRemote(bool isRemote) |
510 { | 531 { |
511 m_isRemote = isRemote; | 532 m_isRemote = isRemote; |
512 if (isRemote) | 533 if (isRemote) |
513 client()->initializeChildFrame(frame()->view()->frameRect(), frame()->vi
ew()->visibleContentScaleFactor()); | 534 client()->initializeChildFrame(frame()->view()->frameRect(), frame()->vi
ew()->visibleContentScaleFactor()); |
514 } | 535 } |
515 | 536 |
516 void WebFrameImpl::setRemoteWebLayer(WebLayer* webLayer) | 537 void WebLocalFrameImpl::setRemoteWebLayer(WebLayer* webLayer) |
517 { | 538 { |
518 if (!frame()) | 539 if (!frame()) |
519 return; | 540 return; |
520 | 541 |
521 if (frame()->remotePlatformLayer()) | 542 if (frame()->remotePlatformLayer()) |
522 GraphicsLayer::unregisterContentsLayer(frame()->remotePlatformLayer()); | 543 GraphicsLayer::unregisterContentsLayer(frame()->remotePlatformLayer()); |
523 if (webLayer) | 544 if (webLayer) |
524 GraphicsLayer::registerContentsLayer(webLayer); | 545 GraphicsLayer::registerContentsLayer(webLayer); |
525 frame()->setRemotePlatformLayer(webLayer); | 546 frame()->setRemotePlatformLayer(webLayer); |
526 frame()->ownerElement()->scheduleLayerUpdate(); | 547 frame()->ownerElement()->scheduleLayerUpdate(); |
527 } | 548 } |
528 | 549 |
529 void WebFrameImpl::setPermissionClient(WebPermissionClient* permissionClient) | 550 void WebLocalFrameImpl::setPermissionClient(WebPermissionClient* permissionClien
t) |
530 { | 551 { |
531 m_permissionClient = permissionClient; | 552 m_permissionClient = permissionClient; |
532 } | 553 } |
533 | 554 |
534 void WebFrameImpl::setSharedWorkerRepositoryClient(WebSharedWorkerRepositoryClie
nt* client) | 555 void WebLocalFrameImpl::setSharedWorkerRepositoryClient(WebSharedWorkerRepositor
yClient* client) |
535 { | 556 { |
536 m_sharedWorkerRepositoryClient = SharedWorkerRepositoryClientImpl::create(cl
ient); | 557 m_sharedWorkerRepositoryClient = SharedWorkerRepositoryClientImpl::create(cl
ient); |
537 } | 558 } |
538 | 559 |
539 WebSize WebFrameImpl::scrollOffset() const | 560 WebSize WebLocalFrameImpl::scrollOffset() const |
540 { | 561 { |
541 FrameView* view = frameView(); | 562 FrameView* view = frameView(); |
542 if (!view) | 563 if (!view) |
543 return WebSize(); | 564 return WebSize(); |
544 return view->scrollOffset(); | 565 return view->scrollOffset(); |
545 } | 566 } |
546 | 567 |
547 WebSize WebFrameImpl::minimumScrollOffset() const | 568 WebSize WebLocalFrameImpl::minimumScrollOffset() const |
548 { | 569 { |
549 FrameView* view = frameView(); | 570 FrameView* view = frameView(); |
550 if (!view) | 571 if (!view) |
551 return WebSize(); | 572 return WebSize(); |
552 return toIntSize(view->minimumScrollPosition()); | 573 return toIntSize(view->minimumScrollPosition()); |
553 } | 574 } |
554 | 575 |
555 WebSize WebFrameImpl::maximumScrollOffset() const | 576 WebSize WebLocalFrameImpl::maximumScrollOffset() const |
556 { | 577 { |
557 FrameView* view = frameView(); | 578 FrameView* view = frameView(); |
558 if (!view) | 579 if (!view) |
559 return WebSize(); | 580 return WebSize(); |
560 return toIntSize(view->maximumScrollPosition()); | 581 return toIntSize(view->maximumScrollPosition()); |
561 } | 582 } |
562 | 583 |
563 void WebFrameImpl::setScrollOffset(const WebSize& offset) | 584 void WebLocalFrameImpl::setScrollOffset(const WebSize& offset) |
564 { | 585 { |
565 if (FrameView* view = frameView()) | 586 if (FrameView* view = frameView()) |
566 view->setScrollOffset(IntPoint(offset.width, offset.height)); | 587 view->setScrollOffset(IntPoint(offset.width, offset.height)); |
567 } | 588 } |
568 | 589 |
569 WebSize WebFrameImpl::contentsSize() const | 590 WebSize WebLocalFrameImpl::contentsSize() const |
570 { | 591 { |
571 return frame()->view()->contentsSize(); | 592 return frame()->view()->contentsSize(); |
572 } | 593 } |
573 | 594 |
574 bool WebFrameImpl::hasVisibleContent() const | 595 bool WebLocalFrameImpl::hasVisibleContent() const |
575 { | 596 { |
576 return frame()->view()->visibleWidth() > 0 && frame()->view()->visibleHeight
() > 0; | 597 return frame()->view()->visibleWidth() > 0 && frame()->view()->visibleHeight
() > 0; |
577 } | 598 } |
578 | 599 |
579 WebRect WebFrameImpl::visibleContentRect() const | 600 WebRect WebLocalFrameImpl::visibleContentRect() const |
580 { | 601 { |
581 return frame()->view()->visibleContentRect(); | 602 return frame()->view()->visibleContentRect(); |
582 } | 603 } |
583 | 604 |
584 bool WebFrameImpl::hasHorizontalScrollbar() const | 605 bool WebLocalFrameImpl::hasHorizontalScrollbar() const |
585 { | 606 { |
586 return frame() && frame()->view() && frame()->view()->horizontalScrollbar(); | 607 return frame() && frame()->view() && frame()->view()->horizontalScrollbar(); |
587 } | 608 } |
588 | 609 |
589 bool WebFrameImpl::hasVerticalScrollbar() const | 610 bool WebLocalFrameImpl::hasVerticalScrollbar() const |
590 { | 611 { |
591 return frame() && frame()->view() && frame()->view()->verticalScrollbar(); | 612 return frame() && frame()->view() && frame()->view()->verticalScrollbar(); |
592 } | 613 } |
593 | 614 |
594 WebView* WebFrameImpl::view() const | 615 WebView* WebLocalFrameImpl::view() const |
595 { | 616 { |
596 return viewImpl(); | 617 return viewImpl(); |
597 } | 618 } |
598 | 619 |
599 WebFrame* WebFrameImpl::opener() const | 620 WebFrame* WebLocalFrameImpl::opener() const |
600 { | 621 { |
601 return m_opener; | 622 return m_opener; |
602 } | 623 } |
603 | 624 |
604 void WebFrameImpl::setOpener(WebFrame* opener) | 625 void WebLocalFrameImpl::setOpener(WebFrame* opener) |
605 { | 626 { |
606 WebFrameImpl* openerImpl = toWebFrameImpl(opener); | 627 WebLocalFrameImpl* openerImpl = toWebLocalFrameImpl(opener); |
607 if (m_opener && !openerImpl && m_client) | 628 if (m_opener && !openerImpl && m_client) |
608 m_client->didDisownOpener(this); | 629 m_client->didDisownOpener(this); |
609 | 630 |
610 if (m_opener) | 631 if (m_opener) |
611 m_opener->m_openedFrames.remove(this); | 632 m_opener->m_openedFrames.remove(this); |
612 if (openerImpl) | 633 if (openerImpl) |
613 openerImpl->m_openedFrames.add(this); | 634 openerImpl->m_openedFrames.add(this); |
614 m_opener = openerImpl; | 635 m_opener = openerImpl; |
615 | 636 |
616 ASSERT(m_frame); | 637 ASSERT(m_frame); |
617 if (m_frame && m_frame->document()) | 638 if (m_frame && m_frame->document()) |
618 m_frame->document()->initSecurityContext(); | 639 m_frame->document()->initSecurityContext(); |
619 } | 640 } |
620 | 641 |
621 void WebFrameImpl::appendChild(WebFrame* child) | 642 void WebLocalFrameImpl::appendChild(WebFrame* child) |
622 { | 643 { |
623 // FIXME: Original code asserts that the frames have the same Page. We | 644 // FIXME: Original code asserts that the frames have the same Page. We |
624 // should add an equivalent check... figure out what. | 645 // should add an equivalent check... figure out what. |
625 WebFrameImpl* childImpl = toWebFrameImpl(child); | 646 WebLocalFrameImpl* childImpl = toWebLocalFrameImpl(child); |
626 childImpl->m_parent = this; | 647 childImpl->m_parent = this; |
627 WebFrameImpl* oldLast = m_lastChild; | 648 WebLocalFrameImpl* oldLast = m_lastChild; |
628 m_lastChild = childImpl; | 649 m_lastChild = childImpl; |
629 | 650 |
630 if (oldLast) { | 651 if (oldLast) { |
631 childImpl->m_previousSibling = oldLast; | 652 childImpl->m_previousSibling = oldLast; |
632 oldLast->m_nextSibling = childImpl; | 653 oldLast->m_nextSibling = childImpl; |
633 } else { | 654 } else { |
634 m_firstChild = childImpl; | 655 m_firstChild = childImpl; |
635 } | 656 } |
636 // FIXME: Not sure if this is a legitimate assert. | 657 // FIXME: Not sure if this is a legitimate assert. |
637 ASSERT(frame()); | 658 ASSERT(frame()); |
638 frame()->tree().invalidateScopedChildCount(); | 659 frame()->tree().invalidateScopedChildCount(); |
639 } | 660 } |
640 | 661 |
641 void WebFrameImpl::removeChild(WebFrame* child) | 662 void WebLocalFrameImpl::removeChild(WebFrame* child) |
642 { | 663 { |
643 WebFrameImpl* childImpl = toWebFrameImpl(child); | 664 WebLocalFrameImpl* childImpl = toWebLocalFrameImpl(child); |
644 childImpl->m_parent = 0; | 665 childImpl->m_parent = 0; |
645 | 666 |
646 if (m_firstChild == childImpl) | 667 if (m_firstChild == childImpl) |
647 m_firstChild = childImpl->m_nextSibling; | 668 m_firstChild = childImpl->m_nextSibling; |
648 else | 669 else |
649 childImpl->m_previousSibling->m_nextSibling = childImpl->m_nextSibling; | 670 childImpl->m_previousSibling->m_nextSibling = childImpl->m_nextSibling; |
650 | 671 |
651 if (m_lastChild == childImpl) | 672 if (m_lastChild == childImpl) |
652 m_lastChild = childImpl->m_previousSibling; | 673 m_lastChild = childImpl->m_previousSibling; |
653 else | 674 else |
654 childImpl->m_nextSibling->m_previousSibling = childImpl->m_previousSibli
ng; | 675 childImpl->m_nextSibling->m_previousSibling = childImpl->m_previousSibli
ng; |
655 | 676 |
656 childImpl->m_previousSibling = childImpl->m_nextSibling = 0; | 677 childImpl->m_previousSibling = childImpl->m_nextSibling = 0; |
657 // FIXME: Not sure if this is a legitimate assert. | 678 // FIXME: Not sure if this is a legitimate assert. |
658 ASSERT(frame()); | 679 ASSERT(frame()); |
659 frame()->tree().invalidateScopedChildCount(); | 680 frame()->tree().invalidateScopedChildCount(); |
660 } | 681 } |
661 | 682 |
662 WebFrame* WebFrameImpl::parent() const | 683 WebFrame* WebLocalFrameImpl::parent() const |
663 { | 684 { |
664 return m_parent; | 685 return m_parent; |
665 } | 686 } |
666 | 687 |
667 WebFrame* WebFrameImpl::top() const | 688 WebFrame* WebLocalFrameImpl::top() const |
668 { | 689 { |
669 WebFrameImpl* frame = const_cast<WebFrameImpl*>(this); | 690 WebLocalFrameImpl* frame = const_cast<WebLocalFrameImpl*>(this); |
670 for (WebFrameImpl* parent = frame; parent; parent = parent->m_parent) | 691 for (WebLocalFrameImpl* parent = frame; parent; parent = parent->m_parent) |
671 frame = parent; | 692 frame = parent; |
672 return frame; | 693 return frame; |
673 } | 694 } |
674 | 695 |
675 WebFrame* WebFrameImpl::previousSibling() const | 696 WebFrame* WebLocalFrameImpl::previousSibling() const |
676 { | 697 { |
677 return m_previousSibling; | 698 return m_previousSibling; |
678 } | 699 } |
679 | 700 |
680 WebFrame* WebFrameImpl::nextSibling() const | 701 WebFrame* WebLocalFrameImpl::nextSibling() const |
681 { | 702 { |
682 return m_nextSibling; | 703 return m_nextSibling; |
683 } | 704 } |
684 | 705 |
685 WebFrame* WebFrameImpl::firstChild() const | 706 WebFrame* WebLocalFrameImpl::firstChild() const |
686 { | 707 { |
687 return m_firstChild; | 708 return m_firstChild; |
688 } | 709 } |
689 | 710 |
690 WebFrame* WebFrameImpl::lastChild() const | 711 WebFrame* WebLocalFrameImpl::lastChild() const |
691 { | 712 { |
692 return m_lastChild; | 713 return m_lastChild; |
693 } | 714 } |
694 | 715 |
695 WebFrame* WebFrameImpl::traversePrevious(bool wrap) const | 716 WebFrame* WebLocalFrameImpl::traversePrevious(bool wrap) const |
696 { | 717 { |
697 if (!frame()) | 718 if (!frame()) |
698 return 0; | 719 return 0; |
699 return fromFrame(frame()->tree().traversePreviousWithWrap(wrap)); | 720 return fromFrame(frame()->tree().traversePreviousWithWrap(wrap)); |
700 } | 721 } |
701 | 722 |
702 WebFrame* WebFrameImpl::traverseNext(bool wrap) const | 723 WebFrame* WebLocalFrameImpl::traverseNext(bool wrap) const |
703 { | 724 { |
704 if (!frame()) | 725 if (!frame()) |
705 return 0; | 726 return 0; |
706 return fromFrame(frame()->tree().traverseNextWithWrap(wrap)); | 727 return fromFrame(frame()->tree().traverseNextWithWrap(wrap)); |
707 } | 728 } |
708 | 729 |
709 WebFrame* WebFrameImpl::findChildByName(const WebString& name) const | 730 WebFrame* WebLocalFrameImpl::findChildByName(const WebString& name) const |
710 { | 731 { |
711 if (!frame()) | 732 if (!frame()) |
712 return 0; | 733 return 0; |
713 return fromFrame(frame()->tree().child(name)); | 734 return fromFrame(frame()->tree().child(name)); |
714 } | 735 } |
715 | 736 |
716 WebDocument WebFrameImpl::document() const | 737 WebDocument WebLocalFrameImpl::document() const |
717 { | 738 { |
718 if (!frame() || !frame()->document()) | 739 if (!frame() || !frame()->document()) |
719 return WebDocument(); | 740 return WebDocument(); |
720 return WebDocument(frame()->document()); | 741 return WebDocument(frame()->document()); |
721 } | 742 } |
722 | 743 |
723 WebPerformance WebFrameImpl::performance() const | 744 WebPerformance WebLocalFrameImpl::performance() const |
724 { | 745 { |
725 if (!frame()) | 746 if (!frame()) |
726 return WebPerformance(); | 747 return WebPerformance(); |
727 return WebPerformance(&frame()->domWindow()->performance()); | 748 return WebPerformance(&frame()->domWindow()->performance()); |
728 } | 749 } |
729 | 750 |
730 bool WebFrameImpl::dispatchBeforeUnloadEvent() | 751 bool WebLocalFrameImpl::dispatchBeforeUnloadEvent() |
731 { | 752 { |
732 if (!frame()) | 753 if (!frame()) |
733 return true; | 754 return true; |
734 return frame()->loader().shouldClose(); | 755 return frame()->loader().shouldClose(); |
735 } | 756 } |
736 | 757 |
737 void WebFrameImpl::dispatchUnloadEvent() | 758 void WebLocalFrameImpl::dispatchUnloadEvent() |
738 { | 759 { |
739 if (!frame()) | 760 if (!frame()) |
740 return; | 761 return; |
741 frame()->loader().closeURL(); | 762 frame()->loader().closeURL(); |
742 } | 763 } |
743 | 764 |
744 NPObject* WebFrameImpl::windowObject() const | 765 NPObject* WebLocalFrameImpl::windowObject() const |
745 { | 766 { |
746 if (!frame()) | 767 if (!frame()) |
747 return 0; | 768 return 0; |
748 return frame()->script().windowScriptNPObject(); | 769 return frame()->script().windowScriptNPObject(); |
749 } | 770 } |
750 | 771 |
751 void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object) | 772 void WebLocalFrameImpl::bindToWindowObject(const WebString& name, NPObject* obje
ct) |
752 { | 773 { |
753 bindToWindowObject(name, object, 0); | 774 bindToWindowObject(name, object, 0); |
754 } | 775 } |
755 | 776 |
756 void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object, v
oid*) | 777 void WebLocalFrameImpl::bindToWindowObject(const WebString& name, NPObject* obje
ct, void*) |
757 { | 778 { |
758 if (!frame() || !frame()->script().canExecuteScripts(NotAboutToExecuteScript
)) | 779 if (!frame() || !frame()->script().canExecuteScripts(NotAboutToExecuteScript
)) |
759 return; | 780 return; |
760 frame()->script().bindToWindowObject(frame(), String(name), object); | 781 frame()->script().bindToWindowObject(frame(), String(name), object); |
761 } | 782 } |
762 | 783 |
763 void WebFrameImpl::executeScript(const WebScriptSource& source) | 784 void WebLocalFrameImpl::executeScript(const WebScriptSource& source) |
764 { | 785 { |
765 ASSERT(frame()); | 786 ASSERT(frame()); |
766 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); | 787 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); |
767 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou
rce.url, position)); | 788 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou
rce.url, position)); |
768 } | 789 } |
769 | 790 |
770 void WebFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSour
ce* sourcesIn, unsigned numSources, int extensionGroup) | 791 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup) |
771 { | 792 { |
772 ASSERT(frame()); | 793 ASSERT(frame()); |
773 RELEASE_ASSERT(worldID > 0); | 794 RELEASE_ASSERT(worldID > 0); |
774 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | 795 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); |
775 | 796 |
776 Vector<ScriptSourceCode> sources; | 797 Vector<ScriptSourceCode> sources; |
777 for (unsigned i = 0; i < numSources; ++i) { | 798 for (unsigned i = 0; i < numSources; ++i) { |
778 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); | 799 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); |
779 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); | 800 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); |
780 } | 801 } |
781 | 802 |
782 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGr
oup, 0); | 803 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGr
oup, 0); |
783 } | 804 } |
784 | 805 |
785 void WebFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSecurity
Origin& securityOrigin) | 806 void WebLocalFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSec
urityOrigin& securityOrigin) |
786 { | 807 { |
787 ASSERT(frame()); | 808 ASSERT(frame()); |
788 DOMWrapperWorld::setIsolatedWorldSecurityOrigin(worldID, securityOrigin.get(
)); | 809 DOMWrapperWorld::setIsolatedWorldSecurityOrigin(worldID, securityOrigin.get(
)); |
789 } | 810 } |
790 | 811 |
791 void WebFrameImpl::setIsolatedWorldContentSecurityPolicy(int worldID, const WebS
tring& policy) | 812 void WebLocalFrameImpl::setIsolatedWorldContentSecurityPolicy(int worldID, const
WebString& policy) |
792 { | 813 { |
793 ASSERT(frame()); | 814 ASSERT(frame()); |
794 DOMWrapperWorld::setIsolatedWorldContentSecurityPolicy(worldID, policy); | 815 DOMWrapperWorld::setIsolatedWorldContentSecurityPolicy(worldID, policy); |
795 } | 816 } |
796 | 817 |
797 void WebFrameImpl::addMessageToConsole(const WebConsoleMessage& message) | 818 void WebLocalFrameImpl::addMessageToConsole(const WebConsoleMessage& message) |
798 { | 819 { |
799 ASSERT(frame()); | 820 ASSERT(frame()); |
800 | 821 |
801 MessageLevel webCoreMessageLevel; | 822 MessageLevel webCoreMessageLevel; |
802 switch (message.level) { | 823 switch (message.level) { |
803 case WebConsoleMessage::LevelDebug: | 824 case WebConsoleMessage::LevelDebug: |
804 webCoreMessageLevel = DebugMessageLevel; | 825 webCoreMessageLevel = DebugMessageLevel; |
805 break; | 826 break; |
806 case WebConsoleMessage::LevelLog: | 827 case WebConsoleMessage::LevelLog: |
807 webCoreMessageLevel = LogMessageLevel; | 828 webCoreMessageLevel = LogMessageLevel; |
808 break; | 829 break; |
809 case WebConsoleMessage::LevelWarning: | 830 case WebConsoleMessage::LevelWarning: |
810 webCoreMessageLevel = WarningMessageLevel; | 831 webCoreMessageLevel = WarningMessageLevel; |
811 break; | 832 break; |
812 case WebConsoleMessage::LevelError: | 833 case WebConsoleMessage::LevelError: |
813 webCoreMessageLevel = ErrorMessageLevel; | 834 webCoreMessageLevel = ErrorMessageLevel; |
814 break; | 835 break; |
815 default: | 836 default: |
816 ASSERT_NOT_REACHED(); | 837 ASSERT_NOT_REACHED(); |
817 return; | 838 return; |
818 } | 839 } |
819 | 840 |
820 frame()->document()->addConsoleMessage(OtherMessageSource, webCoreMessageLev
el, message.text); | 841 frame()->document()->addConsoleMessage(OtherMessageSource, webCoreMessageLev
el, message.text); |
821 } | 842 } |
822 | 843 |
823 void WebFrameImpl::collectGarbage() | 844 void WebLocalFrameImpl::collectGarbage() |
824 { | 845 { |
825 if (!frame()) | 846 if (!frame()) |
826 return; | 847 return; |
827 if (!frame()->settings()->scriptEnabled()) | 848 if (!frame()->settings()->scriptEnabled()) |
828 return; | 849 return; |
829 V8GCController::collectGarbage(v8::Isolate::GetCurrent()); | 850 V8GCController::collectGarbage(v8::Isolate::GetCurrent()); |
830 } | 851 } |
831 | 852 |
832 bool WebFrameImpl::checkIfRunInsecureContent(const WebURL& url) const | 853 bool WebLocalFrameImpl::checkIfRunInsecureContent(const WebURL& url) const |
833 { | 854 { |
834 ASSERT(frame()); | 855 ASSERT(frame()); |
835 return frame()->loader().mixedContentChecker()->canRunInsecureContent(frame(
)->document()->securityOrigin(), url); | 856 return frame()->loader().mixedContentChecker()->canRunInsecureContent(frame(
)->document()->securityOrigin(), url); |
836 } | 857 } |
837 | 858 |
838 v8::Handle<v8::Value> WebFrameImpl::executeScriptAndReturnValue(const WebScriptS
ource& source) | 859 v8::Handle<v8::Value> WebLocalFrameImpl::executeScriptAndReturnValue(const WebSc
riptSource& source) |
839 { | 860 { |
840 ASSERT(frame()); | 861 ASSERT(frame()); |
841 | 862 |
842 // FIXME: This fake user gesture is required to make a bunch of pyauto | 863 // FIXME: This fake user gesture is required to make a bunch of pyauto |
843 // tests pass. If this isn't needed in non-test situations, we should | 864 // tests pass. If this isn't needed in non-test situations, we should |
844 // consider removing this code and changing the tests. | 865 // consider removing this code and changing the tests. |
845 // http://code.google.com/p/chromium/issues/detail?id=86397 | 866 // http://code.google.com/p/chromium/issues/detail?id=86397 |
846 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 867 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
847 | 868 |
848 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); | 869 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi
nalNumber::first()); |
849 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource
Code(source.code, source.url, position)).v8Value(); | 870 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource
Code(source.code, source.url, position)).v8Value(); |
850 } | 871 } |
851 | 872 |
852 void WebFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSour
ce* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local<v8::
Value> >* results) | 873 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local
<v8::Value> >* results) |
853 { | 874 { |
854 ASSERT(frame()); | 875 ASSERT(frame()); |
855 RELEASE_ASSERT(worldID > 0); | 876 RELEASE_ASSERT(worldID > 0); |
856 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | 877 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); |
857 | 878 |
858 Vector<ScriptSourceCode> sources; | 879 Vector<ScriptSourceCode> sources; |
859 | 880 |
860 for (unsigned i = 0; i < numSources; ++i) { | 881 for (unsigned i = 0; i < numSources; ++i) { |
861 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); | 882 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL
ine), OrdinalNumber::first()); |
862 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); | 883 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos
ition)); |
863 } | 884 } |
864 | 885 |
865 if (results) { | 886 if (results) { |
866 Vector<ScriptValue> scriptResults; | 887 Vector<ScriptValue> scriptResults; |
867 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, &scriptResults); | 888 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, &scriptResults); |
868 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size()); | 889 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size()); |
869 for (unsigned i = 0; i < scriptResults.size(); i++) | 890 for (unsigned i = 0; i < scriptResults.size(); i++) |
870 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR
esults[i].v8Value()); | 891 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR
esults[i].v8Value()); |
871 results->swap(v8Results); | 892 results->swap(v8Results); |
872 } else { | 893 } else { |
873 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, 0); | 894 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, 0); |
874 } | 895 } |
875 } | 896 } |
876 | 897 |
877 v8::Handle<v8::Value> WebFrameImpl::callFunctionEvenIfScriptDisabled(v8::Handle<
v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8:
:Value> argv[]) | 898 v8::Handle<v8::Value> WebLocalFrameImpl::callFunctionEvenIfScriptDisabled(v8::Ha
ndle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handl
e<v8::Value> argv[]) |
878 { | 899 { |
879 ASSERT(frame()); | 900 ASSERT(frame()); |
880 return frame()->script().callFunction(function, receiver, argc, argv); | 901 return frame()->script().callFunction(function, receiver, argc, argv); |
881 } | 902 } |
882 | 903 |
883 v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const | 904 v8::Local<v8::Context> WebLocalFrameImpl::mainWorldScriptContext() const |
884 { | 905 { |
885 return toV8Context(V8PerIsolateData::mainThreadIsolate(), frame(), DOMWrappe
rWorld::mainWorld()); | 906 return toV8Context(V8PerIsolateData::mainThreadIsolate(), frame(), DOMWrappe
rWorld::mainWorld()); |
886 } | 907 } |
887 | 908 |
888 void WebFrameImpl::reload(bool ignoreCache) | 909 void WebLocalFrameImpl::reload(bool ignoreCache) |
889 { | 910 { |
890 ASSERT(frame()); | 911 ASSERT(frame()); |
891 frame()->loader().reload(ignoreCache ? EndToEndReload : NormalReload); | 912 frame()->loader().reload(ignoreCache ? EndToEndReload : NormalReload); |
892 } | 913 } |
893 | 914 |
894 void WebFrameImpl::reloadWithOverrideURL(const WebURL& overrideUrl, bool ignoreC
ache) | 915 void WebLocalFrameImpl::reloadWithOverrideURL(const WebURL& overrideUrl, bool ig
noreCache) |
895 { | 916 { |
896 ASSERT(frame()); | 917 ASSERT(frame()); |
897 frame()->loader().reload(ignoreCache ? EndToEndReload : NormalReload, overri
deUrl); | 918 frame()->loader().reload(ignoreCache ? EndToEndReload : NormalReload, overri
deUrl); |
898 } | 919 } |
899 | 920 |
900 void WebFrameImpl::loadRequest(const WebURLRequest& request) | 921 void WebLocalFrameImpl::loadRequest(const WebURLRequest& request) |
901 { | 922 { |
902 ASSERT(frame()); | 923 ASSERT(frame()); |
903 ASSERT(!request.isNull()); | 924 ASSERT(!request.isNull()); |
904 const ResourceRequest& resourceRequest = request.toResourceRequest(); | 925 const ResourceRequest& resourceRequest = request.toResourceRequest(); |
905 | 926 |
906 if (resourceRequest.url().protocolIs("javascript")) { | 927 if (resourceRequest.url().protocolIs("javascript")) { |
907 loadJavaScriptURL(resourceRequest.url()); | 928 loadJavaScriptURL(resourceRequest.url()); |
908 return; | 929 return; |
909 } | 930 } |
910 | 931 |
911 frame()->loader().load(FrameLoadRequest(0, resourceRequest)); | 932 frame()->loader().load(FrameLoadRequest(0, resourceRequest)); |
912 } | 933 } |
913 | 934 |
914 void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item, WebHistoryLoadTyp
e loadType, WebURLRequest::CachePolicy cachePolicy) | 935 void WebLocalFrameImpl::loadHistoryItem(const WebHistoryItem& item, WebHistoryLo
adType loadType, WebURLRequest::CachePolicy cachePolicy) |
915 { | 936 { |
916 ASSERT(frame()); | 937 ASSERT(frame()); |
917 RefPtr<HistoryItem> historyItem = PassRefPtr<HistoryItem>(item); | 938 RefPtr<HistoryItem> historyItem = PassRefPtr<HistoryItem>(item); |
918 ASSERT(historyItem); | 939 ASSERT(historyItem); |
919 frame()->loader().loadHistoryItem(historyItem.get(), static_cast<HistoryLoad
Type>(loadType), static_cast<ResourceRequestCachePolicy>(cachePolicy)); | 940 frame()->loader().loadHistoryItem(historyItem.get(), static_cast<HistoryLoad
Type>(loadType), static_cast<ResourceRequestCachePolicy>(cachePolicy)); |
920 } | 941 } |
921 | 942 |
922 void WebFrameImpl::loadData(const WebData& data, const WebString& mimeType, cons
t WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachableURL,
bool replace) | 943 void WebLocalFrameImpl::loadData(const WebData& data, const WebString& mimeType,
const WebString& textEncoding, const WebURL& baseURL, const WebURL& unreachable
URL, bool replace) |
923 { | 944 { |
924 ASSERT(frame()); | 945 ASSERT(frame()); |
925 | 946 |
926 // If we are loading substitute data to replace an existing load, then | 947 // If we are loading substitute data to replace an existing load, then |
927 // inherit all of the properties of that original request. This way, | 948 // inherit all of the properties of that original request. This way, |
928 // reload will re-attempt the original request. It is essential that | 949 // reload will re-attempt the original request. It is essential that |
929 // we only do this when there is an unreachableURL since a non-empty | 950 // we only do this when there is an unreachableURL since a non-empty |
930 // unreachableURL informs FrameLoader::reload to load unreachableURL | 951 // unreachableURL informs FrameLoader::reload to load unreachableURL |
931 // instead of the currently loaded URL. | 952 // instead of the currently loaded URL. |
932 ResourceRequest request; | 953 ResourceRequest request; |
933 if (replace && !unreachableURL.isEmpty() && frame()->loader().provisionalDoc
umentLoader()) | 954 if (replace && !unreachableURL.isEmpty() && frame()->loader().provisionalDoc
umentLoader()) |
934 request = frame()->loader().provisionalDocumentLoader()->originalRequest
(); | 955 request = frame()->loader().provisionalDocumentLoader()->originalRequest
(); |
935 request.setURL(baseURL); | 956 request.setURL(baseURL); |
936 | 957 |
937 FrameLoadRequest frameRequest(0, request, SubstituteData(data, mimeType, tex
tEncoding, unreachableURL)); | 958 FrameLoadRequest frameRequest(0, request, SubstituteData(data, mimeType, tex
tEncoding, unreachableURL)); |
938 ASSERT(frameRequest.substituteData().isValid()); | 959 ASSERT(frameRequest.substituteData().isValid()); |
939 frameRequest.setLockBackForwardList(replace); | 960 frameRequest.setLockBackForwardList(replace); |
940 frame()->loader().load(frameRequest); | 961 frame()->loader().load(frameRequest); |
941 } | 962 } |
942 | 963 |
943 void WebFrameImpl::loadHTMLString(const WebData& data, const WebURL& baseURL, co
nst WebURL& unreachableURL, bool replace) | 964 void WebLocalFrameImpl::loadHTMLString(const WebData& data, const WebURL& baseUR
L, const WebURL& unreachableURL, bool replace) |
944 { | 965 { |
945 ASSERT(frame()); | 966 ASSERT(frame()); |
946 loadData(data, WebString::fromUTF8("text/html"), WebString::fromUTF8("UTF-8"
), baseURL, unreachableURL, replace); | 967 loadData(data, WebString::fromUTF8("text/html"), WebString::fromUTF8("UTF-8"
), baseURL, unreachableURL, replace); |
947 } | 968 } |
948 | 969 |
949 bool WebFrameImpl::isLoading() const | 970 bool WebLocalFrameImpl::isLoading() const |
950 { | 971 { |
951 if (!frame()) | 972 if (!frame()) |
952 return false; | 973 return false; |
953 return frame()->loader().isLoading(); | 974 return frame()->loader().isLoading(); |
954 } | 975 } |
955 | 976 |
956 void WebFrameImpl::stopLoading() | 977 void WebLocalFrameImpl::stopLoading() |
957 { | 978 { |
958 if (!frame()) | 979 if (!frame()) |
959 return; | 980 return; |
960 // FIXME: Figure out what we should really do here. It seems like a bug | 981 // FIXME: Figure out what we should really do here. It seems like a bug |
961 // that FrameLoader::stopLoading doesn't call stopAllLoaders. | 982 // that FrameLoader::stopLoading doesn't call stopAllLoaders. |
962 frame()->loader().stopAllLoaders(); | 983 frame()->loader().stopAllLoaders(); |
963 } | 984 } |
964 | 985 |
965 WebDataSource* WebFrameImpl::provisionalDataSource() const | 986 WebDataSource* WebLocalFrameImpl::provisionalDataSource() const |
966 { | 987 { |
967 ASSERT(frame()); | 988 ASSERT(frame()); |
968 | 989 |
969 // We regard the policy document loader as still provisional. | 990 // We regard the policy document loader as still provisional. |
970 DocumentLoader* documentLoader = frame()->loader().provisionalDocumentLoader
(); | 991 DocumentLoader* documentLoader = frame()->loader().provisionalDocumentLoader
(); |
971 if (!documentLoader) | 992 if (!documentLoader) |
972 documentLoader = frame()->loader().policyDocumentLoader(); | 993 documentLoader = frame()->loader().policyDocumentLoader(); |
973 | 994 |
974 return DataSourceForDocLoader(documentLoader); | 995 return DataSourceForDocLoader(documentLoader); |
975 } | 996 } |
976 | 997 |
977 WebDataSource* WebFrameImpl::dataSource() const | 998 WebDataSource* WebLocalFrameImpl::dataSource() const |
978 { | 999 { |
979 ASSERT(frame()); | 1000 ASSERT(frame()); |
980 return DataSourceForDocLoader(frame()->loader().documentLoader()); | 1001 return DataSourceForDocLoader(frame()->loader().documentLoader()); |
981 } | 1002 } |
982 | 1003 |
983 void WebFrameImpl::enableViewSourceMode(bool enable) | 1004 void WebLocalFrameImpl::enableViewSourceMode(bool enable) |
984 { | 1005 { |
985 if (frame()) | 1006 if (frame()) |
986 frame()->setInViewSourceMode(enable); | 1007 frame()->setInViewSourceMode(enable); |
987 } | 1008 } |
988 | 1009 |
989 bool WebFrameImpl::isViewSourceModeEnabled() const | 1010 bool WebLocalFrameImpl::isViewSourceModeEnabled() const |
990 { | 1011 { |
991 if (!frame()) | 1012 if (!frame()) |
992 return false; | 1013 return false; |
993 return frame()->inViewSourceMode(); | 1014 return frame()->inViewSourceMode(); |
994 } | 1015 } |
995 | 1016 |
996 void WebFrameImpl::setReferrerForRequest(WebURLRequest& request, const WebURL& r
eferrerURL) | 1017 void WebLocalFrameImpl::setReferrerForRequest(WebURLRequest& request, const WebU
RL& referrerURL) |
997 { | 1018 { |
998 String referrer = referrerURL.isEmpty() ? frame()->document()->outgoingRefer
rer() : String(referrerURL.spec().utf16()); | 1019 String referrer = referrerURL.isEmpty() ? frame()->document()->outgoingRefer
rer() : String(referrerURL.spec().utf16()); |
999 referrer = SecurityPolicy::generateReferrerHeader(frame()->document()->refer
rerPolicy(), request.url(), referrer); | 1020 referrer = SecurityPolicy::generateReferrerHeader(frame()->document()->refer
rerPolicy(), request.url(), referrer); |
1000 if (referrer.isEmpty()) | 1021 if (referrer.isEmpty()) |
1001 return; | 1022 return; |
1002 request.setHTTPReferrer(referrer, static_cast<WebReferrerPolicy>(frame()->do
cument()->referrerPolicy())); | 1023 request.setHTTPReferrer(referrer, static_cast<WebReferrerPolicy>(frame()->do
cument()->referrerPolicy())); |
1003 } | 1024 } |
1004 | 1025 |
1005 void WebFrameImpl::dispatchWillSendRequest(WebURLRequest& request) | 1026 void WebLocalFrameImpl::dispatchWillSendRequest(WebURLRequest& request) |
1006 { | 1027 { |
1007 ResourceResponse response; | 1028 ResourceResponse response; |
1008 frame()->loader().client()->dispatchWillSendRequest(0, 0, request.toMutableR
esourceRequest(), response); | 1029 frame()->loader().client()->dispatchWillSendRequest(0, 0, request.toMutableR
esourceRequest(), response); |
1009 } | 1030 } |
1010 | 1031 |
1011 WebURLLoader* WebFrameImpl::createAssociatedURLLoader(const WebURLLoaderOptions&
options) | 1032 WebURLLoader* WebLocalFrameImpl::createAssociatedURLLoader(const WebURLLoaderOpt
ions& options) |
1012 { | 1033 { |
1013 return new AssociatedURLLoader(this, options); | 1034 return new AssociatedURLLoader(this, options); |
1014 } | 1035 } |
1015 | 1036 |
1016 unsigned WebFrameImpl::unloadListenerCount() const | 1037 unsigned WebLocalFrameImpl::unloadListenerCount() const |
1017 { | 1038 { |
1018 return frame()->domWindow()->pendingUnloadEventListeners(); | 1039 return frame()->domWindow()->pendingUnloadEventListeners(); |
1019 } | 1040 } |
1020 | 1041 |
1021 void WebFrameImpl::replaceSelection(const WebString& text) | 1042 void WebLocalFrameImpl::replaceSelection(const WebString& text) |
1022 { | 1043 { |
1023 bool selectReplacement = false; | 1044 bool selectReplacement = false; |
1024 bool smartReplace = true; | 1045 bool smartReplace = true; |
1025 frame()->editor().replaceSelectionWithText(text, selectReplacement, smartRep
lace); | 1046 frame()->editor().replaceSelectionWithText(text, selectReplacement, smartRep
lace); |
1026 } | 1047 } |
1027 | 1048 |
1028 void WebFrameImpl::insertText(const WebString& text) | 1049 void WebLocalFrameImpl::insertText(const WebString& text) |
1029 { | 1050 { |
1030 if (frame()->inputMethodController().hasComposition()) | 1051 if (frame()->inputMethodController().hasComposition()) |
1031 frame()->inputMethodController().confirmComposition(text); | 1052 frame()->inputMethodController().confirmComposition(text); |
1032 else | 1053 else |
1033 frame()->editor().insertText(text, 0); | 1054 frame()->editor().insertText(text, 0); |
1034 } | 1055 } |
1035 | 1056 |
1036 void WebFrameImpl::setMarkedText(const WebString& text, unsigned location, unsig
ned length) | 1057 void WebLocalFrameImpl::setMarkedText(const WebString& text, unsigned location,
unsigned length) |
1037 { | 1058 { |
1038 Vector<CompositionUnderline> decorations; | 1059 Vector<CompositionUnderline> decorations; |
1039 frame()->inputMethodController().setComposition(text, decorations, location,
length); | 1060 frame()->inputMethodController().setComposition(text, decorations, location,
length); |
1040 } | 1061 } |
1041 | 1062 |
1042 void WebFrameImpl::unmarkText() | 1063 void WebLocalFrameImpl::unmarkText() |
1043 { | 1064 { |
1044 frame()->inputMethodController().cancelComposition(); | 1065 frame()->inputMethodController().cancelComposition(); |
1045 } | 1066 } |
1046 | 1067 |
1047 bool WebFrameImpl::hasMarkedText() const | 1068 bool WebLocalFrameImpl::hasMarkedText() const |
1048 { | 1069 { |
1049 return frame()->inputMethodController().hasComposition(); | 1070 return frame()->inputMethodController().hasComposition(); |
1050 } | 1071 } |
1051 | 1072 |
1052 WebRange WebFrameImpl::markedRange() const | 1073 WebRange WebLocalFrameImpl::markedRange() const |
1053 { | 1074 { |
1054 return frame()->inputMethodController().compositionRange(); | 1075 return frame()->inputMethodController().compositionRange(); |
1055 } | 1076 } |
1056 | 1077 |
1057 bool WebFrameImpl::firstRectForCharacterRange(unsigned location, unsigned length
, WebRect& rect) const | 1078 bool WebLocalFrameImpl::firstRectForCharacterRange(unsigned location, unsigned l
ength, WebRect& rect) const |
1058 { | 1079 { |
1059 if ((location + length < location) && (location + length)) | 1080 if ((location + length < location) && (location + length)) |
1060 length = 0; | 1081 length = 0; |
1061 | 1082 |
1062 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); | 1083 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); |
1063 ASSERT(editable); | 1084 ASSERT(editable); |
1064 RefPtrWillBeRawPtr<Range> range = PlainTextRange(location, location + length
).createRange(*editable); | 1085 RefPtrWillBeRawPtr<Range> range = PlainTextRange(location, location + length
).createRange(*editable); |
1065 if (!range) | 1086 if (!range) |
1066 return false; | 1087 return false; |
1067 IntRect intRect = frame()->editor().firstRectForRange(range.get()); | 1088 IntRect intRect = frame()->editor().firstRectForRange(range.get()); |
1068 rect = WebRect(intRect); | 1089 rect = WebRect(intRect); |
1069 rect = frame()->view()->contentsToWindow(rect); | 1090 rect = frame()->view()->contentsToWindow(rect); |
1070 return true; | 1091 return true; |
1071 } | 1092 } |
1072 | 1093 |
1073 size_t WebFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const | 1094 size_t WebLocalFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const |
1074 { | 1095 { |
1075 if (!frame()) | 1096 if (!frame()) |
1076 return kNotFound; | 1097 return kNotFound; |
1077 | 1098 |
1078 IntPoint point = frame()->view()->windowToContents(webPoint); | 1099 IntPoint point = frame()->view()->windowToContents(webPoint); |
1079 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, H
itTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndO
ftenMisusedDisallowShadowContent); | 1100 HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, H
itTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndO
ftenMisusedDisallowShadowContent); |
1080 RefPtrWillBeRawPtr<Range> range = frame()->rangeForPoint(result.roundedPoint
InInnerNodeFrame()); | 1101 RefPtrWillBeRawPtr<Range> range = frame()->rangeForPoint(result.roundedPoint
InInnerNodeFrame()); |
1081 if (!range) | 1102 if (!range) |
1082 return kNotFound; | 1103 return kNotFound; |
1083 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); | 1104 Element* editable = frame()->selection().rootEditableElementOrDocumentElemen
t(); |
1084 ASSERT(editable); | 1105 ASSERT(editable); |
1085 return PlainTextRange::create(*editable, *range.get()).start(); | 1106 return PlainTextRange::create(*editable, *range.get()).start(); |
1086 } | 1107 } |
1087 | 1108 |
1088 bool WebFrameImpl::executeCommand(const WebString& name, const WebNode& node) | 1109 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebNode& nod
e) |
1089 { | 1110 { |
1090 ASSERT(frame()); | 1111 ASSERT(frame()); |
1091 | 1112 |
1092 if (name.length() <= 2) | 1113 if (name.length() <= 2) |
1093 return false; | 1114 return false; |
1094 | 1115 |
1095 // Since we don't have NSControl, we will convert the format of command | 1116 // Since we don't have NSControl, we will convert the format of command |
1096 // string and call the function on Editor directly. | 1117 // string and call the function on Editor directly. |
1097 String command = name; | 1118 String command = name; |
1098 | 1119 |
(...skipping 27 matching lines...) Expand all Loading... |
1126 // Wee need to pass false here or else the currently selected word will
never be skipped. | 1147 // Wee need to pass false here or else the currently selected word will
never be skipped. |
1127 frame()->spellChecker().advanceToNextMisspelling(false); | 1148 frame()->spellChecker().advanceToNextMisspelling(false); |
1128 } else if (command == "ToggleSpellPanel") { | 1149 } else if (command == "ToggleSpellPanel") { |
1129 frame()->spellChecker().showSpellingGuessPanel(); | 1150 frame()->spellChecker().showSpellingGuessPanel(); |
1130 } else { | 1151 } else { |
1131 result = frame()->editor().command(command).execute(); | 1152 result = frame()->editor().command(command).execute(); |
1132 } | 1153 } |
1133 return result; | 1154 return result; |
1134 } | 1155 } |
1135 | 1156 |
1136 bool WebFrameImpl::executeCommand(const WebString& name, const WebString& value,
const WebNode& node) | 1157 bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebString& v
alue, const WebNode& node) |
1137 { | 1158 { |
1138 ASSERT(frame()); | 1159 ASSERT(frame()); |
1139 String webName = name; | 1160 String webName = name; |
1140 | 1161 |
1141 WebPluginContainerImpl* pluginContainer = pluginContainerFromNode(frame(), n
ode); | 1162 WebPluginContainerImpl* pluginContainer = pluginContainerFromNode(frame(), n
ode); |
1142 if (pluginContainer && pluginContainer->executeEditCommand(name, value)) | 1163 if (pluginContainer && pluginContainer->executeEditCommand(name, value)) |
1143 return true; | 1164 return true; |
1144 | 1165 |
1145 // moveToBeginningOfDocument and moveToEndfDocument are only handled by WebK
it for editable nodes. | 1166 // moveToBeginningOfDocument and moveToEndfDocument are only handled by WebK
it for editable nodes. |
1146 if (!frame()->editor().canEdit() && webName == "moveToBeginningOfDocument") | 1167 if (!frame()->editor().canEdit() && webName == "moveToBeginningOfDocument") |
1147 return viewImpl()->bubblingScroll(ScrollUp, ScrollByDocument); | 1168 return viewImpl()->bubblingScroll(ScrollUp, ScrollByDocument); |
1148 | 1169 |
1149 if (!frame()->editor().canEdit() && webName == "moveToEndOfDocument") | 1170 if (!frame()->editor().canEdit() && webName == "moveToEndOfDocument") |
1150 return viewImpl()->bubblingScroll(ScrollDown, ScrollByDocument); | 1171 return viewImpl()->bubblingScroll(ScrollDown, ScrollByDocument); |
1151 | 1172 |
1152 if (webName == "showGuessPanel") { | 1173 if (webName == "showGuessPanel") { |
1153 frame()->spellChecker().showSpellingGuessPanel(); | 1174 frame()->spellChecker().showSpellingGuessPanel(); |
1154 return true; | 1175 return true; |
1155 } | 1176 } |
1156 | 1177 |
1157 return frame()->editor().command(webName).execute(value); | 1178 return frame()->editor().command(webName).execute(value); |
1158 } | 1179 } |
1159 | 1180 |
1160 bool WebFrameImpl::isCommandEnabled(const WebString& name) const | 1181 bool WebLocalFrameImpl::isCommandEnabled(const WebString& name) const |
1161 { | 1182 { |
1162 ASSERT(frame()); | 1183 ASSERT(frame()); |
1163 return frame()->editor().command(name).isEnabled(); | 1184 return frame()->editor().command(name).isEnabled(); |
1164 } | 1185 } |
1165 | 1186 |
1166 void WebFrameImpl::enableContinuousSpellChecking(bool enable) | 1187 void WebLocalFrameImpl::enableContinuousSpellChecking(bool enable) |
1167 { | 1188 { |
1168 if (enable == isContinuousSpellCheckingEnabled()) | 1189 if (enable == isContinuousSpellCheckingEnabled()) |
1169 return; | 1190 return; |
1170 frame()->spellChecker().toggleContinuousSpellChecking(); | 1191 frame()->spellChecker().toggleContinuousSpellChecking(); |
1171 } | 1192 } |
1172 | 1193 |
1173 bool WebFrameImpl::isContinuousSpellCheckingEnabled() const | 1194 bool WebLocalFrameImpl::isContinuousSpellCheckingEnabled() const |
1174 { | 1195 { |
1175 return frame()->spellChecker().isContinuousSpellCheckingEnabled(); | 1196 return frame()->spellChecker().isContinuousSpellCheckingEnabled(); |
1176 } | 1197 } |
1177 | 1198 |
1178 void WebFrameImpl::requestTextChecking(const WebElement& webElement) | 1199 void WebLocalFrameImpl::requestTextChecking(const WebElement& webElement) |
1179 { | 1200 { |
1180 if (webElement.isNull()) | 1201 if (webElement.isNull()) |
1181 return; | 1202 return; |
1182 frame()->spellChecker().requestTextChecking(*webElement.constUnwrap<Element>
()); | 1203 frame()->spellChecker().requestTextChecking(*webElement.constUnwrap<Element>
()); |
1183 } | 1204 } |
1184 | 1205 |
1185 void WebFrameImpl::replaceMisspelledRange(const WebString& text) | 1206 void WebLocalFrameImpl::replaceMisspelledRange(const WebString& text) |
1186 { | 1207 { |
1187 // If this caret selection has two or more markers, this function replace th
e range covered by the first marker with the specified word as Microsoft Word do
es. | 1208 // If this caret selection has two or more markers, this function replace th
e range covered by the first marker with the specified word as Microsoft Word do
es. |
1188 if (pluginContainerFromFrame(frame())) | 1209 if (pluginContainerFromFrame(frame())) |
1189 return; | 1210 return; |
1190 RefPtrWillBeRawPtr<Range> caretRange = frame()->selection().toNormalizedRang
e(); | 1211 RefPtrWillBeRawPtr<Range> caretRange = frame()->selection().toNormalizedRang
e(); |
1191 if (!caretRange) | 1212 if (!caretRange) |
1192 return; | 1213 return; |
1193 Vector<DocumentMarker*> markers = frame()->document()->markers().markersInRa
nge(caretRange.get(), DocumentMarker::MisspellingMarkers()); | 1214 Vector<DocumentMarker*> markers = frame()->document()->markers().markersInRa
nge(caretRange.get(), DocumentMarker::MisspellingMarkers()); |
1194 if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset
()) | 1215 if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset
()) |
1195 return; | 1216 return; |
1196 RefPtrWillBeRawPtr<Range> markerRange = Range::create(caretRange->ownerDocum
ent(), caretRange->startContainer(), markers[0]->startOffset(), caretRange->endC
ontainer(), markers[0]->endOffset()); | 1217 RefPtrWillBeRawPtr<Range> markerRange = Range::create(caretRange->ownerDocum
ent(), caretRange->startContainer(), markers[0]->startOffset(), caretRange->endC
ontainer(), markers[0]->endOffset()); |
1197 if (!markerRange) | 1218 if (!markerRange) |
1198 return; | 1219 return; |
1199 frame()->selection().setSelection(VisibleSelection(markerRange.get()), Chara
cterGranularity); | 1220 frame()->selection().setSelection(VisibleSelection(markerRange.get()), Chara
cterGranularity); |
1200 frame()->editor().replaceSelectionWithText(text, false, false); | 1221 frame()->editor().replaceSelectionWithText(text, false, false); |
1201 } | 1222 } |
1202 | 1223 |
1203 void WebFrameImpl::removeSpellingMarkers() | 1224 void WebLocalFrameImpl::removeSpellingMarkers() |
1204 { | 1225 { |
1205 frame()->document()->markers().removeMarkers(DocumentMarker::MisspellingMark
ers()); | 1226 frame()->document()->markers().removeMarkers(DocumentMarker::MisspellingMark
ers()); |
1206 } | 1227 } |
1207 | 1228 |
1208 bool WebFrameImpl::hasSelection() const | 1229 bool WebLocalFrameImpl::hasSelection() const |
1209 { | 1230 { |
1210 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); | 1231 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); |
1211 if (pluginContainer) | 1232 if (pluginContainer) |
1212 return pluginContainer->plugin()->hasSelection(); | 1233 return pluginContainer->plugin()->hasSelection(); |
1213 | 1234 |
1214 // frame()->selection()->isNone() never returns true. | 1235 // frame()->selection()->isNone() never returns true. |
1215 return frame()->selection().start() != frame()->selection().end(); | 1236 return frame()->selection().start() != frame()->selection().end(); |
1216 } | 1237 } |
1217 | 1238 |
1218 WebRange WebFrameImpl::selectionRange() const | 1239 WebRange WebLocalFrameImpl::selectionRange() const |
1219 { | 1240 { |
1220 return frame()->selection().toNormalizedRange(); | 1241 return frame()->selection().toNormalizedRange(); |
1221 } | 1242 } |
1222 | 1243 |
1223 WebString WebFrameImpl::selectionAsText() const | 1244 WebString WebLocalFrameImpl::selectionAsText() const |
1224 { | 1245 { |
1225 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); | 1246 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); |
1226 if (pluginContainer) | 1247 if (pluginContainer) |
1227 return pluginContainer->plugin()->selectionAsText(); | 1248 return pluginContainer->plugin()->selectionAsText(); |
1228 | 1249 |
1229 RefPtrWillBeRawPtr<Range> range = frame()->selection().toNormalizedRange(); | 1250 RefPtrWillBeRawPtr<Range> range = frame()->selection().toNormalizedRange(); |
1230 if (!range) | 1251 if (!range) |
1231 return WebString(); | 1252 return WebString(); |
1232 | 1253 |
1233 String text = range->text(); | 1254 String text = range->text(); |
1234 #if OS(WIN) | 1255 #if OS(WIN) |
1235 replaceNewlinesWithWindowsStyleNewlines(text); | 1256 replaceNewlinesWithWindowsStyleNewlines(text); |
1236 #endif | 1257 #endif |
1237 replaceNBSPWithSpace(text); | 1258 replaceNBSPWithSpace(text); |
1238 return text; | 1259 return text; |
1239 } | 1260 } |
1240 | 1261 |
1241 WebString WebFrameImpl::selectionAsMarkup() const | 1262 WebString WebLocalFrameImpl::selectionAsMarkup() const |
1242 { | 1263 { |
1243 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); | 1264 WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame()); |
1244 if (pluginContainer) | 1265 if (pluginContainer) |
1245 return pluginContainer->plugin()->selectionAsMarkup(); | 1266 return pluginContainer->plugin()->selectionAsMarkup(); |
1246 | 1267 |
1247 RefPtrWillBeRawPtr<Range> range = frame()->selection().toNormalizedRange(); | 1268 RefPtrWillBeRawPtr<Range> range = frame()->selection().toNormalizedRange(); |
1248 if (!range) | 1269 if (!range) |
1249 return WebString(); | 1270 return WebString(); |
1250 | 1271 |
1251 return createMarkup(range.get(), 0, AnnotateForInterchange, false, ResolveNo
nLocalURLs); | 1272 return createMarkup(range.get(), 0, AnnotateForInterchange, false, ResolveNo
nLocalURLs); |
1252 } | 1273 } |
1253 | 1274 |
1254 void WebFrameImpl::selectWordAroundPosition(LocalFrame* frame, VisiblePosition p
osition) | 1275 void WebLocalFrameImpl::selectWordAroundPosition(LocalFrame* frame, VisiblePosit
ion position) |
1255 { | 1276 { |
1256 VisibleSelection selection(position); | 1277 VisibleSelection selection(position); |
1257 selection.expandUsingGranularity(WordGranularity); | 1278 selection.expandUsingGranularity(WordGranularity); |
1258 | 1279 |
1259 TextGranularity granularity = selection.isRange() ? WordGranularity : Charac
terGranularity; | 1280 TextGranularity granularity = selection.isRange() ? WordGranularity : Charac
terGranularity; |
1260 frame->selection().setSelection(selection, granularity); | 1281 frame->selection().setSelection(selection, granularity); |
1261 } | 1282 } |
1262 | 1283 |
1263 bool WebFrameImpl::selectWordAroundCaret() | 1284 bool WebLocalFrameImpl::selectWordAroundCaret() |
1264 { | 1285 { |
1265 FrameSelection& selection = frame()->selection(); | 1286 FrameSelection& selection = frame()->selection(); |
1266 ASSERT(!selection.isNone()); | 1287 ASSERT(!selection.isNone()); |
1267 if (selection.isNone() || selection.isRange()) | 1288 if (selection.isNone() || selection.isRange()) |
1268 return false; | 1289 return false; |
1269 selectWordAroundPosition(frame(), selection.selection().visibleStart()); | 1290 selectWordAroundPosition(frame(), selection.selection().visibleStart()); |
1270 return true; | 1291 return true; |
1271 } | 1292 } |
1272 | 1293 |
1273 void WebFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent) | 1294 void WebLocalFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent
) |
1274 { | 1295 { |
1275 moveRangeSelection(base, extent); | 1296 moveRangeSelection(base, extent); |
1276 } | 1297 } |
1277 | 1298 |
1278 void WebFrameImpl::selectRange(const WebRange& webRange) | 1299 void WebLocalFrameImpl::selectRange(const WebRange& webRange) |
1279 { | 1300 { |
1280 if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Ran
ge> >(webRange)) | 1301 if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Ran
ge> >(webRange)) |
1281 frame()->selection().setSelectedRange(range.get(), WebCore::VP_DEFAULT_A
FFINITY, false); | 1302 frame()->selection().setSelectedRange(range.get(), WebCore::VP_DEFAULT_A
FFINITY, false); |
1282 } | 1303 } |
1283 | 1304 |
1284 void WebFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint& exte
nt) | 1305 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint&
extent) |
1285 { | 1306 { |
1286 VisiblePosition basePosition = visiblePositionForWindowPoint(base); | 1307 VisiblePosition basePosition = visiblePositionForWindowPoint(base); |
1287 VisiblePosition extentPosition = visiblePositionForWindowPoint(extent); | 1308 VisiblePosition extentPosition = visiblePositionForWindowPoint(extent); |
1288 VisibleSelection newSelection = VisibleSelection(basePosition, extentPositio
n); | 1309 VisibleSelection newSelection = VisibleSelection(basePosition, extentPositio
n); |
1289 frame()->selection().setSelection(newSelection, CharacterGranularity); | 1310 frame()->selection().setSelection(newSelection, CharacterGranularity); |
1290 } | 1311 } |
1291 | 1312 |
1292 void WebFrameImpl::moveCaretSelection(const WebPoint& point) | 1313 void WebLocalFrameImpl::moveCaretSelection(const WebPoint& point) |
1293 { | 1314 { |
1294 Element* editable = frame()->selection().rootEditableElement(); | 1315 Element* editable = frame()->selection().rootEditableElement(); |
1295 if (!editable) | 1316 if (!editable) |
1296 return; | 1317 return; |
1297 | 1318 |
1298 VisiblePosition position = visiblePositionForWindowPoint(point); | 1319 VisiblePosition position = visiblePositionForWindowPoint(point); |
1299 frame()->selection().moveTo(position, UserTriggered); | 1320 frame()->selection().moveTo(position, UserTriggered); |
1300 } | 1321 } |
1301 | 1322 |
1302 bool WebFrameImpl::setEditableSelectionOffsets(int start, int end) | 1323 bool WebLocalFrameImpl::setEditableSelectionOffsets(int start, int end) |
1303 { | 1324 { |
1304 return frame()->inputMethodController().setEditableSelectionOffsets(PlainTex
tRange(start, end)); | 1325 return frame()->inputMethodController().setEditableSelectionOffsets(PlainTex
tRange(start, end)); |
1305 } | 1326 } |
1306 | 1327 |
1307 bool WebFrameImpl::setCompositionFromExistingText(int compositionStart, int comp
ositionEnd, const WebVector<WebCompositionUnderline>& underlines) | 1328 bool WebLocalFrameImpl::setCompositionFromExistingText(int compositionStart, int
compositionEnd, const WebVector<WebCompositionUnderline>& underlines) |
1308 { | 1329 { |
1309 if (!frame()->editor().canEdit()) | 1330 if (!frame()->editor().canEdit()) |
1310 return false; | 1331 return false; |
1311 | 1332 |
1312 InputMethodController& inputMethodController = frame()->inputMethodControlle
r(); | 1333 InputMethodController& inputMethodController = frame()->inputMethodControlle
r(); |
1313 inputMethodController.cancelComposition(); | 1334 inputMethodController.cancelComposition(); |
1314 | 1335 |
1315 if (compositionStart == compositionEnd) | 1336 if (compositionStart == compositionEnd) |
1316 return true; | 1337 return true; |
1317 | 1338 |
1318 inputMethodController.setCompositionFromExistingText(CompositionUnderlineVec
torBuilder(underlines), compositionStart, compositionEnd); | 1339 inputMethodController.setCompositionFromExistingText(CompositionUnderlineVec
torBuilder(underlines), compositionStart, compositionEnd); |
1319 | 1340 |
1320 return true; | 1341 return true; |
1321 } | 1342 } |
1322 | 1343 |
1323 void WebFrameImpl::extendSelectionAndDelete(int before, int after) | 1344 void WebLocalFrameImpl::extendSelectionAndDelete(int before, int after) |
1324 { | 1345 { |
1325 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported()) { | 1346 if (WebPlugin* plugin = focusedPluginIfInputMethodSupported()) { |
1326 plugin->extendSelectionAndDelete(before, after); | 1347 plugin->extendSelectionAndDelete(before, after); |
1327 return; | 1348 return; |
1328 } | 1349 } |
1329 frame()->inputMethodController().extendSelectionAndDelete(before, after); | 1350 frame()->inputMethodController().extendSelectionAndDelete(before, after); |
1330 } | 1351 } |
1331 | 1352 |
1332 void WebFrameImpl::setCaretVisible(bool visible) | 1353 void WebLocalFrameImpl::setCaretVisible(bool visible) |
1333 { | 1354 { |
1334 frame()->selection().setCaretVisible(visible); | 1355 frame()->selection().setCaretVisible(visible); |
1335 } | 1356 } |
1336 | 1357 |
1337 VisiblePosition WebFrameImpl::visiblePositionForWindowPoint(const WebPoint& poin
t) | 1358 VisiblePosition WebLocalFrameImpl::visiblePositionForWindowPoint(const WebPoint&
point) |
1338 { | 1359 { |
1339 FloatPoint unscaledPoint(point); | 1360 FloatPoint unscaledPoint(point); |
1340 unscaledPoint.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFact
or()); | 1361 unscaledPoint.scale(1 / view()->pageScaleFactor(), 1 / view()->pageScaleFact
or()); |
1341 | 1362 |
1342 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::Confusi
ngAndOftenMisusedDisallowShadowContent; | 1363 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::Confusi
ngAndOftenMisusedDisallowShadowContent; |
1343 HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(unsca
ledPoint))); | 1364 HitTestResult result(frame()->view()->windowToContents(roundedIntPoint(unsca
ledPoint))); |
1344 frame()->document()->renderView()->layer()->hitTest(request, result); | 1365 frame()->document()->renderView()->layer()->hitTest(request, result); |
1345 | 1366 |
1346 if (Node* node = result.targetNode()) | 1367 if (Node* node = result.targetNode()) |
1347 return frame()->selection().selection().visiblePositionRespectingEditing
Boundary(result.localPoint(), node); | 1368 return frame()->selection().selection().visiblePositionRespectingEditing
Boundary(result.localPoint(), node); |
1348 return VisiblePosition(); | 1369 return VisiblePosition(); |
1349 } | 1370 } |
1350 | 1371 |
1351 WebPlugin* WebFrameImpl::focusedPluginIfInputMethodSupported() | 1372 WebPlugin* WebLocalFrameImpl::focusedPluginIfInputMethodSupported() |
1352 { | 1373 { |
1353 WebPluginContainerImpl* container = WebFrameImpl::pluginContainerFromNode(fr
ame(), WebNode(frame()->document()->focusedElement())); | 1374 WebPluginContainerImpl* container = WebLocalFrameImpl::pluginContainerFromNo
de(frame(), WebNode(frame()->document()->focusedElement())); |
1354 if (container && container->supportsInputMethod()) | 1375 if (container && container->supportsInputMethod()) |
1355 return container->plugin(); | 1376 return container->plugin(); |
1356 return 0; | 1377 return 0; |
1357 } | 1378 } |
1358 | 1379 |
1359 NotificationPresenterImpl* WebFrameImpl::notificationPresenterImpl() | 1380 NotificationPresenterImpl* WebLocalFrameImpl::notificationPresenterImpl() |
1360 { | 1381 { |
1361 if (!m_notificationPresenter.isInitialized() && m_client) | 1382 if (!m_notificationPresenter.isInitialized() && m_client) |
1362 m_notificationPresenter.initialize(m_client->notificationPresenter()); | 1383 m_notificationPresenter.initialize(m_client->notificationPresenter()); |
1363 return &m_notificationPresenter; | 1384 return &m_notificationPresenter; |
1364 } | 1385 } |
1365 | 1386 |
1366 int WebFrameImpl::printBegin(const WebPrintParams& printParams, const WebNode& c
onstrainToNode) | 1387 int WebLocalFrameImpl::printBegin(const WebPrintParams& printParams, const WebNo
de& constrainToNode) |
1367 { | 1388 { |
1368 ASSERT(!frame()->document()->isFrameSet()); | 1389 ASSERT(!frame()->document()->isFrameSet()); |
1369 WebPluginContainerImpl* pluginContainer = 0; | 1390 WebPluginContainerImpl* pluginContainer = 0; |
1370 if (constrainToNode.isNull()) { | 1391 if (constrainToNode.isNull()) { |
1371 // If this is a plugin document, check if the plugin supports its own | 1392 // If this is a plugin document, check if the plugin supports its own |
1372 // printing. If it does, we will delegate all printing to that. | 1393 // printing. If it does, we will delegate all printing to that. |
1373 pluginContainer = pluginContainerFromFrame(frame()); | 1394 pluginContainer = pluginContainerFromFrame(frame()); |
1374 } else { | 1395 } else { |
1375 // We only support printing plugin nodes for now. | 1396 // We only support printing plugin nodes for now. |
1376 pluginContainer = toWebPluginContainerImpl(constrainToNode.pluginContain
er()); | 1397 pluginContainer = toWebPluginContainerImpl(constrainToNode.pluginContain
er()); |
1377 } | 1398 } |
1378 | 1399 |
1379 if (pluginContainer && pluginContainer->supportsPaginatedPrint()) | 1400 if (pluginContainer && pluginContainer->supportsPaginatedPrint()) |
1380 m_printContext = adoptPtr(new ChromePluginPrintContext(frame(), pluginCo
ntainer, printParams)); | 1401 m_printContext = adoptPtr(new ChromePluginPrintContext(frame(), pluginCo
ntainer, printParams)); |
1381 else | 1402 else |
1382 m_printContext = adoptPtr(new ChromePrintContext(frame())); | 1403 m_printContext = adoptPtr(new ChromePrintContext(frame())); |
1383 | 1404 |
1384 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width),
static_cast<float>(printParams.printContentArea.height)); | 1405 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width),
static_cast<float>(printParams.printContentArea.height)); |
1385 m_printContext->begin(rect.width(), rect.height()); | 1406 m_printContext->begin(rect.width(), rect.height()); |
1386 float pageHeight; | 1407 float pageHeight; |
1387 // We ignore the overlays calculation for now since they are generated in th
e | 1408 // We ignore the overlays calculation for now since they are generated in th
e |
1388 // browser. pageHeight is actually an output parameter. | 1409 // browser. pageHeight is actually an output parameter. |
1389 m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight); | 1410 m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight); |
1390 | 1411 |
1391 return m_printContext->pageCount(); | 1412 return m_printContext->pageCount(); |
1392 } | 1413 } |
1393 | 1414 |
1394 float WebFrameImpl::getPrintPageShrink(int page) | 1415 float WebLocalFrameImpl::getPrintPageShrink(int page) |
1395 { | 1416 { |
1396 ASSERT(m_printContext && page >= 0); | 1417 ASSERT(m_printContext && page >= 0); |
1397 return m_printContext->getPageShrink(page); | 1418 return m_printContext->getPageShrink(page); |
1398 } | 1419 } |
1399 | 1420 |
1400 float WebFrameImpl::printPage(int page, WebCanvas* canvas) | 1421 float WebLocalFrameImpl::printPage(int page, WebCanvas* canvas) |
1401 { | 1422 { |
1402 #if ENABLE(PRINTING) | 1423 #if ENABLE(PRINTING) |
1403 ASSERT(m_printContext && page >= 0 && frame() && frame()->document()); | 1424 ASSERT(m_printContext && page >= 0 && frame() && frame()->document()); |
1404 | 1425 |
1405 GraphicsContext graphicsContext(canvas); | 1426 GraphicsContext graphicsContext(canvas); |
1406 graphicsContext.setPrinting(true); | 1427 graphicsContext.setPrinting(true); |
1407 return m_printContext->spoolPage(graphicsContext, page); | 1428 return m_printContext->spoolPage(graphicsContext, page); |
1408 #else | 1429 #else |
1409 return 0; | 1430 return 0; |
1410 #endif | 1431 #endif |
1411 } | 1432 } |
1412 | 1433 |
1413 void WebFrameImpl::printEnd() | 1434 void WebLocalFrameImpl::printEnd() |
1414 { | 1435 { |
1415 ASSERT(m_printContext); | 1436 ASSERT(m_printContext); |
1416 m_printContext->end(); | 1437 m_printContext->end(); |
1417 m_printContext.clear(); | 1438 m_printContext.clear(); |
1418 } | 1439 } |
1419 | 1440 |
1420 bool WebFrameImpl::isPrintScalingDisabledForPlugin(const WebNode& node) | 1441 bool WebLocalFrameImpl::isPrintScalingDisabledForPlugin(const WebNode& node) |
1421 { | 1442 { |
1422 WebPluginContainerImpl* pluginContainer = node.isNull() ? pluginContainerFr
omFrame(frame()) : toWebPluginContainerImpl(node.pluginContainer()); | 1443 WebPluginContainerImpl* pluginContainer = node.isNull() ? pluginContainerFr
omFrame(frame()) : toWebPluginContainerImpl(node.pluginContainer()); |
1423 | 1444 |
1424 if (!pluginContainer || !pluginContainer->supportsPaginatedPrint()) | 1445 if (!pluginContainer || !pluginContainer->supportsPaginatedPrint()) |
1425 return false; | 1446 return false; |
1426 | 1447 |
1427 return pluginContainer->isPrintScalingDisabled(); | 1448 return pluginContainer->isPrintScalingDisabled(); |
1428 } | 1449 } |
1429 | 1450 |
1430 bool WebFrameImpl::hasCustomPageSizeStyle(int pageIndex) | 1451 bool WebLocalFrameImpl::hasCustomPageSizeStyle(int pageIndex) |
1431 { | 1452 { |
1432 return frame()->document()->styleForPage(pageIndex)->pageSizeType() != PAGE_
SIZE_AUTO; | 1453 return frame()->document()->styleForPage(pageIndex)->pageSizeType() != PAGE_
SIZE_AUTO; |
1433 } | 1454 } |
1434 | 1455 |
1435 bool WebFrameImpl::isPageBoxVisible(int pageIndex) | 1456 bool WebLocalFrameImpl::isPageBoxVisible(int pageIndex) |
1436 { | 1457 { |
1437 return frame()->document()->isPageBoxVisible(pageIndex); | 1458 return frame()->document()->isPageBoxVisible(pageIndex); |
1438 } | 1459 } |
1439 | 1460 |
1440 void WebFrameImpl::pageSizeAndMarginsInPixels(int pageIndex, WebSize& pageSize,
int& marginTop, int& marginRight, int& marginBottom, int& marginLeft) | 1461 void WebLocalFrameImpl::pageSizeAndMarginsInPixels(int pageIndex, WebSize& pageS
ize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft) |
1441 { | 1462 { |
1442 IntSize size = pageSize; | 1463 IntSize size = pageSize; |
1443 frame()->document()->pageSizeAndMarginsInPixels(pageIndex, size, marginTop,
marginRight, marginBottom, marginLeft); | 1464 frame()->document()->pageSizeAndMarginsInPixels(pageIndex, size, marginTop,
marginRight, marginBottom, marginLeft); |
1444 pageSize = size; | 1465 pageSize = size; |
1445 } | 1466 } |
1446 | 1467 |
1447 WebString WebFrameImpl::pageProperty(const WebString& propertyName, int pageInde
x) | 1468 WebString WebLocalFrameImpl::pageProperty(const WebString& propertyName, int pag
eIndex) |
1448 { | 1469 { |
1449 ASSERT(m_printContext); | 1470 ASSERT(m_printContext); |
1450 return m_printContext->pageProperty(frame(), propertyName.utf8().data(), pag
eIndex); | 1471 return m_printContext->pageProperty(frame(), propertyName.utf8().data(), pag
eIndex); |
1451 } | 1472 } |
1452 | 1473 |
1453 bool WebFrameImpl::find(int identifier, const WebString& searchText, const WebFi
ndOptions& options, bool wrapWithinFrame, WebRect* selectionRect) | 1474 bool WebLocalFrameImpl::find(int identifier, const WebString& searchText, const
WebFindOptions& options, bool wrapWithinFrame, WebRect* selectionRect) |
1454 { | 1475 { |
1455 return ensureTextFinder().find(identifier, searchText, options, wrapWithinFr
ame, selectionRect); | 1476 return ensureTextFinder().find(identifier, searchText, options, wrapWithinFr
ame, selectionRect); |
1456 } | 1477 } |
1457 | 1478 |
1458 void WebFrameImpl::stopFinding(bool clearSelection) | 1479 void WebLocalFrameImpl::stopFinding(bool clearSelection) |
1459 { | 1480 { |
1460 if (m_textFinder) { | 1481 if (m_textFinder) { |
1461 if (!clearSelection) | 1482 if (!clearSelection) |
1462 setFindEndstateFocusAndSelection(); | 1483 setFindEndstateFocusAndSelection(); |
1463 m_textFinder->stopFindingAndClearSelection(); | 1484 m_textFinder->stopFindingAndClearSelection(); |
1464 } | 1485 } |
1465 } | 1486 } |
1466 | 1487 |
1467 void WebFrameImpl::scopeStringMatches(int identifier, const WebString& searchTex
t, const WebFindOptions& options, bool reset) | 1488 void WebLocalFrameImpl::scopeStringMatches(int identifier, const WebString& sear
chText, const WebFindOptions& options, bool reset) |
1468 { | 1489 { |
1469 ensureTextFinder().scopeStringMatches(identifier, searchText, options, reset
); | 1490 ensureTextFinder().scopeStringMatches(identifier, searchText, options, reset
); |
1470 } | 1491 } |
1471 | 1492 |
1472 void WebFrameImpl::cancelPendingScopingEffort() | 1493 void WebLocalFrameImpl::cancelPendingScopingEffort() |
1473 { | 1494 { |
1474 if (m_textFinder) | 1495 if (m_textFinder) |
1475 m_textFinder->cancelPendingScopingEffort(); | 1496 m_textFinder->cancelPendingScopingEffort(); |
1476 } | 1497 } |
1477 | 1498 |
1478 void WebFrameImpl::increaseMatchCount(int count, int identifier) | 1499 void WebLocalFrameImpl::increaseMatchCount(int count, int identifier) |
1479 { | 1500 { |
1480 // This function should only be called on the mainframe. | 1501 // This function should only be called on the mainframe. |
1481 ASSERT(!parent()); | 1502 ASSERT(!parent()); |
1482 ASSERT(m_textFinder); | 1503 ASSERT(m_textFinder); |
1483 m_textFinder->increaseMatchCount(identifier, count); | 1504 m_textFinder->increaseMatchCount(identifier, count); |
1484 } | 1505 } |
1485 | 1506 |
1486 void WebFrameImpl::resetMatchCount() | 1507 void WebLocalFrameImpl::resetMatchCount() |
1487 { | 1508 { |
1488 ASSERT(m_textFinder); | 1509 ASSERT(m_textFinder); |
1489 m_textFinder->resetMatchCount(); | 1510 m_textFinder->resetMatchCount(); |
1490 } | 1511 } |
1491 | 1512 |
1492 void WebFrameImpl::sendOrientationChangeEvent(int orientation) | 1513 void WebLocalFrameImpl::sendOrientationChangeEvent(int orientation) |
1493 { | 1514 { |
1494 if (frame()) | 1515 if (frame()) |
1495 frame()->sendOrientationChangeEvent(orientation); | 1516 frame()->sendOrientationChangeEvent(orientation); |
1496 } | 1517 } |
1497 | 1518 |
1498 void WebFrameImpl::dispatchMessageEventWithOriginCheck(const WebSecurityOrigin&
intendedTargetOrigin, const WebDOMEvent& event) | 1519 void WebLocalFrameImpl::dispatchMessageEventWithOriginCheck(const WebSecurityOri
gin& intendedTargetOrigin, const WebDOMEvent& event) |
1499 { | 1520 { |
1500 ASSERT(!event.isNull()); | 1521 ASSERT(!event.isNull()); |
1501 frame()->domWindow()->dispatchMessageEventWithOriginCheck(intendedTargetOrig
in.get(), event, nullptr); | 1522 frame()->domWindow()->dispatchMessageEventWithOriginCheck(intendedTargetOrig
in.get(), event, nullptr); |
1502 } | 1523 } |
1503 | 1524 |
1504 int WebFrameImpl::findMatchMarkersVersion() const | 1525 int WebLocalFrameImpl::findMatchMarkersVersion() const |
1505 { | 1526 { |
1506 ASSERT(!parent()); | 1527 ASSERT(!parent()); |
1507 | 1528 |
1508 if (m_textFinder) | 1529 if (m_textFinder) |
1509 return m_textFinder->findMatchMarkersVersion(); | 1530 return m_textFinder->findMatchMarkersVersion(); |
1510 return 0; | 1531 return 0; |
1511 } | 1532 } |
1512 | 1533 |
1513 int WebFrameImpl::selectNearestFindMatch(const WebFloatPoint& point, WebRect* se
lectionRect) | 1534 int WebLocalFrameImpl::selectNearestFindMatch(const WebFloatPoint& point, WebRec
t* selectionRect) |
1514 { | 1535 { |
1515 ASSERT(!parent()); | 1536 ASSERT(!parent()); |
1516 ASSERT(m_textFinder); | 1537 ASSERT(m_textFinder); |
1517 return m_textFinder->selectNearestFindMatch(point, selectionRect); | 1538 return m_textFinder->selectNearestFindMatch(point, selectionRect); |
1518 } | 1539 } |
1519 | 1540 |
1520 WebFloatRect WebFrameImpl::activeFindMatchRect() | 1541 WebFloatRect WebLocalFrameImpl::activeFindMatchRect() |
1521 { | 1542 { |
1522 ASSERT(!parent()); | 1543 ASSERT(!parent()); |
1523 | 1544 |
1524 if (m_textFinder) | 1545 if (m_textFinder) |
1525 return m_textFinder->activeFindMatchRect(); | 1546 return m_textFinder->activeFindMatchRect(); |
1526 return WebFloatRect(); | 1547 return WebFloatRect(); |
1527 } | 1548 } |
1528 | 1549 |
1529 void WebFrameImpl::findMatchRects(WebVector<WebFloatRect>& outputRects) | 1550 void WebLocalFrameImpl::findMatchRects(WebVector<WebFloatRect>& outputRects) |
1530 { | 1551 { |
1531 ASSERT(!parent()); | 1552 ASSERT(!parent()); |
1532 ASSERT(m_textFinder); | 1553 ASSERT(m_textFinder); |
1533 m_textFinder->findMatchRects(outputRects); | 1554 m_textFinder->findMatchRects(outputRects); |
1534 } | 1555 } |
1535 | 1556 |
1536 void WebFrameImpl::setTickmarks(const WebVector<WebRect>& tickmarks) | 1557 void WebLocalFrameImpl::setTickmarks(const WebVector<WebRect>& tickmarks) |
1537 { | 1558 { |
1538 if (frameView()) { | 1559 if (frameView()) { |
1539 Vector<IntRect> tickmarksConverted(tickmarks.size()); | 1560 Vector<IntRect> tickmarksConverted(tickmarks.size()); |
1540 for (size_t i = 0; i < tickmarks.size(); ++i) | 1561 for (size_t i = 0; i < tickmarks.size(); ++i) |
1541 tickmarksConverted[i] = tickmarks[i]; | 1562 tickmarksConverted[i] = tickmarks[i]; |
1542 frameView()->setTickmarks(tickmarksConverted); | 1563 frameView()->setTickmarks(tickmarksConverted); |
1543 invalidateScrollbar(); | 1564 invalidateScrollbar(); |
1544 } | 1565 } |
1545 } | 1566 } |
1546 | 1567 |
1547 WebString WebFrameImpl::contentAsText(size_t maxChars) const | 1568 WebString WebLocalFrameImpl::contentAsText(size_t maxChars) const |
1548 { | 1569 { |
1549 if (!frame()) | 1570 if (!frame()) |
1550 return WebString(); | 1571 return WebString(); |
1551 StringBuilder text; | 1572 StringBuilder text; |
1552 frameContentAsPlainText(maxChars, frame(), text); | 1573 frameContentAsPlainText(maxChars, frame(), text); |
1553 return text.toString(); | 1574 return text.toString(); |
1554 } | 1575 } |
1555 | 1576 |
1556 WebString WebFrameImpl::contentAsMarkup() const | 1577 WebString WebLocalFrameImpl::contentAsMarkup() const |
1557 { | 1578 { |
1558 if (!frame()) | 1579 if (!frame()) |
1559 return WebString(); | 1580 return WebString(); |
1560 return createFullMarkup(frame()->document()); | 1581 return createFullMarkup(frame()->document()); |
1561 } | 1582 } |
1562 | 1583 |
1563 WebString WebFrameImpl::renderTreeAsText(RenderAsTextControls toShow) const | 1584 WebString WebLocalFrameImpl::renderTreeAsText(RenderAsTextControls toShow) const |
1564 { | 1585 { |
1565 RenderAsTextBehavior behavior = RenderAsTextBehaviorNormal; | 1586 RenderAsTextBehavior behavior = RenderAsTextBehaviorNormal; |
1566 | 1587 |
1567 if (toShow & RenderAsTextDebug) | 1588 if (toShow & RenderAsTextDebug) |
1568 behavior |= RenderAsTextShowCompositedLayers | RenderAsTextShowAddresses
| RenderAsTextShowIDAndClass | RenderAsTextShowLayerNesting; | 1589 behavior |= RenderAsTextShowCompositedLayers | RenderAsTextShowAddresses
| RenderAsTextShowIDAndClass | RenderAsTextShowLayerNesting; |
1569 | 1590 |
1570 if (toShow & RenderAsTextPrinting) | 1591 if (toShow & RenderAsTextPrinting) |
1571 behavior |= RenderAsTextPrintingMode; | 1592 behavior |= RenderAsTextPrintingMode; |
1572 | 1593 |
1573 return externalRepresentation(frame(), behavior); | 1594 return externalRepresentation(frame(), behavior); |
1574 } | 1595 } |
1575 | 1596 |
1576 WebString WebFrameImpl::markerTextForListItem(const WebElement& webElement) cons
t | 1597 WebString WebLocalFrameImpl::markerTextForListItem(const WebElement& webElement)
const |
1577 { | 1598 { |
1578 return WebCore::markerTextForListItem(const_cast<Element*>(webElement.constU
nwrap<Element>())); | 1599 return WebCore::markerTextForListItem(const_cast<Element*>(webElement.constU
nwrap<Element>())); |
1579 } | 1600 } |
1580 | 1601 |
1581 void WebFrameImpl::printPagesWithBoundaries(WebCanvas* canvas, const WebSize& pa
geSizeInPixels) | 1602 void WebLocalFrameImpl::printPagesWithBoundaries(WebCanvas* canvas, const WebSiz
e& pageSizeInPixels) |
1582 { | 1603 { |
1583 ASSERT(m_printContext); | 1604 ASSERT(m_printContext); |
1584 | 1605 |
1585 GraphicsContext graphicsContext(canvas); | 1606 GraphicsContext graphicsContext(canvas); |
1586 graphicsContext.setPrinting(true); | 1607 graphicsContext.setPrinting(true); |
1587 | 1608 |
1588 m_printContext->spoolAllPagesWithBoundaries(graphicsContext, FloatSize(pageS
izeInPixels.width, pageSizeInPixels.height)); | 1609 m_printContext->spoolAllPagesWithBoundaries(graphicsContext, FloatSize(pageS
izeInPixels.width, pageSizeInPixels.height)); |
1589 } | 1610 } |
1590 | 1611 |
1591 WebRect WebFrameImpl::selectionBoundsRect() const | 1612 WebRect WebLocalFrameImpl::selectionBoundsRect() const |
1592 { | 1613 { |
1593 return hasSelection() ? WebRect(IntRect(frame()->selection().bounds(false)))
: WebRect(); | 1614 return hasSelection() ? WebRect(IntRect(frame()->selection().bounds(false)))
: WebRect(); |
1594 } | 1615 } |
1595 | 1616 |
1596 bool WebFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) cons
t | 1617 bool WebLocalFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length)
const |
1597 { | 1618 { |
1598 if (!frame()) | 1619 if (!frame()) |
1599 return false; | 1620 return false; |
1600 return frame()->spellChecker().selectionStartHasMarkerFor(DocumentMarker::Sp
elling, from, length); | 1621 return frame()->spellChecker().selectionStartHasMarkerFor(DocumentMarker::Sp
elling, from, length); |
1601 } | 1622 } |
1602 | 1623 |
1603 WebString WebFrameImpl::layerTreeAsText(bool showDebugInfo) const | 1624 WebString WebLocalFrameImpl::layerTreeAsText(bool showDebugInfo) const |
1604 { | 1625 { |
1605 if (!frame()) | 1626 if (!frame()) |
1606 return WebString(); | 1627 return WebString(); |
1607 | 1628 |
1608 return WebString(frame()->layerTreeAsText(showDebugInfo ? LayerTreeIncludesD
ebugInfo : LayerTreeNormal)); | 1629 return WebString(frame()->layerTreeAsText(showDebugInfo ? LayerTreeIncludesD
ebugInfo : LayerTreeNormal)); |
1609 } | 1630 } |
1610 | 1631 |
1611 // WebFrameImpl public --------------------------------------------------------- | 1632 // WebLocalFrameImpl public ----------------------------------------------------
----- |
1612 | 1633 |
1613 WebLocalFrame* WebLocalFrame::create(WebFrameClient* client) | 1634 WebLocalFrame* WebLocalFrame::create(WebFrameClient* client) |
1614 { | 1635 { |
1615 return WebFrameImpl::create(client); | 1636 return WebLocalFrameImpl::create(client); |
1616 } | 1637 } |
1617 | 1638 |
1618 WebFrameImpl* WebFrameImpl::create(WebFrameClient* client) | 1639 WebLocalFrameImpl* WebLocalFrameImpl::create(WebFrameClient* client) |
1619 { | 1640 { |
1620 return adoptRef(new WebFrameImpl(client)).leakRef(); | 1641 return adoptRef(new WebLocalFrameImpl(client)).leakRef(); |
1621 } | 1642 } |
1622 | 1643 |
1623 WebFrameImpl::WebFrameImpl(WebFrameClient* client) | 1644 WebLocalFrameImpl::WebLocalFrameImpl(WebFrameClient* client) |
1624 : m_frameLoaderClientImpl(this) | 1645 : m_frameLoaderClientImpl(this) |
1625 , m_parent(0) | 1646 , m_parent(0) |
1626 , m_previousSibling(0) | 1647 , m_previousSibling(0) |
1627 , m_nextSibling(0) | 1648 , m_nextSibling(0) |
1628 , m_firstChild(0) | 1649 , m_firstChild(0) |
1629 , m_lastChild(0) | 1650 , m_lastChild(0) |
1630 , m_opener(0) | 1651 , m_opener(0) |
1631 , m_client(client) | 1652 , m_client(client) |
1632 , m_permissionClient(0) | 1653 , m_permissionClient(0) |
1633 , m_inputEventsScaleFactorForEmulation(1) | 1654 , m_inputEventsScaleFactorForEmulation(1) |
1634 { | 1655 { |
1635 blink::Platform::current()->incrementStatsCounter(webFrameActiveCount); | 1656 blink::Platform::current()->incrementStatsCounter(webFrameActiveCount); |
1636 frameCount++; | 1657 frameCount++; |
1637 } | 1658 } |
1638 | 1659 |
1639 WebFrameImpl::~WebFrameImpl() | 1660 WebLocalFrameImpl::~WebLocalFrameImpl() |
1640 { | 1661 { |
1641 HashSet<WebFrameImpl*>::iterator end = m_openedFrames.end(); | 1662 HashSet<WebLocalFrameImpl*>::iterator end = m_openedFrames.end(); |
1642 for (HashSet<WebFrameImpl*>::iterator it = m_openedFrames.begin(); it != end
; ++it) | 1663 for (HashSet<WebLocalFrameImpl*>::iterator it = m_openedFrames.begin(); it !
= end; ++it) |
1643 (*it)->m_opener = 0; | 1664 (*it)->m_opener = 0; |
1644 | 1665 |
1645 blink::Platform::current()->decrementStatsCounter(webFrameActiveCount); | 1666 blink::Platform::current()->decrementStatsCounter(webFrameActiveCount); |
1646 frameCount--; | 1667 frameCount--; |
1647 | 1668 |
1648 cancelPendingScopingEffort(); | 1669 cancelPendingScopingEffort(); |
1649 } | 1670 } |
1650 | 1671 |
1651 void WebFrameImpl::setWebCoreFrame(PassRefPtr<WebCore::LocalFrame> frame) | 1672 void WebLocalFrameImpl::setWebCoreFrame(PassRefPtr<WebCore::LocalFrame> frame) |
1652 { | 1673 { |
1653 m_frame = frame; | 1674 m_frame = frame; |
1654 | 1675 |
1655 // FIXME: we shouldn't add overhead to every frame by registering these obje
cts when they're not used. | 1676 // FIXME: we shouldn't add overhead to every frame by registering these obje
cts when they're not used. |
1656 if (m_frame) | 1677 if (m_frame) |
1657 provideNotification(*m_frame, notificationPresenterImpl()); | 1678 provideNotification(*m_frame, notificationPresenterImpl()); |
1658 } | 1679 } |
1659 | 1680 |
1660 void WebFrameImpl::initializeAsMainFrame(WebCore::Page* page) | 1681 void WebLocalFrameImpl::initializeAsMainFrame(WebCore::Page* page) |
1661 { | 1682 { |
1662 setWebCoreFrame(LocalFrame::create(&m_frameLoaderClientImpl, &page->frameHos
t(), 0)); | 1683 setWebCoreFrame(LocalFrame::create(&m_frameLoaderClientImpl, &page->frameHos
t(), 0)); |
1663 | 1684 |
1664 // We must call init() after m_frame is assigned because it is referenced | 1685 // We must call init() after m_frame is assigned because it is referenced |
1665 // during init(). | 1686 // during init(). |
1666 m_frame->init(); | 1687 m_frame->init(); |
1667 } | 1688 } |
1668 | 1689 |
1669 PassRefPtr<LocalFrame> WebFrameImpl::createChildFrame(const FrameLoadRequest& re
quest, HTMLFrameOwnerElement* ownerElement) | 1690 PassRefPtr<LocalFrame> WebLocalFrameImpl::createChildFrame(const FrameLoadReques
t& request, HTMLFrameOwnerElement* ownerElement) |
1670 { | 1691 { |
1671 ASSERT(m_client); | 1692 ASSERT(m_client); |
1672 WebFrameImpl* webframe = toWebFrameImpl(m_client->createChildFrame(this, req
uest.frameName())); | 1693 WebLocalFrameImpl* webframe = toWebLocalFrameImpl(m_client->createChildFrame
(this, request.frameName())); |
1673 if (!webframe) | 1694 if (!webframe) |
1674 return nullptr; | 1695 return nullptr; |
1675 | 1696 |
1676 RefPtr<LocalFrame> childFrame = LocalFrame::create(&webframe->m_frameLoaderC
lientImpl, frame()->host(), ownerElement); | 1697 RefPtr<LocalFrame> childFrame = LocalFrame::create(&webframe->m_frameLoaderC
lientImpl, frame()->host(), ownerElement); |
1677 webframe->setWebCoreFrame(childFrame); | 1698 webframe->setWebCoreFrame(childFrame); |
1678 | 1699 |
1679 // FIXME: Using subResourceAttributeName as fallback is not a perfect | 1700 // FIXME: Using subResourceAttributeName as fallback is not a perfect |
1680 // solution. subResourceAttributeName returns just one attribute name. The | 1701 // solution. subResourceAttributeName returns just one attribute name. The |
1681 // element might not have the attribute, and there might be other attributes | 1702 // element might not have the attribute, and there might be other attributes |
1682 // which can identify the element. | 1703 // which can identify the element. |
(...skipping 28 matching lines...) Expand all Loading... |
1711 // A synchronous navigation (about:blank) would have already processed | 1732 // A synchronous navigation (about:blank) would have already processed |
1712 // onload, so it is possible for the frame to have already been destroyed by | 1733 // onload, so it is possible for the frame to have already been destroyed by |
1713 // script in the page. | 1734 // script in the page. |
1714 // NOTE: m_client will be null if this frame has been detached. | 1735 // NOTE: m_client will be null if this frame has been detached. |
1715 if (!childFrame->tree().parent()) | 1736 if (!childFrame->tree().parent()) |
1716 return nullptr; | 1737 return nullptr; |
1717 | 1738 |
1718 return childFrame.release(); | 1739 return childFrame.release(); |
1719 } | 1740 } |
1720 | 1741 |
1721 void WebFrameImpl::didChangeContentsSize(const IntSize& size) | 1742 void WebLocalFrameImpl::didChangeContentsSize(const IntSize& size) |
1722 { | 1743 { |
1723 // This is only possible on the main frame. | 1744 // This is only possible on the main frame. |
1724 if (m_textFinder && m_textFinder->totalMatchCount() > 0) { | 1745 if (m_textFinder && m_textFinder->totalMatchCount() > 0) { |
1725 ASSERT(!parent()); | 1746 ASSERT(!parent()); |
1726 m_textFinder->increaseMarkerVersion(); | 1747 m_textFinder->increaseMarkerVersion(); |
1727 } | 1748 } |
1728 } | 1749 } |
1729 | 1750 |
1730 void WebFrameImpl::createFrameView() | 1751 void WebLocalFrameImpl::createFrameView() |
1731 { | 1752 { |
1732 TRACE_EVENT0("webkit", "WebFrameImpl::createFrameView"); | 1753 TRACE_EVENT0("webkit", "WebLocalFrameImpl::createFrameView"); |
1733 | 1754 |
1734 ASSERT(frame()); // If frame() doesn't exist, we probably didn't init proper
ly. | 1755 ASSERT(frame()); // If frame() doesn't exist, we probably didn't init proper
ly. |
1735 | 1756 |
1736 WebViewImpl* webView = viewImpl(); | 1757 WebViewImpl* webView = viewImpl(); |
1737 bool isMainFrame = webView->mainFrameImpl()->frame() == frame(); | 1758 bool isMainFrame = webView->mainFrameImpl()->frame() == frame(); |
1738 if (isMainFrame) | 1759 if (isMainFrame) |
1739 webView->suppressInvalidations(true); | 1760 webView->suppressInvalidations(true); |
1740 | 1761 |
1741 frame()->createView(webView->size(), webView->baseBackgroundColor(), webView
->isTransparent()); | 1762 frame()->createView(webView->size(), webView->baseBackgroundColor(), webView
->isTransparent()); |
1742 if (webView->shouldAutoResize() && isMainFrame) | 1763 if (webView->shouldAutoResize() && isMainFrame) |
1743 frame()->view()->enableAutoSizeMode(true, webView->minAutoSize(), webVie
w->maxAutoSize()); | 1764 frame()->view()->enableAutoSizeMode(true, webView->minAutoSize(), webVie
w->maxAutoSize()); |
1744 | 1765 |
1745 frame()->view()->setInputEventsTransformForEmulation(m_inputEventsOffsetForE
mulation, m_inputEventsScaleFactorForEmulation); | 1766 frame()->view()->setInputEventsTransformForEmulation(m_inputEventsOffsetForE
mulation, m_inputEventsScaleFactorForEmulation); |
1746 | 1767 |
1747 if (isMainFrame) | 1768 if (isMainFrame) |
1748 webView->suppressInvalidations(false); | 1769 webView->suppressInvalidations(false); |
1749 } | 1770 } |
1750 | 1771 |
1751 WebFrameImpl* WebFrameImpl::fromFrame(LocalFrame* frame) | 1772 WebLocalFrameImpl* WebLocalFrameImpl::fromFrame(LocalFrame* frame) |
1752 { | 1773 { |
1753 if (!frame) | 1774 if (!frame) |
1754 return 0; | 1775 return 0; |
1755 FrameLoaderClient* client = frame->loader().client(); | 1776 FrameLoaderClient* client = frame->loader().client(); |
1756 if (!client || !client->isFrameLoaderClientImpl()) | 1777 if (!client || !client->isFrameLoaderClientImpl()) |
1757 return 0; | 1778 return 0; |
1758 return toFrameLoaderClientImpl(client)->webFrame(); | 1779 return toFrameLoaderClientImpl(client)->webFrame(); |
1759 } | 1780 } |
1760 | 1781 |
1761 WebFrameImpl* WebFrameImpl::fromFrameOwnerElement(Element* element) | 1782 WebLocalFrameImpl* WebLocalFrameImpl::fromFrameOwnerElement(Element* element) |
1762 { | 1783 { |
1763 // FIXME: Why do we check specifically for <iframe> and <frame> here? Why ca
n't we get the WebFrameImpl from an <object> element, for example. | 1784 // FIXME: Why do we check specifically for <iframe> and <frame> here? Why ca
n't we get the WebLocalFrameImpl from an <object> element, for example. |
1764 if (!isHTMLFrameElementBase(element)) | 1785 if (!isHTMLFrameElementBase(element)) |
1765 return 0; | 1786 return 0; |
1766 return fromFrame(toLocalFrame(toHTMLFrameElementBase(element)->contentFrame(
))); | 1787 return fromFrame(toLocalFrame(toHTMLFrameElementBase(element)->contentFrame(
))); |
1767 } | 1788 } |
1768 | 1789 |
1769 WebViewImpl* WebFrameImpl::viewImpl() const | 1790 WebViewImpl* WebLocalFrameImpl::viewImpl() const |
1770 { | 1791 { |
1771 if (!frame()) | 1792 if (!frame()) |
1772 return 0; | 1793 return 0; |
1773 return WebViewImpl::fromPage(frame()->page()); | 1794 return WebViewImpl::fromPage(frame()->page()); |
1774 } | 1795 } |
1775 | 1796 |
1776 WebDataSourceImpl* WebFrameImpl::dataSourceImpl() const | 1797 WebDataSourceImpl* WebLocalFrameImpl::dataSourceImpl() const |
1777 { | 1798 { |
1778 return static_cast<WebDataSourceImpl*>(dataSource()); | 1799 return static_cast<WebDataSourceImpl*>(dataSource()); |
1779 } | 1800 } |
1780 | 1801 |
1781 WebDataSourceImpl* WebFrameImpl::provisionalDataSourceImpl() const | 1802 WebDataSourceImpl* WebLocalFrameImpl::provisionalDataSourceImpl() const |
1782 { | 1803 { |
1783 return static_cast<WebDataSourceImpl*>(provisionalDataSource()); | 1804 return static_cast<WebDataSourceImpl*>(provisionalDataSource()); |
1784 } | 1805 } |
1785 | 1806 |
1786 void WebFrameImpl::setFindEndstateFocusAndSelection() | 1807 void WebLocalFrameImpl::setFindEndstateFocusAndSelection() |
1787 { | 1808 { |
1788 WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); | 1809 WebLocalFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); |
1789 | 1810 |
1790 if (this != mainFrameImpl->activeMatchFrame()) | 1811 if (this != mainFrameImpl->activeMatchFrame()) |
1791 return; | 1812 return; |
1792 | 1813 |
1793 if (Range* activeMatch = m_textFinder->activeMatch()) { | 1814 if (Range* activeMatch = m_textFinder->activeMatch()) { |
1794 // If the user has set the selection since the match was found, we | 1815 // If the user has set the selection since the match was found, we |
1795 // don't focus anything. | 1816 // don't focus anything. |
1796 VisibleSelection selection(frame()->selection().selection()); | 1817 VisibleSelection selection(frame()->selection().selection()); |
1797 if (!selection.isNone()) | 1818 if (!selection.isNone()) |
1798 return; | 1819 return; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1837 // active match as the selection (so that when you end the Find session, | 1858 // active match as the selection (so that when you end the Find session, |
1838 // you'll have the last thing you found highlighted) and make sure that | 1859 // you'll have the last thing you found highlighted) and make sure that |
1839 // we have nothing focused (otherwise you might have text selected but | 1860 // we have nothing focused (otherwise you might have text selected but |
1840 // a link focused, which is weird). | 1861 // a link focused, which is weird). |
1841 frame()->selection().setSelection(VisibleSelection(activeMatch)); | 1862 frame()->selection().setSelection(VisibleSelection(activeMatch)); |
1842 frame()->document()->setFocusedElement(nullptr); | 1863 frame()->document()->setFocusedElement(nullptr); |
1843 | 1864 |
1844 // Finally clear the active match, for two reasons: | 1865 // Finally clear the active match, for two reasons: |
1845 // We just finished the find 'session' and we don't want future (potenti
ally | 1866 // We just finished the find 'session' and we don't want future (potenti
ally |
1846 // unrelated) find 'sessions' operations to start at the same place. | 1867 // unrelated) find 'sessions' operations to start at the same place. |
1847 // The WebFrameImpl could get reused and the activeMatch could end up po
inting | 1868 // The WebLocalFrameImpl could get reused and the activeMatch could end
up pointing |
1848 // to a document that is no longer valid. Keeping an invalid reference a
round | 1869 // to a document that is no longer valid. Keeping an invalid reference a
round |
1849 // is just asking for trouble. | 1870 // is just asking for trouble. |
1850 m_textFinder->resetActiveMatch(); | 1871 m_textFinder->resetActiveMatch(); |
1851 } | 1872 } |
1852 } | 1873 } |
1853 | 1874 |
1854 void WebFrameImpl::didFail(const ResourceError& error, bool wasProvisional) | 1875 void WebLocalFrameImpl::didFail(const ResourceError& error, bool wasProvisional) |
1855 { | 1876 { |
1856 if (!client()) | 1877 if (!client()) |
1857 return; | 1878 return; |
1858 WebURLError webError = error; | 1879 WebURLError webError = error; |
1859 if (wasProvisional) | 1880 if (wasProvisional) |
1860 client()->didFailProvisionalLoad(this, webError); | 1881 client()->didFailProvisionalLoad(this, webError); |
1861 else | 1882 else |
1862 client()->didFailLoad(this, webError); | 1883 client()->didFailLoad(this, webError); |
1863 } | 1884 } |
1864 | 1885 |
1865 void WebFrameImpl::setCanHaveScrollbars(bool canHaveScrollbars) | 1886 void WebLocalFrameImpl::setCanHaveScrollbars(bool canHaveScrollbars) |
1866 { | 1887 { |
1867 frame()->view()->setCanHaveScrollbars(canHaveScrollbars); | 1888 frame()->view()->setCanHaveScrollbars(canHaveScrollbars); |
1868 } | 1889 } |
1869 | 1890 |
1870 void WebFrameImpl::setInputEventsTransformForEmulation(const IntSize& offset, fl
oat contentScaleFactor) | 1891 void WebLocalFrameImpl::setInputEventsTransformForEmulation(const IntSize& offse
t, float contentScaleFactor) |
1871 { | 1892 { |
1872 m_inputEventsOffsetForEmulation = offset; | 1893 m_inputEventsOffsetForEmulation = offset; |
1873 m_inputEventsScaleFactorForEmulation = contentScaleFactor; | 1894 m_inputEventsScaleFactorForEmulation = contentScaleFactor; |
1874 if (frame()->view()) | 1895 if (frame()->view()) |
1875 frame()->view()->setInputEventsTransformForEmulation(m_inputEventsOffset
ForEmulation, m_inputEventsScaleFactorForEmulation); | 1896 frame()->view()->setInputEventsTransformForEmulation(m_inputEventsOffset
ForEmulation, m_inputEventsScaleFactorForEmulation); |
1876 } | 1897 } |
1877 | 1898 |
1878 void WebFrameImpl::loadJavaScriptURL(const KURL& url) | 1899 void WebLocalFrameImpl::loadJavaScriptURL(const KURL& url) |
1879 { | 1900 { |
1880 // This is copied from ScriptController::executeScriptIfJavaScriptURL. | 1901 // This is copied from ScriptController::executeScriptIfJavaScriptURL. |
1881 // Unfortunately, we cannot just use that method since it is private, and | 1902 // Unfortunately, we cannot just use that method since it is private, and |
1882 // it also doesn't quite behave as we require it to for bookmarklets. The | 1903 // it also doesn't quite behave as we require it to for bookmarklets. The |
1883 // key difference is that we need to suppress loading the string result | 1904 // key difference is that we need to suppress loading the string result |
1884 // from evaluating the JS URL if executing the JS URL resulted in a | 1905 // from evaluating the JS URL if executing the JS URL resulted in a |
1885 // location change. We also allow a JS URL to be loaded even if scripts on | 1906 // location change. We also allow a JS URL to be loaded even if scripts on |
1886 // the page are otherwise disabled. | 1907 // the page are otherwise disabled. |
1887 | 1908 |
1888 if (!frame()->document() || !frame()->page()) | 1909 if (!frame()->document() || !frame()->page()) |
1889 return; | 1910 return; |
1890 | 1911 |
1891 RefPtr<Document> ownerDocument(frame()->document()); | 1912 RefPtr<Document> ownerDocument(frame()->document()); |
1892 | 1913 |
1893 // Protect privileged pages against bookmarklets and other javascript manipu
lations. | 1914 // Protect privileged pages against bookmarklets and other javascript manipu
lations. |
1894 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()-
>document()->url().protocol())) | 1915 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()-
>document()->url().protocol())) |
1895 return; | 1916 return; |
1896 | 1917 |
1897 String script = decodeURLEscapeSequences(url.string().substring(strlen("java
script:"))); | 1918 String script = decodeURLEscapeSequences(url.string().substring(strlen("java
script:"))); |
1898 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 1919 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
1899 ScriptValue result = frame()->script().executeScriptInMainWorldAndReturnValu
e(ScriptSourceCode(script)); | 1920 ScriptValue result = frame()->script().executeScriptInMainWorldAndReturnValu
e(ScriptSourceCode(script)); |
1900 | 1921 |
1901 String scriptResult; | 1922 String scriptResult; |
1902 if (!result.toString(scriptResult)) | 1923 if (!result.toString(scriptResult)) |
1903 return; | 1924 return; |
1904 | 1925 |
1905 if (!frame()->navigationScheduler().locationChangePending()) | 1926 if (!frame()->navigationScheduler().locationChangePending()) |
1906 frame()->document()->loader()->replaceDocument(scriptResult, ownerDocume
nt.get()); | 1927 frame()->document()->loader()->replaceDocument(scriptResult, ownerDocume
nt.get()); |
1907 } | 1928 } |
1908 | 1929 |
1909 void WebFrameImpl::willDetachParent() | 1930 void WebLocalFrameImpl::willDetachParent() |
1910 { | 1931 { |
1911 // Do not expect string scoping results from any frames that got detached | 1932 // Do not expect string scoping results from any frames that got detached |
1912 // in the middle of the operation. | 1933 // in the middle of the operation. |
1913 if (m_textFinder && m_textFinder->scopingInProgress()) { | 1934 if (m_textFinder && m_textFinder->scopingInProgress()) { |
1914 | 1935 |
1915 // There is a possibility that the frame being detached was the only | 1936 // There is a possibility that the frame being detached was the only |
1916 // pending one. We need to make sure final replies can be sent. | 1937 // pending one. We need to make sure final replies can be sent. |
1917 m_textFinder->flushCurrentScoping(); | 1938 m_textFinder->flushCurrentScoping(); |
1918 | 1939 |
1919 m_textFinder->cancelPendingScopingEffort(); | 1940 m_textFinder->cancelPendingScopingEffort(); |
1920 } | 1941 } |
1921 } | 1942 } |
1922 | 1943 |
1923 WebFrameImpl* WebFrameImpl::activeMatchFrame() const | 1944 WebLocalFrameImpl* WebLocalFrameImpl::activeMatchFrame() const |
1924 { | 1945 { |
1925 ASSERT(!parent()); | 1946 ASSERT(!parent()); |
1926 | 1947 |
1927 if (m_textFinder) | 1948 if (m_textFinder) |
1928 return m_textFinder->activeMatchFrame(); | 1949 return m_textFinder->activeMatchFrame(); |
1929 return 0; | 1950 return 0; |
1930 } | 1951 } |
1931 | 1952 |
1932 WebCore::Range* WebFrameImpl::activeMatch() const | 1953 WebCore::Range* WebLocalFrameImpl::activeMatch() const |
1933 { | 1954 { |
1934 if (m_textFinder) | 1955 if (m_textFinder) |
1935 return m_textFinder->activeMatch(); | 1956 return m_textFinder->activeMatch(); |
1936 return 0; | 1957 return 0; |
1937 } | 1958 } |
1938 | 1959 |
1939 TextFinder& WebFrameImpl::ensureTextFinder() | 1960 TextFinder& WebLocalFrameImpl::ensureTextFinder() |
1940 { | 1961 { |
1941 if (!m_textFinder) | 1962 if (!m_textFinder) |
1942 m_textFinder = TextFinder::create(*this); | 1963 m_textFinder = TextFinder::create(*this); |
1943 | 1964 |
1944 return *m_textFinder; | 1965 return *m_textFinder; |
1945 } | 1966 } |
1946 | 1967 |
1947 void WebFrameImpl::invalidateScrollbar() const | 1968 void WebLocalFrameImpl::invalidateScrollbar() const |
1948 { | 1969 { |
1949 ASSERT(frame() && frame()->view()); | 1970 ASSERT(frame() && frame()->view()); |
1950 FrameView* view = frame()->view(); | 1971 FrameView* view = frame()->view(); |
1951 // Invalidate the vertical scroll bar region for the view. | 1972 // Invalidate the vertical scroll bar region for the view. |
1952 Scrollbar* scrollbar = view->verticalScrollbar(); | 1973 Scrollbar* scrollbar = view->verticalScrollbar(); |
1953 if (scrollbar) | 1974 if (scrollbar) |
1954 scrollbar->invalidate(); | 1975 scrollbar->invalidate(); |
1955 } | 1976 } |
1956 | 1977 |
1957 void WebFrameImpl::invalidateAll() const | 1978 void WebLocalFrameImpl::invalidateAll() const |
1958 { | 1979 { |
1959 ASSERT(frame() && frame()->view()); | 1980 ASSERT(frame() && frame()->view()); |
1960 FrameView* view = frame()->view(); | 1981 FrameView* view = frame()->view(); |
1961 view->invalidateRect(view->frameRect()); | 1982 view->invalidateRect(view->frameRect()); |
1962 invalidateScrollbar(); | 1983 invalidateScrollbar(); |
1963 } | 1984 } |
1964 | 1985 |
1965 } // namespace blink | 1986 } // namespace blink |
OLD | NEW |