Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / web / WebRemoteFrameImpl.cpp
blobe7932c45aa33a815e914a360b76d7bcaaefe55a8
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "config.h"
6 #include "web/WebRemoteFrameImpl.h"
8 #include "core/frame/FrameView.h"
9 #include "core/frame/RemoteFrame.h"
10 #include "core/frame/Settings.h"
11 #include "core/page/Page.h"
12 #include "platform/heap/Handle.h"
13 #include "public/platform/WebFloatRect.h"
14 #include "public/platform/WebRect.h"
15 #include "public/web/WebDocument.h"
16 #include "public/web/WebPerformance.h"
17 #include "public/web/WebRange.h"
18 #include "public/web/WebTreeScopeType.h"
19 #include "web/RemoteBridgeFrameOwner.h"
20 #include "web/WebViewImpl.h"
21 #include <v8/include/v8.h>
23 namespace blink {
25 WebRemoteFrame* WebRemoteFrame::create(WebTreeScopeType scope, WebRemoteFrameClient* client)
27 return WebRemoteFrameImpl::create(scope, client);
30 WebRemoteFrame* WebRemoteFrameImpl::create(WebTreeScopeType scope, WebRemoteFrameClient* client)
32 WebRemoteFrameImpl* frame = new WebRemoteFrameImpl(scope, client);
33 #if ENABLE(OILPAN)
34 return frame;
35 #else
36 return adoptRef(frame).leakRef();
37 #endif
40 WebRemoteFrameImpl::~WebRemoteFrameImpl()
44 #if ENABLE(OILPAN)
45 DEFINE_TRACE(WebRemoteFrameImpl)
47 visitor->trace(m_frameClient);
48 visitor->trace(m_frame);
49 visitor->trace(m_ownersForChildren);
50 visitor->template registerWeakMembers<WebFrame, &WebFrame::clearWeakFrames>(this);
51 WebFrame::traceFrames(visitor, this);
53 #endif
55 bool WebRemoteFrameImpl::isWebLocalFrame() const
57 return false;
60 WebLocalFrame* WebRemoteFrameImpl::toWebLocalFrame()
62 ASSERT_NOT_REACHED();
63 return nullptr;
66 bool WebRemoteFrameImpl::isWebRemoteFrame() const
68 return true;
71 WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame()
73 return this;
76 void WebRemoteFrameImpl::close()
78 #if ENABLE(OILPAN)
79 m_selfKeepAlive.clear();
80 #else
81 deref();
82 #endif
85 WebString WebRemoteFrameImpl::uniqueName() const
87 ASSERT_NOT_REACHED();
88 return WebString();
91 WebString WebRemoteFrameImpl::assignedName() const
93 ASSERT_NOT_REACHED();
94 return WebString();
97 void WebRemoteFrameImpl::setName(const WebString&)
99 ASSERT_NOT_REACHED();
102 WebVector<WebIconURL> WebRemoteFrameImpl::iconURLs(int iconTypesMask) const
104 ASSERT_NOT_REACHED();
105 return WebVector<WebIconURL>();
108 void WebRemoteFrameImpl::setRemoteWebLayer(WebLayer* webLayer)
110 if (!frame())
111 return;
113 frame()->setRemotePlatformLayer(webLayer);
116 void WebRemoteFrameImpl::setSharedWorkerRepositoryClient(WebSharedWorkerRepositoryClient*)
118 ASSERT_NOT_REACHED();
121 void WebRemoteFrameImpl::setCanHaveScrollbars(bool)
123 ASSERT_NOT_REACHED();
126 WebSize WebRemoteFrameImpl::scrollOffset() const
128 ASSERT_NOT_REACHED();
129 return WebSize();
132 void WebRemoteFrameImpl::setScrollOffset(const WebSize&)
134 ASSERT_NOT_REACHED();
137 WebSize WebRemoteFrameImpl::contentsSize() const
139 ASSERT_NOT_REACHED();
140 return WebSize();
143 bool WebRemoteFrameImpl::hasVisibleContent() const
145 ASSERT_NOT_REACHED();
146 return false;
149 WebRect WebRemoteFrameImpl::visibleContentRect() const
151 ASSERT_NOT_REACHED();
152 return WebRect();
155 bool WebRemoteFrameImpl::hasHorizontalScrollbar() const
157 ASSERT_NOT_REACHED();
158 return false;
161 bool WebRemoteFrameImpl::hasVerticalScrollbar() const
163 ASSERT_NOT_REACHED();
164 return false;
167 WebView* WebRemoteFrameImpl::view() const
169 if (!frame())
170 return nullptr;
171 return WebViewImpl::fromPage(frame()->page());
174 void WebRemoteFrameImpl::removeChild(WebFrame* frame)
176 WebFrame::removeChild(frame);
177 m_ownersForChildren.remove(frame);
180 WebDocument WebRemoteFrameImpl::document() const
182 // TODO(dcheng): this should also ASSERT_NOT_REACHED, but a lot of
183 // code tries to access the document of a remote frame at the moment.
184 return WebDocument();
187 WebPerformance WebRemoteFrameImpl::performance() const
189 ASSERT_NOT_REACHED();
190 return WebPerformance();
193 bool WebRemoteFrameImpl::dispatchBeforeUnloadEvent()
195 ASSERT_NOT_REACHED();
196 return false;
199 void WebRemoteFrameImpl::dispatchUnloadEvent()
201 ASSERT_NOT_REACHED();
204 NPObject* WebRemoteFrameImpl::windowObject() const
206 ASSERT_NOT_REACHED();
207 return nullptr;
210 void WebRemoteFrameImpl::bindToWindowObject(const WebString& name, NPObject*)
212 ASSERT_NOT_REACHED();
215 void WebRemoteFrameImpl::bindToWindowObject(const WebString& name, NPObject*, void*)
217 ASSERT_NOT_REACHED();
220 void WebRemoteFrameImpl::executeScript(const WebScriptSource&)
222 ASSERT_NOT_REACHED();
225 void WebRemoteFrameImpl::executeScriptInIsolatedWorld(
226 int worldID, const WebScriptSource* sources, unsigned numSources,
227 int extensionGroup)
229 ASSERT_NOT_REACHED();
232 void WebRemoteFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSecurityOrigin&)
234 ASSERT_NOT_REACHED();
237 void WebRemoteFrameImpl::setIsolatedWorldContentSecurityPolicy(int worldID, const WebString&)
239 ASSERT_NOT_REACHED();
242 void WebRemoteFrameImpl::addMessageToConsole(const WebConsoleMessage&)
244 ASSERT_NOT_REACHED();
247 void WebRemoteFrameImpl::collectGarbage()
249 ASSERT_NOT_REACHED();
252 bool WebRemoteFrameImpl::checkIfRunInsecureContent(const WebURL&) const
254 ASSERT_NOT_REACHED();
255 return false;
258 v8::Local<v8::Value> WebRemoteFrameImpl::executeScriptAndReturnValue(
259 const WebScriptSource&)
261 ASSERT_NOT_REACHED();
262 return v8::Local<v8::Value>();
265 void WebRemoteFrameImpl::executeScriptInIsolatedWorld(
266 int worldID, const WebScriptSource* sourcesIn, unsigned numSources,
267 int extensionGroup, WebVector<v8::Local<v8::Value>>* results)
269 ASSERT_NOT_REACHED();
272 v8::Local<v8::Value> WebRemoteFrameImpl::callFunctionEvenIfScriptDisabled(
273 v8::Local<v8::Function>,
274 v8::Local<v8::Value>,
275 int argc,
276 v8::Local<v8::Value> argv[])
278 ASSERT_NOT_REACHED();
279 return v8::Local<v8::Value>();
282 v8::Local<v8::Context> WebRemoteFrameImpl::mainWorldScriptContext() const
284 ASSERT_NOT_REACHED();
285 return v8::Local<v8::Context>();
288 v8::Local<v8::Context> WebRemoteFrameImpl::deprecatedMainWorldScriptContext() const
290 return toV8Context(frame(), DOMWrapperWorld::mainWorld());
293 void WebRemoteFrameImpl::reload(bool ignoreCache)
295 ASSERT_NOT_REACHED();
298 void WebRemoteFrameImpl::reloadWithOverrideURL(const WebURL& overrideUrl, bool ignoreCache)
300 ASSERT_NOT_REACHED();
303 void WebRemoteFrameImpl::loadRequest(const WebURLRequest&)
305 ASSERT_NOT_REACHED();
308 void WebRemoteFrameImpl::loadHistoryItem(const WebHistoryItem&, WebHistoryLoadType, WebURLRequest::CachePolicy)
310 ASSERT_NOT_REACHED();
313 void WebRemoteFrameImpl::loadData(
314 const WebData&, const WebString& mimeType, const WebString& textEncoding,
315 const WebURL& baseURL, const WebURL& unreachableURL, bool replace)
317 ASSERT_NOT_REACHED();
320 void WebRemoteFrameImpl::loadHTMLString(
321 const WebData& html, const WebURL& baseURL, const WebURL& unreachableURL,
322 bool replace)
324 ASSERT_NOT_REACHED();
327 void WebRemoteFrameImpl::stopLoading()
329 // TODO(dcheng,japhet): Calling this method should stop loads
330 // in all subframes, both remote and local.
333 WebDataSource* WebRemoteFrameImpl::provisionalDataSource() const
335 ASSERT_NOT_REACHED();
336 return nullptr;
339 WebDataSource* WebRemoteFrameImpl::dataSource() const
341 ASSERT_NOT_REACHED();
342 return nullptr;
345 void WebRemoteFrameImpl::enableViewSourceMode(bool enable)
347 ASSERT_NOT_REACHED();
350 bool WebRemoteFrameImpl::isViewSourceModeEnabled() const
352 ASSERT_NOT_REACHED();
353 return false;
356 void WebRemoteFrameImpl::setReferrerForRequest(WebURLRequest&, const WebURL& referrer)
358 ASSERT_NOT_REACHED();
361 void WebRemoteFrameImpl::dispatchWillSendRequest(WebURLRequest&)
363 ASSERT_NOT_REACHED();
366 WebURLLoader* WebRemoteFrameImpl::createAssociatedURLLoader(const WebURLLoaderOptions&)
368 ASSERT_NOT_REACHED();
369 return nullptr;
372 unsigned WebRemoteFrameImpl::unloadListenerCount() const
374 ASSERT_NOT_REACHED();
375 return 0;
378 void WebRemoteFrameImpl::replaceSelection(const WebString&)
380 ASSERT_NOT_REACHED();
383 void WebRemoteFrameImpl::insertText(const WebString&)
385 ASSERT_NOT_REACHED();
388 void WebRemoteFrameImpl::setMarkedText(const WebString&, unsigned location, unsigned length)
390 ASSERT_NOT_REACHED();
393 void WebRemoteFrameImpl::unmarkText()
395 ASSERT_NOT_REACHED();
398 bool WebRemoteFrameImpl::hasMarkedText() const
400 ASSERT_NOT_REACHED();
401 return false;
404 WebRange WebRemoteFrameImpl::markedRange() const
406 ASSERT_NOT_REACHED();
407 return WebRange();
410 bool WebRemoteFrameImpl::firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const
412 ASSERT_NOT_REACHED();
413 return false;
416 size_t WebRemoteFrameImpl::characterIndexForPoint(const WebPoint&) const
418 ASSERT_NOT_REACHED();
419 return 0;
422 bool WebRemoteFrameImpl::executeCommand(const WebString&, const WebNode&)
424 ASSERT_NOT_REACHED();
425 return false;
428 bool WebRemoteFrameImpl::executeCommand(const WebString&, const WebString& value, const WebNode&)
430 ASSERT_NOT_REACHED();
431 return false;
434 bool WebRemoteFrameImpl::isCommandEnabled(const WebString&) const
436 ASSERT_NOT_REACHED();
437 return false;
440 void WebRemoteFrameImpl::enableContinuousSpellChecking(bool)
444 bool WebRemoteFrameImpl::isContinuousSpellCheckingEnabled() const
446 return false;
449 void WebRemoteFrameImpl::requestTextChecking(const WebElement&)
451 ASSERT_NOT_REACHED();
454 void WebRemoteFrameImpl::replaceMisspelledRange(const WebString&)
456 ASSERT_NOT_REACHED();
459 void WebRemoteFrameImpl::removeSpellingMarkers()
461 ASSERT_NOT_REACHED();
464 bool WebRemoteFrameImpl::hasSelection() const
466 ASSERT_NOT_REACHED();
467 return false;
470 WebRange WebRemoteFrameImpl::selectionRange() const
472 ASSERT_NOT_REACHED();
473 return WebRange();
476 WebString WebRemoteFrameImpl::selectionAsText() const
478 ASSERT_NOT_REACHED();
479 return WebString();
482 WebString WebRemoteFrameImpl::selectionAsMarkup() const
484 ASSERT_NOT_REACHED();
485 return WebString();
488 bool WebRemoteFrameImpl::selectWordAroundCaret()
490 ASSERT_NOT_REACHED();
491 return false;
494 void WebRemoteFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent)
496 ASSERT_NOT_REACHED();
499 void WebRemoteFrameImpl::selectRange(const WebRange&)
501 ASSERT_NOT_REACHED();
504 void WebRemoteFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint& extent, WebFrame::TextGranularity granularity)
506 ASSERT_NOT_REACHED();
509 void WebRemoteFrameImpl::moveCaretSelection(const WebPoint&)
511 ASSERT_NOT_REACHED();
514 bool WebRemoteFrameImpl::setEditableSelectionOffsets(int start, int end)
516 ASSERT_NOT_REACHED();
517 return false;
520 bool WebRemoteFrameImpl::setCompositionFromExistingText(int compositionStart, int compositionEnd, const WebVector<WebCompositionUnderline>& underlines)
522 ASSERT_NOT_REACHED();
523 return false;
526 void WebRemoteFrameImpl::extendSelectionAndDelete(int before, int after)
528 ASSERT_NOT_REACHED();
531 void WebRemoteFrameImpl::setCaretVisible(bool)
533 ASSERT_NOT_REACHED();
536 int WebRemoteFrameImpl::printBegin(const WebPrintParams&, const WebNode& constrainToNode)
538 ASSERT_NOT_REACHED();
539 return 0;
542 float WebRemoteFrameImpl::printPage(int pageToPrint, WebCanvas*)
544 ASSERT_NOT_REACHED();
545 return 0.0;
548 float WebRemoteFrameImpl::getPrintPageShrink(int page)
550 ASSERT_NOT_REACHED();
551 return 0.0;
554 void WebRemoteFrameImpl::printEnd()
556 ASSERT_NOT_REACHED();
559 bool WebRemoteFrameImpl::isPrintScalingDisabledForPlugin(const WebNode&)
561 ASSERT_NOT_REACHED();
562 return false;
565 bool WebRemoteFrameImpl::hasCustomPageSizeStyle(int pageIndex)
567 ASSERT_NOT_REACHED();
568 return false;
571 bool WebRemoteFrameImpl::isPageBoxVisible(int pageIndex)
573 ASSERT_NOT_REACHED();
574 return false;
577 void WebRemoteFrameImpl::pageSizeAndMarginsInPixels(
578 int pageIndex,
579 WebSize& pageSize,
580 int& marginTop,
581 int& marginRight,
582 int& marginBottom,
583 int& marginLeft)
585 ASSERT_NOT_REACHED();
588 WebString WebRemoteFrameImpl::pageProperty(const WebString& propertyName, int pageIndex)
590 ASSERT_NOT_REACHED();
591 return WebString();
594 void WebRemoteFrameImpl::printPagesWithBoundaries(WebCanvas*, const WebSize&)
596 ASSERT_NOT_REACHED();
599 bool WebRemoteFrameImpl::find(
600 int identifier, const WebString& searchText, const WebFindOptions&,
601 bool wrapWithinFrame, WebRect* selectionRect)
603 ASSERT_NOT_REACHED();
604 return false;
607 void WebRemoteFrameImpl::stopFinding(bool clearSelection)
609 ASSERT_NOT_REACHED();
612 void WebRemoteFrameImpl::scopeStringMatches(
613 int identifier, const WebString& searchText, const WebFindOptions&,
614 bool reset)
616 ASSERT_NOT_REACHED();
619 void WebRemoteFrameImpl::cancelPendingScopingEffort()
621 ASSERT_NOT_REACHED();
624 void WebRemoteFrameImpl::increaseMatchCount(int count, int identifier)
626 ASSERT_NOT_REACHED();
629 void WebRemoteFrameImpl::resetMatchCount()
631 ASSERT_NOT_REACHED();
634 int WebRemoteFrameImpl::findMatchMarkersVersion() const
636 ASSERT_NOT_REACHED();
637 return 0;
640 WebFloatRect WebRemoteFrameImpl::activeFindMatchRect()
642 ASSERT_NOT_REACHED();
643 return WebFloatRect();
646 void WebRemoteFrameImpl::findMatchRects(WebVector<WebFloatRect>&)
648 ASSERT_NOT_REACHED();
651 int WebRemoteFrameImpl::selectNearestFindMatch(const WebFloatPoint&, WebRect* selectionRect)
653 ASSERT_NOT_REACHED();
654 return 0;
657 void WebRemoteFrameImpl::setTickmarks(const WebVector<WebRect>&)
659 ASSERT_NOT_REACHED();
662 void WebRemoteFrameImpl::dispatchMessageEventWithOriginCheck(
663 const WebSecurityOrigin& intendedTargetOrigin,
664 const WebDOMEvent&)
666 ASSERT_NOT_REACHED();
669 WebString WebRemoteFrameImpl::contentAsText(size_t maxChars) const
671 ASSERT_NOT_REACHED();
672 return WebString();
675 WebString WebRemoteFrameImpl::contentAsMarkup() const
677 ASSERT_NOT_REACHED();
678 return WebString();
681 WebString WebRemoteFrameImpl::layoutTreeAsText(LayoutAsTextControls toShow) const
683 ASSERT_NOT_REACHED();
684 return WebString();
687 WebString WebRemoteFrameImpl::markerTextForListItem(const WebElement&) const
689 ASSERT_NOT_REACHED();
690 return WebString();
693 WebRect WebRemoteFrameImpl::selectionBoundsRect() const
695 ASSERT_NOT_REACHED();
696 return WebRect();
699 bool WebRemoteFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) const
701 ASSERT_NOT_REACHED();
702 return false;
705 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const
707 ASSERT_NOT_REACHED();
708 return WebString();
711 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(WebTreeScopeType scope, const WebString& name, WebSandboxFlags sandboxFlags, WebFrameClient* client, WebFrame* previousSibling)
713 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(scope, client));
714 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner>>::AddResult result =
715 m_ownersForChildren.add(child, RemoteBridgeFrameOwner::create(child, static_cast<SandboxFlags>(sandboxFlags)));
716 insertAfter(child, previousSibling);
717 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may
718 // result in the browser observing two navigations to about:blank (one from the initial
719 // frame creation, and one from swapping it into the remote process). FrameLoader might
720 // need a special initialization function for this case to avoid that duplicate navigation.
721 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name, nullAtom);
722 // Partially related with the above FIXME--the init() call may trigger JS dispatch. However,
723 // if the parent is remote, it should never be detached synchronously...
724 ASSERT(child->frame());
725 return child;
729 void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner, const AtomicString& name)
731 setCoreFrame(RemoteFrame::create(m_frameClient.get(), host, owner));
732 frame()->createView();
733 m_frame->tree().setName(name, nullAtom);
736 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(WebTreeScopeType scope, const WebString& name, WebSandboxFlags sandboxFlags, WebRemoteFrameClient* client)
738 WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(scope, client));
739 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner>>::AddResult result =
740 m_ownersForChildren.add(child, RemoteBridgeFrameOwner::create(nullptr, static_cast<SandboxFlags>(sandboxFlags)));
741 appendChild(child);
742 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name);
743 return child;
746 void WebRemoteFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<RemoteFrame> frame)
748 m_frame = frame;
751 WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame)
753 if (!frame.client())
754 return nullptr;
755 return static_cast<RemoteFrameClientImpl*>(frame.client())->webFrame();
758 void WebRemoteFrameImpl::initializeFromFrame(WebLocalFrame* source) const
760 ASSERT(source);
761 WebLocalFrameImpl* localFrameImpl = toWebLocalFrameImpl(source);
763 client()->initializeChildFrame(
764 localFrameImpl->frame()->view()->frameRect(),
765 localFrameImpl->frame()->page()->deviceScaleFactor());
768 void WebRemoteFrameImpl::setReplicatedOrigin(const WebSecurityOrigin& origin) const
770 ASSERT(frame());
771 frame()->securityContext()->setReplicatedOrigin(origin);
774 void WebRemoteFrameImpl::setReplicatedSandboxFlags(WebSandboxFlags flags) const
776 ASSERT(frame());
777 frame()->securityContext()->enforceSandboxFlags(static_cast<SandboxFlags>(flags));
780 void WebRemoteFrameImpl::setReplicatedName(const WebString& name) const
782 ASSERT(frame());
783 frame()->tree().setName(name, nullAtom);
786 void WebRemoteFrameImpl::DispatchLoadEventForFrameOwner() const
788 ASSERT(frame()->owner()->isLocal());
789 frame()->owner()->dispatchLoad();
792 void WebRemoteFrameImpl::didStartLoading()
794 frame()->setIsLoading(true);
797 void WebRemoteFrameImpl::didStopLoading()
799 frame()->setIsLoading(false);
800 if (parent() && parent()->isWebLocalFrame()) {
801 WebLocalFrameImpl* parentFrame =
802 toWebLocalFrameImpl(parent()->toWebLocalFrame());
803 parentFrame->frame()->loader().checkCompleted();
807 WebRemoteFrameImpl::WebRemoteFrameImpl(WebTreeScopeType scope, WebRemoteFrameClient* client)
808 : WebRemoteFrame(scope)
809 , m_frameClient(RemoteFrameClientImpl::create(this))
810 , m_client(client)
811 #if ENABLE(OILPAN)
812 , m_selfKeepAlive(this)
813 #endif
817 } // namespace blink