Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp

Issue 2389633002: reflow comments in web/ (Closed)
Patch Set: . Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 25 matching lines...) Expand all
36 // WebView (for the toplevel frame only) 36 // WebView (for the toplevel frame only)
37 // O 37 // O
38 // | WebFrame 38 // | WebFrame
39 // | O 39 // | O
40 // | | 40 // | |
41 // Page O------- LocalFrame (m_mainFrame) O-------O FrameView 41 // Page O------- LocalFrame (m_mainFrame) O-------O FrameView
42 // || 42 // ||
43 // || 43 // ||
44 // FrameLoader 44 // FrameLoader
45 // 45 //
46 // FrameLoader and LocalFrame are formerly one object that was split apart becau se 46 // FrameLoader and LocalFrame are formerly one object that was split apart
47 // it got too big. They basically have the same lifetime, hence the double line. 47 // because it got too big. They basically have the same lifetime, hence the
48 // double line.
48 // 49 //
49 // From the perspective of the embedder, WebFrame is simply an object that it 50 // From the perspective of the embedder, WebFrame is simply an object that it
50 // allocates by calling WebFrame::create() and must be freed by calling close(). 51 // allocates by calling WebFrame::create() and must be freed by calling close().
51 // Internally, WebFrame is actually refcounted and it holds a reference to its 52 // Internally, WebFrame is actually refcounted and it holds a reference to its
52 // corresponding LocalFrame in blink. 53 // corresponding LocalFrame in blink.
53 // 54 //
54 // Oilpan: the middle objects + Page in the above diagram are Oilpan heap alloca ted, 55 // Oilpan: the middle objects + Page in the above diagram are Oilpan heap
55 // WebView and FrameView are currently not. In terms of ownership and control, t he 56 // allocated, WebView and FrameView are currently not. In terms of ownership
56 // relationships stays the same, but the references from the off-heap WebView to the 57 // and control, the relationships stays the same, but the references from the
57 // on-heap Page is handled by a Persistent<>, not a RefPtr<>. Similarly, the mut ual 58 // off-heap WebView to the on-heap Page is handled by a Persistent<>, not a
58 // strong references between the on-heap LocalFrame and the off-heap FrameView 59 // RefPtr<>. Similarly, the mutual strong references between the on-heap
59 // is through a RefPtr (from LocalFrame to FrameView), and a Persistent refers 60 // LocalFrame and the off-heap FrameView is through a RefPtr (from LocalFrame
60 // to the LocalFrame in the other direction. 61 // to FrameView), and a Persistent refers to the LocalFrame in the other
62 // direction.
61 // 63 //
62 // From the embedder's point of view, the use of Oilpan brings no changes. close () 64 // From the embedder's point of view, the use of Oilpan brings no changes.
63 // must still be used to signal that the embedder is through with the WebFrame. 65 // close() must still be used to signal that the embedder is through with the
64 // Calling it will bring about the release and finalization of the frame object, 66 // WebFrame. Calling it will bring about the release and finalization of the
65 // and everything underneath. 67 // frame object, and everything underneath.
66 // 68 //
67 // How frames are destroyed 69 // How frames are destroyed
68 // ------------------------ 70 // ------------------------
69 // 71 //
70 // The main frame is never destroyed and is re-used. The FrameLoader is re-used 72 // The main frame is never destroyed and is re-used. The FrameLoader is re-used
71 // and a reference to the main frame is kept by the Page. 73 // and a reference to the main frame is kept by the Page.
72 // 74 //
73 // When frame content is replaced, all subframes are destroyed. This happens 75 // When frame content is replaced, all subframes are destroyed. This happens
74 // in Frame::detachChildren for each subframe in a pre-order depth-first 76 // in Frame::detachChildren for each subframe in a pre-order depth-first
75 // traversal. Note that child node order may not match DOM node order! 77 // traversal. Note that child node order may not match DOM node order!
76 // detachChildren() (virtually) calls Frame::detach(), which again calls 78 // detachChildren() (virtually) calls Frame::detach(), which again calls
77 // FrameLoaderClient::detached(). This triggers WebFrame to clear its reference to 79 // FrameLoaderClient::detached(). This triggers WebFrame to clear its reference
78 // LocalFrame. FrameLoaderClient::detached() also notifies the embedder via WebF rameClient 80 // to LocalFrame. FrameLoaderClient::detached() also notifies the embedder via
79 // that the frame is detached. Most embedders will invoke close() on the WebFram e 81 // WebFrameClient that the frame is detached. Most embedders will invoke
80 // at this point, triggering its deletion unless something else is still retaini ng a reference. 82 // close() on the WebFrame at this point, triggering its deletion unless
83 // something else is still retaining a reference.
81 // 84 //
82 // The client is expected to be set whenever the WebLocalFrameImpl is attached t o 85 // The client is expected to be set whenever the WebLocalFrameImpl is attached
83 // the DOM. 86 // to the DOM.
84 87
85 #include "web/WebLocalFrameImpl.h" 88 #include "web/WebLocalFrameImpl.h"
86 89
87 #include "bindings/core/v8/BindingSecurity.h" 90 #include "bindings/core/v8/BindingSecurity.h"
88 #include "bindings/core/v8/DOMWrapperWorld.h" 91 #include "bindings/core/v8/DOMWrapperWorld.h"
89 #include "bindings/core/v8/ExceptionState.h" 92 #include "bindings/core/v8/ExceptionState.h"
90 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 93 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
91 #include "bindings/core/v8/ScriptController.h" 94 #include "bindings/core/v8/ScriptController.h"
92 #include "bindings/core/v8/ScriptSourceCode.h" 95 #include "bindings/core/v8/ScriptSourceCode.h"
93 #include "bindings/core/v8/ScriptValue.h" 96 #include "bindings/core/v8/ScriptValue.h"
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 unsigned length, 986 unsigned length,
984 WebRect& rectInViewport) const { 987 WebRect& rectInViewport) const {
985 if ((location + length < location) && (location + length)) 988 if ((location + length < location) && (location + length))
986 length = 0; 989 length = 0;
987 990
988 Element* editable = 991 Element* editable =
989 frame()->selection().rootEditableElementOrDocumentElement(); 992 frame()->selection().rootEditableElementOrDocumentElement();
990 if (!editable) 993 if (!editable)
991 return false; 994 return false;
992 995
993 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets nee ds to be audited. 996 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets
994 // see http://crbug.com/590369 for more details. 997 // needs to be audited. see http://crbug.com/590369 for more details.
995 editable->document().updateStyleAndLayoutIgnorePendingStylesheets(); 998 editable->document().updateStyleAndLayoutIgnorePendingStylesheets();
996 999
997 const EphemeralRange range = 1000 const EphemeralRange range =
998 PlainTextRange(location, location + length).createRange(*editable); 1001 PlainTextRange(location, location + length).createRange(*editable);
999 if (range.isNull()) 1002 if (range.isNull())
1000 return false; 1003 return false;
1001 IntRect intRect = frame()->editor().firstRectForRange(range); 1004 IntRect intRect = frame()->editor().firstRectForRange(range);
1002 rectInViewport = WebRect(intRect); 1005 rectInViewport = WebRect(intRect);
1003 rectInViewport = frame()->view()->contentsToViewport(rectInViewport); 1006 rectInViewport = frame()->view()->contentsToViewport(rectInViewport);
1004 return true; 1007 return true;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 } 1075 }
1073 1076
1074 bool WebLocalFrameImpl::isSpellCheckingEnabled() const { 1077 bool WebLocalFrameImpl::isSpellCheckingEnabled() const {
1075 return frame()->spellChecker().isSpellCheckingEnabled(); 1078 return frame()->spellChecker().isSpellCheckingEnabled();
1076 } 1079 }
1077 1080
1078 void WebLocalFrameImpl::requestTextChecking(const WebElement& webElement) { 1081 void WebLocalFrameImpl::requestTextChecking(const WebElement& webElement) {
1079 if (webElement.isNull()) 1082 if (webElement.isNull())
1080 return; 1083 return;
1081 1084
1082 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited. 1085 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
1083 // see http://crbug.com/590369 for more details. 1086 // needs to be audited. see http://crbug.com/590369 for more details.
1084 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1087 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
1085 1088
1086 DocumentLifecycle::DisallowTransitionScope disallowTransition( 1089 DocumentLifecycle::DisallowTransitionScope disallowTransition(
1087 frame()->document()->lifecycle()); 1090 frame()->document()->lifecycle());
1088 1091
1089 frame()->spellChecker().requestTextChecking( 1092 frame()->spellChecker().requestTextChecking(
1090 *webElement.constUnwrap<Element>()); 1093 *webElement.constUnwrap<Element>());
1091 } 1094 }
1092 1095
1093 void WebLocalFrameImpl::replaceMisspelledRange(const WebString& text) { 1096 void WebLocalFrameImpl::replaceMisspelledRange(const WebString& text) {
1094 // If this caret selection has two or more markers, this function replace the range covered by the first marker with the specified word as Microsoft Word does . 1097 // If this caret selection has two or more markers, this function replace the
1098 // range covered by the first marker with the specified word as Microsoft Word
1099 // does.
1095 if (pluginContainerFromFrame(frame())) 1100 if (pluginContainerFromFrame(frame()))
1096 return; 1101 return;
1097 frame()->spellChecker().replaceMisspelledRange(text); 1102 frame()->spellChecker().replaceMisspelledRange(text);
1098 } 1103 }
1099 1104
1100 void WebLocalFrameImpl::removeSpellingMarkers() { 1105 void WebLocalFrameImpl::removeSpellingMarkers() {
1101 frame()->spellChecker().removeSpellingMarkers(); 1106 frame()->spellChecker().removeSpellingMarkers();
1102 } 1107 }
1103 1108
1104 bool WebLocalFrameImpl::hasSelection() const { 1109 bool WebLocalFrameImpl::hasSelection() const {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 if (pluginContainer) 1142 if (pluginContainer)
1138 return pluginContainer->plugin()->selectionAsMarkup(); 1143 return pluginContainer->plugin()->selectionAsMarkup();
1139 1144
1140 return frame()->selection().selectedHTMLForClipboard(); 1145 return frame()->selection().selectedHTMLForClipboard();
1141 } 1146 }
1142 1147
1143 void WebLocalFrameImpl::selectWordAroundPosition(LocalFrame* frame, 1148 void WebLocalFrameImpl::selectWordAroundPosition(LocalFrame* frame,
1144 VisiblePosition position) { 1149 VisiblePosition position) {
1145 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectWordAroundPosition"); 1150 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectWordAroundPosition");
1146 1151
1147 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited. 1152 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
1148 // see http://crbug.com/590369 for more details. 1153 // needs to be audited. see http://crbug.com/590369 for more details.
1149 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1154 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
1150 1155
1151 frame->selection().selectWordAroundPosition(position); 1156 frame->selection().selectWordAroundPosition(position);
1152 } 1157 }
1153 1158
1154 bool WebLocalFrameImpl::selectWordAroundCaret() { 1159 bool WebLocalFrameImpl::selectWordAroundCaret() {
1155 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectWordAroundCaret"); 1160 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectWordAroundCaret");
1156 FrameSelection& selection = frame()->selection(); 1161 FrameSelection& selection = frame()->selection();
1157 if (selection.isNone() || selection.isRange()) 1162 if (selection.isNone() || selection.isRange())
1158 return false; 1163 return false;
1159 1164
1160 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited. 1165 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
1161 // see http://crbug.com/590369 for more details. 1166 // needs to be audited. see http://crbug.com/590369 for more details.
1162 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1167 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
1163 1168
1164 return frame()->selection().selectWordAroundPosition( 1169 return frame()->selection().selectWordAroundPosition(
1165 selection.selection().visibleStart()); 1170 selection.selection().visibleStart());
1166 } 1171 }
1167 1172
1168 void WebLocalFrameImpl::selectRange(const WebPoint& baseInViewport, 1173 void WebLocalFrameImpl::selectRange(const WebPoint& baseInViewport,
1169 const WebPoint& extentInViewport) { 1174 const WebPoint& extentInViewport) {
1170 moveRangeSelection(baseInViewport, extentInViewport); 1175 moveRangeSelection(baseInViewport, extentInViewport);
1171 } 1176 }
1172 1177
1173 void WebLocalFrameImpl::selectRange(const WebRange& webRange) { 1178 void WebLocalFrameImpl::selectRange(const WebRange& webRange) {
1174 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectRange"); 1179 TRACE_EVENT0("blink", "WebLocalFrameImpl::selectRange");
1175 1180
1176 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets nee ds to be audited. 1181 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets
1177 // see http://crbug.com/590369 for more details. 1182 // needs to be audited. see http://crbug.com/590369 for more details.
1178 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1183 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
1179 1184
1180 DocumentLifecycle::DisallowTransitionScope disallowTransition( 1185 DocumentLifecycle::DisallowTransitionScope disallowTransition(
1181 frame()->document()->lifecycle()); 1186 frame()->document()->lifecycle());
1182 1187
1183 frame()->selection().setSelectedRange( 1188 frame()->selection().setSelectedRange(
1184 webRange.createEphemeralRange(frame()), VP_DEFAULT_AFFINITY, 1189 webRange.createEphemeralRange(frame()), VP_DEFAULT_AFFINITY,
1185 SelectionDirectionalMode::NonDirectional, NotUserTriggered); 1190 SelectionDirectionalMode::NonDirectional, NotUserTriggered);
1186 } 1191 }
1187 1192
1188 WebString WebLocalFrameImpl::rangeAsText(const WebRange& webRange) { 1193 WebString WebLocalFrameImpl::rangeAsText(const WebRange& webRange) {
1189 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets nee ds to be audited. 1194 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets
1190 // see http://crbug.com/590369 for more details. 1195 // needs to be audited. see http://crbug.com/590369 for more details.
1191 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1196 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
1192 1197
1193 DocumentLifecycle::DisallowTransitionScope disallowTransition( 1198 DocumentLifecycle::DisallowTransitionScope disallowTransition(
1194 frame()->document()->lifecycle()); 1199 frame()->document()->lifecycle());
1195 1200
1196 return plainText(webRange.createEphemeralRange(frame()), 1201 return plainText(webRange.createEphemeralRange(frame()),
1197 TextIteratorEmitsObjectReplacementCharacter); 1202 TextIteratorEmitsObjectReplacementCharacter);
1198 } 1203 }
1199 1204
1200 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point) { 1205 void WebLocalFrameImpl::moveRangeSelectionExtent(const WebPoint& point) {
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 } 1446 }
1442 1447
1443 WebString WebLocalFrameImpl::layerTreeAsText(bool showDebugInfo) const { 1448 WebString WebLocalFrameImpl::layerTreeAsText(bool showDebugInfo) const {
1444 if (!frame()) 1449 if (!frame())
1445 return WebString(); 1450 return WebString();
1446 1451
1447 return WebString(frame()->layerTreeAsText( 1452 return WebString(frame()->layerTreeAsText(
1448 showDebugInfo ? LayerTreeIncludesDebugInfo : LayerTreeNormal)); 1453 showDebugInfo ? LayerTreeIncludesDebugInfo : LayerTreeNormal));
1449 } 1454 }
1450 1455
1451 // WebLocalFrameImpl public ---------------------------------------------------- ----- 1456 // WebLocalFrameImpl public --------------------------------------------------
1452 1457
1453 WebLocalFrame* WebLocalFrame::create(WebTreeScopeType scope, 1458 WebLocalFrame* WebLocalFrame::create(WebTreeScopeType scope,
1454 WebFrameClient* client, 1459 WebFrameClient* client,
1455 WebFrame* opener) { 1460 WebFrame* opener) {
1456 return WebLocalFrameImpl::create(scope, client, opener); 1461 return WebLocalFrameImpl::create(scope, client, opener);
1457 } 1462 }
1458 1463
1459 WebLocalFrame* WebLocalFrame::createProvisional(WebFrameClient* client, 1464 WebLocalFrame* WebLocalFrame::createProvisional(WebFrameClient* client,
1460 WebRemoteFrame* oldWebFrame, 1465 WebRemoteFrame* oldWebFrame,
1461 WebSandboxFlags flags) { 1466 WebSandboxFlags flags) {
(...skipping 14 matching lines...) Expand all
1476 WebSandboxFlags flags) { 1481 WebSandboxFlags flags) {
1477 WebLocalFrameImpl* webFrame = new WebLocalFrameImpl(oldWebFrame, client); 1482 WebLocalFrameImpl* webFrame = new WebLocalFrameImpl(oldWebFrame, client);
1478 Frame* oldFrame = oldWebFrame->toImplBase()->frame(); 1483 Frame* oldFrame = oldWebFrame->toImplBase()->frame();
1479 webFrame->setParent(oldWebFrame->parent()); 1484 webFrame->setParent(oldWebFrame->parent());
1480 webFrame->setOpener(oldWebFrame->opener()); 1485 webFrame->setOpener(oldWebFrame->opener());
1481 // Note: this *always* temporarily sets a frame owner, even for main frames! 1486 // Note: this *always* temporarily sets a frame owner, even for main frames!
1482 // When a core Frame is created with no owner, it attempts to set itself as 1487 // When a core Frame is created with no owner, it attempts to set itself as
1483 // the main frame of the Page. However, this is a provisional frame, and may 1488 // the main frame of the Page. However, this is a provisional frame, and may
1484 // disappear, so Page::m_mainFrame can't be updated just yet. 1489 // disappear, so Page::m_mainFrame can't be updated just yet.
1485 FrameOwner* tempOwner = DummyFrameOwner::create(); 1490 FrameOwner* tempOwner = DummyFrameOwner::create();
1486 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to reu se it here. 1491 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to
1492 // reuse it here.
1487 LocalFrame* frame = LocalFrame::create( 1493 LocalFrame* frame = LocalFrame::create(
1488 webFrame->m_frameLoaderClientImpl.get(), oldFrame->host(), tempOwner, 1494 webFrame->m_frameLoaderClientImpl.get(), oldFrame->host(), tempOwner,
1489 client ? client->interfaceProvider() : nullptr); 1495 client ? client->interfaceProvider() : nullptr);
1490 // Set the name and unique name directly, bypassing any of the normal logic 1496 // Set the name and unique name directly, bypassing any of the normal logic
1491 // to calculate unique name. 1497 // to calculate unique name.
1492 frame->tree().setPrecalculatedName( 1498 frame->tree().setPrecalculatedName(
1493 toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().name(), 1499 toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().name(),
1494 toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().uniqueName()); 1500 toWebRemoteFrameImpl(oldWebFrame)->frame()->tree().uniqueName());
1495 webFrame->setCoreFrame(frame); 1501 webFrame->setCoreFrame(frame);
1496 1502
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 if (!webframeChild) 1605 if (!webframeChild)
1600 return nullptr; 1606 return nullptr;
1601 1607
1602 webframeChild->initializeCoreFrame(frame()->host(), ownerElement, name, 1608 webframeChild->initializeCoreFrame(frame()->host(), ownerElement, name,
1603 uniqueName); 1609 uniqueName);
1604 // Initializing the core frame may cause the new child to be detached, since 1610 // Initializing the core frame may cause the new child to be detached, since
1605 // it may dispatch a load event in the parent. 1611 // it may dispatch a load event in the parent.
1606 if (!webframeChild->parent()) 1612 if (!webframeChild->parent())
1607 return nullptr; 1613 return nullptr;
1608 1614
1609 // If we're moving in the back/forward list, we might want to replace the cont ent 1615 // If we're moving in the back/forward list, we might want to replace the
1610 // of this child frame with whatever was there at that point. 1616 // content of this child frame with whatever was there at that point.
1611 HistoryItem* childItem = nullptr; 1617 HistoryItem* childItem = nullptr;
1612 if (isBackForwardLoadType(frame()->loader().loadType()) && 1618 if (isBackForwardLoadType(frame()->loader().loadType()) &&
1613 !frame()->document()->loadEventFinished()) 1619 !frame()->document()->loadEventFinished())
1614 childItem = webframeChild->client()->historyItemForNewChildFrame(); 1620 childItem = webframeChild->client()->historyItemForNewChildFrame();
1615 1621
1616 FrameLoadRequest newRequest = request; 1622 FrameLoadRequest newRequest = request;
1617 FrameLoadType loadType = FrameLoadTypeStandard; 1623 FrameLoadType loadType = FrameLoadTypeStandard;
1618 if (childItem) { 1624 if (childItem) {
1619 newRequest = FrameLoadRequest( 1625 newRequest = FrameLoadRequest(
1620 request.originDocument(), 1626 request.originDocument(),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 if (!m_textFinder || !m_textFinder->activeMatchFrame()) 1712 if (!m_textFinder || !m_textFinder->activeMatchFrame())
1707 return; 1713 return;
1708 1714
1709 if (Range* activeMatch = m_textFinder->activeMatch()) { 1715 if (Range* activeMatch = m_textFinder->activeMatch()) {
1710 // If the user has set the selection since the match was found, we 1716 // If the user has set the selection since the match was found, we
1711 // don't focus anything. 1717 // don't focus anything.
1712 VisibleSelection selection(frame()->selection().selection()); 1718 VisibleSelection selection(frame()->selection().selection());
1713 if (!selection.isNone()) 1719 if (!selection.isNone())
1714 return; 1720 return;
1715 1721
1716 // Need to clean out style and layout state before querying Element::isFocus able(). 1722 // Need to clean out style and layout state before querying
1723 // Element::isFocusable().
1717 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1724 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
1718 1725
1719 // Try to find the first focusable node up the chain, which will, for 1726 // Try to find the first focusable node up the chain, which will, for
1720 // example, focus links if we have found text within the link. 1727 // example, focus links if we have found text within the link.
1721 Node* node = activeMatch->firstNode(); 1728 Node* node = activeMatch->firstNode();
1722 if (node && node->isInShadowTree()) { 1729 if (node && node->isInShadowTree()) {
1723 if (Node* host = node->ownerShadowHost()) { 1730 if (Node* host = node->ownerShadowHost()) {
1724 if (isHTMLInputElement(*host) || isHTMLTextAreaElement(*host)) 1731 if (isHTMLInputElement(*host) || isHTMLTextAreaElement(*host))
1725 node = host; 1732 node = host;
1726 } 1733 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 // active match as the selection (so that when you end the Find session, 1770 // active match as the selection (so that when you end the Find session,
1764 // you'll have the last thing you found highlighted) and make sure that 1771 // you'll have the last thing you found highlighted) and make sure that
1765 // we have nothing focused (otherwise you might have text selected but 1772 // we have nothing focused (otherwise you might have text selected but
1766 // a link focused, which is weird). 1773 // a link focused, which is weird).
1767 frame()->selection().setSelection(createVisibleSelection(activeMatchRange)); 1774 frame()->selection().setSelection(createVisibleSelection(activeMatchRange));
1768 frame()->document()->clearFocusedElement(); 1775 frame()->document()->clearFocusedElement();
1769 1776
1770 // Finally clear the active match, for two reasons: 1777 // Finally clear the active match, for two reasons:
1771 // We just finished the find 'session' and we don't want future (potentially 1778 // We just finished the find 'session' and we don't want future (potentially
1772 // unrelated) find 'sessions' operations to start at the same place. 1779 // unrelated) find 'sessions' operations to start at the same place.
1773 // The WebLocalFrameImpl could get reused and the activeMatch could end up p ointing 1780 // The WebLocalFrameImpl could get reused and the activeMatch could end up
1774 // to a document that is no longer valid. Keeping an invalid reference aroun d 1781 // pointing to a document that is no longer valid. Keeping an invalid
1775 // is just asking for trouble. 1782 // reference around is just asking for trouble.
1776 m_textFinder->resetActiveMatch(); 1783 m_textFinder->resetActiveMatch();
1777 } 1784 }
1778 } 1785 }
1779 1786
1780 void WebLocalFrameImpl::didFail(const ResourceError& error, 1787 void WebLocalFrameImpl::didFail(const ResourceError& error,
1781 bool wasProvisional, 1788 bool wasProvisional,
1782 HistoryCommitType commitType) { 1789 HistoryCommitType commitType) {
1783 if (!client()) 1790 if (!client())
1784 return; 1791 return;
1785 WebURLError webError = error; 1792 WebURLError webError = error;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 // key difference is that we need to suppress loading the string result 1833 // 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 1834 // 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 1835 // location change. We also allow a JS URL to be loaded even if scripts on
1829 // the page are otherwise disabled. 1836 // the page are otherwise disabled.
1830 1837
1831 if (!frame()->document() || !frame()->page()) 1838 if (!frame()->document() || !frame()->page())
1832 return; 1839 return;
1833 1840
1834 Document* ownerDocument(frame()->document()); 1841 Document* ownerDocument(frame()->document());
1835 1842
1836 // Protect privileged pages against bookmarklets and other javascript manipula tions. 1843 // Protect privileged pages against bookmarklets and other javascript
1844 // manipulations.
1837 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs( 1845 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(
1838 frame()->document()->url().protocol())) 1846 frame()->document()->url().protocol()))
1839 return; 1847 return;
1840 1848
1841 String script = decodeURLEscapeSequences( 1849 String script = decodeURLEscapeSequences(
1842 url.getString().substring(strlen("javascript:"))); 1850 url.getString().substring(strlen("javascript:")));
1843 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 1851 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
1844 v8::HandleScope handleScope(toIsolate(frame())); 1852 v8::HandleScope handleScope(toIsolate(frame()));
1845 v8::Local<v8::Value> result = 1853 v8::Local<v8::Value> result =
1846 frame()->script().executeScriptInMainWorldAndReturnValue( 1854 frame()->script().executeScriptInMainWorldAndReturnValue(
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 const WebString& searchText, 2131 const WebString& searchText,
2124 const WebFindOptions& options, 2132 const WebFindOptions& options,
2125 bool wrapWithinFrame, 2133 bool wrapWithinFrame,
2126 bool* activeNow) { 2134 bool* activeNow) {
2127 if (!frame()) 2135 if (!frame())
2128 return false; 2136 return false;
2129 2137
2130 // Unlikely, but just in case we try to find-in-page on a detached frame. 2138 // Unlikely, but just in case we try to find-in-page on a detached frame.
2131 DCHECK(frame()->host()); 2139 DCHECK(frame()->host());
2132 2140
2133 // Up-to-date, clean tree is required for finding text in page, since it relie s 2141 // Up-to-date, clean tree is required for finding text in page, since it
2134 // on TextIterator to look over the text. 2142 // relies on TextIterator to look over the text.
2135 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 2143 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
2136 2144
2137 return ensureTextFinder().find(identifier, searchText, options, 2145 return ensureTextFinder().find(identifier, searchText, options,
2138 wrapWithinFrame, activeNow); 2146 wrapWithinFrame, activeNow);
2139 } 2147 }
2140 2148
2141 void WebLocalFrameImpl::stopFinding(StopFindAction action) { 2149 void WebLocalFrameImpl::stopFinding(StopFindAction action) {
2142 bool clearSelection = action == StopFindActionClearSelection; 2150 bool clearSelection = action == StopFindActionClearSelection;
2143 if (clearSelection) 2151 if (clearSelection)
2144 executeCommand(WebString::fromUTF8("Unselect")); 2152 executeCommand(WebString::fromUTF8("Unselect"));
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol; 2328 feature = UseCounter::ChromeLoadTimesNpnNegotiatedProtocol;
2321 } else if (metric == "wasAlternateProtocolAvailable") { 2329 } else if (metric == "wasAlternateProtocolAvailable") {
2322 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable; 2330 feature = UseCounter::ChromeLoadTimesWasAlternateProtocolAvailable;
2323 } else if (metric == "connectionInfo") { 2331 } else if (metric == "connectionInfo") {
2324 feature = UseCounter::ChromeLoadTimesConnectionInfo; 2332 feature = UseCounter::ChromeLoadTimesConnectionInfo;
2325 } 2333 }
2326 UseCounter::count(frame(), feature); 2334 UseCounter::count(frame(), feature);
2327 } 2335 }
2328 2336
2329 } // namespace blink 2337 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebLocalFrameImpl.h ('k') | third_party/WebKit/Source/web/WebPagePopupImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698