diff options
author | Feng Qian <fqian@google.com> | 2009-06-17 12:12:20 -0700 |
---|---|---|
committer | Feng Qian <fqian@google.com> | 2009-06-17 12:12:20 -0700 |
commit | 5f1ab04193ad0130ca8204aadaceae083aca9881 (patch) | |
tree | 5a92cd389e2cfe7fb67197ce14b38469462379f8 /WebCore/platform/wx | |
parent | 194315e5a908cc8ed67d597010544803eef1ac59 (diff) | |
download | external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.zip external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.gz external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.bz2 |
Get WebKit r44544.
Diffstat (limited to 'WebCore/platform/wx')
-rw-r--r-- | WebCore/platform/wx/KeyboardEventWx.cpp | 32 | ||||
-rw-r--r-- | WebCore/platform/wx/LoggingWx.cpp | 30 | ||||
-rw-r--r-- | WebCore/platform/wx/MouseEventWx.cpp | 4 | ||||
-rw-r--r-- | WebCore/platform/wx/PopupMenuWx.cpp | 1 | ||||
-rw-r--r-- | WebCore/platform/wx/RenderThemeWx.cpp | 4 | ||||
-rw-r--r-- | WebCore/platform/wx/ScrollViewWx.cpp | 8 | ||||
-rw-r--r-- | WebCore/platform/wx/SharedTimerWx.cpp | 25 | ||||
-rw-r--r-- | WebCore/platform/wx/TemporaryLinkStubs.cpp | 5 | ||||
-rw-r--r-- | WebCore/platform/wx/WidgetWx.cpp | 29 | ||||
-rw-r--r-- | WebCore/platform/wx/wxcode/mac/carbon/fontprops.cpp | 15 | ||||
-rw-r--r-- | WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp | 89 | ||||
-rw-r--r-- | WebCore/platform/wx/wxcode/win/fontprops.cpp | 2 | ||||
-rw-r--r-- | WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp | 1 |
13 files changed, 167 insertions, 78 deletions
diff --git a/WebCore/platform/wx/KeyboardEventWx.cpp b/WebCore/platform/wx/KeyboardEventWx.cpp index 8be87ac..7f57073 100644 --- a/WebCore/platform/wx/KeyboardEventWx.cpp +++ b/WebCore/platform/wx/KeyboardEventWx.cpp @@ -27,7 +27,6 @@ #include "PlatformKeyboardEvent.h" #include "KeyboardCodes.h" -#include "NotImplemented.h" #include <wx/defs.h> #include <wx/event.h> @@ -163,14 +162,17 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode) return VK_DECIMAL; // (6E) Decimal key case WXK_DIVIDE: return VK_DIVIDE; // (6F) Divide key - + case WXK_NUMPAD_SEPARATOR: + return VK_SEPARATOR; case WXK_BACK: return VK_BACK; // (08) BACKSPACE key case WXK_TAB: + case WXK_NUMPAD_TAB: return VK_TAB; // (09) TAB key case WXK_CLEAR: return VK_CLEAR; // (0C) CLEAR key + case WXK_NUMPAD_ENTER: case WXK_RETURN: return VK_RETURN; //(0D) Return key case WXK_SHIFT: @@ -204,22 +206,31 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode) // VK_NONCONVERT (1D) IME nonconvert // VK_ACCEPT (1E) IME accept // VK_MODECHANGE (1F) IME mode change request + case WXK_NUMPAD_SPACE: case WXK_SPACE: return VK_SPACE; // (20) SPACEBAR + case WXK_NUMPAD_PAGEUP: case WXK_PAGEUP: return VK_PRIOR; // (21) PAGE UP key + case WXK_NUMPAD_PAGEDOWN: case WXK_PAGEDOWN: return VK_NEXT; // (22) PAGE DOWN key + case WXK_NUMPAD_END: case WXK_END: return VK_END; // (23) END key + case WXK_NUMPAD_HOME: case WXK_HOME: return VK_HOME; // (24) HOME key + case WXK_NUMPAD_LEFT: case WXK_LEFT: return VK_LEFT; // (25) LEFT ARROW key + case WXK_NUMPAD_UP: case WXK_UP: return VK_UP; // (26) UP ARROW key + case WXK_NUMPAD_RIGHT: case WXK_RIGHT: return VK_RIGHT; // (27) RIGHT ARROW key + case WXK_NUMPAD_DOWN: case WXK_DOWN: return VK_DOWN; // (28) DOWN ARROW key case WXK_SELECT: @@ -228,11 +239,12 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode) return VK_PRINT; // (2A) PRINT key case WXK_EXECUTE: return VK_EXECUTE;// (2B) EXECUTE key - //dunno on this - //case WXK_PrintScreen: - // return VK_SNAPSHOT; // (2C) PRINT SCREEN key + case WXK_SNAPSHOT: + return VK_SNAPSHOT; // (2C) PRINT SCREEN key + case WXK_NUMPAD_INSERT: case WXK_INSERT: return VK_INSERT; // (2D) INS key + case WXK_NUMPAD_DELETE: case WXK_DELETE: return VK_DELETE; // (2E) DEL key case WXK_HELP: @@ -336,7 +348,15 @@ PlatformKeyboardEvent::PlatformKeyboardEvent(wxKeyEvent& event) if (m_type != Char) m_keyIdentifier = keyIdentifierForWxKeyCode(event.GetKeyCode()); else { - m_text = wxString(event.GetUnicodeKey()); + //ENTER is an editing command processed as a char (only Enter and Tab are) + //unfortunately the unicode key for numpad_enter (370) is NOT what we want here (13) + //The unicode values for normal enter and tab are the same as the ASCII values, thus ok + //Note that I think this a wx bug, as the Character Code is actually 13 when + //numpad_enter is a CHAR event. + if (event.GetKeyCode() == 13 && event.GetUnicodeKey() == wxChar(370)) + m_text = "\r"; + else + m_text = wxString(event.GetUnicodeKey()); m_unmodifiedText = m_text; } m_autoRepeat = false; // FIXME: not correct. diff --git a/WebCore/platform/wx/LoggingWx.cpp b/WebCore/platform/wx/LoggingWx.cpp index 006712c..4d8a437 100644 --- a/WebCore/platform/wx/LoggingWx.cpp +++ b/WebCore/platform/wx/LoggingWx.cpp @@ -26,11 +26,39 @@ #include "config.h" #include "Logging.h" +#include "CString.h" +#include "PlatformString.h" +#include <wtf/Vector.h> + +#include <wx/defs.h> +#include <wx/utils.h> + namespace WebCore { void InitializeLoggingChannelsIfNecessary() { - LogNotYetImplemented.state = WTFLogChannelOn; + static bool haveInitializedLoggingChannels = false; + if (haveInitializedLoggingChannels) + return; + + haveInitializedLoggingChannels = true; + + wxString loggingEnv; + wxGetEnv(wxT("WX_WEBKIT_LOG"), &loggingEnv); + if (loggingEnv == wxEmptyString) + return; + + String wkLoggingEnv = loggingEnv; + Vector<String> logs; + + wkLoggingEnv.split(",", logs); + + for (size_t i = 0; i < logs.size(); ++i) { + WTFLogChannel* channel = getChannelFromName(logs[i]); + + if (channel) + channel->state = WTFLogChannelOn; + } } } diff --git a/WebCore/platform/wx/MouseEventWx.cpp b/WebCore/platform/wx/MouseEventWx.cpp index a02d7ba..4f39598 100644 --- a/WebCore/platform/wx/MouseEventWx.cpp +++ b/WebCore/platform/wx/MouseEventWx.cpp @@ -33,7 +33,7 @@ namespace WebCore { -PlatformMouseEvent::PlatformMouseEvent(const wxMouseEvent& event, const wxPoint& globalPoint) +PlatformMouseEvent::PlatformMouseEvent(const wxMouseEvent& event, const wxPoint& globalPoint, int clickCount) : m_position(event.GetPosition()) , m_globalPosition(globalPoint) , m_shiftKey(event.ShiftDown()) @@ -67,7 +67,7 @@ PlatformMouseEvent::PlatformMouseEvent(const wxMouseEvent& event, const wxPoint& if (m_eventType == MouseEventMoved) m_clickCount = 0; else - m_clickCount = event.ButtonDClick() ? 2 : 1; + m_clickCount = clickCount; m_timestamp = WTF::currentTime(); } diff --git a/WebCore/platform/wx/PopupMenuWx.cpp b/WebCore/platform/wx/PopupMenuWx.cpp index 4563b77..660282c 100644 --- a/WebCore/platform/wx/PopupMenuWx.cpp +++ b/WebCore/platform/wx/PopupMenuWx.cpp @@ -25,7 +25,6 @@ #include "Frame.h" #include "FrameView.h" -#include "NotImplemented.h" #include "PopupMenuClient.h" #include "PlatformString.h" diff --git a/WebCore/platform/wx/RenderThemeWx.cpp b/WebCore/platform/wx/RenderThemeWx.cpp index 9b6dea5..a26416f 100644 --- a/WebCore/platform/wx/RenderThemeWx.cpp +++ b/WebCore/platform/wx/RenderThemeWx.cpp @@ -32,10 +32,10 @@ #include "NotImplemented.h" #include "RenderView.h" -#include "WebKit/wx/WebView.h" +#include <wx/defs.h> +#include <wx/dc.h> #include <wx/dcgraph.h> -#include <wx/defs.h> #include <wx/renderer.h> #include <wx/dcclient.h> #include <wx/scrolwin.h> diff --git a/WebCore/platform/wx/ScrollViewWx.cpp b/WebCore/platform/wx/ScrollViewWx.cpp index 254ac9f..f556894 100644 --- a/WebCore/platform/wx/ScrollViewWx.cpp +++ b/WebCore/platform/wx/ScrollViewWx.cpp @@ -191,12 +191,12 @@ void ScrollView::platformSetScrollPosition(const IntPoint& scrollPoint) if (newScrollOffset.x < 0) newScrollOffset.x = 0; else if (newScrollOffset.x + cRect.width > vRect.width) - newScrollOffset.x = max(0, vRect.width - cRect.width - 1); + newScrollOffset.x = max(0, vRect.width - cRect.width); if (newScrollOffset.y < 0) newScrollOffset.y = 0; else if (newScrollOffset.y + cRect.height > vRect.height) - newScrollOffset.y = max(0, vRect.height - cRect.height - 1); + newScrollOffset.y = max(0, vRect.height - cRect.height); if (newScrollOffset == scrollOffset) return; @@ -291,8 +291,8 @@ void ScrollView::platformSetScrollbarModes() needsAdjust = true; } - if (m_data->vScrollbarMode != horizontalScrollbarMode() ) { - m_data->vScrollbarMode = horizontalScrollbarMode(); + if (m_data->vScrollbarMode != verticalScrollbarMode() ) { + m_data->vScrollbarMode = verticalScrollbarMode(); needsAdjust = true; } diff --git a/WebCore/platform/wx/SharedTimerWx.cpp b/WebCore/platform/wx/SharedTimerWx.cpp index d95457b..b2b22e4 100644 --- a/WebCore/platform/wx/SharedTimerWx.cpp +++ b/WebCore/platform/wx/SharedTimerWx.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "SharedTimer.h" -#include "NotImplemented.h" #include "Widget.h" #include <wtf/Assertions.h> @@ -79,28 +78,10 @@ void setSharedTimerFireTime(double fireTime) wkTimer = new WebKitTimer(); unsigned int intervalInMS = interval * 1000; - if (interval < 0) { -#ifndef NDEBUG - // TODO: We may eventually want to assert here, to track - // what calls are leading to this condition. It seems to happen - // mostly with repeating timers. - fprintf(stderr, "WARNING: setSharedTimerFireTime: fire time is < 0 ms\n"); -#endif - intervalInMS = 0; - } - - // FIXME: We should mimic the Windows port's behavior and add the timer fired - // event to the event queue directly rather than making an artifical delay. - // However, wx won't allow us to assign a simple callback function - we'd have - // to create a fake wxEvtHandler-derived class with a timer event handler - // function. Until there's a better way, this way is at least far less - // hacky. - if (intervalInMS < 10) -#if __WXMSW__ - intervalInMS = 10; -#else + + // sanity check + if (intervalInMS < 1) intervalInMS = 1; -#endif wkTimer->Start(intervalInMS, wxTIMER_ONE_SHOT); } diff --git a/WebCore/platform/wx/TemporaryLinkStubs.cpp b/WebCore/platform/wx/TemporaryLinkStubs.cpp index d8c6046..dfd2ad5 100644 --- a/WebCore/platform/wx/TemporaryLinkStubs.cpp +++ b/WebCore/platform/wx/TemporaryLinkStubs.cpp @@ -97,11 +97,6 @@ DragImageRef Frame::dragImageForSelection() { notImplemented(); return 0; } void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) { notImplemented(); } -// cookies (we'll need a place to store these -void WebCore::setCookies(Document* document, const KURL& url, const KURL& policyURL, const String& value) { notImplemented(); } -String WebCore::cookies(const Document* document, const KURL& url) { notImplemented(); return String(); } -bool WebCore::cookiesEnabled(const Document* document) { notImplemented(); return false; } - /********************************************************/ /* Completely empty stubs (mostly to allow DRT to run): */ /********************************************************/ diff --git a/WebCore/platform/wx/WidgetWx.cpp b/WebCore/platform/wx/WidgetWx.cpp index 37097fe..bb4fd2a 100644 --- a/WebCore/platform/wx/WidgetWx.cpp +++ b/WebCore/platform/wx/WidgetWx.cpp @@ -45,8 +45,8 @@ Widget::~Widget() void Widget::setFocus() { - if (platformWidget()) - platformWidget()->SetFocus(); + if (PlatformWidget widget = platformWidget()) + widget->SetFocus(); } void Widget::setCursor(const Cursor& cursor) @@ -57,38 +57,43 @@ void Widget::setCursor(const Cursor& cursor) void Widget::show() { - if (platformWidget()) - platformWidget()->Show(); + if (PlatformWidget widget = platformWidget()) + widget->Show(); } void Widget::hide() { - if (platformWidget()) - platformWidget()->Hide(); + if (PlatformWidget widget = platformWidget()) + widget->Hide(); } IntRect Widget::frameRect() const { - if (platformWidget()) - return platformWidget()->GetRect(); + if (PlatformWidget widget = platformWidget()) + return widget->GetRect(); + return m_frame; } void Widget::setFrameRect(const IntRect& rect) { - if (platformWidget()) - platformWidget()->SetSize(rect); + if (PlatformWidget widget = platformWidget()) + widget->SetSize(rect); + m_frame = rect; } void Widget::invalidateRect(const IntRect& r) { - if (platformWidget()) - platformWidget()->RefreshRect(r); + if (PlatformWidget widget = platformWidget()) + widget->RefreshRect(r); } void Widget::paint(GraphicsContext*,const IntRect& r) { + invalidateRect(r); + if (PlatformWidget widget = platformWidget()) + widget->Update(); } } diff --git a/WebCore/platform/wx/wxcode/mac/carbon/fontprops.cpp b/WebCore/platform/wx/wxcode/mac/carbon/fontprops.cpp index 447a3d0..653f142 100644 --- a/WebCore/platform/wx/wxcode/mac/carbon/fontprops.cpp +++ b/WebCore/platform/wx/wxcode/mac/carbon/fontprops.cpp @@ -23,11 +23,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" +#include "fontprops.h" + #include <ApplicationServices/ApplicationServices.h> #include <wx/defs.h> #include <wx/gdicmn.h> -#include "fontprops.h" + +#ifdef BUILDING_ON_TIGER +void (*wkGetFontMetrics)(CGFontRef, int* ascent, int* descent, int* lineGap, unsigned* unitsPerEm); +#endif const float smallCapsFontSizeMultiplier = 0.7f; const float contextDPI = 72.0f; @@ -39,7 +45,7 @@ m_ascent(0), m_descent(0), m_lineGap(0), m_lineSpacing(0), m_xHeight(0) CGFontRef cgFont; #ifdef wxOSX_USE_CORE_TEXT && wxOSX_USE_CORE_TEXT - cgFont = CTFontCopyGraphicsFont((CTFontRef)font->MacGetCTFont(), NULL); + cgFont = CTFontCopyGraphicsFont((CTFontRef)font->OSXGetCTFont(), NULL); #else ATSFontRef fontRef; @@ -53,7 +59,7 @@ m_ascent(0), m_descent(0), m_lineGap(0), m_lineSpacing(0), m_xHeight(0) int iAscent; int iDescent; int iLineGap; - float unitsPerEm; + unsigned unitsPerEm; #ifdef BUILDING_ON_TIGER wkGetFontMetrics(cgFont, &iAscent, &iDescent, &iLineGap, &unitsPerEm); #else @@ -76,6 +82,9 @@ m_ascent(0), m_descent(0), m_lineGap(0), m_lineSpacing(0), m_xHeight(0) m_lineSpacing = m_ascent + m_descent + m_lineGap; } + + if (cgFont) + CGFontRelease(cgFont); } diff --git a/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp b/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp index 6eaa765..e5c60d6 100644 --- a/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp +++ b/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp @@ -24,44 +24,95 @@ */ #include "config.h" +#include "FloatSize.h" #include "GlyphBuffer.h" #include "GraphicsContext.h" #include "SimpleFontData.h" +#include <wtf/Vector.h> + +#include <ApplicationServices/ApplicationServices.h> + +#include <dlfcn.h> #include <wx/defs.h> #include <wx/dcclient.h> #include <wx/dcgraph.h> #include <wx/gdicmn.h> -#include <vector> + + +// Unfortunately we need access to a private function to get the character -> glyph conversion needed to +// allow us to use CGContextShowGlyphsWithAdvances +// Note that on < 10.5, the function is called CGFontGetGlyphsForUnicodes, so we need to detect and deal +// with this. +typedef void (*CGFontGetGlyphsForUnicharsPtr)(CGFontRef, const UniChar[], const CGGlyph[], size_t); +static CGFontGetGlyphsForUnicharsPtr CGFontGetGlyphsForUnichars = (CGFontGetGlyphsForUnicharsPtr)dlsym(RTLD_DEFAULT, "CGFontGetGlyphsForUnichars"); namespace WebCore { void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) { -#if USE(WXGC) + graphicsContext->save(); + wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext()); + + wxFont* wxfont = font->getWxFont(); + graphicsContext->setFillColor(graphicsContext->fillColor()); + + CGContextRef cgContext = static_cast<CGContextRef>(dc->GetGraphicsContext()->GetNativeContext()); + + CGFontRef cgFont; + +#ifdef wxOSX_USE_CORE_TEXT && wxOSX_USE_CORE_TEXT + cgFont = CTFontCopyGraphicsFont((CTFontRef)font->OSXGetCTFont(), NULL); #else - wxDC* dc = graphicsContext->platformContext(); + ATSFontRef fontRef; + + fontRef = FMGetATSFontRefFromFont(wxfont->MacGetATSUFontID()); + + if (fontRef) + cgFont = CGFontCreateWithPlatformFont((void*)&fontRef); #endif + + CGContextSetFont(cgContext, cgFont); - wxFont* wxfont = font->getWxFont(); - if (wxfont->IsOk()) - dc->SetFont(*wxfont); - dc->SetTextForeground(color); - - // convert glyphs to wxString - GlyphBufferGlyph* glyphs = const_cast<GlyphBufferGlyph*>(glyphBuffer.glyphs(from)); - int offset = point.x(); - wxString text = wxEmptyString; - for (unsigned i = 0; i < numGlyphs; i++) { - text = text.Append((wxChar)glyphs[i]); - offset += glyphBuffer.advanceAt(from + i); + CGContextSetFontSize(cgContext, wxfont->GetPointSize()); + + CGFloat red, green, blue, alpha; + graphicsContext->fillColor().getRGBA(red, green, blue, alpha); + CGContextSetRGBFillColor(cgContext, red, green, blue, alpha); + + CGAffineTransform matrix = CGAffineTransformIdentity; + matrix.b = -matrix.b; + matrix.d = -matrix.d; + + CGContextSetTextMatrix(cgContext, matrix); + + CGContextSetTextPosition(cgContext, point.x(), point.y()); + + const FloatSize* advanceSizes = static_cast<const FloatSize*>(glyphBuffer.advances(from)); + int size = glyphBuffer.size() - from; + CGSize sizes[size]; + CGGlyph glyphs[numGlyphs]; + + // if the function doesn't exist, we're probably on tiger and need to grab the + // function under its old name, CGFontGetGlyphsForUnicodes + if (!CGFontGetGlyphsForUnichars) + CGFontGetGlyphsForUnichars = (CGFontGetGlyphsForUnicharsPtr)dlsym(RTLD_DEFAULT, "CGFontGetGlyphsForUnicodes"); + + // Let's make sure we got the function under one name or another! + ASSERT(CGFontGetGlyphsForUnichars); + CGFontGetGlyphsForUnichars(cgFont, glyphBuffer.glyphs(from), glyphs, numGlyphs); + + for (int i = 0; i < size; i++) { + FloatSize fsize = advanceSizes[i]; + sizes[i] = CGSizeMake(fsize.width(), fsize.height()); } - // NOTE: The wx API actually adds the ascent to the y value internally, - // so we have to subtract it from the y point here so that the ascent - // isn't added twice. - dc->DrawText(text, (wxCoord)point.x(), int(point.y() - font->ascent())); + CGContextShowGlyphsWithAdvances(cgContext, glyphs, sizes, numGlyphs); + + if (cgFont) + CGFontRelease(cgFont); + graphicsContext->restore(); } } diff --git a/WebCore/platform/wx/wxcode/win/fontprops.cpp b/WebCore/platform/wx/wxcode/win/fontprops.cpp index 1314691..531db08 100644 --- a/WebCore/platform/wx/wxcode/win/fontprops.cpp +++ b/WebCore/platform/wx/wxcode/win/fontprops.cpp @@ -91,7 +91,7 @@ void GetTextExtent( const wxFont& font, const wxString& str, wxCoord *width, wxC // accounts for under/overhang of the first/last character while we want // just the bounding rect for this string so adjust the width as needed // (using API not available in 2002 SDKs of WinCE) - if ( len > 0 ) + if ( len > 1 ) { ABC width; const wxChar chFirst = *str.begin(); diff --git a/WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp b/WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp index 7d1e924..d2513d7 100644 --- a/WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp +++ b/WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp @@ -30,6 +30,7 @@ #include <wx/defs.h> #include <wx/dcclient.h> +#include <wx/dcgraph.h> #include <wx/gdicmn.h> #include <vector> |