diff options
author | Kristian Monsen <kristianm@google.com> | 2010-06-28 16:42:48 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-07-02 10:29:56 +0100 |
commit | 06ea8e899e48f1f2f396b70e63fae369f2f23232 (patch) | |
tree | 20c1428cd05c76f32394ab354ea35ed99acd86d8 /WebCore/platform/gtk | |
parent | 72aad67af14193199e29cdd5c4ddc095a8b9a8a8 (diff) | |
download | external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.zip external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.gz external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.bz2 |
Merge WebKit at r61871: Initial merge by git.
Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5
Diffstat (limited to 'WebCore/platform/gtk')
-rw-r--r-- | WebCore/platform/gtk/ClipboardGtk.cpp | 20 | ||||
-rw-r--r-- | WebCore/platform/gtk/DataObjectGtk.cpp | 25 | ||||
-rw-r--r-- | WebCore/platform/gtk/DataObjectGtk.h | 1 | ||||
-rw-r--r-- | WebCore/platform/gtk/GtkVersioning.h | 22 | ||||
-rw-r--r-- | WebCore/platform/gtk/PasteboardGtk.cpp | 9 | ||||
-rw-r--r-- | WebCore/platform/gtk/PasteboardHelper.cpp | 7 | ||||
-rw-r--r-- | WebCore/platform/gtk/PlatformScreenGtk.cpp | 4 | ||||
-rw-r--r-- | WebCore/platform/gtk/PopupMenuGtk.cpp | 8 | ||||
-rw-r--r-- | WebCore/platform/gtk/RenderThemeGtk.cpp | 102 | ||||
-rw-r--r-- | WebCore/platform/gtk/ScrollbarGtk.cpp | 20 |
10 files changed, 125 insertions, 93 deletions
diff --git a/WebCore/platform/gtk/ClipboardGtk.cpp b/WebCore/platform/gtk/ClipboardGtk.cpp index ad1c665..924fabc 100644 --- a/WebCore/platform/gtk/ClipboardGtk.cpp +++ b/WebCore/platform/gtk/ClipboardGtk.cpp @@ -331,23 +331,7 @@ void ClipboardGtk::declareAndWriteDragImage(Element* element, const KURL& url, c void ClipboardGtk::writeURL(const KURL& url, const String& label, Frame*) { - String actualLabel(label); - if (actualLabel.isEmpty()) - actualLabel = url; - m_dataObject->setText(actualLabel); - - Vector<UChar> markup; - append(markup, "<a href=\""); - append(markup, url.string()); - append(markup, "\">"); - append(markup, label); - append(markup, "</a>"); - m_dataObject->setMarkup(String::adopt(markup)); - - Vector<KURL> uriList; - uriList.append(url); - m_dataObject->setURIList(uriList); - + m_dataObject->setURL(url, label); if (m_clipboard) m_helper->writeClipboardContents(m_clipboard); } @@ -357,7 +341,7 @@ void ClipboardGtk::writeRange(Range* range, Frame* frame) ASSERT(range); m_dataObject->setText(frame->selectedText()); - m_dataObject->setMarkup(createMarkup(range, 0, AnnotateForInterchange)); + m_dataObject->setMarkup(createMarkup(range, 0, AnnotateForInterchange, false, AbsoluteURLs)); if (m_clipboard) m_helper->writeClipboardContents(m_clipboard); diff --git a/WebCore/platform/gtk/DataObjectGtk.cpp b/WebCore/platform/gtk/DataObjectGtk.cpp index 57d920c..db13345 100644 --- a/WebCore/platform/gtk/DataObjectGtk.cpp +++ b/WebCore/platform/gtk/DataObjectGtk.cpp @@ -21,6 +21,7 @@ #include "markup.h" #include <gtk/gtk.h> +#include <wtf/gobject/GOwnPtr.h> namespace WebCore { @@ -41,7 +42,7 @@ String DataObjectGtk::text() String DataObjectGtk::markup() { if (m_range) - return createMarkup(m_range.get(), 0, AnnotateForInterchange); + return createMarkup(m_range.get(), 0, AnnotateForInterchange, false, AbsoluteURLs); return m_markup; } @@ -58,6 +59,28 @@ void DataObjectGtk::setMarkup(const String& newMarkup) m_markup = newMarkup; } +void DataObjectGtk::setURL(const KURL& url, const String& label) +{ + setText(url.string()); + + String actualLabel(label); + if (actualLabel.isEmpty()) + actualLabel = url; + + Vector<UChar> markup; + append(markup, "<a href=\""); + append(markup, url.string()); + append(markup, "\">"); + GOwnPtr<gchar> escaped(g_markup_escape_text(actualLabel.utf8().data(), -1)); + append(markup, String::fromUTF8(escaped.get())); + append(markup, "</a>"); + setMarkup(String::adopt(markup)); + + Vector<KURL> uriList; + uriList.append(url); + setURIList(uriList); +} + void DataObjectGtk::clearText() { m_range = 0; diff --git a/WebCore/platform/gtk/DataObjectGtk.h b/WebCore/platform/gtk/DataObjectGtk.h index 41f8f49..8fba938 100644 --- a/WebCore/platform/gtk/DataObjectGtk.h +++ b/WebCore/platform/gtk/DataObjectGtk.h @@ -46,6 +46,7 @@ public: void setURIList(const Vector<KURL>& newURIList) { m_uriList = newURIList; } void setImage(GdkPixbuf* newImage) { m_image = newImage; } void setDragContext(GdkDragContext* newDragContext) { m_dragContext = newDragContext; } + void setURL(const KURL&, const String&); bool hasText() { return m_range || !m_text.isEmpty(); } bool hasMarkup() { return m_range || !m_markup.isEmpty(); } bool hasURIList() { return !m_uriList.isEmpty(); } diff --git a/WebCore/platform/gtk/GtkVersioning.h b/WebCore/platform/gtk/GtkVersioning.h index cdd679c..3ee6763 100644 --- a/WebCore/platform/gtk/GtkVersioning.h +++ b/WebCore/platform/gtk/GtkVersioning.h @@ -23,6 +23,16 @@ #include <gtk/gtk.h> // Macros to avoid deprecation checking churn +#if !GTK_CHECK_VERSION(2, 21, 2) +#define gdk_visual_get_depth(visual) (visual)->depth +#define gdk_visual_get_bits_per_rgb(visual) (visual)->bits_per_rgb +#define gdk_drag_context_get_selected_action(context) (context)->action +#endif // GTK_CHECK_VERSION(2, 21, 2) + +#if !GTK_CHECK_VERSION(2, 20, 0) +#define gtk_widget_set_realized(widget, TRUE) GTK_WIDGET_SET_FLAGS((widget), GTK_REALIZED) +#endif // GTK_CHECK_VERSION(2, 20, 0) + #if !GTK_CHECK_VERSION(2, 19, 0) #define gtk_widget_is_toplevel(widget) GTK_WIDGET_TOPLEVEL(widget) #define gtk_widget_get_realized(widget) GTK_WIDGET_REALIZED(widget) @@ -31,8 +41,18 @@ #define gtk_widget_is_sensitive(widget) GTK_WIDGET_IS_SENSITIVE(widget) #endif // GTK_CHECK_VERSION(2, 19, 0) +#if !GTK_CHECK_VERSION(2, 18, 0) +#define gtk_widget_set_visible(widget, FALSE) GTK_WIDGET_UNSET_FLAGS((widget), GTK_VISIBLE) +#define gtk_widget_set_window(widget, new_window) (widget)->window = (new_window) +#define gtk_widget_set_can_focus(widget, TRUE) GTK_WIDGET_SET_FLAGS((widget), GTK_CAN_FOCUS) +#endif // GTK_CHECK_VERSION(2, 18, 0) + #if !GTK_CHECK_VERSION(2, 14, 0) #define gtk_widget_get_window(widget) (widget)->window -#endif +#define gtk_adjustment_get_value(adj) (adj)->value +#define gtk_dialog_get_content_area(dialog) (dialog)->vbox +#define gtk_selection_data_get_length(data) (data)->length +#define gtk_selection_data_get_data(data) (data)->data +#endif // GTK_CHECK_VERSION(2, 14, 0) #endif // GtkVersioning_h diff --git a/WebCore/platform/gtk/PasteboardGtk.cpp b/WebCore/platform/gtk/PasteboardGtk.cpp index 599f7da..a0069cf 100644 --- a/WebCore/platform/gtk/PasteboardGtk.cpp +++ b/WebCore/platform/gtk/PasteboardGtk.cpp @@ -68,7 +68,7 @@ void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, GtkClipboard* clipboard = m_helper->getClipboard(frame); DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); dataObject->setText(frame->selectedText()); - dataObject->setMarkup(createMarkup(selectedRange, 0, AnnotateForInterchange)); + dataObject->setMarkup(createMarkup(selectedRange, 0, AnnotateForInterchange, false, AbsoluteURLs)); m_helper->writeClipboardContents(clipboard); } @@ -80,17 +80,14 @@ void Pasteboard::writePlainText(const String& text) m_helper->writeClipboardContents(clipboard); } -void Pasteboard::writeURL(const KURL& url, const String&, Frame* frame) +void Pasteboard::writeURL(const KURL& url, const String& label, Frame* frame) { if (url.isEmpty()) return; GtkClipboard* clipboard = m_helper->getClipboard(frame); DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); - - Vector<KURL> uriList; - uriList.append(url); - dataObject->setURIList(uriList); + dataObject->setURL(url, label); m_helper->writeClipboardContents(clipboard); } diff --git a/WebCore/platform/gtk/PasteboardHelper.cpp b/WebCore/platform/gtk/PasteboardHelper.cpp index 3dc4cc0..141488f 100644 --- a/WebCore/platform/gtk/PasteboardHelper.cpp +++ b/WebCore/platform/gtk/PasteboardHelper.cpp @@ -25,6 +25,7 @@ #include "Chrome.h" #include "DataObjectGtk.h" #include "Frame.h" +#include "GtkVersioning.h" #include "Page.h" #include "Pasteboard.h" #include "TextResourceDecoder.h" @@ -115,7 +116,7 @@ void PasteboardHelper::getClipboardContents(GtkClipboard* clipboard) if (gtk_clipboard_wait_is_target_available(clipboard, gdkMarkupAtom)) { if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, gdkMarkupAtom)) { RefPtr<TextResourceDecoder> decoder(TextResourceDecoder::create("text/plain", "UTF-8", true)); - String markup(decoder->decode(reinterpret_cast<char*>(data->data), data->length)); + String markup(decoder->decode(reinterpret_cast<const char*>(gtk_selection_data_get_data(data)), gtk_selection_data_get_length(data))); markup += decoder->flush(); dataObject->setMarkup(markup); gtk_selection_data_free(data); @@ -141,7 +142,7 @@ void PasteboardHelper::fillSelectionData(GtkSelectionData* selectionData, guint else if (info == getIdForTargetType(TargetTypeMarkup)) { GOwnPtr<gchar> markup(g_strdup(dataObject->markup().utf8().data())); - gtk_selection_data_set(selectionData, selectionData->target, 8, + gtk_selection_data_set(selectionData, gdkMarkupAtom, 8, reinterpret_cast<const guchar*>(markup.get()), strlen(markup.get())); } else if (info == getIdForTargetType(TargetTypeURIList)) { @@ -164,7 +165,7 @@ void PasteboardHelper::fillSelectionData(GtkSelectionData* selectionData, guint result.append(url); GOwnPtr<gchar> resultData(g_strdup(result.utf8().data())); - gtk_selection_data_set(selectionData, selectionData->target, 8, + gtk_selection_data_set(selectionData, netscapeURLAtom, 8, reinterpret_cast<const guchar*>(resultData.get()), strlen(resultData.get())); } else if (info == getIdForTargetType(TargetTypeImage)) diff --git a/WebCore/platform/gtk/PlatformScreenGtk.cpp b/WebCore/platform/gtk/PlatformScreenGtk.cpp index 0ab00a1..6ace728 100644 --- a/WebCore/platform/gtk/PlatformScreenGtk.cpp +++ b/WebCore/platform/gtk/PlatformScreenGtk.cpp @@ -72,7 +72,7 @@ int screenDepth(Widget* widget) GdkVisual* visual = getVisual(widget); if (!visual) return 24; - return visual->depth; + return gdk_visual_get_depth(visual); } int screenDepthPerComponent(Widget* widget) @@ -81,7 +81,7 @@ int screenDepthPerComponent(Widget* widget) if (!visual) return 8; - return visual->bits_per_rgb; + return gdk_visual_get_bits_per_rgb(visual); } bool screenIsMonochrome(Widget* widget) diff --git a/WebCore/platform/gtk/PopupMenuGtk.cpp b/WebCore/platform/gtk/PopupMenuGtk.cpp index f29d51b..bf8cfb4 100644 --- a/WebCore/platform/gtk/PopupMenuGtk.cpp +++ b/WebCore/platform/gtk/PopupMenuGtk.cpp @@ -89,22 +89,24 @@ void PopupMenu::show(const IntRect& rect, FrameView* view, int index) gtk_widget_size_request(GTK_WIDGET(m_popup.get()), &requisition); gtk_widget_set_size_request(GTK_WIDGET(m_popup.get()), std::max(rect.width(), requisition.width), -1); - GList* children = GTK_MENU_SHELL(m_popup.get())->children; + GList* children = gtk_container_get_children(GTK_CONTAINER(m_popup.get())); + GList* p = children; if (size) for (int i = 0; i < size; i++) { if (i > index) break; - GtkWidget* item = reinterpret_cast<GtkWidget*>(children->data); + GtkWidget* item = reinterpret_cast<GtkWidget*>(p->data); GtkRequisition itemRequisition; gtk_widget_get_child_requisition(item, &itemRequisition); m_menuPosition.setY(m_menuPosition.y() - itemRequisition.height); - children = g_list_next(children); + p = g_list_next(p); } else // Center vertically the empty popup in the combo box area m_menuPosition.setY(m_menuPosition.y() - rect.height() / 2); + g_list_free(children); gtk_menu_popup(m_popup.get(), 0, 0, reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this, 0, gtk_get_current_event_time()); } diff --git a/WebCore/platform/gtk/RenderThemeGtk.cpp b/WebCore/platform/gtk/RenderThemeGtk.cpp index 6205dbd..75fb946 100644 --- a/WebCore/platform/gtk/RenderThemeGtk.cpp +++ b/WebCore/platform/gtk/RenderThemeGtk.cpp @@ -299,77 +299,63 @@ static void setMozillaState(const RenderTheme* theme, GtkThemeWidgetType type, R static bool paintMozillaGtkWidget(const RenderThemeGtk* theme, GtkThemeWidgetType type, RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) { - GRefPtr<GdkDrawable> pixmap; - // Painting is disabled so just claim to have succeeded if (i.context->paintingDisabled()) return false; - // No GdkWindow to render to, so return true to fall back - if (!i.context->gdkDrawable()) - // This is slow, used only during printing process - pixmap = adoptGRef(gdk_pixmap_new(0, rect.width(), rect.height(), gdk_visual_get_system()->depth)); - - GtkWidgetState mozState; - setMozillaState(theme, type, o, &mozState); - - int flags; + GtkWidgetState widgetState; + setMozillaState(theme, type, o, &widgetState); // We might want to make setting flags the caller's job at some point rather than doing it here. - switch (type) { - case MOZ_GTK_BUTTON: + int flags = 0; + if (type == MOZ_GTK_BUTTON) flags = GTK_RELIEF_NORMAL; - break; - case MOZ_GTK_CHECKBUTTON: - case MOZ_GTK_RADIOBUTTON: + else if (type == MOZ_GTK_CHECKBUTTON || type == MOZ_GTK_RADIOBUTTON) flags = theme->isChecked(o); - break; - default: - flags = 0; - break; - } - - GtkTextDirection direction = gtkTextDirection(o->style()->direction()); - if (pixmap) { - GdkRectangle gdkRect = IntRect(0, 0, rect.width(), rect.height()); + GRefPtr<GdkDrawable> drawable(i.context->gdkDrawable()); + GdkRectangle paintRect, clipRect; + if (drawable) { + AffineTransform ctm = i.context->getCTM(); + IntPoint pos = ctm.mapPoint(rect.location()); + paintRect = IntRect(pos.x(), pos.y(), rect.width(), rect.height()); + + // Intersect the cairo rectangle with the target widget region. This will + // prevent the theme drawing code from drawing into regions that cairo will + // clip anyway. + cairo_t* cr = i.context->platformContext(); + double clipX1, clipX2, clipY1, clipY2; + cairo_clip_extents(cr, &clipX1, &clipY1, &clipX2, &clipY2); + IntPoint clipPos = ctm.mapPoint(IntPoint(clipX1, clipY1)); + + clipRect.width = clipX2 - clipX1; + clipRect.height = clipY2 - clipY1; + clipRect.x = clipPos.x(); + clipRect.y = clipPos.y(); + gdk_rectangle_intersect(&paintRect, &clipRect, &clipRect); - moz_gtk_use_theme_parts(theme->partsForDrawable(pixmap.get())); - - bool result = moz_gtk_widget_paint(type, pixmap.get(), &gdkRect, &gdkRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS; - - if (!result) { - cairo_t* cr = i.context->platformContext(); - gdk_cairo_set_source_pixmap(cr, pixmap.get(), rect.x(), rect.y()); - cairo_paint(cr); - } - - return result; + } else { + // In some situations, like during print previews, this GraphicsContext is not + // backed by a GdkDrawable. In those situations, we render onto a pixmap and then + // copy the rendered data back to the GraphicsContext via Cairo. + drawable = adoptGRef(gdk_pixmap_new(0, rect.width(), rect.height(), gdk_visual_get_system()->depth)); + paintRect = clipRect = IntRect(0, 0, rect.width(), rect.height()); } - AffineTransform ctm = i.context->getCTM(); - - IntPoint pos = ctm.mapPoint(rect.location()); - GdkRectangle gdkRect = IntRect(pos.x(), pos.y(), rect.width(), rect.height()); - - // Find the clip rectangle - cairo_t* cr = i.context->platformContext(); - double clipX1, clipX2, clipY1, clipY2; - cairo_clip_extents(cr, &clipX1, &clipY1, &clipX2, &clipY2); - - GdkRectangle gdkClipRect; - gdkClipRect.width = clipX2 - clipX1; - gdkClipRect.height = clipY2 - clipY1; - IntPoint clipPos = ctm.mapPoint(IntPoint(clipX1, clipY1)); - gdkClipRect.x = clipPos.x(); - gdkClipRect.y = clipPos.y(); - - gdk_rectangle_intersect(&gdkRect, &gdkClipRect, &gdkClipRect); + moz_gtk_use_theme_parts(theme->partsForDrawable(drawable.get())); + bool success = moz_gtk_widget_paint(type, drawable.get(), &paintRect, &clipRect, &widgetState, flags, gtkTextDirection(o->style()->direction())) == MOZ_GTK_SUCCESS; + + // If the drawing was successful and we rendered onto a pixmap, copy the + // results back to the original GraphicsContext. + if (success && !i.context->gdkDrawable()) { + cairo_t* cairoContext = i.context->platformContext(); + cairo_save(cairoContext); + gdk_cairo_set_source_pixmap(cairoContext, drawable.get(), rect.x(), rect.y()); + cairo_paint(cairoContext); + cairo_restore(cairoContext); + } - // Since the theme renderer is going to be drawing onto this GdkDrawable, - // select the appropriate widgets for the drawable depth. - moz_gtk_use_theme_parts(theme->partsForDrawable(i.context->gdkDrawable())); - return moz_gtk_widget_paint(type, i.context->gdkDrawable(), &gdkRect, &gdkClipRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS; + return !success; } static void setButtonPadding(RenderStyle* style) diff --git a/WebCore/platform/gtk/ScrollbarGtk.cpp b/WebCore/platform/gtk/ScrollbarGtk.cpp index 3d4cc47..5dc4dd6 100644 --- a/WebCore/platform/gtk/ScrollbarGtk.cpp +++ b/WebCore/platform/gtk/ScrollbarGtk.cpp @@ -120,11 +120,15 @@ void ScrollbarGtk::detachAdjustment() // For the case where we only operate on the GtkAdjustment it is best to // reset the values so that the surrounding scrollbar gets updated, or // e.g. for a GtkScrolledWindow the scrollbar gets hidden. +#if GTK_CHECK_VERSION(2, 14, 0) + gtk_adjustment_configure(m_adjustment, 0, 0, 0, 0, 0, 0); +#else m_adjustment->lower = 0; m_adjustment->upper = 0; m_adjustment->value = 0; gtk_adjustment_changed(m_adjustment); gtk_adjustment_value_changed(m_adjustment); +#endif g_object_unref(m_adjustment); m_adjustment = 0; } @@ -158,19 +162,33 @@ void ScrollbarGtk::frameRectsChanged() void ScrollbarGtk::updateThumbPosition() { - if (m_adjustment->value != m_currentPos) { + if (gtk_adjustment_get_value(m_adjustment) != m_currentPos) { +#if GTK_CHECK_VERSION(2, 14, 0) + gtk_adjustment_set_value(m_adjustment, m_currentPos); +#else m_adjustment->value = m_currentPos; gtk_adjustment_value_changed(m_adjustment); +#endif } } void ScrollbarGtk::updateThumbProportion() { +#if GTK_CHECK_VERSION(2, 14, 0) + gtk_adjustment_configure(m_adjustment, + gtk_adjustment_get_value(m_adjustment), + gtk_adjustment_get_lower(m_adjustment), + m_totalSize, + m_lineStep, + m_pageStep, + m_visibleSize); +#else m_adjustment->step_increment = m_lineStep; m_adjustment->page_increment = m_pageStep; m_adjustment->page_size = m_visibleSize; m_adjustment->upper = m_totalSize; gtk_adjustment_changed(m_adjustment); +#endif } void ScrollbarGtk::setFrameRect(const IntRect& rect) |