diff options
author | Steve Block <steveblock@google.com> | 2009-12-15 10:12:09 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2009-12-17 17:41:10 +0000 |
commit | 643ca7872b450ea4efacab6188849e5aac2ba161 (patch) | |
tree | 6982576c228bcd1a7efe98afed544d840751094c /WebCore/platform/wx | |
parent | d026980fde6eb3b01c1fe49441174e89cd1be298 (diff) | |
download | external_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.zip external_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.tar.gz external_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.tar.bz2 |
Merge webkit.org at r51976 : Initial merge by git.
Change-Id: Ib0e7e2f0fb4bee5a186610272edf3186f0986b43
Diffstat (limited to 'WebCore/platform/wx')
-rw-r--r-- | WebCore/platform/wx/FileSystemWx.cpp | 76 | ||||
-rw-r--r-- | WebCore/platform/wx/LocalizedStringsWx.cpp | 43 | ||||
-rw-r--r-- | WebCore/platform/wx/ScrollbarThemeWx.cpp | 28 | ||||
-rw-r--r-- | WebCore/platform/wx/ScrollbarThemeWx.h | 4 | ||||
-rw-r--r-- | WebCore/platform/wx/wxcode/gtk/scrollbar_render.cpp | 21 | ||||
-rw-r--r-- | WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp | 2 | ||||
-rw-r--r-- | WebCore/platform/wx/wxcode/scrollbar_render.h | 15 | ||||
-rw-r--r-- | WebCore/platform/wx/wxcode/win/scrollbar_render.cpp | 26 |
8 files changed, 193 insertions, 22 deletions
diff --git a/WebCore/platform/wx/FileSystemWx.cpp b/WebCore/platform/wx/FileSystemWx.cpp index 109278f..1ee87ae 100644 --- a/WebCore/platform/wx/FileSystemWx.cpp +++ b/WebCore/platform/wx/FileSystemWx.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2007 Kevin Ollivier * Copyright (C) 2008 Collabora, Ltd. + * Copyright (C) 2009 Peter Laufenberg @ Inhance Digital Corp * * All rights reserved. * @@ -34,13 +35,23 @@ #include "PlatformString.h" #include <wx/wx.h> +#include <wx/datetime.h> +#include <wx/dir.h> +#include <wx/dynlib.h> +#include <wx/file.h> +#include <wx/filefn.h> #include <wx/filename.h> +#if PLATFORM(DARWIN) +#include <CoreFoundation/CoreFoundation.h> +#endif + namespace WebCore { bool fileExists(const String& path) { - return wxFileName::FileExists(path); + // NOTE: This is called for directory paths too so we need to check both. + return wxFileName::FileExists(path) || wxFileName::DirExists(path); } bool deleteFile(const String& path) @@ -114,16 +125,71 @@ int writeToFile(PlatformFileHandle, const char* data, int length) return 0; } -bool unloadModule(PlatformModule) +bool unloadModule(PlatformModule mod) { - notImplemented(); - return false; +#if PLATFORM(WIN_OS) + return ::FreeLibrary(mod); +#elif PLATFORM(DARWIN) + CFRelease(mod); + return true; +#else + wxASSERT(mod); + delete mod; + return true; +#endif } + +class wxDirTraverserNonRecursive : public wxDirTraverser { +public: + wxDirTraverserNonRecursive(wxString basePath, wxArrayString& files) : m_basePath(basePath), m_files(files) { } + + virtual wxDirTraverseResult OnFile(const wxString& filename) + { + wxFileName afile(filename); + afile.MakeRelativeTo(m_basePath); + if (afile.GetFullPath().Find(afile.GetPathSeparator()) == wxNOT_FOUND) + m_files.push_back(filename); + + return wxDIR_CONTINUE; + } + + virtual wxDirTraverseResult OnDir(const wxString& dirname) + { + wxFileName dirfile(dirname); + dirfile.MakeRelativeTo(m_basePath); + if (dirfile.GetFullPath().Find(dirfile.GetPathSeparator()) == wxNOT_FOUND) + m_files.push_back(dirname); + + return wxDIR_CONTINUE; + } + +private: + wxString m_basePath; + wxArrayString& m_files; + + DECLARE_NO_COPY_CLASS(wxDirTraverserNonRecursive) +}; + Vector<String> listDirectory(const String& path, const String& filter) { + wxArrayString file_paths; + // wxDir::GetAllFiles recurses and for platforms like Mac where + // a .plugin or .bundle can be a dir wx will recurse into the bundle + // and list the files rather than just returning the plugin name, so + // we write a special traverser that works around that issue. + wxDirTraverserNonRecursive traverser(path, file_paths); + + wxDir dir(path); + dir.Traverse(traverser, _T(""), wxDIR_FILES | wxDIR_DIRS); + Vector<String> entries; - notImplemented(); + + for (int i = 0; i < file_paths.GetCount(); i++) + { + entries.append(file_paths[i]); + } + return entries; } diff --git a/WebCore/platform/wx/LocalizedStringsWx.cpp b/WebCore/platform/wx/LocalizedStringsWx.cpp index 5bede52..6a389f2 100644 --- a/WebCore/platform/wx/LocalizedStringsWx.cpp +++ b/WebCore/platform/wx/LocalizedStringsWx.cpp @@ -27,6 +27,7 @@ #include "config.h" #include "LocalizedStrings.h" +#include "NotImplemented.h" #include "PlatformString.h" namespace WebCore { @@ -323,4 +324,46 @@ String AXDefinitionListDefinitionText() return String(); } +String validationMessageValueMissingText() +{ + notImplemented(); + return String(); +} + +String validationMessageTypeMismatchText() +{ + notImplemented(); + return String(); +} + +String validationMessagePatternMismatchText() +{ + notImplemented(); + return String(); +} + +String validationMessageTooLongText() +{ + notImplemented(); + return String(); +} + +String validationMessageRangeUnderflowText() +{ + notImplemented(); + return String(); +} + +String validationMessageRangeOverflowText() +{ + notImplemented(); + return String(); +} + +String validationMessageStepMismatchText() +{ + notImplemented(); + return String(); +} + } // namespace WebCore diff --git a/WebCore/platform/wx/ScrollbarThemeWx.cpp b/WebCore/platform/wx/ScrollbarThemeWx.cpp index 6904f41..82e4a15 100644 --- a/WebCore/platform/wx/ScrollbarThemeWx.cpp +++ b/WebCore/platform/wx/ScrollbarThemeWx.cpp @@ -28,6 +28,7 @@ #include "HostWindow.h" #include "NotImplemented.h" +#include "PlatformMouseEvent.h" #include "Scrollbar.h" #include "ScrollbarClient.h" #include "scrollbar_render.h" @@ -70,6 +71,11 @@ bool ScrollbarThemeWx::hasThumb(Scrollbar* scrollbar) return thumbLength(scrollbar) > 0; } +int ScrollbarThemeWx::minimumThumbLength(Scrollbar* scrollbar) +{ + return 20; +} + IntSize ScrollbarThemeWx::buttonSize(Scrollbar*) { #ifdef __WXMAC__ @@ -79,6 +85,22 @@ IntSize ScrollbarThemeWx::buttonSize(Scrollbar*) #endif } +void ScrollbarThemeWx::splitTrack(Scrollbar* scrollbar, const IntRect& unconstrainedTrackRect, IntRect& beforeThumbRect, IntRect& thumbRect, IntRect& afterThumbRect) +{ + ScrollbarThemeComposite::splitTrack(scrollbar, unconstrainedTrackRect, beforeThumbRect, thumbRect, afterThumbRect); +#ifdef __WXMAC__ + // on Mac, there are a few pixels drawn above the actual track and so adjust + // the hit testing rects accordingly + int trackStart = 10; + if (scrollbar->orientation() == HorizontalScrollbar) { + thumbRect.setX(thumbRect.x() + trackStart); + afterThumbRect.setX(afterThumbRect.x() - trackStart); + } else { + thumbRect.setY(thumbRect.y() + trackStart); + afterThumbRect.setY(afterThumbRect.y() - trackStart); + } +#endif +} IntRect ScrollbarThemeWx::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool) { @@ -111,10 +133,16 @@ IntRect ScrollbarThemeWx::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart IntSize size = buttonSize(scrollbar); int x, y; if (scrollbar->orientation() == HorizontalScrollbar) { +#ifdef __WXMAC__ + size.setWidth(size.width() + cMacButtonOverlap); +#endif x = scrollbar->x() + scrollbar->width() - size.width(); y = scrollbar->y(); } else { x = scrollbar->x(); +#ifdef __WXMAC__ + size.setHeight(size.height() + cMacButtonOverlap); +#endif y = scrollbar->y() + scrollbar->height() - size.height(); } return IntRect(x, y, size.width(), size.height()); diff --git a/WebCore/platform/wx/ScrollbarThemeWx.h b/WebCore/platform/wx/ScrollbarThemeWx.h index 2b3bff0..79b10b3 100644 --- a/WebCore/platform/wx/ScrollbarThemeWx.h +++ b/WebCore/platform/wx/ScrollbarThemeWx.h @@ -48,6 +48,10 @@ protected: virtual IntRect backButtonRect(Scrollbar*, ScrollbarPart, bool painting = false); virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false); virtual IntRect trackRect(Scrollbar*, bool painting = false); + + virtual void splitTrack(Scrollbar*, const IntRect& track, IntRect& startTrack, IntRect& thumb, IntRect& endTrack); + + virtual int minimumThumbLength(Scrollbar*); }; } diff --git a/WebCore/platform/wx/wxcode/gtk/scrollbar_render.cpp b/WebCore/platform/wx/wxcode/gtk/scrollbar_render.cpp index f74b076..3b4daa8 100644 --- a/WebCore/platform/wx/wxcode/gtk/scrollbar_render.cpp +++ b/WebCore/platform/wx/wxcode/gtk/scrollbar_render.cpp @@ -116,9 +116,18 @@ void wxRenderer_DrawScrollbar(wxWindow* window, wxDC& dc, const wxRect& rect, wx dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW))); dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); + // when going from Cairo -> Gdk, any Cairo context transformations are lost + // so we need to alter the coordinates to reflect their transformed point. + double xtrans = 0; + double ytrans = 0; + + wxGCDC* gcdc = wxDynamicCast(&dc, wxGCDC); + wxGraphicsContext* gc = gcdc->GetGraphicsContext(); + gc->GetTransform().TransformPoint(&xtrans, &ytrans); + wxRendererNative& renderer = wxRendererNative::Get(); - int x = rect.x; - int y = rect.y; + int x = rect.x + (int)xtrans; + int y = rect.y + (int)ytrans; int buttonLength = 16; @@ -138,13 +147,15 @@ void wxRenderer_DrawScrollbar(wxWindow* window, wxDC& dc, const wxRect& rect, wx physicalLength -= buttonLength*2; int thumbStart = 0; int thumbLength = 0; - calcThumbStartAndLength(physicalLength, max + step, current, step, &thumbStart, &thumbLength); + calcThumbStartAndLength(physicalLength, max, current, step, &thumbStart, &thumbLength); if (horiz) { - buttonRect.x = thumbStart + buttonLength; + buttonRect.x = x + thumbStart + buttonLength; + buttonRect.y = y; buttonRect.width = thumbLength; } else { - buttonRect.y = thumbStart + buttonLength; + buttonRect.x = x; + buttonRect.y = y + thumbStart + buttonLength; buttonRect.height = thumbLength; } 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 c4c4d48..47eb1f8 100644 --- a/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp +++ b/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp @@ -56,7 +56,7 @@ void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext()); wxFont* wxfont = font->getWxFont(); - graphicsContext->setFillColor(graphicsContext->fillColor()); + graphicsContext->setFillColor(graphicsContext->fillColor(), DeviceColorSpace); CGContextRef cgContext = static_cast<CGContextRef>(dc->GetGraphicsContext()->GetNativeContext()); diff --git a/WebCore/platform/wx/wxcode/scrollbar_render.h b/WebCore/platform/wx/wxcode/scrollbar_render.h index 7a0ba1c..5e0ea8e 100644 --- a/WebCore/platform/wx/wxcode/scrollbar_render.h +++ b/WebCore/platform/wx/wxcode/scrollbar_render.h @@ -50,16 +50,17 @@ void wxRenderer_DrawScrollbar(wxWindow* window, wxDC& dc, int current, wxScrollbarPart focusPart, wxScrollbarPart hoverPart, int max, int step, int flags=0); -inline void calcThumbStartAndLength(int physicalLength, int virtualLength, int current, +inline void calcThumbStartAndLength(int physicalLength, int max, int current, int step, int *thumbStart, int *thumbLength) { - float proportion = (float)physicalLength / virtualLength; - float scale = (float)virtualLength / physicalLength; - int thumbSize = proportion * physicalLength; - int currentPos = current / scale; - + float proportion = ((float)physicalLength - 8)/ (max + step); + float thumbSize = proportion * (float)physicalLength; + if (thumbSize < 20) + thumbSize = 20; + + float thumbPos = ((float)current / (float)max) * ((float)physicalLength - thumbSize); if (thumbStart) - *thumbStart = currentPos; + *thumbStart = thumbPos; if (thumbLength) *thumbLength = thumbSize; diff --git a/WebCore/platform/wx/wxcode/win/scrollbar_render.cpp b/WebCore/platform/wx/wxcode/win/scrollbar_render.cpp index 4d6bbc0..890db00 100644 --- a/WebCore/platform/wx/wxcode/win/scrollbar_render.cpp +++ b/WebCore/platform/wx/wxcode/win/scrollbar_render.cpp @@ -30,6 +30,8 @@ #include <wx/defs.h> #include <wx/dc.h> +#include <wx/dcgraph.h> +#include <wx/graphics.h> #include <wx/renderer.h> #include <wx/window.h> @@ -131,8 +133,24 @@ void wxRenderer_DrawScrollbar(wxWindow* window, wxDC& dc, part = SP_TRACKENDVERT; int xpState = TS_NORMAL; + wxRect transRect = rect; + +#if USE(WXGC) + // when going from GdiPlus -> Gdi, any GdiPlus transformations are lost + // so we need to alter the coordinates to reflect their transformed point. + double xtrans = 0; + double ytrans = 0; + + wxGCDC* gcdc = wxDynamicCast(&dc, wxGCDC); + wxGraphicsContext* gc = gcdc->GetGraphicsContext(); + gc->GetTransform().TransformPoint(&xtrans, &ytrans); + + transRect.x += (int)xtrans; + transRect.y += (int)ytrans; +#endif + RECT r; - wxCopyRectToRECT(rect, r); + wxCopyRectToRECT(transRect, r); // Unlike Mac, on MSW you draw the scrollbar piece by piece. // so we draw the track first, then the buttons @@ -163,14 +181,14 @@ void wxRenderer_DrawScrollbar(wxWindow* window, wxDC& dc, physicalLength -= buttonSize*2; int thumbStart = 0; int thumbLength = 0; - calcThumbStartAndLength(physicalLength, max + step, + calcThumbStartAndLength(physicalLength, max, current, step, &thumbStart, &thumbLength); buttonRect = r; if (horiz) { - buttonRect.left = thumbStart + buttonSize; + buttonRect.left = buttonRect.left + thumbStart + buttonSize; buttonRect.right = buttonRect.left + thumbLength; } else { - buttonRect.top = thumbStart + buttonSize; + buttonRect.top = buttonRect.top + thumbStart + buttonSize; buttonRect.bottom = buttonRect.top + thumbLength; } |