Implement the rest of the search field. Make it work with form submission. Implement onscroll at
the document level.
Reviewed by darin
* khtml/html/html_formimpl.cpp:
(HTMLFormElementImpl::submit):
* khtml/rendering/render_form.cpp:
(RenderLineEdit::addSearchResult):
* khtml/rendering/render_form.h:
* kwq/KWQKHTMLPart.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::sendScrollEvent):
* kwq/KWQLineEdit.h:
* kwq/KWQLineEdit.mm:
(QLineEdit::setMaxResults):
(QLineEdit::setPlaceholderString):
(QLineEdit::addSearchResult):
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge sendScrollEvent]):
* kwq/WebCoreViewFactory.h:
WebKit:
Implement the rest of the search field.
Implement onscroll at the document level.
Reviewed by darin
* English.lproj/Localizable.strings:
* WebCoreSupport.subproj/WebBridge.m:
* WebCoreSupport.subproj/WebViewFactory.m:
(-[NSMenu addItemWithTitle:action:tag:]):
(-[WebViewFactory submitButtonDefaultLabel]):
(-[WebViewFactory cellMenuForSearchField]):
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView _frameOrBoundsChanged]):
(-[WebHTMLView viewDidMoveToWindow]):
* WebView.subproj/WebHTMLViewPrivate.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@6260
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-03-25 David Hyatt <hyatt@apple.com>
+
+ Implement the rest of the search field. Make it work with form submission. Implement onscroll at
+ the document level.
+
+ Reviewed by darin
+
+ * khtml/html/html_formimpl.cpp:
+ (HTMLFormElementImpl::submit):
+ * khtml/rendering/render_form.cpp:
+ (RenderLineEdit::addSearchResult):
+ * khtml/rendering/render_form.h:
+ * kwq/KWQKHTMLPart.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::sendScrollEvent):
+ * kwq/KWQLineEdit.h:
+ * kwq/KWQLineEdit.mm:
+ (QLineEdit::setMaxResults):
+ (QLineEdit::setPlaceholderString):
+ (QLineEdit::addSearchResult):
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge sendScrollEvent]):
+ * kwq/WebCoreViewFactory.h:
+
2004-03-25 David Hyatt <hyatt@apple.com>
Fix for 3570700, crash in inlineBox::isDirty. Make sure line boxes null out parent pointers when those
if (current->id() == ID_INPUT) {
HTMLInputElementImpl *input = static_cast<HTMLInputElementImpl*>(current);
if (input->inputType() == HTMLInputElementImpl::TEXT
- || input->inputType() == HTMLInputElementImpl::PASSWORD)
+ || input->inputType() == HTMLInputElementImpl::PASSWORD
+ || input->inputType() == HTMLInputElementImpl::SEARCH)
{
KWQ(part)->recordFormValue(input->name().string(), input->value().string(), this);
+ if (input->renderer() && input->inputType() == HTMLInputElementImpl::SEARCH)
+ static_cast<RenderLineEdit*>(input->renderer())->addSearchResult();
}
}
#else
// Fire the "search" DOM event.
element()->dispatchHTMLEvent(EventImpl::SEARCH_EVENT, true, false);
}
+
+void RenderLineEdit::addSearchResult()
+{
+ if (widget())
+ widget()->addSearchResult();
+}
#endif
void RenderLineEdit::handleFocusOut()
void slotTextChanged(const QString &string);
#if APPLE_CHANGES
void slotPerformSearch();
+public:
+ void addSearchResult();
#endif
protected:
void forceLayout();
void forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth);
void sendResizeEvent();
+ void sendScrollEvent();
void paint(QPainter *, const QRect &);
void paintSelectionOnly(QPainter *p, const QRect &rect);
}
}
+void KWQKHTMLPart::sendScrollEvent()
+{
+ KHTMLView *v = d->m_view;
+ if (v) {
+ DocumentImpl *doc = xmlDocImpl();
+ if (!doc)
+ return;
+ doc->dispatchHTMLEvent(EventImpl::SCROLL_EVENT, true, false);
+ }
+}
+
void KWQKHTMLPart::runJavaScriptAlert(const QString &message)
{
QString text = message;
void setAutoSaveName(const QString& name);
void setMaxResults(int maxResults);
void setPlaceholderString(const QString& placeholder);
+ void addSearchResult();
private:
KWQSignal m_returnPressed;
#import "KWQTextField.h"
#import "WebCoreTextRenderer.h"
#import "WebCoreTextRendererFactory.h"
+#import "WebCoreViewFactory.h"
+
+@interface NSSearchField (SearchFieldSecrets)
+- (void) _addStringToRecentSearches:(NSString*)string;
+@end
QLineEdit::QLineEdit(Type type)
: m_returnPressed(this, SIGNAL(returnPressed()))
return;
NSSearchField *searchField = (NSSearchField *)getView();
- if (!maxResults)
- [[searchField cell] setSearchButtonCell:nil];
- else
- [[searchField cell] resetSearchButtonCell];
-
- [[searchField cell] setMaximumRecents:maxResults];
+ id searchCell = [searchField cell];
+ if (!maxResults) {
+ [searchCell setSearchButtonCell:nil];
+ [searchCell setSearchMenuTemplate:nil];
+ }
+ else {
+ NSMenu* cellMenu = [searchCell searchMenuTemplate];
+ NSButtonCell* buttonCell = [searchCell searchButtonCell];
+ if (!buttonCell)
+ [searchCell resetSearchButtonCell];
+ if (!cellMenu)
+ [searchCell setSearchMenuTemplate:[[WebCoreViewFactory sharedFactory] cellMenuForSearchField]];
+ }
+
+ [searchCell setMaximumRecents:maxResults];
}
void QLineEdit::setPlaceholderString(const QString& placeholder)
[[searchField cell] setPlaceholderString:placeholder.getNSString()];
}
+void QLineEdit::addSearchResult()
+{
+ if (m_type != Search)
+ return;
+
+ NSSearchField *searchField = (NSSearchField *)getView();
+ [[searchField cell] _addStringToRecentSearches:[searchField stringValue]];
+}
+
- (void)forceLayoutAdjustingViewSize:(BOOL)adjustSizeFlag;
- (void)forceLayoutWithMinimumPageWidth:(float)minPageWidth maximumPageWidth:(float)maxPageWidth adjustingViewSize:(BOOL)adjustSizeFlag;
- (void)sendResizeEvent;
+- (void)sendScrollEvent;
- (BOOL)needsLayout;
- (void)setNeedsLayout;
- (void)drawRect:(NSRect)rect;
_part->sendResizeEvent();
}
+- (void)sendScrollEvent
+{
+ _part->sendScrollEvent();
+}
+
- (void)drawRect:(NSRect)rect withPainter:(QPainter *)p
{
[self _setupRootForPrinting:YES];
- (NSString *)searchableIndexIntroduction;
- (NSString *)submitButtonDefaultLabel;
+- (NSMenu *)cellMenuForSearchField;
+
- (NSString *)defaultLanguageCode;
- (WebCoreBridge *)bridgeForView:(NSView *)aView;
+2004-03-25 David Hyatt <hyatt@apple.com>
+
+ Implement the rest of the search field.
+
+ Implement onscroll at the document level.
+
+ Reviewed by darin
+
+ * English.lproj/Localizable.strings:
+ * WebCoreSupport.subproj/WebBridge.m:
+ * WebCoreSupport.subproj/WebViewFactory.m:
+ (-[NSMenu addItemWithTitle:action:tag:]):
+ (-[WebViewFactory submitButtonDefaultLabel]):
+ (-[WebViewFactory cellMenuForSearchField]):
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView _frameOrBoundsChanged]):
+ (-[WebHTMLView viewDidMoveToWindow]):
+ * WebView.subproj/WebHTMLViewPrivate.h:
+
2004-03-25 Richard Williamson <rjw@apple.com>
Netscape plugin API header cleanup.
- (jobject)pollForAppletInWindow: (NSWindow *)window;
@end
-
@implementation WebBridge
- (id)initWithWebFrame:(WebFrame *)webFrame
#import <WebKit/WebPluginDatabase.h>
+@interface NSMenu (BrowserMenuAdditions)
+- (NSMenuItem *)addItemWithTitle:(NSString *)title action:(SEL)action tag:(int)tag;
+@end
+
+@implementation NSMenu (BrowserMenuAdditions)
+- (NSMenuItem *)addItemWithTitle:(NSString *)title action:(SEL)action tag:(int)tag
+{
+ NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title action:action keyEquivalent:@""] autorelease];
+ [item setTag:tag];
+ [self addItem:item];
+ return item;
+}
+@end
+
@implementation WebViewFactory
+ (void)createSharedFactory;
return UI_STRING("Submit", "default label for Submit buttons in forms on web pages");
}
+- (NSMenu *)cellMenuForSearchField
+{
+ NSMenu* cellMenu = [[[NSMenu alloc] initWithTitle:@""] autorelease];
+ [cellMenu addItemWithTitle:UI_STRING("Recent Searches", "label for first item in the menu that appears when clicking on the search field image, used as embedded menu title")
+ action:NULL tag:NSSearchFieldRecentsTitleMenuItemTag];
+ [cellMenu addItemWithTitle:@"" action:NULL tag:NSSearchFieldRecentsMenuItemTag];
+ NSMenuItem *separator = [NSMenuItem separatorItem];
+ [separator setTag:NSSearchFieldRecentsTitleMenuItemTag];
+ [cellMenu addItem:separator];
+ [cellMenu addItemWithTitle:UI_STRING("Clear Recent Searches", "menu item in Recent Searches menu that empties menu's contents")
+ action:NULL tag:NSSearchFieldClearRecentsMenuItemTag];
+ [cellMenu addItemWithTitle:UI_STRING("No recent searches", "Label for only item in menu that appears when clicking on the search field image, when no searches have been performed")
+ action:NULL tag:NSSearchFieldNoRecentsMenuItemTag];
+ return cellMenu;
+}
+
- (NSString *)defaultLanguageCode
{
// FIXME: Need implementation. Defaults gives us a list of languages, but by name, not code.
[self setNeedsDisplay:YES];
}
+ NSPoint origin = [[self superview] bounds].origin;
+ if (!NSEqualPoints(_private->lastScrollPosition, origin))
+ [[self _bridge] sendScrollEvent];
+ _private->lastScrollPosition = origin;
+
SEL selector = @selector(_updateMouseoverWithFakeEvent);
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:selector object:nil];
[self performSelector:selector withObject:nil afterDelay:0];
if (_private) {
[self _stopAutoscrollTimer];
if ([self window]) {
+ _private->lastScrollPosition = [[self superview] bounds].origin;
[self addWindowObservers];
[self addSuperviewObservers];
[self addMouseMovedObserver];
[[self _pluginController] startAllPlugins];
+ _private->lastScrollPosition = NSZeroPoint;
+
_private->inWindow = YES;
} else {
// Reset when we are moved out of a window after being moved into one.
NSSize lastLayoutFrameSize;
BOOL laidOutAtLeastOnce;
+ NSPoint lastScrollPosition;
+
WebPluginController *pluginController;
NSString *toolTip;