Reviewed by Darin.
- WebCore part of fix for:
http://bugzilla.opendarwin.org/show_bug.cgi?id=10576
Disallow copy from new password fields
* page/Frame.cpp: (WebCore::Frame::mayCopy): Added. Checks to see if the selection is within a password field.
* page/Frame.h: Added mayCopy.
* bridge/mac/FrameMac.h:
* bridge/mac/FrameMac.mm:
(WebCore::FrameMac::handleMouseMoveEvent): Checks mayCopy before starting a drag.
(WebCore::FrameMac::mayDHTMLCut): Renamed to match the bridge method. This also checks mayCopy now.
(WebCore::FrameMac::mayDHTMLCopy): ditto.
(WebCore::FrameMac::tryDHTMLCut): ditto.
(WebCore::FrameMac::tryDHTMLCopy): ditto.
(WebCore::FrameMac::mayDHTMLPaste): Renamed to match the bridge function.
(WebCore::FrameMac::tryDHTMLPaste): ditto.
* bridge/mac/WebCoreFrameBridge.h:
* bridge/mac/WebCoreFrameBridge.mm:
(-[WebCoreFrameBridge mayCopy]): Calls the renamed method on frame.
(-[WebCoreFrameBridge mayDHTMLCut]): ditto.
(-[WebCoreFrameBridge mayDHTMLCopy]): ditto.
(-[WebCoreFrameBridge mayDHTMLPaste]): ditto.
(-[WebCoreFrameBridge tryDHTMLCut]): ditto.
(-[WebCoreFrameBridge tryDHTMLCopy]): ditto.
(-[WebCoreFrameBridge tryDHTMLPaste]): ditto.
* css/html4.css: Added !important to the -webkit-text-security property for password fields.
WebKit:
Reviewed by Darin.
WebKit part of fix for:
http://bugzilla.opendarwin.org/show_bug.cgi?id=10576
Disallow copy from new password fields
* WebView/WebHTMLView.m:
(-[WebHTMLView _canCopy]): Now also calls across the bridge to ask if it mayCopy.
(-[WebHTMLView _canCut]): Calls _canCopy now.
(-[NSArray validateUserInterfaceItem:]): Calls _canCut when validating the "Cut" menu item.
This used to call _canDelete (which used to be the same as _canCut), but now _canCut also checks _canCopy.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16116
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-08-30 Adele Peterson <adele@apple.com>
+
+ Reviewed by Darin.
+
+ - WebCore part of fix for:
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=10576
+ Disallow copy from new password fields
+
+ * page/Frame.cpp: (WebCore::Frame::mayCopy): Added. Checks to see if the selection is within a password field.
+ * page/Frame.h: Added mayCopy.
+
+ * bridge/mac/FrameMac.h:
+ * bridge/mac/FrameMac.mm:
+ (WebCore::FrameMac::handleMouseMoveEvent): Checks mayCopy before starting a drag.
+ (WebCore::FrameMac::mayDHTMLCut): Renamed to match the bridge method. This also checks mayCopy now.
+ (WebCore::FrameMac::mayDHTMLCopy): ditto.
+ (WebCore::FrameMac::tryDHTMLCut): ditto.
+ (WebCore::FrameMac::tryDHTMLCopy): ditto.
+ (WebCore::FrameMac::mayDHTMLPaste): Renamed to match the bridge function.
+ (WebCore::FrameMac::tryDHTMLPaste): ditto.
+ * bridge/mac/WebCoreFrameBridge.h:
+ * bridge/mac/WebCoreFrameBridge.mm:
+ (-[WebCoreFrameBridge mayCopy]): Calls the renamed method on frame.
+ (-[WebCoreFrameBridge mayDHTMLCut]): ditto.
+ (-[WebCoreFrameBridge mayDHTMLCopy]): ditto.
+ (-[WebCoreFrameBridge mayDHTMLPaste]): ditto.
+ (-[WebCoreFrameBridge tryDHTMLCut]): ditto.
+ (-[WebCoreFrameBridge tryDHTMLCopy]): ditto.
+ (-[WebCoreFrameBridge tryDHTMLPaste]): ditto.
+
+ * css/html4.css: Added !important to the -webkit-text-security property for password fields.
+
2006-08-30 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed by Tim H.
void dragSourceMovedTo(const PlatformMouseEvent&);
void dragSourceEndedAt(const PlatformMouseEvent&, NSDragOperation);
- bool mayCut();
- bool mayCopy();
- bool mayPaste();
- bool tryCut();
- bool tryCopy();
- bool tryPaste();
+ bool mayDHTMLCut();
+ bool mayDHTMLCopy();
+ bool mayDHTMLPaste();
+ bool tryDHTMLCut();
+ bool tryDHTMLCopy();
+ bool tryDHTMLPaste();
bool sendContextMenuEvent(NSEvent*);
_dragClipboard->setDragImageElement(_dragSrc.get(), IntPoint() + delta);
}
- _mouseDownMayStartDrag = dispatchDragSrcEvent(dragstartEvent, m_mouseDown);
+ _mouseDownMayStartDrag = dispatchDragSrcEvent(dragstartEvent, m_mouseDown) && mayCopy();
// Invalidate clipboard here against anymore pasteboard writing for security. The drag
// image can still be changed as we drag, but not the pasteboard data.
_dragClipboard->setAccessPolicy(ClipboardMac::ImageWritable);
// We need to use onbeforecopy as a real menu enabler because we allow elements that are not
// normally selectable to implement copy/paste (like divs, or a document body).
-bool FrameMac::mayCut()
+bool FrameMac::mayDHTMLCut()
{
- return !dispatchCPPEvent(beforecutEvent, ClipboardMac::Numb);
+ return mayCopy() && !dispatchCPPEvent(beforecutEvent, ClipboardMac::Numb);
}
-bool FrameMac::mayCopy()
+bool FrameMac::mayDHTMLCopy()
{
- return !dispatchCPPEvent(beforecopyEvent, ClipboardMac::Numb);
+ return mayCopy() && !dispatchCPPEvent(beforecopyEvent, ClipboardMac::Numb);
}
-bool FrameMac::mayPaste()
+bool FrameMac::mayDHTMLPaste()
{
return !dispatchCPPEvent(beforepasteEvent, ClipboardMac::Numb);
}
-bool FrameMac::tryCut()
+bool FrameMac::tryDHTMLCut()
{
+ if (!mayCopy())
+ return false;
+
// Must be done before oncut adds types and data to the pboard,
// also done for security, as it erases data from the last copy/paste.
[[NSPasteboard generalPasteboard] declareTypes:[NSArray array] owner:nil];
return !dispatchCPPEvent(cutEvent, ClipboardMac::Writable);
}
-bool FrameMac::tryCopy()
+bool FrameMac::tryDHTMLCopy()
{
+ if (!mayCopy())
+ return false;
+
// Must be done before oncopy adds types and data to the pboard,
// also done for security, as it erases data from the last copy/paste.
[[NSPasteboard generalPasteboard] declareTypes:[NSArray array] owner:nil];
return !dispatchCPPEvent(copyEvent, ClipboardMac::Writable);
}
-bool FrameMac::tryPaste()
+bool FrameMac::tryDHTMLPaste()
{
return !dispatchCPPEvent(pasteEvent, ClipboardMac::Readable);
}
- (BOOL)isSelectionRichlyEditable;
- (WebSelectionState)selectionState;
+- (BOOL)mayCopy;
+
- (NSAttributedString *)selectedAttributedString;
- (NSString *)selectedString;
return WebSelectionStateNone;
}
+- (BOOL)mayCopy
+{
+ return m_frame->mayCopy();
+}
+
- (NSString *)_stringWithDocumentTypeStringAndMarkupString:(NSString *)markupString
{
return m_frame->documentTypeString() + markupString;
- (BOOL)mayDHTMLCut
{
- return m_frame->mayCut();
+ return m_frame->mayDHTMLCut();
}
- (BOOL)mayDHTMLCopy
{
- return m_frame->mayCopy();
+ return m_frame->mayDHTMLCopy();
}
- (BOOL)mayDHTMLPaste
{
- return m_frame->mayPaste();
+ return m_frame->mayDHTMLPaste();
}
- (BOOL)tryDHTMLCut
{
- return m_frame->tryCut();
+ return m_frame->tryDHTMLCut();
}
- (BOOL)tryDHTMLCopy
{
- return m_frame->tryCopy();
+ return m_frame->tryDHTMLCopy();
}
- (BOOL)tryDHTMLPaste
{
- return m_frame->tryPaste();
+ return m_frame->tryDHTMLPaste();
}
- (DOMRange *)rangeOfCharactersAroundCaret
border:initial;
padding:initial;
- -webkit-text-security: disc;
+ -webkit-text-security: disc !important;
}
input[type="search"], input[type="hidden"], input[type="image"], input[type="file"] {
issuePasteAndMatchStyleCommand();
}
+bool Frame::mayCopy()
+{
+ Node* startNode = selection().start().node();
+ if (startNode) {
+ startNode = startNode->shadowAncestorNode();
+ if (startNode->hasTagName(inputTag) && static_cast<HTMLInputElement*>(startNode)->inputType() == HTMLInputElement::PASSWORD)
+ return false;
+ }
+ return true;
+}
+
void Frame::transpose()
{
issueTransposeCommand();
void cutToPasteboard();
void pasteFromPasteboard();
void pasteAndMatchStyle();
+ bool mayCopy();
virtual bool canPaste() const = 0;
void redo();
void undo();
+2006-08-30 Adele Peterson <adele@apple.com>
+
+ Reviewed by Darin.
+
+ WebKit part of fix for:
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=10576
+ Disallow copy from new password fields
+
+ * WebView/WebHTMLView.m:
+ (-[WebHTMLView _canCopy]): Now also calls across the bridge to ask if it mayCopy.
+ (-[WebHTMLView _canCut]): Calls _canCopy now.
+ (-[NSArray validateUserInterfaceItem:]): Calls _canCut when validating the "Cut" menu item.
+ This used to call _canDelete (which used to be the same as _canCut), but now _canCut also checks _canCopy.
+
2006-08-30 Karl Adam <karladam@yahoo-inc.com>
Reviewed by Eric and Tim H.
- (BOOL)_canCopy
{
// Copying can be done regardless of whether you can edit.
- return [self _hasSelection];
+ return [self _hasSelection] && [[self _bridge] mayCopy];
}
- (BOOL)_canCut
{
- return [self _hasSelection] && [self _isEditable];
+ return [self _canCopy] && [self _isEditable];
}
- (BOOL)_canDelete
} else if (action == @selector(copy:)) {
return [bridge mayDHTMLCopy] || [self _canCopy];
} else if (action == @selector(cut:)) {
- return [bridge mayDHTMLCut] || [self _canDelete];
+ return [bridge mayDHTMLCut] || [self _canCut];
} else if (action == @selector(delete:)) {
return [self _canDelete];
} else if (action == @selector(_ignoreSpellingFromMenu:)