<rdar://problem/
3752791> Dashboard: Need a better solution for control regions
This patch actually collections the regions and converts to absolute coordinates.
Only remaining piece is to pass over the bridge and up the alley to WebKit
UI delegate.
Reviewed by Ken.
* khtml/css/css_valueimpl.h:
(DOM::CSSPrimitiveValueImpl::getDashboardRegionValue):
* khtml/css/cssparser.cpp:
(CSSParser::parseValue):
(CSSParser::parseDashboardRegions):
* khtml/css/cssproperties.c:
* khtml/css/cssproperties.h:
* khtml/css/cssproperties.in:
* khtml/css/cssstyleselector.cpp:
(khtml::CSSStyleSelector::applyProperty):
* khtml/khtmlview.cpp:
(KHTMLView::layout):
* khtml/rendering/render_object.cpp:
(RenderObject::computeDashboardRegions):
(RenderObject::addDashboardRegions):
(RenderObject::collectDashboardRegions):
* khtml/rendering/render_object.h:
(khtml::DashboardRegionValue::operator==):
* khtml/rendering/render_style.cpp:
* khtml/rendering/render_style.h:
(khtml::StyleDashboardRegion::):
(khtml::RenderStyle::dashboardRegions):
(khtml::RenderStyle::setDashboardRegion):
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::DocumentImpl):
(DocumentImpl::updateLayout):
(DocumentImpl::acceptsEditingFocus):
(DocumentImpl::dashboardRegions):
(DocumentImpl::setDashboardRegions):
* khtml/xml/dom_docimpl.h:
(DOM::DocumentImpl::hasDashboardRegions):
(DOM::DocumentImpl::setHasDashboardRegions):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7623
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-09-21 Richard Williamson <rjw@apple.com>
+
+ Part 2 of the feature requested in
+ <rdar://problem/3752791> Dashboard: Need a better solution for control regions
+
+ This patch actually collections the regions and converts to absolute coordinates.
+ Only remaining piece is to pass over the bridge and up the alley to WebKit
+ UI delegate.
+
+ Reviewed by Ken.
+
+ * khtml/css/css_valueimpl.h:
+ (DOM::CSSPrimitiveValueImpl::getDashboardRegionValue):
+ * khtml/css/cssparser.cpp:
+ (CSSParser::parseValue):
+ (CSSParser::parseDashboardRegions):
+ * khtml/css/cssproperties.c:
+ * khtml/css/cssproperties.h:
+ * khtml/css/cssproperties.in:
+ * khtml/css/cssstyleselector.cpp:
+ (khtml::CSSStyleSelector::applyProperty):
+ * khtml/khtmlview.cpp:
+ (KHTMLView::layout):
+ * khtml/rendering/render_object.cpp:
+ (RenderObject::computeDashboardRegions):
+ (RenderObject::addDashboardRegions):
+ (RenderObject::collectDashboardRegions):
+ * khtml/rendering/render_object.h:
+ (khtml::DashboardRegionValue::operator==):
+ * khtml/rendering/render_style.cpp:
+ * khtml/rendering/render_style.h:
+ (khtml::StyleDashboardRegion::):
+ (khtml::RenderStyle::dashboardRegions):
+ (khtml::RenderStyle::setDashboardRegion):
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::DocumentImpl):
+ (DocumentImpl::updateLayout):
+ (DocumentImpl::acceptsEditingFocus):
+ (DocumentImpl::dashboardRegions):
+ (DocumentImpl::setDashboardRegions):
+ * khtml/xml/dom_docimpl.h:
+ (DOM::DocumentImpl::hasDashboardRegions):
+ (DOM::DocumentImpl::setHasDashboardRegions):
+
2004-09-21 John Sullivan <sullivan@apple.com>
Reviewed by Darin.
return ( m_type != CSSPrimitiveValue::CSS_RGBCOLOR ? 0 : m_value.rgbcolor );
}
+#if APPLE_CHANGES
+ DashboardRegionImpl *getDashboardRegionValue () const {
+ return ( m_type != CSSPrimitiveValue::CSS_DASHBOARD_REGION ? 0 : m_value.region );
+ }
+#endif
+
virtual bool isPrimitiveValue() const { return true; }
virtual unsigned short cssValueType() const;
CSSPrimitiveValueImpl *m_left;
};
+#if APPLE_CHANGES
class DashboardRegionImpl : public RectImpl {
public:
DashboardRegionImpl() : RectImpl(), m_next(0), m_isCircle(0), m_isRectangle(0) { };
m_next = next;
};
- void setLabel(const QString &label) {
- m_label = label;
- };
-
public:
DashboardRegionImpl *m_next;
QString m_label;
unsigned int m_isCircle:1;
unsigned int m_isRectangle:1;
};
+#endif
class CSSImageValueImpl : public CSSPrimitiveValueImpl, public khtml::CachedObjectClient
{
return parseShape( propId, important );
break;
+#if APPLE_CHANGES
case CSS_PROP__APPLE_DASHBOARD_REGION: // <dashboard-region-circle> | <dashboard-region-rectangle>
if ( value->unit == Value::Function )
return parseDashboardRegions( propId, important );
break;
+#endif
/* Start of supported CSS properties with validation. This is needed for parseShortHand to work
* correctly and allows optimization in khtml::applyRule(..)
return args->current();
}
+#if APPLE_CHANGES
bool CSSParser::parseDashboardRegions( int propId, bool important )
{
bool valid = true;
break;
}
- region->setLabel (qString(arg->string));
+ region->m_label = qString(arg->string);
// Next four arguments must be offset numbers
int i;
return valid;
}
+#endif
bool CSSParser::parseShape( int propId, bool important )
{
"text-underline-style",
"text-underline-width",
"-apple-text-size-adjust",
+"-apple-dashboard-region",
"top",
"unicode-bidi",
"-khtml-user-drag",
"scrollbar-track-color",
"scrollbar-arrow-color",
"-khtml-flow-mode",
-"-apple-dashboard-region",
0
};
DOMString getPropertyName(unsigned short id)
#define CSS_PROP_TEXT_UNDERLINE_STYLE 117
#define CSS_PROP_TEXT_UNDERLINE_WIDTH 118
#define CSS_PROP__APPLE_TEXT_SIZE_ADJUST 119
-#define CSS_PROP_TOP 120
-#define CSS_PROP_UNICODE_BIDI 121
-#define CSS_PROP__KHTML_USER_DRAG 122
-#define CSS_PROP__KHTML_USER_MODIFY 123
-#define CSS_PROP__KHTML_USER_SELECT 124
-#define CSS_PROP_VERTICAL_ALIGN 125
-#define CSS_PROP_VISIBILITY 126
-#define CSS_PROP_WHITE_SPACE 127
-#define CSS_PROP_WIDOWS 128
-#define CSS_PROP_WIDTH 129
-#define CSS_PROP_WORD_SPACING 130
-#define CSS_PROP_Z_INDEX 131
-#define CSS_PROP_BACKGROUND 132
-#define CSS_PROP_BORDER 133
-#define CSS_PROP_BORDER_COLOR 134
-#define CSS_PROP_BORDER_STYLE 135
-#define CSS_PROP_BORDER_TOP 136
-#define CSS_PROP_BORDER_RIGHT 137
-#define CSS_PROP_BORDER_BOTTOM 138
-#define CSS_PROP_BORDER_LEFT 139
-#define CSS_PROP_BORDER_WIDTH 140
-#define CSS_PROP_FONT 141
-#define CSS_PROP_LIST_STYLE 142
-#define CSS_PROP_MARGIN 143
-#define CSS_PROP_OUTLINE 144
-#define CSS_PROP_PADDING 145
-#define CSS_PROP_SCROLLBAR_FACE_COLOR 146
-#define CSS_PROP_SCROLLBAR_SHADOW_COLOR 147
-#define CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR 148
-#define CSS_PROP_SCROLLBAR_3DLIGHT_COLOR 149
-#define CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR 150
-#define CSS_PROP_SCROLLBAR_TRACK_COLOR 151
-#define CSS_PROP_SCROLLBAR_ARROW_COLOR 152
-#define CSS_PROP__KHTML_FLOW_MODE 153
-#define CSS_PROP__APPLE_DASHBOARD_REGION 154
+#define CSS_PROP__APPLE_DASHBOARD_REGION 120
+#define CSS_PROP_TOP 121
+#define CSS_PROP_UNICODE_BIDI 122
+#define CSS_PROP__KHTML_USER_DRAG 123
+#define CSS_PROP__KHTML_USER_MODIFY 124
+#define CSS_PROP__KHTML_USER_SELECT 125
+#define CSS_PROP_VERTICAL_ALIGN 126
+#define CSS_PROP_VISIBILITY 127
+#define CSS_PROP_WHITE_SPACE 128
+#define CSS_PROP_WIDOWS 129
+#define CSS_PROP_WIDTH 130
+#define CSS_PROP_WORD_SPACING 131
+#define CSS_PROP_Z_INDEX 132
+#define CSS_PROP_BACKGROUND 133
+#define CSS_PROP_BORDER 134
+#define CSS_PROP_BORDER_COLOR 135
+#define CSS_PROP_BORDER_STYLE 136
+#define CSS_PROP_BORDER_TOP 137
+#define CSS_PROP_BORDER_RIGHT 138
+#define CSS_PROP_BORDER_BOTTOM 139
+#define CSS_PROP_BORDER_LEFT 140
+#define CSS_PROP_BORDER_WIDTH 141
+#define CSS_PROP_FONT 142
+#define CSS_PROP_LIST_STYLE 143
+#define CSS_PROP_MARGIN 144
+#define CSS_PROP_OUTLINE 145
+#define CSS_PROP_PADDING 146
+#define CSS_PROP_SCROLLBAR_FACE_COLOR 147
+#define CSS_PROP_SCROLLBAR_SHADOW_COLOR 148
+#define CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR 149
+#define CSS_PROP_SCROLLBAR_3DLIGHT_COLOR 150
+#define CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR 151
+#define CSS_PROP_SCROLLBAR_TRACK_COLOR 152
+#define CSS_PROP_SCROLLBAR_ARROW_COLOR 153
+#define CSS_PROP__KHTML_FLOW_MODE 154
#define CSS_PROP_MAX CSS_PROP_Z_INDEX
#define CSS_PROP_TOTAL 155
text-underline-style
text-underline-width
-apple-text-size-adjust
+-apple-dashboard-region
top
unicode-bidi
-khtml-user-drag
scrollbar-track-color
scrollbar-arrow-color
-khtml-flow-mode
--apple-dashboard-region
style->setTextSizeAdjust(primitiveValue->getIdent() == CSS_VAL_AUTO);
fontDirty = true;
break;
- }
+ }
+ case CSS_PROP__APPLE_DASHBOARD_REGION: {
+ if (!primitiveValue)
+ return;
+ DashboardRegionImpl *region = primitiveValue->getDashboardRegionValue();
+ if (!region)
+ return;
+
+ DashboardRegionImpl *first = region;
+ while (region) {
+ Length top = convertToLength (region->top(), style, paintDeviceMetrics );
+ Length right = convertToLength (region->right(), style, paintDeviceMetrics );
+ Length bottom = convertToLength (region->bottom(), style, paintDeviceMetrics );
+ Length left = convertToLength (region->left(), style, paintDeviceMetrics );
+ if (region->m_isCircle) {
+ style->setDashboardRegion (StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true);
+ }
+ else if (region->m_isRectangle) {
+ style->setDashboardRegion (StyleDashboardRegion::Rectangle, region->m_label, top, right, bottom, left, region == first ? false : true);
+ }
+ region = region->m_next;
+ }
+
+ element->getDocument()->setHasDashboardRegions (true);
+
+ break;
+ }
#endif
default:
root->document()->getOrCreateAccObjectCache()->postNotification(root, "AXLayoutComplete");
#endif
+#if APPLE_CHANGES
+ if (document->hasDashboardRegions()) {
+ QValueList<DashboardRegionValue> newRegions = document->renderer()->computeDashboardRegions();
+ QValueList<DashboardRegionValue> currentRegions = document->dashboardRegions();
+ if (!(newRegions == currentRegions)) {
+ document->setDashboardRegions(newRegions);
+ // FIXME: Pass the regions on up to webkit.
+ }
+ }
+#endif
+
if (root->needsLayout()) {
//qDebug("needs layout, delaying repaint");
scheduleRelayout();
for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
curr->updateWidgetPositions();
}
+
+QValueList<DashboardRegionValue> RenderObject::computeDashboardRegions()
+{
+ QValueList<DashboardRegionValue> regions;
+ collectDashboardRegions(regions);
+ return regions;
+}
+
+void RenderObject::addDashboardRegions (QValueList<DashboardRegionValue>& regions)
+{
+ // Convert the style regions to absolute coordinates.
+ QValueList<StyleDashboardRegion> styleRegions = style()->dashboardRegions();
+ if (styleRegions.count() > 0) {
+ uint i, count = styleRegions.count();
+ for (i = 0; i < count; i++){
+ StyleDashboardRegion styleRegion = styleRegions[i];
+
+ int x, y;
+ absolutePosition (x, y);
+
+ int w = width() + marginLeft() + marginRight();
+ int h = height() + marginTop() + marginBottom();
+
+ DashboardRegionValue region;
+ region.label = styleRegion.label;
+ region.bounds = QRect (
+ x + styleRegion.offset.left.value,
+ y + styleRegion.offset.top.value,
+ w - styleRegion.offset.left.value - styleRegion.offset.right.value,
+ h - styleRegion.offset.top.value - styleRegion.offset.bottom.value);
+ region.type = styleRegion.type;
+
+ regions.append (region);
+ }
+ }
+}
+
+void RenderObject::collectDashboardRegions (QValueList<DashboardRegionValue>& regions)
+{
+ addDashboardRegions (regions);
+ for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
+ curr->collectDashboardRegions(regions);
+ }
+}
+
#endif
void RenderObject::collectBorders(QValueList<CollapsedBorderValue>& borderStyles)
class InlineFlowBox;
class CollapsedBorderValue;
+#if APPLE_CHANGES
+struct DashboardRegionValue
+{
+ QString label;
+ QRect bounds;
+ int type;
+
+ bool operator==(const DashboardRegionValue& o) const
+ {
+ return type == o.type && bounds == o.bounds && label == o.label;
+ }
+};
+#endif
+
+
/**
* Base Class for all rendering tree objects.
*/
#if APPLE_CHANGES
// Called recursively to update the absolute positions of all widgets.
virtual void updateWidgetPositions();
+
+ QValueList<DashboardRegionValue> RenderObject::computeDashboardRegions();
+ void addDashboardRegions (QValueList<DashboardRegionValue>& regions);
+ void collectDashboardRegions (QValueList<DashboardRegionValue>& regions);
#endif
// does a query on the rendertree and finds the innernode
z_auto == o.z_auto;
}
+
StyleVisualData::StyleVisualData()
: hasClip(false),
textDecoration(RenderStyle::initialTextDecoration()),
bool z_auto : 1;
};
+//------------------------------------------------
+// Dashboard region attributes. Not inherited.
+
+#if APPLE_CHANGES
+struct StyleDashboardRegion
+{
+ QString label;
+ LengthBox offset;
+ int type;
+
+ enum {
+ None,
+ Circle,
+ Rectangle
+ };
+};
+#endif
+
//------------------------------------------------
// Random visual rendering model attributes. Not inherited.
DataRef<StyleBackgroundData> background;
DataRef<StyleSurroundData> surround;
DataRef<StyleCSS3NonInheritedData> css3NonInheritedData;
-
+
+#if APPLE_CHANGES
+ QValueList<StyleDashboardRegion> m_dashboardRegions;
+#endif
+
// inherited attributes
DataRef<StyleCSS3InheritedData> css3InheritedData;
DataRef<StyleInheritedData> inherited;
void setMinHeight(Length v) { SET_VAR(box,min_height,v) }
void setMaxHeight(Length v) { SET_VAR(box,max_height,v) }
+#if APPLE_CHANGES
+ QValueList<StyleDashboardRegion> dashboardRegions() { return m_dashboardRegions; }
+ void setDashboardRegion (int type, QString label, Length t, Length r, Length b, Length l, bool append) {
+ StyleDashboardRegion region;
+ region.label = label;
+ region.offset.top = t;
+ region.offset.right = r;
+ region.offset.bottom = b;
+ region.offset.left = l;
+ region.type = type;
+ if (!append) {
+ m_dashboardRegions.clear ();
+ }
+ m_dashboardRegions.append (region);
+ }
+#endif
+
void resetBorderTop() { SET_VAR(surround, border.top, BorderValue()) }
void resetBorderRight() { SET_VAR(surround, border.right, BorderValue()) }
void resetBorderBottom() { SET_VAR(surround, border.bottom, BorderValue()) }
#include "rendering/render_canvas.h"
#include "rendering/render_frames.h"
#include "rendering/render_image.h"
+#include "rendering/render_object.h"
#include "render_arena.h"
#include "khtmlview.h"
, m_inPageCache(false), m_savedRenderer(0)
, m_passwordFields(0), m_secureForms(0)
, m_decoder(0), m_createRenderers(true)
+ , m_hasDashboardRegions(false)
#endif
{
document->doc = this;
updateRendering();
// Only do a layout if changes have occurred that make it necessary.
- if (m_view && renderer() && renderer()->needsLayout())
+ if (m_view && renderer() && renderer()->needsLayout()) {
m_view->layout();
+ }
m_ignorePendingStylesheets = oldIgnore;
}
return part()->shouldBeginEditing(range);
}
+QValueList<DashboardRegionValue> DocumentImpl::dashboardRegions() const
+{
+ return m_dashboardRegions;
+}
+
+void DocumentImpl::setDashboardRegions (QValueList<DashboardRegionValue>& regions)
+{
+ m_dashboardRegions = regions;
+}
+
#endif
bool DocumentImpl::setFocusNode(NodeImpl *newFocusNode)
class RenderImage;
class Tokenizer;
class XMLHandler;
+#if APPLE_CHANGES
+ struct DashboardRegionValue;
+#endif
}
#ifndef KHTML_NO_XBL
void setDecoder(khtml::Decoder *);
khtml::Decoder *decoder() const { return m_decoder; }
+ bool hasDashboardRegions () const { return m_hasDashboardRegions; }
+ void setHasDashboardRegions (bool f) { m_hasDashboardRegions = f; }
+ QValueList<khtml::DashboardRegionValue> dashboardRegions() const;
+ void setDashboardRegions (QValueList<khtml::DashboardRegionValue>& regions);
+
private:
JSEditor *jsEditor();
bool m_accessKeyDictValid;
bool m_createRenderers;
+
+ QValueList<khtml::DashboardRegionValue> m_dashboardRegions;
+ bool m_hasDashboardRegions;
#endif
};