| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 #include "web/WebRemoteFrameImpl.h" | 237 #include "web/WebRemoteFrameImpl.h" |
| 238 #include "web/WebViewImpl.h" | 238 #include "web/WebViewImpl.h" |
| 239 #include "wtf/CurrentTime.h" | 239 #include "wtf/CurrentTime.h" |
| 240 #include "wtf/HashMap.h" | 240 #include "wtf/HashMap.h" |
| 241 #include <algorithm> | 241 #include <algorithm> |
| 242 | 242 |
| 243 namespace blink { | 243 namespace blink { |
| 244 | 244 |
| 245 static int frameCount = 0; | 245 static int frameCount = 0; |
| 246 | 246 |
| 247 static WillBeHeapVector<ScriptSourceCode> createSourcesVector(const WebScriptSou
rce* sourcesIn, unsigned numSources) | 247 static HeapVector<ScriptSourceCode> createSourcesVector(const WebScriptSource* s
ourcesIn, unsigned numSources) |
| 248 { | 248 { |
| 249 WillBeHeapVector<ScriptSourceCode> sources; | 249 HeapVector<ScriptSourceCode> sources; |
| 250 sources.append(sourcesIn, numSources); | 250 sources.append(sourcesIn, numSources); |
| 251 return sources; | 251 return sources; |
| 252 } | 252 } |
| 253 | 253 |
| 254 WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromFrame(LocalFrame*
frame) | 254 WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromFrame(LocalFrame*
frame) |
| 255 { | 255 { |
| 256 if (!frame) | 256 if (!frame) |
| 257 return 0; | 257 return 0; |
| 258 if (!frame->document() || !frame->document()->isPluginDocument()) | 258 if (!frame->document() || !frame->document()->isPluginDocument()) |
| 259 return 0; | 259 return 0; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 DrawingRecorder lineBoundaryRecorder(context, *this, DisplayItem::Pr
intedContentDestinationLocations, pageRect); | 402 DrawingRecorder lineBoundaryRecorder(context, *this, DisplayItem::Pr
intedContentDestinationLocations, pageRect); |
| 403 outputLinkedDestinations(context, pageRect); | 403 outputLinkedDestinations(context, pageRect); |
| 404 } | 404 } |
| 405 | 405 |
| 406 return scale; | 406 return scale; |
| 407 } | 407 } |
| 408 | 408 |
| 409 private: | 409 private: |
| 410 void dispatchEventsForPrintingOnAllFrames() | 410 void dispatchEventsForPrintingOnAllFrames() |
| 411 { | 411 { |
| 412 WillBeHeapVector<RefPtrWillBeMember<Document>> documents; | 412 HeapVector<Member<Document>> documents; |
| 413 for (Frame* currentFrame = frame(); currentFrame; currentFrame = current
Frame->tree().traverseNext(frame())) { | 413 for (Frame* currentFrame = frame(); currentFrame; currentFrame = current
Frame->tree().traverseNext(frame())) { |
| 414 if (currentFrame->isLocalFrame()) | 414 if (currentFrame->isLocalFrame()) |
| 415 documents.append(toLocalFrame(currentFrame)->document()); | 415 documents.append(toLocalFrame(currentFrame)->document()); |
| 416 } | 416 } |
| 417 | 417 |
| 418 for (auto& doc : documents) | 418 for (auto& doc : documents) |
| 419 doc->dispatchEventsForPrinting(); | 419 doc->dispatchEventsForPrinting(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 // Set when printing. | 422 // Set when printing. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 float spoolPage(GraphicsContext& context, int pageNumber) override | 474 float spoolPage(GraphicsContext& context, int pageNumber) override |
| 475 { | 475 { |
| 476 IntRect pageRect = m_pageRects[pageNumber]; | 476 IntRect pageRect = m_pageRects[pageNumber]; |
| 477 m_plugin->printPage(pageNumber, context, pageRect); | 477 m_plugin->printPage(pageNumber, context, pageRect); |
| 478 | 478 |
| 479 return 1.0; | 479 return 1.0; |
| 480 } | 480 } |
| 481 | 481 |
| 482 private: | 482 private: |
| 483 // Set when printing. | 483 // Set when printing. |
| 484 RawPtrWillBeMember<WebPluginContainerImpl> m_plugin; | 484 Member<WebPluginContainerImpl> m_plugin; |
| 485 WebPrintParams m_printParams; | 485 WebPrintParams m_printParams; |
| 486 }; | 486 }; |
| 487 | 487 |
| 488 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) | 488 static WebDataSource* DataSourceForDocLoader(DocumentLoader* loader) |
| 489 { | 489 { |
| 490 return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : 0; | 490 return loader ? WebDataSourceImpl::fromDocumentLoader(loader) : 0; |
| 491 } | 491 } |
| 492 | 492 |
| 493 // WebSuspendableTaskWrapper -------------------------------------------------- | 493 // WebSuspendableTaskWrapper -------------------------------------------------- |
| 494 | 494 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 return frameForContext(context); | 533 return frameForContext(context); |
| 534 } | 534 } |
| 535 | 535 |
| 536 WebLocalFrame* WebLocalFrame::frameForContext(v8::Local<v8::Context> context) | 536 WebLocalFrame* WebLocalFrame::frameForContext(v8::Local<v8::Context> context) |
| 537 { | 537 { |
| 538 return WebLocalFrameImpl::fromFrame(toLocalFrame(toFrameIfNotDetached(contex
t))); | 538 return WebLocalFrameImpl::fromFrame(toLocalFrame(toFrameIfNotDetached(contex
t))); |
| 539 } | 539 } |
| 540 | 540 |
| 541 WebLocalFrame* WebLocalFrame::fromFrameOwnerElement(const WebElement& element) | 541 WebLocalFrame* WebLocalFrame::fromFrameOwnerElement(const WebElement& element) |
| 542 { | 542 { |
| 543 return WebLocalFrameImpl::fromFrameOwnerElement(PassRefPtrWillBeRawPtr<Eleme
nt>(element).get()); | 543 return WebLocalFrameImpl::fromFrameOwnerElement(RawPtr<Element>(element).get
()); |
| 544 } | 544 } |
| 545 | 545 |
| 546 bool WebLocalFrameImpl::isWebLocalFrame() const | 546 bool WebLocalFrameImpl::isWebLocalFrame() const |
| 547 { | 547 { |
| 548 return true; | 548 return true; |
| 549 } | 549 } |
| 550 | 550 |
| 551 WebLocalFrame* WebLocalFrameImpl::toWebLocalFrame() | 551 WebLocalFrame* WebLocalFrameImpl::toWebLocalFrame() |
| 552 { | 552 { |
| 553 return this; | 553 return this; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 v8::HandleScope handleScope(toIsolate(frame())); | 745 v8::HandleScope handleScope(toIsolate(frame())); |
| 746 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou
rce.url, position)); | 746 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou
rce.url, position)); |
| 747 } | 747 } |
| 748 | 748 |
| 749 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup) | 749 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup) |
| 750 { | 750 { |
| 751 ASSERT(frame()); | 751 ASSERT(frame()); |
| 752 RELEASE_ASSERT(worldID > 0); | 752 RELEASE_ASSERT(worldID > 0); |
| 753 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | 753 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); |
| 754 | 754 |
| 755 WillBeHeapVector<ScriptSourceCode> sources = createSourcesVector(sourcesIn,
numSources); | 755 HeapVector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSou
rces); |
| 756 v8::HandleScope handleScope(toIsolate(frame())); | 756 v8::HandleScope handleScope(toIsolate(frame())); |
| 757 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGr
oup, 0); | 757 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGr
oup, 0); |
| 758 } | 758 } |
| 759 | 759 |
| 760 void WebLocalFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSec
urityOrigin& securityOrigin) | 760 void WebLocalFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSec
urityOrigin& securityOrigin) |
| 761 { | 761 { |
| 762 ASSERT(frame()); | 762 ASSERT(frame()); |
| 763 DOMWrapperWorld::setIsolatedWorldSecurityOrigin(worldID, securityOrigin.get(
)); | 763 DOMWrapperWorld::setIsolatedWorldSecurityOrigin(worldID, securityOrigin.get(
)); |
| 764 } | 764 } |
| 765 | 765 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 | 824 |
| 825 SuspendableScriptExecutor::createAndRun(frame(), 0, createSourcesVector(&sou
rce, 1), 0, userGesture, callback); | 825 SuspendableScriptExecutor::createAndRun(frame(), 0, createSourcesVector(&sou
rce, 1), 0, userGesture, callback); |
| 826 } | 826 } |
| 827 | 827 |
| 828 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local
<v8::Value>>* results) | 828 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local
<v8::Value>>* results) |
| 829 { | 829 { |
| 830 ASSERT(frame()); | 830 ASSERT(frame()); |
| 831 RELEASE_ASSERT(worldID > 0); | 831 RELEASE_ASSERT(worldID > 0); |
| 832 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); | 832 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); |
| 833 | 833 |
| 834 WillBeHeapVector<ScriptSourceCode> sources = createSourcesVector(sourcesIn,
numSources); | 834 HeapVector<ScriptSourceCode> sources = createSourcesVector(sourcesIn, numSou
rces); |
| 835 | 835 |
| 836 if (results) { | 836 if (results) { |
| 837 Vector<v8::Local<v8::Value>> scriptResults; | 837 Vector<v8::Local<v8::Value>> scriptResults; |
| 838 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, &scriptResults); | 838 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi
onGroup, &scriptResults); |
| 839 WebVector<v8::Local<v8::Value>> v8Results(scriptResults.size()); | 839 WebVector<v8::Local<v8::Value>> v8Results(scriptResults.size()); |
| 840 for (unsigned i = 0; i < scriptResults.size(); i++) | 840 for (unsigned i = 0; i < scriptResults.size(); i++) |
| 841 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR
esults[i]); | 841 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR
esults[i]); |
| 842 results->swap(v8Results); | 842 results->swap(v8Results); |
| 843 } else { | 843 } else { |
| 844 v8::HandleScope handleScope(toIsolate(frame())); | 844 v8::HandleScope handleScope(toIsolate(frame())); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 } | 1207 } |
| 1208 | 1208 |
| 1209 void WebLocalFrameImpl::selectRange(const WebPoint& baseInViewport, const WebPoi
nt& extentInViewport) | 1209 void WebLocalFrameImpl::selectRange(const WebPoint& baseInViewport, const WebPoi
nt& extentInViewport) |
| 1210 { | 1210 { |
| 1211 moveRangeSelection(baseInViewport, extentInViewport); | 1211 moveRangeSelection(baseInViewport, extentInViewport); |
| 1212 } | 1212 } |
| 1213 | 1213 |
| 1214 void WebLocalFrameImpl::selectRange(const WebRange& webRange) | 1214 void WebLocalFrameImpl::selectRange(const WebRange& webRange) |
| 1215 { | 1215 { |
| 1216 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectRange"); | 1216 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectRange"); |
| 1217 if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Ran
ge>>(webRange)) | 1217 if (RawPtr<Range> range = static_cast<RawPtr<Range>>(webRange)) |
| 1218 frame()->selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY,
SelectionDirectionalMode::NonDirectional, NotUserTriggered); | 1218 frame()->selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY,
SelectionDirectionalMode::NonDirectional, NotUserTriggered); |
| 1219 } | 1219 } |
| 1220 | 1220 |
| 1221 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point) | 1221 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point) |
| 1222 { | 1222 { |
| 1223 TRACE_EVENT0("blink", "WebLocalFrameImpl::moveRangeSelectionExtent"); | 1223 TRACE_EVENT0("blink", "WebLocalFrameImpl::moveRangeSelectionExtent"); |
| 1224 frame()->selection().moveRangeSelectionExtent(frame()->view()->viewportToCon
tents(point)); | 1224 frame()->selection().moveRangeSelectionExtent(frame()->view()->viewportToCon
tents(point)); |
| 1225 } | 1225 } |
| 1226 | 1226 |
| 1227 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& baseInViewport, const
WebPoint& extentInViewport, WebFrame::TextGranularity granularity) | 1227 void WebLocalFrameImpl::moveRangeSelection(const WebPoint& baseInViewport, const
WebPoint& extentInViewport, WebFrame::TextGranularity granularity) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 if (constrainToNode.isNull()) { | 1305 if (constrainToNode.isNull()) { |
| 1306 // If this is a plugin document, check if the plugin supports its own | 1306 // If this is a plugin document, check if the plugin supports its own |
| 1307 // printing. If it does, we will delegate all printing to that. | 1307 // printing. If it does, we will delegate all printing to that. |
| 1308 pluginContainer = pluginContainerFromFrame(frame()); | 1308 pluginContainer = pluginContainerFromFrame(frame()); |
| 1309 } else { | 1309 } else { |
| 1310 // We only support printing plugin nodes for now. | 1310 // We only support printing plugin nodes for now. |
| 1311 pluginContainer = toWebPluginContainerImpl(constrainToNode.pluginContain
er()); | 1311 pluginContainer = toWebPluginContainerImpl(constrainToNode.pluginContain
er()); |
| 1312 } | 1312 } |
| 1313 | 1313 |
| 1314 if (pluginContainer && pluginContainer->supportsPaginatedPrint()) | 1314 if (pluginContainer && pluginContainer->supportsPaginatedPrint()) |
| 1315 m_printContext = adoptPtrWillBeNoop(new ChromePluginPrintContext(frame()
, pluginContainer, printParams)); | 1315 m_printContext = (new ChromePluginPrintContext(frame(), pluginContainer,
printParams)); |
| 1316 else | 1316 else |
| 1317 m_printContext = adoptPtrWillBeNoop(new ChromePrintContext(frame())); | 1317 m_printContext = (new ChromePrintContext(frame())); |
| 1318 | 1318 |
| 1319 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width),
static_cast<float>(printParams.printContentArea.height)); | 1319 FloatRect rect(0, 0, static_cast<float>(printParams.printContentArea.width),
static_cast<float>(printParams.printContentArea.height)); |
| 1320 m_printContext->begin(rect.width(), rect.height()); | 1320 m_printContext->begin(rect.width(), rect.height()); |
| 1321 float pageHeight; | 1321 float pageHeight; |
| 1322 // We ignore the overlays calculation for now since they are generated in th
e | 1322 // We ignore the overlays calculation for now since they are generated in th
e |
| 1323 // browser. pageHeight is actually an output parameter. | 1323 // browser. pageHeight is actually an output parameter. |
| 1324 m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight); | 1324 m_printContext->computePageRects(rect, 0, 0, 1.0, pageHeight); |
| 1325 | 1325 |
| 1326 return static_cast<int>(m_printContext->pageCount()); | 1326 return static_cast<int>(m_printContext->pageCount()); |
| 1327 } | 1327 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 WebLocalFrameImpl* frame = new WebLocalFrameImpl(scope, client); | 1455 WebLocalFrameImpl* frame = new WebLocalFrameImpl(scope, client); |
| 1456 #if ENABLE(OILPAN) | 1456 #if ENABLE(OILPAN) |
| 1457 return frame; | 1457 return frame; |
| 1458 #else | 1458 #else |
| 1459 return adoptRef(frame).leakRef(); | 1459 return adoptRef(frame).leakRef(); |
| 1460 #endif | 1460 #endif |
| 1461 } | 1461 } |
| 1462 | 1462 |
| 1463 WebLocalFrameImpl* WebLocalFrameImpl::createProvisional(WebFrameClient* client,
WebRemoteFrame* oldWebFrame, WebSandboxFlags flags, const WebFrameOwnerPropertie
s& frameOwnerProperties) | 1463 WebLocalFrameImpl* WebLocalFrameImpl::createProvisional(WebFrameClient* client,
WebRemoteFrame* oldWebFrame, WebSandboxFlags flags, const WebFrameOwnerPropertie
s& frameOwnerProperties) |
| 1464 { | 1464 { |
| 1465 RefPtrWillBeRawPtr<WebLocalFrameImpl> webFrame = adoptRefWillBeNoop(new WebL
ocalFrameImpl(oldWebFrame, client)); | 1465 RawPtr<WebLocalFrameImpl> webFrame = (new WebLocalFrameImpl(oldWebFrame, cli
ent)); |
| 1466 Frame* oldFrame = oldWebFrame->toImplBase()->frame(); | 1466 Frame* oldFrame = oldWebFrame->toImplBase()->frame(); |
| 1467 webFrame->setParent(oldWebFrame->parent()); | 1467 webFrame->setParent(oldWebFrame->parent()); |
| 1468 webFrame->setOpener(oldWebFrame->opener()); | 1468 webFrame->setOpener(oldWebFrame->opener()); |
| 1469 // Note: this *always* temporarily sets a frame owner, even for main frames! | 1469 // Note: this *always* temporarily sets a frame owner, even for main frames! |
| 1470 // When a core Frame is created with no owner, it attempts to set itself as | 1470 // When a core Frame is created with no owner, it attempts to set itself as |
| 1471 // the main frame of the Page. However, this is a provisional frame, and may | 1471 // the main frame of the Page. However, this is a provisional frame, and may |
| 1472 // disappear, so Page::m_mainFrame can't be updated just yet. | 1472 // disappear, so Page::m_mainFrame can't be updated just yet. |
| 1473 OwnPtrWillBeRawPtr<FrameOwner> tempOwner = RemoteBridgeFrameOwner::create(nu
llptr, SandboxNone, WebFrameOwnerProperties()); | 1473 RawPtr<FrameOwner> tempOwner = RemoteBridgeFrameOwner::create(nullptr, Sandb
oxNone, WebFrameOwnerProperties()); |
| 1474 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to r
euse it here. | 1474 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to r
euse it here. |
| 1475 RefPtrWillBeRawPtr<LocalFrame> frame = LocalFrame::create(webFrame->m_frameL
oaderClientImpl.get(), oldFrame->host(), tempOwner.get()); | 1475 RawPtr<LocalFrame> frame = LocalFrame::create(webFrame->m_frameLoaderClientI
mpl.get(), oldFrame->host(), tempOwner.get()); |
| 1476 // Set the name and unique name directly, bypassing any of the normal logic | 1476 // Set the name and unique name directly, bypassing any of the normal logic |
| 1477 // to calculate unique name. | 1477 // to calculate unique name. |
| 1478 frame->tree().setNameForReplacementFrame(toWebRemoteFrameImpl(oldWebFrame)->
frame()->tree().name(), toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().uniqu
eName()); | 1478 frame->tree().setNameForReplacementFrame(toWebRemoteFrameImpl(oldWebFrame)->
frame()->tree().name(), toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().uniqu
eName()); |
| 1479 webFrame->setCoreFrame(frame); | 1479 webFrame->setCoreFrame(frame); |
| 1480 | 1480 |
| 1481 frame->setOwner(oldFrame->owner()); | 1481 frame->setOwner(oldFrame->owner()); |
| 1482 | 1482 |
| 1483 if (frame->owner() && !frame->owner()->isLocal()) { | 1483 if (frame->owner() && !frame->owner()->isLocal()) { |
| 1484 toRemoteBridgeFrameOwner(frame->owner())->setSandboxFlags(static_cast<Sa
ndboxFlags>(flags)); | 1484 toRemoteBridgeFrameOwner(frame->owner())->setSandboxFlags(static_cast<Sa
ndboxFlags>(flags)); |
| 1485 // Since a remote frame doesn't get the notifications about frame owner | 1485 // Since a remote frame doesn't get the notifications about frame owner |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 visitor->trace(m_devToolsAgent); | 1541 visitor->trace(m_devToolsAgent); |
| 1542 visitor->trace(m_textFinder); | 1542 visitor->trace(m_textFinder); |
| 1543 visitor->trace(m_printContext); | 1543 visitor->trace(m_printContext); |
| 1544 visitor->trace(m_geolocationClientProxy); | 1544 visitor->trace(m_geolocationClientProxy); |
| 1545 visitor->template registerWeakMembers<WebFrame, &WebFrame::clearWeakFrames>(
this); | 1545 visitor->template registerWeakMembers<WebFrame, &WebFrame::clearWeakFrames>(
this); |
| 1546 WebFrame::traceFrames(visitor, this); | 1546 WebFrame::traceFrames(visitor, this); |
| 1547 WebFrameImplBase::trace(visitor); | 1547 WebFrameImplBase::trace(visitor); |
| 1548 } | 1548 } |
| 1549 #endif | 1549 #endif |
| 1550 | 1550 |
| 1551 void WebLocalFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<LocalFrame> frame) | 1551 void WebLocalFrameImpl::setCoreFrame(RawPtr<LocalFrame> frame) |
| 1552 { | 1552 { |
| 1553 m_frame = frame; | 1553 m_frame = frame; |
| 1554 | 1554 |
| 1555 // FIXME: we shouldn't add overhead to every frame by registering these obje
cts when they're not used. | 1555 // FIXME: we shouldn't add overhead to every frame by registering these obje
cts when they're not used. |
| 1556 if (m_frame) { | 1556 if (m_frame) { |
| 1557 if (m_client) | 1557 if (m_client) |
| 1558 providePushControllerTo(*m_frame, m_client->pushClient()); | 1558 providePushControllerTo(*m_frame, m_client->pushClient()); |
| 1559 | 1559 |
| 1560 provideNotificationPermissionClientTo(*m_frame, NotificationPermissionCl
ientImpl::create()); | 1560 provideNotificationPermissionClientTo(*m_frame, NotificationPermissionCl
ientImpl::create()); |
| 1561 provideUserMediaTo(*m_frame, &m_userMediaClientImpl); | 1561 provideUserMediaTo(*m_frame, &m_userMediaClientImpl); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1587 void WebLocalFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner,
const AtomicString& name, const AtomicString& fallbackName) | 1587 void WebLocalFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner,
const AtomicString& name, const AtomicString& fallbackName) |
| 1588 { | 1588 { |
| 1589 setCoreFrame(LocalFrame::create(m_frameLoaderClientImpl.get(), host, owner))
; | 1589 setCoreFrame(LocalFrame::create(m_frameLoaderClientImpl.get(), host, owner))
; |
| 1590 frame()->tree().setName(name, fallbackName); | 1590 frame()->tree().setName(name, fallbackName); |
| 1591 // We must call init() after m_frame is assigned because it is referenced | 1591 // We must call init() after m_frame is assigned because it is referenced |
| 1592 // during init(). Note that this may dispatch JS events; the frame may be | 1592 // during init(). Note that this may dispatch JS events; the frame may be |
| 1593 // detached after init() returns. | 1593 // detached after init() returns. |
| 1594 frame()->init(); | 1594 frame()->init(); |
| 1595 } | 1595 } |
| 1596 | 1596 |
| 1597 PassRefPtrWillBeRawPtr<LocalFrame> WebLocalFrameImpl::createChildFrame(const Fra
meLoadRequest& request, | 1597 RawPtr<LocalFrame> WebLocalFrameImpl::createChildFrame(const FrameLoadRequest& r
equest, |
| 1598 const AtomicString& name, HTMLFrameOwnerElement* ownerElement) | 1598 const AtomicString& name, HTMLFrameOwnerElement* ownerElement) |
| 1599 { | 1599 { |
| 1600 ASSERT(m_client); | 1600 ASSERT(m_client); |
| 1601 TRACE_EVENT0("blink", "WebLocalFrameImpl::createChildframe"); | 1601 TRACE_EVENT0("blink", "WebLocalFrameImpl::createChildframe"); |
| 1602 WebTreeScopeType scope = frame()->document() == ownerElement->treeScope() | 1602 WebTreeScopeType scope = frame()->document() == ownerElement->treeScope() |
| 1603 ? WebTreeScopeType::Document | 1603 ? WebTreeScopeType::Document |
| 1604 : WebTreeScopeType::Shadow; | 1604 : WebTreeScopeType::Shadow; |
| 1605 WebFrameOwnerProperties ownerProperties(ownerElement->scrollingMode(), owner
Element->marginWidth(), ownerElement->marginHeight()); | 1605 WebFrameOwnerProperties ownerProperties(ownerElement->scrollingMode(), owner
Element->marginWidth(), ownerElement->marginHeight()); |
| 1606 RefPtrWillBeRawPtr<WebLocalFrameImpl> webframeChild = toWebLocalFrameImpl(m_
client->createChildFrame(this, scope, name, static_cast<WebSandboxFlags>(ownerEl
ement->sandboxFlags()), ownerProperties)); | 1606 RawPtr<WebLocalFrameImpl> webframeChild = toWebLocalFrameImpl(m_client->crea
teChildFrame(this, scope, name, static_cast<WebSandboxFlags>(ownerElement->sandb
oxFlags()), ownerProperties)); |
| 1607 if (!webframeChild) | 1607 if (!webframeChild) |
| 1608 return nullptr; | 1608 return nullptr; |
| 1609 | 1609 |
| 1610 // FIXME: Using subResourceAttributeName as fallback is not a perfect | 1610 // FIXME: Using subResourceAttributeName as fallback is not a perfect |
| 1611 // solution. subResourceAttributeName returns just one attribute name. The | 1611 // solution. subResourceAttributeName returns just one attribute name. The |
| 1612 // element might not have the attribute, and there might be other attributes | 1612 // element might not have the attribute, and there might be other attributes |
| 1613 // which can identify the element. | 1613 // which can identify the element. |
| 1614 webframeChild->initializeCoreFrame(frame()->host(), ownerElement, name, owne
rElement->getAttribute(ownerElement->subResourceAttributeName())); | 1614 webframeChild->initializeCoreFrame(frame()->host(), ownerElement, name, owne
rElement->getAttribute(ownerElement->subResourceAttributeName())); |
| 1615 // Initializing the core frame may cause the new child to be detached, since | 1615 // Initializing the core frame may cause the new child to be detached, since |
| 1616 // it may dispatch a load event in the parent. | 1616 // it may dispatch a load event in the parent. |
| 1617 if (!webframeChild->parent()) | 1617 if (!webframeChild->parent()) |
| 1618 return nullptr; | 1618 return nullptr; |
| 1619 | 1619 |
| 1620 // If we're moving in the back/forward list, we might want to replace the co
ntent | 1620 // If we're moving in the back/forward list, we might want to replace the co
ntent |
| 1621 // of this child frame with whatever was there at that point. | 1621 // of this child frame with whatever was there at that point. |
| 1622 RefPtrWillBeRawPtr<HistoryItem> childItem = nullptr; | 1622 RawPtr<HistoryItem> childItem = nullptr; |
| 1623 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen
t()->loadEventFinished()) | 1623 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen
t()->loadEventFinished()) |
| 1624 childItem = PassRefPtrWillBeRawPtr<HistoryItem>(webframeChild->client()-
>historyItemForNewChildFrame()); | 1624 childItem = RawPtr<HistoryItem>(webframeChild->client()->historyItemForN
ewChildFrame()); |
| 1625 | 1625 |
| 1626 FrameLoadRequest newRequest = request; | 1626 FrameLoadRequest newRequest = request; |
| 1627 FrameLoadType loadType = FrameLoadTypeStandard; | 1627 FrameLoadType loadType = FrameLoadTypeStandard; |
| 1628 if (childItem) { | 1628 if (childItem) { |
| 1629 newRequest = FrameLoadRequest(request.originDocument(), | 1629 newRequest = FrameLoadRequest(request.originDocument(), |
| 1630 FrameLoader::resourceRequestFromHistoryItem(childItem.get(), UseProt
ocolCachePolicy)); | 1630 FrameLoader::resourceRequestFromHistoryItem(childItem.get(), UseProt
ocolCachePolicy)); |
| 1631 loadType = FrameLoadTypeInitialHistoryLoad; | 1631 loadType = FrameLoadTypeInitialHistoryLoad; |
| 1632 } | 1632 } |
| 1633 webframeChild->frame()->loader().load(newRequest, loadType, childItem.get())
; | 1633 webframeChild->frame()->loader().load(newRequest, loadType, childItem.get())
; |
| 1634 | 1634 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 // Unfortunately, we cannot just use that method since it is private, and | 1824 // Unfortunately, we cannot just use that method since it is private, and |
| 1825 // it also doesn't quite behave as we require it to for bookmarklets. The | 1825 // it also doesn't quite behave as we require it to for bookmarklets. The |
| 1826 // key difference is that we need to suppress loading the string result | 1826 // key difference is that we need to suppress loading the string result |
| 1827 // from evaluating the JS URL if executing the JS URL resulted in a | 1827 // from evaluating the JS URL if executing the JS URL resulted in a |
| 1828 // location change. We also allow a JS URL to be loaded even if scripts on | 1828 // location change. We also allow a JS URL to be loaded even if scripts on |
| 1829 // the page are otherwise disabled. | 1829 // the page are otherwise disabled. |
| 1830 | 1830 |
| 1831 if (!frame()->document() || !frame()->page()) | 1831 if (!frame()->document() || !frame()->page()) |
| 1832 return; | 1832 return; |
| 1833 | 1833 |
| 1834 RefPtrWillBeRawPtr<Document> ownerDocument(frame()->document()); | 1834 RawPtr<Document> ownerDocument(frame()->document()); |
| 1835 | 1835 |
| 1836 // Protect privileged pages against bookmarklets and other javascript manipu
lations. | 1836 // Protect privileged pages against bookmarklets and other javascript manipu
lations. |
| 1837 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()-
>document()->url().protocol())) | 1837 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()-
>document()->url().protocol())) |
| 1838 return; | 1838 return; |
| 1839 | 1839 |
| 1840 String script = decodeURLEscapeSequences(url.string().substring(strlen("java
script:"))); | 1840 String script = decodeURLEscapeSequences(url.string().substring(strlen("java
script:"))); |
| 1841 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 1841 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
| 1842 v8::HandleScope handleScope(toIsolate(frame())); | 1842 v8::HandleScope handleScope(toIsolate(frame())); |
| 1843 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR
eturnValue(ScriptSourceCode(script)); | 1843 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR
eturnValue(ScriptSourceCode(script)); |
| 1844 if (result.IsEmpty() || !result->IsString()) | 1844 if (result.IsEmpty() || !result->IsString()) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1926 { | 1926 { |
| 1927 ASSERT(frame()); | 1927 ASSERT(frame()); |
| 1928 Element* anchor = contextNode.constUnwrap<Node>()->enclosingLinkEventParentO
rSelf(); | 1928 Element* anchor = contextNode.constUnwrap<Node>()->enclosingLinkEventParentO
rSelf(); |
| 1929 if (isHTMLAnchorElement(anchor)) | 1929 if (isHTMLAnchorElement(anchor)) |
| 1930 toHTMLAnchorElement(anchor)->sendPings(destinationURL); | 1930 toHTMLAnchorElement(anchor)->sendPings(destinationURL); |
| 1931 } | 1931 } |
| 1932 | 1932 |
| 1933 WebURLRequest WebLocalFrameImpl::requestFromHistoryItem(const WebHistoryItem& it
em, | 1933 WebURLRequest WebLocalFrameImpl::requestFromHistoryItem(const WebHistoryItem& it
em, |
| 1934 WebURLRequest::CachePolicy cachePolicy) const | 1934 WebURLRequest::CachePolicy cachePolicy) const |
| 1935 { | 1935 { |
| 1936 RefPtrWillBeRawPtr<HistoryItem> historyItem = PassRefPtrWillBeRawPtr<History
Item>(item); | 1936 RawPtr<HistoryItem> historyItem = RawPtr<HistoryItem>(item); |
| 1937 ResourceRequest request = FrameLoader::resourceRequestFromHistoryItem( | 1937 ResourceRequest request = FrameLoader::resourceRequestFromHistoryItem( |
| 1938 historyItem.get(), static_cast<ResourceRequestCachePolicy>(cachePolicy))
; | 1938 historyItem.get(), static_cast<ResourceRequestCachePolicy>(cachePolicy))
; |
| 1939 return WrappedResourceRequest(request); | 1939 return WrappedResourceRequest(request); |
| 1940 } | 1940 } |
| 1941 | 1941 |
| 1942 WebURLRequest WebLocalFrameImpl::requestForReload(WebFrameLoadType loadType, | 1942 WebURLRequest WebLocalFrameImpl::requestForReload(WebFrameLoadType loadType, |
| 1943 const WebURL& overrideUrl) const | 1943 const WebURL& overrideUrl) const |
| 1944 { | 1944 { |
| 1945 ASSERT(frame()); | 1945 ASSERT(frame()); |
| 1946 ResourceRequest request = frame()->loader().resourceRequestForReload( | 1946 ResourceRequest request = frame()->loader().resourceRequestForReload( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1957 | 1957 |
| 1958 if (resourceRequest.url().protocolIs("javascript") | 1958 if (resourceRequest.url().protocolIs("javascript") |
| 1959 && webFrameLoadType == WebFrameLoadType::Standard) { | 1959 && webFrameLoadType == WebFrameLoadType::Standard) { |
| 1960 loadJavaScriptURL(resourceRequest.url()); | 1960 loadJavaScriptURL(resourceRequest.url()); |
| 1961 return; | 1961 return; |
| 1962 } | 1962 } |
| 1963 | 1963 |
| 1964 FrameLoadRequest frameRequest = FrameLoadRequest(nullptr, resourceRequest); | 1964 FrameLoadRequest frameRequest = FrameLoadRequest(nullptr, resourceRequest); |
| 1965 if (isClientRedirect) | 1965 if (isClientRedirect) |
| 1966 frameRequest.setClientRedirect(ClientRedirect); | 1966 frameRequest.setClientRedirect(ClientRedirect); |
| 1967 RefPtrWillBeRawPtr<HistoryItem> historyItem = PassRefPtrWillBeRawPtr<History
Item>(item); | 1967 RawPtr<HistoryItem> historyItem = RawPtr<HistoryItem>(item); |
| 1968 frame()->loader().load( | 1968 frame()->loader().load( |
| 1969 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem.
get(), | 1969 frameRequest, static_cast<FrameLoadType>(webFrameLoadType), historyItem.
get(), |
| 1970 static_cast<HistoryLoadType>(webHistoryLoadType)); | 1970 static_cast<HistoryLoadType>(webHistoryLoadType)); |
| 1971 } | 1971 } |
| 1972 | 1972 |
| 1973 bool WebLocalFrameImpl::isLoading() const | 1973 bool WebLocalFrameImpl::isLoading() const |
| 1974 { | 1974 { |
| 1975 if (!frame() || !frame()->document()) | 1975 if (!frame() || !frame()->document()) |
| 1976 return false; | 1976 return false; |
| 1977 return frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument()
|| frame()->loader().provisionalDocumentLoader() || !frame()->document()->loadEv
entFinished(); | 1977 return frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument()
|| frame()->loader().provisionalDocumentLoader() || !frame()->document()->loadEv
entFinished(); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2177 return WebSandboxFlags::None; | 2177 return WebSandboxFlags::None; |
| 2178 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); | 2178 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags(
)); |
| 2179 } | 2179 } |
| 2180 | 2180 |
| 2181 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) | 2181 void WebLocalFrameImpl::forceSandboxFlags(WebSandboxFlags flags) |
| 2182 { | 2182 { |
| 2183 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); | 2183 frame()->loader().forceSandboxFlags(static_cast<SandboxFlags>(flags)); |
| 2184 } | 2184 } |
| 2185 | 2185 |
| 2186 } // namespace blink | 2186 } // namespace blink |
| OLD | NEW |