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

Side by Side Diff: Source/web/ContextMenuClientImpl.cpp

Issue 31063004: Have Frame::loader() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2012 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 using namespace WebCore; 80 using namespace WebCore;
81 81
82 namespace WebKit { 82 namespace WebKit {
83 83
84 // Figure out the URL of a page or subframe. Returns |page_type| as the type, 84 // Figure out the URL of a page or subframe. Returns |page_type| as the type,
85 // which indicates page or subframe, or ContextNodeType::NONE if the URL could n ot 85 // which indicates page or subframe, or ContextNodeType::NONE if the URL could n ot
86 // be determined for some reason. 86 // be determined for some reason.
87 static WebURL urlFromFrame(Frame* frame) 87 static WebURL urlFromFrame(Frame* frame)
88 { 88 {
89 if (frame) { 89 if (frame) {
90 DocumentLoader* dl = frame->loader()->documentLoader(); 90 DocumentLoader* dl = frame->loader().documentLoader();
91 if (dl) { 91 if (dl) {
92 WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl); 92 WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl);
93 if (ds) 93 if (ds)
94 return ds->hasUnreachableURL() ? ds->unreachableURL() : ds->requ est().url(); 94 return ds->hasUnreachableURL() ? ds->unreachableURL() : ds->requ est().url();
95 } 95 }
96 } 96 }
97 return WebURL(); 97 return WebURL();
98 } 98 }
99 99
100 // Helper function to determine whether text is a single word. 100 // Helper function to determine whether text is a single word.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 // If it's not a link, an image, a media element, or an image/media link, 282 // If it's not a link, an image, a media element, or an image/media link,
283 // show a selection menu or a more generic page menu. 283 // show a selection menu or a more generic page menu.
284 if (selectedFrame->document()->loader()) 284 if (selectedFrame->document()->loader())
285 data.frameEncoding = selectedFrame->document()->encodingName(); 285 data.frameEncoding = selectedFrame->document()->encodingName();
286 286
287 // Send the frame and page URLs in any case. 287 // Send the frame and page URLs in any case.
288 data.pageURL = urlFromFrame(m_webView->mainFrameImpl()->frame()); 288 data.pageURL = urlFromFrame(m_webView->mainFrameImpl()->frame());
289 if (selectedFrame != m_webView->mainFrameImpl()->frame()) { 289 if (selectedFrame != m_webView->mainFrameImpl()->frame()) {
290 data.frameURL = urlFromFrame(selectedFrame); 290 data.frameURL = urlFromFrame(selectedFrame);
291 RefPtr<HistoryItem> historyItem = selectedFrame->loader()->history()->cu rrentItem(); 291 RefPtr<HistoryItem> historyItem = selectedFrame->loader().history()->cur rentItem();
292 if (historyItem) 292 if (historyItem)
293 data.frameHistoryItem = WebHistoryItem(historyItem); 293 data.frameHistoryItem = WebHistoryItem(historyItem);
294 } 294 }
295 295
296 if (r.isSelected()) { 296 if (r.isSelected()) {
297 if (!r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag) || !toHTMLI nputElement(r.innerNonSharedNode())->isPasswordField()) 297 if (!r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag) || !toHTMLI nputElement(r.innerNonSharedNode())->isPasswordField())
298 data.selectedText = selectedFrame->selectedText().stripWhiteSpace(); 298 data.selectedText = selectedFrame->selectedText().stripWhiteSpace();
299 } 299 }
300 300
301 if (r.isContentEditable()) { 301 if (r.isContentEditable()) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 347 }
348 348
349 #if OS(MACOSX) 349 #if OS(MACOSX)
350 if (selectedFrame->editor().selectionHasStyle(CSSPropertyDirection, "ltr") ! = FalseTriState) 350 if (selectedFrame->editor().selectionHasStyle(CSSPropertyDirection, "ltr") ! = FalseTriState)
351 data.writingDirectionLeftToRight |= WebContextMenuData::CheckableMenuIte mChecked; 351 data.writingDirectionLeftToRight |= WebContextMenuData::CheckableMenuIte mChecked;
352 if (selectedFrame->editor().selectionHasStyle(CSSPropertyDirection, "rtl") ! = FalseTriState) 352 if (selectedFrame->editor().selectionHasStyle(CSSPropertyDirection, "rtl") ! = FalseTriState)
353 data.writingDirectionRightToLeft |= WebContextMenuData::CheckableMenuIte mChecked; 353 data.writingDirectionRightToLeft |= WebContextMenuData::CheckableMenuIte mChecked;
354 #endif // OS(MACOSX) 354 #endif // OS(MACOSX)
355 355
356 // Now retrieve the security info. 356 // Now retrieve the security info.
357 DocumentLoader* dl = selectedFrame->loader()->documentLoader(); 357 DocumentLoader* dl = selectedFrame->loader().documentLoader();
358 WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl); 358 WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl);
359 if (ds) 359 if (ds)
360 data.securityInfo = ds->response().securityInfo(); 360 data.securityInfo = ds->response().securityInfo();
361 361
362 data.referrerPolicy = static_cast<WebReferrerPolicy>(selectedFrame->document ()->referrerPolicy()); 362 data.referrerPolicy = static_cast<WebReferrerPolicy>(selectedFrame->document ()->referrerPolicy());
363 363
364 // Filter out custom menu elements and add them into the data. 364 // Filter out custom menu elements and add them into the data.
365 populateCustomMenuItems(defaultMenu, &data); 365 populateCustomMenuItems(defaultMenu, &data);
366 366
367 data.node = r.innerNonSharedNode(); 367 data.node = r.innerNonSharedNode();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 outputItems[i] = subItems[i]; 413 outputItems[i] = subItems[i];
414 subMenuItems.swap(outputItems); 414 subMenuItems.swap(outputItems);
415 } 415 }
416 416
417 void ContextMenuClientImpl::populateCustomMenuItems(const WebCore::ContextMenu* defaultMenu, WebContextMenuData* data) 417 void ContextMenuClientImpl::populateCustomMenuItems(const WebCore::ContextMenu* defaultMenu, WebContextMenuData* data)
418 { 418 {
419 populateSubMenuItems(defaultMenu->items(), data->customItems); 419 populateSubMenuItems(defaultMenu->items(), data->customItems);
420 } 420 }
421 421
422 } // namespace WebKit 422 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/modules/websockets/MainThreadWebSocketChannel.cpp ('k') | Source/web/FrameLoaderClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698