diff options
Diffstat (limited to 'WebCore/editing/DeleteButtonController.cpp')
-rw-r--r-- | WebCore/editing/DeleteButtonController.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/WebCore/editing/DeleteButtonController.cpp b/WebCore/editing/DeleteButtonController.cpp index 0516e0c..c0775e3 100644 --- a/WebCore/editing/DeleteButtonController.cpp +++ b/WebCore/editing/DeleteButtonController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -101,12 +101,12 @@ static bool isDeletableElement(const Node* node) return false; } -static HTMLElement* enclosingDeletableElement(const Selection& selection) +static HTMLElement* enclosingDeletableElement(const VisibleSelection& selection) { if (!selection.isContentEditable()) return 0; - RefPtr<Range> range = selection.toRange(); + RefPtr<Range> range = selection.toNormalizedRange(); if (!range) return 0; @@ -128,7 +128,7 @@ static HTMLElement* enclosingDeletableElement(const Selection& selection) return static_cast<HTMLElement*>(element); } -void DeleteButtonController::respondToChangedSelection(const Selection& oldSelection) +void DeleteButtonController::respondToChangedSelection(const VisibleSelection& oldSelection) { if (!enabled()) return; @@ -154,6 +154,13 @@ void DeleteButtonController::createDeletionUI() style->setProperty(CSSPropertyWebkitUserDrag, CSSValueNone); style->setProperty(CSSPropertyWebkitUserSelect, CSSValueNone); style->setProperty(CSSPropertyWebkitUserModify, CSSValueNone); + style->setProperty(CSSPropertyVisibility, CSSValueHidden); + style->setProperty(CSSPropertyPosition, CSSValueAbsolute); + style->setProperty(CSSPropertyCursor, CSSValueDefault); + style->setProperty(CSSPropertyTop, "0"); + style->setProperty(CSSPropertyRight, "0"); + style->setProperty(CSSPropertyBottom, "0"); + style->setProperty(CSSPropertyLeft, "0"); RefPtr<HTMLDivElement> outline = new HTMLDivElement(divTag, m_target->document()); outline->setId(outlineElementIdentifier); @@ -163,10 +170,6 @@ void DeleteButtonController::createDeletionUI() style = outline->getInlineStyleDecl(); style->setProperty(CSSPropertyPosition, CSSValueAbsolute); - style->setProperty(CSSPropertyCursor, CSSValueDefault); - style->setProperty(CSSPropertyWebkitUserDrag, CSSValueNone); - style->setProperty(CSSPropertyWebkitUserSelect, CSSValueNone); - style->setProperty(CSSPropertyWebkitUserModify, CSSValueNone); style->setProperty(CSSPropertyZIndex, String::number(-1000000)); style->setProperty(CSSPropertyTop, String::number(-borderWidth - m_target->renderBox()->borderTop()) + "px"); style->setProperty(CSSPropertyRight, String::number(-borderWidth - m_target->renderBox()->borderRight()) + "px"); @@ -174,6 +177,7 @@ void DeleteButtonController::createDeletionUI() style->setProperty(CSSPropertyLeft, String::number(-borderWidth - m_target->renderBox()->borderLeft()) + "px"); style->setProperty(CSSPropertyBorder, String::number(borderWidth) + "px solid rgba(0, 0, 0, 0.6)"); style->setProperty(CSSPropertyWebkitBorderRadius, String::number(borderRadius) + "px"); + style->setProperty(CSSPropertyVisibility, CSSValueVisible); ExceptionCode ec = 0; container->appendChild(outline.get(), ec); @@ -190,15 +194,12 @@ void DeleteButtonController::createDeletionUI() style = button->getInlineStyleDecl(); style->setProperty(CSSPropertyPosition, CSSValueAbsolute); - style->setProperty(CSSPropertyCursor, CSSValueDefault); - style->setProperty(CSSPropertyWebkitUserDrag, CSSValueNone); - style->setProperty(CSSPropertyWebkitUserSelect, CSSValueNone); - style->setProperty(CSSPropertyWebkitUserModify, CSSValueNone); style->setProperty(CSSPropertyZIndex, String::number(1000000)); style->setProperty(CSSPropertyTop, String::number((-buttonHeight / 2) - m_target->renderBox()->borderTop() - (borderWidth / 2) + buttonBottomShadowOffset) + "px"); style->setProperty(CSSPropertyLeft, String::number((-buttonWidth / 2) - m_target->renderBox()->borderLeft() - (borderWidth / 2)) + "px"); style->setProperty(CSSPropertyWidth, String::number(buttonWidth) + "px"); style->setProperty(CSSPropertyHeight, String::number(buttonHeight) + "px"); + style->setProperty(CSSPropertyVisibility, CSSValueVisible); RefPtr<Image> buttonImage = Image::loadPlatformResource("deleteButton"); if (buttonImage->isNull()) @@ -283,8 +284,13 @@ void DeleteButtonController::enable() ASSERT(m_disableStack > 0); if (m_disableStack > 0) m_disableStack--; - if (enabled()) + if (enabled()) { + // Determining if the element is deletable currently depends on style + // because whether something is editable depends on style, so we need + // to recalculate style before calling enclosingDeletableElement. + m_frame->document()->updateRendering(); show(enclosingDeletableElement(m_frame->selection()->selection())); + } } void DeleteButtonController::disable() |